[SeaBIOS] [PATCH V4 1/1] Add an option to only execute option ROMs contained in CBFS

tpearson at raptorengineeringinc.com tpearson at raptorengineeringinc.com
Tue Feb 17 22:04:17 CET 2015


TEST: Booted ASUS KFSN4-DRE with iPXE ROMs built in to CBFS;
with etc/pci-optionrom-exec set to 0 the on-board network ROMs
were ignored while the iPXE ROMs executed normally.  When set
to 2 or greater all option ROMs executed normally.  Tests of
VGA only were not possible due to a lack of supported hardware.

Signed-off-by: Timothy Pearson <tpearson at raptorengineeringinc.com>
---
 src/optionroms.c |   22 +++++++++++++++++-----
 1 file changed, 17 insertions(+), 5 deletions(-)

diff --git a/src/optionroms.c b/src/optionroms.c
index 93d9d2f..374e52f 100644
--- a/src/optionroms.c
+++ b/src/optionroms.c
@@ -20,6 +20,8 @@
 #include "string.h" // memset
 #include "util.h" // get_pnp_offset

+static int EnforceChecksum, S3ResumeVga, RunPCIroms;
+

 /****************************************************************
  * Helper functions
@@ -60,8 +62,6 @@ 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)
@@ -320,7 +320,16 @@ fail:
     return NULL;
 }

-// Attempt to map and initialize the option rom on a given PCI device.
+/*
+ * Attempt to map and initialize the option rom on a given PCI device.
+ *
+ * The following values are supported by RunPCIroms:
+ * 0: Execute no ROMs
+ * 1: Execute only VGA ROMs
+ * 2: Execute all ROMs
+ * This value is read from the CBFS file etc/pci-optionrom-exec
+ * Default is 2 (execute all ROMs)
+ */
 static int
 init_pcirom(struct pci_device *pci, int isvga, u64 *sources)
 {
@@ -329,7 +338,7 @@ init_pcirom(struct pci_device *pci, int isvga, u64 *sources)
             , pci_bdf_to_bus(bdf), pci_bdf_to_dev(bdf), pci_bdf_to_fn(bdf)
             , pci->vendor, pci->device);
     struct rom_header *rom = lookup_hardcode(pci);
-    if (! rom)
+    if (!rom && ((RunPCIroms > 1) || ((RunPCIroms == 1) && isvga)))
         rom = map_pcirom(pci);
     if (! rom)
         // No ROM present.
@@ -416,7 +425,6 @@ optionrom_setup(void)
  * VGA init
  ****************************************************************/

-static int S3ResumeVga;
 int ScreenAndDebug;
 struct rom_header *VgaROM;

@@ -432,8 +440,12 @@ vgarom_setup(void)
     // Load some config settings that impact VGA.
     EnforceChecksum = romfile_loadint("etc/optionroms-checksum", 1);
     S3ResumeVga = romfile_loadint("etc/s3-resume-vga-init", CONFIG_QEMU);
+    RunPCIroms = romfile_loadint("etc/pci-optionrom-exec", 2);
     ScreenAndDebug = romfile_loadint("etc/screen-and-debug", 1);

+    if (RunPCIroms > 2)
+        dprintf(1, "WARNING: etc/pci-optionrom-exec value %d out of range\n", RunPCIroms);
+
     if (CONFIG_OPTIONROMS_DEPLOYED) {
         // Option roms are already deployed on the system.
         init_optionrom((void*)BUILD_ROM_START, 0, 1);
-- 
1.7.9.5






More information about the SeaBIOS mailing list