mirror of
https://github.com/saymrwulf/xous-core.git
synced 2026-11-18 08:52:45 +00:00
usb-block-device: fix compilation warnings
This commit is contained in:
parent
7eef972065
commit
76bfa0b37a
2 changed files with 25 additions and 31 deletions
|
|
@ -1,11 +1,9 @@
|
||||||
use core::num::NonZeroUsize;
|
use core::convert::TryInto;
|
||||||
use core::{cell::RefCell, convert::TryInto};
|
|
||||||
use num_traits::*;
|
use num_traits::*;
|
||||||
use xous::{msg_scalar_unpack, msg_blocking_scalar_unpack};
|
|
||||||
use std::sync::Arc;
|
use std::sync::Arc;
|
||||||
use std::sync::Mutex;
|
use std::sync::Mutex;
|
||||||
use usbd_scsi::BlockDevice;
|
use usbd_scsi::BlockDevice;
|
||||||
use xous::MemoryRange;
|
use xous::msg_blocking_scalar_unpack;
|
||||||
|
|
||||||
#[derive(num_derive::FromPrimitive, num_derive::ToPrimitive)]
|
#[derive(num_derive::FromPrimitive, num_derive::ToPrimitive)]
|
||||||
pub enum BlockDeviceOp {
|
pub enum BlockDeviceOp {
|
||||||
|
|
@ -49,7 +47,7 @@ pub struct AppsBlockDevice {
|
||||||
impl AppsBlockDevice {
|
impl AppsBlockDevice {
|
||||||
pub fn new() -> AppsBlockDevice {
|
pub fn new() -> AppsBlockDevice {
|
||||||
let app_cid = Arc::new(Mutex::new(None));
|
let app_cid = Arc::new(Mutex::new(None));
|
||||||
let rw_ids = Arc::new(Mutex::new(RwOp{
|
let rw_ids = Arc::new(Mutex::new(RwOp {
|
||||||
read_id: 0,
|
read_id: 0,
|
||||||
write_id: 0,
|
write_id: 0,
|
||||||
max_lba_id: 0,
|
max_lba_id: 0,
|
||||||
|
|
@ -60,12 +58,12 @@ impl AppsBlockDevice {
|
||||||
|
|
||||||
let mgmt_sid = xous::create_server().unwrap();
|
let mgmt_sid = xous::create_server().unwrap();
|
||||||
|
|
||||||
std::thread::spawn(move || {
|
std::thread::spawn(move || loop {
|
||||||
loop {
|
let msg = xous::receive_message(mgmt_sid).unwrap();
|
||||||
let mut msg = xous::receive_message(mgmt_sid).unwrap();
|
let opcode: Option<BlockDeviceMgmtOp> = FromPrimitive::from_usize(msg.body.id());
|
||||||
let opcode: Option<BlockDeviceMgmtOp> = FromPrimitive::from_usize(msg.body.id());
|
match opcode {
|
||||||
match opcode {
|
Some(BlockDeviceMgmtOp::SetOps) => {
|
||||||
Some(BlockDeviceMgmtOp::SetOps) => msg_blocking_scalar_unpack!(msg, read_id, write_id, max_lba_id, _, {
|
msg_blocking_scalar_unpack!(msg, read_id, write_id, max_lba_id, _, {
|
||||||
let mut ids = rw_ids_clone.lock().unwrap();
|
let mut ids = rw_ids_clone.lock().unwrap();
|
||||||
|
|
||||||
*ids = RwOp {
|
*ids = RwOp {
|
||||||
|
|
@ -76,18 +74,21 @@ impl AppsBlockDevice {
|
||||||
|
|
||||||
log::info!("setting new app block device handler: {:?}", ids);
|
log::info!("setting new app block device handler: {:?}", ids);
|
||||||
xous::return_scalar(msg.sender, 0).unwrap();
|
xous::return_scalar(msg.sender, 0).unwrap();
|
||||||
}),
|
})
|
||||||
Some(BlockDeviceMgmtOp::SetSID) => msg_blocking_scalar_unpack!(msg, sid1, sid2, sid3, sid4, {
|
}
|
||||||
let app_sid = xous::SID::from_u32(sid1 as u32, sid2 as u32, sid3 as u32, sid4 as u32);
|
Some(BlockDeviceMgmtOp::SetSID) => {
|
||||||
|
msg_blocking_scalar_unpack!(msg, sid1, sid2, sid3, sid4, {
|
||||||
|
let app_sid =
|
||||||
|
xous::SID::from_u32(sid1 as u32, sid2 as u32, sid3 as u32, sid4 as u32);
|
||||||
let app_cid = xous::connect(app_sid).unwrap();
|
let app_cid = xous::connect(app_sid).unwrap();
|
||||||
let mut ac = app_cid_clone.lock().unwrap();
|
let mut ac = app_cid_clone.lock().unwrap();
|
||||||
|
|
||||||
*ac = Some(app_cid as u32);
|
*ac = Some(app_cid as u32);
|
||||||
log::info!("setting new app block device handler SID: {:?}", app_sid);
|
log::info!("setting new app block device handler SID: {:?}", app_sid);
|
||||||
xous::return_scalar(msg.sender, 0).unwrap();
|
xous::return_scalar(msg.sender, 0).unwrap();
|
||||||
}),
|
})
|
||||||
None => unimplemented!("missing opcode for appsblockdevice mgmt interface"),
|
|
||||||
}
|
}
|
||||||
|
None => unimplemented!("missing opcode for appsblockdevice mgmt interface"),
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
@ -131,7 +132,8 @@ impl BlockDevice for AppsBlockDevice {
|
||||||
xous::MemoryAddress::new(lba as usize),
|
xous::MemoryAddress::new(lba as usize),
|
||||||
None,
|
None,
|
||||||
),
|
),
|
||||||
).unwrap();
|
)
|
||||||
|
.unwrap();
|
||||||
|
|
||||||
block.copy_from_slice(&request.raw[..Self::BLOCK_BYTES as usize]);
|
block.copy_from_slice(&request.raw[..Self::BLOCK_BYTES as usize]);
|
||||||
|
|
||||||
|
|
@ -165,8 +167,8 @@ impl BlockDevice for AppsBlockDevice {
|
||||||
xous::MemoryAddress::new(lba as usize),
|
xous::MemoryAddress::new(lba as usize),
|
||||||
None,
|
None,
|
||||||
),
|
),
|
||||||
).unwrap();
|
)
|
||||||
|
.unwrap();
|
||||||
|
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
@ -182,19 +184,11 @@ impl BlockDevice for AppsBlockDevice {
|
||||||
|
|
||||||
match xous::send_message(
|
match xous::send_message(
|
||||||
cid,
|
cid,
|
||||||
xous::Message::new_blocking_scalar(
|
xous::Message::new_blocking_scalar(rw_ids.max_lba_id, 0, 0, 0, 0),
|
||||||
rw_ids.max_lba_id,
|
|
||||||
0,
|
|
||||||
0,
|
|
||||||
0,
|
|
||||||
0,
|
|
||||||
),
|
|
||||||
)
|
)
|
||||||
.expect("cannot send message to block device app")
|
.expect("cannot send message to block device app")
|
||||||
{
|
{
|
||||||
xous::Result::Scalar1(max_lba) => {
|
xous::Result::Scalar1(max_lba) => max_lba.try_into().unwrap(),
|
||||||
max_lba.try_into().unwrap()
|
|
||||||
}
|
|
||||||
_ => panic!("received response to max_lba that isn't a Scalar1!"),
|
_ => panic!("received response to max_lba that isn't a Scalar1!"),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -214,9 +214,9 @@ pub(crate) fn main_hw() -> ! {
|
||||||
|
|
||||||
// Mass storage
|
// Mass storage
|
||||||
#[cfg(feature="mass-storage")]
|
#[cfg(feature="mass-storage")]
|
||||||
let mut ums_alloc = UsbBusAllocator::new(ums_dev);
|
let ums_alloc = UsbBusAllocator::new(ums_dev);
|
||||||
#[cfg(feature="mass-storage")]
|
#[cfg(feature="mass-storage")]
|
||||||
let mut abd = apps_block_device::AppsBlockDevice::new();
|
let abd = apps_block_device::AppsBlockDevice::new();
|
||||||
let abdcid = abd.conn();
|
let abdcid = abd.conn();
|
||||||
|
|
||||||
let mut ums = usbd_scsi::Scsi::new(
|
let mut ums = usbd_scsi::Scsi::new(
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue