Skip to content

Commit 3dcea0e

Browse files
committed
register: add miselect CSR
Adds the `miselect` register for selecting an indirect CSR according to the `Smcsrind` extension. Reference: <https://riscv-software-src.github.io/riscv-unified-db/manual/html/isa/isa_20240411/chapters/indirect-csr.html>
1 parent 527f6e2 commit 3dcea0e

File tree

2 files changed

+50
-0
lines changed

2 files changed

+50
-0
lines changed

riscv/src/register.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -117,6 +117,9 @@ pub mod mseccfg;
117117
#[cfg(any(test, target_arch = "riscv32"))]
118118
pub mod mseccfgh;
119119

120+
// Machine indirect access
121+
pub mod miselect;
122+
120123
#[cfg(test)]
121124
mod tests;
122125

riscv/src/register/miselect.rs

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
//! `miselect` register.
2+
3+
const MASK: usize = usize::MAX;
4+
5+
read_write_csr! {
6+
/// `miselect` register.
7+
Miselect: 0x350,
8+
mask: MASK,
9+
}
10+
11+
#[cfg(target_arch = "riscv32")]
12+
read_write_csr_field! {
13+
Miselect,
14+
/// Returns whether `miselect` is for custom use of indirect CSRs.
15+
is_custom: 31,
16+
}
17+
18+
#[cfg(not(target_arch = "riscv32"))]
19+
read_write_csr_field! {
20+
Miselect,
21+
/// Returns whether `miselect` is for custom use of indirect CSRs.
22+
is_custom: 63,
23+
}
24+
25+
#[cfg(target_arch = "riscv32")]
26+
read_write_csr_field! {
27+
Miselect,
28+
/// Gets the value stored in the `miselect` CSR.
29+
///
30+
/// # Note
31+
///
32+
/// The semantics of the value depend on the extension for the referenced CSR,
33+
/// and the relevant `mireg*` value.
34+
value: [0:30],
35+
}
36+
37+
#[cfg(not(target_arch = "riscv32"))]
38+
read_write_csr_field! {
39+
Miselect,
40+
/// Gets the value stored in the `miselect` CSR.
41+
///
42+
/// # Note
43+
///
44+
/// The semantics of the value depend on the extension for the referenced CSR,
45+
/// and the relevant `mireg*` value.
46+
value: [0:62],
47+
}

0 commit comments

Comments
 (0)