From 8840aee369d168a50c84b9adbbf3736854cbee0d Mon Sep 17 00:00:00 2001 From: Ales Katona Date: Sat, 31 Aug 2019 17:32:43 -0600 Subject: [PATCH] ucause only as readable bits --- src/register/ucause.rs | 43 ------------------------------------------ 1 file changed, 43 deletions(-) diff --git a/src/register/ucause.rs b/src/register/ucause.rs index 9f447be..06dd8a3 100644 --- a/src/register/ucause.rs +++ b/src/register/ucause.rs @@ -1,7 +1,5 @@ //! ucause register -pub use crate::register::mcause::{Interrupt, Exception, Trap}; - /// ucause register #[derive(Clone, Copy, Debug)] pub struct Ucause { @@ -14,47 +12,6 @@ impl Ucause { pub fn bits(&self) -> usize { self.bits } - - /// Returns the code field - pub fn code(&self) -> usize { - match () { - #[cfg(target_pointer_width = "32")] - () => self.bits & !(1 << 31), - #[cfg(target_pointer_width = "64")] - () => self.bits & !(1 << 63), - #[cfg(target_pointer_width = "128")] - () => self.bits & !(1 << 127), - } - } - - /// Trap Cause - #[inline] - pub fn cause(&self) -> Trap { - if self.is_interrupt() { - Trap::Interrupt(Interrupt::from(self.code())) - } else { - Trap::Exception(Exception::from(self.code())) - } - } - - /// Is trap cause an interrupt. - #[inline] - pub fn is_interrupt(&self) -> bool { - match () { - #[cfg(target_pointer_width = "32")] - () => self.bits & (1 << 31) == 1 << 31, - #[cfg(target_pointer_width = "64")] - () => self.bits & (1 << 63) == 1 << 63, - #[cfg(target_pointer_width = "128")] - () => self.bits & (1 << 127) == 1 << 127, - } - } - - /// Is trap cause an exception. - #[inline] - pub fn is_exception(&self) -> bool { - !self.is_interrupt() - } } read_csr_as!(Ucause, 0x042, __read_ucause);