Move the standard video bios definitions into a new header file. Also, define a struct with the layout for the static functionality table.
Signed-off-by: Kevin O'Connor kevin@koconnor.net --- src/std/vga.h | 63 ++++++++++++++++++++++++++++++++++++++++++++++++++++ vgasrc/stdvgamodes.c | 4 ++-- vgasrc/vgabios.c | 44 +++++++----------------------------- vgasrc/vgabios.h | 19 +++------------- vgasrc/vgainit.c | 16 +++---------- 5 files changed, 79 insertions(+), 67 deletions(-) create mode 100644 src/std/vga.h
diff --git a/src/std/vga.h b/src/std/vga.h new file mode 100644 index 0000000..de9ec75 --- /dev/null +++ b/src/std/vga.h @@ -0,0 +1,63 @@ +#ifndef __VGA_H +#define __VGA_H +// Standard structure definitions for vgabios video tables + +#include "types.h" // u8 + +// standard BIOS Video Parameter Table +struct video_param_s { + u8 twidth; + u8 theightm1; + u8 cheight; + u16 slength; + u8 sequ_regs[4]; + u8 miscreg; + u8 crtc_regs[25]; + u8 actl_regs[20]; + u8 grdc_regs[9]; +} PACKED; + +// Standard Video Save Pointer Table +struct video_save_pointer_s { + struct segoff_s videoparam; + struct segoff_s paramdynamicsave; + struct segoff_s textcharset; + struct segoff_s graphcharset; + struct segoff_s secsavepointer; + u8 reserved[8]; +} PACKED; + +// Data returned by int101B +struct video_func_static { + u32 modes; + u8 reserved_0x04[3]; + u8 scanlines; + u8 cblocks; + u8 active_cblocks; + u16 misc_flags; + u8 reserved_0x0c[2]; + u8 save_flags; + u8 reserved_0x0f; +} PACKED; + +struct video_func_info { + struct segoff_s static_functionality; + u8 bda_0x49[30]; + u8 bda_0x84[3]; + u8 dcc_index; + u8 dcc_alt; + u16 colors; + u8 pages; + u8 scan_lines; + u8 primary_char; + u8 secondar_char; + u8 misc; + u8 non_vga_mode; + u8 reserved_2f[2]; + u8 video_mem; + u8 save_flags; + u8 disp_info; + u8 reserved_34[12]; +} PACKED; + +#endif // vga.h diff --git a/vgasrc/stdvgamodes.c b/vgasrc/stdvgamodes.c index 8436729..53b7463 100644 --- a/vgasrc/stdvgamodes.c +++ b/vgasrc/stdvgamodes.c @@ -9,7 +9,7 @@ #include "output.h" // warn_internalerror #include "stdvga.h" // stdvga_find_mode #include "string.h" // memcpy_far -#include "vgabios.h" // struct VideoParamTableEntry_s +#include "vgabios.h" // video_param_table
/**************************************************************** @@ -363,7 +363,7 @@ stdvga_build_video_param(void) int mode = GET_GLOBAL(parammodes[i]); if (! mode) continue; - struct VideoParam_s *vparam_g = &video_param_table[i]; + struct video_param_s *vparam_g = &video_param_table[i]; struct vgamode_s *vmode_g = stdvga_find_mode(mode); if (!vmode_g) continue; diff --git a/vgasrc/vgabios.c b/vgasrc/vgabios.c index e2a4efc..449a615 100644 --- a/vgasrc/vgabios.c +++ b/vgasrc/vgabios.c @@ -1083,51 +1083,23 @@ handle_101a(struct bregs *regs) }
-static u8 static_functionality[0x10] VAR16 = { - /* 0 */ 0xff, // All modes supported #1 - /* 1 */ 0xe0, // All modes supported #2 - /* 2 */ 0x0f, // All modes supported #3 - /* 3 */ 0x00, 0x00, 0x00, 0x00, // reserved - /* 7 */ 0x07, // 200, 350, 400 scan lines - /* 8 */ 0x02, // mamimum number of visible charsets in text mode - /* 9 */ 0x08, // total number of charset blocks in text mode - /* a */ 0xe7, // Change to add new functions - /* b */ 0x0c, // Change to add new functions - /* c */ 0x00, // reserved - /* d */ 0x00, // reserved - /* e */ 0x00, // Change to add new functions - /* f */ 0x00 // reserved +static struct video_func_static static_functionality VAR16 = { + .modes = 0x0fe0ff, + .scanlines = 0x07, // 200, 350, 400 scan lines + .cblocks = 0x02, // mamimum number of visible charsets in text mode + .active_cblocks = 0x08, // total number of charset blocks in text mode + .misc_flags = 0x0ce7, };
-struct funcInfo { - struct segoff_s static_functionality; - u8 bda_0x49[30]; - u8 bda_0x84[3]; - u8 dcc_index; - u8 dcc_alt; - u16 colors; - u8 pages; - u8 scan_lines; - u8 primary_char; - u8 secondar_char; - u8 misc; - u8 non_vga_mode; - u8 reserved_2f[2]; - u8 video_mem; - u8 save_flags; - u8 disp_info; - u8 reserved_34[12]; -} PACKED; - static void handle_101b(struct bregs *regs) { u16 seg = regs->es; - struct funcInfo *info = (void*)(regs->di+0); + struct video_func_info *info = (void*)(regs->di+0); memset_far(seg, info, 0, sizeof(*info)); // Address of static functionality table SET_FARVAR(seg, info->static_functionality - , SEGOFF(get_global_seg(), (u32)static_functionality)); + , SEGOFF(get_global_seg(), (u32)&static_functionality));
// Hard coded copy from BIOS area. Should it be cleaner ? memcpy_far(seg, info->bda_0x49, SEG_BDA, (void*)0x49 diff --git a/vgasrc/vgabios.h b/vgasrc/vgabios.h index 98dc3cd..fc1eba6 100644 --- a/vgasrc/vgabios.h +++ b/vgasrc/vgabios.h @@ -3,21 +3,7 @@
#include "types.h" // u8 #include "farptr.h" // struct segoff_s - -// standard BIOS Video Parameter Table -struct VideoParam_s { - u8 twidth; - u8 theightm1; - u8 cheight; - u16 slength; - u8 sequ_regs[4]; - u8 miscreg; - u8 crtc_regs[25]; - u8 actl_regs[20]; - u8 grdc_regs[9]; -} PACKED; - -extern struct VideoParam_s video_param_table[29]; +#include "std/vga.h" // struct video_param_s
// Save/Restore flags #define SR_HARDWARE 0x0001 @@ -104,7 +90,8 @@ extern u8 vgafont14alt[]; extern u8 vgafont16alt[];
// vgainit.c -extern struct VideoSavePointer_s video_save_pointer_table; +extern struct video_save_pointer_s video_save_pointer_table; +extern struct video_param_s video_param_table[29];
// vgabios.c extern int VgaBDF; diff --git a/vgasrc/vgainit.c b/vgasrc/vgainit.c index e14664b..9153e31 100644 --- a/vgasrc/vgainit.c +++ b/vgasrc/vgainit.c @@ -15,22 +15,12 @@ #include "std/pmm.h" // struct pmmheader #include "string.h" // checksum_far #include "util.h" // VERSION -#include "vgabios.h" // struct VideoSavePointer_s +#include "vgabios.h" // video_save_pointer_table #include "vgahw.h" // vgahw_setup
-// Standard Video Save Pointer Table -struct VideoSavePointer_s { - struct segoff_s videoparam; - struct segoff_s paramdynamicsave; - struct segoff_s textcharset; - struct segoff_s graphcharset; - struct segoff_s secsavepointer; - u8 reserved[8]; -} PACKED; +struct video_save_pointer_s video_save_pointer_table VAR16;
-struct VideoSavePointer_s video_save_pointer_table VAR16; - -struct VideoParam_s video_param_table[29] VAR16; +struct video_param_s video_param_table[29] VAR16;
// Type of emulator platform - for dprintf with certain compile options. int PlatformRunningOn VAR16;