From 1af7591e37d09ddcd734ea07d0e999cf61c8bc5e Mon Sep 17 00:00:00 2001 From: vetch Date: Mon, 13 Jan 2020 12:40:38 +0100 Subject: Great Reorganisation, modify structure and makefile --- src/arm/PL0/PL0_test.c | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) create mode 100644 src/arm/PL0/PL0_test.c (limited to 'src/arm/PL0/PL0_test.c') diff --git a/src/arm/PL0/PL0_test.c b/src/arm/PL0/PL0_test.c new file mode 100644 index 0000000..0bfebc7 --- /dev/null +++ b/src/arm/PL0/PL0_test.c @@ -0,0 +1,34 @@ +#include "PL0_utils.h" + +// entry point - must remain the only function in the file! +void PL0_main(void) +{ + // If loading program to userspace and handling of svc are + // implemented correctly, this shall get printed + puts("Hello userspace! Type 'f' if you want me to try accessing " + "kernel memory!"); + + while (1) + { + char c = getchar(); + + if (c == '\r') + putchar('\n'); + + putchar(c); + + if (c == 'f') + { + // 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 read kernel memory from userspace :d"); + char first_kernel_byte[2]; + + first_kernel_byte[0] = *(char*) 0x0; + first_kernel_byte[1] = '\0'; + + puts(first_kernel_byte); + } + } +} -- cgit v1.2.3