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 u16 segment = GET_INT13EXT(regs, segment);
184 u16 offset = GET_INT13EXT(regs, offset);
185 dop.buf_fl = MAKE_FLATPTR(segment, offset);
186 dop.count = GET_INT13EXT(regs, count);
188 int status = send_disk_op(&dop);
190 SET_INT13EXT(regs, count, dop.count);
192 disk_ret(regs, status);
196 /****************************************************************
197 * Hard Drive functions
198 ****************************************************************/
200 // disk controller reset
202 disk_1300(struct bregs *regs, u8 driveid)
204 struct disk_op_s dop;
205 dop.driveid = driveid;
206 dop.command = CMD_RESET;
207 int status = send_disk_op(&dop);
208 disk_ret(regs, status);
213 disk_1301(struct bregs *regs, u8 driveid)
216 if (regs->dl < EXTSTART_HD)
218 v = GET_BDA(floppy_last_status);
220 v = GET_BDA(disk_last_status);
223 // XXX - clear disk_last_status?
228 disk_1302(struct bregs *regs, u8 driveid)
230 basic_access(regs, driveid, CMD_READ);
233 // write disk sectors
235 disk_1303(struct bregs *regs, u8 driveid)
237 basic_access(regs, driveid, CMD_WRITE);
240 // verify disk sectors
242 disk_1304(struct bregs *regs, u8 driveid)
244 basic_access(regs, driveid, CMD_VERIFY);
250 disk_1305(struct bregs *regs, u8 driveid)
254 u16 nlh = GET_GLOBAL(Drives.drives[driveid].lchs.heads);
255 u16 nlspt = GET_GLOBAL(Drives.drives[driveid].lchs.spt);
257 u8 num_sectors = regs->al;
260 if (head >= nlh || num_sectors == 0 || num_sectors > nlspt) {
261 disk_ret(regs, DISK_RET_EPARAM);
265 struct disk_op_s dop;
266 dop.driveid = driveid;
267 dop.command = CMD_FORMAT;
269 dop.count = num_sectors;
270 dop.buf_fl = MAKE_FLATPTR(regs->es, regs->bx);
271 int status = send_disk_op(&dop);
272 disk_ret(regs, status);
275 // read disk drive parameters
277 disk_1308(struct bregs *regs, u8 driveid)
279 // Get logical geometry from table
280 u16 nlc = GET_GLOBAL(Drives.drives[driveid].lchs.cylinders) - 1;
281 u16 nlh = GET_GLOBAL(Drives.drives[driveid].lchs.heads) - 1;
282 u16 nlspt = GET_GLOBAL(Drives.drives[driveid].lchs.spt);
284 if (regs->dl < EXTSTART_HD) {
286 count = GET_GLOBAL(Drives.floppycount);
288 regs->bx = GET_GLOBAL(Drives.drives[driveid].floppy_type);
290 // set es & di to point to 11 byte diskette param table in ROM
292 regs->di = (u32)&diskette_param_table2;
293 } else if (regs->dl < EXTSTART_CD) {
295 count = GET_BDA(hdcount);
296 nlc--; // last sector reserved
298 // Not supported on CDROM
299 disk_ret(regs, DISK_RET_EPARAM);
304 regs->ch = nlc & 0xff;
305 regs->cl = ((nlc >> 2) & 0xc0) | (nlspt & 0x3f);
308 disk_ret(regs, DISK_RET_SUCCESS);
312 // initialize drive parameters
314 disk_1309(struct bregs *regs, u8 driveid)
319 // seek to specified cylinder
321 disk_130c(struct bregs *regs, u8 driveid)
326 // alternate disk reset
328 disk_130d(struct bregs *regs, u8 driveid)
335 disk_1310(struct bregs *regs, u8 driveid)
337 // should look at 40:8E also???
339 struct disk_op_s dop;
340 dop.driveid = driveid;
341 dop.command = CMD_ISREADY;
342 int status = send_disk_op(&dop);
343 disk_ret(regs, status);
348 disk_1311(struct bregs *regs, u8 driveid)
353 // controller internal diagnostic
355 disk_1314(struct bregs *regs, u8 driveid)
360 // read disk drive size
362 disk_1315(struct bregs *regs, u8 driveid)
364 disk_ret(regs, DISK_RET_SUCCESS);
365 if (regs->dl < EXTSTART_HD || regs->dl >= EXTSTART_CD) {
372 // Get logical geometry from table
373 u16 nlc = GET_GLOBAL(Drives.drives[driveid].lchs.cylinders);
374 u16 nlh = GET_GLOBAL(Drives.drives[driveid].lchs.heads);
375 u16 nlspt = GET_GLOBAL(Drives.drives[driveid].lchs.spt);
377 // Compute sector count seen by int13
378 u32 lba = (u32)(nlc - 1) * (u32)nlh * (u32)nlspt;
379 regs->cx = lba >> 16;
380 regs->dx = lba & 0xffff;
381 regs->ah = 3; // hard disk accessible
385 disk_1316(struct bregs *regs, u8 driveid)
387 if (regs->dl >= EXTSTART_HD) {
389 disk_ret(regs, DISK_RET_EPARAM);
392 disk_ret(regs, DISK_RET_ECHANGED);
395 // IBM/MS installation check
397 disk_1341(struct bregs *regs, u8 driveid)
399 regs->bx = 0xaa55; // install check
400 regs->cx = 0x0007; // ext disk access and edd, removable supported
401 disk_ret(regs, DISK_RET_SUCCESS);
402 regs->ah = 0x30; // EDD 3.0
405 // IBM/MS extended read
407 disk_1342(struct bregs *regs, u8 driveid)
409 extended_access(regs, driveid, CMD_READ);
412 // IBM/MS extended write
414 disk_1343(struct bregs *regs, u8 driveid)
416 extended_access(regs, driveid, CMD_WRITE);
421 disk_1344(struct bregs *regs, u8 driveid)
423 extended_access(regs, driveid, CMD_VERIFY);
428 disk_134500(struct bregs *regs, u8 driveid)
430 u16 ebda_seg = get_ebda_seg();
431 u8 locks = GET_EBDA2(ebda_seg, cdrom_locks[driveid]);
434 disk_ret(regs, DISK_RET_ETOOMANYLOCKS);
437 SET_EBDA2(ebda_seg, cdrom_locks[driveid], locks + 1);
439 disk_ret(regs, DISK_RET_SUCCESS);
444 disk_134501(struct bregs *regs, u8 driveid)
446 u16 ebda_seg = get_ebda_seg();
447 u8 locks = GET_EBDA2(ebda_seg, cdrom_locks[driveid]);
450 disk_ret(regs, DISK_RET_ENOTLOCKED);
454 SET_EBDA2(ebda_seg, cdrom_locks[driveid], locks);
455 regs->al = (locks ? 1 : 0);
456 disk_ret(regs, DISK_RET_SUCCESS);
461 disk_134502(struct bregs *regs, u8 driveid)
463 u8 locks = GET_EBDA(cdrom_locks[driveid]);
464 regs->al = (locks ? 1 : 0);
465 disk_ret(regs, DISK_RET_SUCCESS);
469 disk_1345XX(struct bregs *regs, u8 driveid)
471 disk_ret(regs, DISK_RET_EPARAM);
474 // IBM/MS lock/unlock drive
476 disk_1345(struct bregs *regs, u8 driveid)
478 if (regs->dl < EXTSTART_CD) {
479 // Always success for HD
480 disk_ret(regs, DISK_RET_SUCCESS);
485 case 0x00: disk_134500(regs, driveid); break;
486 case 0x01: disk_134501(regs, driveid); break;
487 case 0x02: disk_134502(regs, driveid); break;
488 default: disk_1345XX(regs, driveid); break;
492 // IBM/MS eject media
494 disk_1346(struct bregs *regs, u8 driveid)
496 if (regs->dl < EXTSTART_CD) {
497 // Volume Not Removable
498 disk_ret(regs, DISK_RET_ENOTREMOVABLE);
502 u8 locks = GET_EBDA(cdrom_locks[driveid]);
504 disk_ret(regs, DISK_RET_ELOCKED);
508 // FIXME should handle 0x31 no media in device
509 // FIXME should handle 0xb5 valid request failed
511 // Call removable media eject
513 memset(&br, 0, sizeof(br));
515 call16_int(0x15, &br);
517 if (br.ah || br.flags & F_CF) {
518 disk_ret(regs, DISK_RET_ELOCKED);
521 disk_ret(regs, DISK_RET_SUCCESS);
524 // IBM/MS extended seek
526 disk_1347(struct bregs *regs, u8 driveid)
528 extended_access(regs, driveid, CMD_SEEK);
531 // IBM/MS get drive parameters
533 disk_1348(struct bregs *regs, u8 driveid)
535 u16 size = GET_INT13DPT(regs, size);
537 // Buffer is too small
539 disk_ret(regs, DISK_RET_EPARAM);
545 u8 type = GET_GLOBAL(Drives.drives[driveid].type);
546 u16 npc = GET_GLOBAL(Drives.drives[driveid].pchs.cylinders);
547 u16 nph = GET_GLOBAL(Drives.drives[driveid].pchs.heads);
548 u16 npspt = GET_GLOBAL(Drives.drives[driveid].pchs.spt);
549 u64 lba = GET_GLOBAL(Drives.drives[driveid].sectors);
550 u16 blksize = GET_GLOBAL(Drives.drives[driveid].blksize);
552 dprintf(DEBUG_HDL_13, "disk_1348 size=%d t=%d chs=%d,%d,%d lba=%d bs=%d\n"
553 , size, type, npc, nph, npspt, (u32)lba, blksize);
555 SET_INT13DPT(regs, size, 26);
556 if (type == DTYPE_ATAPI) {
557 // 0x74 = removable, media change, lockable, max values
558 SET_INT13DPT(regs, infos, 0x74);
559 SET_INT13DPT(regs, cylinders, 0xffffffff);
560 SET_INT13DPT(regs, heads, 0xffffffff);
561 SET_INT13DPT(regs, spt, 0xffffffff);
562 SET_INT13DPT(regs, sector_count, (u64)-1);
564 if (lba > (u64)npspt*nph*0x3fff) {
565 SET_INT13DPT(regs, infos, 0x00); // geometry is invalid
566 SET_INT13DPT(regs, cylinders, 0x3fff);
568 SET_INT13DPT(regs, infos, 0x02); // geometry is valid
569 SET_INT13DPT(regs, cylinders, (u32)npc);
571 SET_INT13DPT(regs, heads, (u32)nph);
572 SET_INT13DPT(regs, spt, (u32)npspt);
573 SET_INT13DPT(regs, sector_count, lba);
575 SET_INT13DPT(regs, blksize, blksize);
577 if (size < 30 || (type != DTYPE_ATA && type != DTYPE_ATAPI)) {
578 disk_ret(regs, DISK_RET_SUCCESS);
584 u16 ebda_seg = get_ebda_seg();
585 SET_INT13DPT(regs, size, 30);
587 SET_INT13DPT(regs, dpte_segment, ebda_seg);
588 SET_INT13DPT(regs, dpte_offset
589 , offsetof(struct extended_bios_data_area_s, dpte));
592 u8 ataid = GET_GLOBAL(Drives.drives[driveid].cntl_id);
593 u8 channel = ataid / 2;
594 u8 slave = ataid % 2;
595 u16 iobase1 = GET_GLOBAL(ATA_channels[channel].iobase1);
596 u16 iobase2 = GET_GLOBAL(ATA_channels[channel].iobase2);
597 u8 irq = GET_GLOBAL(ATA_channels[channel].irq);
600 if (type == DTYPE_ATA) {
601 u8 translation = GET_GLOBAL(Drives.drives[driveid].translation);
602 if (translation != TRANSLATION_NONE) {
603 options |= 1<<3; // CHS translation
604 if (translation == TRANSLATION_LBA)
606 if (translation == TRANSLATION_RECHS)
611 options |= 1<<5; // removable device
612 options |= 1<<6; // atapi device
614 options |= 1<<4; // lba translation
615 if (CONFIG_ATA_PIO32)
618 SET_EBDA2(ebda_seg, dpte.iobase1, iobase1);
619 SET_EBDA2(ebda_seg, dpte.iobase2, iobase2 + ATA_CB_DC);
620 SET_EBDA2(ebda_seg, dpte.prefix, ((slave ? ATA_CB_DH_DEV1 : ATA_CB_DH_DEV0)
622 SET_EBDA2(ebda_seg, dpte.unused, 0xcb);
623 SET_EBDA2(ebda_seg, dpte.irq, irq);
624 SET_EBDA2(ebda_seg, dpte.blkcount, 1);
625 SET_EBDA2(ebda_seg, dpte.dma, 0);
626 SET_EBDA2(ebda_seg, dpte.pio, 0);
627 SET_EBDA2(ebda_seg, dpte.options, options);
628 SET_EBDA2(ebda_seg, dpte.reserved, 0);
629 SET_EBDA2(ebda_seg, dpte.revision, 0x11);
631 u8 sum = checksum_far(
632 ebda_seg, (void*)offsetof(struct extended_bios_data_area_s, dpte), 15);
633 SET_EBDA2(ebda_seg, dpte.checksum, -sum);
636 disk_ret(regs, DISK_RET_SUCCESS);
641 SET_INT13DPT(regs, key, 0xbedd);
642 SET_INT13DPT(regs, dpi_length, 36);
643 SET_INT13DPT(regs, reserved1, 0);
644 SET_INT13DPT(regs, reserved2, 0);
646 SET_INT13DPT(regs, host_bus[0], 'P');
647 SET_INT13DPT(regs, host_bus[1], 'C');
648 SET_INT13DPT(regs, host_bus[2], 'I');
649 SET_INT13DPT(regs, host_bus[3], 0);
651 u32 bdf = GET_GLOBAL(ATA_channels[channel].pci_bdf);
652 u32 path = (pci_bdf_to_bus(bdf) | (pci_bdf_to_dev(bdf) << 8)
653 | (pci_bdf_to_fn(bdf) << 16));
654 SET_INT13DPT(regs, iface_path, path);
656 SET_INT13DPT(regs, iface_type[0], 'A');
657 SET_INT13DPT(regs, iface_type[1], 'T');
658 SET_INT13DPT(regs, iface_type[2], 'A');
659 SET_INT13DPT(regs, iface_type[3], 0);
660 SET_INT13DPT(regs, iface_type[4], 0);
661 SET_INT13DPT(regs, iface_type[5], 0);
662 SET_INT13DPT(regs, iface_type[6], 0);
663 SET_INT13DPT(regs, iface_type[7], 0);
665 SET_INT13DPT(regs, device_path, slave);
667 SET_INT13DPT(regs, checksum
668 , -checksum_far(regs->ds, (void*)(regs->si+30), 35));
670 disk_ret(regs, DISK_RET_SUCCESS);
673 // IBM/MS extended media change
675 disk_1349(struct bregs *regs, u8 driveid)
677 if (regs->dl < EXTSTART_CD) {
678 // Always success for HD
679 disk_ret(regs, DISK_RET_SUCCESS);
683 // always send changed ??
684 regs->ah = DISK_RET_ECHANGED;
688 disk_134e01(struct bregs *regs, u8 driveid)
690 disk_ret(regs, DISK_RET_SUCCESS);
694 disk_134e03(struct bregs *regs, u8 driveid)
696 disk_ret(regs, DISK_RET_SUCCESS);
700 disk_134e04(struct bregs *regs, u8 driveid)
702 disk_ret(regs, DISK_RET_SUCCESS);
706 disk_134e06(struct bregs *regs, u8 driveid)
708 disk_ret(regs, DISK_RET_SUCCESS);
712 disk_134eXX(struct bregs *regs, u8 driveid)
714 disk_ret(regs, DISK_RET_EPARAM);
717 // IBM/MS set hardware configuration
719 disk_134e(struct bregs *regs, u8 driveid)
722 case 0x01: disk_134e01(regs, driveid); break;
723 case 0x03: disk_134e03(regs, driveid); break;
724 case 0x04: disk_134e04(regs, driveid); break;
725 case 0x06: disk_134e06(regs, driveid); break;
726 default: disk_134eXX(regs, driveid); break;
731 disk_13XX(struct bregs *regs, u8 driveid)
733 disk_ret(regs, DISK_RET_EPARAM);
737 disk_13(struct bregs *regs, u8 driveid)
741 // clear completion flag
742 SET_BDA(disk_interrupt_flag, 0);
745 case 0x00: disk_1300(regs, driveid); break;
746 case 0x01: disk_1301(regs, driveid); break;
747 case 0x02: disk_1302(regs, driveid); break;
748 case 0x03: disk_1303(regs, driveid); break;
749 case 0x04: disk_1304(regs, driveid); break;
750 case 0x05: disk_1305(regs, driveid); break;
751 case 0x08: disk_1308(regs, driveid); break;
752 case 0x09: disk_1309(regs, driveid); break;
753 case 0x0c: disk_130c(regs, driveid); break;
754 case 0x0d: disk_130d(regs, driveid); break;
755 case 0x10: disk_1310(regs, driveid); break;
756 case 0x11: disk_1311(regs, driveid); break;
757 case 0x14: disk_1314(regs, driveid); break;
758 case 0x15: disk_1315(regs, driveid); break;
759 case 0x16: disk_1316(regs, driveid); break;
760 case 0x41: disk_1341(regs, driveid); break;
761 case 0x42: disk_1342(regs, driveid); break;
762 case 0x43: disk_1343(regs, driveid); break;
763 case 0x44: disk_1344(regs, driveid); break;
764 case 0x45: disk_1345(regs, driveid); break;
765 case 0x46: disk_1346(regs, driveid); break;
766 case 0x47: disk_1347(regs, driveid); break;
767 case 0x48: disk_1348(regs, driveid); break;
768 case 0x49: disk_1349(regs, driveid); break;
769 case 0x4e: disk_134e(regs, driveid); break;
770 default: disk_13XX(regs, driveid); break;
775 floppy_13(struct bregs *regs, u8 driveid)
777 // Only limited commands are supported on floppies.
788 disk_13(regs, driveid);
790 default: disk_13XX(regs, driveid); break;
795 /****************************************************************
797 ****************************************************************/
800 get_driveid(struct bregs *regs, u8 exttype, u8 extdriveoffset)
802 // basic check : device has to be defined
803 if (extdriveoffset >= ARRAY_SIZE(Drives.idmap[0]))
806 // Get the ata channel
807 u8 driveid = GET_GLOBAL(Drives.idmap[exttype][extdriveoffset]);
809 // basic check : device has to be valid
810 if (driveid >= ARRAY_SIZE(Drives.drives))
817 handle_legacy_disk(struct bregs *regs, u8 extdrive)
819 if (! CONFIG_DRIVES) {
820 // XXX - support handle_1301 anyway?
821 disk_ret(regs, DISK_RET_EPARAM);
825 if (extdrive < EXTSTART_HD) {
826 int driveid = get_driveid(regs, EXTTYPE_FLOPPY, extdrive);
829 floppy_13(regs, driveid);
834 if (extdrive >= EXTSTART_CD)
835 driveid = get_driveid(regs, EXTTYPE_CD, extdrive - EXTSTART_CD);
837 driveid = get_driveid(regs, EXTTYPE_HD, extdrive - EXTSTART_HD);
840 disk_13(regs, driveid);
844 // XXX - support 1301/1308/1315 anyway?
845 disk_ret(regs, DISK_RET_EPARAM);
849 handle_40(struct bregs *regs)
851 debug_enter(regs, DEBUG_HDL_40);
852 handle_legacy_disk(regs, regs->dl);
855 // INT 13h Fixed Disk Services Entry Point
857 handle_13(struct bregs *regs)
859 debug_enter(regs, DEBUG_HDL_13);
860 u8 extdrive = regs->dl;
862 if (CONFIG_CDROM_EMU) {
863 if (regs->ah == 0x4b) {
867 u16 ebda_seg = get_ebda_seg();
868 if (GET_EBDA2(ebda_seg, cdemu.active)) {
869 u8 emudrive = GET_EBDA2(ebda_seg, cdemu.emulated_extdrive);
870 if (extdrive == emudrive) {
874 if (extdrive < EXTSTART_CD && ((emudrive ^ extdrive) & 0x80) == 0)
878 handle_legacy_disk(regs, extdrive);
881 // record completion in BIOS task complete flag
885 debug_isr(DEBUG_ISR_76);
886 SET_BDA(disk_interrupt_flag, 0xff);
890 // Old Fixed Disk Parameter Table (newer tables are in the ebda).
891 struct fdpt_s OldFDPT VAR16FIXED(0xe401);