aboutsummaryrefslogtreecommitdiff
path: root/libkernel.c
diff options
context:
space:
mode:
authorWojtek Kosior <kwojtus@protonmail.com>2019-12-17 16:02:33 +0100
committerWojtek Kosior <kwojtus@protonmail.com>2019-12-17 16:02:33 +0100
commit24df4b958832cf7a42a82a205a536d8bcc02ab35 (patch)
treefd9e00676b01aa86bbd8fb8a6b7eb50c8b72982e /libkernel.c
parent1a75b3f08e28876896ea90f85b1e8101ef55dd5d (diff)
downloadrpi-MMU-example-24df4b958832cf7a42a82a205a536d8bcc02ab35.tar.gz
rpi-MMU-example-24df4b958832cf7a42a82a205a536d8bcc02ab35.zip
add forgotten libkernel.c
Diffstat (limited to 'libkernel.c')
-rw-r--r--libkernel.c12
1 files changed, 12 insertions, 0 deletions
diff --git a/libkernel.c b/libkernel.c
new file mode 100644
index 0000000..0955e0e
--- /dev/null
+++ b/libkernel.c
@@ -0,0 +1,12 @@
+// This is the privileged code, that gets placed somewhere in
+// unprivileged process' address space. It's compiled as relocatable,
+// so it can be loaded at different address for different processes.
+
+void call_unprivileged(void (*address) (void)) {
+ // switch to PL0
+ asm("cps #0b10000\n\r"
+ "isb" ::: "memory");
+
+ // jump to that unprivileged code
+ address();
+}