From 8876f6e7f5362b67e5783d382ee44d32695c85dd Mon Sep 17 00:00:00 2001 From: bunnie Date: Mon, 2 Dec 2024 19:05:56 +0800 Subject: [PATCH] raw pointer dance for IRQ handlers --- kernel/src/irq.rs | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/kernel/src/irq.rs b/kernel/src/irq.rs index e7d12d11e..f8c7e520a 100644 --- a/kernel/src/irq.rs +++ b/kernel/src/irq.rs @@ -17,7 +17,7 @@ pub fn handle(irqs_pending: usize) -> Result), { unsafe { - for (idx, handler) in IRQ_HANDLERS.iter().enumerate() { + for (idx, handler) in (&mut *(&raw mut IRQ_HANDLERS)).iter().enumerate() { // Ignore threads that have no PC, and ignore the ISR thread if let Some(handler) = handler { op(idx, &handler.0, handler.1, handler.2); @@ -77,12 +77,12 @@ pub fn interrupt_claim( // 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() { + if irq > (&mut *(&raw mut IRQ_HANDLERS)).len() { Err(xous_kernel::Error::InterruptNotFound) - } else if IRQ_HANDLERS[irq].is_some() { + } else if (&mut *(&raw mut IRQ_HANDLERS))[irq].is_some() { Err(xous_kernel::Error::InterruptInUse) } else { - IRQ_HANDLERS[irq] = Some((pid, f, arg)); + (&mut *(&raw mut IRQ_HANDLERS))[irq] = Some((pid, f, arg)); arch::irq::enable_irq(irq); Ok(()) } @@ -93,13 +93,13 @@ 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() { + if irq > (&mut *(&raw mut IRQ_HANDLERS)).len() { Err(xous_kernel::Error::InterruptNotFound) - } else if !IRQ_HANDLERS[irq].map(|f| f.0 == pid).unwrap_or(false) { + } else if !(&mut *(&raw mut IRQ_HANDLERS))[irq].map(|f| f.0 == pid).unwrap_or(false) { Err(xous_kernel::Error::InterruptNotFound) } else { arch::irq::disable_irq(irq); - IRQ_HANDLERS[irq] = None; + (&mut *(&raw mut IRQ_HANDLERS))[irq] = None; Ok(()) } } @@ -109,7 +109,7 @@ pub fn interrupt_free(irq: usize, pid: PID) -> Result<(), xous_kernel::Error> { /// for the given PID. pub fn release_interrupts_for_pid(pid: PID) { unsafe { - for (irq, handler) in IRQ_HANDLERS.iter_mut().enumerate() { + for (irq, handler) in (&mut *(&raw mut IRQ_HANDLERS)).iter_mut().enumerate() { if let Some(h) = handler { if h.0 == pid { arch::irq::disable_irq(irq);