From 95239eb05febffd92db824e3864e89c4617f038d Mon Sep 17 00:00:00 2001 From: bunnie Date: Sun, 16 Jul 2023 17:37:25 +0800 Subject: [PATCH] apply deferred-init + box idiom to susres --- services/xous-susres/src/main.rs | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/services/xous-susres/src/main.rs b/services/xous-susres/src/main.rs index 5654aca09..680cb93f4 100644 --- a/services/xous-susres/src/main.rs +++ b/services/xous-susres/src/main.rs @@ -188,13 +188,14 @@ mod implementation { // Set EV_ENABLE, this starts pre-emption sr.os_timer.wfo(utra::timer0::EV_ENABLE_ZERO, 0b1); + sr + } + pub fn init(&mut self) { xous::claim_interrupt( utra::susres::SUSRES_IRQ, susres_handler, - (&mut sr) as *mut SusResHw as *mut usize, + self as *mut SusResHw as *mut usize, ).expect("couldn't claim IRQ"); - - sr } pub fn ignore_wfi(&mut self) { self.csr.wfo(utra::susres::WFI_OVERRIDE, 1); @@ -557,7 +558,8 @@ static SHOULD_RESUME: AtomicBool = AtomicBool::new(false); fn main() -> ! { // Start the OS timer which is responsible for setting up preemption. // os_timer::init(); - let mut susres_hw = implementation::SusResHw::new(); + let mut susres_hw = Box::new(implementation::SusResHw::new()); + susres_hw.init(); log_server::init_wait().unwrap(); // debugging note: it's actually easiest to debug using client-side hooks. Search for