Skip to content

Commit

Permalink
riscv: use CSR macros for marchid
Browse files Browse the repository at this point in the history
Uses CSR helper macros to define the `marchid` register.
  • Loading branch information
rmsyn committed Oct 22, 2024
1 parent c2fc408 commit c473fdb
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 25 deletions.
8 changes: 8 additions & 0 deletions riscv/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,14 @@ and this project adheres to [Semantic Versioning](http://semver.org/).

## [Unreleased]

### Added

- CSR helper macro to check for platform implementation

### Changed

- Use CSR helper macros to define `marchid` register

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

### Changed
Expand Down
30 changes: 5 additions & 25 deletions riscv/src/register/marchid.rs
Original file line number Diff line number Diff line change
@@ -1,28 +1,8 @@
//! marchid register

use core::num::NonZeroUsize;

/// marchid register
#[derive(Clone, Copy, Debug)]
pub struct Marchid {
bits: NonZeroUsize,
}

impl Marchid {
/// Returns the contents of the register as raw bits
#[inline]
pub fn bits(&self) -> usize {
self.bits.get()
}
}

read_csr!(0xF12);

/// Reads the CSR
#[inline]
pub fn read() -> Option<Marchid> {
let r = unsafe { _read() };
// When marchid is hardwired to zero it means that the marchid
// csr isn't implemented.
NonZeroUsize::new(r).map(|bits| Marchid { bits })
read_only_csr! {
/// `marchid` register
Marchid: 0xF12,
mask: 0xffff_ffff,
sentinel: 0,
}

0 comments on commit c473fdb

Please sign in to comment.