|
| 1 | +//! medeleg register |
| 2 | +
|
| 3 | +use bit_field::BitField; |
| 4 | + |
| 5 | +/// medeleg register |
| 6 | +#[derive(Clone, Copy, Debug)] |
| 7 | +pub struct Medeleg { |
| 8 | + bits: usize, |
| 9 | +} |
| 10 | + |
| 11 | +impl Medeleg { |
| 12 | + /// Returns the contents of the register as raw bits |
| 13 | + #[inline] |
| 14 | + pub fn bits(&self) -> usize { |
| 15 | + self.bits |
| 16 | + } |
| 17 | + |
| 18 | + /// Instruction Address Misaligned Delegate |
| 19 | + #[inline] |
| 20 | + pub fn instruction_misaligned(&self) -> bool { |
| 21 | + self.bits.get_bit(0) |
| 22 | + } |
| 23 | + |
| 24 | + /// Instruction Access Fault Delegate |
| 25 | + #[inline] |
| 26 | + pub fn instruction_fault(&self) -> bool { |
| 27 | + self.bits.get_bit(1) |
| 28 | + } |
| 29 | + |
| 30 | + /// Illegal Instruction Delegate |
| 31 | + #[inline] |
| 32 | + pub fn illegal_instruction(&self) -> bool { |
| 33 | + self.bits.get_bit(2) |
| 34 | + } |
| 35 | + |
| 36 | + /// Breakpoint Delegate |
| 37 | + #[inline] |
| 38 | + pub fn breakpoint(&self) -> bool { |
| 39 | + self.bits.get_bit(3) |
| 40 | + } |
| 41 | + |
| 42 | + /// Load Address Misaligned Delegate |
| 43 | + #[inline] |
| 44 | + pub fn load_misaligned(&self) -> bool { |
| 45 | + self.bits.get_bit(4) |
| 46 | + } |
| 47 | + |
| 48 | + /// Load Access Fault Delegate |
| 49 | + #[inline] |
| 50 | + pub fn load_fault(&self) -> bool { |
| 51 | + self.bits.get_bit(5) |
| 52 | + } |
| 53 | + |
| 54 | + /// Store/AMO Address Misaligned Delegate |
| 55 | + #[inline] |
| 56 | + pub fn store_misaligned(&self) -> bool { |
| 57 | + self.bits.get_bit(6) |
| 58 | + } |
| 59 | + |
| 60 | + /// Store/AMO Access Fault Delegate |
| 61 | + #[inline] |
| 62 | + pub fn store_fault(&self) -> bool { |
| 63 | + self.bits.get_bit(7) |
| 64 | + } |
| 65 | + |
| 66 | + /// Environment Call from U-mode Delegate |
| 67 | + #[inline] |
| 68 | + pub fn user_env_call(&self) -> bool { |
| 69 | + self.bits.get_bit(8) |
| 70 | + } |
| 71 | + |
| 72 | + /// Environment Call from S-mode Delegate |
| 73 | + #[inline] |
| 74 | + pub fn supervisor_env_call(&self) -> bool { |
| 75 | + self.bits.get_bit(9) |
| 76 | + } |
| 77 | + |
| 78 | + /// Environment Call from M-mode Delegate |
| 79 | + #[inline] |
| 80 | + pub fn machine_env_call(&self) -> bool { |
| 81 | + self.bits.get_bit(11) |
| 82 | + } |
| 83 | + |
| 84 | + /// Instruction Page Fault Delegate |
| 85 | + #[inline] |
| 86 | + pub fn instruction_page_fault(&self) -> bool { |
| 87 | + self.bits.get_bit(12) |
| 88 | + } |
| 89 | + |
| 90 | + /// Load Page Fault Delegate |
| 91 | + #[inline] |
| 92 | + pub fn load_page_fault(&self) -> bool { |
| 93 | + self.bits.get_bit(13) |
| 94 | + } |
| 95 | + |
| 96 | + /// Store/AMO Page Fault Delegate |
| 97 | + #[inline] |
| 98 | + pub fn store_page_fault(&self) -> bool { |
| 99 | + self.bits.get_bit(15) |
| 100 | + } |
| 101 | +} |
| 102 | + |
| 103 | +read_csr_as!(Medeleg, 0x302, __read_medeleg); |
| 104 | +set!(0x302, __set_medeleg); |
| 105 | +clear!(0x302, __clear_medeleg); |
| 106 | + |
| 107 | +set_clear_csr!( |
| 108 | + /// Instruction Address Misaligned Delegate |
| 109 | + , set_instruction_misaligned, clear_instruction_misaligned, 1 << 0); |
| 110 | +set_clear_csr!( |
| 111 | + /// Instruction Access Fault Delegate |
| 112 | + , set_instruction_fault, clear_instruction_fault, 1 << 1); |
| 113 | +set_clear_csr!( |
| 114 | + /// Illegal Instruction Delegate |
| 115 | + , set_illegal_instruction, clear_illegal_instruction, 1 << 2); |
| 116 | +set_clear_csr!( |
| 117 | + /// Breakpoint Delegate |
| 118 | + , set_breakpoint, clear_breakpoint, 1 << 3); |
| 119 | +set_clear_csr!( |
| 120 | + /// Load Address Misaligned Delegate |
| 121 | + , set_load_misaligned, clear_load_misaligned, 1 << 4); |
| 122 | +set_clear_csr!( |
| 123 | + /// Load Access Fault Delegate |
| 124 | + , set_load_fault, clear_load_fault, 1 << 5); |
| 125 | +set_clear_csr!( |
| 126 | + /// Store/AMO Address Misaligned Delegate |
| 127 | + , set_store_misaligned, clear_store_misaligned, 1 << 6); |
| 128 | +set_clear_csr!( |
| 129 | + /// Store/AMO Access fault |
| 130 | + , set_store_fault, clear_store_fault, 1 << 7); |
| 131 | +set_clear_csr!( |
| 132 | + /// Environment Call from U-mode Delegate |
| 133 | + , set_user_env_call, clear_user_env_call, 1 << 8); |
| 134 | +set_clear_csr!( |
| 135 | + /// Environment Call from S-mode Delegate |
| 136 | + , set_supervisor_env_call, clear_supervisor_env_call, 1 << 9); |
| 137 | +set_clear_csr!( |
| 138 | + /// Environment Call from M-mode Delegate |
| 139 | + , set_machine_env_call, clear_machine_env_call, 1 << 11); |
| 140 | +set_clear_csr!( |
| 141 | + /// Instruction Page Fault Delegate |
| 142 | + , set_instruction_page_fault, clear_instruction_page_fault, 1 << 12); |
| 143 | +set_clear_csr!( |
| 144 | + /// Load Page Fault Delegate |
| 145 | + , set_load_page_fault, clear_load_page_fault, 1 << 13); |
| 146 | +set_clear_csr!( |
| 147 | + /// Store/AMO Page Fault Delegate |
| 148 | + , set_store_page_fault, clear_store_page_fault, 1 << 15); |
0 commit comments