Exception Vector remapped in startup code

This commit is contained in:
giomba 2018-12-31 14:02:23 +01:00
parent d3152ca2ad
commit a38f8f359b
3 changed files with 16 additions and 43 deletions

View File

@ -1,27 +0,0 @@
.text
.global setVectorBAR
setVectorBAR:
/* Disable interrupts */
cpsid if
/* Enable BAR remapping (clears bit 13 of SCTLR) */
mrc p15, 0, r0, c1, c0, 0
and r0, #0xffffdfff
mcr p15, 0, r0, c1, c0, 0
/* Sets VBAR with custom vector table's address */
ldr r0, =vectab
mcr p15, 0, r0, c12, c0, 0
/* Re-Enables interrupts */
cpsie if
mov pc, lr
.global getVectorBAR
getVectorBAR:
mrc p15, 0, r0, c12, c0, 0
mov pc, lr

View File

@ -6,18 +6,6 @@
extern "C" int main(int argc, char** argv) { extern "C" int main(int argc, char** argv) {
printkl("Welcome to STKARM -- Simple and Trivial Kernel for Advanced Reduced Instruction Set Computer Machines"); printkl("Welcome to STKARM -- Simple and Trivial Kernel for Advanced Reduced Instruction Set Computer Machines");
setVectorBAR();
uint32_t bar = (uint32_t)getVectorBAR();
printk("BAR is now at ");
printkl(itoa(bar));
uint32_t* table = (uint32_t*)(bar);
printkl("Vector table content:");
for (short i = 0; i < 8; ++i) {
printk(itoa(i)); printk("\t");
printkl(itoa(table[i]));
}
printkl("Now firing software interrupt..."); printkl("Now firing software interrupt...");
fireswi(); fireswi();

View File

@ -7,10 +7,12 @@ godot_msg:
.balign 4 .balign 4
.global _start .global _start
_start: _start:
/* Disable IRQ and FIQ */
cpsid if
/* Initialize stack pointers */ /* Initialize stack pointers */
cps #0x13
ldr sp, =stack_svc ldr sp, =stack_svc
cps #0x1b cps #0x1b
ldr sp, =stack_und ldr sp, =stack_und
cps #0x17 cps #0x17
@ -19,8 +21,6 @@ _start:
ldr sp, =stack_irq ldr sp, =stack_irq
cps #0x11 cps #0x11
ldr sp, =stack_fiq ldr sp, =stack_fiq
// Leave in sys mode
cps #0x1f cps #0x1f
ldr sp, =stack_sys ldr sp, =stack_sys
@ -28,6 +28,18 @@ _start:
// cps #0x10 // cps #0x10
// ldr sp, =stack_usr // ldr sp, =stack_usr
/* Enable Vector Table BAR remapping (clears bit 13 of SCTLR) */
mrc p15, 0, r0, c1, c0, 0
and r0, #0xffffdfff
mcr p15, 0, r0, c1, c0, 0
/* Sets VBAR with custom vector table's address */
ldr r0, =vectab
mcr p15, 0, r0, c12, c0, 0
/* Enable IRQ and FIQ */
cpsie if
/* C-Main */ /* C-Main */
bl main bl main