blob: 7f6d0c6aa0bfc642c9cb3786633fd129638f416b [file] [log] [blame]
Sandrine Bailleux3cd87d72018-10-09 11:12:55 +02001/*
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
13func init_spinlock
14 str wzr, [x0]
15 ret
16endfunc init_spinlock
17
18func spin_lock
19 mov w2, #1
20 sevl
21l1: wfe
22l2: ldaxr w1, [x0]
23 cbnz w1, l1
24 stxr w1, w2, [x0]
25 cbnz w1, l2
26 ret
27endfunc spin_lock
28
29
30func spin_unlock
31 stlr wzr, [x0]
32 ret
33endfunc spin_unlock