diff options
author | Wojtek Kosior <kwojtus@protonmail.com> | 2019-12-17 16:02:33 +0100 |
---|---|---|
committer | Wojtek Kosior <kwojtus@protonmail.com> | 2019-12-17 16:02:33 +0100 |
commit | 24df4b958832cf7a42a82a205a536d8bcc02ab35 (patch) | |
tree | fd9e00676b01aa86bbd8fb8a6b7eb50c8b72982e | |
parent | 1a75b3f08e28876896ea90f85b1e8101ef55dd5d (diff) | |
download | rpi-MMU-example-24df4b958832cf7a42a82a205a536d8bcc02ab35.tar.gz rpi-MMU-example-24df4b958832cf7a42a82a205a536d8bcc02ab35.zip |
add forgotten libkernel.c
-rw-r--r-- | libkernel.c | 12 |
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(); +} |