Add option CONFIG_VGA_STDVGA_PORTS. When this option is disabled, the main BIOS code will not attempt to access any of the legacy VGA IO ports.
Signed-off-by: Kevin O'Connor kevin@koconnor.net --- vgasrc/Kconfig | 8 ++++++++ vgasrc/vgabios.c | 44 ++++++++++++++++++++++++++++++++------------ vgasrc/vgafb.c | 8 ++++++++ vgasrc/vgainit.c | 3 ++- 4 files changed, 50 insertions(+), 13 deletions(-)
diff --git a/vgasrc/Kconfig b/vgasrc/Kconfig index b442b3e..f04fca7 100644 --- a/vgasrc/Kconfig +++ b/vgasrc/Kconfig @@ -13,6 +13,7 @@ menu "VGA ROM" config VGA_STANDARD_VGA depends on QEMU bool "QEMU/Bochs Original IBM 256K VGA" + select VGA_STDVGA_PORTS help Build basic VGA BIOS support (pre Super-VGA) for use on emulators. @@ -20,6 +21,7 @@ menu "VGA ROM" config VGA_CIRRUS depends on QEMU bool "QEMU/Bochs Cirrus SVGA" + select VGA_STDVGA_PORTS help Build support for Cirrus VGA emulation found on QEMU and Bochs emulators. This is for emulators; it is not @@ -28,17 +30,20 @@ menu "VGA ROM" config VGA_BOCHS depends on QEMU bool "QEMU/Bochs VBE SVGA" + select VGA_STDVGA_PORTS help Build support for Bochs DISPI interface (a custom VBE protocol) found on QEMU and Bochs emulators.
config VGA_GEODEGX2 bool "GeodeGX2" + select VGA_STDVGA_PORTS help Build support for Geode GX2 vga.
config VGA_GEODELX bool "GeodeLX" + select VGA_STDVGA_PORTS help Build support for Geode LX vga. endchoice @@ -68,6 +73,9 @@ menu "VGA ROM" bool default !NO_VGABIOS
+ config VGA_STDVGA_PORTS + bool + config VGA_ALLOCATE_EXTRA_STACK depends on BUILD_VGABIOS bool "Allocate an internal stack for 16bit interrupt entry point" diff --git a/vgasrc/vgabios.c b/vgasrc/vgabios.c index 44502b3..040a7ae 100644 --- a/vgasrc/vgabios.c +++ b/vgasrc/vgabios.c @@ -59,6 +59,9 @@ set_cursor_shape(u8 start, u8 end) u16 curs = (start << 8) + end; SET_BDA(cursor_type, curs);
+ if (!CONFIG_VGA_STDVGA_PORTS) + return; + u8 modeset_ctl = GET_BDA(modeset_ctl); u16 cheight = GET_BDA(char_height); if ((modeset_ctl & 0x01) && (cheight > 8) && (end < 8) && (start < 0x20)) { @@ -92,6 +95,9 @@ set_cursor_pos(struct cursorpos cp) // Bios cursor pos SET_BDA(cursor_pos[page], (y << 8) | x);
+ if (!CONFIG_VGA_STDVGA_PORTS) + return; + // Set the hardware cursor u8 current = GET_BDA(video_page); if (cp.page != current) @@ -300,7 +306,7 @@ vga_set_mode(int mode, int flags) SET_BDA(cursor_type, 0x0000); } SET_BDA(video_pagesize, calc_page_size(memmodel, width, height)); - SET_BDA(crtc_address, stdvga_get_crtc()); + SET_BDA(crtc_address, CONFIG_VGA_STDVGA_PORTS ? stdvga_get_crtc() : 0); SET_BDA(char_height, cheight); SET_BDA(video_ctl, 0x60 | (flags & MF_NOCLEARMEM ? 0x80 : 0x00)); SET_BDA(video_switches, 0xF9); @@ -485,6 +491,10 @@ handle_100bXX(struct bregs *regs) static void handle_100b(struct bregs *regs) { + if (!CONFIG_VGA_STDVGA_PORTS) { + handle_100bXX(regs); + return; + } switch (regs->bh) { case 0x00: handle_100b00(regs); break; case 0x01: handle_100b01(regs); break; @@ -641,6 +651,10 @@ handle_1010XX(struct bregs *regs) static void handle_1010(struct bregs *regs) { + if (!CONFIG_VGA_STDVGA_PORTS) { + handle_1010XX(regs); + return; + } switch (regs->al) { case 0x00: handle_101000(regs); break; case 0x01: handle_101001(regs); break; @@ -838,16 +852,20 @@ handle_1011XX(struct bregs *regs) static void handle_1011(struct bregs *regs) { + if (CONFIG_VGA_STDVGA_PORTS) { + switch (regs->al) { + case 0x00: handle_101100(regs); break; + case 0x01: handle_101101(regs); break; + case 0x02: handle_101102(regs); break; + case 0x03: handle_101103(regs); break; + case 0x04: handle_101104(regs); break; + case 0x10: handle_101110(regs); break; + case 0x11: handle_101111(regs); break; + case 0x12: handle_101112(regs); break; + case 0x14: handle_101114(regs); break; + } + } switch (regs->al) { - case 0x00: handle_101100(regs); break; - case 0x01: handle_101101(regs); break; - case 0x02: handle_101102(regs); break; - case 0x03: handle_101103(regs); break; - case 0x04: handle_101104(regs); break; - case 0x10: handle_101110(regs); break; - case 0x11: handle_101111(regs); break; - case 0x12: handle_101112(regs); break; - case 0x14: handle_101114(regs); break; case 0x30: handle_101130(regs); break; case 0x20: handle_101120(regs); break; case 0x21: handle_101121(regs); break; @@ -912,8 +930,10 @@ handle_101231(struct bregs *regs) static void handle_101232(struct bregs *regs) { - stdvga_enable_video_addressing(regs->al); - regs->al = 0x12; + if (CONFIG_VGA_STDVGA_PORTS) { + stdvga_enable_video_addressing(regs->al); + regs->al = 0x12; + } }
static void diff --git a/vgasrc/vgafb.c b/vgasrc/vgafb.c index 2efaab5..7c2570f 100644 --- a/vgasrc/vgafb.c +++ b/vgasrc/vgafb.c @@ -43,6 +43,8 @@ static void scroll_pl4(struct vgamode_s *vmode_g, int nblines, int attr , struct cursorpos ul, struct cursorpos lr) { + if (!CONFIG_VGA_STDVGA_PORTS) + return; int cheight = GET_BDA(char_height); int cwidth = 1; int stride = GET_BDA(video_cols) * cwidth; @@ -225,6 +227,8 @@ static void write_gfx_char_pl4(struct vgamode_s *vmode_g , struct cursorpos cp, struct carattr ca) { + if (!CONFIG_VGA_STDVGA_PORTS) + return; u16 nbcols = GET_BDA(video_cols); if (cp.x >= nbcols) return; @@ -407,6 +411,8 @@ vgafb_write_pixel(u8 color, u16 x, u16 y) u8 *addr_far, mask, attr, data, i; switch (GET_GLOBAL(vmode_g->memmodel)) { case MM_PLANAR: + if (!CONFIG_VGA_STDVGA_PORTS) + return; addr_far = (void*)(x / 8 + y * GET_BDA(video_cols)); mask = 0x80 >> (x & 0x07); for (i=0; i<4; i++) { @@ -464,6 +470,8 @@ vgafb_read_pixel(u16 x, u16 y) u8 *addr_far, mask, attr=0, data, i; switch (GET_GLOBAL(vmode_g->memmodel)) { case MM_PLANAR: + if (!CONFIG_VGA_STDVGA_PORTS) + return 0; addr_far = (void*)(x / 8 + y * GET_BDA(video_cols)); mask = 0x80 >> (x & 0x07); attr = 0x00; diff --git a/vgasrc/vgainit.c b/vgasrc/vgainit.c index 4692c34..33b8eb9 100644 --- a/vgasrc/vgainit.c +++ b/vgasrc/vgainit.c @@ -153,7 +153,8 @@ vga_post(struct bregs *regs)
SET_VGA(video_save_pointer_table.videoparam , SEGOFF(get_global_seg(), (u32)video_param_table)); - stdvga_build_video_param(); + if (CONFIG_VGA_STDVGA_PORTS) + stdvga_build_video_param();
extern void entry_10(void); SET_IVT(0x10, SEGOFF(get_global_seg(), (u32)entry_10));