aboutsummaryrefslogtreecommitdiff
path: root/PL0_test.c
diff options
context:
space:
mode:
authorWojtek Kosior <kwojtus@protonmail.com>2019-11-12 18:23:39 +0100
committerWojtek Kosior <kwojtus@protonmail.com>2019-11-12 18:23:39 +0100
commit11541f1d1eaaefebd6d01b42e92a65606e4bc382 (patch)
treeb36a67dd6ab8e6e7804e1ff9daf9a683b1b76269 /PL0_test.c
parent533976feb8ea79c15fa905642d75adb58a0e6996 (diff)
downloadrpi-MMU-example-11541f1d1eaaefebd6d01b42e92a65606e4bc382.tar.gz
rpi-MMU-example-11541f1d1eaaefebd6d01b42e92a65606e4bc382.zip
some ugly instructions (I wouldn't call this code), that switch to PL0 and check that MMU really works here - it's temporary, don't merge! (merge commit b4 PL0_test.c was added, if you really want)
Diffstat (limited to 'PL0_test.c')
-rw-r--r--PL0_test.c18
1 files changed, 17 insertions, 1 deletions
diff --git a/PL0_test.c b/PL0_test.c
index 1a3d49d..7609294 100644
--- a/PL0_test.c
+++ b/PL0_test.c
@@ -1,9 +1,25 @@
#include "uart.h"
+#include "psr.h"
void PL0_main(void)
{
- uart_puts("hello PL0!\n\r");
+ uart_puts("hello PL0! Switching to user mode!\n\r");
+ asm("cps #0b10000\n\r"
+ "isb" ::: "memory");
+
+ // if all went correct, Success! gets printed
+ uart_puts("Success!\n\r");
+
+ // if we're indeed i PL0, we should crash now, when trying to access
+ // memory we're not allowed to
+ char first_kernel_byte[2];
+
+ first_kernel_byte[0] = *(char*) ((uint32_t) 0x8000);
+ first_kernel_byte[1] = '\0';
+
+ uart_puts(first_kernel_byte);
+
while (1)
{
char c;