clean up formatting

This commit is contained in:
Ales Katona 2019-08-31 16:12:39 -06:00
parent cdf6a33665
commit e1232ed680
No known key found for this signature in database
GPG Key ID: 08C459E2D8ABB7E8
1 changed files with 63 additions and 64 deletions

View File

@ -9,74 +9,73 @@ pub struct Scause {
bits: usize, bits: usize,
} }
/// Trap Cause /// Trap Cause
#[derive(Copy, Clone, Debug, Eq, PartialEq)] #[derive(Copy, Clone, Debug, Eq, PartialEq)]
pub enum Trap { pub enum Trap {
Interrupt(Interrupt), Interrupt(Interrupt),
Exception(Exception), Exception(Exception),
} }
/// Interrupt /// Interrupt
#[derive(Copy, Clone, Debug, Eq, PartialEq)] #[derive(Copy, Clone, Debug, Eq, PartialEq)]
pub enum Interrupt { pub enum Interrupt {
UserSoft, UserSoft,
SupervisorSoft, SupervisorSoft,
UserTimer, UserTimer,
SupervisorTimer, SupervisorTimer,
UserExternal, UserExternal,
SupervisorExternal, SupervisorExternal,
Unknown, Unknown,
} }
/// Exception /// Exception
#[derive(Copy, Clone, Debug, Eq, PartialEq)] #[derive(Copy, Clone, Debug, Eq, PartialEq)]
pub enum Exception { pub enum Exception {
InstructionMisaligned, InstructionMisaligned,
InstructionFault, InstructionFault,
IllegalInstruction, IllegalInstruction,
Breakpoint, Breakpoint,
LoadFault, LoadFault,
StoreMisaligned, StoreMisaligned,
StoreFault, StoreFault,
UserEnvCall, UserEnvCall,
InstructionPageFault, InstructionPageFault,
LoadPageFault, LoadPageFault,
StorePageFault, StorePageFault,
Unknown, Unknown,
} }
impl Interrupt { impl Interrupt {
pub fn from(nr: usize) -> Self { pub fn from(nr: usize) -> Self {
match nr { match nr {
0 => Interrupt::UserSoft, 0 => Interrupt::UserSoft,
1 => Interrupt::SupervisorSoft, 1 => Interrupt::SupervisorSoft,
4 => Interrupt::UserTimer, 4 => Interrupt::UserTimer,
5 => Interrupt::SupervisorTimer, 5 => Interrupt::SupervisorTimer,
8 => Interrupt::UserExternal, 8 => Interrupt::UserExternal,
9 => Interrupt::SupervisorExternal, 9 => Interrupt::SupervisorExternal,
_ => Interrupt::Unknown, _ => Interrupt::Unknown,
} }
} }
} }
impl Exception {
impl Exception { pub fn from(nr: usize) -> Self {
pub fn from(nr: usize) -> Self { match nr {
match nr { 0 => Exception::InstructionMisaligned,
0 => Exception::InstructionMisaligned, 1 => Exception::InstructionFault,
1 => Exception::InstructionFault, 2 => Exception::IllegalInstruction,
2 => Exception::IllegalInstruction, 3 => Exception::Breakpoint,
3 => Exception::Breakpoint, 5 => Exception::LoadFault,
5 => Exception::LoadFault, 6 => Exception::StoreMisaligned,
6 => Exception::StoreMisaligned, 7 => Exception::StoreFault,
7 => Exception::StoreFault, 8 => Exception::UserEnvCall,
8 => Exception::UserEnvCall, 12 => Exception::InstructionPageFault,
12 => Exception::InstructionPageFault, 13 => Exception::LoadPageFault,
13 => Exception::LoadPageFault, 15 => Exception::StorePageFault,
15 => Exception::StorePageFault, _ => Exception::Unknown,
_ => Exception::Unknown, }
} }
}
} }
impl Scause { impl Scause {