-
Notifications
You must be signed in to change notification settings - Fork 18
/
Copy pathvectors.S
37 lines (35 loc) · 1.25 KB
/
vectors.S
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
/* This is the vector table. MTVEC points here.
*
* Use 4-byte intructions here. 1 instruction = 1 entry of the table.
* The CPU jumps to MTVEC (i.e. the first entry) in case of an exception,
* and (MTVEC & 0xfffffffc) + (mcause & 0x7fffffff) * 4, in case of an interrupt.
*/
.balign 0x100
.global _vector_table
.type _vector_table, @function
_vector_table:
.option push
.option norvc
j _panic_handler /* exception handler, entry 0 */
.rept 31
j _interrupt_handler /* 31 identical entries, all pointing to the interrupt handler */
.endr
.option pop
.size _vector_table, .-_vector_table
/* This should be the exception handler.
* It doesn't do anything useful yet, but you can set a breakpoint here, to see if an exception happens.
*/
.global _panic_handler
.type _panic_handler, @function
_panic_handler:
j _panic_handler
.size _panic_handler, .-_panic_handler
/* This is the interrupt handler.
* It is declared as a weak function, and can be overridden.
*/
.global _interrupt_handler
.weak _interrupt_handler
.type _interrupt_handler, @function
_interrupt_handler:
mret
.size _interrupt_handler, .-_interrupt_handler