From 00003ae7129802d7f943756c94b35372c1b1b053 Mon Sep 17 00:00:00 2001 From: Carl-Daniel Hailfinger Date: Tue, 22 Sep 2009 00:09:41 +0000 Subject: If no pci access method has been set for the device tree so far (e.g. during early coreboot_ram), pci_{read,write}_config{8,16,32} will die(). This patch changes pci_{read,write}_config{8,16,32} to use the existing PCI access method autodetection infrastructure instead of die()ing. Until r4340, any usage of pci_{read,write}_config{8,16,32} in coreboot_ram before the device tree was set up resulted in either a silent hang or a NULL pointer dereference. I changed the code in r4340 to die() properly with a loud error message. That still was not perfect, but at least it allowed people to see why their new ports died. Still, die() is not something developers like to see, and thus a patch to automatically pick a sensible default instead of dying was created. Of course, handling PCI access method selection automatically for fallback purposes has certain limitations before the device tree is set up. We only check if conf1 works and use conf2 as fallback. No further tests are done. This patch enables cleanups and readability improvements in early coreboot_ram code: Without this patch: dword = pci_cf8_conf1.read32(&pbus, sm_dev->bus->secondary, sm_dev->path.pci.devfn, 0x64); With this patch: dword = pci_read_config32(sm_dev, 0x64); Signed-off-by: Carl-Daniel Hailfinger Acked-by: Peter Stuge git-svn-id: svn://svn.coreboot.org/coreboot/trunk@4646 2b7e53f0-3cfb-0310-b3e9-8179ed1497e1 --- src/include/device/pci.h | 2 ++ src/include/device/pci_ops.h | 3 +++ 2 files changed, 5 insertions(+) (limited to 'src/include') diff --git a/src/include/device/pci.h b/src/include/device/pci.h index df9e80dbbb..60cf4aa35c 100644 --- a/src/include/device/pci.h +++ b/src/include/device/pci.h @@ -97,6 +97,8 @@ static inline const struct pci_bus_operations *ops_pci_bus(struct bus *bus) if (bus && bus->dev && bus->dev->ops) { bops = bus->dev->ops->ops_pci_bus; } + if (!bops) + bops = pci_remember_direct(); return bops; } diff --git a/src/include/device/pci_ops.h b/src/include/device/pci_ops.h index da7e6c5d17..13eee9d4a9 100644 --- a/src/include/device/pci_ops.h +++ b/src/include/device/pci_ops.h @@ -21,4 +21,7 @@ void pci_mmio_write_config16(device_t dev, unsigned where, uint16_t val); void pci_mmio_write_config32(device_t dev, unsigned where, uint32_t val); #endif +/* This function lives in pci_ops_auto.c */ +const struct pci_bus_operations *pci_remember_direct(void); + #endif /* PCI_OPS_H */ -- cgit v1.2.3