aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorKevin O'Connor <kevin@koconnor.net>2015-07-07 14:43:01 -0400
committerKevin O'Connor <kevin@koconnor.net>2015-07-14 14:40:08 -0400
commit5dcd1ee7c32dcd9187f95fabe5bd4770fa8e5072 (patch)
tree39062a4f589a1b9fc32f6ede96af9b2d4a8470cf /src
parentbb05a67220b8d37ac8fce216266bb1821939b3b1 (diff)
downloadseabios-5dcd1ee7c32dcd9187f95fabe5bd4770fa8e5072.tar.gz
blockcmd: Convert cdb_is_read() to scsi_is_read()
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>
Diffstat (limited to 'src')
-rw-r--r--src/hw/blockcmd.c15
-rw-r--r--src/hw/blockcmd.h2
-rw-r--r--src/hw/esp-scsi.c3
-rw-r--r--src/hw/lsi-scsi.c2
-rw-r--r--src/hw/pvscsi.c2
-rw-r--r--src/hw/usb-msc.c2
-rw-r--r--src/hw/virtio-scsi.c2
7 files changed, 14 insertions, 14 deletions
diff --git a/src/hw/blockcmd.c b/src/hw/blockcmd.c
index c56f7f5f..e20e3fc6 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 52b72bc4..b543f85e 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 0266492b..d4e47e3c 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 ad9c3bf6..ad335288 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 4e98b5d5..a462522f 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 3376f2cb..a234f13b 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 8cdcfd0f..80afd04c 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;