[SeaBIOS] [PATCH 09/17] lsi-scsi: Handle LSI drives directly via 'struct disk_op_s' requests

Kevin O'Connor kevin at koconnor.net
Tue Jul 7 21:26:13 CEST 2015


Signed-off-by: Kevin O'Connor <kevin at koconnor.net>
---
 src/block.c       |  2 ++
 src/hw/blockcmd.c |  3 ---
 src/hw/lsi-scsi.c | 30 ++++++++++++------------------
 src/hw/lsi-scsi.h |  2 +-
 4 files changed, 15 insertions(+), 22 deletions(-)

diff --git a/src/block.c b/src/block.c
index 3e76857..99b768c 100644
--- a/src/block.c
+++ b/src/block.c
@@ -10,6 +10,7 @@
 #include "hw/ata.h" // process_ata_op
 #include "hw/ahci.h" // process_ahci_op
 #include "hw/blockcmd.h" // cdb_*
+#include "hw/lsi-scsi.h" // lsi_scsi_process_op
 #include "hw/pci.h" // pci_bdf_to_bus
 #include "hw/rtc.h" // rtc_read
 #include "hw/usb-msc.h" // usb_process_op
@@ -498,6 +499,7 @@ process_op_both(struct disk_op_s *op)
     case DTYPE_UAS:
         return uas_process_op(op);
     case DTYPE_LSI_SCSI:
+        return lsi_scsi_process_op(op);
     case DTYPE_ESP_SCSI:
     case DTYPE_MEGASAS:
         return scsi_process_op(op);
diff --git a/src/hw/blockcmd.c b/src/hw/blockcmd.c
index 2d80c1f..329515c 100644
--- a/src/hw/blockcmd.c
+++ b/src/hw/blockcmd.c
@@ -10,7 +10,6 @@
 #include "blockcmd.h" // struct cdb_request_sense
 #include "byteorder.h" // be32_to_cpu
 #include "esp-scsi.h" // esp_scsi_cmd_data
-#include "lsi-scsi.h" // lsi_scsi_cmd_data
 #include "megasas.h" // megasas_cmd_data
 #include "pvscsi.h" // pvscsi_cmd_data
 #include "output.h" // dprintf
@@ -25,8 +24,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_LSI_SCSI:
-        return lsi_scsi_cmd_data(op, cdbcmd, blocksize);
     case DTYPE_ESP_SCSI:
         return esp_scsi_cmd_data(op, cdbcmd, blocksize);
     case DTYPE_MEGASAS:
diff --git a/src/hw/lsi-scsi.c b/src/hw/lsi-scsi.c
index b1d6bbf..ad9c3bf 100644
--- a/src/hw/lsi-scsi.c
+++ b/src/hw/lsi-scsi.c
@@ -50,10 +50,19 @@ struct lsi_lun_s {
     u8 lun;
 };
 
-static int
-lsi_scsi_cmd(struct lsi_lun_s *llun_gf, struct disk_op_s *op,
-             void *cdbcmd, u16 target, u16 lun, u16 blocksize)
+int
+lsi_scsi_process_op(struct disk_op_s *op)
 {
+    if (!CONFIG_LSI_SCSI)
+        return DISK_RET_EBADTRACK;
+    struct lsi_lun_s *llun_gf =
+        container_of(op->drive_gf, struct lsi_lun_s, drive);
+    u16 target = GET_GLOBALFLAT(llun_gf->target);
+    u16 lun = GET_GLOBALFLAT(llun_gf->lun);
+    u8 cdbcmd[16];
+    int blocksize = scsi_fill_cmd(op, cdbcmd, sizeof(cdbcmd));
+    if (blocksize < 0)
+        return default_process_op(op);
     u32 iobase = GET_GLOBALFLAT(llun_gf->iobase);
     u32 dma = ((cdb_is_read(cdbcmd, blocksize) ? 0x01000000 : 0x00000000) |
                (op->count * blocksize));
@@ -122,21 +131,6 @@ fail:
     return DISK_RET_EBADTRACK;
 }
 
-int
-lsi_scsi_cmd_data(struct disk_op_s *op, void *cdbcmd, u16 blocksize)
-{
-    if (!CONFIG_LSI_SCSI)
-        return DISK_RET_EBADTRACK;
-
-    struct lsi_lun_s *llun_gf =
-        container_of(op->drive_gf, struct lsi_lun_s, drive);
-
-    return lsi_scsi_cmd(llun_gf, op, cdbcmd,
-                        GET_GLOBALFLAT(llun_gf->target),
-                        GET_GLOBALFLAT(llun_gf->lun),
-                        blocksize);
-}
-
 static int
 lsi_scsi_add_lun(struct pci_device *pci, u32 iobase, u8 target, u8 lun)
 {
diff --git a/src/hw/lsi-scsi.h b/src/hw/lsi-scsi.h
index 9c5a9b2..6baf4a1 100644
--- a/src/hw/lsi-scsi.h
+++ b/src/hw/lsi-scsi.h
@@ -2,7 +2,7 @@
 #define __LSI_SCSI_H
 
 struct disk_op_s;
-int lsi_scsi_cmd_data(struct disk_op_s *op, void *cdbcmd, u16 blocksize);
+int lsi_scsi_process_op(struct disk_op_s *op);
 void lsi_scsi_setup(void);
 
 #endif /* __LSI_SCSI_H */
-- 
1.9.3




More information about the SeaBIOS mailing list