diff options
author | vetch <vetch97@gmail.com> | 2020-01-02 17:54:31 +0100 |
---|---|---|
committer | vetch <vetch97@gmail.com> | 2020-01-02 17:54:31 +0100 |
commit | ab7b754bb32022336527c1a2d5d710b95a589d0e (patch) | |
tree | 19f508f06c72efcbdd2cfad46949ed6f1ae45a3c /PL0_test.c | |
parent | 5e1e6796109c892c4300c3da17c35e7874a40107 (diff) | |
parent | 6bf5a3b8c6e8a5d1cb3fb4880a5d9688ab094c62 (diff) | |
download | rpi-MMU-example-ab7b754bb32022336527c1a2d5d710b95a589d0e.tar.gz rpi-MMU-example-ab7b754bb32022336527c1a2d5d710b95a589d0e.zip |
Merge branch 'bob' of https://repo.or.cz/RPi-MMU-example into alice
# Conflicts:
# .gitignore
# PL0_test.ld
# demo_functionality.c
# interrupt_vector.S
# interrupts.c
# kernel.c
# memory.h
Diffstat (limited to 'PL0_test.c')
-rw-r--r-- | PL0_test.c | 41 |
1 files changed, 24 insertions, 17 deletions
@@ -1,27 +1,34 @@ -#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"); - - // 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'; + // 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!"); - uart_puts(first_kernel_byte); - while (1) { - char c = uart_getc(); - - uart_putc(c); + char c = getchar(); if (c == '\r') - uart_putc('\n'); + 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); + } } } |