Kevin O'Connor | 392d2aa | 2013-09-15 00:14:28 -0400 | [diff] [blame^] | 1 | // BIOS Data Area (and similar) definitions |
| 2 | #ifndef __BDA_H |
| 3 | #define __BDA_H |
| 4 | |
| 5 | #include "disk.h" // struct fdpt_s |
| 6 | #include "types.h" // u8 |
| 7 | |
| 8 | |
| 9 | /**************************************************************** |
| 10 | * Interupt vector table |
| 11 | ****************************************************************/ |
| 12 | |
| 13 | struct rmode_IVT { |
| 14 | struct segoff_s ivec[256]; |
| 15 | }; |
| 16 | |
| 17 | |
| 18 | /**************************************************************** |
| 19 | * Bios Data Area (BDA) |
| 20 | ****************************************************************/ |
| 21 | |
| 22 | struct bios_data_area_s { |
| 23 | // 40:00 |
| 24 | u16 port_com[4]; |
| 25 | u16 port_lpt[3]; |
| 26 | u16 ebda_seg; |
| 27 | // 40:10 |
| 28 | u16 equipment_list_flags; |
| 29 | u8 pad1; |
| 30 | u16 mem_size_kb; |
| 31 | u8 pad2; |
| 32 | u8 ps2_ctrl_flag; |
| 33 | u8 kbd_flag0; |
| 34 | u8 kbd_flag1; |
| 35 | u8 alt_keypad; |
| 36 | u16 kbd_buf_head; |
| 37 | u16 kbd_buf_tail; |
| 38 | // 40:1e |
| 39 | u8 kbd_buf[32]; |
| 40 | u8 floppy_recalibration_status; |
| 41 | u8 floppy_motor_status; |
| 42 | // 40:40 |
| 43 | u8 floppy_motor_counter; |
| 44 | u8 floppy_last_status; |
| 45 | u8 floppy_return_status[7]; |
| 46 | u8 video_mode; |
| 47 | u16 video_cols; |
| 48 | u16 video_pagesize; |
| 49 | u16 video_pagestart; |
| 50 | // 40:50 |
| 51 | u16 cursor_pos[8]; |
| 52 | // 40:60 |
| 53 | u16 cursor_type; |
| 54 | u8 video_page; |
| 55 | u16 crtc_address; |
| 56 | u8 video_msr; |
| 57 | u8 video_pal; |
| 58 | struct segoff_s jump; |
| 59 | u8 other_6b; |
| 60 | u32 timer_counter; |
| 61 | // 40:70 |
| 62 | u8 timer_rollover; |
| 63 | u8 break_flag; |
| 64 | u16 soft_reset_flag; |
| 65 | u8 disk_last_status; |
| 66 | u8 hdcount; |
| 67 | u8 disk_control_byte; |
| 68 | u8 port_disk; |
| 69 | u8 lpt_timeout[4]; |
| 70 | u8 com_timeout[4]; |
| 71 | // 40:80 |
| 72 | u16 kbd_buf_start_offset; |
| 73 | u16 kbd_buf_end_offset; |
| 74 | u8 video_rows; |
| 75 | u16 char_height; |
| 76 | u8 video_ctl; |
| 77 | u8 video_switches; |
| 78 | u8 modeset_ctl; |
| 79 | u8 dcc_index; |
| 80 | u8 floppy_last_data_rate; |
| 81 | u8 disk_status_controller; |
| 82 | u8 disk_error_controller; |
| 83 | u8 disk_interrupt_flag; |
| 84 | u8 floppy_harddisk_info; |
| 85 | // 40:90 |
| 86 | u8 floppy_media_state[4]; |
| 87 | u8 floppy_track[2]; |
| 88 | u8 kbd_flag2; |
| 89 | u8 kbd_led; |
| 90 | struct segoff_s user_wait_complete_flag; |
| 91 | u32 user_wait_timeout; |
| 92 | // 40:A0 |
| 93 | u8 rtc_wait_flag; |
| 94 | u8 other_a1[7]; |
| 95 | struct segoff_s video_savetable; |
| 96 | u8 other_ac[4]; |
| 97 | // 40:B0 |
| 98 | u8 other_b0[9]; |
| 99 | u8 vbe_flag; |
| 100 | u16 vbe_mode; |
| 101 | u8 other_bc[4]; |
| 102 | // 40:C0 |
| 103 | u8 other_c0[4*16]; |
| 104 | } PACKED; |
| 105 | |
| 106 | // BDA floppy_recalibration_status bitdefs |
| 107 | #define FRS_IRQ (1<<7) |
| 108 | |
| 109 | // BDA rtc_wait_flag bitdefs |
| 110 | #define RWS_WAIT_PENDING (1<<0) |
| 111 | #define RWS_WAIT_ELAPSED (1<<7) |
| 112 | |
| 113 | // BDA floppy_media_state bitdefs |
| 114 | #define FMS_DRIVE_STATE_MASK (0x07) |
| 115 | #define FMS_MEDIA_DRIVE_ESTABLISHED (1<<4) |
| 116 | #define FMS_DOUBLE_STEPPING (1<<5) |
| 117 | #define FMS_DATA_RATE_MASK (0xc0) |
| 118 | |
| 119 | // Limit of BDA timer_counter field |
| 120 | #define TICKS_PER_DAY 1573040 |
| 121 | |
| 122 | |
| 123 | /**************************************************************** |
| 124 | * Extended Bios Data Area (EBDA) |
| 125 | ****************************************************************/ |
| 126 | |
| 127 | struct extended_bios_data_area_s { |
| 128 | u8 size; |
| 129 | u8 reserved1[0x21]; |
| 130 | struct segoff_s far_call_pointer; |
| 131 | u8 mouse_flag1; |
| 132 | u8 mouse_flag2; |
| 133 | u8 mouse_data[0x08]; |
| 134 | // 0x30 |
| 135 | u8 other1[0x0d]; |
| 136 | |
| 137 | // 0x3d |
| 138 | struct fdpt_s fdpt[2]; |
| 139 | |
| 140 | // 0x5d |
| 141 | u8 other2[0xC4]; |
| 142 | |
| 143 | // 0x121 - Begin custom storage. |
| 144 | } PACKED; |
| 145 | |
| 146 | |
| 147 | /**************************************************************** |
| 148 | * Bios Config Table |
| 149 | ****************************************************************/ |
| 150 | |
| 151 | struct bios_config_table_s { |
| 152 | u16 size; |
| 153 | u8 model; |
| 154 | u8 submodel; |
| 155 | u8 biosrev; |
| 156 | u8 feature1, feature2, feature3, feature4, feature5; |
| 157 | } PACKED; |
| 158 | |
| 159 | #endif // bda.h |