25 __asm__
volatile (
"dmb");
29#if defined(__ARM_ARCH_7M__) || defined(__ARM_ARCH_7EM__)
31uint32_t __ldrex(
volatile uint32_t *addr)
34 __asm__
volatile (
"ldrex %0, [%1]" :
"=r" (res) :
"r" (addr));
38uint32_t __strex(uint32_t val,
volatile uint32_t *addr)
41 __asm__
volatile (
"strex %0, %2, [%1]"
42 :
"=&r" (res) :
"r" (addr),
"r" (val));
46void mutex_lock(mutex_t *m)
48 while (!mutex_trylock(m));
52uint32_t mutex_trylock(mutex_t *m)
57 if (__ldrex(m) == MUTEX_UNLOCKED) {
59 status = __strex(MUTEX_LOCKED, m);
70void mutex_unlock(mutex_t *m)