Patrick Rudolph (siro@das-labor.org) just uploaded a new patch set to gerrit, which you can find at https://review.coreboot.org/14222
-gerrit
commit 197bad8d4be6279a7af28f5745ab954ab1e1fe58 Author: Patrick Rudolph siro@das-labor.org Date: Sat Mar 19 15:10:59 2016 +0100
device/pci_rom: Pass optional load address
Pass optional argument to pci_rom_load. It is useful to load the Option Rom into ACPI tables without touching the legacy address space 0xc0000.
Always write primary VGA Option Rom to address 0xc0000. The Linux kernel expects it to be available.
Depends on: I52e8e435ba7ddc37288a690ed9730633f6aff8e0
Change-Id: I3b7098f53462a3a65044e9314cf6f3cd938cc99a Signed-off-by: Patrick Rudolph siro@das-labor.org --- src/device/pci_rom.c | 40 +++++++++++++++++++++------------------- src/include/device/pci_rom.h | 4 +++- 2 files changed, 24 insertions(+), 20 deletions(-)
diff --git a/src/device/pci_rom.c b/src/device/pci_rom.c index 5abfd8e..56eafef 100644 --- a/src/device/pci_rom.c +++ b/src/device/pci_rom.c @@ -20,6 +20,7 @@ #include <console/console.h> #include <device/device.h> #include <device/pci.h> +#include <device/pci_def.h> #include <device/pci_ids.h> #include <device/pci_ops.h> #include <string.h> @@ -124,7 +125,8 @@ struct rom_header *pci_rom_probe(struct device *dev) static void *pci_ram_image_start = (void *)PCI_RAM_IMAGE_START;
struct rom_header *pci_rom_load(struct device *dev, - struct rom_header *rom_header) + struct rom_header *rom_header, + void *load_addr) { struct pci_data * rom_data; unsigned int rom_size; @@ -146,25 +148,17 @@ struct rom_header *pci_rom_load(struct device *dev,
rom_size = rom_header->size * 512;
- /* - * We check to see if the device thinks it is a VGA device not - * 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 (!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); - memcpy((void *)PCI_VGA_RAM_IMAGE_START, rom_header, - rom_size); + if (load_addr) { + if (load_addr != rom_header) { + printk(BIOS_DEBUG, "Copying ROM Image from %p to " + "%p, 0x%x bytes\n", rom_header, + load_addr, rom_size); + memcpy(load_addr, rom_header, rom_size); } - return (struct rom_header *) (PCI_VGA_RAM_IMAGE_START); + return (struct rom_header *) load_addr; }
- printk(BIOS_DEBUG, "Copying non-VGA ROM image from %p to %p, 0x%x " + printk(BIOS_DEBUG, "Copying ROM image from %p to %p, 0x%x " "bytes\n", rom_header, pci_ram_image_start, rom_size);
memcpy(pci_ram_image_start, rom_header, rom_size); @@ -235,9 +229,17 @@ void pci_rom_load_and_run(struct device *dev) if (rom == NULL) return;
- ram = pci_rom_load(dev, rom); - if (ram == NULL) + /* Primary VGA Option Rom is always loaded to PCI_VGA_RAM_IMAGE_START */ + if (dev == vga_pri) { + ram = pci_rom_load(dev, rom, (void *)PCI_VGA_RAM_IMAGE_START); + if (ram == NULL) + return; + + printk(BIOS_DEBUG, "VGA Option ROM placed at %p\n", ram); + } else { + /* TODO: support secondary VGA devices */ return; + }
if (!should_run_oprom(dev)) return; diff --git a/src/include/device/pci_rom.h b/src/include/device/pci_rom.h index 26b7c23..1dff9a7 100644 --- a/src/include/device/pci_rom.h +++ b/src/include/device/pci_rom.h @@ -34,7 +34,9 @@ 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); +struct rom_header *pci_rom_load(struct device *dev, + struct rom_header *rom_header, + void *load_addr); void pci_rom_load_and_run(struct device *dev); u32 map_oprom_vendev(u32 vendev);