Tested some exceptions; Added a simple panic function

Working exception handlers at the moment:
- und
- swi
- data_abt
Others not tested (yet)
master
giomba 2018-12-30 23:45:46 +01:00
parent b18437ba51
commit c4bfb74eef
3 changed files with 25 additions and 4 deletions

View File

@ -32,3 +32,4 @@ extern "C" const char* itoa(uint32_t n) {
return &string[0];
}

View File

@ -1,3 +1,7 @@
.data
panic_msg:
.string "=== PANIC : I'm afraid I have lost my towel"
.text
.extern c_printk
@ -16,3 +20,14 @@ printk:
pop {pc}
/* TODO: to be implemented in a more useful way */
.global panic
panic:
cpsid if
ldr r0, =panic_msg
bl printkl
1:
wfi
b 1b

View File

@ -1,3 +1,6 @@
/*
ARM System Developer's Guide, Chapter 9 Section 1 (y. 2004-2008) (page 323)
*/
.data
und_msg:
.string "Undefined Instruction"
@ -16,7 +19,7 @@ fiq_msg:
.align 4
.global vectab
vectab:
b _start
ldr pc, =panic
ldr pc, =und_handler
ldr pc, =swi_handler
ldr pc, =prefetch_abt_handler
@ -25,12 +28,11 @@ vectab:
ldr pc, =irq_handler
ldr pc, =fiq_handler
// TODO: untested
und_handler:
stmfd sp!, {lr}
ldr r0, =und_msg
bl printk
bl printkl
ldmfd sp!, {pc}^
@ -44,6 +46,7 @@ swi_handler:
// TODO: untested
prefetch_abt_handler:
sub lr, #4
stmfd sp!, {lr}
ldr r0, =prefetch_abt_msg
@ -51,13 +54,15 @@ prefetch_abt_handler:
ldmfd sp!, {pc}^
// TODO: untested
data_abt_handler:
sub lr, #8
stmfd sp!, {lr}
ldr r0, =data_abt_msg
bl printkl
b panic
ldmfd sp!, {pc}^
// TODO: untested