Skip to content

Commit 25511f7

Browse files
committed
riscv: define mstatush CSR with macro helpers
Uses CSR macro helpers to define the `mstatush` CSR register.
1 parent 60800c1 commit 25511f7

File tree

1 file changed

+13
-15
lines changed

1 file changed

+13
-15
lines changed

riscv/src/register/mstatush.rs

Lines changed: 13 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -2,28 +2,26 @@
22
33
pub use super::mstatus::Endianness;
44

5-
/// mstatus register
6-
#[derive(Clone, Copy, Debug)]
7-
pub struct Mstatush {
8-
bits: usize,
5+
read_write_csr! {
6+
/// mstatus register
7+
Mstatush: 0x310,
8+
mask: 0x30,
99
}
1010

11-
impl Mstatush {
11+
read_write_csr_field! {
12+
Mstatush,
1213
/// S-mode non-instruction-fetch memory endianness
13-
#[inline]
14-
pub fn sbe(&self) -> Endianness {
15-
Endianness::from(self.bits & (1 << 4) != 0)
16-
}
14+
sbe,
15+
Endianness: [4:4],
16+
}
1717

18+
read_write_csr_field! {
19+
Mstatush,
1820
/// M-mode non-instruction-fetch memory endianness
19-
#[inline]
20-
pub fn mbe(&self) -> Endianness {
21-
Endianness::from(self.bits & (1 << 5) != 0)
22-
}
21+
mbe,
22+
Endianness: [5:5],
2323
}
2424

25-
read_csr_as_rv32!(Mstatush, 0x310);
26-
write_csr_rv32!(0x310);
2725
set_rv32!(0x310);
2826
clear_rv32!(0x310);
2927

0 commit comments

Comments
 (0)