[SeaBIOS] [PATCH 3/6] vgabios: Handle VGA option rom being re-run.

Kevin O'Connor kevin at koconnor.net
Sat Feb 4 18:50:46 CET 2012


Check for the case where the option rom is executed a second time - in
that case re-init the hardware, but do not set any variables.  This
should make the rom better behaving when run from S3 resume.

Signed-off-by: Kevin O'Connor <kevin at koconnor.net>
---
 vgasrc/bochsvga.c |    3 +++
 vgasrc/clext.c    |   19 +++++++++++--------
 vgasrc/vgabios.c  |    8 +++++++-
 vgasrc/vgabios.h  |    1 +
 4 files changed, 22 insertions(+), 9 deletions(-)

diff --git a/vgasrc/bochsvga.c b/vgasrc/bochsvga.c
index e6ab794..9210004 100644
--- a/vgasrc/bochsvga.c
+++ b/vgasrc/bochsvga.c
@@ -258,6 +258,9 @@ bochsvga_init(void)
 
     dispi_write(VBE_DISPI_INDEX_ID, VBE_DISPI_ID5);
 
+    if (GET_GLOBAL(HaveRunInit))
+        return 0;
+
     u32 lfb_addr = VBE_DISPI_LFB_PHYSICAL_ADDRESS;
     int bdf = GET_GLOBAL(VgaBDF);
     if (CONFIG_VGA_PCI && bdf >= 0) {
diff --git a/vgasrc/clext.c b/vgasrc/clext.c
index 26b34e0..0470d80 100644
--- a/vgasrc/clext.c
+++ b/vgasrc/clext.c
@@ -590,6 +590,17 @@ clext_init(void)
         return -1;
     dprintf(1, "cirrus init 2\n");
 
+    // memory setup
+    stdvga_sequ_write(0x0a, stdvga_sequ_read(0x0f) & 0x18);
+    // set vga mode
+    stdvga_sequ_write(0x07, 0x00);
+    // reset bitblt
+    stdvga_grdc_write(0x31, 0x04);
+    stdvga_grdc_write(0x31, 0x00);
+
+    if (GET_GLOBAL(HaveRunInit))
+        return 0;
+
     u32 lfb_addr = 0;
     int bdf = GET_GLOBAL(VgaBDF);
     if (CONFIG_VGA_PCI && bdf >= 0)
@@ -600,13 +611,5 @@ clext_init(void)
     SET_VGA(VBE_total_memory, totalmem * 64 * 1024);
     SET_VGA(VBE_win_granularity, 16);
 
-    // memory setup
-    stdvga_sequ_write(0x0a, stdvga_sequ_read(0x0f) & 0x18);
-    // set vga mode
-    stdvga_sequ_write(0x07, 0x00);
-    // reset bitblt
-    stdvga_grdc_write(0x31, 0x04);
-    stdvga_grdc_write(0x31, 0x00);
-
     return 0;
 }
diff --git a/vgasrc/vgabios.c b/vgasrc/vgabios.c
index e69c6c5..ec251fe 100644
--- a/vgasrc/vgabios.c
+++ b/vgasrc/vgabios.c
@@ -1271,13 +1271,14 @@ init_bios_area(void)
 }
 
 int VgaBDF VAR16 = -1;
+int HaveRunInit VAR16;
 
 void VISIBLE16
 vga_post(struct bregs *regs)
 {
     debug_enter(regs, DEBUG_VGA_POST);
 
-    if (CONFIG_VGA_PCI) {
+    if (CONFIG_VGA_PCI && !GET_GLOBAL(HaveRunInit)) {
         u16 bdf = regs->ax;
         if ((pci_config_readw(bdf, PCI_VENDOR_ID)
              == GET_GLOBAL(rom_pci_data.vendor))
@@ -1292,6 +1293,9 @@ vga_post(struct bregs *regs)
         return;
     }
 
+    if (GET_GLOBAL(HaveRunInit))
+        return;
+
     init_bios_area();
 
     SET_VGA(video_save_pointer_table.videoparam
@@ -1303,6 +1307,8 @@ vga_post(struct bregs *regs)
 
     // XXX - clear screen and display info
 
+    SET_VGA(HaveRunInit, 1);
+
     // Fixup checksum
     extern u8 _rom_header_size, _rom_header_checksum;
     SET_VGA(_rom_header_checksum, 0);
diff --git a/vgasrc/vgabios.h b/vgasrc/vgabios.h
index b47c669..0aff684 100644
--- a/vgasrc/vgabios.h
+++ b/vgasrc/vgabios.h
@@ -75,6 +75,7 @@ extern u8 vgafont16alt[];
 
 // vgabios.c
 extern int VgaBDF;
+extern int HaveRunInit;
 #define SET_VGA(var, val) SET_FARVAR(get_global_seg(), (var), (val))
 struct carattr {
     u8 car, attr, use_attr;
-- 
1.7.6.4




More information about the SeaBIOS mailing list