|
@@ -86,10 +86,8 @@ pub mod pmpcfg0 {
|
|
|
|
|
|
read_csr_as!(Pmpcsr, 0x3A0, __read_pmpcfg0);
|
|
|
write_csr_as_usize!(0x3A0, __write_pmpcfg0);
|
|
|
- set!(0x3A0, __set_pmpcfg0);
|
|
|
- clear!(0x3A0, __clear_pmpcfg0);
|
|
|
|
|
|
- /// set the configuration for pmp(x)
|
|
|
+ /// set the configuration for the defined index in pmpcfg3
|
|
|
pub unsafe fn set_pmp(index: usize, range: Range, permission: Permission, locked: bool) {
|
|
|
#[cfg(riscv32)]
|
|
|
assert!(index < 4);
|
|
@@ -100,7 +98,21 @@ pub mod pmpcfg0 {
|
|
|
let mut value = _read();
|
|
|
let byte = (locked as usize) << 7 | (range as usize) << 3 | (permission as usize);
|
|
|
value.set_bits(8 * index..=8 * index + 7, byte);
|
|
|
- _set(value)
|
|
|
+ _write(value)
|
|
|
+ }
|
|
|
+
|
|
|
+ /// clear the configuration for the defined index in pmpcfg0
|
|
|
+ /// will not work when pmp is locked
|
|
|
+ pub unsafe fn clear_pmp(index: usize) {
|
|
|
+ #[cfg(riscv32)]
|
|
|
+ assert!(index < 4);
|
|
|
+
|
|
|
+ #[cfg(riscv64)]
|
|
|
+ assert!(index < 8);
|
|
|
+
|
|
|
+ let mut value = _read();
|
|
|
+ value.set_bits(8 * index..=8 * index + 7, 0);
|
|
|
+ _write(value);
|
|
|
}
|
|
|
}
|
|
|
|
|
@@ -113,17 +125,25 @@ pub mod pmpcfg1 {
|
|
|
|
|
|
read_csr_as!(Pmpcsr, 0x3A1, __read_pmpcfg1);
|
|
|
write_csr_as_usize_rv32!(0x3A1, __write_pmpcfg1);
|
|
|
- set!(0x3A1, __set_pmpcfg1);
|
|
|
- clear!(0x3A1, __clear_pmpcfg1);
|
|
|
|
|
|
- /// set the configuration for pmp(x)
|
|
|
+ /// set the configuration for the defined index in pmpcfg3
|
|
|
pub unsafe fn set_pmp(index: usize, range: Range, permission: Permission, locked: bool) {
|
|
|
assert!(index < 4);
|
|
|
|
|
|
let mut value = _read();
|
|
|
let byte = (locked as usize) << 7 | (range as usize) << 3 | (permission as usize);
|
|
|
value.set_bits(8 * index..=8 * index + 7, byte);
|
|
|
- _set(value)
|
|
|
+ _write(value)
|
|
|
+ }
|
|
|
+
|
|
|
+ /// clear the configuration for the defined index in pmpcfg1
|
|
|
+ /// will not work when pmp is locked
|
|
|
+ pub unsafe fn clear_pmp(index: usize) {
|
|
|
+ assert!(index < 4);
|
|
|
+
|
|
|
+ let mut value = _read();
|
|
|
+ value.set_bits(8 * index..=8 * index + 7, 0);
|
|
|
+ _write(value);
|
|
|
}
|
|
|
}
|
|
|
|
|
@@ -135,10 +155,8 @@ pub mod pmpcfg2 {
|
|
|
|
|
|
read_csr_as!(Pmpcsr, 0x3A2, __read_pmpcfg2);
|
|
|
write_csr_as_usize!(0x3A2, __write_pmpcfg2);
|
|
|
- set!(0x3A2, __set_pmpcfg2);
|
|
|
- clear!(0x3A2, __clear_pmpcfg2);
|
|
|
|
|
|
- /// set the configuration for pmp(x)
|
|
|
+ /// set the configuration for the defined index in pmpcfg3
|
|
|
pub unsafe fn set_pmp(index: usize, range: Range, permission: Permission, locked: bool) {
|
|
|
#[cfg(riscv32)]
|
|
|
assert!(index < 4);
|
|
@@ -149,7 +167,21 @@ pub mod pmpcfg2 {
|
|
|
let mut value = _read();
|
|
|
let byte = (locked as usize) << 7 | (range as usize) << 3 | (permission as usize);
|
|
|
value.set_bits(8 * index..=8 * index + 7, byte);
|
|
|
- _set(value)
|
|
|
+ _write(value)
|
|
|
+ }
|
|
|
+
|
|
|
+ /// clear the configuration for the defined index in pmpcfg2
|
|
|
+ /// will not work when pmp is locked
|
|
|
+ pub unsafe fn clear_pmp(index: usize) {
|
|
|
+ #[cfg(riscv32)]
|
|
|
+ assert!(index < 4);
|
|
|
+
|
|
|
+ #[cfg(riscv64)]
|
|
|
+ assert!(index < 8);
|
|
|
+
|
|
|
+ let mut value = _read();
|
|
|
+ value.set_bits(8 * index..=8 * index + 7, 0);
|
|
|
+ _write(value);
|
|
|
}
|
|
|
}
|
|
|
|
|
@@ -162,16 +194,27 @@ pub mod pmpcfg3 {
|
|
|
|
|
|
read_csr_as!(Pmpcsr, 0x3A3, __read_pmpcfg3);
|
|
|
write_csr_as_usize_rv32!(0x3A3, __write_pmpcfg3);
|
|
|
- set!(0x3A3, __set_pmpcfg3);
|
|
|
- clear!(0x3A3, __clear_pmpcfg3);
|
|
|
|
|
|
- /// set the configuration for pmp(x)
|
|
|
+ /// set the configuration for the defined index in pmpcfg3
|
|
|
pub unsafe fn set_pmp(index: usize, range: Range, permission: Permission, locked: bool) {
|
|
|
assert!(index < 4);
|
|
|
|
|
|
let mut value = _read();
|
|
|
let byte = (locked as usize) << 7 | (range as usize) << 3 | (permission as usize);
|
|
|
value.set_bits(8 * index..=8 * index + 7, byte);
|
|
|
- _set(value)
|
|
|
+ _write(value)
|
|
|
+ }
|
|
|
+ /// clear the configuration for the defined index in pmpcfg3
|
|
|
+ /// will not work when pmp is locked
|
|
|
+ pub unsafe fn clear_pmp(index: usize) {
|
|
|
+ #[cfg(riscv32)]
|
|
|
+ assert!(index < 4);
|
|
|
+
|
|
|
+ #[cfg(riscv64)]
|
|
|
+ assert!(index < 8);
|
|
|
+
|
|
|
+ let mut value = _read();
|
|
|
+ value.set_bits(8 * index..=8 * index + 7, 0);
|
|
|
+ _write(value);
|
|
|
}
|
|
|
}
|