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 * Initial Program Load (IPL)
133 ****************************************************************/
143 struct ipl_entry_s table[8];
150 #define IPL_TYPE_FLOPPY 0x01
151 #define IPL_TYPE_HARDDISK 0x02
152 #define IPL_TYPE_CDROM 0x03
153 #define IPL_TYPE_BEV 0x80
156 /****************************************************************
157 * Extended Bios Data Area (EBDA)
158 ****************************************************************/
183 u8 drive_control_byte;
191 struct extended_bios_data_area_s {
194 u32 far_call_pointer;
202 struct fdpt_s fdpt[2];
207 // 0x121 - Begin custom storage.
212 // Count of transferred sectors and bytes to/from disk
215 // Buffer for disk DPTE table
218 // Locks for removable devices
219 u8 cdrom_locks[CONFIG_MAX_ATA_DEVICES];
221 // Initial program load
225 u8 resume_stack[128] __aligned(8);
228 // Accessor functions
229 #define GET_EBDA(var) \
230 GET_FARVAR(GET_BDA(ebda_seg), ((struct extended_bios_data_area_s *)0)->var)
231 #define SET_EBDA(var, val) \
232 SET_FARVAR(GET_BDA(ebda_seg), ((struct extended_bios_data_area_s *)0)->var, (val))
233 static inline struct extended_bios_data_area_s *
236 extern void *__force_link_error__get_ebda_ptr_only_in_32bit();
238 return __force_link_error__get_ebda_ptr_only_in_32bit();
239 return (void*)MAKE_FARPTR(GET_BDA(ebda_seg), 0);
243 /****************************************************************
245 ****************************************************************/
247 #define GET_GLOBAL(var) \
250 extern void __force_link_error__set_global_only_in_32bit();
251 #define SET_GLOBAL(var, val) do { \
253 __force_link_error__set_global_only_in_32bit(); \
256 #define SET_GLOBAL(var, val) \
257 do { (var) = (val); } while (0)
261 /****************************************************************
263 ****************************************************************/
265 struct bios_config_table_s {
270 u8 feature1, feature2, feature3, feature4, feature5;
273 extern struct bios_config_table_s BIOS_CONFIG_TABLE;
275 #endif // __BIOSVAR_H