Signed-off-by: Kevin O'Connor kevin@koconnor.net --- src/block.c | 2 +- src/hw/ata.c | 9 ++++++++- src/hw/ata.h | 2 +- src/hw/blockcmd.c | 3 --- 4 files changed, 10 insertions(+), 6 deletions(-)
diff --git a/src/block.c b/src/block.c index 1d628f9..8bd9398 100644 --- a/src/block.c +++ b/src/block.c @@ -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: diff --git a/src/hw/ata.c b/src/hw/ata.c index d674f61..b5bd75f 100644 --- a/src/hw/ata.c +++ b/src/hw/ata.c @@ -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); diff --git a/src/hw/ata.h b/src/hw/ata.h index c73892b..3a7ab65 100644 --- a/src/hw/ata.h +++ b/src/hw/ata.h @@ -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);
diff --git a/src/hw/blockcmd.c b/src/hw/blockcmd.c index 004c58f..d227d17 100644 --- a/src/hw/blockcmd.c +++ b/src/hw/blockcmd.c @@ -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: