Allow free space in f-segment to be used by malloc_fseg().
[seabios.git] / src / optionroms.c
index b2415cc848b40f93cea22d8f9c0fcceef7c02e49..2832eab1ab42b696292faf3eec1090ac0f99d003 100644 (file)
@@ -116,6 +116,8 @@ call_bcv(u16 seg, u16 ip)
     __callrom(MAKE_FLATPTR(seg, 0), ip, 0);
 }
 
+static int EnforceChecksum;
+
 // Verify that an option rom looks valid
 static int
 is_valid_rom(struct rom_header *rom)
@@ -131,7 +133,7 @@ is_valid_rom(struct rom_header *rom)
     if (sum != 0) {
         dprintf(1, "Found option rom with bad checksum: loc=%p len=%d sum=%x\n"
                 , rom, len, sum);
-        if (CONFIG_OPTIONROMS_CHECKSUM)
+        if (EnforceChecksum)
             return 0;
     }
     return 1;
@@ -228,10 +230,11 @@ getRomPriority(u64 *sources, struct rom_header *rom, int instance)
     if (!source)
         return -1;
     if (source & RS_PCIROM)
-        return bootprio_find_pci_rom(source, instance);
+        return bootprio_find_pci_rom((void*)(u32)source, instance);
     return bootprio_find_named_rom(romfile_name(source), instance);
 }
 
+
 /****************************************************************
  * Roms in CBFS
  ****************************************************************/
@@ -376,7 +379,7 @@ init_pcirom(struct pci_device *pci, int isvga, u64 *sources)
     if (! rom)
         // No ROM present.
         return -1;
-    setRomSource(sources, rom, RS_PCIROM | bdf);
+    setRomSource(sources, rom, RS_PCIROM | (u32)pci);
     return init_optionrom(rom, bdf, isvga);
 }
 
@@ -410,9 +413,7 @@ optionrom_setup(void)
         // Find and deploy PCI roms.
         struct pci_device *pci;
         foreachpci(pci) {
-            u16 v = pci->class;
-            if (v == 0x0000 || v == 0xffff || v == PCI_CLASS_DISPLAY_VGA
-                || (CONFIG_ATA && v == PCI_CLASS_STORAGE_IDE))
+            if (pci->class == PCI_CLASS_DISPLAY_VGA || pci->have_driver)
                 continue;
             init_pcirom(pci, 0, sources);
         }
@@ -460,6 +461,9 @@ optionrom_setup(void)
  * VGA init
  ****************************************************************/
 
+static int S3ResumeVgaInit;
+int ScreenAndDebug;
+
 // Call into vga code to turn on console.
 void
 vga_setup(void)
@@ -469,19 +473,24 @@ vga_setup(void)
 
     dprintf(1, "Scan for VGA option rom\n");
 
+    // Load some config settings that impact VGA.
+    EnforceChecksum = romfile_loadint("etc/optionroms-checksum", 1);
+    S3ResumeVgaInit = romfile_loadint("etc/s3-resume-vga-init", 0);
+    ScreenAndDebug = romfile_loadint("etc/screen-and-debug", 1);
+
     if (CONFIG_OPTIONROMS_DEPLOYED) {
         // Option roms are already deployed on the system.
         init_optionrom((void*)BUILD_ROM_START, 0, 1);
     } else {
         // Clear option rom memory
-        memset((void*)RomEnd, 0, _max_rom() - RomEnd);
+        memset((void*)RomEnd, 0, max_rom() - RomEnd);
 
         // Find and deploy PCI VGA rom.
         struct pci_device *pci;
         foreachpci(pci) {
             if (!is_pci_vga(pci))
                 continue;
-            VGAbdf = pci->bdf;
+            vgahook_setup(pci);
             init_pcirom(pci, 1, NULL);
             break;
         }
@@ -502,7 +511,7 @@ vga_setup(void)
 void
 s3_resume_vga_init(void)
 {
-    if (!CONFIG_S3_RESUME_VGA_INIT)
+    if (!S3ResumeVgaInit)
         return;
     struct rom_header *rom = (void*)BUILD_ROM_START;
     if (! is_valid_rom(rom))