[coreboot-gerrit] New patch to review for coreboot: device/device: add dev_verify_resources

Patrick Rudolph (siro@das-labor.org) gerrit at coreboot.org
Sun Jun 5 12:43:27 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/15073

-gerrit

commit 84b279cc718b9123630cf716ba42d975a919c332
Author: Patrick Rudolph <siro at das-labor.org>
Date:   Sun May 29 17:00:11 2016 +0200

    device/device: add dev_verify_resources
    
    Make sure that dynamic allocated resource fit into PCI mmio region.
    The caller has to provide the current lower PCI MMIO limit (TOLUD) and
    receives the lowest dynamic resource base address.
    
    Change-Id: Icde74e4748e9b273882af3f5955b530c3567886b
    Signed-off-by: Patrick Rudolph <siro at das-labor.org>
---
 src/device/device.c         | 47 +++++++++++++++++++++++++++++++++++++++++++++
 src/include/device/device.h |  1 +
 2 files changed, 48 insertions(+)

diff --git a/src/device/device.c b/src/device/device.c
index 9ea32cc..1c314e4 100644
--- a/src/device/device.c
+++ b/src/device/device.c
@@ -1116,6 +1116,53 @@ void dev_enable(void)
 }
 
 /**
+ * Find and verify the smallest resource base address.
+ *
+ * Starting at the root, walk the tree and verify all devices/bridges by
+ * looking at the resource's base address. Ignore fixed resources.
+ * Print an error if the resource lays outside of the PCI decode range.
+ *
+ * @configured_mmio_base: Current PCI MMIO address used for verification
+ *
+ * Returns: The smallest resource base address found
+ */
+u32 dev_verify_resources(u32 configured_mmio_base)
+{
+	struct resource *res;
+	struct device *root;
+	struct device *child;
+	u32 real_mmio_base = 0xffffffff;
+
+	root = &dev_root;
+
+	/* Read the resources for the entire tree. */
+
+	printk(BIOS_DEBUG, "Reading resources...\n");
+	read_resources(root->link_list);
+	printk(BIOS_DEBUG, "Done reading resources.\n");
+
+	/* Verify PCI MMIO configuration ... */
+
+	for (child = root->link_list->children; child; child = child->sibling) {
+		if (!(child->path.type == DEVICE_PATH_DOMAIN))
+			continue;
+		post_log_path(child);
+		for (res = child->resource_list; res; res = res->next) {
+			if (res->flags & IORESOURCE_FIXED)
+				continue;
+			if (res->base < configured_mmio_base) {
+				show_one_resource(BIOS_ERR, child, res,
+								  " doesn't fit into PCI MMIO space.");
+			}
+			if (res->base < real_mmio_base)
+				real_mmio_base = res->base;
+		}
+	}
+
+	return real_mmio_base;
+}
+
+/**
  * Initialize a specific device.
  *
  * The parent should be initialized first to avoid having an ordering problem.
diff --git a/src/include/device/device.h b/src/include/device/device.h
index 00ff3d9..8ccc421 100644
--- a/src/include/device/device.h
+++ b/src/include/device/device.h
@@ -169,6 +169,7 @@ void dev_initialize_chips(void);
 void dev_enumerate(void);
 void dev_configure(void);
 void dev_enable(void);
+u32 dev_verify_resources(u32);
 void dev_initialize(void);
 void dev_optimize(void);
 void dev_finalize(void);



More information about the coreboot-gerrit mailing list