Version 0.1.1
[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     set_cf(regs, 1);
16 }
17
18 static void
19 handle_legacy_disk(struct bregs *regs, u8 drive)
20 {
21     if (drive < 0x80) {
22         floppy_13(regs, drive);
23         return;
24     }
25 #if BX_USE_ATADRV
26     if (drive >= 0xE0) {
27         int13_cdrom(regs); // xxx
28         return;
29     }
30 #endif
31
32     disk_13(regs, drive);
33 }
34
35 void VISIBLE
36 handle_40(struct bregs *regs)
37 {
38     debug_enter(regs);
39     handle_legacy_disk(regs, regs->dl);
40     debug_exit(regs);
41 }
42
43 // INT 13h Fixed Disk Services Entry Point
44 void VISIBLE
45 handle_13(struct bregs *regs)
46 {
47     //debug_enter(regs);
48     u8 drive = regs->dl;
49 #if BX_ELTORITO_BOOT
50     if (regs->ah >= 0x4a || regs->ah <= 0x4d) {
51         int13_eltorito(regs);
52     } else if (cdemu_isactive() && cdrom_emulated_drive()) {
53         int13_cdemu(regs);
54     } else
55 #endif
56         handle_legacy_disk(regs, drive);
57     debug_exit(regs);
58 }
59
60 // record completion in BIOS task complete flag
61 void VISIBLE
62 handle_76(struct bregs *regs)
63 {
64     debug_enter(regs);
65     SET_BDA(floppy_harddisk_info, 0xff);
66     eoi_both_pics();
67 }