2 * Copyright (c) 2013-2019, ARM Limited and Contributors. All rights reserved.
4 * SPDX-License-Identifier: BSD-3-Clause
7 #include <asm_macros.S>
13 #if !ARM_ARCH_AT_LEAST(8, 1)
14 #error USE_SPINLOCK_CAS option requires at least an ARMv8.1 platform
18 * When compiled for ARMv8.1 or later, choose spin locks based on Compare and
23 * Acquire lock using Compare and Swap instruction.
25 * Compare for 0 with acquire semantics, and swap 1. If failed to acquire, use
26 * load exclusive semantics to monitor the address and enter WFE.
28 * void spin_lock(spinlock_t *lock);
43 #else /* !USE_SPINLOCK_CAS */
46 * Acquire lock using load-/store-exclusive instruction pair.
48 * void spin_lock(spinlock_t *lock);
61 #endif /* USE_SPINLOCK_CAS */
64 * Release lock previously acquired by spin_lock.
66 * Use store-release to unconditionally clear the spinlock variable.
67 * Store operation generates an event to all cores waiting in WFE
68 * when address is monitored by the global monitor.
70 * void spin_unlock(spinlock_t *lock);