]> xenbits.xensource.com Git - seabios.git/commitdiff
ahci: Handle AHCI ATAPI drives directly via 'struct disk_op_s' requests
authorKevin O'Connor <kevin@koconnor.net>
Tue, 7 Jul 2015 15:24:27 +0000 (11:24 -0400)
committerKevin O'Connor <kevin@koconnor.net>
Tue, 14 Jul 2015 18:40:08 +0000 (14:40 -0400)
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
src/block.c
src/hw/ahci.c
src/hw/ahci.h
src/hw/blockcmd.c

index 8bd9398d1950b18dbc2affb1a7176ab32fb56840..5f238c7169d5d6c8aabb04fbd8b22071292440fc 100644 (file)
@@ -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:
index ad813cec96e0be41f06a2b89b81961949506abdc..726fe25eed1da6463186a183c838d3bf7f3ea8c8 100644 (file)
@@ -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,14 @@ 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;
index c8c755a3fbcaefc0bdf3631e960a86d6d16ae004..16ad6a984f6251dbf56b254f28d7ff52cf4c8cf7 100644 (file)
@@ -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)
index d227d179fbe209abfedd9eab013bd32075588bf6..20bd59e645aaba52af896b2991cfcb68960b7006 100644 (file)
@@ -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;
     }