]> xenbits.xensource.com Git - seabios.git/commitdiff
blockcmd: Convert cdb_is_read() to scsi_is_read()
authorKevin O'Connor <kevin@koconnor.net>
Tue, 7 Jul 2015 18:43:01 +0000 (14:43 -0400)
committerKevin O'Connor <kevin@koconnor.net>
Tue, 14 Jul 2015 18:40:08 +0000 (14:40 -0400)
Convert the cdb_is_read() function to a new function scsi_is_read()
which takes a 'struct disk_op_s' as a paramter.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
src/hw/blockcmd.c
src/hw/blockcmd.h
src/hw/esp-scsi.c
src/hw/lsi-scsi.c
src/hw/pvscsi.c
src/hw/usb-msc.c
src/hw/virtio-scsi.c

index c56f7f5fd4257541b6d2e9176b51f611dc6c92ba..e20e3fc65887dfffe5f2026a9d89095e4a4a9e55 100644 (file)
 #include "string.h" // memset
 #include "util.h" // timer_calc
 
-// Determine if the command is a request to pull data from the device
-int
-cdb_is_read(u8 *cdbcmd, u16 blocksize)
-{
-    return blocksize && cdbcmd[0] != CDB_CMD_WRITE_10;
-}
-
 
 /****************************************************************
  * Low level command requests
@@ -132,6 +125,14 @@ scsi_fill_cmd(struct disk_op_s *op, void *cdbcmd, int maxcdb)
     }
 }
 
+// Determine if the command is a request to pull data from the device
+int
+scsi_is_read(struct disk_op_s *op)
+{
+    return op->command == CMD_READ || (op->command == CMD_SCSI && op->blocksize);
+}
+
+// Check if a SCSI device is ready to receive commands
 int
 scsi_is_ready(struct disk_op_s *op)
 {
index 52b72bc4d83a8ac80211693a6e7fd9b8c54ef1d3..b543f85ebda1999a6ad782efc9686737c11a6336 100644 (file)
@@ -100,9 +100,9 @@ struct cdbres_mode_sense_geom {
 } PACKED;
 
 // blockcmd.c
-int cdb_is_read(u8 *cdbcmd, u16 blocksize);
 struct disk_op_s;
 int scsi_fill_cmd(struct disk_op_s *op, void *cdbcmd, int maxcdb);
+int scsi_is_read(struct disk_op_s *op);
 int scsi_is_ready(struct disk_op_s *op);
 struct drive_s;
 int scsi_drive_setup(struct drive_s *drive, const char *s, int prio);
index 0266492bb776497b0d2a4c2db511299d61f9dd75..d4e47e3c5ef8dfc12b330ce325aa8b9ffd350a05 100644 (file)
@@ -122,8 +122,7 @@ esp_scsi_process_op(struct disk_op_s *op)
             if (op->count && blocksize) {
                 /* Data phase.  */
                 u32 count = (u32)op->count * blocksize;
-                esp_scsi_dma(iobase, (u32)op->buf_fl, count,
-                             cdb_is_read(cdbcmd, blocksize));
+                esp_scsi_dma(iobase, (u32)op->buf_fl, count, scsi_is_read(op));
                 outb(ESP_CMD_TI | ESP_CMD_DMA, iobase + ESP_CMD);
                 continue;
             }
index ad9c3bf6eaa59467bcaced767e998e5afb33b7c2..ad3352886a53f978b99be0c7388a1d70eb77276b 100644 (file)
@@ -64,7 +64,7 @@ lsi_scsi_process_op(struct disk_op_s *op)
     if (blocksize < 0)
         return default_process_op(op);
     u32 iobase = GET_GLOBALFLAT(llun_gf->iobase);
-    u32 dma = ((cdb_is_read(cdbcmd, blocksize) ? 0x01000000 : 0x00000000) |
+    u32 dma = ((scsi_is_read(op) ? 0x01000000 : 0x00000000) |
                (op->count * blocksize));
     u8 msgout[] = {
         0x80 | lun,                 // select lun
index 4e98b5d56a4a95243e490de2c90893d5c4331e1e..a462522f6751192fe3b71f7a71ff00f167f2107d 100644 (file)
@@ -240,7 +240,7 @@ pvscsi_process_op(struct disk_op_s *op)
     req->cdbLen = 16;
     req->vcpuHint = 0;
     req->tag = SIMPLE_QUEUE_TAG;
-    req->flags = cdb_is_read(req->cdb, blocksize) ?
+    req->flags = scsi_is_read(op) ?
         PVSCSI_FLAG_CMD_DIR_TOHOST : PVSCSI_FLAG_CMD_DIR_TODEVICE;
     req->dataLen = op->count * blocksize;
     req->dataAddr = (u32)op->buf_fl;
index 3376f2cbace1cbc63187cd94243824256aadd055..a234f13bebcdd4424a0720706dcd95e985f704d0 100644 (file)
@@ -83,7 +83,7 @@ usb_process_op(struct disk_op_s *op)
     cbw.dCBWSignature = CBW_SIGNATURE;
     cbw.dCBWTag = 999; // XXX
     cbw.dCBWDataTransferLength = bytes;
-    cbw.bmCBWFlags = cdb_is_read(cbw.CBWCB, blocksize) ? USB_DIR_IN : USB_DIR_OUT;
+    cbw.bmCBWFlags = scsi_is_read(op) ? USB_DIR_IN : USB_DIR_OUT;
     cbw.bCBWLUN = GET_GLOBALFLAT(udrive_gf->lun);
     cbw.bCBWCBLength = USB_CDB_SIZE;
 
index 8cdcfd0fd2ca31997a7785ba77f15049464c71b6..80afd04ca652e85bad1e15ec4d8722f5289de3c5 100644 (file)
@@ -55,7 +55,7 @@ virtio_scsi_process_op(struct disk_op_s *op)
     req.lun[3] = (vlun->lun & 0xff);
 
     u32 len = op->count * blocksize;
-    int datain = cdb_is_read((u8*)req.cdb, blocksize);
+    int datain = scsi_is_read(op);
     int in_num = (datain ? 2 : 1);
     int out_num = (len ? 3 : 2) - in_num;