This is just code movement - no code changes.
Signed-off-by: Kevin O'Connor kevin@koconnor.net --- src/hw/blockcmd.c | 186 ++++++++++++++++++++++++++++-------------------------- 1 file changed, 98 insertions(+), 88 deletions(-)
diff --git a/src/hw/blockcmd.c b/src/hw/blockcmd.c index eb531d4..bbcc08f 100644 --- a/src/hw/blockcmd.c +++ b/src/hw/blockcmd.c @@ -67,6 +67,104 @@ cdb_is_read(u8 *cdbcmd, u16 blocksize) return blocksize && cdbcmd[0] != CDB_CMD_WRITE_10; }
+ +/**************************************************************** + * Low level command requests + ****************************************************************/ + +int +cdb_get_inquiry(struct disk_op_s *op, struct cdbres_inquiry *data) +{ + struct cdb_request_sense cmd; + memset(&cmd, 0, sizeof(cmd)); + cmd.command = CDB_CMD_INQUIRY; + cmd.length = sizeof(*data); + op->count = 1; + op->buf_fl = data; + return cdb_cmd_data(op, &cmd, sizeof(*data)); +} + +// Request SENSE +int +cdb_get_sense(struct disk_op_s *op, struct cdbres_request_sense *data) +{ + struct cdb_request_sense cmd; + memset(&cmd, 0, sizeof(cmd)); + cmd.command = CDB_CMD_REQUEST_SENSE; + cmd.length = sizeof(*data); + op->count = 1; + op->buf_fl = data; + return cdb_cmd_data(op, &cmd, sizeof(*data)); +} + +// Test unit ready +int +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->count = 0; + op->buf_fl = NULL; + return cdb_cmd_data(op, &cmd, 0); +} + +// Request capacity +int +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->count = 1; + op->buf_fl = data; + return cdb_cmd_data(op, &cmd, sizeof(*data)); +} + +// Mode sense, geometry page. +int +cdb_mode_sense_geom(struct disk_op_s *op, struct cdbres_mode_sense_geom *data) +{ + struct cdb_mode_sense cmd; + memset(&cmd, 0, sizeof(cmd)); + cmd.command = CDB_CMD_MODE_SENSE; + cmd.flags = 8; /* DBD */ + cmd.page = MODE_PAGE_HD_GEOMETRY; + cmd.count = cpu_to_be16(sizeof(*data)); + op->count = 1; + op->buf_fl = data; + return cdb_cmd_data(op, &cmd, sizeof(*data)); +} + +// Read sectors. +int +cdb_read(struct disk_op_s *op) +{ + struct cdb_rwdata_10 cmd; + memset(&cmd, 0, sizeof(cmd)); + cmd.command = CDB_CMD_READ_10; + cmd.lba = cpu_to_be32(op->lba); + cmd.count = cpu_to_be16(op->count); + return cdb_cmd_data(op, &cmd, GET_GLOBALFLAT(op->drive_gf->blksize)); +} + +// Write sectors. +int +cdb_write(struct disk_op_s *op) +{ + struct cdb_rwdata_10 cmd; + memset(&cmd, 0, sizeof(cmd)); + cmd.command = CDB_CMD_WRITE_10; + cmd.lba = cpu_to_be32(op->lba); + cmd.count = cpu_to_be16(op->count); + return cdb_cmd_data(op, &cmd, GET_GLOBALFLAT(op->drive_gf->blksize)); +} + + +/**************************************************************** + * Main SCSI commands + ****************************************************************/ + int scsi_is_ready(struct disk_op_s *op) { @@ -200,91 +298,3 @@ scsi_drive_setup(struct drive_s *drive, const char *s, int prio) boot_add_hd(drive, desc, prio); return 0; } - -int -cdb_get_inquiry(struct disk_op_s *op, struct cdbres_inquiry *data) -{ - struct cdb_request_sense cmd; - memset(&cmd, 0, sizeof(cmd)); - cmd.command = CDB_CMD_INQUIRY; - cmd.length = sizeof(*data); - op->count = 1; - op->buf_fl = data; - return cdb_cmd_data(op, &cmd, sizeof(*data)); -} - -// Request SENSE -int -cdb_get_sense(struct disk_op_s *op, struct cdbres_request_sense *data) -{ - struct cdb_request_sense cmd; - memset(&cmd, 0, sizeof(cmd)); - cmd.command = CDB_CMD_REQUEST_SENSE; - cmd.length = sizeof(*data); - op->count = 1; - op->buf_fl = data; - return cdb_cmd_data(op, &cmd, sizeof(*data)); -} - -// Test unit ready -int -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->count = 0; - op->buf_fl = NULL; - return cdb_cmd_data(op, &cmd, 0); -} - -// Request capacity -int -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->count = 1; - op->buf_fl = data; - return cdb_cmd_data(op, &cmd, sizeof(*data)); -} - -// Mode sense, geometry page. -int -cdb_mode_sense_geom(struct disk_op_s *op, struct cdbres_mode_sense_geom *data) -{ - struct cdb_mode_sense cmd; - memset(&cmd, 0, sizeof(cmd)); - cmd.command = CDB_CMD_MODE_SENSE; - cmd.flags = 8; /* DBD */ - cmd.page = MODE_PAGE_HD_GEOMETRY; - cmd.count = cpu_to_be16(sizeof(*data)); - op->count = 1; - op->buf_fl = data; - return cdb_cmd_data(op, &cmd, sizeof(*data)); -} - -// Read sectors. -int -cdb_read(struct disk_op_s *op) -{ - struct cdb_rwdata_10 cmd; - memset(&cmd, 0, sizeof(cmd)); - cmd.command = CDB_CMD_READ_10; - cmd.lba = cpu_to_be32(op->lba); - cmd.count = cpu_to_be16(op->count); - return cdb_cmd_data(op, &cmd, GET_GLOBALFLAT(op->drive_gf->blksize)); -} - -// Write sectors. -int -cdb_write(struct disk_op_s *op) -{ - struct cdb_rwdata_10 cmd; - memset(&cmd, 0, sizeof(cmd)); - cmd.command = CDB_CMD_WRITE_10; - cmd.lba = cpu_to_be32(op->lba); - cmd.count = cpu_to_be16(op->count); - return cdb_cmd_data(op, &cmd, GET_GLOBALFLAT(op->drive_gf->blksize)); -}
Signed-off-by: Kevin O'Connor kevin@koconnor.net --- src/block.c | 27 ++++----------------------- src/hw/blockcmd.c | 19 +++++++++++++++++++ src/hw/blockcmd.h | 1 + 3 files changed, 24 insertions(+), 23 deletions(-)
diff --git a/src/block.c b/src/block.c index c6d53c1..43af305 100644 --- a/src/block.c +++ b/src/block.c @@ -468,25 +468,6 @@ fill_edd(u16 seg, struct int13dpt_s *param_far, struct drive_s *drive_gf) ****************************************************************/
int VISIBLE32FLAT -process_scsi_op(struct disk_op_s *op) -{ - switch (op->command) { - case CMD_READ: - return cdb_read(op); - case CMD_WRITE: - return cdb_write(op); - case CMD_FORMAT: - case CMD_RESET: - case CMD_ISREADY: - case CMD_VERIFY: - case CMD_SEEK: - return DISK_RET_SUCCESS; - default: - return DISK_RET_EPARAM; - } -} - -int VISIBLE32FLAT process_atapi_op(struct disk_op_s *op) { switch (op->command) { @@ -494,7 +475,7 @@ process_atapi_op(struct disk_op_s *op) case CMD_FORMAT: return DISK_RET_EWRITEPROTECT; default: - return process_scsi_op(op); + return scsi_process_op(op); } }
@@ -545,13 +526,13 @@ process_op(struct disk_op_s *op) case DTYPE_LSI_SCSI: case DTYPE_ESP_SCSI: case DTYPE_MEGASAS: - ret = process_scsi_op(op); + ret = scsi_process_op(op); break; case DTYPE_USB_32: case DTYPE_UAS_32: case DTYPE_PVSCSI: ; - extern void _cfunc32flat_process_scsi_op(void); - ret = call32(_cfunc32flat_process_scsi_op + extern void _cfunc32flat_scsi_process_op(void); + ret = call32(_cfunc32flat_scsi_process_op , (u32)MAKE_FLATPTR(GET_SEG(SS), op), DISK_RET_EPARAM); break; default: diff --git a/src/hw/blockcmd.c b/src/hw/blockcmd.c index bbcc08f..ad8814c 100644 --- a/src/hw/blockcmd.c +++ b/src/hw/blockcmd.c @@ -165,6 +165,25 @@ cdb_write(struct disk_op_s *op) * Main SCSI commands ****************************************************************/
+int VISIBLE32FLAT +scsi_process_op(struct disk_op_s *op) +{ + switch (op->command) { + case CMD_READ: + return cdb_read(op); + case CMD_WRITE: + return cdb_write(op); + case CMD_FORMAT: + case CMD_RESET: + case CMD_ISREADY: + case CMD_VERIFY: + case CMD_SEEK: + return DISK_RET_SUCCESS; + default: + return DISK_RET_EPARAM; + } +} + int scsi_is_ready(struct disk_op_s *op) { diff --git a/src/hw/blockcmd.h b/src/hw/blockcmd.h index 8bacfcf..429b669 100644 --- a/src/hw/blockcmd.h +++ b/src/hw/blockcmd.h @@ -111,6 +111,7 @@ int cdb_inquiry(struct disk_op_s *op, struct cdbres_inquiry *data); int cdb_read(struct disk_op_s *op); int cdb_write(struct disk_op_s *op);
+int scsi_process_op(struct disk_op_s *op); int scsi_is_ready(struct disk_op_s *op); struct drive_s; int scsi_drive_setup(struct drive_s *drive, const char *s, int prio);
Use the scsi_process_op() function instead of the lower level cdb_read() function.
Signed-off-by: Kevin O'Connor kevin@koconnor.net --- src/cdrom.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-)
diff --git a/src/cdrom.c b/src/cdrom.c index 86e3f0c..de0e7de 100644 --- a/src/cdrom.c +++ b/src/cdrom.c @@ -154,10 +154,11 @@ cdrom_boot(struct drive_s *drive)
// Read the Boot Record Volume Descriptor u8 buffer[CDROM_SECTOR_SIZE]; + dop.command = CMD_READ; dop.lba = 0x11; dop.count = 1; dop.buf_fl = buffer; - ret = cdb_read(&dop); + ret = scsi_process_op(&dop); if (ret) return 3;
@@ -173,7 +174,7 @@ cdrom_boot(struct drive_s *drive) // And we read the Boot Catalog dop.lba = lba; dop.count = 1; - ret = cdb_read(&dop); + ret = scsi_process_op(&dop); if (ret) return 7;
@@ -214,7 +215,7 @@ cdrom_boot(struct drive_s *drive) dop.lba = lba; dop.count = DIV_ROUND_UP(nbsectors, 4); dop.buf_fl = MAKE_FLATPTR(boot_segment, 0); - ret = cdb_read(&dop); + ret = scsi_process_op(&dop); if (ret) return 12;
The low-level cdb_* functions are now only used from within cmdblock.c, so don't export them.
Signed-off-by: Kevin O'Connor kevin@koconnor.net --- src/hw/blockcmd.c | 14 +++++++------- src/hw/blockcmd.h | 9 --------- 2 files changed, 7 insertions(+), 16 deletions(-)
diff --git a/src/hw/blockcmd.c b/src/hw/blockcmd.c index ad8814c..78c0e65 100644 --- a/src/hw/blockcmd.c +++ b/src/hw/blockcmd.c @@ -72,7 +72,7 @@ cdb_is_read(u8 *cdbcmd, u16 blocksize) * Low level command requests ****************************************************************/
-int +static int cdb_get_inquiry(struct disk_op_s *op, struct cdbres_inquiry *data) { struct cdb_request_sense cmd; @@ -85,7 +85,7 @@ cdb_get_inquiry(struct disk_op_s *op, struct cdbres_inquiry *data) }
// Request SENSE -int +static int cdb_get_sense(struct disk_op_s *op, struct cdbres_request_sense *data) { struct cdb_request_sense cmd; @@ -98,7 +98,7 @@ cdb_get_sense(struct disk_op_s *op, struct cdbres_request_sense *data) }
// Test unit ready -int +static int cdb_test_unit_ready(struct disk_op_s *op) { struct cdb_request_sense cmd; @@ -110,7 +110,7 @@ cdb_test_unit_ready(struct disk_op_s *op) }
// Request capacity -int +static int cdb_read_capacity(struct disk_op_s *op, struct cdbres_read_capacity *data) { struct cdb_read_capacity cmd; @@ -122,7 +122,7 @@ cdb_read_capacity(struct disk_op_s *op, struct cdbres_read_capacity *data) }
// Mode sense, geometry page. -int +static int cdb_mode_sense_geom(struct disk_op_s *op, struct cdbres_mode_sense_geom *data) { struct cdb_mode_sense cmd; @@ -137,7 +137,7 @@ cdb_mode_sense_geom(struct disk_op_s *op, struct cdbres_mode_sense_geom *data) }
// Read sectors. -int +static int cdb_read(struct disk_op_s *op) { struct cdb_rwdata_10 cmd; @@ -149,7 +149,7 @@ cdb_read(struct disk_op_s *op) }
// Write sectors. -int +static int cdb_write(struct disk_op_s *op) { struct cdb_rwdata_10 cmd; diff --git a/src/hw/blockcmd.h b/src/hw/blockcmd.h index 429b669..df12a6d 100644 --- a/src/hw/blockcmd.h +++ b/src/hw/blockcmd.h @@ -102,15 +102,6 @@ struct cdbres_mode_sense_geom { // blockcmd.c int cdb_is_read(u8 *cdbcmd, u16 blocksize); struct disk_op_s; -int cdb_get_inquiry(struct disk_op_s *op, struct cdbres_inquiry *data); -int cdb_get_sense(struct disk_op_s *op, struct cdbres_request_sense *data); -int cdb_test_unit_ready(struct disk_op_s *op); -int cdb_read_capacity(struct disk_op_s *op, struct cdbres_read_capacity *data); -int cdb_mode_sense_geom(struct disk_op_s *op, struct cdbres_mode_sense_geom *data); -int cdb_inquiry(struct disk_op_s *op, struct cdbres_inquiry *data); -int cdb_read(struct disk_op_s *op); -int cdb_write(struct disk_op_s *op); - int scsi_process_op(struct disk_op_s *op); int scsi_is_ready(struct disk_op_s *op); struct drive_s;