Annotation of qemu/roms/seabios/src/biosvar.h, revision 1.1.1.3

1.1       root        1: // Variable layouts of bios.
                      2: //
                      3: // Copyright (C) 2008,2009  Kevin O'Connor <[email protected]>
                      4: //
                      5: // This file may be distributed under the terms of the GNU LGPLv3 license.
                      6: #ifndef __BIOSVAR_H
                      7: #define __BIOSVAR_H
                      8: 
                      9: #include "types.h" // u8
                     10: #include "farptr.h" // GET_FARVAR
                     11: #include "config.h" // CONFIG_*
                     12: #include "disk.h" // struct chs_s
                     13: 
                     14: 
                     15: /****************************************************************
                     16:  * Interupt vector table
                     17:  ****************************************************************/
                     18: 
                     19: struct rmode_IVT {
                     20:     struct segoff_s ivec[256];
                     21: };
                     22: 
                     23: #define GET_IVT(vector)                                         \
                     24:     GET_FARVAR(SEG_IVT, ((struct rmode_IVT *)0)->ivec[vector])
                     25: #define SET_IVT(vector, segoff)                                         \
                     26:     SET_FARVAR(SEG_IVT, ((struct rmode_IVT *)0)->ivec[vector], segoff)
                     27: 
                     28: 
                     29: /****************************************************************
                     30:  * Bios Data Area (BDA)
                     31:  ****************************************************************/
                     32: 
                     33: struct bios_data_area_s {
                     34:     // 40:00
                     35:     u16 port_com[4];
                     36:     u16 port_lpt[3];
                     37:     u16 ebda_seg;
                     38:     // 40:10
                     39:     u16 equipment_list_flags;
                     40:     u8 pad1;
                     41:     u16 mem_size_kb;
                     42:     u8 pad2;
                     43:     u8 ps2_ctrl_flag;
                     44:     u8 kbd_flag0;
                     45:     u8 kbd_flag1;
                     46:     u8 alt_keypad;
                     47:     u16 kbd_buf_head;
                     48:     u16 kbd_buf_tail;
                     49:     // 40:1e
                     50:     u8 kbd_buf[32];
                     51:     u8 floppy_recalibration_status;
                     52:     u8 floppy_motor_status;
                     53:     // 40:40
                     54:     u8 floppy_motor_counter;
                     55:     u8 floppy_last_status;
                     56:     u8 floppy_return_status[7];
                     57:     u8 video_mode;
                     58:     u16 video_cols;
                     59:     u16 video_pagesize;
                     60:     u16 video_pagestart;
                     61:     // 40:50
                     62:     u16 cursor_pos[8];
                     63:     // 40:60
                     64:     u16 cursor_type;
                     65:     u8 video_page;
                     66:     u16 crtc_address;
                     67:     u8 video_msr;
                     68:     u8 video_pal;
                     69:     struct segoff_s jump;
                     70:     u8 other_6b;
                     71:     u32 timer_counter;
                     72:     // 40:70
                     73:     u8 timer_rollover;
                     74:     u8 break_flag;
                     75:     u16 soft_reset_flag;
                     76:     u8 disk_last_status;
                     77:     u8 hdcount;
                     78:     u8 disk_control_byte;
                     79:     u8 port_disk;
                     80:     u8 lpt_timeout[4];
                     81:     u8 com_timeout[4];
                     82:     // 40:80
                     83:     u16 kbd_buf_start_offset;
                     84:     u16 kbd_buf_end_offset;
                     85:     u8 video_rows;
                     86:     u16 char_height;
                     87:     u8 video_ctl;
                     88:     u8 video_switches;
                     89:     u8 modeset_ctl;
                     90:     u8 dcc_index;
                     91:     u8 floppy_last_data_rate;
                     92:     u8 disk_status_controller;
                     93:     u8 disk_error_controller;
                     94:     u8 disk_interrupt_flag;
                     95:     u8 floppy_harddisk_info;
                     96:     // 40:90
                     97:     u8 floppy_media_state[4];
                     98:     u8 floppy_track[2];
                     99:     u8 kbd_flag2;
                    100:     u8 kbd_led;
                    101:     struct segoff_s user_wait_complete_flag;
                    102:     u32 user_wait_timeout;
                    103:     // 40:A0
                    104:     u8 rtc_wait_flag;
                    105:     u8 other_a1[7];
                    106:     struct segoff_s video_savetable;
                    107:     u8 other_ac[4];
                    108:     // 40:B0
                    109:     u8 other_b0[10];
                    110:     u16 vbe_mode;
                    111: } PACKED;
                    112: 
                    113: // BDA floppy_recalibration_status bitdefs
                    114: #define FRS_TIMEOUT (1<<7)
                    115: 
                    116: // BDA rtc_wait_flag bitdefs
                    117: #define RWS_WAIT_PENDING (1<<0)
                    118: #define RWS_WAIT_ELAPSED (1<<7)
                    119: 
                    120: // BDA floppy_media_state bitdefs
                    121: #define FMS_DRIVE_STATE_MASK        (0x07)
                    122: #define FMS_MEDIA_DRIVE_ESTABLISHED (1<<4)
                    123: #define FMS_DOUBLE_STEPPING         (1<<5)
                    124: #define FMS_DATA_RATE_MASK          (0xc0)
                    125: 
                    126: // Accessor functions
                    127: #define GET_BDA(var) \
                    128:     GET_FARVAR(SEG_BDA, ((struct bios_data_area_s *)0)->var)
                    129: #define SET_BDA(var, val) \
                    130:     SET_FARVAR(SEG_BDA, ((struct bios_data_area_s *)0)->var, (val))
                    131: #define CLEARBITS_BDA(var, val) do {                                    \
                    132:         typeof(((struct bios_data_area_s *)0)->var) __val = GET_BDA(var); \
                    133:         SET_BDA(var, (__val & ~(val)));                                 \
                    134:     } while (0)
                    135: #define SETBITS_BDA(var, val) do {                                      \
                    136:         typeof(((struct bios_data_area_s *)0)->var) __val = GET_BDA(var); \
                    137:         SET_BDA(var, (__val | (val)));                                  \
                    138:     } while (0)
                    139: 
                    140: 
                    141: /****************************************************************
                    142:  * Extended Bios Data Area (EBDA)
                    143:  ****************************************************************/
                    144: 
                    145: // DPTE definition
                    146: struct dpte_s {
                    147:     u16 iobase1;
                    148:     u16 iobase2;
                    149:     u8  prefix;
                    150:     u8  unused;
                    151:     u8  irq;
                    152:     u8  blkcount;
                    153:     u8  dma;
                    154:     u8  pio;
                    155:     u16 options;
                    156:     u16 reserved;
                    157:     u8  revision;
                    158:     u8  checksum;
                    159: };
                    160: 
                    161: // ElTorito Device Emulation data
                    162: struct cdemu_s {
1.1.1.3 ! root      163:     struct drive_s *emulated_drive_gf;
1.1       root      164:     u32 ilba;
                    165:     u16 buffer_segment;
                    166:     u16 load_segment;
                    167:     u16 sector_count;
                    168:     u8  active;
                    169:     u8  media;
                    170:     u8  emulated_extdrive;
                    171: 
                    172:     // Virtual device
                    173:     struct chs_s lchs;
                    174: };
                    175: 
                    176: struct fdpt_s {
                    177:     u16 cylinders;
                    178:     u8 heads;
                    179:     u8 a0h_signature;
                    180:     u8 phys_sectors;
                    181:     u16 precompensation;
                    182:     u8 reserved;
                    183:     u8 drive_control_byte;
                    184:     u16 phys_cylinders;
                    185:     u8 phys_heads;
                    186:     u16 landing_zone;
                    187:     u8 sectors;
                    188:     u8 checksum;
                    189: } PACKED;
                    190: 
