xref: /rk3399_ARM-atf/lib/locks/exclusive/aarch32/spinlock.S (revision 82cb2c1ad9897473743f08437d0a3995bed561b9)
1e33b78a6SSoby Mathew/*
2e33b78a6SSoby Mathew * Copyright (c) 2016, ARM Limited and Contributors. All rights reserved.
3e33b78a6SSoby Mathew *
4*82cb2c1aSdp-arm * SPDX-License-Identifier: BSD-3-Clause
5e33b78a6SSoby Mathew */
6e33b78a6SSoby Mathew
7e33b78a6SSoby Mathew#include <asm_macros.S>
8e33b78a6SSoby Mathew
9e33b78a6SSoby Mathew	.globl	spin_lock
10e33b78a6SSoby Mathew	.globl	spin_unlock
11e33b78a6SSoby Mathew
12e33b78a6SSoby Mathew
13e33b78a6SSoby Mathewfunc spin_lock
14e33b78a6SSoby Mathew	mov	r2, #1
15e33b78a6SSoby Mathew1:
16e33b78a6SSoby Mathew	ldrex	r1, [r0]
17e33b78a6SSoby Mathew	cmp	r1, #0
18e33b78a6SSoby Mathew	wfene
19e33b78a6SSoby Mathew	strexeq	r1, r2, [r0]
20e33b78a6SSoby Mathew	cmpeq	r1, #0
21e33b78a6SSoby Mathew	bne	1b
22e33b78a6SSoby Mathew	dmb
23e33b78a6SSoby Mathew	bx	lr
24e33b78a6SSoby Mathewendfunc spin_lock
25e33b78a6SSoby Mathew
26e33b78a6SSoby Mathew
27e33b78a6SSoby Mathewfunc spin_unlock
28e33b78a6SSoby Mathew	mov	r1, #0
29e33b78a6SSoby Mathew	stl	r1, [r0]
30e33b78a6SSoby Mathew	bx	lr
31e33b78a6SSoby Mathewendfunc spin_unlock
32