2 Copyright © 2015, The AROS Development Team. All rights reserved.
6 #include <aros/types/spinlock_s.h>
7 #include <aros/kernel.h>
8 #include <aros/libcall.h>
10 #include <kernel_base.h>
12 #include <proto/kernel.h>
14 AROS_LH1(void, KrnSpinUnLock
,
15 AROS_LHA(spinlock_t
*, lock
, A0
),
16 struct KernelBase
*, KernelBase
, 44, Kernel
)
24 * Are we releasing a write lock? Just zero out the value. Also send event so that other cores waiting for lock
27 if (lock
->lock
& 0x80000000)
34 unsigned long lock_value
, write_result
;
37 "1: ldrex %0, [%2] \n\t" // Read lock value and gain write exclusive lock
38 " sub %0, %0, #1 \n\t" // Decrease lock value
39 " strex %1, %0, [%2] \n\t" // Try to update the lock value
40 " teq %1, #0 \n\t" // test if write succeeded
41 " bne 1b \n\t" // Try again if write failed
42 :"=&r"(lock_value
), "=&r"(write_result
)
47 /* Send event to other cores if lock is free */