Skip to content

Commit 2ed5a32

Browse files
committed
feat(kernel): add Port::is_interrupt_line_pending, InterruptLine::is_pending
1 parent 74fe9f4 commit 2ed5a32

File tree

3 files changed

+27
-1
lines changed

3 files changed

+27
-1
lines changed

src/constance/src/kernel.rs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -315,6 +315,13 @@ pub unsafe trait Port: KernelCfg1 {
315315
unsafe fn clear_interrupt_line(_line: InterruptNum) -> Result<(), ClearInterruptLineError> {
316316
Err(ClearInterruptLineError::NotSupported)
317317
}
318+
319+
/// Read the pending flag of the specified interrupt line.
320+
unsafe fn is_interrupt_line_pending(
321+
_line: InterruptNum,
322+
) -> Result<bool, QueryInterruptLineError> {
323+
Err(QueryInterruptLineError::NotSupported)
324+
}
318325
}
319326

320327
/// Methods intended to be called by a port.

src/constance/src/kernel/error.rs

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -389,3 +389,16 @@ define_error! {
389389
BadObjectState,
390390
}
391391
}
392+
393+
define_error! {
394+
/// Error type for [`InterruptLine::is_pending`].
395+
///
396+
/// [`InterruptLine::is_pending`]: super::InterruptLine::is_pending
397+
pub enum QueryInterruptLineError: BadParamError {
398+
/// Reading a pending flag is not supported by the port.
399+
NotSupported,
400+
/// Reading the pending flag of the specified interrupt line is not
401+
/// supported.
402+
BadParam,
403+
}
404+
}

src/constance/src/kernel/interrupt.rs

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ use core::{fmt, hash, marker::PhantomData};
22

33
use super::{
44
utils, ClearInterruptLineError, EnableInterruptLineError, Kernel, PendInterruptLineError, Port,
5-
SetInterruptLinePriorityError,
5+
QueryInterruptLineError, SetInterruptLinePriorityError,
66
};
77
use crate::utils::Init;
88

@@ -128,6 +128,12 @@ impl<System: Kernel> InterruptLine<System> {
128128
unsafe { System::clear_interrupt_line(self.0) }
129129
}
130130

131+
/// Read the pending flag of the interrupt line.
132+
pub fn is_pending(self) -> Result<bool, QueryInterruptLineError> {
133+
// Safety: We are the kernel, so it's okay to call `Port`'s methods
134+
unsafe { System::is_interrupt_line_pending(self.0) }
135+
}
136+
131137
// TODO: port-specific attributes
132138
}
133139

0 commit comments

Comments
 (0)