aboutsummaryrefslogtreecommitdiff
path: root/w9x/dumpdcb.h
blob: 74679c063d3c41ba87662d9a0d69320e9860bdad (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
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
/* Debugging routines to dump the DCB structure and flags to dlog. */

#ifndef DUMPDCB_H
#define DUMPDCB_H

static void print_dev_flags(uint32_t bitset) {
    if (bitset & DCB_DEV_SPINDOWN_SUPPORTED) dprintf(" DCB_DEV_SPINDOWN_SUPPORTED");
    if (bitset & DCB_DEV_SPUN_DOWN) dprintf(" DCB_DEV_SPUN_DOWN");
    if (bitset & DCB_DEV_IO_ACTIVE) dprintf(" DCB_DEV_IO_ACTIVE");
    if (bitset & DCB_DEV_INT13_CONFIGURED) dprintf(" DCB_DEV_INT13_CONFIGURED");
    if (bitset & DCB_DEV_NO_ASPICAM) dprintf(" DCB_DEV_NO_ASPICAM");
    if (bitset & DCB_DEV_REMOVAL_PENDING) dprintf(" DCB_DEV_REMOVAL_PENDING");
    if (bitset & DCB_DEV_RMM_INT13) dprintf(" DCB_DEV_RMM_INT13");
    if (bitset & DCB_DEV_TSD_PROCESSED) dprintf(" DCB_DEV_TSD_PROCESSED");
    if (bitset & DCB_DEV_SINGLE_FLOPPY) dprintf(" DCB_DEV_SINGLE_FLOPPY");
    if (bitset & DCB_DEV_REAL_MODE) dprintf(" DCB_DEV_REAL_MODE");
    if (bitset & DCB_DEV_QUE_DESCEND) dprintf(" DCB_DEV_QUE_DESCEND");
    if (bitset & DCB_DEV_MEDIA_CHANGED) dprintf(" DCB_DEV_MEDIA_CHANGED");
    if (bitset & DCB_DEV_INVALID_GEOM) dprintf(" DCB_DEV_INVALID_GEOM");
    if (bitset & DCB_DEV_INHIBIT_SW_TIMED_SUPPORT) dprintf(" DCB_DEV_INHIBIT_SW_TIMED_SUPPORT");
    if (bitset & DCB_DEV_ASYNC_MED_CHG_SUPPORT) dprintf(" DCB_DEV_ASYNC_MED_CHG_SUPPORT");
    if (bitset & DCB_DEV_SYNC_MED_CHG_SUPPORT) dprintf(" DCB_DEV_SYNC_MED_CHG_SUPPORT");
    if (bitset & DCB_DEV_PHYSICAL) dprintf(" DCB_DEV_PHYSICAL");
    if (bitset & DCB_DEV_LOGICAL) dprintf(" DCB_DEV_LOGICAL");
    if (bitset & DCB_DEV_RMM) dprintf(" DCB_DEV_RMM");
    if (bitset & DCB_DEV_UNCERTAIN_MEDIA) dprintf(" DCB_DEV_UNCERTAIN_MEDIA");
    if (bitset & DCB_DEV_ROM_CFG_REQ) dprintf(" DCB_DEV_ROM_CFG_REQ");
    if (bitset & DCB_DEV_MUST_CONFIGURE) dprintf(" DCB_DEV_MUST_CONFIGURE");
    if (bitset & DCB_DEV_SSTOR_VOL) dprintf(" DCB_DEV_SSTOR_VOL");
    if (bitset & DCB_DEV_PAGING_DEVICE) dprintf(" DCB_DEV_PAGING_DEVICE");
    if (bitset & DCB_CHAR_DEVICE) dprintf(" DCB_CHAR_DEVICE");
    if (bitset & DCB_DEV_I13_IN_PROGRESS) dprintf(" DCB_DEV_I13_IN_PROGRESS");
    if (bitset & DCB_DEV_CACHE) dprintf(" DCB_DEV_CACHE");
    if (bitset & DCB_DEV_SERIAL_CMD) dprintf(" DCB_DEV_SERIAL_CMD");
    if (bitset & DCB_DEV_REMOTE) dprintf(" DCB_DEV_REMOTE");
    if (bitset & DCB_DEV_REMOVABLE) dprintf(" DCB_DEV_REMOVABLE");
    if (bitset & DCB_DEV_WRITEABLE) dprintf(" DCB_DEV_WRITEABLE");
    if (bitset & DCB_DEV_INT13_DRIVE) dprintf(" DCB_DEV_INT13_DRIVE");
}

void print_tsd_flags(uint32_t flags) {
    if (flags & DCB_TSD_INVALID_PARTITION) dprintf(" DCB_TSD_INVALID_PARTITION");
    if (flags & DCB_TSD_BAD_MBR) dprintf(" DCB_TSD_BAD_MBR");
    if (flags & DCB_TSD_USER_LETTERS_CHECKED) dprintf(" DCB_TSD_USER_LETTERS_CHECKED");
    if (flags & DCB_TSD_FIRST_USER_CHECK) dprintf(" DCB_TSD_FIRST_USER_CHECK");
    if (flags & DCB_TSD_USER_SET) dprintf(" DCB_TSD_USER_SET");
    if (flags & DCB_TSD_NO_USER_INT13) dprintf(" DCB_TSD_NO_USER_INT13");
    if (flags & DCB_TSD_PROTMODE_INT_13) dprintf(" DCB_TSD_PROTMODE_INT_13");
    if (flags & DCB_TSD_NONEXIST_PARTITION) dprintf(" DCB_TSD_NONEXIST_PARTITION");
    if (flags & DCB_TSD_MBPB_PBR) dprintf(" DCB_TSD_MBPB_PBR");
    if (flags & DCB_TSD_RBPB_INIT) dprintf(" DCB_TSD_RBPB_INIT");
    if (flags & DCB_TSD_MBPB_INIT) dprintf(" DCB_TSD_MBPB_INIT");
    if (flags & DCB_TSD_APPARENT_PBR) dprintf(" DCB_TSD_APPARENT_PBR");
    if (flags & DCB_TSD_APPARENT_ROM) dprintf(" DCB_TSD_APPARENT_ROM");
    if (flags & DCB_TSD_ACTUAL_SET) dprintf(" DCB_TSD_ACTUAL_SET");
    if (flags & DCB_TSD_ACTUAL_PRE_SET) dprintf(" DCB_TSD_ACTUAL_PRE_SET");
    if (flags & DCB_TSD_APPARENT_PRE_SET) dprintf(" DCB_TSD_APPARENT_PRE_SET");
}

void print_dmd_flags(uint32_t bitset) {
    if (bitset & DCB_dmd_srb_cdb) dprintf(" %s", "DCB_dmd_srb_cdb");
    if (bitset & DCB_dmd_logical) dprintf(" %s", "DCB_dmd_logical");
    if (bitset & DCB_dmd_physical) dprintf(" %s", "DCB_dmd_physical");
    if (bitset & DCB_dmd_small_memory) dprintf(" %s", "DCB_dmd_small_memory");
    if (bitset & DCB_dmd_not_512) dprintf(" %s", "DCB_dmd_not_512");
    if (bitset & DCB_dmd_word_align) dprintf(" %s", "DCB_dmd_word_align");
    if (bitset & DCB_dmd_dword_align) dprintf(" %s", "DCB_dmd_dword_align");
    if (bitset & DCB_dmd_phys_sgd) dprintf(" %s", "DCB_dmd_phys_sgd");
    if (bitset & DCB_dmd_phys_sgd_ptr) dprintf(" %s", "DCB_dmd_phys_sgd_ptr");
    if (bitset & DCB_dmd_do_a_b_toggling) dprintf(" %s", "DCB_dmd_do_a_b_toggling");
    if (bitset & DCB_dmd_query_remov) dprintf(" %s", "DCB_dmd_query_remov");
    if (bitset & DCB_dmd_request_sns) dprintf(" %s", "DCB_dmd_request_sns");
    if (bitset & DCB_dmd_lock_unlock_media) dprintf(" %s", "DCB_dmd_lock_unlock_media");
    if (bitset & DCB_dmd_load_eject_media) dprintf(" %s", "DCB_dmd_load_eject_media");
    if (bitset & DCB_dmd_clear_media_chg) dprintf(" %s", "DCB_dmd_clear_media_chg");
    if (bitset & DCB_dmd_prot_mode) dprintf(" %s", "DCB_dmd_prot_mode");
    if (bitset & DCB_dmd_no_xclusive) dprintf(" %s", "DCB_dmd_no_xclusive");
    if (bitset & DCB_dmd_pageability) dprintf(" %s", "DCB_dmd_pageability");
}


static void dcb_dump(const DCB *dcb)
{
#if ENABLE_DLOG
    if (dcb->DCB_cmn.DCB_device_flags & DCB_DEV_PHYSICAL) {
        dprintf("DCB %p physical prod %.8s %.16s %.4s port %.8s\n", dcb, dcb->DCB_vendor_id, dcb->DCB_product_id, dcb->DCB_rev_level, dcb->DCB_port_name);
        dprintf("    geom apparent blksize=%u(%u) sectors=%u c=%u h=%u s=%u\n",
                dcb->DCB_bdd.DCB_apparent_blk_size, dcb->DCB_cmn.DCB_apparent_blk_shift, (uint32_t) dcb->DCB_bdd.DCB_apparent_sector_cnt,
                dcb->DCB_bdd.DCB_apparent_cyl_cnt, dcb->DCB_bdd.DCB_apparent_head_cnt, dcb->DCB_bdd.DCB_apparent_spt);
        dprintf("    geom actual blksize=%u sectors=%u c=%u h=%u s=%u\n",
                dcb->DCB_actual_blk_size, (uint32_t) dcb->DCB_actual_sector_cnt,
                dcb->DCB_actual_cyl_cnt, dcb->DCB_actual_head_cnt, dcb->DCB_actual_spt);
        dprintf("    max xfer=%u sg elems=%u\n", dcb->DCB_max_xfer_len, dcb->DCB_max_sg_elements);
    } else {
        dprintf("DCB %p logical\n", dcb);
    }
    // only dump DCB_cmn fields here, since they are common to both logical/physical
    dprintf("    dev flags %x :", dcb->DCB_cmn.DCB_device_flags);
    print_dev_flags(dcb->DCB_cmn.DCB_device_flags);
    dputc('\n');
    dprintf("    TSD flags %x :", dcb->DCB_cmn.DCB_TSD_Flags);
    print_tsd_flags(dcb->DCB_cmn.DCB_TSD_Flags);
    dputc('\n');
    dprintf("    DMD flags %x :", dcb->DCB_cmn.DCB_dmd_flags);
    print_dmd_flags(dcb->DCB_cmn.DCB_dmd_flags);
    dputc('\n');
#endif
}

#endif // DUMPDCB_H