A cdrom boot image could be over 64K in size, but the low level drivers may not support very large reads. If a large cdrom image is found, issue multiple reads so that a read request over 64K is never issued.
Signed-off-by: Kevin O'Connor kevin@koconnor.net --- src/cdrom.c | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-)
diff --git a/src/cdrom.c b/src/cdrom.c index de0e7de..92f34f4 100644 --- a/src/cdrom.c +++ b/src/cdrom.c @@ -212,12 +212,21 @@ cdrom_boot(struct drive_s *drive) CDEmu.device_spec = drive->cntl_id % 2;
// And we read the image in memory + nbsectors = DIV_ROUND_UP(nbsectors, 4); dop.lba = lba; - dop.count = DIV_ROUND_UP(nbsectors, 4); dop.buf_fl = MAKE_FLATPTR(boot_segment, 0); - ret = scsi_process_op(&dop); - if (ret) - return 12; + while (nbsectors) { + int count = nbsectors; + if (count > 64*1024/CDROM_SECTOR_SIZE) + count = 64*1024/CDROM_SECTOR_SIZE; + dop.count = count; + ret = scsi_process_op(&dop); + if (ret) + return 12; + nbsectors -= count; + dop.lba += count; + dop.buf_fl += count*CDROM_SECTOR_SIZE; + }
if (media == 0) { // No emulation requested - return success.
The standard BIOS disk read/write request interface should never get a request for more than 64K of data. Explicitly check for overly large requests and reject them. This way, the low-level drivers do not need to check for or attempt to handle very large requests.
Signed-off-by: Kevin O'Connor kevin@koconnor.net --- src/block.c | 4 ++++ src/disk.c | 2 ++ 2 files changed, 6 insertions(+)
diff --git a/src/block.c b/src/block.c index 43af305..3f7ecb1 100644 --- a/src/block.c +++ b/src/block.c @@ -485,6 +485,10 @@ process_op(struct disk_op_s *op) { ASSERT16(); int ret, origcount = op->count; + if (origcount * GET_GLOBALFLAT(op->drive_gf->blksize) > 64*1024) { + op->count = 0; + return DISK_RET_EBOUNDARY; + } u8 type = GET_GLOBALFLAT(op->drive_gf->type); switch (type) { case DTYPE_FLOPPY: diff --git a/src/disk.c b/src/disk.c index fe2e2c3..0e0af24 100644 --- a/src/disk.c +++ b/src/disk.c @@ -173,6 +173,7 @@ disk_1300(struct bregs *regs, struct drive_s *drive_gf) struct disk_op_s dop; dop.drive_gf = drive_gf; dop.command = CMD_RESET; + dop.count = 0; int status = send_disk_op(&dop); disk_ret(regs, status); } @@ -322,6 +323,7 @@ disk_1310(struct bregs *regs, struct drive_s *drive_gf) struct disk_op_s dop; dop.drive_gf = drive_gf; dop.command = CMD_ISREADY; + dop.count = 0; int status = send_disk_op(&dop); disk_ret(regs, status); }