mirror of
https://github.com/saymrwulf/xous-core.git
synced 2026-11-16 08:38:26 +00:00
add cleanup for USB stack
have to shut it down gracefully or the next stage won't run.
This commit is contained in:
parent
b86664d279
commit
444ae53a11
3 changed files with 34 additions and 0 deletions
|
|
@ -245,6 +245,10 @@ pub unsafe extern "C" fn rust_entry() -> ! {
|
|||
marquee(sh1107, "Booting...");
|
||||
}
|
||||
|
||||
// stop the USB subsystem so it can be re-init'd by the next stage.
|
||||
// without this, USB init will hang later on.
|
||||
glue::shutdown();
|
||||
|
||||
// when we get to this point, there's only two options...
|
||||
crate::secboot::boot_or_die();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -34,6 +34,26 @@ pub fn enable_irq(irq_no: usize) {
|
|||
unsafe { mie::set_mext() };
|
||||
}
|
||||
|
||||
pub fn disable_all_irqs() {
|
||||
// Note that the vexriscv "IRQ Mask" register is inverse-logic --
|
||||
// that is, setting a bit in the "mask" register unmasks (i.e. enables) it.
|
||||
mim::write(0);
|
||||
unsafe { mie::clear_mext() };
|
||||
unsafe { mstatus::clear_mie() };
|
||||
// redo delegations
|
||||
unsafe {
|
||||
#[rustfmt::skip]
|
||||
core::arch::asm!(
|
||||
"li t0, 0xffffffff",
|
||||
"csrw mideleg, t0",
|
||||
"csrw medeleg, t0",
|
||||
// Re-install the machine mode trap handler
|
||||
"la t0, abort",
|
||||
"csrw mtvec, t0",
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
#[export_name = "_start_trap"]
|
||||
// #[repr(align(4))] // can't do this yet.
|
||||
#[inline(never)]
|
||||
|
|
|
|||
|
|
@ -51,6 +51,16 @@ pub fn setup() -> (UsbDeviceState, u32) {
|
|||
}
|
||||
}
|
||||
|
||||
pub fn shutdown() {
|
||||
unsafe {
|
||||
if let Some(ref mut usb_ref) = crate::platform::bao1x::usb::USB {
|
||||
let usb = &mut *core::ptr::addr_of_mut!(*usb_ref);
|
||||
crate::irq::disable_all_irqs();
|
||||
usb.stop();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
pub fn usb_status() -> (UsbDeviceState, u32) {
|
||||
unsafe {
|
||||
if let Some(ref mut usb_ref) = crate::platform::bao1x::usb::USB {
|
||||
|
|
|
|||
Loading…
Reference in a new issue