Version 0.1.2
[seabios.git] / src / disk.c
1 // 16bit code to access hard drives.
2 //
3 // Copyright (C) 2008  Kevin O'Connor <kevin@koconnor.net>
4 // Copyright (C) 2002  MandrakeSoft S.A.
5 //
6 // This file may be distributed under the terms of the GNU GPLv3 license.
7
8 #include "disk.h" // floppy_13
9 #include "biosvar.h" // struct bregs
10 #include "util.h" // debug_enter
11
12 static void
13 disk_13(struct bregs *regs, u8 drive)
14 {
15     // XXX
16     set_cf(regs, 1);
17 }
18
19 static void
20 handle_legacy_disk(struct bregs *regs, u8 drive)
21 {
22     if (drive < 0x80) {
23         floppy_13(regs, drive);
24         return;
25     }
26 #if BX_USE_ATADRV
27     if (drive >= 0xE0) {
28         int13_cdrom(regs); // xxx
29         return;
30     }
31 #endif
32
33     disk_13(regs, drive);
34 }
35
36 void VISIBLE
37 handle_40(struct bregs *regs)
38 {
39     debug_enter(regs);
40     handle_legacy_disk(regs, regs->dl);
41     debug_exit(regs);
42 }
43
44 // INT 13h Fixed Disk Services Entry Point
45 void VISIBLE
46 handle_13(struct bregs *regs)
47 {
48     //debug_enter(regs);
49     u8 drive = regs->dl;
50     // XXX
51 #if BX_ELTORITO_BOOT
52     if (regs->ah >= 0x4a || regs->ah <= 0x4d) {
53         int13_eltorito(regs);
54     } else if (cdemu_isactive() && cdrom_emulated_drive()) {
55         int13_cdemu(regs);
56     } else
57 #endif
58         handle_legacy_disk(regs, drive);
59     debug_exit(regs);
60 }
61
62 // record completion in BIOS task complete flag
63 void VISIBLE
64 handle_76(struct bregs *regs)
65 {
66     debug_enter(regs);
67     SET_BDA(floppy_harddisk_info, 0xff);
68     eoi_both_pics();
69 }