Soby Mathew | 748be1d | 2016-05-05 14:10:46 +0100 | [diff] [blame] | 1 | /* |
2 | * Copyright (c) 2016, ARM Limited and Contributors. All rights reserved. | ||||
3 | * | ||||
dp-arm | fa3cf0b | 2017-05-03 09:38:09 +0100 | [diff] [blame] | 4 | * SPDX-License-Identifier: BSD-3-Clause |
Soby Mathew | 748be1d | 2016-05-05 14:10:46 +0100 | [diff] [blame] | 5 | */ |
6 | |||||
7 | #include <asm_macros.S> | ||||
8 | |||||
9 | .globl spin_lock | ||||
10 | .globl spin_unlock | ||||
11 | |||||
12 | |||||
13 | func spin_lock | ||||
14 | mov r2, #1 | ||||
15 | 1: | ||||
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 | ||||
24 | endfunc spin_lock | ||||
25 | |||||
26 | |||||
27 | func spin_unlock | ||||
28 | mov r1, #0 | ||||
29 | stl r1, [r0] | ||||
30 | bx lr | ||||
31 | endfunc spin_unlock |