aboutsummaryrefslogtreecommitdiffstats
path: root/src/cdrom.c
diff options
context:
space:
mode:
authorKevin O'Connor <kevin@koconnor.net>2008-03-22 23:13:24 -0400
committerKevin O'Connor <kevin@koconnor.net>2008-03-22 23:13:24 -0400
commitaa2590c55834f9d1f0f07a3c05ac8ca54f6dc69a (patch)
tree6281462a17451281d056f21cbade559b8713f8c1 /src/cdrom.c
parent070231b908d0f84c3ab1fb970318f0fb5f7e281a (diff)
downloadseabios-aa2590c55834f9d1f0f07a3c05ac8ca54f6dc69a.tar.gz
Cleanup cdrom emulation.
Remove 'header' param for ata_cmd_packet - the only code that uses it is cdrom emulation. So, bury this detail in ata.c. Introduce new helpers cdrom_read_emu and cdrom_read_512 for working with emulated cdrom drives. Unify basic_access() and emu_access() - now basic_access() can read from cdrom drives.
Diffstat (limited to 'src/cdrom.c')
-rw-r--r--src/cdrom.c43
1 files changed, 20 insertions, 23 deletions
diff --git a/src/cdrom.c b/src/cdrom.c
index fc616e1a..875b9e30 100644
--- a/src/cdrom.c
+++ b/src/cdrom.c
@@ -179,18 +179,13 @@ cdrom_13(struct bregs *regs, u8 device)
* CD emulation
****************************************************************/
-// read disk sectors
-static void
-cdemu_1302(struct bregs *regs, u8 device)
-{
- emu_access(regs, device, ATA_CMD_READ_SECTORS);
-}
-
-// verify disk sectors
-static void
-cdemu_1304(struct bregs *regs, u8 device)
+// Read a series of 512 byte sectors from the cdrom starting at the
+// image offset.
+inline int
+cdrom_read_emu(u16 biosid, u32 vlba, u32 count, void *far_buffer)
{
- emu_access(regs, device, 0);
+ u32 ilba = GET_EBDA(cdemu.ilba);
+ return cdrom_read_512(biosid, ilba * 4 + vlba, count, far_buffer);
}
// read disk drive parameters
@@ -228,9 +223,14 @@ cdemu_13(struct bregs *regs)
device += GET_EBDA(cdemu.device_spec);
switch (regs->ah) {
- case 0x02: cdemu_1302(regs, device); break;
- case 0x04: cdemu_1304(regs, device); break;
+ // These functions are the same as for hard disks
+ case 0x02:
+ case 0x04:
+ disk_13(regs, device);
+ break;
+
case 0x08: cdemu_1308(regs, device); break;
+
// XXX - All other calls get passed to standard CDROM functions.
default: cdrom_13(regs, device); break;
}
@@ -295,8 +295,7 @@ atapi_get_sense(u16 device, u8 *asc, u8 *ascq)
memset(atacmd, 0, sizeof(atacmd));
atacmd[0] = ATA_CMD_REQUEST_SENSE;
atacmd[4] = sizeof(buffer);
- u16 ret = ata_cmd_packet(device, atacmd, sizeof(atacmd)
- , 0, sizeof(buffer)
+ u16 ret = ata_cmd_packet(device, atacmd, sizeof(atacmd), sizeof(buffer)
, MAKE_FARPTR(GET_SEG(SS), (u32)buffer));
if (ret != 0)
return 0x0002;
@@ -332,8 +331,7 @@ atapi_is_ready(u16 device)
DEBUGF("read capacity failed\n");
return -1;
}
- u16 ret = ata_cmd_packet(device, packet, sizeof(packet)
- , 0, sizeof(buf)
+ u16 ret = ata_cmd_packet(device, packet, sizeof(packet), sizeof(buf)
, MAKE_FARPTR(GET_SEG(SS), (u32)buf));
if (ret == 0)
break;
@@ -431,8 +429,8 @@ cdrom_boot()
// Read the Boot Record Volume Descriptor
u8 buffer[2048];
- ret = cdrom_read(device, 0x11, 2048
- , MAKE_FARPTR(GET_SEG(SS), (u32)buffer), 0);
+ ret = cdrom_read(device, 0x11, 1
+ , MAKE_FARPTR(GET_SEG(SS), (u32)buffer));
if (ret)
return 3;
@@ -446,8 +444,8 @@ cdrom_boot()
u32 lba = *(u32*)&buffer[0x47];
// And we read the Boot Catalog
- ret = cdrom_read(device, lba, 2048
- , MAKE_FARPTR(GET_SEG(SS), (u32)buffer), 0);
+ ret = cdrom_read(device, lba, 1
+ , MAKE_FARPTR(GET_SEG(SS), (u32)buffer));
if (ret)
return 7;
@@ -484,8 +482,7 @@ cdrom_boot()
SET_EBDA(cdemu.ilba, lba);
// And we read the image in memory
- ret = cdrom_read(device, lba, nbsectors*512
- , MAKE_FARPTR(boot_segment, 0), 0);
+ ret = cdrom_read_emu(device, 0, nbsectors, MAKE_FARPTR(boot_segment, 0));
if (ret)
return 12;