-
Notifications
You must be signed in to change notification settings - Fork 162
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
db6c2f9
commit fc4f314
Showing
5 changed files
with
111 additions
and
77 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
extern "C" { | ||
fn SupervisorSoft(); | ||
fn MachineSoft(); | ||
fn SupervisorTimer(); | ||
fn MachineTimer(); | ||
fn SupervisorExternal(); | ||
fn MachineExternal(); | ||
fn DefaultHandler(); | ||
} | ||
|
||
#[doc(hidden)] | ||
#[no_mangle] | ||
pub static __CORE_INTERRUPTS: [Option<unsafe extern "C" fn()>; 12] = [ | ||
None, | ||
Some(SupervisorSoft), | ||
None, | ||
Some(MachineSoft), | ||
None, | ||
Some(SupervisorTimer), | ||
None, | ||
Some(MachineTimer), | ||
None, | ||
Some(SupervisorExternal), | ||
None, | ||
Some(MachineExternal), | ||
]; | ||
|
||
#[export_name = "_dispatch_core_interrupt"] | ||
unsafe extern "C" fn dispatch_core_interrupt(code: usize) { | ||
if code < __CORE_INTERRUPTS.len() { | ||
let h = &__CORE_INTERRUPTS[code]; | ||
if let Some(handler) = h { | ||
handler(); | ||
} else { | ||
DefaultHandler(); | ||
} | ||
} else { | ||
DefaultHandler(); | ||
} | ||
} | ||
|
||
#[cfg(all(riscv, feature = "v-trap"))] | ||
core::arch::global_asm!( | ||
r#" .section .trap, "ax" | ||
.weak _vector_table | ||
.type _vector_table, @function | ||
.option push | ||
.balign 0x4 // TODO check if this is the correct alignment | ||
.option norelax | ||
.option norvc | ||
_vector_table: | ||
j _start_trap // Interrupt 0 is used for exceptions | ||
j _start_SupervisorSoft_trap | ||
j _start_DefaultHandler_trap // Interrupt 2 is reserved | ||
j _start_MachineSoft_trap | ||
j _start_DefaultHandler_trap // Interrupt 4 is reserved | ||
j _start_SupervisorTimer_trap | ||
j _start_DefaultHandler_trap // Interrupt 6 is reserved | ||
j _start_MachineTimer_trap | ||
j _start_DefaultHandler_trap // Interrupt 8 is reserved | ||
j _start_SupervisorExternal_trap | ||
j _start_DefaultHandler_trap // Interrupt 10 is reserved | ||
j _start_MachineExternal_trap | ||
.option pop"# | ||
); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters