From 3941fe97783c7a31ab04fbfb127f5026dd31ef78 Mon Sep 17 00:00:00 2001 From: Wojtek Kosior Date: Thu, 2 Jan 2020 13:24:29 +0100 Subject: demo of arm timer irq --- PL0_test.c | 29 +++++++++++++++++------------ 1 file changed, 17 insertions(+), 12 deletions(-) (limited to 'PL0_test.c') diff --git a/PL0_test.c b/PL0_test.c index ac74ad4..c6cbe18 100644 --- a/PL0_test.c +++ b/PL0_test.c @@ -5,25 +5,30 @@ void PL0_main(void) { // If loading program to userspace and handling of svc are // implemented correctly, this shall get printed - puts("Hello userspace!"); + puts("Hello userspace! Type 'f' if you want me to try accessing " + "kernel memory!"); - // 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*) 0x0; - first_kernel_byte[1] = '\0'; - - puts(first_kernel_byte); - 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