1 // Variable layouts of bios.
3 // Copyright (C) 2008 Kevin O'Connor <kevin@koconnor.net>
5 // This file may be distributed under the terms of the GNU GPLv3 license.
9 #include "types.h" // u8
10 #include "farptr.h" // GET_FARVAR
11 #include "config.h" // CONFIG_*
14 /****************************************************************
15 * Bios Data Area (BDA)
16 ****************************************************************/
23 struct bios_data_area_s {
25 struct ivec ivecs[256];
33 u16 equipment_list_flags;
45 u8 floppy_recalibration_status;
46 u8 floppy_motor_status;
48 u8 floppy_motor_counter;
49 u8 floppy_last_status;
50 u8 floppy_return_status[7];
78 u16 kbd_buf_start_offset;
79 u16 kbd_buf_end_offset;
86 u8 floppy_last_data_rate;
87 u8 disk_status_controller;
88 u8 disk_error_controller;
89 u8 disk_interrupt_flag;
90 u8 floppy_harddisk_info;
92 u8 floppy_media_state[4];
97 u32 ptr_user_wait_complete_flag;
98 u32 user_wait_timeout;
103 // BDA floppy_recalibration_status bitdefs
104 #define FRS_TIMEOUT (1<<7)
106 // BDA rtc_wait_flag bitdefs
107 #define RWS_WAIT_PENDING (1<<0)
108 #define RWS_WAIT_ELAPSED (1<<7)
110 // BDA floppy_media_state bitdefs
111 #define FMS_DRIVE_STATE_MASK (0x07)
112 #define FMS_MEDIA_DRIVE_ESTABLISHED (1<<4)
113 #define FMS_DOUBLE_STEPPING (1<<5)
114 #define FMS_DATA_RATE_MASK (0xc0)
116 // Accessor functions
117 #define GET_BDA(var) \
118 GET_FARVAR(SEG_BDA, ((struct bios_data_area_s *)0)->var)
119 #define SET_BDA(var, val) \
120 SET_FARVAR(SEG_BDA, ((struct bios_data_area_s *)0)->var, (val))
121 #define CLEARBITS_BDA(var, val) do { \
122 typeof(((struct bios_data_area_s *)0)->var) __val = GET_BDA(var); \
123 SET_BDA(var, (__val & ~(val))); \
125 #define SETBITS_BDA(var, val) do { \
126 typeof(((struct bios_data_area_s *)0)->var) __val = GET_BDA(var); \
127 SET_BDA(var, (__val | (val))); \
131 /****************************************************************
132 * Extended Bios Data Area (EBDA)
133 ****************************************************************/
158 u8 drive_control_byte;
166 struct extended_bios_data_area_s {
169 u32 far_call_pointer;
177 struct fdpt_s fdpt[2];
182 // 0x121 - Begin custom storage.
187 // Count of transferred sectors and bytes to/from disk
190 // Buffer for disk DPTE table
193 // Locks for removable devices
194 u8 cdrom_locks[CONFIG_MAX_ATA_DEVICES];
199 u8 resume_stack[128] __aligned(8);
202 // Accessor functions
203 static inline u16 get_ebda_seg() {
204 return GET_BDA(ebda_seg);
206 static inline struct extended_bios_data_area_s *
209 extern void *__force_link_error__get_ebda_ptr_only_in_32bit();
211 return __force_link_error__get_ebda_ptr_only_in_32bit();
212 return (void*)MAKE_FARPTR(get_ebda_seg(), 0);
214 #define GET_EBDA2(eseg, var) \
215 GET_FARVAR(eseg, ((struct extended_bios_data_area_s *)0)->var)
216 #define SET_EBDA2(eseg, var, val) \
217 SET_FARVAR(eseg, ((struct extended_bios_data_area_s *)0)->var, (val))
218 #define GET_EBDA(var) \
219 GET_EBDA2(get_ebda_seg(), var)
220 #define SET_EBDA(var, val) \
221 SET_EBDA2(get_ebda_seg(), var, (val))
224 /****************************************************************
226 ****************************************************************/
228 #define GET_GLOBAL(var) \
231 extern void __force_link_error__set_global_only_in_32bit();
232 #define SET_GLOBAL(var, val) do { \
234 __force_link_error__set_global_only_in_32bit(); \
237 #define SET_GLOBAL(var, val) \
238 do { (var) = (val); } while (0)
242 /****************************************************************
244 ****************************************************************/
246 struct bios_config_table_s {
251 u8 feature1, feature2, feature3, feature4, feature5;
254 extern struct bios_config_table_s BIOS_CONFIG_TABLE;
256 #endif // __BIOSVAR_H