diff options
author | Kevin O'Connor <kevin@koconnor.net> | 2008-03-22 20:13:08 -0400 |
---|---|---|
committer | Kevin O'Connor <kevin@koconnor.net> | 2008-03-22 20:13:08 -0400 |
commit | dfa165052c4eca5d90ecf9e44803791f428a4068 (patch) | |
tree | 4efde8443480b7ba7248d4e9e61dad76b622daf0 | |
parent | faa8b6f1bb40d74943baa19df2e8694e9cb9cb12 (diff) | |
download | seabios-dfa165052c4eca5d90ecf9e44803791f428a4068.tar.gz |
Breakout cdrom emulation support into CONFIG_CDROM_EMU.
This allows one to support just booting from cdroms that don't require
floppy/harddisk emulation.
-rw-r--r-- | src/boot.c | 1 | ||||
-rw-r--r-- | src/cdrom.c | 59 | ||||
-rw-r--r-- | src/config.h | 1 | ||||
-rw-r--r-- | src/disk.c | 2 |
4 files changed, 37 insertions, 26 deletions
@@ -71,6 +71,7 @@ try_boot(u16 seq_nr) u8 bootdrv = 0; u16 bootdev, bootip; + // XXX - why different bootdev check based on CONFIG_CDROM_BOOT? if (CONFIG_CDROM_BOOT) { bootdev = inb_cmos(CMOS_BIOS_BOOTFLAG2); bootdev |= ((inb_cmos(CMOS_BIOS_BOOTFLAG1) & 0xf0) << 4); diff --git a/src/cdrom.c b/src/cdrom.c index cf77584e..590569ad 100644 --- a/src/cdrom.c +++ b/src/cdrom.c @@ -465,15 +465,8 @@ cdrom_boot() if (buffer[0x20] != 0x88) return 11; // Bootable - SET_EBDA(cdemu.media,buffer[0x21]); - if (buffer[0x21] == 0) - // FIXME ElTorito Hardcoded. cdrom is hardcoded as device 0xE0. - // Win2000 cd boot needs to know it booted from cd - SET_EBDA(cdemu.emulated_drive, 0xE0); - else if (buffer[0x21] < 4) - SET_EBDA(cdemu.emulated_drive, 0x00); - else - SET_EBDA(cdemu.emulated_drive, 0x80); + u8 media = buffer[0x21]; + SET_EBDA(cdemu.media, media); SET_EBDA(cdemu.controller_index, device/2); SET_EBDA(cdemu.device_spec, device%2); @@ -481,9 +474,8 @@ cdrom_boot() u16 boot_segment = *(u16*)&buffer[0x22]; if (!boot_segment) boot_segment = 0x07C0; - - SET_EBDA(cdemu.load_segment,boot_segment); - SET_EBDA(cdemu.buffer_segment,0x0000); + SET_EBDA(cdemu.load_segment, boot_segment); + SET_EBDA(cdemu.buffer_segment, 0x0000); u16 nbsectors = *(u16*)&buffer[0x26]; SET_EBDA(cdemu.sector_count, nbsectors); @@ -497,8 +489,34 @@ cdrom_boot() if (ret) return 12; + if (media == 0) { + // No emulation requested - return success. + + // FIXME ElTorito Hardcoded. cdrom is hardcoded as device 0xE0. + // Win2000 cd boot needs to know it booted from cd + SET_EBDA(cdemu.emulated_drive, 0xE0); + + return 0; + } + + // Emulation of a floppy/harddisk requested + if (! CONFIG_CDROM_EMU) + return 13; + + // Set emulated drive id and increase bios installed hardware + // number of devices + if (media < 4) { + // Floppy emulation + SET_EBDA(cdemu.emulated_drive, 0x00); + SETBITS_BDA(equipment_list_flags, 0x41); + } else { + // Harddrive emulation + SET_EBDA(cdemu.emulated_drive, 0x80); + SET_EBDA(ata.hdcount, GET_EBDA(ata.hdcount) + 1); + } + // Remember the media type - switch (GET_EBDA(cdemu.media)) { + switch (media) { case 0x01: // 1.2M floppy SET_EBDA(cdemu.vdevice.spt, 15); SET_EBDA(cdemu.vdevice.cylinders, 80); @@ -525,18 +543,9 @@ cdrom_boot() } } - if (GET_EBDA(cdemu.media) != 0) { - // Increase bios installed hardware number of devices - if (GET_EBDA(cdemu.emulated_drive) == 0x00) - SETBITS_BDA(equipment_list_flags, 0x41); - else - SET_EBDA(ata.hdcount, GET_EBDA(ata.hdcount) + 1); - // everything is ok, so from now on, the emulation is active - SET_EBDA(cdemu.active, 0x01); - } - - DEBUGF("cdemu media=%d active=%d\n" - , GET_EBDA(cdemu.media), GET_EBDA(cdemu.active)); + // everything is ok, so from now on, the emulation is active + SET_EBDA(cdemu.active, 0x01); + DEBUGF("cdemu media=%d\n", media); return 0; } diff --git a/src/config.h b/src/config.h index d61830b6..206fffae 100644 --- a/src/config.h +++ b/src/config.h @@ -7,6 +7,7 @@ #define CONFIG_ATA 1 #define CONFIG_KBD_CALL_INT15_4F 1 #define CONFIG_CDROM_BOOT 1 +#define CONFIG_CDROM_EMU 1 #define CONFIG_PCIBIOS 1 #define CONFIG_MAX_ATA_INTERFACES 4 @@ -706,7 +706,7 @@ handle_13(struct bregs *regs) //debug_enter(regs); u8 drive = regs->dl; - if (CONFIG_CDROM_BOOT) { + if (CONFIG_CDROM_EMU) { if (regs->ah == 0x4b) { cdemu_134b(regs); return; |