diff --git a/code/uncore/Cargo.toml b/code/uncore/Cargo.toml index 9aed04e..2421472 100644 --- a/code/uncore/Cargo.toml +++ b/code/uncore/Cargo.toml @@ -63,7 +63,7 @@ workspace = true [dependencies] linked_list_allocator = "0.10.5" log = "0.4.20" -riscv-rt = { git = "https://github.com/rust-embedded/riscv-rt.git", rev = "28b916d", features = ["s-mode"] } +riscv-rt = { version = "0.12.0", features = ["s-mode"] } owo-colors = "4.0.0" sbi = "0.2.0" spin = "0.9.8" diff --git a/code/uncore/src/library/arch/risc_v/interrupts.rs b/code/uncore/src/library/arch/risc_v/interrupts.rs deleted file mode 100644 index ee70547..0000000 --- a/code/uncore/src/library/arch/risc_v/interrupts.rs +++ /dev/null @@ -1,70 +0,0 @@ -// SPDX-License-Identifier: GPL-3.0-or-later - -//! Contains all interrupt handlers. These handlers are set up by [`riscv-rt`]. - -/// This function is used by [`riscv-rt`] to provide a default interrupt handler. This -/// handler reports the interrupt and exists the kernel. -#[export_name = "DefaultHandler"] -pub fn default_handler() { - todo!("Default Interrupt handler is todo"); -} - -/// todo -#[export_name = "UserSoft"] -pub fn user_software() { - todo!("User Software Interrupt triggered but interrupt handler is todo"); -} - -/// todo -#[export_name = "SupervisorSoft"] -pub fn supervisor_software() { - todo!("Supervisor Software Interrupt triggered but interrupt handler is todo"); -} - -/// todo -#[export_name = "MachineSoft"] -pub fn machine_software() { - todo!("Machine Software Interrupt triggered but interrupt handler is todo"); -} - -/// todo -#[export_name = "UserTimer"] -pub fn user_timer() { - todo!("User Timer Interrupt triggered but interrupt handler is todo"); -} - -/// todo -#[export_name = "SupervisorTimer"] -pub fn supervisor_timer() { - todo!("User Timer Interrupt triggered but interrupt handler is todo"); -} - -/// todo -#[export_name = "MachineTimer"] -pub fn machine_timer() { - todo!("User Timer Interrupt triggered but interrupt handler is todo"); -} - -/// todo -#[export_name = "UserExternal"] -pub fn user_external() { - todo!("User External Interrupt triggered but interrupt handler is todo"); -} - -/// todo -#[export_name = "SupervisorExternal"] -pub fn supervisor_external() { - todo!("Supervisor External Interrupt triggered but interrupt handler is todo"); -} - -/// todo -#[export_name = "MachineExternal"] -pub fn machine_external() { - todo!("Machine External Interrupt triggered but interrupt handler is todo"); -} - -/// This function is used by [`riscv-rt`] to provide an exception handler. -#[export_name = "ExceptionHandler"] -fn exception_handler(_trap_frame: &riscv_rt::TrapFrame) -> ! { - todo!("Exception occurred but handler has not been written"); -} diff --git a/code/uncore/src/library/arch/risc_v/interrupts_exceptions.rs b/code/uncore/src/library/arch/risc_v/interrupts_exceptions.rs new file mode 100644 index 0000000..cec7f00 --- /dev/null +++ b/code/uncore/src/library/arch/risc_v/interrupts_exceptions.rs @@ -0,0 +1,15 @@ +// SPDX-License-Identifier: GPL-3.0-or-later + +//! Contains all interrupt handlers. These handlers are set up by [`riscv-rt`]. + +/// This function is used by [`riscv-rt`] to provide an exception handler. +#[export_name = "ExceptionHandler"] +fn default_exception_handler(_trap_frame: &riscv_rt::TrapFrame) -> ! { + todo!("Exception occurred but handler has not been written"); +} + +/// This function is used by [`riscv-rt`] to provide an interrupt handler. +#[export_name = "DefaultHandler"] +fn default_interrupt_handler(_trap_frame: &riscv_rt::TrapFrame) -> ! { + todo!("Exception occurred but handler has not been written"); +} diff --git a/code/uncore/src/library/arch/risc_v/linking.ld b/code/uncore/src/library/arch/risc_v/linking.ld index 5837039..91b1ba3 100644 --- a/code/uncore/src/library/arch/risc_v/linking.ld +++ b/code/uncore/src/library/arch/risc_v/linking.ld @@ -1,7 +1,7 @@ /* SPDX-License-Identifier: GPL-3.0-or-later */ /* This script needs to be synchronized with */ -/* https://github.com/rust-embedded/riscv-rt/blob/28b916dc400caef2b3bfd4c5e66130a162e21f26/link-rv64.x */ +/* https://github.com/rust-embedded/riscv/blob/master/riscv-rt/link.x.in */ /* and updates to the riscv-rt crate need to be synchronized with */ /* the updates the script gets on GitHub. */ @@ -48,6 +48,29 @@ REGION_ALIAS(REGION_STACK, REGION_DRAM); PROVIDE(_max_hart_id = 0); PROVIDE(_hart_stack_size = 2K); +/* Provide default handlers for possible interrupts and exceptions . */ +PROVIDE(InstructionMisaligned = ExceptionHandler); +PROVIDE(InstructionFault = ExceptionHandler); +PROVIDE(IllegalInstruction = ExceptionHandler); +PROVIDE(Breakpoint = ExceptionHandler); +PROVIDE(LoadMisaligned = ExceptionHandler); +PROVIDE(LoadFault = ExceptionHandler); +PROVIDE(StoreMisaligned = ExceptionHandler); +PROVIDE(StoreFault = ExceptionHandler);; +PROVIDE(UserEnvCall = ExceptionHandler); +PROVIDE(SupervisorEnvCall = ExceptionHandler); +PROVIDE(MachineEnvCall = ExceptionHandler); +PROVIDE(InstructionPageFault = ExceptionHandler); +PROVIDE(LoadPageFault = ExceptionHandler); +PROVIDE(StorePageFault = ExceptionHandler); + +PROVIDE(SupervisorSoft = DefaultHandler); +PROVIDE(MachineSoft = DefaultHandler); +PROVIDE(SupervisorTimer = DefaultHandler); +PROVIDE(MachineTimer = DefaultHandler); +PROVIDE(SupervisorExternal = DefaultHandler); +PROVIDE(MachineExternal = DefaultHandler); + /* Pre-initialization function. If the user overrides this using the */ /* `#[pre_init]` attribute or by creating a `__pre_init` function, then the */ /* function this points to will be called before the RAM is initialized. */ diff --git a/code/uncore/src/library/arch/risc_v/mod.rs b/code/uncore/src/library/arch/risc_v/mod.rs index a46758e..fcec6be 100644 --- a/code/uncore/src/library/arch/risc_v/mod.rs +++ b/code/uncore/src/library/arch/risc_v/mod.rs @@ -8,7 +8,7 @@ pub mod drivers; pub mod heap; -mod interrupts; +mod interrupts_exceptions; /// Architecture-specific functionality before the kernel setup in [`crate::setup_kernel`] /// should run.