Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

registers: add mseccfg #21

Merged
merged 1 commit into from
Dec 16, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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);
Loading