1.1.1.3 ! root      191: struct usbkeyinfo {
        !           192:     union {
        !           193:         struct {
        !           194:             u8 modifiers;
        !           195:             u8 repeatcount;
        !           196:             u8 keys[6];
        !           197:         };
        !           198:         u64 data;
        !           199:     };
        !           200: };
        !           201: 
1.1       root      202: struct extended_bios_data_area_s {
                    203:     u8 size;
                    204:     u8 reserved1[0x21];
                    205:     struct segoff_s far_call_pointer;
                    206:     u8 mouse_flag1;
                    207:     u8 mouse_flag2;
                    208:     u8 mouse_data[0x08];
                    209:     // 0x30
                    210:     u8 other1[0x0d];
                    211: 
                    212:     // 0x3d
                    213:     struct fdpt_s fdpt[2];
                    214: 
                    215:     // 0x5d
                    216:     u8 other2[0xC4];
                    217: 
                    218:     // 0x121 - Begin custom storage.
                    219:     u8 ps2ctr;
1.1.1.3 ! root      220:     struct usbkeyinfo usbkey_last;
        !           221: 
1.1       root      222:     int RTCusers;
                    223: 
                    224:     // El Torito Emulation data
                    225:     struct cdemu_s cdemu;
                    226: 
                    227:     // Buffer for disk DPTE table
                    228:     struct dpte_s dpte;
                    229: 
                    230:     // Locks for removable devices
                    231:     u8 cdrom_locks[CONFIG_MAX_EXTDRIVE];
                    232: 
                    233:     u16 boot_sequence;
                    234: 
                    235:     // Stack space available for code that needs it.
                    236:     u8 extra_stack[512] __aligned(8);
                    237: } PACKED;
                    238: 
                    239: // The initial size and location of EBDA
                    240: #define EBDA_SIZE_START \
                    241:     DIV_ROUND_UP(sizeof(struct extended_bios_data_area_s), 1024)
                    242: #define EBDA_SEGMENT_START \
                    243:     FLATPTR_TO_SEG(BUILD_LOWRAM_END - EBDA_SIZE_START*1024)
                    244: 
                    245: // Accessor functions
