-
Notifications
You must be signed in to change notification settings - Fork 165
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #232 from rmsyn/riscv/marchid-csr-macro
riscv: define marchid using CSR macros
- Loading branch information
Showing
3 changed files
with
44 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
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, | ||
} |