diff options
Diffstat (limited to 'src/cpu')
-rw-r--r-- | src/cpu/atomic/swap.h | 40 | ||||
-rw-r--r-- | src/cpu/irq.c | 19 | ||||
-rw-r--r-- | src/cpu/irq.h | 23 |
3 files changed, 10 insertions, 72 deletions
diff --git a/src/cpu/atomic/swap.h b/src/cpu/atomic/swap.h deleted file mode 100644 index cbed62c..0000000 --- a/src/cpu/atomic/swap.h +++ /dev/null @@ -1,40 +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 -/// https://developer.arm.com/documentation/dht0008/a/arm-synchronization-primitives/practical-uses/implementing-a-semaphore?lang=en - -// TODO: Once scheduling works, have a failed lock put thread in waiting state -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/irq.c b/src/cpu/irq.c index 4a96018..28ad886 100644 --- a/src/cpu/irq.c +++ b/src/cpu/irq.c @@ -1,12 +1,13 @@ -#include "../cpu/irq.h" -#include "../drivers/uart.h" -#include "../graphics/drawer.h" -#include "../sys/core.h" -#include "../sys/kernel.h" -#include "../sys/timer.h" -#include "../util/mutex.h" -#include "../util/status.h" -#include "../util/time.h" +#include <cpu/irq.h> +#include <drivers/uart.h> +#include <graphics/drawer.h> +#include <symbols.h> +#include <sys/core.h> +#include <sys/kernel.h> +#include <sys/timer.h> +#include <util/mutex.h> +#include <util/status.h> +#include <util/time.h> void localtest(void); diff --git a/src/cpu/irq.h b/src/cpu/irq.h deleted file mode 100644 index 3b8f085..0000000 --- a/src/cpu/irq.h +++ /dev/null @@ -1,23 +0,0 @@ -#ifndef CPU_IRQ_H -#define CPU_IRQ_H - -static inline void enableirq(void) -{ - asm volatile("cpsie i"); -} -static inline void disableirq(void) -{ - asm volatile("cpsid i"); -} -static inline void enablefiq(void) -{ - asm volatile("cpsie f"); -} -static inline void disablefiq(void) -{ - asm volatile("cpsid f"); -} - -void c_irq_handler(void); - -#endif |