mideleg.rs 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  1. //! mideleg register
  2. /// mideleg register
  3. #[derive(Clone, Copy, Debug)]
  4. pub struct Mideleg {
  5. bits: usize,
  6. }
  7. impl Mideleg {
  8. /// Returns the contents of the register as raw bits
  9. #[inline]
  10. pub fn bits(&self) -> usize {
  11. self.bits
  12. }
  13. /// User Software Interrupt Delegate
  14. #[inline]
  15. pub fn usoft(&self) -> bool {
  16. self.bits & (1 << 0) != 0
  17. }
  18. /// Supervisor Software Interrupt Delegate
  19. #[inline]
  20. pub fn ssoft(&self) -> bool {
  21. self.bits & (1 << 1) != 0
  22. }
  23. /// User Timer Interrupt Delegate
  24. #[inline]
  25. pub fn utimer(&self) -> bool {
  26. self.bits & (1 << 4) != 0
  27. }
  28. /// Supervisor Timer Interrupt Delegate
  29. #[inline]
  30. pub fn stimer(&self) -> bool {
  31. self.bits & (1 << 5) != 0
  32. }
  33. /// User External Interrupt Delegate
  34. #[inline]
  35. pub fn uext(&self) -> bool {
  36. self.bits & (1 << 8) != 0
  37. }
  38. /// Supervisor External Interrupt Delegate
  39. #[inline]
  40. pub fn sext(&self) -> bool {
  41. self.bits & (1 << 9) != 0
  42. }
  43. }
  44. read_csr_as!(Mideleg, 0x303);
  45. set!(0x303);
  46. clear!(0x303);
  47. set_clear_csr!(
  48. /// User Software Interrupt Delegate
  49. , set_usoft, clear_usoft, 1 << 0);
  50. set_clear_csr!(
  51. /// Supervisor Software Interrupt Delegate
  52. , set_ssoft, clear_ssoft, 1 << 1);
  53. set_clear_csr!(
  54. /// User Timer Interrupt Delegate
  55. , set_utimer, clear_utimer, 1 << 4);
  56. set_clear_csr!(
  57. /// Supervisor Timer Interrupt Delegate
  58. , set_stimer, clear_stimer, 1 << 5);
  59. set_clear_csr!(
  60. /// User External Interrupt Delegate
  61. , set_uext, clear_uext, 1 << 8);
  62. set_clear_csr!(
  63. /// Supervisor External Interrupt Delegate
  64. , set_sext, clear_sext, 1 << 9);