Skip to content

Commit

Permalink
Merge pull request #241 from rmsyn/riscv/mimpid-csr-macro
Browse files Browse the repository at this point in the history
riscv: define mimpid using CSR macros
  • Loading branch information
romancardenas authored Nov 8, 2024
2 parents 4605597 + 630c91c commit afc3efb
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 25 deletions.
1 change: 1 addition & 0 deletions riscv/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/).
- Use CSR helper macros to define `mideleg` register
- Use CSR helper macros to define `mcounteren` register
- Use CSR helper macros to define `mie` register
- Use CSR helper macros to define `mimpid` register

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

Expand Down
30 changes: 5 additions & 25 deletions riscv/src/register/mimpid.rs
Original file line number Diff line number Diff line change
@@ -1,28 +1,8 @@
//! mimpid register
use core::num::NonZeroUsize;

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

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

read_csr!(0xF13);

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

0 comments on commit afc3efb

Please sign in to comment.