Skip to content

Commit ff86cd0

Browse files
committed
Add hook to initialize custom interrupt controllers.
1 parent 8ec323b commit ff86cd0

11 files changed

+15
-8
lines changed

riscv-rt/asm.S

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -113,15 +113,10 @@ _abs_start:
113113
// Set frame pointer
114114
add s0, sp, zero
115115

116-
// Set trap handler
117-
la t0, _start_trap
118-
csrw mtvec, t0
119-
120116
jal zero, _start_rust
121117

122118
.cfi_endproc
123119

124-
125120
/*
126121
Trap entry point (_start_trap)
127122
@@ -130,6 +125,7 @@ _abs_start:
130125
*/
131126
.section .trap, "ax"
132127
.global _start_trap
128+
.weak _start_trap
133129

134130
_start_trap:
135131
addi sp, sp, -16*REGBYTES
@@ -174,9 +170,14 @@ _start_trap:
174170
addi sp, sp, 16*REGBYTES
175171
mret
176172

173+
.section .text
174+
default_setup_interrupts:
175+
// Set trap handler
176+
la t0, _start_trap
177+
csrw mtvec, t0
178+
ret
177179

178180
/* Make sure there is an abort when linking */
179-
.section .text
180181
.globl abort
181182
abort:
182183
j abort
88 Bytes
Binary file not shown.
88 Bytes
Binary file not shown.
88 Bytes
Binary file not shown.
88 Bytes
Binary file not shown.
136 Bytes
Binary file not shown.
136 Bytes
Binary file not shown.
120 Bytes
Binary file not shown.
120 Bytes
Binary file not shown.

riscv-rt/link.x

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,8 @@ PROVIDE(ExceptionHandler = DefaultExceptionHandler);
2222
then the function this points to will be called before the RAM is initialized. */
2323
PROVIDE(__pre_init = default_pre_init);
2424

25+
PROVIDE(_setup_interrupts = default_setup_interrupts);
26+
2527
/* # Multi-processing hook function
2628
fn _mp_hook() -> bool;
2729

@@ -46,8 +48,8 @@ SECTIONS
4648
KEEP(*(.init));
4749
KEEP(*(.init.rust));
4850
. = ALIGN(4);
49-
KEEP(*(.trap));
50-
KEEP(*(.trap.rust));
51+
(*(.trap));
52+
(*(.trap.rust));
5153

5254
*(.text .text.*);
5355
} > REGION_TEXT

0 commit comments

Comments
 (0)