Skip to content

Commit f97c427

Browse files
committed
feat(kernel): add Port::set_interrupt_line_priority
1 parent 2ed5a32 commit f97c427

File tree

3 files changed

+19
-3
lines changed

3 files changed

+19
-3
lines changed

src/constance/src/kernel.rs

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -296,6 +296,18 @@ pub unsafe trait Port: KernelCfg1 {
296296
/// [an interrupt context]: crate#contexts
297297
fn is_interrupt_context() -> bool;
298298

299+
/// Set the priority of the specified interrupt line.
300+
///
301+
/// Precondition: CPU Lock active
302+
///
303+
/// Postcondition: CPU Lock active
304+
unsafe fn set_interrupt_line_priority(
305+
_line: InterruptNum,
306+
_priority: InterruptPriority,
307+
) -> Result<(), SetInterruptLinePriorityError> {
308+
Err(SetInterruptLinePriorityError::NotSupported)
309+
}
310+
299311
/// Enable the specified interrupt line.
300312
unsafe fn enable_interrupt_line(_line: InterruptNum) -> Result<(), EnableInterruptLineError> {
301313
Err(EnableInterruptLineError::NotSupported)

src/constance/src/kernel/error.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -329,6 +329,8 @@ define_error! {
329329
/// [`InterruptLine::set_priority`]: super::InterruptLine::set_priority
330330
/// [`InterruptLine::set_priority_unchecked`]: super::InterruptLine::set_priority_unchecked
331331
pub enum SetInterruptLinePriorityError: BadContextError, BadParamError {
332+
/// The operation is not supported by the port.
333+
NotSupported,
332334
/// CPU Lock is active, or the current context is not [a task context].
333335
///
334336
/// [a task context]: crate#contexts

src/constance/src/kernel/interrupt.rs

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -97,11 +97,13 @@ impl<System: Kernel> InterruptLine<System> {
9797
/// [unmanaged-safe]: crate::kernel::cfg::CfgInterruptHandlerBuilder::unmanaged
9898
pub unsafe fn set_priority_unchecked(
9999
self,
100-
_value: InterruptPriority,
100+
value: InterruptPriority,
101101
) -> Result<(), SetInterruptLinePriorityError> {
102102
let _lock = utils::lock_cpu::<System>()?;
103-
// TODO: deny non-task context
104-
todo!()
103+
104+
// Safety: (1) We are the kernel, so it's okay to call `Port`'s methods.
105+
// (2) CPU Lock active
106+
unsafe { System::set_interrupt_line_priority(self.0, value) }
105107
}
106108

107109
/// Enable the interrupt line.

0 commit comments

Comments
 (0)