[coreboot-gerrit] Change in coreboot[master]: device/pci_rom: Write _ROM method for VGA devices
Patrick Rudolph (Code Review)
gerrit at coreboot.org
Wed Jul 12 19:45:52 CEST 2017
Patrick Rudolph has uploaded this change for review. ( https://review.coreboot.org/20548
Change subject: device/pci_rom: Write _ROM method for VGA devices
......................................................................
device/pci_rom: Write _ROM method for VGA devices
Write _ROM method and store PCI option rom in CBMEM.
Change-Id: I548b730fb64833083cc05af5b21dd6959804224b
Signed-off-by: Patrick Rudolph <siro at das-labor.org>
---
M src/commonlib/include/commonlib/cbmem_id.h
M src/device/pci_device.c
M src/device/pci_rom.c
M src/include/device/pci_rom.h
4 files changed, 68 insertions(+), 0 deletions(-)
git pull ssh://review.coreboot.org:29418/coreboot refs/changes/48/20548/1
diff --git a/src/commonlib/include/commonlib/cbmem_id.h b/src/commonlib/include/commonlib/cbmem_id.h
index 2c9b3c3..a7fb154 100644
--- a/src/commonlib/include/commonlib/cbmem_id.h
+++ b/src/commonlib/include/commonlib/cbmem_id.h
@@ -70,6 +70,10 @@
#define CBMEM_ID_WIFI_CALIBRATION 0x57494649
#define CBMEM_ID_EC_HOSTEVENT 0x63ccbbc3
#define CBMEM_ID_EXT_VBT 0x69866684
+#define CBMEM_ID_ROM0 0x524f4d30
+#define CBMEM_ID_ROM1 0x524f4d31
+#define CBMEM_ID_ROM2 0x524f4d32
+#define CBMEM_ID_ROM3 0x524f4d33
#define CBMEM_ID_TO_NAME_TABLE \
{ CBMEM_ID_ACPI, "ACPI " }, \
diff --git a/src/device/pci_device.c b/src/device/pci_device.c
index 75e9a79..f08f95c 100644
--- a/src/device/pci_device.c
+++ b/src/device/pci_device.c
@@ -744,6 +744,7 @@
.enable_resources = pci_dev_enable_resources,
#if IS_ENABLED(CONFIG_HAVE_ACPI_TABLES)
.write_acpi_tables = pci_rom_write_acpi_tables,
+ .acpi_fill_ssdt_generator = pci_rom_ssdt,
#endif
.init = pci_dev_init,
.scan_bus = 0,
diff --git a/src/device/pci_rom.c b/src/device/pci_rom.c
index 6456d17..c798f92 100644
--- a/src/device/pci_rom.c
+++ b/src/device/pci_rom.c
@@ -25,6 +25,8 @@
#include <device/pci_ops.h>
#include <string.h>
#include <cbfs.h>
+#include <cbmem.h>
+#include <arch/acpigen.h>
/* Rmodules don't like weak symbols. */
u32 __attribute__((weak)) map_oprom_vendev(u32 vendev) { return vendev; }
@@ -267,4 +269,63 @@
return current;
}
+
+void pci_rom_ssdt(device_t device)
+{
+ struct rom_header *rom;
+ const char *scope;
+ size_t cbrom_length;
+ void *cbrom;
+ static size_t ngfx;
+
+ /* Only handle VGA devices */
+ if ((device->class >> 8) != PCI_CLASS_DISPLAY_VGA)
+ return;
+
+ /* Only handle enabled devices */
+ if (!device->enabled)
+ return;
+
+ /* Probe for option rom */
+ rom = pci_rom_probe(device);
+ if (!rom || !rom->size) {
+ printk(BIOS_ERR, "%s: Missing ROM\n", dev_path(device));
+ return;
+ }
+
+ scope = acpi_device_path(device);
+ if (!scope) {
+ printk(BIOS_ERR, "%s: Missing ACPI scope\n", dev_path(device));
+ return;
+ }
+
+ /* Supports up to four devices. */
+ if ((CBMEM_ID_ROM0 + ngfx) > CBMEM_ID_ROM3) {
+ printk(BIOS_ERR, "ERROR: Out of CBMEM IDs.\n");
+ return;
+ }
+
+ /* Prepare memory */
+ cbrom_length = DIV_ROUND_UP(rom->size * 512, 0x10000) * 0x10000;
+ if (cbrom_length > 0x40000) {
+ printk(BIOS_ERR, "ERROR: ROM of size 0x%x not supported.\n",
+ cbrom_length);
+ return;
+ }
+
+ cbrom = cbmem_add(CBMEM_ID_ROM0 + ngfx, cbrom_length);
+ if (!cbrom) {
+ printk(BIOS_ERR, "ERROR: Failed to allocate CBMEM.\n");
+ return;
+ }
+ memset(cbrom, 0, cbrom_length);
+ memcpy(cbrom, rom, rom->size * 512);
+
+ /* Write SSDT */
+
+ /* Device is known, only add _ROM method */
+ acpigen_write_scope(scope);
+ acpigen_write_rom(cbrom, cbrom_length);
+ acpigen_pop_len(); /* pop scope */
+}
#endif
diff --git a/src/include/device/pci_rom.h b/src/include/device/pci_rom.h
index c5ace4c..44d8917 100644
--- a/src/include/device/pci_rom.h
+++ b/src/include/device/pci_rom.h
@@ -43,6 +43,8 @@
unsigned long current,
struct acpi_rsdp *rsdp);
+void pci_rom_ssdt(device_t device);
+
u32 map_oprom_vendev(u32 vendev);
#endif
--
To view, visit https://review.coreboot.org/20548
To unsubscribe, visit https://review.coreboot.org/settings
Gerrit-Project: coreboot
Gerrit-Branch: master
Gerrit-MessageType: newchange
Gerrit-Change-Id: I548b730fb64833083cc05af5b21dd6959804224b
Gerrit-Change-Number: 20548
Gerrit-PatchSet: 1
Gerrit-Owner: Patrick Rudolph <siro at das-labor.org>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.coreboot.org/pipermail/coreboot-gerrit/attachments/20170712/b17a052c/attachment.html>
More information about the coreboot-gerrit
mailing list