[coreboot-gerrit] New patch to review for coreboot: 77fffb8 Match device_t between romstage and ramstage

Kyösti Mälkki (kyosti.malkki@gmail.com) gerrit at coreboot.org
Sun Jun 16 08:45:09 CEST 2013

Kyösti Mälkki (kyosti.malkki at gmail.com) just uploaded a new patch set to gerrit, which you can find at http://review.coreboot.org/3474


commit 77fffb86591e239b32bbfe4ac171d8e2f76af487
Author: Kyösti Mälkki <kyosti.malkki at gmail.com>
Date:   Sat Jun 15 17:16:56 2013 +0300

    Match device_t between romstage and ramstage
    The aliased typedef of device_t causes problems when a function
    declaration is included for a source compilied without __PRE_RAM__
    but the function definition is compiled with __PRE_RAM__.
    For such cases use simple_device_t. Add a function to test if
    simple_device_t (from romstage) matches with a device_t (from ramstage)
    for PCI devices by comparing bus:dev.fn.
    Change-Id: Ic6c3148ac62c7183246d83302ee504b17064c794
    Signed-off-by: Kyösti Mälkki <kyosti.malkki at gmail.com>
 src/arch/x86/include/arch/io.h |  1 +
 src/device/pci_device.c        | 12 ++++++++++++
 src/include/device/device.h    |  1 +
 src/include/device/pci.h       |  1 +
 4 files changed, 15 insertions(+)

diff --git a/src/arch/x86/include/arch/io.h b/src/arch/x86/include/arch/io.h
index 29c8339..3450cb2 100644
--- a/src/arch/x86/include/arch/io.h
+++ b/src/arch/x86/include/arch/io.h
@@ -207,6 +207,7 @@ static inline int log2f(int value)
 #define PNP_DEV(PORT, FUNC) (((PORT) << 8) | (FUNC))
 typedef unsigned device_t; /* pci and pci_mmio need to have different ways to have dev */
+typedef device_t simple_device_t;
 /* FIXME: We need to make the coreboot to run at 64bit mode, So when read/write memory above 4G,
  * We don't need to set %fs, and %gs anymore
diff --git a/src/device/pci_device.c b/src/device/pci_device.c
index 4c5a814..29077a2 100644
--- a/src/device/pci_device.c
+++ b/src/device/pci_device.c
@@ -1054,6 +1054,18 @@ device_t pci_probe_dev(device_t dev, struct bus *bus, unsigned devfn)
+ * Test for match between romstage and ramstage device instance.
+ *
+ * @param dev Pointer to the device structure.
+ * @param sdev Simple device model identifier, created with PCI_DEV().
+ * @return Non-zero if bus:dev.fn of device matches.
+ */
+unsigned int pci_match_simple_dev(device_t dev, simple_device_t sdev)
+	return dev->path.pci.devfn == PCI_DEV2DEVFN(sdev);
  * Scan a PCI bus.
  * Determine the existence of devices and bridges on a PCI bus. If there are
diff --git a/src/include/device/device.h b/src/include/device/device.h
index 44a9742..ac75b21 100644
--- a/src/include/device/device.h
+++ b/src/include/device/device.h
@@ -10,6 +10,7 @@
 struct device;
 #ifndef __PRE_RAM__
 typedef struct device * device_t;
+typedef unsigned int simple_device_t;
 struct pci_operations;
 struct pci_bus_operations;
 struct smbus_bus_operations;
diff --git a/src/include/device/pci.h b/src/include/device/pci.h
index 1f47daf..249c242 100644
--- a/src/include/device/pci.h
+++ b/src/include/device/pci.h
@@ -77,6 +77,7 @@ unsigned pci_find_capability(device_t dev, unsigned cap);
 struct resource *pci_get_resource(struct device *dev, unsigned long index);
 void pci_dev_set_subsystem(device_t dev, unsigned vendor, unsigned device);
 void pci_dev_init(struct device *dev);
+unsigned int pci_match_simple_dev(device_t dev, simple_device_t sdev);
 void pci_assign_irqs(unsigned bus, unsigned slot,
 		     const unsigned char pIntAtoD[4]);

More information about the coreboot-gerrit mailing list