Skip to content

Commit

Permalink
Merge pull request #21 from rivosinc/dev/mathieu/mseccfg
Browse files Browse the repository at this point in the history
registers: add mseccfg
  • Loading branch information
mvaquez authored Dec 16, 2024
2 parents 93ce7dd + 2e6a838 commit 2434778
Show file tree
Hide file tree
Showing 2 changed files with 52 additions and 0 deletions.
3 changes: 3 additions & 0 deletions src/register/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,9 @@ pub use self::pmpcfgx::*;
mod pmpaddrx;
pub use self::pmpaddrx::*;

// epmp configuration register
pub mod mseccfg;

// Machine Counter/Timers
pub mod mcycle;
pub mod mcycleh;
Expand Down
49 changes: 49 additions & 0 deletions src/register/mseccfg.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
//! mseccfg register
use bit_field::BitField;

/// mseccfg register
#[derive(Clone, Copy, Debug)]
pub struct Mseccfg {
bits: usize,
}

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

/// Rule Locking Bypass
#[inline]
pub fn rlb(&self) -> bool {
self.bits.get_bit(2)
}

/// Machine Mode Whitelist Policy
#[inline]
pub fn mmwp(&self) -> bool {
self.bits.get_bit(1)
}

/// Machine Mode Lockdown
#[inline]
pub fn mml(&self) -> bool {
self.bits.get_bit(0)
}
}

read_csr_as!(Mseccfg, 0x747);
set!(0x747);
clear!(0x747);

set_clear_csr!(
/// Rule Locking Bypass
, set_rlb, clear_rlb, 1 << 2);
set_clear_csr!(
/// Machine Mode Whitelist Policy
, set_mmwp, clear_mmwp, 1 << 1);
set_clear_csr!(
/// Machine Mode Lockdown
, set_mml, clear_mml, 1 << 0);

0 comments on commit 2434778

Please sign in to comment.