-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathexception.c
More file actions
41 lines (32 loc) · 1.11 KB
/
exception.c
File metadata and controls
41 lines (32 loc) · 1.11 KB
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
35
36
37
38
39
40
41
#include "exception.h"
#include "mem.h"
#include "term.h"
#include "led.h"
extern unsigned int vectors_start, vectors_end;
extern struct terminfo term_dbg;
void exception_init() {
void *page = alloc_phy_pages(1);
map_page((unsigned int)page, 0xffff0000, PAGE_RW_RO);
unsigned int *table = (unsigned int*)0xffff0000;
unsigned int *vect = &vectors_start;
// Copy the vectors table and code
while(vect < &vectors_end)
*table++ = *vect++;
// Select high vectors
unsigned int ctrl_reg;
__asm("mrc p15, 0, %[reg], c1, c0, 0" : [reg] "=r" (ctrl_reg));
ctrl_reg |= 0x2000;
__asm("mcr p15, 0, %[reg], c1, c0, 0" : : [reg] "r" (ctrl_reg));
// Set up the banked stack pointers
banked_sp_init();
}
void inst_abort_handler(void *inst, unsigned int status) {
term_printf(&term_dbg, "Instruction abort:\nInst 0x%x\nStatus 0x%x\n", inst, status);
led_pattern(0b00010101, 8, 0x400000, 0);
while(1);
}
void data_abort_handler(void *inst, void *data, unsigned int status) {
term_printf(&term_dbg, "Data abort:\nInst 0x%x\nAddr 0x%x\nStatus 0x%x\n", inst, data, status);
led_pattern(0b00010101, 8, 0x400000, 0);
while(1);
}