Skip to content

Commit afc3efb

Browse files
Merge pull request #241 from rmsyn/riscv/mimpid-csr-macro
riscv: define mimpid using CSR macros
2 parents 4605597 + 630c91c commit afc3efb

File tree

2 files changed

+6
-25
lines changed

2 files changed

+6
-25
lines changed

riscv/CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/).
2020
- Use CSR helper macros to define `mideleg` register
2121
- Use CSR helper macros to define `mcounteren` register
2222
- Use CSR helper macros to define `mie` register
23+
- Use CSR helper macros to define `mimpid` register
2324

2425
## [v0.12.1] - 2024-10-20
2526

riscv/src/register/mimpid.rs

Lines changed: 5 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,8 @@
11
//! mimpid register
22
3-
use core::num::NonZeroUsize;
4-
5-
/// mimpid register
6-
#[derive(Clone, Copy, Debug)]
7-
pub struct Mimpid {
8-
bits: NonZeroUsize,
9-
}
10-
11-
impl Mimpid {
12-
/// Returns the contents of the register as raw bits
13-
#[inline]
14-
pub fn bits(&self) -> usize {
15-
self.bits.get()
16-
}
17-
}
18-
19-
read_csr!(0xF13);
20-
21-
/// Reads the CSR
22-
#[inline]
23-
pub fn read() -> Option<Mimpid> {
24-
let r = unsafe { _read() };
25-
// When mimpid is hardwired to zero it means that the mimpid
26-
// csr isn't implemented.
27-
NonZeroUsize::new(r).map(|bits| Mimpid { bits })
3+
read_only_csr! {
4+
/// `mimpid` register
5+
Mimpid: 0xF13,
6+
mask: 0xffff_ffff,
7+
sentinel: 0,
288
}

0 commit comments

Comments
 (0)