1/* 2 * Copyright (c) 2025 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 10#if WITH_SMP 11 12// void arch_spin_lock(spin_lock_t *lock); 13FUNCTION(arch_spin_lock) 14 mov 4(%esp), %ecx 15 16 mov $1, %edx 170: 18 xor %eax, %eax 19 lock cmpxchg %edx, (%ecx) 20 jz 1f 21 pause 22 jmp 0b 231: 24 ret 25END_FUNCTION(arch_spin_lock) 26 27// int arch_spin_trylock(spin_lock_t *lock); 28FUNCTION(arch_spin_trylock) 29 mov 4(%esp), %ecx 30 31 mov $1, %eax 32 lock xchg %eax, (%ecx) 33 34 ret 35END_FUNCTION(arch_spin_trylock) 36 37// void arch_spin_unlock(spin_lock_t *lock); 38FUNCTION(arch_spin_unlock) 39 mov 4(%esp), %ecx 40 movl $0, (%ecx) 41 ret 42END_FUNCTION(arch_spin_unlock) 43 44#endif // WITH_SMP