|
@@ -1,7 +1,7 @@
|
|
//! scause register
|
|
//! scause register
|
|
|
|
|
|
use bit_field::BitField;
|
|
use bit_field::BitField;
|
|
-use core::mem::size_of;
|
|
|
|
|
|
+
|
|
|
|
|
|
/// scause register
|
|
/// scause register
|
|
#[derive(Clone, Copy)]
|
|
#[derive(Clone, Copy)]
|
|
@@ -90,7 +90,7 @@ impl Scause {
|
|
/// Returns the code field
|
|
/// Returns the code field
|
|
#[inline]
|
|
#[inline]
|
|
pub fn code(&self) -> usize {
|
|
pub fn code(&self) -> usize {
|
|
- let bit = 1 << (size_of::<usize>() * 8 - 1);
|
|
|
|
|
|
+ let bit = 1 << (usize::BITS as usize - 1);
|
|
self.bits & !bit
|
|
self.bits & !bit
|
|
}
|
|
}
|
|
|
|
|
|
@@ -107,7 +107,7 @@ impl Scause {
|
|
/// Is trap cause an interrupt.
|
|
/// Is trap cause an interrupt.
|
|
#[inline]
|
|
#[inline]
|
|
pub fn is_interrupt(&self) -> bool {
|
|
pub fn is_interrupt(&self) -> bool {
|
|
- self.bits.get_bit(size_of::<usize>() * 8 - 1)
|
|
|
|
|
|
+ self.bits.get_bit(usize::BITS as usize - 1)
|
|
}
|
|
}
|
|
|
|
|
|
/// Is trap cause an exception.
|
|
/// Is trap cause an exception.
|
|
@@ -139,7 +139,7 @@ pub unsafe fn set(cause: Trap) {
|
|
Interrupt::UserExternal => 8,
|
|
Interrupt::UserExternal => 8,
|
|
Interrupt::SupervisorExternal => 9,
|
|
Interrupt::SupervisorExternal => 9,
|
|
Interrupt::Unknown => panic!("unknown interrupt"),
|
|
Interrupt::Unknown => panic!("unknown interrupt"),
|
|
- } | (1 << (size_of::<usize>() * 8 - 1)))
|
|
|
|
|
|
+ } | (1 << (usize::BITS as usize - 1)))
|
|
} // interrupt bit is 1
|
|
} // interrupt bit is 1
|
|
Trap::Exception(e) => match e {
|
|
Trap::Exception(e) => match e {
|
|
Exception::InstructionMisaligned => 0,
|
|
Exception::InstructionMisaligned => 0,
|