Skip to content

Commit d525c4c

Browse files
committed
riscv: define sie CSR with macro helpers
Uses CSR macro helpers to define the `sie` CSR register.
1 parent b584859 commit d525c4c

File tree

2 files changed

+16
-24
lines changed

2 files changed

+16
-24
lines changed

riscv/CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/).
3434
- Use CSR helper macros to define `satp` register
3535
- Use CSR helper macros to define `pmpcfgx` field types
3636
- Use CSR helper macros to define `scause` field types
37+
- Use CSR helper macros to define `sie` register
3738

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

riscv/src/register/sie.rs

Lines changed: 15 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,38 +1,29 @@
11
//! sie register
22
3+
read_write_csr! {
34
/// sie register
4-
#[derive(Clone, Copy, Debug)]
5-
pub struct Sie {
6-
bits: usize,
5+
Sie: 0x104,
6+
mask: 0x222,
77
}
88

9-
impl Sie {
10-
/// Returns the contents of the register as raw bits
11-
#[inline]
12-
pub fn bits(&self) -> usize {
13-
self.bits
14-
}
15-
9+
read_write_csr_field! {
10+
Sie,
1611
/// Supervisor Software Interrupt Enable
17-
#[inline]
18-
pub fn ssoft(&self) -> bool {
19-
self.bits & (1 << 1) != 0
20-
}
12+
ssoft: 1,
13+
}
2114

15+
read_write_csr_field! {
16+
Sie,
2217
/// Supervisor Timer Interrupt Enable
23-
#[inline]
24-
pub fn stimer(&self) -> bool {
25-
self.bits & (1 << 5) != 0
26-
}
18+
stimer: 5,
19+
}
2720

28-
/// Supervisor External Interrupt Enable
29-
#[inline]
30-
pub fn sext(&self) -> bool {
31-
self.bits & (1 << 9) != 0
32-
}
21+
read_write_csr_field! {
22+
Sie,
23+
/// Supervisor Timer Interrupt Enable
24+
sext: 9,
3325
}
3426

35-
read_csr_as!(Sie, 0x104);
3627
set!(0x104);
3728
clear!(0x104);
3829

0 commit comments

Comments
 (0)