From a9e632c2ac29c60872e7e4f9314263b34ce5031d Mon Sep 17 00:00:00 2001 From: Eric Biederman Date: Thu, 18 Nov 2004 22:38:08 +0000 Subject: - First stab at getting the ppc ports building and working. - The sandpointx3+altimus has been consolidated into one directory for now. - Added support for having different versions of the pci access functions on a per bus basis if needed. Hopefully I have not broken something inadvertently. git-svn-id: svn://svn.coreboot.org/coreboot/trunk@1786 2b7e53f0-3cfb-0310-b3e9-8179ed1497e1 --- src/arch/i386/lib/pci_ops_auto.c | 45 ++++++++++++++++++++-------------------- 1 file changed, 22 insertions(+), 23 deletions(-) (limited to 'src/arch/i386/lib/pci_ops_auto.c') diff --git a/src/arch/i386/lib/pci_ops_auto.c b/src/arch/i386/lib/pci_ops_auto.c index 5c45720888..b757e608fc 100644 --- a/src/arch/i386/lib/pci_ops_auto.c +++ b/src/arch/i386/lib/pci_ops_auto.c @@ -1,3 +1,4 @@ +#include #include #include #include @@ -15,11 +16,12 @@ * This should be close to trivial, but it isn't, because there are buggy * chipsets (yes, you guessed it, by Intel and Compaq) that have no class ID. */ -static int pci_sanity_check(const struct pci_ops *o) +static int pci_sanity_check(const struct pci_bus_operations *o) { uint16_t class, vendor; - uint8_t bus; + unsigned bus; int devfn; + struct bus pbus; /* Dummy device */ #define PCI_CLASS_BRIDGE_HOST 0x0600 #define PCI_CLASS_DISPLAY_VGA 0x0300 #define PCI_VENDOR_ID_COMPAQ 0x0e11 @@ -27,8 +29,8 @@ static int pci_sanity_check(const struct pci_ops *o) #define PCI_VENDOR_ID_MOTOROLA 0x1057 for (bus = 0, devfn = 0; devfn < 0x100; devfn++) { - class = o->read16(bus, devfn, PCI_CLASS_DEVICE); - vendor = o->read16(bus, devfn, PCI_VENDOR_ID); + class = o->read16(&pbus, bus, devfn, PCI_CLASS_DEVICE); + vendor = o->read16(&pbus, bus, devfn, PCI_VENDOR_ID); if (((class == PCI_CLASS_BRIDGE_HOST) || (class == PCI_CLASS_DISPLAY_VGA)) || ((vendor == PCI_VENDOR_ID_INTEL) || (vendor == PCI_VENDOR_ID_COMPAQ) || (vendor == PCI_VENDOR_ID_MOTOROLA))) { @@ -39,7 +41,7 @@ static int pci_sanity_check(const struct pci_ops *o) return 0; } -static void pci_check_direct(void) +const struct pci_bus_operations *pci_check_direct(void) { unsigned int tmp; @@ -50,13 +52,12 @@ static void pci_check_direct(void) outb(0x01, 0xCFB); tmp = inl(0xCF8); outl(0x80000000, 0xCF8); - if (inl(0xCF8) == 0x80000000) { - pci_set_method_conf1(); - if (pci_sanity_check(conf)) { - outl(tmp, 0xCF8); - printk_debug("PCI: Using configuration type 1\n"); - return; - } + if ((inl(0xCF8) == 0x80000000) && + pci_sanity_check(&pci_cf8_conf1)) + { + outl(tmp, 0xCF8); + printk_debug("PCI: Using configuration type 1\n"); + return &pci_cf8_conf1; } outl(tmp, 0xCF8); } @@ -68,25 +69,23 @@ static void pci_check_direct(void) outb(0x00, 0xCFB); outb(0x00, 0xCF8); outb(0x00, 0xCFA); - if (inb(0xCF8) == 0x00 && inb(0xCFA) == 0x00) { - pci_set_method_conf2(); - if (pci_sanity_check(conf)) { - printk_debug("PCI: Using configuration type 2\n"); - } + if ((inb(0xCF8) == 0x00 && inb(0xCFA) == 0x00) && + pci_sanity_check(&pci_cf8_conf2)) + { + printk_debug("PCI: Using configuration type 2\n"); + return &pci_cf8_conf2; } } - printk_debug("pci_check_direct failed\n"); - conf = 0; - - return; + die("pci_check_direct failed\n"); + return NULL; } /** Set the method to be used for PCI, type I or type II */ -void pci_set_method(void) +void pci_set_method(device_t dev) { printk_info("Finding PCI configuration type.\n"); - pci_check_direct(); + dev->ops->ops_pci_bus = pci_check_direct(); post_code(0x5f); } -- cgit v1.2.3