mirror of
https://github.com/saymrwulf/xous-core.git
synced 2026-11-18 08:52:45 +00:00
apply deferred init + Box idiom to spinor
This commit is contained in:
parent
cdddb59e33
commit
17a13f2aff
1 changed files with 17 additions and 16 deletions
|
|
@ -453,7 +453,7 @@ mod implementation {
|
||||||
)
|
)
|
||||||
.expect("couldn't map flusher memory");
|
.expect("couldn't map flusher memory");
|
||||||
|
|
||||||
let mut spinor = Spinor {
|
Spinor {
|
||||||
id: 0,
|
id: 0,
|
||||||
handler_conn,
|
handler_conn,
|
||||||
csr: CSR::new(csr.as_mut_ptr() as *mut u32),
|
csr: CSR::new(csr.as_mut_ptr() as *mut u32),
|
||||||
|
|
@ -463,36 +463,36 @@ mod implementation {
|
||||||
ticktimer: ticktimer_server::Ticktimer::new().unwrap(),
|
ticktimer: ticktimer_server::Ticktimer::new().unwrap(),
|
||||||
#[cfg(feature="extra_flush")]
|
#[cfg(feature="extra_flush")]
|
||||||
flusher,
|
flusher,
|
||||||
};
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn init(&mut self) {
|
||||||
xous::claim_interrupt(
|
xous::claim_interrupt(
|
||||||
utra::spinor_soft_int::SPINOR_SOFT_INT_IRQ,
|
utra::spinor_soft_int::SPINOR_SOFT_INT_IRQ,
|
||||||
spinor_safe_context,
|
spinor_safe_context,
|
||||||
(&mut spinor) as *mut Spinor as *mut usize,
|
self as *mut Spinor as *mut usize,
|
||||||
)
|
)
|
||||||
.expect("couldn't claim SPINOR irq");
|
.expect("couldn't claim SPINOR irq");
|
||||||
spinor.softirq.wfo(utra::spinor_soft_int::EV_PENDING_SPINOR_INT, 1);
|
self.softirq.wfo(utra::spinor_soft_int::EV_PENDING_SPINOR_INT, 1);
|
||||||
spinor.softirq.wfo(utra::spinor_soft_int::EV_ENABLE_SPINOR_INT, 1);
|
self.softirq.wfo(utra::spinor_soft_int::EV_ENABLE_SPINOR_INT, 1);
|
||||||
|
|
||||||
xous::claim_interrupt(
|
xous::claim_interrupt(
|
||||||
utra::spinor::SPINOR_IRQ,
|
utra::spinor::SPINOR_IRQ,
|
||||||
ecc_handler,
|
ecc_handler,
|
||||||
(&mut spinor) as *mut Spinor as *mut usize,
|
self as *mut Spinor as *mut usize,
|
||||||
)
|
)
|
||||||
.expect("couldn't claim SPINOR irq");
|
.expect("couldn't claim SPINOR irq");
|
||||||
spinor.csr.wfo(utra::spinor::EV_PENDING_ECC_ERROR, 1);
|
self.csr.wfo(utra::spinor::EV_PENDING_ECC_ERROR, 1);
|
||||||
spinor.csr.wfo(utra::spinor::EV_ENABLE_ECC_ERROR, 1);
|
self.csr.wfo(utra::spinor::EV_ENABLE_ECC_ERROR, 1);
|
||||||
spinor.susres.push_fixed_value(RegOrField::Reg(utra::spinor::EV_PENDING), 0xFFFF_FFFF);
|
self.susres.push_fixed_value(RegOrField::Reg(utra::spinor::EV_PENDING), 0xFFFF_FFFF);
|
||||||
spinor.susres.push(RegOrField::Reg(utra::spinor::EV_ENABLE), None);
|
self.susres.push(RegOrField::Reg(utra::spinor::EV_ENABLE), None);
|
||||||
|
|
||||||
// now populate the id field
|
// now populate the id field
|
||||||
spinor.cur_op = Some(FlashOp::ReadId);
|
self.cur_op = Some(FlashOp::ReadId);
|
||||||
SPINOR_RUNNING.store(true, Ordering::SeqCst);
|
SPINOR_RUNNING.store(true, Ordering::SeqCst);
|
||||||
spinor.softirq.wfo(utra::spinor_soft_int::SOFTINT_SOFTINT, 1);
|
self.softirq.wfo(utra::spinor_soft_int::SOFTINT_SOFTINT, 1);
|
||||||
while SPINOR_RUNNING.load(Ordering::SeqCst) {}
|
while SPINOR_RUNNING.load(Ordering::SeqCst) {}
|
||||||
spinor.id = SPINOR_RESULT.load(Ordering::SeqCst);
|
self.id = SPINOR_RESULT.load(Ordering::SeqCst);
|
||||||
|
|
||||||
spinor
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// changes into the spinor interrupt handler context, which is "safe" for ROM operations because we guarantee
|
/// changes into the spinor interrupt handler context, which is "safe" for ROM operations because we guarantee
|
||||||
|
|
@ -769,7 +769,8 @@ fn main() -> ! {
|
||||||
log::trace!("registered with NS -- {:?}", spinor_sid);
|
log::trace!("registered with NS -- {:?}", spinor_sid);
|
||||||
|
|
||||||
let handler_conn = xous::connect(spinor_sid).expect("couldn't create interrupt handler callback connection");
|
let handler_conn = xous::connect(spinor_sid).expect("couldn't create interrupt handler callback connection");
|
||||||
let mut spinor = Spinor::new(handler_conn);
|
let mut spinor = Box::new(Spinor::new(handler_conn));
|
||||||
|
spinor.init();
|
||||||
|
|
||||||
log::trace!("ready to accept requests");
|
log::trace!("ready to accept requests");
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue