Skip to content
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
1 change: 1 addition & 0 deletions riscv/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/).
- Use CSR helper macros to define `satp` register
- Use CSR helper macros to define `pmpcfgx` field types
- Use CSR helper macros to define `scause` field types
- Use CSR helper macros to define `sie` register

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

Expand Down
53 changes: 29 additions & 24 deletions riscv/src/register/sie.rs
Original file line number Diff line number Diff line change
@@ -1,38 +1,29 @@
//! sie register

read_write_csr! {
/// sie register
#[derive(Clone, Copy, Debug)]
pub struct Sie {
bits: usize,
Sie: 0x104,
mask: 0x222,
}

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

read_write_csr_field! {
Sie,
/// Supervisor Software Interrupt Enable
#[inline]
pub fn ssoft(&self) -> bool {
self.bits & (1 << 1) != 0
}
ssoft: 1,
}

read_write_csr_field! {
Sie,
/// Supervisor Timer Interrupt Enable
#[inline]
pub fn stimer(&self) -> bool {
self.bits & (1 << 5) != 0
}
stimer: 5,
}

/// Supervisor External Interrupt Enable
#[inline]
pub fn sext(&self) -> bool {
self.bits & (1 << 9) != 0
}
read_write_csr_field! {
Sie,
/// Supervisor Timer Interrupt Enable
sext: 9,
}

read_csr_as!(Sie, 0x104);
set!(0x104);
clear!(0x104);

Expand All @@ -45,3 +36,17 @@ set_clear_csr!(
set_clear_csr!(
/// Supervisor External Interrupt Enable
, set_sext, clear_sext, 1 << 9);

#[cfg(test)]
mod tests {
use super::*;

#[test]
fn test_sie() {
let mut sie = Sie::from_bits(0);

test_csr_field!(sie, ssoft);
test_csr_field!(sie, stimer);
test_csr_field!(sie, sext);
}
}