1/* 2 * Copyright (c) 2014 Google Inc. All rights reserved 3 * 4 * Use of this source code is governed by a MIT-style 5 * license that can be found in the LICENSE file or at 6 * https://opensource.org/licenses/MIT 7 */ 8#include <lk/asm.h> 9 10.text 11 12FUNCTION(arch_spin_trylock) 13 mov x2, x0 14 mov x1, #1 15 ldaxr x0, [x2] 16 cbnz x0, 1f 17 stxr w0, x1, [x2] 181: 19 ret 20 21FUNCTION(arch_spin_lock) 22 mov x1, #1 23 sevl 241: 25 wfe 26 ldaxr x2, [x0] 27 cbnz x2, 1b 28 stxr w2, x1, [x0] 29 cbnz w2, 1b 30 ret 31 32FUNCTION(arch_spin_unlock) 33 stlr xzr, [x0] 34 ret 35