[coreboot-gerrit] Patch set updated for coreboot: device/pci_rom: Move Option Rom code into pci_rom
Patrick Rudolph (siro@das-labor.org)
gerrit at coreboot.org
Fri Apr 1 19:18:50 CEST 2016
Patrick Rudolph (siro at das-labor.org) just uploaded a new patch set to gerrit, which you can find at https://review.coreboot.org/14220
-gerrit
commit 0a188a9197fdfbfbe9aa2627355a46dd5f651271
Author: Patrick Rudolph <siro at das-labor.org>
Date: Fri Mar 18 18:14:35 2016 +0100
device/pci_rom: Move Option Rom code into pci_rom
Move the Option Rom code out of pci_device.c into
pci_rom.c. As more changes the the code will follow,
this is only for a clear view purpose.
Depends on: I6ed7ff5380edc7cd88dc1c71b43b1129a3de0f52
Change-Id: Iacdff8618d080d7c928d307756662fe33ee13cf0
Signed-off-by: Patrick Rudolph <siro at das-labor.org>
---
src/device/pci_device.c | 68 +--------------------------------------
src/device/pci_rom.c | 75 ++++++++++++++++++++++++++++++++++++++++++++
src/include/device/pci_rom.h | 1 +
3 files changed, 77 insertions(+), 67 deletions(-)
diff --git a/src/device/pci_device.c b/src/device/pci_device.c
index 5123229..5f02955 100644
--- a/src/device/pci_device.c
+++ b/src/device/pci_device.c
@@ -24,9 +24,7 @@
* Copyright 1997 -- 1999 Martin Mares <mj at atrey.karlin.mff.cuni.cz>
*/
-#include <arch/acpi.h>
#include <arch/io.h>
-#include <bootmode.h>
#include <console/console.h>
#include <stdlib.h>
#include <stdint.h>
@@ -651,74 +649,10 @@ void pci_dev_set_subsystem(struct device *dev, unsigned vendor, unsigned device)
((device & 0xffff) << 16) | (vendor & 0xffff));
}
-#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;
-
- /* Don't run VGA option ROMs, unless we have to print
- * something on the screen before the kernel is loaded.
- */
- should_run = !IS_ENABLED(CONFIG_BOOTMODE_STRAPS) ||
- developer_mode_enabled() || recovery_mode_enabled();
-
-#if CONFIG_CHROMEOS
- if (!should_run)
- should_run = vboot_wants_oprom();
-#endif
- if (!should_run)
- printk(BIOS_DEBUG, "Not running VGA Option ROM\n");
- 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 */
-
/** Default handler: only runs the relevant PCI BIOS. */
void pci_dev_init(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;
-
- rom = pci_rom_probe(dev);
- if (rom == NULL)
- return;
-
- ram = pci_rom_load(dev, rom);
- if (ram == NULL)
- return;
-
- if (!should_run_oprom(dev))
- return;
-
- run_bios(dev, (unsigned long)ram);
- gfx_set_init_done(1);
- printk(BIOS_DEBUG, "VGA Option ROM was run\n");
-#endif /* CONFIG_VGA_ROM_RUN */
+ pci_rom_load_and_run(dev);
}
/** Default device operation for PCI devices */
diff --git a/src/device/pci_rom.c b/src/device/pci_rom.c
index 8366fea..9a4f6a0 100644
--- a/src/device/pci_rom.c
+++ b/src/device/pci_rom.c
@@ -24,6 +24,9 @@
#include <device/pci_ops.h>
#include <string.h>
#include <cbfs.h>
+#include <bootmode.h>
+#include <arch/acpi.h>
+#include <vendorcode/google/chromeos/vbnv.h>
/* Rmodules don't like weak symbols. */
u32 __attribute__((weak)) map_oprom_vendev(u32 vendev) { return vendev; }
@@ -169,3 +172,75 @@ struct rom_header *pci_rom_load(struct device *dev,
pci_ram_image_start += rom_size;
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;
+
+ /* Don't run VGA option ROMs, unless we have to print
+ * something on the screen before the kernel is loaded.
+ */
+ should_run = !IS_ENABLED(CONFIG_BOOTMODE_STRAPS) ||
+ developer_mode_enabled() || recovery_mode_enabled();
+
+ if (IS_ENABLED(CONFIG_CHROMEOS) && !should_run)
+ should_run = vboot_wants_oprom();
+
+ if (!should_run)
+ printk(BIOS_DEBUG, "Not running VGA Option ROM\n");
+ 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 */
+
+/**
+ * Load or run PCI Option Roms.
+ * TODO: support non VGA Option Roms.
+ * @param dev Pointer to the device
+ */
+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;
+
+ rom = pci_rom_probe(dev);
+ if (rom == NULL)
+ return;
+
+ ram = pci_rom_load(dev, rom);
+ if (ram == NULL)
+ return;
+
+ if (!should_run_oprom(dev))
+ return;
+
+ run_bios(dev, (unsigned long)ram);
+ gfx_set_init_done(1);
+ printk(BIOS_DEBUG, "VGA Option ROM was run\n");
+#endif /* CONFIG_VGA_ROM_RUN */
+}
diff --git a/src/include/device/pci_rom.h b/src/include/device/pci_rom.h
index 2fb2f7a..26b7c23 100644
--- a/src/include/device/pci_rom.h
+++ b/src/include/device/pci_rom.h
@@ -35,6 +35,7 @@ struct pci_data {
struct rom_header *pci_rom_probe(struct device *dev);
struct rom_header *pci_rom_load(struct device *dev, struct rom_header *rom_header);
+void pci_rom_load_and_run(struct device *dev);
u32 map_oprom_vendev(u32 vendev);
#endif
More information about the coreboot-gerrit
mailing list