mip.rs 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. //! mip register
  2. /// mip register
  3. #[derive(Clone, Copy, Debug)]
  4. pub struct Mip {
  5. bits: usize,
  6. }
  7. impl Mip {
  8. /// Returns the contents of the register as raw bits
  9. #[inline]
  10. pub fn bits(&self) -> usize {
  11. self.bits
  12. }
  13. /// Supervisor Software Interrupt Pending
  14. #[inline]
  15. pub fn ssoft(&self) -> bool {
  16. self.bits & (1 << 1) != 0
  17. }
  18. /// Machine Software Interrupt Pending
  19. #[inline]
  20. pub fn msoft(&self) -> bool {
  21. self.bits & (1 << 3) != 0
  22. }
  23. /// Supervisor Timer Interrupt Pending
  24. #[inline]
  25. pub fn stimer(&self) -> bool {
  26. self.bits & (1 << 5) != 0
  27. }
  28. /// Machine Timer Interrupt Pending
  29. #[inline]
  30. pub fn mtimer(&self) -> bool {
  31. self.bits & (1 << 7) != 0
  32. }
  33. /// Supervisor External Interrupt Pending
  34. #[inline]
  35. pub fn sext(&self) -> bool {
  36. self.bits & (1 << 9) != 0
  37. }
  38. /// Machine External Interrupt Pending
  39. #[inline]
  40. pub fn mext(&self) -> bool {
  41. self.bits & (1 << 11) != 0
  42. }
  43. }
  44. read_csr_as!(Mip, 0x344);
  45. set!(0x344);
  46. clear!(0x344);
  47. set_clear_csr!(
  48. /// Supervisor Software Interrupt Pending
  49. , set_ssoft, clear_ssoft, 1 << 1);
  50. set_clear_csr!(
  51. /// Supervisor Timer Interrupt Pending
  52. , set_stimer, clear_stimer, 1 << 5);
  53. set_clear_csr!(
  54. /// Supervisor External Interrupt Pending
  55. , set_sext, clear_sext, 1 << 9);