From c374eaacbc0d16983bbd1112fefa74dbe88e1e53 Mon Sep 17 00:00:00 2001 From: Wojtek Kosior Date: Sat, 28 Dec 2019 15:55:29 +0100 Subject: use ldm instruction instead of libkernel for entering user mode; get rid of libkernel (no longer needed) --- psr.h | 15 +++++++++++++++ 1 file changed, 15 insertions(+) (limited to 'psr.h') diff --git a/psr.h b/psr.h index 9809fc4..b2adafb 100644 --- a/psr.h +++ b/psr.h @@ -64,4 +64,19 @@ inline static PSR_t read_CPSR(void) return CPSR; } +inline static PSR_t read_SPSR(void) +{ + PSR_t SPSR; + // get content of saved program status register + asm("mrs %0, spsr" : "=r" (SPSR.raw) :: "memory"); + + return SPSR; +} + +inline static void write_SPSR(PSR_t SPSR) +{ + // set content of saved program status register + asm("msr spsr, %0" :: "r" (SPSR.raw)); +} + #endif // PSR_H -- cgit v1.2.3 From 42636b818a2f8e1b14917e6060fc149f39987299 Mon Sep 17 00:00:00 2001 From: Wojtek Kosior Date: Tue, 31 Dec 2019 18:59:17 +0100 Subject: add cpsr-writing function --- psr.h | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'psr.h') diff --git a/psr.h b/psr.h index b2adafb..5efc6d9 100644 --- a/psr.h +++ b/psr.h @@ -64,6 +64,12 @@ inline static PSR_t read_CPSR(void) return CPSR; } +inline static void write_CPSR(PSR_t CPSR) +{ + // set content of current program status register + asm("msr cpsr, %0" :: "r" (CPSR.raw) : "memory"); +} + inline static PSR_t read_SPSR(void) { PSR_t SPSR; -- cgit v1.2.3