Skip to content

Commit 74fe9f4

Browse files
committed
feat(kernel): add Port::{pend, clear}_interrupt_line, InterruptLine::{pend, clear}
1 parent 5914e48 commit 74fe9f4

File tree

3 files changed

+64
-1
lines changed

3 files changed

+64
-1
lines changed

src/constance/src/kernel.rs

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -305,6 +305,16 @@ pub unsafe trait Port: KernelCfg1 {
305305
unsafe fn disable_interrupt_line(_line: InterruptNum) -> Result<(), EnableInterruptLineError> {
306306
Err(EnableInterruptLineError::NotSupported)
307307
}
308+
309+
/// Set the pending flag of the specified interrupt line.
310+
unsafe fn pend_interrupt_line(_line: InterruptNum) -> Result<(), PendInterruptLineError> {
311+
Err(PendInterruptLineError::NotSupported)
312+
}
313+
314+
/// Clear the pending flag of the specified interrupt line.
315+
unsafe fn clear_interrupt_line(_line: InterruptNum) -> Result<(), ClearInterruptLineError> {
316+
Err(ClearInterruptLineError::NotSupported)
317+
}
308318
}
309319

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

src/constance/src/kernel/error.rs

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -351,3 +351,41 @@ define_error! {
351351
BadParam,
352352
}
353353
}
354+
355+
define_error! {
356+
/// Error type for [`InterruptLine::pend`].
357+
///
358+
/// [`InterruptLine::pend`]: super::InterruptLine::pend
359+
pub enum PendInterruptLineError: BadParamError {
360+
/// Setting a pending flag is not supported by the port.
361+
NotSupported,
362+
/// Setting the pending flag of the specified interrupt line is not
363+
/// supported.
364+
BadParam,
365+
/// The interrupt line is not configured to allow this operation. For
366+
/// example, this operation is invalid for an level-triggered interrupt
367+
/// line.
368+
///
369+
/// A port is not required to detect this condition.
370+
BadObjectState,
371+
}
372+
}
373+
374+
define_error! {
375+
/// Error type for [`InterruptLine::clear`].
376+
///
377+
/// [`InterruptLine::clear`]: super::InterruptLine::clear
378+
pub enum ClearInterruptLineError: BadParamError {
379+
/// Clearing a pending flag is not supported by the port.
380+
NotSupported,
381+
/// Clearing the pending flag of the specified interrupt line is not
382+
/// supported.
383+
BadParam,
384+
/// The interrupt line is not configured to allow this operation. For
385+
/// example, this operation is invalid for an level-triggered interrupt
386+
/// line.
387+
///
388+
/// A port is not required to detect this condition.
389+
BadObjectState,
390+
}
391+
}

src/constance/src/kernel/interrupt.rs

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

3-
use super::{utils, EnableInterruptLineError, Kernel, Port, SetInterruptLinePriorityError};
3+
use super::{
4+
utils, ClearInterruptLineError, EnableInterruptLineError, Kernel, PendInterruptLineError, Port,
5+
SetInterruptLinePriorityError,
6+
};
47
use crate::utils::Init;
58

69
/// Numeric value used to identify interrupt lines.
@@ -113,6 +116,18 @@ impl<System: Kernel> InterruptLine<System> {
113116
unsafe { System::disable_interrupt_line(self.0) }
114117
}
115118

119+
/// Set the pending flag of the interrupt line.
120+
pub fn pend(self) -> Result<(), PendInterruptLineError> {
121+
// Safety: We are the kernel, so it's okay to call `Port`'s methods
122+
unsafe { System::pend_interrupt_line(self.0) }
123+
}
124+
125+
/// Clear the pending flag of the interrupt line.
126+
pub fn clear(self) -> Result<(), ClearInterruptLineError> {
127+
// Safety: We are the kernel, so it's okay to call `Port`'s methods
128+
unsafe { System::clear_interrupt_line(self.0) }
129+
}
130+
116131
// TODO: port-specific attributes
117132
}
118133

0 commit comments

Comments
 (0)