Signed-off-by: Kevin O'Connor kevin@koconnor.net --- src/block.c | 3 +++ src/hw/blockcmd.c | 6 ------ src/hw/usb-msc.c | 14 ++++++++------ src/hw/usb-msc.h | 2 +- 4 files changed, 12 insertions(+), 13 deletions(-)
diff --git a/src/block.c b/src/block.c index 5f238c7..3aa7595 100644 --- a/src/block.c +++ b/src/block.c @@ -12,6 +12,7 @@ #include "hw/blockcmd.h" // cdb_* #include "hw/pci.h" // pci_bdf_to_bus #include "hw/rtc.h" // rtc_read +#include "hw/usb-msc.h" // usb_process_op #include "hw/virtio-blk.h" // process_virtio_blk_op #include "malloc.h" // malloc_low #include "output.h" // dprintf @@ -492,6 +493,7 @@ process_op_both(struct disk_op_s *op) case DTYPE_ATA_ATAPI: return ata_atapi_process_op(op); case DTYPE_USB: + return usb_process_op(op); case DTYPE_UAS: case DTYPE_LSI_SCSI: case DTYPE_ESP_SCSI: @@ -522,6 +524,7 @@ process_op_32(struct disk_op_s *op) case DTYPE_SDCARD: return process_sdcard_op(op); case DTYPE_USB_32: + return usb_process_op(op); case DTYPE_UAS_32: case DTYPE_VIRTIO_SCSI: case DTYPE_PVSCSI: diff --git a/src/hw/blockcmd.c b/src/hw/blockcmd.c index 20bd59e..9b91098 100644 --- a/src/hw/blockcmd.c +++ b/src/hw/blockcmd.c @@ -16,7 +16,6 @@ #include "output.h" // dprintf #include "std/disk.h" // DISK_RET_EPARAM #include "string.h" // memset -#include "usb-msc.h" // usb_cmd_data #include "usb-uas.h" // usb_cmd_data #include "util.h" // timer_calc #include "virtio-scsi.h" // virtio_scsi_cmd_data @@ -27,8 +26,6 @@ cdb_cmd_data(struct disk_op_s *op, void *cdbcmd, u16 blocksize) { u8 type = GET_GLOBALFLAT(op->drive_gf->type); switch (type) { - case DTYPE_USB: - return usb_cmd_data(op, cdbcmd, blocksize); case DTYPE_UAS: return uas_cmd_data(op, cdbcmd, blocksize); case DTYPE_LSI_SCSI: @@ -40,9 +37,6 @@ cdb_cmd_data(struct disk_op_s *op, void *cdbcmd, u16 blocksize) case DTYPE_VIRTIO_SCSI: if (!MODESEGMENT) return virtio_scsi_cmd_data(op, cdbcmd, blocksize); - case DTYPE_USB_32: - if (!MODESEGMENT) - return usb_cmd_data(op, cdbcmd, blocksize); case DTYPE_UAS_32: if (!MODESEGMENT) return uas_cmd_data(op, cdbcmd, blocksize); diff --git a/src/hw/usb-msc.c b/src/hw/usb-msc.c index d90319f..3376f2c 100644 --- a/src/hw/usb-msc.c +++ b/src/hw/usb-msc.c @@ -63,25 +63,27 @@ usb_msc_send(struct usbdrive_s *udrive_gf, int dir, void *buf, u32 bytes)
// Low-level usb command transmit function. int -usb_cmd_data(struct disk_op_s *op, void *cdbcmd, u16 blocksize) +usb_process_op(struct disk_op_s *op) { if (!CONFIG_USB_MSC) return 0;
- dprintf(16, "usb_cmd_data id=%p write=%d count=%d bs=%d buf=%p\n" - , op->drive_gf, 0, op->count, blocksize, op->buf_fl); + dprintf(16, "usb_cmd_data id=%p write=%d count=%d buf=%p\n" + , op->drive_gf, 0, op->count, op->buf_fl); struct usbdrive_s *udrive_gf = container_of( op->drive_gf, struct usbdrive_s, drive);
// Setup command block wrapper. - u32 bytes = blocksize * op->count; struct cbw_s cbw; memset(&cbw, 0, sizeof(cbw)); - memcpy(cbw.CBWCB, cdbcmd, USB_CDB_SIZE); + int blocksize = scsi_fill_cmd(op, cbw.CBWCB, USB_CDB_SIZE); + if (blocksize < 0) + return default_process_op(op); + u32 bytes = blocksize * op->count; cbw.dCBWSignature = CBW_SIGNATURE; cbw.dCBWTag = 999; // XXX cbw.dCBWDataTransferLength = bytes; - cbw.bmCBWFlags = cdb_is_read(cdbcmd, blocksize) ? USB_DIR_IN : USB_DIR_OUT; + cbw.bmCBWFlags = cdb_is_read(cbw.CBWCB, blocksize) ? USB_DIR_IN : USB_DIR_OUT; cbw.bCBWLUN = GET_GLOBALFLAT(udrive_gf->lun); cbw.bCBWCBLength = USB_CDB_SIZE;
diff --git a/src/hw/usb-msc.h b/src/hw/usb-msc.h index c40d755..ff3c380 100644 --- a/src/hw/usb-msc.h +++ b/src/hw/usb-msc.h @@ -3,7 +3,7 @@
// usb-msc.c struct disk_op_s; -int usb_cmd_data(struct disk_op_s *op, void *cdbcmd, u16 blocksize); +int usb_process_op(struct disk_op_s *op); struct usbdevice_s; int usb_msc_setup(struct usbdevice_s *usbdev);