1.1.1.2   root      246: static inline u16 get_ebda_seg(void) {
1.1       root      247:     return GET_BDA(ebda_seg);
                    248: }
                    249: static inline struct extended_bios_data_area_s *
1.1.1.2   root      250: get_ebda_ptr(void)
1.1       root      251: {
1.1.1.2   root      252:     ASSERT32FLAT();
1.1       root      253:     return MAKE_FLATPTR(get_ebda_seg(), 0);
                    254: }
                    255: #define GET_EBDA2(eseg, var)                                            \
                    256:     GET_FARVAR(eseg, ((struct extended_bios_data_area_s *)0)->var)
                    257: #define SET_EBDA2(eseg, var, val)                                       \
                    258:     SET_FARVAR(eseg, ((struct extended_bios_data_area_s *)0)->var, (val))
                    259: #define GET_EBDA(var)                           \
                    260:     GET_EBDA2(get_ebda_seg(), var)
                    261: #define SET_EBDA(var, val)                      \
                    262:     SET_EBDA2(get_ebda_seg(), var, (val))
                    263: 
                    264: #define EBDA_OFFSET_TOP_STACK                                   \
                    265:     offsetof(struct extended_bios_data_area_s, extra_stack[     \
                    266:                  FIELD_SIZEOF(struct extended_bios_data_area_s  \
                    267:                               , extra_stack)])
                    268: 
                    269: 
                    270: /****************************************************************
                    271:  * Global variables
                    272:  ****************************************************************/
                    273: 
1.1.1.2   root      274: #if MODE16 == 0 && MODESEGMENT == 1
                    275: // In 32bit segmented mode %cs may not be readable and the code may be
                    276: // relocated.  The entry code sets up %gs with a readable segment and
                    277: // the code offset can be determined by get_global_offset().
                    278: #define GLOBAL_SEGREG GS
                    279: static inline u32 __attribute_const get_global_offset(void) {
                    280:     u32 ret;
                    281:     asm("  calll 1f\n"
                    282:         "1:popl %0\n"
                    283:         "  subl $1b, %0"
                    284:         : "=r"(ret));
                    285:     return ret;
                    286: }
                    287: #else
1.1       root      288: #define GLOBAL_SEGREG CS
1.1.1.2   root      289: static inline u32 __attribute_const get_global_offset(void) {
                    290:     return 0;
                    291: }
                    292: #endif
                    293: static inline u16 get_global_seg(void) {
1.1       root      294:     return GET_SEG(GLOBAL_SEGREG);
                    295: }
1.1.1.2   root      296: #define GET_GLOBAL(var)                                                 \
                    297:     GET_VAR(GLOBAL_SEGREG, *(typeof(&(var)))((void*)&(var)              \
                    298:                                              + get_global_offset()))
1.1       root      299: #define SET_GLOBAL(var, val) do {               \
1.1.1.2   root      300:         ASSERT32FLAT();                         \
1.1       root      301:         (var) = (val);                          \
                    302:     } while (0)
1.1.1.2   root      303: #if MODESEGMENT
1.1.1.3 ! root      304: #define GLOBALFLAT2GLOBAL(var) ((typeof(var))((void*)(var) - BUILD_BIOS_ADDR))
1.1       root      305: #else
1.1.1.3 ! root      306: #define GLOBALFLAT2GLOBAL(var) (var)
1.1       root      307: #endif
1.1.1.3 ! root      308: // Access a "flat" pointer known to point to the f-segment.
        !           309: #define GET_GLOBALFLAT(var) GET_GLOBAL(*GLOBALFLAT2GLOBAL(&(var)))
1.1       root      310: 
                    311: 
                    312: /****************************************************************
                    313:  * Bios Config Table
                    314:  ****************************************************************/
                    315: 
                    316: struct bios_config_table_s {
                    317:     u16 size;
                    318:     u8 model;
                    319:     u8 submodel;
                    320:     u8 biosrev;
                    321:     u8 feature1, feature2, feature3, feature4, feature5;
                    322: } PACKED;
                    323: 
                    324: extern struct bios_config_table_s BIOS_CONFIG_TABLE __aligned(1);
                    325: 
                    326: #endif // __BIOSVAR_H

unix.superglobalmegacorp.com

This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.