mirror of
https://github.com/saymrwulf/xous-core.git
synced 2026-11-20 09:03:28 +00:00
usb-device-xous: implement way to reset current block device app
This commit is contained in:
parent
9e5cc25a50
commit
12a7271732
4 changed files with 35 additions and 15 deletions
|
|
@ -33,6 +33,7 @@ pub(crate) enum Opcode {
|
||||||
|
|
||||||
SetBlockDevice,
|
SetBlockDevice,
|
||||||
SetBlockDeviceSID,
|
SetBlockDeviceSID,
|
||||||
|
ResetBlockDevice,
|
||||||
|
|
||||||
/// Handle the USB interrupt
|
/// Handle the USB interrupt
|
||||||
UsbIrqHandler,
|
UsbIrqHandler,
|
||||||
|
|
|
||||||
|
|
@ -5,25 +5,11 @@ use std::sync::Mutex;
|
||||||
use usbd_scsi::BlockDevice;
|
use usbd_scsi::BlockDevice;
|
||||||
use xous::msg_blocking_scalar_unpack;
|
use xous::msg_blocking_scalar_unpack;
|
||||||
|
|
||||||
#[derive(num_derive::FromPrimitive, num_derive::ToPrimitive)]
|
|
||||||
pub enum BlockDeviceOp {
|
|
||||||
// Read signals the application on the other side to read some data into
|
|
||||||
// the shared MemoryRange and return.
|
|
||||||
Read,
|
|
||||||
|
|
||||||
// Write signals the application on the other side to write some data in to the
|
|
||||||
// shared MemoryRange and return.
|
|
||||||
Write,
|
|
||||||
|
|
||||||
// MaxLBA signals the application on the other side to return the max amount of
|
|
||||||
// LBA and return.
|
|
||||||
MaxLBA,
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(num_derive::FromPrimitive, num_derive::ToPrimitive)]
|
#[derive(num_derive::FromPrimitive, num_derive::ToPrimitive)]
|
||||||
pub enum BlockDeviceMgmtOp {
|
pub enum BlockDeviceMgmtOp {
|
||||||
SetOps,
|
SetOps,
|
||||||
SetSID,
|
SetSID,
|
||||||
|
Reset,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[repr(C, align(4096))]
|
#[repr(C, align(4096))]
|
||||||
|
|
@ -88,6 +74,19 @@ impl AppsBlockDevice {
|
||||||
xous::return_scalar(msg.sender, 0).unwrap();
|
xous::return_scalar(msg.sender, 0).unwrap();
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
Some(BlockDeviceMgmtOp::Reset) => msg_blocking_scalar_unpack!(msg, 0, 0, 0, 0, {
|
||||||
|
let mut ac = app_cid_clone.lock().unwrap();
|
||||||
|
let mut ids = rw_ids_clone.lock().unwrap();
|
||||||
|
|
||||||
|
*ac = None;
|
||||||
|
*ids = RwOp {
|
||||||
|
read_id: 0,
|
||||||
|
write_id: 0,
|
||||||
|
max_lba_id: 0,
|
||||||
|
};
|
||||||
|
|
||||||
|
xous::return_scalar(msg.sender, 0).unwrap();
|
||||||
|
}),
|
||||||
None => unimplemented!("missing opcode for appsblockdevice mgmt interface"),
|
None => unimplemented!("missing opcode for appsblockdevice mgmt interface"),
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
|
||||||
|
|
@ -50,6 +50,18 @@ impl UsbHid {
|
||||||
).unwrap();
|
).unwrap();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn reset_block_device(&self) {
|
||||||
|
send_message(self.conn,
|
||||||
|
Message::new_blocking_scalar(
|
||||||
|
Opcode::ResetBlockDevice.to_usize().unwrap(),
|
||||||
|
0,
|
||||||
|
0,
|
||||||
|
0,
|
||||||
|
0,
|
||||||
|
)
|
||||||
|
).unwrap();
|
||||||
|
}
|
||||||
|
|
||||||
/// used to query if the HID core was able to start. Mainly to handle edge cases between updates.
|
/// used to query if the HID core was able to start. Mainly to handle edge cases between updates.
|
||||||
pub fn is_soc_compatible(&self) -> bool {
|
pub fn is_soc_compatible(&self) -> bool {
|
||||||
match send_message(
|
match send_message(
|
||||||
|
|
|
||||||
|
|
@ -289,6 +289,14 @@ pub(crate) fn main_hw() -> ! {
|
||||||
).unwrap();
|
).unwrap();
|
||||||
xous::return_scalar(msg.sender, 0).unwrap();
|
xous::return_scalar(msg.sender, 0).unwrap();
|
||||||
}),
|
}),
|
||||||
|
Some(Opcode::ResetBlockDevice) => msg_blocking_scalar_unpack!(msg, 0, 0, 0, 0, {
|
||||||
|
xous::send_message(abdcid,
|
||||||
|
xous::Message::new_blocking_scalar(
|
||||||
|
apps_block_device::BlockDeviceMgmtOp::Reset.to_usize().unwrap(), 0, 0, 0, 0,
|
||||||
|
)
|
||||||
|
).unwrap();
|
||||||
|
xous::return_scalar(msg.sender, 0).unwrap();
|
||||||
|
}),
|
||||||
Some(Opcode::SuspendResume) => msg_scalar_unpack!(msg, token, _, _, _, {
|
Some(Opcode::SuspendResume) => msg_scalar_unpack!(msg, token, _, _, _, {
|
||||||
usbmgmt.xous_suspend();
|
usbmgmt.xous_suspend();
|
||||||
susres.suspend_until_resume(token).expect("couldn't execute suspend/resume");
|
susres.suspend_until_resume(token).expect("couldn't execute suspend/resume");
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue