Don't set the device details when changing modes, and don't set mode details outside of mode setting.
Signed-off-by: Kevin O'Connor kevin@koconnor.net --- vgasrc/vgabios.c | 9 --------- vgasrc/vgainit.c | 19 ++++++++----------- 2 files changed, 8 insertions(+), 20 deletions(-)
diff --git a/vgasrc/vgabios.c b/vgasrc/vgabios.c index 5fdb549..e2a4efc 100644 --- a/vgasrc/vgabios.c +++ b/vgasrc/vgabios.c @@ -326,15 +326,6 @@ vga_set_mode(int mode, int flags) SET_BDA(video_pagestart, 0x0000); SET_BDA(video_page, 0x00);
- // FIXME We nearly have the good tables. to be reworked - SET_BDA(dcc_index, 0x08); // 8 is VGA should be ok for now - SET_BDA(video_savetable - , SEGOFF(get_global_seg(), (u32)&video_save_pointer_table)); - - // FIXME - SET_BDA(video_msr, 0x00); // Unavailable on vanilla vga, but... - SET_BDA(video_pal, 0x00); // Unavailable on vanilla vga, but... - // Set the ints 0x1F and 0x43 SET_IVT(0x1f, SEGOFF(get_global_seg(), (u32)&vgafont8[128 * 8]));
diff --git a/vgasrc/vgainit.c b/vgasrc/vgainit.c index 5c76c5b..c323cf8 100644 --- a/vgasrc/vgainit.c +++ b/vgasrc/vgainit.c @@ -140,20 +140,17 @@ init_bios_area(void) // set 80x25 color (not clear from RBIL but usual) set_equipment_flags(0x30, 0x20);
- // the default char height - SET_BDA(char_height, 0x10); - - // Clear the screen - SET_BDA(video_ctl, 0x60); - - // Set the basic screen we have - SET_BDA(video_switches, 0xf9); - // Set the basic modeset options SET_BDA(modeset_ctl, 0x51);
- // Set the default MSR - SET_BDA(video_msr, 0x09); + // FIXME We nearly have the good tables. to be reworked + SET_BDA(dcc_index, 0x08); // 8 is VGA should be ok for now + SET_BDA(video_savetable + , SEGOFF(get_global_seg(), (u32)&video_save_pointer_table)); + + // FIXME + SET_BDA(video_msr, 0x00); // Unavailable on vanilla vga, but... + SET_BDA(video_pal, 0x00); // Unavailable on vanilla vga, but... }
int VgaBDF VAR16 = -1;
Signed-off-by: Kevin O'Connor kevin@koconnor.net --- vgasrc/vgainit.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)
diff --git a/vgasrc/vgainit.c b/vgasrc/vgainit.c index c323cf8..e14664b 100644 --- a/vgasrc/vgainit.c +++ b/vgasrc/vgainit.c @@ -143,8 +143,7 @@ init_bios_area(void) // Set the basic modeset options SET_BDA(modeset_ctl, 0x51);
- // FIXME We nearly have the good tables. to be reworked - SET_BDA(dcc_index, 0x08); // 8 is VGA should be ok for now + SET_BDA(dcc_index, CONFIG_VGA_STDVGA_PORTS ? 0x08 : 0xff); SET_BDA(video_savetable , SEGOFF(get_global_seg(), (u32)&video_save_pointer_table));
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;
Instead of hard coding the list of modes, fill them in from the list of supported modes.
Signed-off-by: Kevin O'Connor kevin@koconnor.net --- vgasrc/stdvgamodes.c | 9 +++++++++ vgasrc/vgabios.c | 4 ++-- vgasrc/vgabios.h | 1 + 3 files changed, 12 insertions(+), 2 deletions(-)
diff --git a/vgasrc/stdvgamodes.c b/vgasrc/stdvgamodes.c index 53b7463..c553514 100644 --- a/vgasrc/stdvgamodes.c +++ b/vgasrc/stdvgamodes.c @@ -397,6 +397,15 @@ stdvga_build_video_param(void) , get_global_seg(), GET_GLOBAL(stdmode_g->grdc_regs) , ARRAY_SIZE(vparam_g->grdc_regs)); } + + // Fill available legacy modes in video_func_static table + u32 modes = 0; + for (i = 0; i < ARRAY_SIZE(vga_modes); i++) { + u16 mode = vga_modes[i].mode; + if (mode <= 0x13) + modes |= 1<<i; + } + SET_VGA(static_functionality.modes, modes); }
void diff --git a/vgasrc/vgabios.c b/vgasrc/vgabios.c index 449a615..84c772d 100644 --- a/vgasrc/vgabios.c +++ b/vgasrc/vgabios.c @@ -1083,8 +1083,8 @@ handle_101a(struct bregs *regs) }
-static struct video_func_static static_functionality VAR16 = { - .modes = 0x0fe0ff, +struct video_func_static static_functionality VAR16 = { + .modes = 0x00, // Filled in by stdvga_build_video_param() .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 diff --git a/vgasrc/vgabios.h b/vgasrc/vgabios.h index fc1eba6..77782e6 100644 --- a/vgasrc/vgabios.h +++ b/vgasrc/vgabios.h @@ -110,6 +110,7 @@ struct cursorpos get_cursor_pos(u8 page); int bda_save_restore(int cmd, u16 seg, void *data); struct vgamode_s *get_current_mode(void); int vga_set_mode(int mode, int flags); +extern struct video_func_static static_functionality;
// vgafb.c void init_gfx_op(struct gfx_op *op, struct vgamode_s *vmode_g);
On Thu, Oct 23, 2014 at 04:45:09PM -0400, Kevin O'Connor wrote:
Don't set the device details when changing modes, and don't set mode details outside of mode setting.
FYI, I have pushed all the vgabios cleanup patches to master. I have, however, left two patches out (Support emulating text mode attributes while in graphics mode, and Add software cursor capability). I want to give more thought to these two patches. They remain available at: https://github.com/KevinOConnor/seabios/tree/testing
-Kevin