Support sending scsi style "command data block" commands (cdbcmd) through the 'struct disk_op_s' command request structure. And change the blockcmd.c and cdrom.c code to route these commands through the process_op() code.
Signed-off-by: Kevin O'Connor kevin@koconnor.net --- src/block.h | 13 +++++++++++-- src/cdrom.c | 6 +++--- src/hw/blockcmd.c | 27 ++++++++++++++++++++++----- 3 files changed, 36 insertions(+), 10 deletions(-)
diff --git a/src/block.h b/src/block.h index 2fa52bd..702f357 100644 --- a/src/block.h +++ b/src/block.h @@ -9,11 +9,19 @@ ****************************************************************/
struct disk_op_s { - u64 lba; void *buf_fl; struct drive_s *drive_gf; - u16 count; u8 command; + u16 count; + union { + // Commands: READ, WRITE, VERIFY, SEEK, FORMAT + u64 lba; + // Commands: SCSI + struct { + u16 blocksize; + void *cdbcmd; + }; + }; };
#define CMD_RESET 0x00 @@ -23,6 +31,7 @@ struct disk_op_s { #define CMD_FORMAT 0x05 #define CMD_SEEK 0x07 #define CMD_ISREADY 0x10 +#define CMD_SCSI 0x20
/**************************************************************** diff --git a/src/cdrom.c b/src/cdrom.c index bf1d2a6..60964bd 100644 --- a/src/cdrom.c +++ b/src/cdrom.c @@ -153,7 +153,7 @@ cdrom_boot(struct drive_s *drive) dop.lba = 0x11; dop.count = 1; dop.buf_fl = buffer; - ret = scsi_process_op(&dop); + ret = process_op(&dop); if (ret) return 3;
@@ -169,7 +169,7 @@ cdrom_boot(struct drive_s *drive) // And we read the Boot Catalog dop.lba = lba; dop.count = 1; - ret = scsi_process_op(&dop); + ret = process_op(&dop); if (ret) return 7;
@@ -218,7 +218,7 @@ cdrom_boot(struct drive_s *drive) if (count > 64*1024/CDROM_SECTOR_SIZE) count = 64*1024/CDROM_SECTOR_SIZE; dop.count = count; - ret = scsi_process_op(&dop); + ret = process_op(&dop); if (ret) return 12; nbsectors -= count; diff --git a/src/hw/blockcmd.c b/src/hw/blockcmd.c index ecfeb5d..99ebabc 100644 --- a/src/hw/blockcmd.c +++ b/src/hw/blockcmd.c @@ -80,9 +80,12 @@ cdb_get_inquiry(struct disk_op_s *op, struct cdbres_inquiry *data) memset(&cmd, 0, sizeof(cmd)); cmd.command = CDB_CMD_INQUIRY; cmd.length = sizeof(*data); + op->command = CMD_SCSI; op->count = 1; op->buf_fl = data; - return cdb_cmd_data(op, &cmd, sizeof(*data)); + op->cdbcmd = &cmd; + op->blocksize = sizeof(*data); + return process_op(op); }
// Request SENSE @@ -93,9 +96,12 @@ cdb_get_sense(struct disk_op_s *op, struct cdbres_request_sense *data) memset(&cmd, 0, sizeof(cmd)); cmd.command = CDB_CMD_REQUEST_SENSE; cmd.length = sizeof(*data); + op->command = CMD_SCSI; op->count = 1; op->buf_fl = data; - return cdb_cmd_data(op, &cmd, sizeof(*data)); + op->cdbcmd = &cmd; + op->blocksize = sizeof(*data); + return process_op(op); }
// Test unit ready @@ -105,9 +111,12 @@ cdb_test_unit_ready(struct disk_op_s *op) struct cdb_request_sense cmd; memset(&cmd, 0, sizeof(cmd)); cmd.command = CDB_CMD_TEST_UNIT_READY; + op->command = CMD_SCSI; op->count = 0; op->buf_fl = NULL; - return cdb_cmd_data(op, &cmd, 0); + op->cdbcmd = &cmd; + op->blocksize = 0; + return process_op(op); }
// Request capacity @@ -117,9 +126,12 @@ cdb_read_capacity(struct disk_op_s *op, struct cdbres_read_capacity *data) struct cdb_read_capacity cmd; memset(&cmd, 0, sizeof(cmd)); cmd.command = CDB_CMD_READ_CAPACITY; + op->command = CMD_SCSI; op->count = 1; op->buf_fl = data; - return cdb_cmd_data(op, &cmd, sizeof(*data)); + op->cdbcmd = &cmd; + op->blocksize = sizeof(*data); + return process_op(op); }
// Mode sense, geometry page. @@ -132,9 +144,12 @@ cdb_mode_sense_geom(struct disk_op_s *op, struct cdbres_mode_sense_geom *data) cmd.flags = 8; /* DBD */ cmd.page = MODE_PAGE_HD_GEOMETRY; cmd.count = cpu_to_be16(sizeof(*data)); + op->command = CMD_SCSI; op->count = 1; op->buf_fl = data; - return cdb_cmd_data(op, &cmd, sizeof(*data)); + op->cdbcmd = &cmd; + op->blocksize = sizeof(*data); + return process_op(op); }
// Read sectors. @@ -174,6 +189,8 @@ scsi_process_op(struct disk_op_s *op) return cdb_read(op); case CMD_WRITE: return cdb_write(op); + case CMD_SCSI: + return cdb_cmd_data(op, op->cdbcmd, op->blocksize); default: return default_process_op(op); }