Skip to content

Commit c473fdb

Browse files
committed
riscv: use CSR macros for marchid
Uses CSR helper macros to define the `marchid` register.
1 parent c2fc408 commit c473fdb

File tree

2 files changed

+13
-25
lines changed

2 files changed

+13
-25
lines changed

riscv/CHANGELOG.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,14 @@ and this project adheres to [Semantic Versioning](http://semver.org/).
77

88
## [Unreleased]
99

10+
### Added
11+
12+
- CSR helper macro to check for platform implementation
13+
14+
### Changed
15+
16+
- Use CSR helper macros to define `marchid` register
17+
1018
## [v0.12.1] - 2024-10-20
1119

1220
### Changed

riscv/src/register/marchid.rs

Lines changed: 5 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,8 @@
11
//! marchid register
22
3-
use core::num::NonZeroUsize;
4-
5-
/// marchid register
6-
#[derive(Clone, Copy, Debug)]
7-
pub struct Marchid {
8-
bits: NonZeroUsize,
9-
}
10-
11-
impl Marchid {
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!(0xF12);
20-
21-
/// Reads the CSR
22-
#[inline]
23-
pub fn read() -> Option<Marchid> {
24-
let r = unsafe { _read() };
25-
// When marchid is hardwired to zero it means that the marchid
26-
// csr isn't implemented.
27-
NonZeroUsize::new(r).map(|bits| Marchid { bits })
3+
read_only_csr! {
4+
/// `marchid` register
5+
Marchid: 0xF12,
6+
mask: 0xffff_ffff,
7+
sentinel: 0,
288
}

0 commit comments

Comments
 (0)