Skip to content

Commit dbef76c

Browse files
committed
register: add senvcfg register
Adds the definition for the `senvcfg` Supervisor configuration CSR.
1 parent 665ffdf commit dbef76c

File tree

2 files changed

+89
-0
lines changed

2 files changed

+89
-0
lines changed

riscv/src/register.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,7 @@ pub mod stvec;
5757

5858
// Supervisor Trap Handling
5959
pub mod scause;
60+
pub mod senvcfg;
6061
pub mod sepc;
6162
pub mod sip;
6263
pub mod sscratch;

riscv/src/register/senvcfg.rs

Lines changed: 88 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,88 @@
1+
//! `senvcfg` register.
2+
3+
#[cfg(target_arch = "riscv32")]
4+
const MASK: usize = 0xf5;
5+
#[cfg(not(target_arch = "riscv32"))]
6+
const MASK: usize = 0x3_0000_00fd;
7+
8+
read_write_csr! {
9+
/// `senvcfg` register.
10+
Senvcfg: 0x10a,
11+
mask: MASK,
12+
}
13+
14+
set!(0x10a);
15+
clear!(0x10a);
16+
17+
read_write_csr_field! {
18+
Senvcfg,
19+
/// Gets the `fiom` (Fence of I/O Implies Memory) field value.
20+
fiom: 0,
21+
}
22+
23+
read_write_csr_field! {
24+
Senvcfg,
25+
/// Gets the `lpe` (Landing Pad Enable) field value.
26+
lpe: 2,
27+
}
28+
29+
#[cfg(not(target_arch = "riscv32"))]
30+
read_write_csr_field! {
31+
Senvcfg,
32+
/// Gets the `sse` (Shadow Stack Enable) field value.
33+
sse: 3,
34+
}
35+
36+
csr_field_enum! {
37+
/// Represents CBIE (Cache Block Invalidate instruction Enable) field of the `senvcfg` CSR.
38+
Cbie {
39+
default: IllegalInstruction,
40+
/// The instruction takes an illegal instruction exception.
41+
IllegalInstruction = 0b00,
42+
/// The instruction is executed and performs a flush operation.
43+
Flush = 0b01,
44+
/// The instruction is executed and performs an invalidate operation.
45+
Invalidate = 0b11,
46+
}
47+
}
48+
49+
read_write_csr_field! {
50+
Senvcfg,
51+
/// Gets the `cbie` (Cache Block Invalidate Enable) field value.
52+
cbie,
53+
Cbie: [4:5],
54+
}
55+
56+
read_write_csr_field! {
57+
Senvcfg,
58+
/// Gets the `cbcfe` (Cache Block Clean and Flush Enable) field value.
59+
cbcfe: 6,
60+
}
61+
62+
read_write_csr_field! {
63+
Senvcfg,
64+
/// Gets the `cbze` (Cache Block Zero Enable) field value.
65+
cbze: 7,
66+
}
67+
68+
#[cfg(not(target_arch = "riscv32"))]
69+
csr_field_enum! {
70+
/// Represents PMM (Pointer Masking Mode) field of the `senvcfg` CSR.
71+
Pmm {
72+
default: Disabled,
73+
/// Pointer masking is disabled (PMLEN=0).
74+
Disabled = 0b00,
75+
/// Pointer masking is enabled with PMLEN=XLEN-57 (PMLEN=7 on RV64).
76+
Mask7bit = 0b10,
77+
/// Pointer masking is enabled with PMLEN=XLEN-48 (PMLEN=16 on RV64).
78+
Mask16bit = 0b11,
79+
}
80+
}
81+
82+
#[cfg(not(target_arch = "riscv32"))]
83+
read_write_csr_field! {
84+
Senvcfg,
85+
/// Gets the `pmm` (Pointer Masking Mode) field value.
86+
pmm,
87+
Pmm: [32:33],
88+
}

0 commit comments

Comments
 (0)