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/).
1212- New convenience ` try_new ` and ` new ` associated functions for ` Mtvec ` and ` Stvec ` .
1313- New methods and functions for enabling core interrupts in the ` mie ` and ` sie ` registers
1414 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.
1616
1717### Changed
1818
Original file line number Diff line number Diff line change @@ -96,11 +96,16 @@ unsafe impl ExceptionNumber for Exception {
9696 }
9797}
9898
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+
99105/// Disables interrupts for a specific core interrupt source in the current hart (machine mode).
100106#[ inline]
101107pub 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) ;
104109}
105110
106111/// 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) {
115120/// Ensure that this is called in a safe context where interrupts can be enabled.
116121#[ inline]
117122pub unsafe fn enable_interrupt < I : CoreInterruptNumber > ( interrupt : I ) {
118- mie:: enable_interrupt ( interrupt) ;
123+ mie:: enable ( interrupt) ;
119124}
120125
121126/// 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 {
8888 }
8989}
9090
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+
9197/// Disables interrupts for a specific core interrupt source in the current hart (supervisor mode).
9298#[ inline]
9399pub fn disable_interrupt < I : CoreInterruptNumber > ( interrupt : I ) {
94100 // SAFETY: it is safe to disable an interrupt source
95- sie:: disable_interrupt ( interrupt) ;
101+ sie:: disable ( interrupt) ;
96102}
97103
98104/// 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) {
107113/// Ensure that this is called in a safe context where interrupts can be enabled.
108114#[ inline]
109115pub unsafe fn enable_interrupt < I : CoreInterruptNumber > ( interrupt : I ) {
110- sie:: enable_interrupt ( interrupt) ;
116+ sie:: enable ( interrupt) ;
111117}
112118
113119/// 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!(
8989
9090/// Disables a specific core interrupt source.
9191#[ inline]
92- pub fn disable_interrupt < I : CoreInterruptNumber > ( interrupt : I ) {
92+ pub fn disable < I : CoreInterruptNumber > ( interrupt : I ) {
9393 // SAFETY: it is safe to disable an interrupt source
9494 unsafe { _clear ( 1 << interrupt. number ( ) ) } ;
9595}
@@ -101,7 +101,7 @@ pub fn disable_interrupt<I: CoreInterruptNumber>(interrupt: I) {
101101/// Enabling interrupts might break critical sections or other synchronization mechanisms.
102102/// Ensure that this is called in a safe context where interrupts can be enabled.
103103#[ inline]
104- pub unsafe fn enable_interrupt < I : CoreInterruptNumber > ( interrupt : I ) {
104+ pub unsafe fn enable < I : CoreInterruptNumber > ( interrupt : I ) {
105105 unsafe { _set ( 1 << interrupt. number ( ) ) } ;
106106}
107107
Original file line number Diff line number Diff line change @@ -62,7 +62,7 @@ set_clear_csr!(
6262
6363/// Disables a specific core interrupt source.
6464#[ inline]
65- pub fn disable_interrupt < I : CoreInterruptNumber > ( interrupt : I ) {
65+ pub fn disable < I : CoreInterruptNumber > ( interrupt : I ) {
6666 // SAFETY: it is safe to disable an interrupt source
6767 unsafe { _clear ( 1 << interrupt. number ( ) ) } ;
6868}
@@ -74,7 +74,7 @@ pub fn disable_interrupt<I: CoreInterruptNumber>(interrupt: I) {
7474/// Enabling interrupts might break critical sections or other synchronization mechanisms.
7575/// Ensure that this is called in a safe context where interrupts can be enabled.
7676#[ inline]
77- pub unsafe fn enable_interrupt < I : CoreInterruptNumber > ( interrupt : I ) {
77+ pub unsafe fn enable < I : CoreInterruptNumber > ( interrupt : I ) {
7878 unsafe { _set ( 1 << interrupt. number ( ) ) } ;
7979}
8080
You can’t perform that action at this time.
0 commit comments