mirror of
https://github.com/saymrwulf/xous-core.git
synced 2026-11-04 04:27:34 +00:00
kernel: implement FreeInterrupt
This syscall is the opposite of ClaimInterrupt. Signed-off-by: Sean Cross <sean@xobs.io>
This commit is contained in:
parent
e8fe8b9123
commit
787d77fcbd
2 changed files with 20 additions and 1 deletions
|
|
@ -81,6 +81,22 @@ pub fn interrupt_claim(
|
|||
}
|
||||
}
|
||||
|
||||
pub fn interrupt_free(irq: usize, pid: PID) -> Result<(), xous_kernel::Error> {
|
||||
// Unsafe is required since we're accessing a static mut array.
|
||||
// However, we disable interrupts to prevent contention on this array.
|
||||
unsafe {
|
||||
if irq > IRQ_HANDLERS.len() {
|
||||
Err(xous_kernel::Error::InterruptNotFound)
|
||||
} else if !IRQ_HANDLERS[irq].map(|f| f.0 == pid).unwrap_or(false) {
|
||||
Err(xous_kernel::Error::InterruptNotFound)
|
||||
} else {
|
||||
arch::irq::disable_irq(irq).unwrap();
|
||||
IRQ_HANDLERS[irq] = None;
|
||||
Ok(())
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// Iterate through the IRQ handlers and remove any handler that exists
|
||||
/// for the given PID.
|
||||
pub fn release_interrupts_for_pid(pid: PID) {
|
||||
|
|
|
|||
|
|
@ -3,7 +3,7 @@
|
|||
|
||||
use crate::arch;
|
||||
use crate::arch::process::Process as ArchProcess;
|
||||
use crate::irq::interrupt_claim;
|
||||
use crate::irq::{interrupt_claim, interrupt_free};
|
||||
use crate::mem::{MemoryManager, PAGE_SIZE};
|
||||
use crate::server::{SenderID, WaitingMessage};
|
||||
use crate::services::SystemServices;
|
||||
|
|
@ -954,6 +954,9 @@ pub fn handle_inner(pid: PID, tid: TID, in_irq: bool, call: SysCall) -> SysCallR
|
|||
interrupt_claim(no, pid as definitions::PID, callback, arg)
|
||||
.map(|_| xous_kernel::Result::Ok)
|
||||
}
|
||||
SysCall::FreeInterrupt(no) => {
|
||||
interrupt_free(no, pid as definitions::PID).map(|_| xous_kernel::Result::Ok)
|
||||
}
|
||||
SysCall::Yield => do_yield(pid, tid),
|
||||
SysCall::ReturnToParent(_pid, _cpuid) => {
|
||||
unsafe {
|
||||
|
|
|
|||
Loading…
Reference in a new issue