blob: 76092948adb83b3c4525cc65a81a0942d2036409 (
about) (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
|
#include "uart.h"
#include "psr.h"
void PL0_main(void)
{
uart_puts("hello PL0! Switching to user mode!\n\r");
asm("cps #0b10000\n\r"
"isb" ::: "memory");
// 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';
uart_puts(first_kernel_byte);
while (1)
{
char c;
switch(c = uart_getc())
{
case '\r':
uart_putc('\n');
default:
uart_putc(c);
}
}
}
|