use bit_field::BitField;
impl_define_csr!(Misc,"Miscellaneous Controller (MISC)
This register contains a number of control bits for the operating behavior of the processor core at different privilege levels, including whether to enable 32-bit address mode, whether to allow partially privileged instructions at non-privileged levels, whether to enable address non-alignment check, and whether to enable page table write protection check.
");
impl_read_csr!(0x3, Misc);
impl Misc {
pub fn va32l1(&self) -> bool {
self.bits.get_bit(1)
}
pub fn va32l2(&self) -> bool {
self.bits.get_bit(2)
}
pub fn va32l3(&self) -> bool {
self.bits.get_bit(3)
}
pub fn drdtl1(&self) -> bool {
self.bits.get_bit(5)
}
pub fn drdtl2(&self) -> bool {
self.bits.get_bit(6)
}
pub fn drdtl3(&self) -> bool {
self.bits.get_bit(7)
}
pub fn rpcntl1(&self) -> bool {
self.bits.get_bit(9)
}
pub fn rpcntl2(&self) -> bool {
self.bits.get_bit(10)
}
pub fn rpcntl3(&self) -> bool {
self.bits.get_bit(11)
}
pub fn alcl0(&self) -> bool {
self.bits.get_bit(12)
}
pub fn alcl1(&self) -> bool {
self.bits.get_bit(13)
}
pub fn alcl2(&self) -> bool {
self.bits.get_bit(14)
}
pub fn alcl3(&self) -> bool {
self.bits.get_bit(15)
}
pub fn dwpl0(&self) -> bool {
self.bits.get_bit(16)
}
pub fn dwpl1(&self) -> bool {
self.bits.get_bit(17)
}
pub fn dwpl2(&self) -> bool {
self.bits.get_bit(18)
}
}
pub fn set_va32l1(value: bool) {
set_csr_loong_bit!(0x3, 1, value);
}
pub fn set_va32l2(value: bool) {
set_csr_loong_bit!(0x3, 2, value);
}
pub fn set_va32l3(value: bool) {
set_csr_loong_bit!(0x3, 3, value);
}
pub fn set_drdtl1(value: bool) {
set_csr_loong_bit!(0x3, 5, value);
}
pub fn set_drdtl2(value: bool) {
set_csr_loong_bit!(0x3, 6, value);
}
pub fn set_drdtl3(value: bool) {
set_csr_loong_bit!(0x3, 7, value);
}
pub fn set_rpcntl1(value: bool) {
set_csr_loong_bit!(0x3, 9, value);
}
pub fn set_rpcntl2(value: bool) {
set_csr_loong_bit!(0x3, 10, value);
}
pub fn set_rpcntl3(value: bool) {
set_csr_loong_bit!(0x3, 11, value);
}
pub fn set_alcl0(value: bool) {
set_csr_loong_bit!(0x3, 12, value);
}
pub fn set_alcl1(value: bool) {
set_csr_loong_bit!(0x3, 13, value);
}
pub fn set_alcl2(value: bool) {
set_csr_loong_bit!(0x3, 14, value);
}
pub fn set_alcl3(value: bool) {
set_csr_loong_bit!(0x3, 15, value);
}
pub fn set_dwpl0(value: bool) {
set_csr_loong_bit!(0x3, 16, value);
}
pub fn set_dwpl1(value: bool) {
set_csr_loong_bit!(0x3, 17, value);
}
pub fn set_dwpl2(value: bool) {
set_csr_loong_bit!(0x3, 18, value);
}
impl core::fmt::Debug for Misc {
fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
f.debug_struct("Misc")
.field(
"32-bit addr plv(1,2,3):",
&format_args!("{},{},{}", self.va32l1(), self.va32l2(), self.va32l3()),
)
.field(
"rdtime allowed for plv(1,2,3):",
&format_args!("{},{},{}", self.drdtl1(), self.drdtl2(), self.drdtl3()),
)
.field(
"Disable dirty bit check for plv(0,1,2):",
&format_args!("{},{},{}", self.dwpl0(), self.dwpl1(), self.dwpl2(),),
)
.field(
"Misalignment check for plv(0,1,2,4):",
&format_args!(
"{},{},{},{}",
self.alcl0(),
self.alcl1(),
self.alcl2(),
self.alcl3(),
),
)
.finish()
}
}