Patrick Rudolph (siro@das-labor.org) just uploaded a new patch set to gerrit, which you can find at https://review.coreboot.org/14221
-gerrit
commit 300afca77d05f8cfbd05c8c21c4e315e59e71a7b Author: Patrick Rudolph siro@das-labor.org Date: Sat Mar 19 13:47:39 2016 +0100
device/pci_rom: Always load primary Option Rom
The linux kernel expects the primary VGA Option Rom to be shadowed at 0xc0000, but it is only loaded if CONFIG_VGA_ROM_RUN is set.
For users that don't want to run Option Roms always load the Option Rom and run it if CONFIG_VGA_ROM_RUN is set.
Change-Id: I52e8e435ba7ddc37288a690ed9730633f6aff8e0 Signed-off-by: Patrick Rudolph siro@das-labor.org --- src/device/Kconfig | 12 --------- src/device/pci_rom.c | 69 +++++++++++++++++++++++++++------------------------- 2 files changed, 36 insertions(+), 45 deletions(-)
diff --git a/src/device/Kconfig b/src/device/Kconfig index d156d36..3d154e5 100644 --- a/src/device/Kconfig +++ b/src/device/Kconfig @@ -72,18 +72,6 @@ config S3_VGA_ROM_RUN
If unsure, say N when using SeaBIOS as payload, Y otherwise.
-config ALWAYS_LOAD_OPROM - def_bool n - depends on VGA_ROM_RUN - help - Always load option ROMs if any are found. The decision to run - the ROM is still determined at runtime, but the distinction - between loading and not running comes into play for CHROMEOS. - - An example where this is required is that VBT (Video BIOS Tables) - are needed for the kernel's display driver to know how a piece of - hardware is configured to be used. - config ON_DEVICE_ROM_LOAD bool "Load Option ROMs on PCI devices" default n if PAYLOAD_SEABIOS diff --git a/src/device/pci_rom.c b/src/device/pci_rom.c index acda996..5abfd8e 100644 --- a/src/device/pci_rom.c +++ b/src/device/pci_rom.c @@ -30,6 +30,8 @@ /* Rmodules don't like weak symbols. */ u32 __attribute__((weak)) map_oprom_vendev(u32 vendev) { return vendev; }
+extern device_t vga_pri; /* Primary VGA device (device.c). */ + struct rom_header *pci_rom_probe(struct device *dev) { struct rom_header *rom_header; @@ -149,17 +151,15 @@ struct rom_header *pci_rom_load(struct device *dev, * whether the ROM image is for a VGA device because some * devices have a mismatch between the hardware and the ROM. */ - if (PCI_CLASS_DISPLAY_VGA == (dev->class >> 8)) { -#if !CONFIG_MULTIPLE_VGA_ADAPTERS - extern device_t vga_pri; /* Primary VGA device (device.c). */ - if (dev != vga_pri) return NULL; /* Only one VGA supported. */ -#endif + if (PCI_CLASS_DISPLAY_VGA == (dev->class >> 8)) { + if (!IS_ENABLED(CONFIG_MULTIPLE_VGA_ADAPTERS) && dev != vga_pri) + return NULL; /* Only one VGA supported. */ if ((void *)PCI_VGA_RAM_IMAGE_START != rom_header) { printk(BIOS_DEBUG, "Copying VGA ROM Image from %p to " - "0x%x, 0x%x bytes\n", rom_header, - PCI_VGA_RAM_IMAGE_START, rom_size); + "0x%x, 0x%x bytes\n", rom_header, + PCI_VGA_RAM_IMAGE_START, rom_size); memcpy((void *)PCI_VGA_RAM_IMAGE_START, rom_header, - rom_size); + rom_size); } return (struct rom_header *) (PCI_VGA_RAM_IMAGE_START); } @@ -172,19 +172,41 @@ struct rom_header *pci_rom_load(struct device *dev, return (struct rom_header *) (pci_ram_image_start-rom_size); }
-#if CONFIG_VGA_ROM_RUN static int should_run_oprom(struct device *dev) { static int should_run = -1;
- if (should_run >= 0) - return should_run; + /* If CONFIG_VGA_ROM_RUN is disabled, skip running VGA option + * ROMs. + */ + if (!IS_ENABLED(CONFIG_VGA_ROM_RUN)) { + printk(BIOS_DEBUG, "Not running VGA Option ROM\n"); + return 0; + } + + /* If S3_VGA_ROM_RUN is disabled, skip running VGA option + * ROMs when coming out of an S3 resume. + */ + if (!IS_ENABLED(CONFIG_S3_VGA_ROM_RUN) && acpi_is_wakeup_s3() && + ((dev->class >> 8) == PCI_CLASS_DISPLAY_VGA)) { + printk(BIOS_DEBUG, "Not running VGA Option ROM\n"); + return 0; + } + + /* Only run primary VGA device Option Rom. + */ + if (vga_pri != dev) { + printk(BIOS_DEBUG, "Not running VGA Option ROM\n"); + return 0; + }
/* Don't run VGA option ROMs, unless we have to print * something on the screen before the kernel is loaded. + * Only run the primary vga device's Option Rom. */ should_run = !IS_ENABLED(CONFIG_BOOTMODE_STRAPS) || - developer_mode_enabled() || recovery_mode_enabled(); + developer_mode_enabled() || + recovery_mode_enabled();
#if CONFIG_CHROMEOS if (!should_run) @@ -195,23 +217,6 @@ static int should_run_oprom(struct device *dev) return should_run; }
-static int should_load_oprom(struct device *dev) -{ - /* If S3_VGA_ROM_RUN is disabled, skip running VGA option - * ROMs when coming out of an S3 resume. - */ - if (!IS_ENABLED(CONFIG_S3_VGA_ROM_RUN) && acpi_is_wakeup_s3() && - ((dev->class >> 8) == PCI_CLASS_DISPLAY_VGA)) - return 0; - if (IS_ENABLED(CONFIG_ALWAYS_LOAD_OPROM)) - return 1; - if (should_run_oprom(dev)) - return 1; - - return 0; -} -#endif /* CONFIG_VGA_ROM_RUN */ - /* TODO: find a good name for this function */ /** * Load or run PCI Option Roms. @@ -220,15 +225,12 @@ static int should_load_oprom(struct device *dev) */ void pci_rom_load_and_run(struct device *dev) { -#if CONFIG_VGA_ROM_RUN struct rom_header *rom, *ram; /* Only execute VGA ROMs. */ if (((dev->class >> 8) != PCI_CLASS_DISPLAY_VGA)) return;
- if (!should_load_oprom(dev)) - return; - + /* Always load VGA Option Roms. */ rom = pci_rom_probe(dev); if (rom == NULL) return; @@ -240,6 +242,7 @@ void pci_rom_load_and_run(struct device *dev) if (!should_run_oprom(dev)) return;
+#if CONFIG_VGA_ROM_RUN run_bios(dev, (unsigned long)ram); gfx_set_init_done(1); printk(BIOS_DEBUG, "VGA Option ROM was run\n");