blob: bc77bc9c4d9dfda1ad14706c54f5d3c12acd7c30 [file] [log] [blame]
Soby Mathew748be1d2016-05-05 14:10:46 +01001/*
2 * Copyright (c) 2016, ARM Limited and Contributors. All rights reserved.
3 *
dp-armfa3cf0b2017-05-03 09:38:09 +01004 * SPDX-License-Identifier: BSD-3-Clause
Soby Mathew748be1d2016-05-05 14:10:46 +01005 */
6
7#include <asm_macros.S>
8
9 .globl spin_lock
10 .globl spin_unlock
11
12
13func spin_lock
14 mov r2, #1
151:
16 ldrex r1, [r0]
17 cmp r1, #0
18 wfene
19 strexeq r1, r2, [r0]
20 cmpeq r1, #0
21 bne 1b
22 dmb
23 bx lr
24endfunc spin_lock
25
26
27func spin_unlock
28 mov r1, #0
29 stl r1, [r0]
30 bx lr
31endfunc spin_unlock