[SeaBIOS] [PATCH 1/4] vgabios: Add option to control use of standard VGA IO ports and ranges.

Kevin O'Connor kevin at koconnor.net
Wed Feb 12 18:31:22 CET 2014


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.

Add option CONFIG_VGA_STDVGA_FRAMEBUFFER.  When this option is
disabled, the code to read/write to the 0xA0000-0xC0000 is not
included in the vgabios.

Signed-off-by: Kevin O'Connor <kevin at koconnor.net>
---
 vgasrc/Kconfig   | 15 +++++++++++++++
 vgasrc/vgabios.c | 44 ++++++++++++++++++++++++++++++++------------
 vgasrc/vgafb.c   | 26 ++++++++++++++++++++++++++
 vgasrc/vgainit.c |  3 ++-
 4 files changed, 75 insertions(+), 13 deletions(-)

diff --git a/vgasrc/Kconfig b/vgasrc/Kconfig
index b442b3e..a058a86 100644
--- a/vgasrc/Kconfig
+++ b/vgasrc/Kconfig
@@ -13,6 +13,8 @@ menu "VGA ROM"
         config VGA_STANDARD_VGA
             depends on QEMU
             bool "QEMU/Bochs Original IBM 256K VGA"
+            select VGA_STDVGA_PORTS
+            select VGA_STDVGA_FRAMEBUFFER
             help
                 Build basic VGA BIOS support (pre Super-VGA) for use
                 on emulators.
@@ -20,6 +22,8 @@ menu "VGA ROM"
         config VGA_CIRRUS
             depends on QEMU
             bool "QEMU/Bochs Cirrus SVGA"
+            select VGA_STDVGA_PORTS
+            select VGA_STDVGA_FRAMEBUFFER
             help
                 Build support for Cirrus VGA emulation found on QEMU
                 and Bochs emulators.  This is for emulators; it is not
@@ -28,17 +32,23 @@ menu "VGA ROM"
         config VGA_BOCHS
             depends on QEMU
             bool "QEMU/Bochs VBE SVGA"
+            select VGA_STDVGA_PORTS
+            select VGA_STDVGA_FRAMEBUFFER
             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
+            select VGA_STDVGA_FRAMEBUFFER
             help
                 Build support for Geode GX2 vga.
 
         config VGA_GEODELX
             bool "GeodeLX"
+            select VGA_STDVGA_PORTS
+            select VGA_STDVGA_FRAMEBUFFER
             help
                 Build support for Geode LX vga.
     endchoice
@@ -68,6 +78,11 @@ menu "VGA ROM"
         bool
         default !NO_VGABIOS
 
+    config VGA_STDVGA_PORTS
+        bool
+    config VGA_STDVGA_FRAMEBUFFER
+        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..a31db46 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_FRAMEBUFFER || !CONFIG_VGA_STDVGA_PORTS)
+        return;
     int cheight = GET_BDA(char_height);
     int cwidth = 1;
     int stride = GET_BDA(video_cols) * cwidth;
@@ -79,6 +81,8 @@ static void
 scroll_cga(struct vgamode_s *vmode_g, int nblines, int attr
             , struct cursorpos ul, struct cursorpos lr)
 {
+    if (!CONFIG_VGA_STDVGA_FRAMEBUFFER)
+        return;
     int cheight = GET_BDA(char_height) / 2;
     int cwidth = GET_GLOBAL(vmode_g->depth);
     int stride = GET_BDA(video_cols) * cwidth;
@@ -117,6 +121,8 @@ static void
 scroll_lin(struct vgamode_s *vmode_g, int nblines, int attr
            , struct cursorpos ul, struct cursorpos lr)
 {
+    if (!CONFIG_VGA_STDVGA_FRAMEBUFFER)
+        return;
     int cheight = GET_BDA(char_height);
     int cwidth = 8;
     int stride = GET_BDA(video_cols) * cwidth;
@@ -146,6 +152,8 @@ static void
 scroll_text(struct vgamode_s *vmode_g, int nblines, int attr
             , struct cursorpos ul, struct cursorpos lr)
 {
+    if (!CONFIG_VGA_STDVGA_FRAMEBUFFER)
+        return;
     int cheight = 1;
     int cwidth = 2;
     int stride = GET_BDA(video_cols) * cwidth;
@@ -225,6 +233,8 @@ static void
 write_gfx_char_pl4(struct vgamode_s *vmode_g
                    , struct cursorpos cp, struct carattr ca)
 {
+    if (!CONFIG_VGA_STDVGA_FRAMEBUFFER || !CONFIG_VGA_STDVGA_PORTS)
+        return;
     u16 nbcols = GET_BDA(video_cols);
     if (cp.x >= nbcols)
         return;
@@ -255,6 +265,8 @@ static void
 write_gfx_char_cga(struct vgamode_s *vmode_g
                    , struct cursorpos cp, struct carattr ca)
 {
+    if (!CONFIG_VGA_STDVGA_FRAMEBUFFER)
+        return;
     u16 nbcols = GET_BDA(video_cols);
     if (cp.x >= nbcols)
         return;
@@ -295,6 +307,8 @@ static void
 write_gfx_char_lin(struct vgamode_s *vmode_g
                    , struct cursorpos cp, struct carattr ca)
 {
+    if (!CONFIG_VGA_STDVGA_FRAMEBUFFER)
+        return;
     // Get the dimensions
     u16 nbcols = GET_BDA(video_cols);
     if (cp.x >= nbcols)
@@ -321,6 +335,8 @@ static void
 write_text_char(struct vgamode_s *vmode_g
                 , struct cursorpos cp, struct carattr ca)
 {
+    if (!CONFIG_VGA_STDVGA_FRAMEBUFFER)
+        return;
     int cheight = 1;
     int cwidth = 2;
     int stride = GET_BDA(video_cols) * cwidth;
@@ -365,6 +381,8 @@ vgafb_write_char(struct cursorpos cp, struct carattr ca)
 struct carattr
 vgafb_read_char(struct cursorpos cp)
 {
+    if (!CONFIG_VGA_STDVGA_FRAMEBUFFER)
+        goto fail;
     // Get the mode
     struct vgamode_s *vmode_g = get_current_mode();
     if (!vmode_g)
@@ -399,6 +417,8 @@ fail: ;
 void
 vgafb_write_pixel(u8 color, u16 x, u16 y)
 {
+    if (!CONFIG_VGA_STDVGA_FRAMEBUFFER)
+        return;
     // Get the mode
     struct vgamode_s *vmode_g = get_current_mode();
     if (!vmode_g)
@@ -407,6 +427,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++) {
@@ -456,6 +478,8 @@ vgafb_write_pixel(u8 color, u16 x, u16 y)
 u8
 vgafb_read_pixel(u16 x, u16 y)
 {
+    if (!CONFIG_VGA_STDVGA_FRAMEBUFFER)
+        return 0;
     // Get the mode
     struct vgamode_s *vmode_g = get_current_mode();
     if (!vmode_g)
@@ -464,6 +488,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 13221fd..87bc75c 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));
-- 
1.8.5.3




More information about the SeaBIOS mailing list