diff options
author | Kevin O'Connor <kevin@koconnor.net> | 2014-12-29 10:15:57 -0500 |
---|---|---|
committer | Kevin O'Connor <kevin@koconnor.net> | 2014-12-29 10:15:57 -0500 |
commit | c08ef9a777d3bec4deaad564bcf510e8f0b27ff6 (patch) | |
tree | 78bac20f464a7b81ce46a3780ba1fde752a39058 | |
parent | ef102af2a91a2b7fa3c5aaeee02df87334da6670 (diff) | |
download | seabios-c08ef9a777d3bec4deaad564bcf510e8f0b27ff6.zip seabios-c08ef9a777d3bec4deaad564bcf510e8f0b27ff6.tar.gz seabios-c08ef9a777d3bec4deaad564bcf510e8f0b27ff6.tar.bz2 |
cdrom: Break up very large read requests into smaller requests
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>
-rw-r--r-- | src/cdrom.c | 17 |
1 files 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. |