From 183a08c2745f0f9f2237aaf8b1ddbb5b7fec5ce2 Mon Sep 17 00:00:00 2001 From: Dhaval Date: Mon, 9 Dec 2024 12:31:11 +0530 Subject: [PATCH] Align to latest RVI Priv spec Version 20240411 --- src/register/mcause.rs | 50 ++++++++++++++++++++---------------------- 1 file changed, 24 insertions(+), 26 deletions(-) diff --git a/src/register/mcause.rs b/src/register/mcause.rs index 705ffff4..90f74127 100644 --- a/src/register/mcause.rs +++ b/src/register/mcause.rs @@ -16,35 +16,34 @@ pub enum Trap { /// Interrupt #[derive(Copy, Clone, Debug, PartialEq, Eq)] pub enum Interrupt { - UserSoft, - SupervisorSoft, - MachineSoft, - UserTimer, - SupervisorTimer, - MachineTimer, - UserExternal, - SupervisorExternal, - MachineExternal, + SupervisorSoft = 1, + MachineSoft = 3, + SupervisorTimer = 5, + MachineTimer = 7, + SupervisorExternal = 9, + MachineExternal = 11, Unknown, } /// Exception #[derive(Copy, Clone, Debug, PartialEq, Eq)] pub enum Exception { - InstructionMisaligned, - InstructionFault, - IllegalInstruction, - Breakpoint, - LoadMisaligned, - LoadFault, - StoreMisaligned, - StoreFault, - UserEnvCall, - SupervisorEnvCall, - MachineEnvCall, - InstructionPageFault, - LoadPageFault, - StorePageFault, + InstructionMisaligned = 0, + InstructionFault = 1, + IllegalInstruction = 2, + Breakpoint = 3, + LoadMisaligned = 4, + LoadFault = 5, + StoreMisaligned = 6, + StoreFault = 7, + UserEnvCall = 8, + SupervisorEnvCall = 9, + MachineEnvCall = 11, + InstructionPageFault = 12, + LoadPageFault = 13, + StorePageFault = 15, + SoftwareCheck = 18, + HardwareError = 19, Unknown, } @@ -52,13 +51,10 @@ impl Interrupt { #[inline] pub fn from(nr: usize) -> Self { match nr { - 0 => Interrupt::UserSoft, 1 => Interrupt::SupervisorSoft, 3 => Interrupt::MachineSoft, - 4 => Interrupt::UserTimer, 5 => Interrupt::SupervisorTimer, 7 => Interrupt::MachineTimer, - 8 => Interrupt::UserExternal, 9 => Interrupt::SupervisorExternal, 11 => Interrupt::MachineExternal, _ => Interrupt::Unknown, @@ -84,6 +80,8 @@ impl Exception { 12 => Exception::InstructionPageFault, 13 => Exception::LoadPageFault, 15 => Exception::StorePageFault, + 18 => Exception::SoftwareCheck, + 19 => Exception::HardwareError, _ => Exception::Unknown, } }