aboutsummaryrefslogtreecommitdiff
path: root/psr.h
diff options
context:
space:
mode:
authorWojtek Kosior <kwojtus@protonmail.com>2019-12-28 15:55:29 +0100
committerWojtek Kosior <kwojtus@protonmail.com>2019-12-28 15:55:29 +0100
commitc374eaacbc0d16983bbd1112fefa74dbe88e1e53 (patch)
treec6930675e0200a4aed724fd65947853f2b4f274f /psr.h
parent7062b101197c03c7f4806d83b8d79cf34d3b6a42 (diff)
downloadrpi-MMU-example-c374eaacbc0d16983bbd1112fefa74dbe88e1e53.tar.gz
rpi-MMU-example-c374eaacbc0d16983bbd1112fefa74dbe88e1e53.zip
use ldm instruction instead of libkernel for entering user mode; get rid of libkernel (no longer needed)
Diffstat (limited to 'psr.h')
-rw-r--r--psr.h15
1 files changed, 15 insertions, 0 deletions
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