vgabios: Handle VGA option rom being re-run.
authorKevin O'Connor <kevin@koconnor.net>
Fri, 3 Feb 2012 03:52:17 +0000 (22:52 -0500)
committerKevin O'Connor <kevin@koconnor.net>
Fri, 3 Feb 2012 03:52:17 +0000 (22:52 -0500)
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@koconnor.net>
vgasrc/bochsvga.c
vgasrc/clext.c
vgasrc/vgabios.c
vgasrc/vgabios.h

index e6ab7941d63695ce177b6307536a8d3f7904ee2e..9210004466b7a94c4cba0182e90d8eb7dd783b1c 100644 (file)
@@ -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) {
index 26b34e0d30db6306502579959a93b4a4b81f35bd..0470d80a548329d3ad2df1a8b691309971efd7ad 100644 (file)
@@ -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;
 }
index e69c6c511a0138cc3c90e7c9a928333c7d4ad429..ec251fe20c0b01def6008862110e451018a26486 100644 (file)
@@ -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);
index b47c6691c555527f564b7204867cada98d1777c4..0aff68495f41f0c71452b0bb6fa949508b272820 100644 (file)
@@ -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;