-
Notifications
You must be signed in to change notification settings - Fork 163
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Uses CSR helper macros to define the `marchid` register.
- Loading branch information
Showing
2 changed files
with
13 additions
and
25 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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, | ||
} |