Kyösti Mälkki (kyosti.malkki@gmail.com) just uploaded a new patch set to gerrit, which you can find at http://review.coreboot.org/3474
-gerrit
commit b690c78a405ebc96943a954ce09ab0bcc3a273df Author: Kyösti Mälkki kyosti.malkki@gmail.com Date: Sat Jun 15 17:16:56 2013 +0300
Add test to match struct device with simple_pcidev_t
Add a function to test if simple_pcidev_t matches with a device instance of struct device, by comparing bus:dev.fn.
Change-Id: Ic6c3148ac62c7183246d83302ee504b17064c794 Signed-off-by: Kyösti Mälkki kyosti.malkki@gmail.com --- src/device/pci_device.c | 13 +++++++++++++ src/include/device/pci.h | 1 + src/include/device/pci_def.h | 4 ++++ 3 files changed, 18 insertions(+)
diff --git a/src/device/pci_device.c b/src/device/pci_device.c index 4c5a814..5164896 100644 --- a/src/device/pci_device.c +++ b/src/device/pci_device.c @@ -1054,6 +1054,19 @@ 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_pcidev_t sdev) +{ + return dev->bus->secondary == PCI_DEV2SEGBUS(sdev) && + 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/pci.h b/src/include/device/pci.h index 1f47daf..c4978ef 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_pcidev_t sdev);
void pci_assign_irqs(unsigned bus, unsigned slot, const unsigned char pIntAtoD[4]); diff --git a/src/include/device/pci_def.h b/src/include/device/pci_def.h index 58a7321..c24c445 100644 --- a/src/include/device/pci_def.h +++ b/src/include/device/pci_def.h @@ -474,4 +474,8 @@ #define PCI_FUNC(devfn) ((devfn) & 0x07) #define PCI_BDF(bus,dev,func) ((bus) << 16 | (dev) << 11 | (func) << 8)
+/* Translation from PCI_DEV() to devicetree bus and path.pci.devfn. */ +#define PCI_DEV2DEVFN(sdev) ((sdev>>12)&0xff) +#define PCI_DEV2SEGBUS(sdev) ((sdev>>20)&0xfff) + #endif /* PCI_DEF_H */