-
Notifications
You must be signed in to change notification settings - Fork 182
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
kern: let drivers disable double-interrupt behavior #1948
Merged
cbiffle
merged 1 commit into
oxidecomputer:master
from
cbiffle:cbiffle/clear-pending-irq
Dec 13, 2024
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -549,3 +549,15 @@ bitflags::bitflags! { | |
const POSTED = 1 << 2; | ||
} | ||
} | ||
|
||
bitflags::bitflags! { | ||
/// Bitflags that can be passed into the `IRQ_CONTROL` syscall. | ||
#[derive(Copy, Clone, Debug, PartialEq, Eq)] | ||
pub struct IrqControlArg: u32 { | ||
/// Enables the interrupt if present, disables if not present. | ||
const ENABLED = 1 << 0; | ||
/// If present, requests that any pending instance of this interrupt be | ||
// cleared. | ||
const CLEAR_PENDING = 1 << 1; | ||
} | ||
Comment on lines
+553
to
+562
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. you love to see it! |
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -31,8 +31,8 @@ | |
use core::sync::atomic::{AtomicBool, Ordering}; | ||
|
||
use abi::{ | ||
FaultInfo, IrqStatus, LeaseAttributes, SchedState, Sysnum, TaskId, | ||
TaskState, ULease, UsageError, | ||
FaultInfo, IrqControlArg, IrqStatus, LeaseAttributes, SchedState, Sysnum, | ||
TaskId, TaskState, ULease, UsageError, | ||
}; | ||
use unwrap_lite::UnwrapLite; | ||
|
||
|
@@ -753,15 +753,19 @@ fn irq_control( | |
) -> Result<NextTask, UserError> { | ||
let args = tasks[caller].save().as_irq_args(); | ||
|
||
let operation = match args.control { | ||
0 => crate::arch::disable_irq, | ||
1 => crate::arch::enable_irq, | ||
_ => { | ||
return Err(UserError::Unrecoverable(FaultInfo::SyscallUsage( | ||
UsageError::NoIrq, | ||
))) | ||
} | ||
// TODO: our use of NoIrq here is conventional but is getting increasingly | ||
// weird. Arguably it's always been wrong, since it's validating the control | ||
// argument. | ||
let control = IrqControlArg::from_bits(args.control).ok_or( | ||
UserError::Unrecoverable(FaultInfo::SyscallUsage(UsageError::NoIrq)), | ||
)?; | ||
|
||
let operation = if control.contains(IrqControlArg::ENABLED) { | ||
crate::arch::enable_irq | ||
} else { | ||
crate::arch::disable_irq | ||
}; | ||
let also_clear_pending = control.contains(IrqControlArg::CLEAR_PENDING); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. this looks lovely! |
||
|
||
let caller = caller as u32; | ||
|
||
|
@@ -774,7 +778,7 @@ fn irq_control( | |
UsageError::NoIrq, | ||
)))?; | ||
for i in irqs.iter() { | ||
operation(i.0); | ||
operation(i.0, also_clear_pending); | ||
} | ||
Ok(NextTask::Same) | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this might just be one of my pet hobby-horses but i might cite some examples of such architectures here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I can't, sorry. I'd take suggestions, but, all the architectures where I'm deeply familiar with the interrupt controller have this bit. I think maybe AVRs don't, but they also don't have a Rust port.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
hm, honestly, maybe we should just say "such as all the architectures Hubris currently targets"...but we would have to go and change that if hubris gets ported to some weird thing someday...