[SeaBIOS] [PATCH 06/17] ahci: Handle AHCI ATAPI drives directly via 'struct disk_op_s' requests

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


Signed-off-by: Kevin O'Connor <kevin at koconnor.net>
---
 src/block.c       | 14 +-------------
 src/hw/ahci.c     | 16 ++++++++--------
 src/hw/ahci.h     |  2 +-
 src/hw/blockcmd.c |  4 ----
 4 files changed, 10 insertions(+), 26 deletions(-)

diff --git a/src/block.c b/src/block.c
index 8bd9398..5f238c7 100644
--- a/src/block.c
+++ b/src/block.c
@@ -484,18 +484,6 @@ default_process_op(struct disk_op_s *op)
     }
 }
 
-static int
-process_atapi_op(struct disk_op_s *op)
-{
-    switch (op->command) {
-    case CMD_WRITE:
-    case CMD_FORMAT:
-        return DISK_RET_EWRITEPROTECT;
-    default:
-        return scsi_process_op(op);
-    }
-}
-
 // Command dispatch for disk drivers that run in both 16bit and 32bit mode
 static int
 process_op_both(struct disk_op_s *op)
@@ -530,7 +518,7 @@ process_op_32(struct disk_op_s *op)
     case DTYPE_AHCI:
         return process_ahci_op(op);
     case DTYPE_AHCI_ATAPI:
-        return process_atapi_op(op);
+        return ahci_atapi_process_op(op);
     case DTYPE_SDCARD:
         return process_sdcard_op(op);
     case DTYPE_USB_32:
diff --git a/src/hw/ahci.c b/src/hw/ahci.c
index ad813ce..72ba230 100644
--- a/src/hw/ahci.c
+++ b/src/hw/ahci.c
@@ -213,7 +213,7 @@ static int ahci_command(struct ahci_port_s *port_gf, int iswrite, int isatapi,
 
 #define CDROM_CDB_SIZE 12
 
-int ahci_cmd_data(struct disk_op_s *op, void *cdbcmd, u16 blocksize)
+int ahci_atapi_process_op(struct disk_op_s *op)
 {
     if (! CONFIG_AHCI)
         return 0;
@@ -221,15 +221,15 @@ int ahci_cmd_data(struct disk_op_s *op, void *cdbcmd, u16 blocksize)
     struct ahci_port_s *port_gf = container_of(
         op->drive_gf, struct ahci_port_s, drive);
     struct ahci_cmd_s *cmd = port_gf->cmd;
-    u8 *atapi = cdbcmd;
-    int i, rc;
 
+    if (op->command == CMD_WRITE || op->command == CMD_FORMAT)
+        return DISK_RET_EWRITEPROTECT;
+    int blocksize = scsi_fill_cmd(op, cmd->atapi, CDROM_CDB_SIZE);
+    if (blocksize < 0)
+        return default_process_op(op);
     sata_prep_atapi(&cmd->fis, blocksize);
-    for (i = 0; i < CDROM_CDB_SIZE; i++) {
-        cmd->atapi[i] = atapi[i];
-    }
-    rc = ahci_command(port_gf, 0, 1, op->buf_fl,
-                      op->count * blocksize);
+    int rc = ahci_command(port_gf, 0, 1, op->buf_fl,
+                          op->count * blocksize);
     if (rc < 0)
         return DISK_RET_EBADTRACK;
     return DISK_RET_SUCCESS;
diff --git a/src/hw/ahci.h b/src/hw/ahci.h
index c8c755a..16ad6a9 100644
--- a/src/hw/ahci.h
+++ b/src/hw/ahci.h
@@ -84,7 +84,7 @@ struct ahci_port_s {
 
 void ahci_setup(void);
 int process_ahci_op(struct disk_op_s *op);
-int ahci_cmd_data(struct disk_op_s *op, void *cdbcmd, u16 blocksize);
+int ahci_atapi_process_op(struct disk_op_s *op);
 
 #define AHCI_IRQ_ON_SG            (1 << 31)
 #define AHCI_CMD_ATAPI            (1 << 5)
diff --git a/src/hw/blockcmd.c b/src/hw/blockcmd.c
index d227d17..20bd59e 100644
--- a/src/hw/blockcmd.c
+++ b/src/hw/blockcmd.c
@@ -5,7 +5,6 @@
 //
 // This file may be distributed under the terms of the GNU LGPLv3 license.
 
-#include "ahci.h" // atapi_cmd_data
 #include "biosvar.h" // GET_GLOBALFLAT
 #include "block.h" // struct disk_op_s
 #include "blockcmd.h" // struct cdb_request_sense
@@ -50,9 +49,6 @@ cdb_cmd_data(struct disk_op_s *op, void *cdbcmd, u16 blocksize)
     case DTYPE_PVSCSI:
         if (!MODESEGMENT)
             return pvscsi_cmd_data(op, cdbcmd, blocksize);
-    case DTYPE_AHCI_ATAPI:
-        if (!MODESEGMENT)
-            return ahci_cmd_data(op, cdbcmd, blocksize);
     default:
         return DISK_RET_EPARAM;
     }
-- 
1.9.3




More information about the SeaBIOS mailing list