From 8e52f3ff03eeaac35a9d7a792cdedff6a92434b4 Mon Sep 17 00:00:00 2001 From: Christian Cunningham Date: Tue, 21 Dec 2021 19:37:52 -0800 Subject: Move .a.h to .h --- src/cpu/atomic/swap.a.h | 36 ------------------------------------ src/cpu/atomic/swap.h | 36 ++++++++++++++++++++++++++++++++++++ src/util/mutex.c | 2 +- 3 files changed, 37 insertions(+), 37 deletions(-) delete mode 100644 src/cpu/atomic/swap.a.h create mode 100644 src/cpu/atomic/swap.h (limited to 'src') diff --git a/src/cpu/atomic/swap.a.h b/src/cpu/atomic/swap.a.h deleted file mode 100644 index 5e8ff57..0000000 --- a/src/cpu/atomic/swap.a.h +++ /dev/null @@ -1,36 +0,0 @@ -#ifndef CPU_ATOMIC_SWAP_A_H -#define CPU_ATOMIC_SWAP_A_H -#include "../../util/mutex.h" - -/// https://stackoverflow.com/questions/16329123/use-of-strexeq-instead-of-strex-for-spinlock-implementation-in-arm -/// https://elixir.bootlin.com/linux/v4.9/source/arch/arm/include/asm/spinlock.h -/// https://elixir.bootlin.com/linux/v4.9/source/arch/arm/include/asm/spinlock_types.h#L23 -/// https://www.cs.uic.edu/~jbell/CourseNotes/OperatingSystems/3_Processes.html - -static inline void atm_lock(unsigned long pid, unsigned long* addr) { - unsigned long tmp, current_lock_value; - asm volatile( -"1: ldrex %0, [%3]\n" -" cmp %0, #0\n" -" wfene\n" -" strexeq %1, %2, [%3]\n" -" teq %1, #0\n" -" bne 1b\n" -" dmb" - : "=&r" (current_lock_value), "=&r" (tmp) - : "r" (pid), "r" (addr) - : "cc"); -} - -static inline void atm_release(unsigned long* addr) { - unsigned long cleared = NULL_PID; - asm volatile( -" dmb\n" -" str %0, [%1]\n" -" dsb\n" -" sev" - :: "r" (cleared), "r" (addr) - : "cc"); -} - -#endif diff --git a/src/cpu/atomic/swap.h b/src/cpu/atomic/swap.h new file mode 100644 index 0000000..5e8ff57 --- /dev/null +++ b/src/cpu/atomic/swap.h @@ -0,0 +1,36 @@ +#ifndef CPU_ATOMIC_SWAP_A_H +#define CPU_ATOMIC_SWAP_A_H +#include "../../util/mutex.h" + +/// https://stackoverflow.com/questions/16329123/use-of-strexeq-instead-of-strex-for-spinlock-implementation-in-arm +/// https://elixir.bootlin.com/linux/v4.9/source/arch/arm/include/asm/spinlock.h +/// https://elixir.bootlin.com/linux/v4.9/source/arch/arm/include/asm/spinlock_types.h#L23 +/// https://www.cs.uic.edu/~jbell/CourseNotes/OperatingSystems/3_Processes.html + +static inline void atm_lock(unsigned long pid, unsigned long* addr) { + unsigned long tmp, current_lock_value; + asm volatile( +"1: ldrex %0, [%3]\n" +" cmp %0, #0\n" +" wfene\n" +" strexeq %1, %2, [%3]\n" +" teq %1, #0\n" +" bne 1b\n" +" dmb" + : "=&r" (current_lock_value), "=&r" (tmp) + : "r" (pid), "r" (addr) + : "cc"); +} + +static inline void atm_release(unsigned long* addr) { + unsigned long cleared = NULL_PID; + asm volatile( +" dmb\n" +" str %0, [%1]\n" +" dsb\n" +" sev" + :: "r" (cleared), "r" (addr) + : "cc"); +} + +#endif diff --git a/src/util/mutex.c b/src/util/mutex.c index 98dc849..9cfdf6c 100644 --- a/src/util/mutex.c +++ b/src/util/mutex.c @@ -1,5 +1,5 @@ #include "../util/mutex.h" -#include "../cpu/atomic/swap.a.h" +#include "../cpu/atomic/swap.h" unsigned char lock_mutex(struct Mutex* m, unsigned long pid) { if (m->pid == NULL_PID) { -- cgit v1.2.1