--- qemu/roms/seabios/src/disk.c 2018/04/24 17:36:47 1.1 +++ qemu/roms/seabios/src/disk.c 2018/04/24 18:27:14 1.1.1.3 @@ -54,10 +54,12 @@ __disk_stub(struct bregs *regs, int line #define DISK_STUB(regs) \ __disk_stub((regs), __LINE__, __func__) +// Get the cylinders/heads/sectors for the given drive. static void fillLCHS(struct drive_s *drive_g, u16 *nlc, u16 *nlh, u16 *nlspt) { - if (CONFIG_CDROM_EMU && drive_g == GET_GLOBAL(cdemu_drive)) { + if (CONFIG_CDROM_EMU + && drive_g == GLOBALFLAT2GLOBAL(GET_GLOBAL(cdemu_drive_gf))) { // Emulated drive - get info from ebda. (It's not possible to // populate the geometry directly in the driveid because the // geometry is only known after the bios segment is made @@ -87,8 +89,7 @@ basic_access(struct bregs *regs, struct u16 head = regs->dh; if (count > 128 || count == 0 || sector == 0) { - dprintf(1, "int13_harddisk: function %02x, parameter out of range!\n" - , regs->ah); + warn_invalid(regs); disk_ret(regs, DISK_RET_EPARAM); return; } @@ -99,9 +100,7 @@ basic_access(struct bregs *regs, struct // sanity check on cyl heads, sec if (cylinder >= nlc || head >= nlh || sector > nlspt) { - dprintf(1, "int13_harddisk: function %02x, parameters out of" - " range %04x/%04x/%04x!\n" - , regs->ah, cylinder, head, sector); + warn_invalid(regs); disk_ret(regs, DISK_RET_EPARAM); return; } @@ -129,8 +128,7 @@ extended_access(struct bregs *regs, stru dop.command = command; dop.drive_g = drive_g; if (dop.lba >= GET_GLOBAL(drive_g->sectors)) { - dprintf(1, "int13_harddisk: function %02x. LBA out of range\n" - , regs->ah); + warn_invalid(regs); disk_ret(regs, DISK_RET_EPARAM); return; } @@ -239,7 +237,8 @@ disk_1308(struct bregs *regs, struct dri // Floppy count = GET_GLOBAL(Drives.floppycount); - if (CONFIG_CDROM_EMU && drive_g == GET_GLOBAL(cdemu_drive)) + if (CONFIG_CDROM_EMU + && drive_g == GLOBALFLAT2GLOBAL(GET_GLOBAL(cdemu_drive_gf))) regs->bx = GET_EBDA2(ebda_seg, cdemu.media) * 2; else regs->bx = GET_GLOBAL(drive_g->floppy_type); @@ -482,6 +481,7 @@ disk_1346(struct bregs *regs, struct dri struct bregs br; memset(&br, 0, sizeof(br)); br.ah = 0x52; + br.dl = regs->dl; call16_int(0x15, &br); if (br.ah || br.flags & F_CF) { @@ -559,12 +559,13 @@ disk_1348(struct bregs *regs, struct dri , offsetof(struct extended_bios_data_area_s, dpte)); // Fill in dpte - u8 ataid = GET_GLOBAL(drive_g->cntl_id); - u8 channel = ataid / 2; - u8 slave = ataid % 2; - u16 iobase1 = GET_GLOBAL(ATA_channels[channel].iobase1); - u16 iobase2 = GET_GLOBAL(ATA_channels[channel].iobase2); - u8 irq = GET_GLOBAL(ATA_channels[channel].irq); + struct atadrive_s *adrive_g = container_of( + drive_g, struct atadrive_s, drive); + struct ata_channel_s *chan_gf = GET_GLOBAL(adrive_g->chan_gf); + u8 slave = GET_GLOBAL(adrive_g->slave); + u16 iobase1 = GET_GLOBALFLAT(chan_gf->iobase1); + u16 iobase2 = GET_GLOBALFLAT(chan_gf->iobase2); + u8 irq = GET_GLOBALFLAT(chan_gf->irq); u16 options = 0; if (type == DTYPE_ATA) { @@ -613,7 +614,7 @@ disk_1348(struct bregs *regs, struct dri SET_INT13DPT(regs, reserved1, 0); SET_INT13DPT(regs, reserved2, 0); - int bdf = GET_GLOBAL(ATA_channels[channel].pci_bdf); + int bdf = GET_GLOBALFLAT(chan_gf->pci_bdf); if (bdf != -1) { SET_INT13DPT(regs, host_bus[0], 'P'); SET_INT13DPT(regs, host_bus[1], 'C'); @@ -832,13 +833,14 @@ handle_13(struct bregs *regs) u8 emudrive = GET_EBDA2(ebda_seg, cdemu.emulated_extdrive); if (extdrive == emudrive) { // Access to an emulated drive. - struct drive_s *cdemu = GET_GLOBAL(cdemu_drive); + struct drive_s *cdemu_g; + cdemu_g = GLOBALFLAT2GLOBAL(GET_GLOBAL(cdemu_drive_gf)); if (regs->ah > 0x16) { // Only old-style commands supported. - disk_13XX(regs, cdemu); + disk_13XX(regs, cdemu_g); return; } - disk_13(regs, cdemu); + disk_13(regs, cdemu_g); return; } if (extdrive < EXTSTART_CD && ((emudrive ^ extdrive) & 0x80) == 0) @@ -851,7 +853,7 @@ handle_13(struct bregs *regs) // record completion in BIOS task complete flag void VISIBLE16 -handle_76() +handle_76(void) { debug_isr(DEBUG_ISR_76); SET_BDA(disk_interrupt_flag, 0xff);