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_fail(regs, linecode, fname);
33 set_code_success(regs);
37 __disk_stub(struct bregs *regs, int lineno, const char *fname)
39 __debug_stub(regs, lineno, fname);
40 __disk_ret(regs, DISK_RET_SUCCESS | (lineno << 8), fname);
43 #define DISK_STUB(regs) \
44 __disk_stub((regs), __LINE__, __func__)
46 // Obtain the requested disk lba from an old-style chs request.
48 legacy_lba(struct bregs *regs, u16 lchs_seg, struct chs_s *lchs_far)
51 u16 cylinder = regs->ch | ((((u16)regs->cl) << 2) & 0x300);
52 u16 sector = regs->cl & 0x3f;
55 if (count > 128 || count == 0 || sector == 0) {
56 dprintf(1, "int13_harddisk: function %02x, parameter out of range!\n"
58 disk_ret(regs, DISK_RET_EPARAM);
62 u16 nlc = GET_FARVAR(lchs_seg, lchs_far->cylinders);
63 u16 nlh = GET_FARVAR(lchs_seg, lchs_far->heads);
64 u16 nlspt = GET_FARVAR(lchs_seg, lchs_far->spt);
66 // sanity check on cyl heads, sec
67 if (cylinder >= nlc || head >= nlh || sector > nlspt) {
68 dprintf(1, "int13_harddisk: function %02x, parameters out of"
69 " range %04x/%04x/%04x!\n"
70 , regs->ah, cylinder, head, sector);
71 disk_ret(regs, DISK_RET_EPARAM);
75 // translate lchs to lba
76 return (((((u32)cylinder * (u32)nlh) + (u32)head) * (u32)nlspt)
80 // Perform read/write/verify using old-style chs accesses
82 basic_access(struct bregs *regs, u8 driveid, u16 command)
85 dop.driveid = driveid;
86 dop.command = command;
87 int lba = legacy_lba(regs, get_global_seg(), &Drives.drives[driveid].lchs);
92 dop.buf_fl = MAKE_FLATPTR(regs->es, regs->bx);
94 int status = send_disk_op(&dop);
98 disk_ret(regs, status);
101 // Perform cdemu read/verify
103 cdemu_access(struct bregs *regs, u8 driveid, u16 command)
105 struct disk_op_s dop;
106 dop.driveid = driveid;
107 dop.command = command;
108 u16 ebda_seg = get_ebda_seg();
109 int vlba = legacy_lba(
111 , (void*)offsetof(struct extended_bios_data_area_s, cdemu.lchs));
114 dop.lba = GET_EBDA2(ebda_seg, cdemu.ilba) + vlba / 4;
116 u8 *cdbuf_far = (void*)offsetof(struct extended_bios_data_area_s, cdemu_buf);
117 u8 *dest_far = (void*)(regs->bx+0);
119 int status = DISK_RET_SUCCESS;
123 dop.buf_fl = MAKE_FLATPTR(ebda_seg, cdbuf_far);
124 status = send_disk_op(&dop);
127 u8 thiscount = 4 - (vlba & 3);
128 if (thiscount > count)
131 memcpy_far(regs->es, dest_far
132 , ebda_seg, cdbuf_far + (vlba & 3) * 512
134 dest_far += thiscount * 512;
135 regs->al += thiscount;
140 dop.count = count / 4;
141 dop.buf_fl = MAKE_FLATPTR(regs->es, dest_far);
142 status = send_disk_op(&dop);
143 regs->al += dop.count * 4;
146 u8 thiscount = count & ~3;
148 dest_far += thiscount * 512;
149 dop.lba += thiscount / 4;
154 dop.buf_fl = MAKE_FLATPTR(ebda_seg, cdbuf_far);
155 status = send_disk_op(&dop);
158 u8 thiscount = count;
159 memcpy_far(regs->es, dest_far, ebda_seg, cdbuf_far, thiscount * 512);
160 regs->al += thiscount;
164 disk_ret(regs, status);
167 // Perform read/write/verify using new-style "int13ext" accesses.
169 extended_access(struct bregs *regs, u8 driveid, u16 command)
171 struct disk_op_s dop;
172 // Get lba and check.
173 dop.lba = GET_INT13EXT(regs, lba);
174 dop.command = command;
175 dop.driveid = driveid;
176 if (dop.lba >= GET_GLOBAL(Drives.drives[driveid].sectors)) {
177 dprintf(1, "int13_harddisk: function %02x. LBA out of range\n"
179 disk_ret(regs, DISK_RET_EPARAM);
183 dop.buf_fl = SEGOFF_TO_FLATPTR(GET_INT13EXT(regs, data));
184 dop.count = GET_INT13EXT(regs, count);
186 int status = send_disk_op(&dop);
188 SET_INT13EXT(regs, count, dop.count);
190 disk_ret(regs, status);
194 /****************************************************************
195 * Hard Drive functions
196 ****************************************************************/
198 // disk controller reset
200 disk_1300(struct bregs *regs, u8 driveid)
202 struct disk_op_s dop;
203 dop.driveid = driveid;
204 dop.command = CMD_RESET;
205 int status = send_disk_op(&dop);
206 disk_ret(regs, status);
211 disk_1301(struct bregs *regs, u8 driveid)
214 if (regs->dl < EXTSTART_HD)
216 v = GET_BDA(floppy_last_status);
218 v = GET_BDA(disk_last_status);
221 // XXX - clear disk_last_status?
226 disk_1302(struct bregs *regs, u8 driveid)
228 basic_access(regs, driveid, CMD_READ);
231 // write disk sectors
233 disk_1303(struct bregs *regs, u8 driveid)
235 basic_access(regs, driveid, CMD_WRITE);
238 // verify disk sectors
240 disk_1304(struct bregs *regs, u8 driveid)
242 basic_access(regs, driveid, CMD_VERIFY);
248 disk_1305(struct bregs *regs, u8 driveid)
252 u16 nlh = GET_GLOBAL(Drives.drives[driveid].lchs.heads);
253 u16 nlspt = GET_GLOBAL(Drives.drives[driveid].lchs.spt);
255 u8 num_sectors = regs->al;
258 if (head >= nlh || num_sectors == 0 || num_sectors > nlspt) {
259 disk_ret(regs, DISK_RET_EPARAM);
263 struct disk_op_s dop;
264 dop.driveid = driveid;
265 dop.command = CMD_FORMAT;
267 dop.count = num_sectors;
268 dop.buf_fl = MAKE_FLATPTR(regs->es, regs->bx);
269 int status = send_disk_op(&dop);
270 disk_ret(regs, status);
273 // read disk drive parameters
275 disk_1308(struct bregs *regs, u8 driveid)
277 // Get logical geometry from table
278 u16 nlc = GET_GLOBAL(Drives.drives[driveid].lchs.cylinders) - 1;
279 u16 nlh = GET_GLOBAL(Drives.drives[driveid].lchs.heads) - 1;
280 u16 nlspt = GET_GLOBAL(Drives.drives[driveid].lchs.spt);
282 if (regs->dl < EXTSTART_HD) {
284 count = GET_GLOBAL(Drives.floppycount);
286 regs->bx = GET_GLOBAL(Drives.drives[driveid].floppy_type);
288 // set es & di to point to 11 byte diskette param table in ROM
290 regs->di = (u32)&diskette_param_table2;
291 } else if (regs->dl < EXTSTART_CD) {
293 count = GET_BDA(hdcount);
294 nlc--; // last sector reserved
296 // Not supported on CDROM
297 disk_ret(regs, DISK_RET_EPARAM);
302 regs->ch = nlc & 0xff;
303 regs->cl = ((nlc >> 2) & 0xc0) | (nlspt & 0x3f);
306 disk_ret(regs, DISK_RET_SUCCESS);
310 // initialize drive parameters
312 disk_1309(struct bregs *regs, u8 driveid)
317 // seek to specified cylinder
319 disk_130c(struct bregs *regs, u8 driveid)
324 // alternate disk reset
326 disk_130d(struct bregs *regs, u8 driveid)
333 disk_1310(struct bregs *regs, u8 driveid)
335 // should look at 40:8E also???
337 struct disk_op_s dop;
338 dop.driveid = driveid;
339 dop.command = CMD_ISREADY;
340 int status = send_disk_op(&dop);
341 disk_ret(regs, status);
346 disk_1311(struct bregs *regs, u8 driveid)
351 // controller internal diagnostic
353 disk_1314(struct bregs *regs, u8 driveid)
358 // read disk drive size
360 disk_1315(struct bregs *regs, u8 driveid)
362 disk_ret(regs, DISK_RET_SUCCESS);
363 if (regs->dl < EXTSTART_HD || regs->dl >= EXTSTART_CD) {
370 // Get logical geometry from table
371 u16 nlc = GET_GLOBAL(Drives.drives[driveid].lchs.cylinders);
372 u16 nlh = GET_GLOBAL(Drives.drives[driveid].lchs.heads);
373 u16 nlspt = GET_GLOBAL(Drives.drives[driveid].lchs.spt);
375 // Compute sector count seen by int13
376 u32 lba = (u32)(nlc - 1) * (u32)nlh * (u32)nlspt;
377 regs->cx = lba >> 16;
378 regs->dx = lba & 0xffff;
379 regs->ah = 3; // hard disk accessible
383 disk_1316(struct bregs *regs, u8 driveid)
385 if (regs->dl >= EXTSTART_HD) {
387 disk_ret(regs, DISK_RET_EPARAM);
390 disk_ret(regs, DISK_RET_ECHANGED);
393 // IBM/MS installation check
395 disk_1341(struct bregs *regs, u8 driveid)
397 regs->bx = 0xaa55; // install check
398 regs->cx = 0x0007; // ext disk access and edd, removable supported
399 disk_ret(regs, DISK_RET_SUCCESS);
400 regs->ah = 0x30; // EDD 3.0
403 // IBM/MS extended read
405 disk_1342(struct bregs *regs, u8 driveid)
407 extended_access(regs, driveid, CMD_READ);
410 // IBM/MS extended write
412 disk_1343(struct bregs *regs, u8 driveid)
414 extended_access(regs, driveid, CMD_WRITE);
419 disk_1344(struct bregs *regs, u8 driveid)
421 extended_access(regs, driveid, CMD_VERIFY);
426 disk_134500(struct bregs *regs, u8 driveid)
428 u16 ebda_seg = get_ebda_seg();
429 u8 locks = GET_EBDA2(ebda_seg, cdrom_locks[driveid]);
432 disk_ret(regs, DISK_RET_ETOOMANYLOCKS);
435 SET_EBDA2(ebda_seg, cdrom_locks[driveid], locks + 1);
437 disk_ret(regs, DISK_RET_SUCCESS);
442 disk_134501(struct bregs *regs, u8 driveid)
444 u16 ebda_seg = get_ebda_seg();
445 u8 locks = GET_EBDA2(ebda_seg, cdrom_locks[driveid]);
448 disk_ret(regs, DISK_RET_ENOTLOCKED);
452 SET_EBDA2(ebda_seg, cdrom_locks[driveid], locks);
453 regs->al = (locks ? 1 : 0);
454 disk_ret(regs, DISK_RET_SUCCESS);
459 disk_134502(struct bregs *regs, u8 driveid)
461 u8 locks = GET_EBDA(cdrom_locks[driveid]);
462 regs->al = (locks ? 1 : 0);
463 disk_ret(regs, DISK_RET_SUCCESS);
467 disk_1345XX(struct bregs *regs, u8 driveid)
469 disk_ret(regs, DISK_RET_EPARAM);
472 // IBM/MS lock/unlock drive
474 disk_1345(struct bregs *regs, u8 driveid)
476 if (regs->dl < EXTSTART_CD) {
477 // Always success for HD
478 disk_ret(regs, DISK_RET_SUCCESS);
483 case 0x00: disk_134500(regs, driveid); break;
484 case 0x01: disk_134501(regs, driveid); break;
485 case 0x02: disk_134502(regs, driveid); break;
486 default: disk_1345XX(regs, driveid); break;
490 // IBM/MS eject media
492 disk_1346(struct bregs *regs, u8 driveid)
494 if (regs->dl < EXTSTART_CD) {
495 // Volume Not Removable
496 disk_ret(regs, DISK_RET_ENOTREMOVABLE);
500 u8 locks = GET_EBDA(cdrom_locks[driveid]);
502 disk_ret(regs, DISK_RET_ELOCKED);
506 // FIXME should handle 0x31 no media in device
507 // FIXME should handle 0xb5 valid request failed
509 // Call removable media eject
511 memset(&br, 0, sizeof(br));
513 call16_int(0x15, &br);
515 if (br.ah || br.flags & F_CF) {
516 disk_ret(regs, DISK_RET_ELOCKED);
519 disk_ret(regs, DISK_RET_SUCCESS);
522 // IBM/MS extended seek
524 disk_1347(struct bregs *regs, u8 driveid)
526 extended_access(regs, driveid, CMD_SEEK);
529 // IBM/MS get drive parameters
531 disk_1348(struct bregs *regs, u8 driveid)
533 u16 size = GET_INT13DPT(regs, size);
535 // Buffer is too small
537 disk_ret(regs, DISK_RET_EPARAM);
543 u8 type = GET_GLOBAL(Drives.drives[driveid].type);
544 u16 npc = GET_GLOBAL(Drives.drives[driveid].pchs.cylinders);
545 u16 nph = GET_GLOBAL(Drives.drives[driveid].pchs.heads);
546 u16 npspt = GET_GLOBAL(Drives.drives[driveid].pchs.spt);
547 u64 lba = GET_GLOBAL(Drives.drives[driveid].sectors);
548 u16 blksize = GET_GLOBAL(Drives.drives[driveid].blksize);
550 dprintf(DEBUG_HDL_13, "disk_1348 size=%d t=%d chs=%d,%d,%d lba=%d bs=%d\n"
551 , size, type, npc, nph, npspt, (u32)lba, blksize);
553 SET_INT13DPT(regs, size, 26);
554 if (type == DTYPE_ATAPI) {
555 // 0x74 = removable, media change, lockable, max values
556 SET_INT13DPT(regs, infos, 0x74);
557 SET_INT13DPT(regs, cylinders, 0xffffffff);
558 SET_INT13DPT(regs, heads, 0xffffffff);
559 SET_INT13DPT(regs, spt, 0xffffffff);
560 SET_INT13DPT(regs, sector_count, (u64)-1);
562 if (lba > (u64)npspt*nph*0x3fff) {
563 SET_INT13DPT(regs, infos, 0x00); // geometry is invalid
564 SET_INT13DPT(regs, cylinders, 0x3fff);
566 SET_INT13DPT(regs, infos, 0x02); // geometry is valid
567 SET_INT13DPT(regs, cylinders, (u32)npc);
569 SET_INT13DPT(regs, heads, (u32)nph);
570 SET_INT13DPT(regs, spt, (u32)npspt);
571 SET_INT13DPT(regs, sector_count, lba);
573 SET_INT13DPT(regs, blksize, blksize);
575 if (size < 30 || (type != DTYPE_ATA && type != DTYPE_ATAPI)) {
576 disk_ret(regs, DISK_RET_SUCCESS);
582 u16 ebda_seg = get_ebda_seg();
583 SET_INT13DPT(regs, size, 30);
585 SET_INT13DPT(regs, dpte_segment, ebda_seg);
586 SET_INT13DPT(regs, dpte_offset
587 , offsetof(struct extended_bios_data_area_s, dpte));
590 u8 ataid = GET_GLOBAL(Drives.drives[driveid].cntl_id);
591 u8 channel = ataid / 2;
592 u8 slave = ataid % 2;
593 u16 iobase1 = GET_GLOBAL(ATA_channels[channel].iobase1);
594 u16 iobase2 = GET_GLOBAL(ATA_channels[channel].iobase2);
595 u8 irq = GET_GLOBAL(ATA_channels[channel].irq);
598 if (type == DTYPE_ATA) {
599 u8 translation = GET_GLOBAL(Drives.drives[driveid].translation);
600 if (translation != TRANSLATION_NONE) {
601 options |= 1<<3; // CHS translation
602 if (translation == TRANSLATION_LBA)
604 if (translation == TRANSLATION_RECHS)
609 options |= 1<<5; // removable device
610 options |= 1<<6; // atapi device
612 options |= 1<<4; // lba translation
613 if (CONFIG_ATA_PIO32)
616 SET_EBDA2(ebda_seg, dpte.iobase1, iobase1);
617 SET_EBDA2(ebda_seg, dpte.iobase2, iobase2 + ATA_CB_DC);
618 SET_EBDA2(ebda_seg, dpte.prefix, ((slave ? ATA_CB_DH_DEV1 : ATA_CB_DH_DEV0)
620 SET_EBDA2(ebda_seg, dpte.unused, 0xcb);
621 SET_EBDA2(ebda_seg, dpte.irq, irq);
622 SET_EBDA2(ebda_seg, dpte.blkcount, 1);
623 SET_EBDA2(ebda_seg, dpte.dma, 0);
624 SET_EBDA2(ebda_seg, dpte.pio, 0);
625 SET_EBDA2(ebda_seg, dpte.options, options);
626 SET_EBDA2(ebda_seg, dpte.reserved, 0);
627 SET_EBDA2(ebda_seg, dpte.revision, 0x11);
629 u8 sum = checksum_far(
630 ebda_seg, (void*)offsetof(struct extended_bios_data_area_s, dpte), 15);
631 SET_EBDA2(ebda_seg, dpte.checksum, -sum);
634 disk_ret(regs, DISK_RET_SUCCESS);
639 SET_INT13DPT(regs, key, 0xbedd);
640 SET_INT13DPT(regs, dpi_length, 36);
641 SET_INT13DPT(regs, reserved1, 0);
642 SET_INT13DPT(regs, reserved2, 0);
644 SET_INT13DPT(regs, host_bus[0], 'P');
645 SET_INT13DPT(regs, host_bus[1], 'C');
646 SET_INT13DPT(regs, host_bus[2], 'I');
647 SET_INT13DPT(regs, host_bus[3], 0);
649 u32 bdf = GET_GLOBAL(ATA_channels[channel].pci_bdf);
650 u32 path = (pci_bdf_to_bus(bdf) | (pci_bdf_to_dev(bdf) << 8)
651 | (pci_bdf_to_fn(bdf) << 16));
652 SET_INT13DPT(regs, iface_path, path);
654 SET_INT13DPT(regs, iface_type[0], 'A');
655 SET_INT13DPT(regs, iface_type[1], 'T');
656 SET_INT13DPT(regs, iface_type[2], 'A');
657 SET_INT13DPT(regs, iface_type[3], 0);
658 SET_INT13DPT(regs, iface_type[4], 0);
659 SET_INT13DPT(regs, iface_type[5], 0);
660 SET_INT13DPT(regs, iface_type[6], 0);
661 SET_INT13DPT(regs, iface_type[7], 0);
663 SET_INT13DPT(regs, device_path, slave);
665 SET_INT13DPT(regs, checksum
666 , -checksum_far(regs->ds, (void*)(regs->si+30), 35));
668 disk_ret(regs, DISK_RET_SUCCESS);
671 // IBM/MS extended media change
673 disk_1349(struct bregs *regs, u8 driveid)
675 if (regs->dl < EXTSTART_CD) {
676 // Always success for HD
677 disk_ret(regs, DISK_RET_SUCCESS);
681 // always send changed ??
682 regs->ah = DISK_RET_ECHANGED;
686 disk_134e01(struct bregs *regs, u8 driveid)
688 disk_ret(regs, DISK_RET_SUCCESS);
692 disk_134e03(struct bregs *regs, u8 driveid)
694 disk_ret(regs, DISK_RET_SUCCESS);
698 disk_134e04(struct bregs *regs, u8 driveid)
700 disk_ret(regs, DISK_RET_SUCCESS);
704 disk_134e06(struct bregs *regs, u8 driveid)
706 disk_ret(regs, DISK_RET_SUCCESS);
710 disk_134eXX(struct bregs *regs, u8 driveid)
712 disk_ret(regs, DISK_RET_EPARAM);
715 // IBM/MS set hardware configuration
717 disk_134e(struct bregs *regs, u8 driveid)
720 case 0x01: disk_134e01(regs, driveid); break;
721 case 0x03: disk_134e03(regs, driveid); break;
722 case 0x04: disk_134e04(regs, driveid); break;
723 case 0x06: disk_134e06(regs, driveid); break;
724 default: disk_134eXX(regs, driveid); break;
729 disk_13XX(struct bregs *regs, u8 driveid)
731 disk_ret(regs, DISK_RET_EPARAM);
735 disk_13(struct bregs *regs, u8 driveid)
739 // clear completion flag
740 SET_BDA(disk_interrupt_flag, 0);
743 case 0x00: disk_1300(regs, driveid); break;
744 case 0x01: disk_1301(regs, driveid); break;
745 case 0x02: disk_1302(regs, driveid); break;
746 case 0x03: disk_1303(regs, driveid); break;
747 case 0x04: disk_1304(regs, driveid); break;
748 case 0x05: disk_1305(regs, driveid); break;
749 case 0x08: disk_1308(regs, driveid); break;
750 case 0x09: disk_1309(regs, driveid); break;
751 case 0x0c: disk_130c(regs, driveid); break;
752 case 0x0d: disk_130d(regs, driveid); break;
753 case 0x10: disk_1310(regs, driveid); break;
754 case 0x11: disk_1311(regs, driveid); break;
755 case 0x14: disk_1314(regs, driveid); break;
756 case 0x15: disk_1315(regs, driveid); break;
757 case 0x16: disk_1316(regs, driveid); break;
758 case 0x41: disk_1341(regs, driveid); break;
759 case 0x42: disk_1342(regs, driveid); break;
760 case 0x43: disk_1343(regs, driveid); break;
761 case 0x44: disk_1344(regs, driveid); break;
762 case 0x45: disk_1345(regs, driveid); break;
763 case 0x46: disk_1346(regs, driveid); break;
764 case 0x47: disk_1347(regs, driveid); break;
765 case 0x48: disk_1348(regs, driveid); break;
766 case 0x49: disk_1349(regs, driveid); break;
767 case 0x4e: disk_134e(regs, driveid); break;
768 default: disk_13XX(regs, driveid); break;
773 floppy_13(struct bregs *regs, u8 driveid)
775 // Only limited commands are supported on floppies.
786 disk_13(regs, driveid);
788 default: disk_13XX(regs, driveid); break;
793 /****************************************************************
795 ****************************************************************/
798 get_driveid(struct bregs *regs, u8 exttype, u8 extdriveoffset)
800 // basic check : device has to be defined
801 if (extdriveoffset >= ARRAY_SIZE(Drives.idmap[0]))
804 // Get the ata channel
805 u8 driveid = GET_GLOBAL(Drives.idmap[exttype][extdriveoffset]);
807 // basic check : device has to be valid
808 if (driveid >= ARRAY_SIZE(Drives.drives))
815 handle_legacy_disk(struct bregs *regs, u8 extdrive)
817 if (! CONFIG_DRIVES) {
818 // XXX - support handle_1301 anyway?
819 disk_ret(regs, DISK_RET_EPARAM);
823 if (extdrive < EXTSTART_HD) {
824 int driveid = get_driveid(regs, EXTTYPE_FLOPPY, extdrive);
827 floppy_13(regs, driveid);
832 if (extdrive >= EXTSTART_CD)
833 driveid = get_driveid(regs, EXTTYPE_CD, extdrive - EXTSTART_CD);
835 driveid = get_driveid(regs, EXTTYPE_HD, extdrive - EXTSTART_HD);
838 disk_13(regs, driveid);
842 // XXX - support 1301/1308/1315 anyway?
843 disk_ret(regs, DISK_RET_EPARAM);
847 handle_40(struct bregs *regs)
849 debug_enter(regs, DEBUG_HDL_40);
850 handle_legacy_disk(regs, regs->dl);
853 // INT 13h Fixed Disk Services Entry Point
855 handle_13(struct bregs *regs)
857 debug_enter(regs, DEBUG_HDL_13);
858 u8 extdrive = regs->dl;
860 if (CONFIG_CDROM_EMU) {
861 if (regs->ah == 0x4b) {
865 u16 ebda_seg = get_ebda_seg();
866 if (GET_EBDA2(ebda_seg, cdemu.active)) {
867 u8 emudrive = GET_EBDA2(ebda_seg, cdemu.emulated_extdrive);
868 if (extdrive == emudrive) {
872 if (extdrive < EXTSTART_CD && ((emudrive ^ extdrive) & 0x80) == 0)
876 handle_legacy_disk(regs, extdrive);
879 // record completion in BIOS task complete flag
883 debug_isr(DEBUG_ISR_76);
884 SET_BDA(disk_interrupt_flag, 0xff);
888 // Old Fixed Disk Parameter Table (newer tables are in the ebda).
889 struct fdpt_s OldFDPT VAR16FIXED(0xe401);