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 | 15 ++++++++------- src/hw/blockcmd.h | 2 +- src/hw/esp-scsi.c | 3 +-- src/hw/lsi-scsi.c | 2 +- src/hw/pvscsi.c | 2 +- src/hw/usb-msc.c | 2 +- src/hw/virtio-scsi.c | 2 +- 7 files changed, 14 insertions(+), 14 deletions(-)
diff --git a/src/hw/blockcmd.c b/src/hw/blockcmd.c index c56f7f5..e20e3fc 100644 --- a/src/hw/blockcmd.c +++ b/src/hw/blockcmd.c @@ -14,13 +14,6 @@ #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) { diff --git a/src/hw/blockcmd.h b/src/hw/blockcmd.h index 52b72bc..b543f85 100644 --- a/src/hw/blockcmd.h +++ b/src/hw/blockcmd.h @@ -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); diff --git a/src/hw/esp-scsi.c b/src/hw/esp-scsi.c index 0266492..d4e47e3 100644 --- a/src/hw/esp-scsi.c +++ b/src/hw/esp-scsi.c @@ -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; } diff --git a/src/hw/lsi-scsi.c b/src/hw/lsi-scsi.c index ad9c3bf..ad33528 100644 --- a/src/hw/lsi-scsi.c +++ b/src/hw/lsi-scsi.c @@ -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 diff --git a/src/hw/pvscsi.c b/src/hw/pvscsi.c index 4e98b5d..a462522 100644 --- a/src/hw/pvscsi.c +++ b/src/hw/pvscsi.c @@ -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; diff --git a/src/hw/usb-msc.c b/src/hw/usb-msc.c index 3376f2c..a234f13 100644 --- a/src/hw/usb-msc.c +++ b/src/hw/usb-msc.c @@ -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;
diff --git a/src/hw/virtio-scsi.c b/src/hw/virtio-scsi.c index 8cdcfd0..80afd04 100644 --- a/src/hw/virtio-scsi.c +++ b/src/hw/virtio-scsi.c @@ -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;