1 // 16bit code to access hard drives.
3 // Copyright (C) 2008 Kevin O'Connor <kevin@koconnor.net>
4 // Copyright (C) 2002 MandrakeSoft S.A.
6 // This file may be distributed under the terms of the GNU LGPLv3 license.
8 #include "disk.h" // floppy_13
9 #include "biosvar.h" // SET_BDA
10 #include "config.h" // CONFIG_*
11 #include "util.h" // debug_enter
12 #include "pic.h" // eoi_pic2
13 #include "bregs.h" // struct bregs
14 #include "pci.h" // pci_bdf_to_bus
15 #include "ata.h" // ATA_CB_DC
18 /****************************************************************
20 ****************************************************************/
23 __disk_ret(struct bregs *regs, u32 linecode, const char *fname)
26 if (regs->dl < EXTSTART_HD)
27 SET_BDA(floppy_last_status, code);
29 SET_BDA(disk_last_status, code);
31 __set_code_invalid(regs, linecode, fname);
33 set_code_success(regs);
37 __disk_ret_unimplemented(struct bregs *regs, u32 linecode, const char *fname)
40 if (regs->dl < EXTSTART_HD)
41 SET_BDA(floppy_last_status, code);
43 SET_BDA(disk_last_status, code);
44 __set_code_unimplemented(regs, linecode, fname);
48 __disk_stub(struct bregs *regs, int lineno, const char *fname)
50 __warn_unimplemented(regs, lineno, fname);
51 __disk_ret(regs, DISK_RET_SUCCESS | (lineno << 8), fname);
54 #define DISK_STUB(regs) \
55 __disk_stub((regs), __LINE__, __func__)
57 // Get the cylinders/heads/sectors for the given drive.
59 fillLCHS(struct drive_s *drive_g, u16 *nlc, u16 *nlh, u16 *nlspt)
61 if (CONFIG_CDROM_EMU && drive_g == GET_GLOBAL(cdemu_drive)) {
62 // Emulated drive - get info from ebda. (It's not possible to
63 // populate the geometry directly in the driveid because the
64 // geometry is only known after the bios segment is made
66 u16 ebda_seg = get_ebda_seg();
67 *nlc = GET_EBDA2(ebda_seg, cdemu.lchs.cylinders);
68 *nlh = GET_EBDA2(ebda_seg, cdemu.lchs.heads);
69 *nlspt = GET_EBDA2(ebda_seg, cdemu.lchs.spt);
72 *nlc = GET_GLOBAL(drive_g->lchs.cylinders);
73 *nlh = GET_GLOBAL(drive_g->lchs.heads);
74 *nlspt = GET_GLOBAL(drive_g->lchs.spt);
77 // Perform read/write/verify using old-style chs accesses
79 basic_access(struct bregs *regs, struct drive_s *drive_g, u16 command)
82 dop.drive_g = drive_g;
83 dop.command = command;
86 u16 cylinder = regs->ch | ((((u16)regs->cl) << 2) & 0x300);
87 u16 sector = regs->cl & 0x3f;
90 if (count > 128 || count == 0 || sector == 0) {
92 disk_ret(regs, DISK_RET_EPARAM);
98 fillLCHS(drive_g, &nlc, &nlh, &nlspt);
100 // sanity check on cyl heads, sec
101 if (cylinder >= nlc || head >= nlh || sector > nlspt) {
103 disk_ret(regs, DISK_RET_EPARAM);
107 // translate lchs to lba
108 dop.lba = (((((u32)cylinder * (u32)nlh) + (u32)head) * (u32)nlspt)
111 dop.buf_fl = MAKE_FLATPTR(regs->es, regs->bx);
113 int status = send_disk_op(&dop);
115 regs->al = dop.count;
117 disk_ret(regs, status);
120 // Perform read/write/verify using new-style "int13ext" accesses.
122 extended_access(struct bregs *regs, struct drive_s *drive_g, u16 command)
124 struct disk_op_s dop;
125 // Get lba and check.
126 dop.lba = GET_INT13EXT(regs, lba);
127 dop.command = command;
128 dop.drive_g = drive_g;
129 if (dop.lba >= GET_GLOBAL(drive_g->sectors)) {
131 disk_ret(regs, DISK_RET_EPARAM);
135 dop.buf_fl = SEGOFF_TO_FLATPTR(GET_INT13EXT(regs, data));
136 dop.count = GET_INT13EXT(regs, count);
138 int status = send_disk_op(&dop);
140 SET_INT13EXT(regs, count, dop.count);
142 disk_ret(regs, status);
146 /****************************************************************
147 * Hard Drive functions
148 ****************************************************************/
150 // disk controller reset
152 disk_1300(struct bregs *regs, struct drive_s *drive_g)
154 struct disk_op_s dop;
155 dop.drive_g = drive_g;
156 dop.command = CMD_RESET;
157 int status = send_disk_op(&dop);
158 disk_ret(regs, status);
163 disk_1301(struct bregs *regs, struct drive_s *drive_g)
166 if (regs->dl < EXTSTART_HD)
168 v = GET_BDA(floppy_last_status);
170 v = GET_BDA(disk_last_status);
173 // XXX - clear disk_last_status?
178 disk_1302(struct bregs *regs, struct drive_s *drive_g)
180 basic_access(regs, drive_g, CMD_READ);
183 // write disk sectors
185 disk_1303(struct bregs *regs, struct drive_s *drive_g)
187 basic_access(regs, drive_g, CMD_WRITE);
190 // verify disk sectors
192 disk_1304(struct bregs *regs, struct drive_s *drive_g)
194 basic_access(regs, drive_g, CMD_VERIFY);
199 disk_1305(struct bregs *regs, struct drive_s *drive_g)
204 fillLCHS(drive_g, &nlc, &nlh, &nlspt);
206 u8 num_sectors = regs->al;
209 if (head >= nlh || num_sectors == 0 || num_sectors > nlspt) {
210 disk_ret(regs, DISK_RET_EPARAM);
214 struct disk_op_s dop;
215 dop.drive_g = drive_g;
216 dop.command = CMD_FORMAT;
218 dop.count = num_sectors;
219 dop.buf_fl = MAKE_FLATPTR(regs->es, regs->bx);
220 int status = send_disk_op(&dop);
221 disk_ret(regs, status);
224 // read disk drive parameters
226 disk_1308(struct bregs *regs, struct drive_s *drive_g)
228 u16 ebda_seg = get_ebda_seg();
229 // Get logical geometry from table
231 fillLCHS(drive_g, &nlc, &nlh, &nlspt);
235 if (regs->dl < EXTSTART_HD) {
237 count = GET_GLOBAL(Drives.floppycount);
239 if (CONFIG_CDROM_EMU && drive_g == GET_GLOBAL(cdemu_drive))
240 regs->bx = GET_EBDA2(ebda_seg, cdemu.media) * 2;
242 regs->bx = GET_GLOBAL(drive_g->floppy_type);
244 // set es & di to point to 11 byte diskette param table in ROM
246 regs->di = (u32)&diskette_param_table2;
247 } else if (regs->dl < EXTSTART_CD) {
249 count = GET_BDA(hdcount);
250 nlc--; // last sector reserved
252 // Not supported on CDROM
253 disk_ret(regs, DISK_RET_EPARAM);
257 if (CONFIG_CDROM_EMU && GET_EBDA2(ebda_seg, cdemu.active)) {
258 u8 emudrive = GET_EBDA2(ebda_seg, cdemu.emulated_extdrive);
259 if (((emudrive ^ regs->dl) & 0x80) == 0)
260 // Note extra drive due to emulation.
262 if (regs->dl < EXTSTART_HD && count > 2)
263 // Max of two floppy drives.
268 regs->ch = nlc & 0xff;
269 regs->cl = ((nlc >> 2) & 0xc0) | (nlspt & 0x3f);
272 disk_ret(regs, DISK_RET_SUCCESS);
276 // initialize drive parameters
278 disk_1309(struct bregs *regs, struct drive_s *drive_g)
283 // seek to specified cylinder
285 disk_130c(struct bregs *regs, struct drive_s *drive_g)
290 // alternate disk reset
292 disk_130d(struct bregs *regs, struct drive_s *drive_g)
299 disk_1310(struct bregs *regs, struct drive_s *drive_g)
301 // should look at 40:8E also???
303 struct disk_op_s dop;
304 dop.drive_g = drive_g;
305 dop.command = CMD_ISREADY;
306 int status = send_disk_op(&dop);
307 disk_ret(regs, status);
312 disk_1311(struct bregs *regs, struct drive_s *drive_g)
317 // controller internal diagnostic
319 disk_1314(struct bregs *regs, struct drive_s *drive_g)
324 // read disk drive size
326 disk_1315(struct bregs *regs, struct drive_s *drive_g)
328 disk_ret(regs, DISK_RET_SUCCESS);
329 if (regs->dl < EXTSTART_HD || regs->dl >= EXTSTART_CD) {
336 // Get logical geometry from table
338 fillLCHS(drive_g, &nlc, &nlh, &nlspt);
340 // Compute sector count seen by int13
341 u32 lba = (u32)(nlc - 1) * (u32)nlh * (u32)nlspt;
342 regs->cx = lba >> 16;
343 regs->dx = lba & 0xffff;
344 regs->ah = 3; // hard disk accessible
348 disk_1316(struct bregs *regs, struct drive_s *drive_g)
350 if (regs->dl >= EXTSTART_HD) {
352 disk_ret(regs, DISK_RET_EPARAM);
355 disk_ret(regs, DISK_RET_ECHANGED);
358 // IBM/MS installation check
360 disk_1341(struct bregs *regs, struct drive_s *drive_g)
362 regs->bx = 0xaa55; // install check
363 regs->cx = 0x0007; // ext disk access and edd, removable supported
364 disk_ret(regs, DISK_RET_SUCCESS);
365 regs->ah = 0x30; // EDD 3.0
368 // IBM/MS extended read
370 disk_1342(struct bregs *regs, struct drive_s *drive_g)
372 extended_access(regs, drive_g, CMD_READ);
375 // IBM/MS extended write
377 disk_1343(struct bregs *regs, struct drive_s *drive_g)
379 extended_access(regs, drive_g, CMD_WRITE);
384 disk_1344(struct bregs *regs, struct drive_s *drive_g)
386 extended_access(regs, drive_g, CMD_VERIFY);
391 disk_134500(struct bregs *regs, struct drive_s *drive_g)
393 u16 ebda_seg = get_ebda_seg();
394 int cdid = regs->dl - EXTSTART_CD;
395 u8 locks = GET_EBDA2(ebda_seg, cdrom_locks[cdid]);
398 disk_ret(regs, DISK_RET_ETOOMANYLOCKS);
401 SET_EBDA2(ebda_seg, cdrom_locks[cdid], locks + 1);
403 disk_ret(regs, DISK_RET_SUCCESS);
408 disk_134501(struct bregs *regs, struct drive_s *drive_g)
410 u16 ebda_seg = get_ebda_seg();
411 int cdid = regs->dl - EXTSTART_CD;
412 u8 locks = GET_EBDA2(ebda_seg, cdrom_locks[cdid]);
415 disk_ret(regs, DISK_RET_ENOTLOCKED);
419 SET_EBDA2(ebda_seg, cdrom_locks[cdid], locks);
420 regs->al = (locks ? 1 : 0);
421 disk_ret(regs, DISK_RET_SUCCESS);
426 disk_134502(struct bregs *regs, struct drive_s *drive_g)
428 int cdid = regs->dl - EXTSTART_CD;
429 u8 locks = GET_EBDA(cdrom_locks[cdid]);
430 regs->al = (locks ? 1 : 0);
431 disk_ret(regs, DISK_RET_SUCCESS);
435 disk_1345XX(struct bregs *regs, struct drive_s *drive_g)
437 disk_ret_unimplemented(regs, DISK_RET_EPARAM);
440 // IBM/MS lock/unlock drive
442 disk_1345(struct bregs *regs, struct drive_s *drive_g)
444 if (regs->dl < EXTSTART_CD) {
445 // Always success for HD
446 disk_ret(regs, DISK_RET_SUCCESS);
451 case 0x00: disk_134500(regs, drive_g); break;
452 case 0x01: disk_134501(regs, drive_g); break;
453 case 0x02: disk_134502(regs, drive_g); break;
454 default: disk_1345XX(regs, drive_g); break;
458 // IBM/MS eject media
460 disk_1346(struct bregs *regs, struct drive_s *drive_g)
462 if (regs->dl < EXTSTART_CD) {
463 // Volume Not Removable
464 disk_ret(regs, DISK_RET_ENOTREMOVABLE);
468 int cdid = regs->dl - EXTSTART_CD;
469 u8 locks = GET_EBDA(cdrom_locks[cdid]);
471 disk_ret(regs, DISK_RET_ELOCKED);
475 // FIXME should handle 0x31 no media in device
476 // FIXME should handle 0xb5 valid request failed
478 // Call removable media eject
480 memset(&br, 0, sizeof(br));
482 call16_int(0x15, &br);
484 if (br.ah || br.flags & F_CF) {
485 disk_ret(regs, DISK_RET_ELOCKED);
488 disk_ret(regs, DISK_RET_SUCCESS);
491 // IBM/MS extended seek
493 disk_1347(struct bregs *regs, struct drive_s *drive_g)
495 extended_access(regs, drive_g, CMD_SEEK);
498 // IBM/MS get drive parameters
500 disk_1348(struct bregs *regs, struct drive_s *drive_g)
502 u16 size = GET_INT13DPT(regs, size);
504 // Buffer is too small
506 disk_ret(regs, DISK_RET_EPARAM);
512 u8 type = GET_GLOBAL(drive_g->type);
513 u16 npc = GET_GLOBAL(drive_g->pchs.cylinders);
514 u16 nph = GET_GLOBAL(drive_g->pchs.heads);
515 u16 npspt = GET_GLOBAL(drive_g->pchs.spt);
516 u64 lba = GET_GLOBAL(drive_g->sectors);
517 u16 blksize = GET_GLOBAL(drive_g->blksize);
519 dprintf(DEBUG_HDL_13, "disk_1348 size=%d t=%d chs=%d,%d,%d lba=%d bs=%d\n"
520 , size, type, npc, nph, npspt, (u32)lba, blksize);
522 SET_INT13DPT(regs, size, 26);
523 if (type == DTYPE_ATAPI) {
524 // 0x74 = removable, media change, lockable, max values
525 SET_INT13DPT(regs, infos, 0x74);
526 SET_INT13DPT(regs, cylinders, 0xffffffff);
527 SET_INT13DPT(regs, heads, 0xffffffff);
528 SET_INT13DPT(regs, spt, 0xffffffff);
529 SET_INT13DPT(regs, sector_count, (u64)-1);
531 if (lba > (u64)npspt*nph*0x3fff) {
532 SET_INT13DPT(regs, infos, 0x00); // geometry is invalid
533 SET_INT13DPT(regs, cylinders, 0x3fff);
535 SET_INT13DPT(regs, infos, 0x02); // geometry is valid
536 SET_INT13DPT(regs, cylinders, (u32)npc);
538 SET_INT13DPT(regs, heads, (u32)nph);
539 SET_INT13DPT(regs, spt, (u32)npspt);
540 SET_INT13DPT(regs, sector_count, lba);
542 SET_INT13DPT(regs, blksize, blksize);
544 if (size < 30 || (type != DTYPE_ATA && type != DTYPE_ATAPI)) {
545 disk_ret(regs, DISK_RET_SUCCESS);
551 u16 ebda_seg = get_ebda_seg();
552 SET_INT13DPT(regs, size, 30);
554 SET_INT13DPT(regs, dpte_segment, ebda_seg);
555 SET_INT13DPT(regs, dpte_offset
556 , offsetof(struct extended_bios_data_area_s, dpte));
559 u8 ataid = GET_GLOBAL(drive_g->cntl_id);
560 u8 channel = ataid / 2;
561 u8 slave = ataid % 2;
562 u16 iobase1 = GET_GLOBAL(ATA_channels[channel].iobase1);
563 u16 iobase2 = GET_GLOBAL(ATA_channels[channel].iobase2);
564 u8 irq = GET_GLOBAL(ATA_channels[channel].irq);
567 if (type == DTYPE_ATA) {
568 u8 translation = GET_GLOBAL(drive_g->translation);
569 if (translation != TRANSLATION_NONE) {
570 options |= 1<<3; // CHS translation
571 if (translation == TRANSLATION_LBA)
573 if (translation == TRANSLATION_RECHS)
578 options |= 1<<5; // removable device
579 options |= 1<<6; // atapi device
581 options |= 1<<4; // lba translation
582 if (CONFIG_ATA_PIO32)
585 SET_EBDA2(ebda_seg, dpte.iobase1, iobase1);
586 SET_EBDA2(ebda_seg, dpte.iobase2, iobase2 + ATA_CB_DC);
587 SET_EBDA2(ebda_seg, dpte.prefix, ((slave ? ATA_CB_DH_DEV1 : ATA_CB_DH_DEV0)
589 SET_EBDA2(ebda_seg, dpte.unused, 0xcb);
590 SET_EBDA2(ebda_seg, dpte.irq, irq);
591 SET_EBDA2(ebda_seg, dpte.blkcount, 1);
592 SET_EBDA2(ebda_seg, dpte.dma, 0);
593 SET_EBDA2(ebda_seg, dpte.pio, 0);
594 SET_EBDA2(ebda_seg, dpte.options, options);
595 SET_EBDA2(ebda_seg, dpte.reserved, 0);
596 SET_EBDA2(ebda_seg, dpte.revision, 0x11);
598 u8 sum = checksum_far(
599 ebda_seg, (void*)offsetof(struct extended_bios_data_area_s, dpte), 15);
600 SET_EBDA2(ebda_seg, dpte.checksum, -sum);
603 disk_ret(regs, DISK_RET_SUCCESS);
608 SET_INT13DPT(regs, key, 0xbedd);
609 SET_INT13DPT(regs, dpi_length, 36);
610 SET_INT13DPT(regs, reserved1, 0);
611 SET_INT13DPT(regs, reserved2, 0);
613 int bdf = GET_GLOBAL(ATA_channels[channel].pci_bdf);
615 SET_INT13DPT(regs, host_bus[0], 'P');
616 SET_INT13DPT(regs, host_bus[1], 'C');
617 SET_INT13DPT(regs, host_bus[2], 'I');
618 SET_INT13DPT(regs, host_bus[3], 0);
620 u32 path = (pci_bdf_to_bus(bdf) | (pci_bdf_to_dev(bdf) << 8)
621 | (pci_bdf_to_fn(bdf) << 16));
622 SET_INT13DPT(regs, iface_path, path);
625 SET_INT13DPT(regs, host_bus[0], 'I');
626 SET_INT13DPT(regs, host_bus[1], 'S');
627 SET_INT13DPT(regs, host_bus[2], 'A');
628 SET_INT13DPT(regs, host_bus[3], 0);
630 SET_INT13DPT(regs, iface_path, iobase1);
633 SET_INT13DPT(regs, iface_type[0], 'A');
634 SET_INT13DPT(regs, iface_type[1], 'T');
635 SET_INT13DPT(regs, iface_type[2], 'A');
636 SET_INT13DPT(regs, iface_type[3], 0);
637 SET_INT13DPT(regs, iface_type[4], 0);
638 SET_INT13DPT(regs, iface_type[5], 0);
639 SET_INT13DPT(regs, iface_type[6], 0);
640 SET_INT13DPT(regs, iface_type[7], 0);
642 SET_INT13DPT(regs, device_path, slave);
644 SET_INT13DPT(regs, checksum
645 , -checksum_far(regs->ds, (void*)(regs->si+30), 35));
647 disk_ret(regs, DISK_RET_SUCCESS);
650 // IBM/MS extended media change
652 disk_1349(struct bregs *regs, struct drive_s *drive_g)
654 if (regs->dl < EXTSTART_CD) {
655 // Always success for HD
656 disk_ret(regs, DISK_RET_SUCCESS);
660 // always send changed ??
661 regs->ah = DISK_RET_ECHANGED;
665 disk_134e01(struct bregs *regs, struct drive_s *drive_g)
667 disk_ret(regs, DISK_RET_SUCCESS);
671 disk_134e03(struct bregs *regs, struct drive_s *drive_g)
673 disk_ret(regs, DISK_RET_SUCCESS);
677 disk_134e04(struct bregs *regs, struct drive_s *drive_g)
679 disk_ret(regs, DISK_RET_SUCCESS);
683 disk_134e06(struct bregs *regs, struct drive_s *drive_g)
685 disk_ret(regs, DISK_RET_SUCCESS);
689 disk_134eXX(struct bregs *regs, struct drive_s *drive_g)
691 disk_ret(regs, DISK_RET_EPARAM);
694 // IBM/MS set hardware configuration
696 disk_134e(struct bregs *regs, struct drive_s *drive_g)
699 case 0x01: disk_134e01(regs, drive_g); break;
700 case 0x03: disk_134e03(regs, drive_g); break;
701 case 0x04: disk_134e04(regs, drive_g); break;
702 case 0x06: disk_134e06(regs, drive_g); break;
703 default: disk_134eXX(regs, drive_g); break;
708 disk_13XX(struct bregs *regs, struct drive_s *drive_g)
710 disk_ret_unimplemented(regs, DISK_RET_EPARAM);
714 disk_13(struct bregs *regs, struct drive_s *drive_g)
718 // clear completion flag
719 SET_BDA(disk_interrupt_flag, 0);
722 case 0x00: disk_1300(regs, drive_g); break;
723 case 0x01: disk_1301(regs, drive_g); break;
724 case 0x02: disk_1302(regs, drive_g); break;
725 case 0x03: disk_1303(regs, drive_g); break;
726 case 0x04: disk_1304(regs, drive_g); break;
727 case 0x05: disk_1305(regs, drive_g); break;
728 case 0x08: disk_1308(regs, drive_g); break;
729 case 0x09: disk_1309(regs, drive_g); break;
730 case 0x0c: disk_130c(regs, drive_g); break;
731 case 0x0d: disk_130d(regs, drive_g); break;
732 case 0x10: disk_1310(regs, drive_g); break;
733 case 0x11: disk_1311(regs, drive_g); break;
734 case 0x14: disk_1314(regs, drive_g); break;
735 case 0x15: disk_1315(regs, drive_g); break;
736 case 0x16: disk_1316(regs, drive_g); break;
737 case 0x41: disk_1341(regs, drive_g); break;
738 case 0x42: disk_1342(regs, drive_g); break;
739 case 0x43: disk_1343(regs, drive_g); break;
740 case 0x44: disk_1344(regs, drive_g); break;
741 case 0x45: disk_1345(regs, drive_g); break;
742 case 0x46: disk_1346(regs, drive_g); break;
743 case 0x47: disk_1347(regs, drive_g); break;
744 case 0x48: disk_1348(regs, drive_g); break;
745 case 0x49: disk_1349(regs, drive_g); break;
746 case 0x4e: disk_134e(regs, drive_g); break;
747 default: disk_13XX(regs, drive_g); break;
752 floppy_13(struct bregs *regs, struct drive_s *drive_g)
754 // Only limited commands are supported on floppies.
765 disk_13(regs, drive_g);
767 default: disk_13XX(regs, drive_g); break;
772 /****************************************************************
774 ****************************************************************/
777 handle_legacy_disk(struct bregs *regs, u8 extdrive)
779 if (! CONFIG_DRIVES) {
780 // XXX - support handle_1301 anyway?
781 disk_ret(regs, DISK_RET_EPARAM);
785 if (extdrive < EXTSTART_HD) {
786 struct drive_s *drive_g = getDrive(EXTTYPE_FLOPPY, extdrive);
789 floppy_13(regs, drive_g);
793 struct drive_s *drive_g;
794 if (extdrive >= EXTSTART_CD)
795 drive_g = getDrive(EXTTYPE_CD, extdrive - EXTSTART_CD);
797 drive_g = getDrive(EXTTYPE_HD, extdrive - EXTSTART_HD);
800 disk_13(regs, drive_g);
804 // XXX - support 1301/1308/1315 anyway?
805 disk_ret(regs, DISK_RET_EPARAM);
809 handle_40(struct bregs *regs)
811 debug_enter(regs, DEBUG_HDL_40);
812 handle_legacy_disk(regs, regs->dl);
815 // INT 13h Fixed Disk Services Entry Point
817 handle_13(struct bregs *regs)
819 debug_enter(regs, DEBUG_HDL_13);
820 u8 extdrive = regs->dl;
822 if (CONFIG_CDROM_EMU) {
823 if (regs->ah == 0x4b) {
827 u16 ebda_seg = get_ebda_seg();
828 if (GET_EBDA2(ebda_seg, cdemu.active)) {
829 u8 emudrive = GET_EBDA2(ebda_seg, cdemu.emulated_extdrive);
830 if (extdrive == emudrive) {
831 // Access to an emulated drive.
832 struct drive_s *cdemu = GET_GLOBAL(cdemu_drive);
833 if (regs->ah > 0x16) {
834 // Only old-style commands supported.
835 disk_13XX(regs, cdemu);
838 disk_13(regs, cdemu);
841 if (extdrive < EXTSTART_CD && ((emudrive ^ extdrive) & 0x80) == 0)
842 // Adjust id to make room for emulated drive.
846 handle_legacy_disk(regs, extdrive);
849 // record completion in BIOS task complete flag
853 debug_isr(DEBUG_ISR_76);
854 SET_BDA(disk_interrupt_flag, 0xff);
858 // Old Fixed Disk Parameter Table (newer tables are in the ebda).
859 struct fdpt_s OldFDPT VAR16FIXED(0xe401);