diff options
Diffstat (limited to 'PL0_test.c')
-rw-r--r-- | PL0_test.c | 34 |
1 files changed, 34 insertions, 0 deletions
diff --git a/PL0_test.c b/PL0_test.c new file mode 100644 index 0000000..7609294 --- /dev/null +++ b/PL0_test.c @@ -0,0 +1,34 @@ +#include "uart.h" +#include "psr.h" + +void PL0_main(void) +{ + 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; + switch(c = uart_getc()) + { + case '\r': + uart_putc('\n'); + default: + uart_putc(c); + } + } +} |