]> xenbits.xensource.com Git - seabios.git/commitdiff
usb-msc: Handle USB drives directly via 'struct disk_op_s' requests
authorKevin O'Connor <kevin@koconnor.net>
Tue, 7 Jul 2015 15:35:25 +0000 (11:35 -0400)
committerKevin O'Connor <kevin@koconnor.net>
Tue, 14 Jul 2015 18:40:08 +0000 (14:40 -0400)
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
src/block.c
src/hw/blockcmd.c
src/hw/usb-msc.c
src/hw/usb-msc.h

index 5f238c7169d5d6c8aabb04fbd8b22071292440fc..3aa759514c92171571b072181874845913ba246f 100644 (file)
@@ -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:
index 20bd59e645aaba52af896b2991cfcb68960b7006..9b91098f7965f3821ce7089eb81ec1f720d94339 100644 (file)
@@ -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);
index d90319f51f52b019ee122145a1f1106d27026e84..3376f2cbace1cbc63187cd94243824256aadd055 100644 (file)
@@ -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;
 
index c40d755562e3cdbcce517b4b7e9bd17ee565e75f..ff3c38038fb3f23c83038827a460f03b88777847 100644 (file)
@@ -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);