Skip to content
Snippets Groups Projects
Commit e780bcbf authored by Brian's avatar Brian
Browse files

tentative artie 3

parent afa941e0
No related branches found
No related tags found
No related merge requests found
...@@ -7,9 +7,9 @@ ...@@ -7,9 +7,9 @@
.global asm_test_fault .global asm_test_fault
.global switch_to_user_mode .global switch_to_user_mode
.global set_psp
.extern user_stack DATA // this adress can be read like: ldr Rx, =user_stack .extern user_stack DATA // this adress can be read like: ldr Rx, =user_stack
switch_to_user_mode: switch_to_user_mode:
ldr r0, =user_stack ldr r0, =user_stack
msr PSP, r0 msr PSP, r0
...@@ -17,6 +17,9 @@ switch_to_user_mode: ...@@ -17,6 +17,9 @@ switch_to_user_mode:
msr CONTROL, r1 msr CONTROL, r1
bx lr bx lr
set_psp:
mrs r0, psp
bx lr
.equ bad_addr,0x90000 .equ bad_addr,0x90000
......
...@@ -36,6 +36,7 @@ volatile static unsigned idx_error; ...@@ -36,6 +36,7 @@ volatile static unsigned idx_error;
void switch_to_user_mode(); void switch_to_user_mode();
void asm_test_fault(); void asm_test_fault();
void set_psp();
void MemManage_Handler() { void MemManage_Handler() {
arr_addr[idx_error] = MMFAR; arr_addr[idx_error] = MMFAR;
...@@ -44,6 +45,13 @@ void MemManage_Handler() { ...@@ -44,6 +45,13 @@ void MemManage_Handler() {
SCB->CFSR = 0xFFFF; SCB->CFSR = 0xFFFF;
LPC_GPIO2->FIOPIN = idx_error; LPC_GPIO2->FIOPIN = idx_error;
uint32_t* user_psp;
set_psp(user_psp);
user_psp[6] = (uint32_t)user_stating_address;
} }
void test_supervisor_mode() { void test_supervisor_mode() {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment