aboutsummaryrefslogtreecommitdiff
path: root/src/disk.c
blob: 8901b7d4b2a99a8e016f8f75ba0ad44dd6747c58 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
// 16bit code to access hard drives.
//
// Copyright (C) 2008  Kevin O'Connor <kevin@koconnor.net>
// Copyright (C) 2002  MandrakeSoft S.A.
//
// This file may be distributed under the terms of the GNU GPLv3 license.

#include "disk.h" // floppy_13
#include "biosvar.h" // struct bregs
#include "util.h" // debug_enter

static void
disk_13(struct bregs *regs, u8 drive)
{
    set_cf(regs, 1);
}

static void
handle_legacy_disk(struct bregs *regs, u8 drive)
{
    if (drive < 0x80) {
        floppy_13(regs, drive);
        return;
    }
#if BX_USE_ATADRV
    if (drive >= 0xE0) {
        int13_cdrom(regs); // xxx
        return;
    }
#endif

    disk_13(regs, drive);
}

void VISIBLE
handle_40(struct bregs *regs)
{
    debug_enter(regs);
    handle_legacy_disk(regs, regs->dl);
    debug_exit(regs);
}

// INT 13h Fixed Disk Services Entry Point
void VISIBLE
handle_13(struct bregs *regs)
{
    debug_enter(regs);
    u8 drive = regs->dl;
#if BX_ELTORITO_BOOT
    if (regs->ah >= 0x4a || regs->ah <= 0x4d) {
        int13_eltorito(regs);
    } else if (cdemu_isactive() && cdrom_emulated_drive()) {
        int13_cdemu(regs);
    } else
#endif
        handle_legacy_disk(regs, drive);
    debug_exit(regs);
}

// record completion in BIOS task complete flag
void VISIBLE
handle_76(struct bregs *regs)
{
    debug_enter(regs);
    SET_BDA(floppy_harddisk_info, 0xff);
    eoi_both_pics();
}