Signed-off-by: Kevin O'Connor kevin@koconnor.net --- src/block.c | 3 +++ src/hw/blockcmd.c | 6 ------ src/hw/usb-uas.c | 6 ++++-- src/hw/usb-uas.h | 2 +- 4 files changed, 8 insertions(+), 9 deletions(-)
diff --git a/src/block.c b/src/block.c index 3aa7595..3e76857 100644 --- a/src/block.c +++ b/src/block.c @@ -13,6 +13,7 @@ #include "hw/pci.h" // pci_bdf_to_bus #include "hw/rtc.h" // rtc_read #include "hw/usb-msc.h" // usb_process_op +#include "hw/usb-uas.h" // uas_process_op #include "hw/virtio-blk.h" // process_virtio_blk_op #include "malloc.h" // malloc_low #include "output.h" // dprintf @@ -495,6 +496,7 @@ process_op_both(struct disk_op_s *op) case DTYPE_USB: return usb_process_op(op); case DTYPE_UAS: + return uas_process_op(op); case DTYPE_LSI_SCSI: case DTYPE_ESP_SCSI: case DTYPE_MEGASAS: @@ -526,6 +528,7 @@ process_op_32(struct disk_op_s *op) case DTYPE_USB_32: return usb_process_op(op); case DTYPE_UAS_32: + return uas_process_op(op); case DTYPE_VIRTIO_SCSI: case DTYPE_PVSCSI: return scsi_process_op(op); diff --git a/src/hw/blockcmd.c b/src/hw/blockcmd.c index 9b91098..2d80c1f 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-uas.h" // usb_cmd_data #include "util.h" // timer_calc #include "virtio-scsi.h" // virtio_scsi_cmd_data
@@ -26,8 +25,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_UAS: - return uas_cmd_data(op, cdbcmd, blocksize); case DTYPE_LSI_SCSI: return lsi_scsi_cmd_data(op, cdbcmd, blocksize); case DTYPE_ESP_SCSI: @@ -37,9 +34,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_UAS_32: - if (!MODESEGMENT) - return uas_cmd_data(op, cdbcmd, blocksize); case DTYPE_PVSCSI: if (!MODESEGMENT) return pvscsi_cmd_data(op, cdbcmd, blocksize); diff --git a/src/hw/usb-uas.c b/src/hw/usb-uas.c index 6ef8d09..10e3845 100644 --- a/src/hw/usb-uas.c +++ b/src/hw/usb-uas.c @@ -91,7 +91,7 @@ struct uasdrive_s { };
int -uas_cmd_data(struct disk_op_s *op, void *cdbcmd, u16 blocksize) +uas_process_op(struct disk_op_s *op) { if (!CONFIG_USB_UAS) return DISK_RET_EBADTRACK; @@ -104,7 +104,9 @@ uas_cmd_data(struct disk_op_s *op, void *cdbcmd, u16 blocksize) ui.hdr.id = UAS_UI_COMMAND; ui.hdr.tag = 0xdead; ui.command.lun[1] = GET_GLOBALFLAT(drive_gf->lun); - memcpy(ui.command.cdb, cdbcmd, sizeof(ui.command.cdb)); + int blocksize = scsi_fill_cmd(op, ui.command.cdb, sizeof(ui.command.cdb)); + if (blocksize < 0) + return default_process_op(op); int ret = usb_send_bulk(GET_GLOBALFLAT(drive_gf->command), USB_DIR_OUT, MAKE_FLATPTR(GET_SEG(SS), &ui), sizeof(ui.hdr) + sizeof(ui.command)); diff --git a/src/hw/usb-uas.h b/src/hw/usb-uas.h index ad91c5f..8b2f810 100644 --- a/src/hw/usb-uas.h +++ b/src/hw/usb-uas.h @@ -2,7 +2,7 @@ #define __USB_UAS_H
struct disk_op_s; -int uas_cmd_data(struct disk_op_s *op, void *cdbcmd, u16 blocksize); +int uas_process_op(struct disk_op_s *op); struct usbdevice_s; int usb_uas_setup(struct usbdevice_s *usbdev);