From a910d10349593fce9f5f28f0de4f27ba85cd7df2 Mon Sep 17 00:00:00 2001 From: Wojtek Kosior Date: Sat, 28 Dec 2019 23:25:05 +0100 Subject: enter and exit supervisor call (+ fixed jumping to PL0 for the first time - setting sp was broken there) --- PL0_test.c | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) (limited to 'PL0_test.c') diff --git a/PL0_test.c b/PL0_test.c index 32addf8..2e008a2 100644 --- a/PL0_test.c +++ b/PL0_test.c @@ -1,18 +1,25 @@ #include "uart.h" #include "psr.h" +// entry point - must remain the only function in the file! void PL0_main(void) { - // if all went correct, Success! gets printed + // 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 + uart_puts("calling supervisor\n\r"); + + asm volatile("svc #0"); + + uart_puts("back from supervisor call\n\r"); + + // if we're indeed in 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[0] = *(char*) ((uint32_t) 0x0); first_kernel_byte[1] = '\0'; - + uart_puts(first_kernel_byte); while (1) -- cgit v1.2.3