Test initialisation of MUIA_List_AdjustWidth and MUIA_List_AdjustHeight, and
[AROS.git] / arch / arm-native / kernel / spintrylock.c
blob6a7d4bb5e89c65c0949a58d10f1e7088f858f509
1 /*
2 Copyright © 2015, The AROS Development Team. All rights reserved.
3 $Id$
4 */
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, 42, Kernel)
21 AROS_LIBFUNC_INIT
23 unsigned long lock_value, tmp;
25 if (mode == SPINLOCK_MODE_WRITE)
29 asm volatile(
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)
35 : "cc"
37 } while(tmp);
39 if (lock_value == 0)
41 dmb();
42 return lock;
44 else
45 return NULL;
47 else
51 asm volatile(
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)
57 : "cc"
59 } while(tmp);
61 if (lock_value < 0x80000000)
63 dmb();
64 return lock;
66 else
67 return NULL;
70 AROS_LIBFUNC_EXIT