File tree Expand file tree Collapse file tree 5 files changed +21
-10
lines changed Expand file tree Collapse file tree 5 files changed +21
-10
lines changed Original file line number Diff line number Diff line change @@ -12,7 +12,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/).
12
12
- New convenience ` try_new ` and ` new ` associated functions for ` Mtvec ` and ` Stvec ` .
13
13
- New methods and functions for enabling core interrupts in the ` mie ` and ` sie ` registers
14
14
using the ` riscv_pac::CoreInterrupt ` trait.
15
- - New ` riscv::interrupt::{disable_interrupt, enable_interrupt} ` functions.
15
+ - New ` riscv::interrupt::{is_interrupt_enabled, disable_interrupt, enable_interrupt} ` functions.
16
16
17
17
### Changed
18
18
Original file line number Diff line number Diff line change @@ -96,11 +96,16 @@ unsafe impl ExceptionNumber for Exception {
96
96
}
97
97
}
98
98
99
+ /// Checks if a specific core interrupt source is enabled in the current hart (machine mode).
100
+ #[ inline]
101
+ pub fn is_interrupt_enabled < I : CoreInterruptNumber > ( interrupt : I ) -> bool {
102
+ mie:: read ( ) . is_enabled ( interrupt)
103
+ }
104
+
99
105
/// Disables interrupts for a specific core interrupt source in the current hart (machine mode).
100
106
#[ inline]
101
107
pub fn disable_interrupt < I : CoreInterruptNumber > ( interrupt : I ) {
102
- // SAFETY: it is safe to disable an interrupt source
103
- mie:: disable_interrupt ( interrupt) ;
108
+ mie:: disable ( interrupt) ;
104
109
}
105
110
106
111
/// Enables interrupts for a specific core interrupt source in the current hart (machine mode).
@@ -115,7 +120,7 @@ pub fn disable_interrupt<I: CoreInterruptNumber>(interrupt: I) {
115
120
/// Ensure that this is called in a safe context where interrupts can be enabled.
116
121
#[ inline]
117
122
pub unsafe fn enable_interrupt < I : CoreInterruptNumber > ( interrupt : I ) {
118
- mie:: enable_interrupt ( interrupt) ;
123
+ mie:: enable ( interrupt) ;
119
124
}
120
125
121
126
/// Disables interrupts globally in the current hart (machine mode).
Original file line number Diff line number Diff line change @@ -88,11 +88,17 @@ unsafe impl ExceptionNumber for Exception {
88
88
}
89
89
}
90
90
91
+ /// Checks if a specific core interrupt source is enabled in the current hart (supervisor mode).
92
+ #[ inline]
93
+ pub fn is_interrupt_enabled < I : CoreInterruptNumber > ( interrupt : I ) -> bool {
94
+ sie:: read ( ) . is_enabled ( interrupt)
95
+ }
96
+
91
97
/// Disables interrupts for a specific core interrupt source in the current hart (supervisor mode).
92
98
#[ inline]
93
99
pub fn disable_interrupt < I : CoreInterruptNumber > ( interrupt : I ) {
94
100
// SAFETY: it is safe to disable an interrupt source
95
- sie:: disable_interrupt ( interrupt) ;
101
+ sie:: disable ( interrupt) ;
96
102
}
97
103
98
104
/// Enables interrupts for a specific core interrupt source in the current hart (supervisor mode).
@@ -107,7 +113,7 @@ pub fn disable_interrupt<I: CoreInterruptNumber>(interrupt: I) {
107
113
/// Ensure that this is called in a safe context where interrupts can be enabled.
108
114
#[ inline]
109
115
pub unsafe fn enable_interrupt < I : CoreInterruptNumber > ( interrupt : I ) {
110
- sie:: enable_interrupt ( interrupt) ;
116
+ sie:: enable ( interrupt) ;
111
117
}
112
118
113
119
/// Disables interrupts globally in the current hart (supervisor mode).
Original file line number Diff line number Diff line change @@ -89,7 +89,7 @@ set_clear_csr!(
89
89
90
90
/// Disables a specific core interrupt source.
91
91
#[ inline]
92
- pub fn disable_interrupt < I : CoreInterruptNumber > ( interrupt : I ) {
92
+ pub fn disable < I : CoreInterruptNumber > ( interrupt : I ) {
93
93
// SAFETY: it is safe to disable an interrupt source
94
94
unsafe { _clear ( 1 << interrupt. number ( ) ) } ;
95
95
}
@@ -101,7 +101,7 @@ pub fn disable_interrupt<I: CoreInterruptNumber>(interrupt: I) {
101
101
/// Enabling interrupts might break critical sections or other synchronization mechanisms.
102
102
/// Ensure that this is called in a safe context where interrupts can be enabled.
103
103
#[ inline]
104
- pub unsafe fn enable_interrupt < I : CoreInterruptNumber > ( interrupt : I ) {
104
+ pub unsafe fn enable < I : CoreInterruptNumber > ( interrupt : I ) {
105
105
unsafe { _set ( 1 << interrupt. number ( ) ) } ;
106
106
}
107
107
Original file line number Diff line number Diff line change @@ -62,7 +62,7 @@ set_clear_csr!(
62
62
63
63
/// Disables a specific core interrupt source.
64
64
#[ inline]
65
- pub fn disable_interrupt < I : CoreInterruptNumber > ( interrupt : I ) {
65
+ pub fn disable < I : CoreInterruptNumber > ( interrupt : I ) {
66
66
// SAFETY: it is safe to disable an interrupt source
67
67
unsafe { _clear ( 1 << interrupt. number ( ) ) } ;
68
68
}
@@ -74,7 +74,7 @@ pub fn disable_interrupt<I: CoreInterruptNumber>(interrupt: I) {
74
74
/// Enabling interrupts might break critical sections or other synchronization mechanisms.
75
75
/// Ensure that this is called in a safe context where interrupts can be enabled.
76
76
#[ inline]
77
- pub unsafe fn enable_interrupt < I : CoreInterruptNumber > ( interrupt : I ) {
77
+ pub unsafe fn enable < I : CoreInterruptNumber > ( interrupt : I ) {
78
78
unsafe { _set ( 1 << interrupt. number ( ) ) } ;
79
79
}
80
80
You can’t perform that action at this time.
0 commit comments