]> xenbits.xensource.com Git - seabios.git/commitdiff
ata: Handle ATA ATAPI drives directly via 'struct disk_op_s' requests
authorKevin O'Connor <kevin@koconnor.net>
Tue, 7 Jul 2015 15:11:46 +0000 (11:11 -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/ata.c
src/hw/ata.h
src/hw/blockcmd.c

index 1d628f9c328acdaf483347f050560109aa8521cc..8bd9398d1950b18dbc2affb1a7176ab32fb56840 100644 (file)
@@ -502,7 +502,7 @@ process_op_both(struct disk_op_s *op)
 {
     switch (GET_GLOBALFLAT(op->drive_gf->type)) {
     case DTYPE_ATA_ATAPI:
-        return process_atapi_op(op);
+        return ata_atapi_process_op(op);
     case DTYPE_USB:
     case DTYPE_UAS:
     case DTYPE_LSI_SCSI:
index d674f61468c762e8044b197e8dd8ef3f08b439e1..b5bd75f463e33d311b228711ff665015b9fee90d 100644 (file)
@@ -583,11 +583,18 @@ process_ata_op(struct disk_op_s *op)
 
 // Low-level atapi command transmit function.
 int
-atapi_cmd_data(struct disk_op_s *op, void *cdbcmd, u16 blocksize)
+ata_atapi_process_op(struct disk_op_s *op)
 {
     if (! CONFIG_ATA)
         return 0;
 
+    if (op->command == CMD_WRITE || op->command == CMD_FORMAT)
+        return DISK_RET_EWRITEPROTECT;
+    u8 cdbcmd[CDROM_CDB_SIZE];
+    int blocksize = scsi_fill_cmd(op, cdbcmd, sizeof(cdbcmd));
+    if (blocksize < 0)
+        return default_process_op(op);
+
     struct atadrive_s *adrive_gf = container_of(
         op->drive_gf, struct atadrive_s, drive);
     struct ata_channel_s *chan_gf = GET_GLOBALFLAT(adrive_gf->chan_gf);
index c73892bbe90c1eed1c13a4a03ab5e561f3aec5f2..3a7ab6558f030a1cc0455b843471014938f964b3 100644 (file)
@@ -25,7 +25,7 @@ struct atadrive_s {
 char *ata_extract_model(char *model, u32 size, u16 *buffer);
 int ata_extract_version(u16 *buffer);
 int cdrom_read(struct disk_op_s *op);
-int atapi_cmd_data(struct disk_op_s *op, void *cdbcmd, u16 blocksize);
+int ata_atapi_process_op(struct disk_op_s *op);
 void ata_setup(void);
 int process_ata_op(struct disk_op_s *op);
 
index 004c58f5aa259a2f36f3da9e59962d6ff2b6b8c6..d227d179fbe209abfedd9eab013bd32075588bf6 100644 (file)
@@ -6,7 +6,6 @@
 // This file may be distributed under the terms of the GNU LGPLv3 license.
 
 #include "ahci.h" // atapi_cmd_data
-#include "ata.h" // atapi_cmd_data
 #include "biosvar.h" // GET_GLOBALFLAT
 #include "block.h" // struct disk_op_s
 #include "blockcmd.h" // struct cdb_request_sense
@@ -29,8 +28,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_ATA_ATAPI:
-        return atapi_cmd_data(op, cdbcmd, blocksize);
     case DTYPE_USB:
         return usb_cmd_data(op, cdbcmd, blocksize);
     case DTYPE_UAS: