1/* 2 * Copyright (c) 2008 Travis Geiselbrecht 3 * 4 * Use of this source code is governed by a MIT-style 5 * license that can be found in the LICENSE file or at 6 * https://opensource.org/licenses/MIT 7 */ 8#include <lk/asm.h> 9#include <arch/arm/cores.h> 10 11.text 12 13FUNCTION(arch_spin_trylock) 14 mov r2, r0 15 mov r1, #1 16 ldrex r0, [r2] 17 cmp r0, #0 18 strexeq r0, r1, [r2] 19 dmb 20 bx lr 21 22FUNCTION(arch_spin_lock) 23 mov r1, #1 241: 25 ldrex r2, [r0] 26 cmp r2, #0 27 wfene 28 strexeq r2, r1, [r0] 29 cmpeq r2, #0 30 bne 1b 31 dmb 32 bx lr 33 34FUNCTION(arch_spin_unlock) 35 mov r1, #0 36 dmb 37 str r1, [r0] 38 dsb 39 sev 40 bx lr 41 42/* void arch_idle(); */ 43FUNCTION(arch_idle) 44#if ARM_ARCH_LEVEL >= 7 45 wfi 46#elif ARM_ARCH_LEVEL == 6 47 mov r0, #0 48 mcr p15, 0, r0, c7, c0, #4 49#else 50#error unknown cpu 51#endif 52 bx lr 53 54/* void arm_invalidate_tlb(void) */ 55FUNCTION(arm_invalidate_tlb) 56 mov r0, #0 57 mcr p15, 0, r0, c8, c7, 0 58 bx lr 59 60