Skip to content

Commit ebc8968

Browse files
authored
Merge pull request #143 from rust-embedded/clean-ulevel-interrupt
Removing user mode registers
2 parents ee80fd4 + 2d31842 commit ebc8968

File tree

17 files changed

+26
-361
lines changed

17 files changed

+26
-361
lines changed

CHANGELOG.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,12 @@ and this project adheres to [Semantic Versioning](http://semver.org/).
3232
- Fix `scause::Exception` missing `SupervisorEnvCall`
3333
- Removed user-level interrupts from `mcause::Interrupt` and `scause::Interrupt`
3434
- Removed user-level interrupts from `mstatus`
35+
- Removed machine environment call delegation from `medeleg`
36+
- Removed user-level interrupts from machine and supervisor mode interrupt-related registers.
37+
38+
### Removed
39+
40+
- User mode registers removed, as they are no longer supported in RISC-V
3541

3642
## [v0.10.1] - 2023-01-18
3743

src/register.rs

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -14,18 +14,6 @@
1414
#[macro_use]
1515
mod macros;
1616

17-
// User Trap Setup
18-
pub mod uie;
19-
pub mod ustatus;
20-
pub mod utvec;
21-
22-
// User Trap Handling
23-
pub mod ucause;
24-
pub mod uepc;
25-
pub mod uip;
26-
pub mod uscratch;
27-
pub mod utval;
28-
2917
// User Floating-Point CSRs
3018
// TODO: frm, fflags
3119
pub mod fcsr;

src/register/medeleg.rs

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -73,12 +73,6 @@ impl Medeleg {
7373
self.bits & (1 << 9) != 0
7474
}
7575

76-
/// Environment Call from M-mode Delegate
77-
#[inline]
78-
pub fn machine_env_call(&self) -> bool {
79-
self.bits & (1 << 11) != 0
80-
}
81-
8276
/// Instruction Page Fault Delegate
8377
#[inline]
8478
pub fn instruction_page_fault(&self) -> bool {
@@ -132,9 +126,6 @@ set_clear_csr!(
132126
set_clear_csr!(
133127
/// Environment Call from S-mode Delegate
134128
, set_supervisor_env_call, clear_supervisor_env_call, 1 << 9);
135-
set_clear_csr!(
136-
/// Environment Call from M-mode Delegate
137-
, set_machine_env_call, clear_machine_env_call, 1 << 11);
138129
set_clear_csr!(
139130
/// Instruction Page Fault Delegate
140131
, set_instruction_page_fault, clear_instruction_page_fault, 1 << 12);

src/register/mideleg.rs

Lines changed: 0 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -13,36 +13,18 @@ impl Mideleg {
1313
self.bits
1414
}
1515

16-
/// User Software Interrupt Delegate
17-
#[inline]
18-
pub fn usoft(&self) -> bool {
19-
self.bits & (1 << 0) != 0
20-
}
21-
2216
/// Supervisor Software Interrupt Delegate
2317
#[inline]
2418
pub fn ssoft(&self) -> bool {
2519
self.bits & (1 << 1) != 0
2620
}
2721

28-
/// User Timer Interrupt Delegate
29-
#[inline]
30-
pub fn utimer(&self) -> bool {
31-
self.bits & (1 << 4) != 0
32-
}
33-
3422
/// Supervisor Timer Interrupt Delegate
3523
#[inline]
3624
pub fn stimer(&self) -> bool {
3725
self.bits & (1 << 5) != 0
3826
}
3927

40-
/// User External Interrupt Delegate
41-
#[inline]
42-
pub fn uext(&self) -> bool {
43-
self.bits & (1 << 8) != 0
44-
}
45-
4628
/// Supervisor External Interrupt Delegate
4729
#[inline]
4830
pub fn sext(&self) -> bool {
@@ -54,21 +36,12 @@ read_csr_as!(Mideleg, 0x303);
5436
set!(0x303);
5537
clear!(0x303);
5638

57-
set_clear_csr!(
58-
/// User Software Interrupt Delegate
59-
, set_usoft, clear_usoft, 1 << 0);
6039
set_clear_csr!(
6140
/// Supervisor Software Interrupt Delegate
6241
, set_ssoft, clear_ssoft, 1 << 1);
63-
set_clear_csr!(
64-
/// User Timer Interrupt Delegate
65-
, set_utimer, clear_utimer, 1 << 4);
6642
set_clear_csr!(
6743
/// Supervisor Timer Interrupt Delegate
6844
, set_stimer, clear_stimer, 1 << 5);
69-
set_clear_csr!(
70-
/// User External Interrupt Delegate
71-
, set_uext, clear_uext, 1 << 8);
7245
set_clear_csr!(
7346
/// Supervisor External Interrupt Delegate
7447
, set_sext, clear_sext, 1 << 9);

src/register/mie.rs

Lines changed: 0 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -13,12 +13,6 @@ impl Mie {
1313
self.bits
1414
}
1515

16-
/// User Software Interrupt Enable
17-
#[inline]
18-
pub fn usoft(&self) -> bool {
19-
self.bits & (1 << 0) != 0
20-
}
21-
2216
/// Supervisor Software Interrupt Enable
2317
#[inline]
2418
pub fn ssoft(&self) -> bool {
@@ -31,12 +25,6 @@ impl Mie {
3125
self.bits & (1 << 3) != 0
3226
}
3327

34-
/// User Timer Interrupt Enable
35-
#[inline]
36-
pub fn utimer(&self) -> bool {
37-
self.bits & (1 << 4) != 0
38-
}
39-
4028
/// Supervisor Timer Interrupt Enable
4129
#[inline]
4230
pub fn stimer(&self) -> bool {
@@ -49,12 +37,6 @@ impl Mie {
4937
self.bits & (1 << 7) != 0
5038
}
5139

52-
/// User External Interrupt Enable
53-
#[inline]
54-
pub fn uext(&self) -> bool {
55-
self.bits & (1 << 8) != 0
56-
}
57-
5840
/// Supervisor External Interrupt Enable
5941
#[inline]
6042
pub fn sext(&self) -> bool {
@@ -72,27 +54,18 @@ read_csr_as!(Mie, 0x304);
7254
set!(0x304);
7355
clear!(0x304);
7456

75-
set_clear_csr!(
76-
/// User Software Interrupt Enable
77-
, set_usoft, clear_usoft, 1 << 0);
7857
set_clear_csr!(
7958
/// Supervisor Software Interrupt Enable
8059
, set_ssoft, clear_ssoft, 1 << 1);
8160
set_clear_csr!(
8261
/// Machine Software Interrupt Enable
8362
, set_msoft, clear_msoft, 1 << 3);
84-
set_clear_csr!(
85-
/// User Timer Interrupt Enable
86-
, set_utimer, clear_utimer, 1 << 4);
8763
set_clear_csr!(
8864
/// Supervisor Timer Interrupt Enable
8965
, set_stimer, clear_stimer, 1 << 5);
9066
set_clear_csr!(
9167
/// Machine Timer Interrupt Enable
9268
, set_mtimer, clear_mtimer, 1 << 7);
93-
set_clear_csr!(
94-
/// User External Interrupt Enable
95-
, set_uext, clear_uext, 1 << 8);
9669
set_clear_csr!(
9770
/// Supervisor External Interrupt Enable
9871
, set_sext, clear_sext, 1 << 9);

src/register/mip.rs

Lines changed: 0 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -13,12 +13,6 @@ impl Mip {
1313
self.bits
1414
}
1515

16-
/// User Software Interrupt Pending
17-
#[inline]
18-
pub fn usoft(&self) -> bool {
19-
self.bits & (1 << 0) != 0
20-
}
21-
2216
/// Supervisor Software Interrupt Pending
2317
#[inline]
2418
pub fn ssoft(&self) -> bool {
@@ -31,12 +25,6 @@ impl Mip {
3125
self.bits & (1 << 3) != 0
3226
}
3327

34-
/// User Timer Interrupt Pending
35-
#[inline]
36-
pub fn utimer(&self) -> bool {
37-
self.bits & (1 << 4) != 0
38-
}
39-
4028
/// Supervisor Timer Interrupt Pending
4129
#[inline]
4230
pub fn stimer(&self) -> bool {
@@ -49,12 +37,6 @@ impl Mip {
4937
self.bits & (1 << 7) != 0
5038
}
5139

52-
/// User External Interrupt Pending
53-
#[inline]
54-
pub fn uext(&self) -> bool {
55-
self.bits & (1 << 8) != 0
56-
}
57-
5840
/// Supervisor External Interrupt Pending
5941
#[inline]
6042
pub fn sext(&self) -> bool {
@@ -72,21 +54,12 @@ read_csr_as!(Mip, 0x344);
7254
set!(0x344);
7355
clear!(0x344);
7456

75-
set_clear_csr!(
76-
/// User Software Interrupt Pending
77-
, set_usoft, clear_usoft, 1 << 0);
7857
set_clear_csr!(
7958
/// Supervisor Software Interrupt Pending
8059
, set_ssoft, clear_ssoft, 1 << 1);
81-
set_clear_csr!(
82-
/// User Timer Interrupt Pending
83-
, set_utimer, clear_utimer, 1 << 4);
8460
set_clear_csr!(
8561
/// Supervisor Timer Interrupt Pending
8662
, set_stimer, clear_stimer, 1 << 5);
87-
set_clear_csr!(
88-
/// User External Interrupt Pending
89-
, set_uext, clear_uext, 1 << 8);
9063
set_clear_csr!(
9164
/// Supervisor External Interrupt Pending
9265
, set_sext, clear_sext, 1 << 9);

src/register/sie.rs

Lines changed: 0 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -13,36 +13,18 @@ impl Sie {
1313
self.bits
1414
}
1515

16-
/// User Software Interrupt Enable
17-
#[inline]
18-
pub fn usoft(&self) -> bool {
19-
self.bits & (1 << 0) != 0
20-
}
21-
2216
/// Supervisor Software Interrupt Enable
2317
#[inline]
2418
pub fn ssoft(&self) -> bool {
2519
self.bits & (1 << 1) != 0
2620
}
2721

28-
/// User Timer Interrupt Enable
29-
#[inline]
30-
pub fn utimer(&self) -> bool {
31-
self.bits & (1 << 4) != 0
32-
}
33-
3422
/// Supervisor Timer Interrupt Enable
3523
#[inline]
3624
pub fn stimer(&self) -> bool {
3725
self.bits & (1 << 5) != 0
3826
}
3927

40-
/// User External Interrupt Enable
41-
#[inline]
42-
pub fn uext(&self) -> bool {
43-
self.bits & (1 << 8) != 0
44-
}
45-
4628
/// Supervisor External Interrupt Enable
4729
#[inline]
4830
pub fn sext(&self) -> bool {
@@ -54,21 +36,12 @@ read_csr_as!(Sie, 0x104);
5436
set!(0x104);
5537
clear!(0x104);
5638

57-
set_clear_csr!(
58-
/// User Software Interrupt Enable
59-
, set_usoft, clear_usoft, 1 << 0);
6039
set_clear_csr!(
6140
/// Supervisor Software Interrupt Enable
6241
, set_ssoft, clear_ssoft, 1 << 1);
63-
set_clear_csr!(
64-
/// User Timer Interrupt Enable
65-
, set_utimer, clear_utimer, 1 << 4);
6642
set_clear_csr!(
6743
/// Supervisor Timer Interrupt Enable
6844
, set_stimer, clear_stimer, 1 << 5);
69-
set_clear_csr!(
70-
/// User External Interrupt Enable
71-
, set_uext, clear_uext, 1 << 8);
7245
set_clear_csr!(
7346
/// Supervisor External Interrupt Enable
7447
, set_sext, clear_sext, 1 << 9);

src/register/sip.rs

Lines changed: 6 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -13,36 +13,18 @@ impl Sip {
1313
self.bits
1414
}
1515

16-
/// User Software Interrupt Pending
17-
#[inline]
18-
pub fn usoft(&self) -> bool {
19-
self.bits & (1 << 0) != 0
20-
}
21-
2216
/// Supervisor Software Interrupt Pending
2317
#[inline]
2418
pub fn ssoft(&self) -> bool {
2519
self.bits & (1 << 1) != 0
2620
}
2721

28-
/// User Timer Interrupt Pending
29-
#[inline]
30-
pub fn utimer(&self) -> bool {
31-
self.bits & (1 << 4) != 0
32-
}
33-
3422
/// Supervisor Timer Interrupt Pending
3523
#[inline]
3624
pub fn stimer(&self) -> bool {
3725
self.bits & (1 << 5) != 0
3826
}
3927

40-
/// User External Interrupt Pending
41-
#[inline]
42-
pub fn uext(&self) -> bool {
43-
self.bits & (1 << 8) != 0
44-
}
45-
4628
/// Supervisor External Interrupt Pending
4729
#[inline]
4830
pub fn sext(&self) -> bool {
@@ -51,3 +33,9 @@ impl Sip {
5133
}
5234

5335
read_csr_as!(Sip, 0x144);
36+
set!(0x344);
37+
clear!(0x104);
38+
39+
set_clear_csr!(
40+
/// Supervisor Software Interrupt Pending
41+
, set_ssoft, clear_ssoft, 1 << 1);

src/register/sstatus.rs

Lines changed: 14 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
//! sstatus register
22
3+
pub use super::misa::XLEN;
34
pub use super::mstatus::FS;
45

56
/// Supervisor Status Register
@@ -16,24 +17,12 @@ pub enum SPP {
1617
}
1718

1819
impl Sstatus {
19-
/// User Interrupt Enable
20-
#[inline]
21-
pub fn uie(&self) -> bool {
22-
self.bits & (1 << 0) != 0
23-
}
24-
2520
/// Supervisor Interrupt Enable
2621
#[inline]
2722
pub fn sie(&self) -> bool {
2823
self.bits & (1 << 1) != 0
2924
}
3025

31-
/// User Previous Interrupt Enable
32-
#[inline]
33-
pub fn upie(&self) -> bool {
34-
self.bits & (1 << 4) != 0
35-
}
36-
3726
/// Supervisor Previous Interrupt Enable
3827
#[inline]
3928
pub fn spie(&self) -> bool {
@@ -88,6 +77,19 @@ impl Sstatus {
8877
self.bits & (1 << 19) != 0
8978
}
9079

80+
/// Effective xlen in U-mode (i.e., `UXLEN`).
81+
///
82+
/// In RISCV-32, UXL does not exist, and `UXLEN` is always [`XLEN::XLEN32`].
83+
#[inline]
84+
pub fn uxl(&self) -> XLEN {
85+
match () {
86+
#[cfg(riscv32)]
87+
() => XLEN::XLEN32,
88+
#[cfg(not(riscv32))]
89+
() => XLEN::from((self.bits >> 32) as u8 & 0x3),
90+
}
91+
}
92+
9193
/// Whether either the FS field or XS field
9294
/// signals the presence of some dirty state
9395
#[inline]

0 commit comments

Comments
 (0)