use bit_field::BitField;
#[derive(Clone, Copy, Debug)]
pub struct Medeleg {
bits: usize,
}
impl Medeleg {
#[inline]
pub fn bits(&self) -> usize {
self.bits
}
#[inline]
pub fn instruction_misaligned(&self) -> bool {
self.bits.get_bit(0)
}
#[inline]
pub fn instruction_fault(&self) -> bool {
self.bits.get_bit(1)
}
#[inline]
pub fn illegal_instruction(&self) -> bool {
self.bits.get_bit(2)
}
#[inline]
pub fn breakpoint(&self) -> bool {
self.bits.get_bit(3)
}
#[inline]
pub fn load_misaligned(&self) -> bool {
self.bits.get_bit(4)
}
#[inline]
pub fn load_fault(&self) -> bool {
self.bits.get_bit(5)
}
#[inline]
pub fn store_misaligned(&self) -> bool {
self.bits.get_bit(6)
}
#[inline]
pub fn store_fault(&self) -> bool {
self.bits.get_bit(7)
}
#[inline]
pub fn user_env_call(&self) -> bool {
self.bits.get_bit(8)
}
#[inline]
pub fn supervisor_env_call(&self) -> bool {
self.bits.get_bit(9)
}
#[inline]
pub fn machine_env_call(&self) -> bool {
self.bits.get_bit(11)
}
#[inline]
pub fn instruction_page_fault(&self) -> bool {
self.bits.get_bit(12)
}
#[inline]
pub fn load_page_fault(&self) -> bool {
self.bits.get_bit(13)
}
#[inline]
pub fn store_page_fault(&self) -> bool {
self.bits.get_bit(15)
}
}
read_csr_as!(Medeleg, 0x302);
set!(0x302);
clear!(0x302);
set_clear_csr!(
, set_instruction_misaligned, clear_instruction_misaligned, 1 << 0);
set_clear_csr!(
, set_instruction_fault, clear_instruction_fault, 1 << 1);
set_clear_csr!(
, set_illegal_instruction, clear_illegal_instruction, 1 << 2);
set_clear_csr!(
, set_breakpoint, clear_breakpoint, 1 << 3);
set_clear_csr!(
, set_load_misaligned, clear_load_misaligned, 1 << 4);
set_clear_csr!(
, set_load_fault, clear_load_fault, 1 << 5);
set_clear_csr!(
, set_store_misaligned, clear_store_misaligned, 1 << 6);
set_clear_csr!(
, set_store_fault, clear_store_fault, 1 << 7);
set_clear_csr!(
, set_user_env_call, clear_user_env_call, 1 << 8);
set_clear_csr!(
, set_supervisor_env_call, clear_supervisor_env_call, 1 << 9);
set_clear_csr!(
, set_machine_env_call, clear_machine_env_call, 1 << 11);
set_clear_csr!(
, set_instruction_page_fault, clear_instruction_page_fault, 1 << 12);
set_clear_csr!(
, set_load_page_fault, clear_load_page_fault, 1 << 13);
set_clear_csr!(
, set_store_page_fault, clear_store_page_fault, 1 << 15);