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 <asm/arm/cpu.h>
12 #include <kernel_base.h>
14 #include <proto/kernel.h>
16 AROS_LH2(spinlock_t
*, KrnSpinTryLock
,
17 AROS_LHA(spinlock_t
*, lock
, A0
),
18 AROS_LHA(ULONG
, mode
, D0
),
19 struct KernelBase
*, KernelBase
, 51, Kernel
)
23 unsigned long lock_value
, tmp
;
25 if (mode
== SPINLOCK_MODE_WRITE
)
30 " ldrex %0, [%2] \n\t" // Load the lock value and gain exclusive lock to memory
31 " teq %0, #0 \n\t" // is the value 0? It means the lock was free
32 " strexeq %1, %3, [%2] \n\t" // Store value to memory and check if it succeeded
33 : "=&r"(lock_value
), "=&r"(tmp
)
34 : "r" (&lock
->lock
), "r"(0x80000000), "1"(0)
52 " ldrex %0, [%2] \n\t" // Load lock value and gain exclusive lock to memory
53 " adds %0, %0, #1 \n\t" // Increase the lock value and update conditional bits
54 " strexpl %1, %0, [%2] \n\t" // Store value to memory if positive and check result
55 : "=&r"(lock_value
), "=&r"(tmp
)
56 : "r"(&lock
->lock
), "1"(0)
61 if (lock_value
< 0x80000000)