aboutsummaryrefslogtreecommitdiff
path: root/PL0_test.c
diff options
context:
space:
mode:
Diffstat (limited to 'PL0_test.c')
-rw-r--r--PL0_test.c27
1 files changed, 11 insertions, 16 deletions
diff --git a/PL0_test.c b/PL0_test.c
index 2e008a2..f476eb7 100644
--- a/PL0_test.c
+++ b/PL0_test.c
@@ -1,34 +1,29 @@
-#include "uart.h"
-#include "psr.h"
+#include "PL0_utils.h"
// entry point - must remain the only function in the file!
void PL0_main(void)
{
- // If all went correct, Success! gets printed
- uart_puts("Success!\n\r");
-
- uart_puts("calling supervisor\n\r");
-
- asm volatile("svc #0");
-
- uart_puts("back from supervisor call\n\r");
+ // If loading program to userspace and handling of svc are
+ // implemented correctly, this shall get printed
+ puts("Hello userspace!");
- // if we're indeed in PL0, we should crash now, when trying to access
- // memory we're not allowed to
+ // if we're indeed in PL0, we should trigger the abort handler now,
+ // when trying to access memory we're not allowed to
+ puts("Attempting to meddle with kernel memory from userspace :d");
char first_kernel_byte[2];
- first_kernel_byte[0] = *(char*) ((uint32_t) 0x0);
+ first_kernel_byte[0] = *(char*) 0x0;
first_kernel_byte[1] = '\0';
uart_puts(first_kernel_byte);
while (1)
{
- char c = uart_getc();
+ char c = getchar();
- uart_putc(c);
+ putchar(c);
if (c == '\r')
- uart_putc('\n');
+ putchar('\n');
}
}