Sandrine Bailleux | 3cd87d7 | 2018-10-09 11:12:55 +0200 | [diff] [blame] | 1 | /* |
2 | * Copyright (c) 2018, Arm Limited. All rights reserved. | ||||
3 | * | ||||
4 | * SPDX-License-Identifier: BSD-3-Clause | ||||
5 | */ | ||||
6 | |||||
7 | #include <asm_macros.S> | ||||
8 | |||||
9 | .globl init_spinlock | ||||
10 | .globl spin_lock | ||||
11 | .globl spin_unlock | ||||
12 | |||||
13 | func init_spinlock | ||||
14 | str wzr, [x0] | ||||
15 | ret | ||||
16 | endfunc init_spinlock | ||||
17 | |||||
18 | func spin_lock | ||||
19 | mov w2, #1 | ||||
20 | sevl | ||||
21 | l1: wfe | ||||
22 | l2: ldaxr w1, [x0] | ||||
23 | cbnz w1, l1 | ||||
24 | stxr w1, w2, [x0] | ||||
25 | cbnz w1, l2 | ||||
26 | ret | ||||
27 | endfunc spin_lock | ||||
28 | |||||
29 | |||||
30 | func spin_unlock | ||||
31 | stlr wzr, [x0] | ||||
32 | ret | ||||
33 | endfunc spin_unlock |