diff options
author | Tiago Vignatti <vignatti@c3sl.ufpr.br> | 2008-02-25 17:07:07 -0300 |
---|---|---|
committer | Tiago Vignatti <vignatti@c3sl.ufpr.br> | 2008-02-25 17:07:07 -0300 |
commit | f19f7b8e53ed6609fc1fdd272de5521417946209 (patch) | |
tree | 9a5250613e21731be4faf2f6ef733980c798687e /hw | |
parent | 4b50e71bf127c8e0f289e3b76c786f0398effe65 (diff) |
Clean some garbage caused when pciaccess was merged:
FindPCIVideoInfo() function isn't need anymore.
xf86scanpci() is being called only once so we don't need permanent
(static) variables there.
restorePciState() is not used for now (until we find why multiple
cards aren't working).
Diffstat (limited to 'hw')
-rw-r--r-- | hw/xfree86/common/xf86pciBus.c | 241 | ||||
-rw-r--r-- | hw/xfree86/os-support/bus/Pci.c | 13 |
2 files changed, 118 insertions, 136 deletions
diff --git a/hw/xfree86/common/xf86pciBus.c b/hw/xfree86/common/xf86pciBus.c index 13e13e980..d5ae75b3a 100644 --- a/hw/xfree86/common/xf86pciBus.c +++ b/hw/xfree86/common/xf86pciBus.c @@ -107,127 +107,6 @@ xf86FormatPciBusNumber(int busnum, char *buffer) sprintf(buffer, "%d@%d", busnum & 0x00ff, busnum >> 8); } -static void -FindPCIVideoInfo(void) -{ - int i = 0, k; - int num = 0; - struct pci_device *info; - struct pci_device_iterator *iter; - - - if (!xf86scanpci()) { - xf86PciVideoInfo = NULL; - return; - } - - iter = pci_slot_match_iterator_create(& xf86IsolateDevice); - while ((info = pci_device_next(iter)) != NULL) { - if (PCIINFOCLASSES(info->device_class)) { - num++; - xf86PciVideoInfo = xnfrealloc(xf86PciVideoInfo, - (sizeof(struct pci_device *) - * (num + 1))); - xf86PciVideoInfo[num] = NULL; - xf86PciVideoInfo[num - 1] = info; - - pci_device_probe(info); - info->user_data = 0; - } - } - - - /* If we haven't found a primary device try a different heuristic */ - if (primaryBus.type == BUS_NONE && num) { - for (i = 0; i < num; i++) { - uint16_t command; - - info = xf86PciVideoInfo[i]; - pci_device_cfg_read_u16(info, & command, 4); - - if ((command & PCI_CMD_MEM_ENABLE) - && ((num == 1) || IS_VGA(info->device_class))) { - if (primaryBus.type == BUS_NONE) { - primaryBus.type = BUS_PCI; - primaryBus.id.pci = info; - } else { - xf86Msg(X_NOTICE, - "More than one possible primary device found\n"); - primaryBus.type ^= (BusType)(-1); - } - } - } - } - - /* Print a summary of the video devices found */ - for (k = 0; k < num; k++) { - const char *vendorname = NULL, *chipname = NULL; - const char *prim = " "; - Bool memdone = FALSE, iodone = FALSE; - - - info = xf86PciVideoInfo[k]; - - vendorname = pci_device_get_vendor_name( info ); - chipname = pci_device_get_device_name( info ); - - if ((!vendorname || !chipname) && - !PCIALWAYSPRINTCLASSES(info->device_class)) - continue; - - if (xf86IsPrimaryPci(info)) - prim = "*"; - - xf86Msg( X_PROBED, "PCI:%s(%u@%u:%u:%u) ", prim, info->domain, - info->bus, info->dev, info->func ); - - if (vendorname) - xf86ErrorF("%s ", vendorname); - else - xf86ErrorF("unknown vendor (0x%04x) ", info->vendor_id); - - if (chipname) - xf86ErrorF("%s ", chipname); - else - xf86ErrorF("unknown chipset (0x%04x) ", info->device_id); - - xf86ErrorF("rev %d", info->revision); - - for (i = 0; i < 6; i++) { - struct pci_mem_region * r = & info->regions[i]; - - if ( r->size && ! r->is_IO ) { - if (!memdone) { - xf86ErrorF(", Mem @ "); - memdone = TRUE; - } else - xf86ErrorF(", "); - xf86ErrorF("0x%08lx/%ld", r->base_addr, r->size); - } - } - - for (i = 0; i < 6; i++) { - struct pci_mem_region * r = & info->regions[i]; - - if ( r->size && r->is_IO ) { - if (!iodone) { - xf86ErrorF(", I/O @ "); - iodone = TRUE; - } else - xf86ErrorF(", "); - xf86ErrorF("0x%08lx/%ld", r->base_addr, r->size); - } - } - - if ( info->rom_size ) { - xf86ErrorF(", BIOS @ 0x\?\?\?\?\?\?\?\?/%ld", info->rom_size); - } - - xf86ErrorF("\n"); - } -} - - /* * IO enable/disable related routines for PCI */ @@ -401,10 +280,10 @@ savePciState( struct pci_device * dev, pciSavePtr ptr ) } /* move to OS layer */ +#if 0 static void restorePciState( struct pci_device * dev, pciSavePtr ptr) { -#if 0 int i; /* disable card before setting anything */ @@ -419,8 +298,8 @@ restorePciState( struct pci_device * dev, pciSavePtr ptr) } pci_device_cfg_write_u32(dev, ptr->command, PCI_CMD_STAT_REG); -#endif } +#endif /* move to OS layer */ static void @@ -470,7 +349,121 @@ restorePciBusState(BusAccPtr ptr) void xf86PciProbe(void) { - FindPCIVideoInfo(); + int i = 0, k; + int num = 0; + struct pci_device *info; + struct pci_device_iterator *iter; + + + if (!xf86scanpci()) { + xf86PciVideoInfo = NULL; + return; + } + + iter = pci_slot_match_iterator_create(& xf86IsolateDevice); + while ((info = pci_device_next(iter)) != NULL) { + if (PCIINFOCLASSES(info->device_class)) { + num++; + xf86PciVideoInfo = xnfrealloc(xf86PciVideoInfo, + (sizeof(struct pci_device *) + * (num + 1))); + xf86PciVideoInfo[num] = NULL; + xf86PciVideoInfo[num - 1] = info; + + pci_device_probe(info); + info->user_data = 0; + } + } + + + /* If we haven't found a primary device try a different heuristic */ + if (primaryBus.type == BUS_NONE && num) { + for (i = 0; i < num; i++) { + uint16_t command; + + info = xf86PciVideoInfo[i]; + pci_device_cfg_read_u16(info, & command, 4); + + if ((command & PCI_CMD_MEM_ENABLE) + && ((num == 1) || IS_VGA(info->device_class))) { + if (primaryBus.type == BUS_NONE) { + primaryBus.type = BUS_PCI; + primaryBus.id.pci = info; + } else { + xf86Msg(X_NOTICE, + "More than one possible primary device found\n"); + primaryBus.type ^= (BusType)(-1); + } + } + } + } + + /* Print a summary of the video devices found */ + for (k = 0; k < num; k++) { + const char *vendorname = NULL, *chipname = NULL; + const char *prim = " "; + Bool memdone = FALSE, iodone = FALSE; + + + info = xf86PciVideoInfo[k]; + + vendorname = pci_device_get_vendor_name( info ); + chipname = pci_device_get_device_name( info ); + + if ((!vendorname || !chipname) && + !PCIALWAYSPRINTCLASSES(info->device_class)) + continue; + + if (xf86IsPrimaryPci(info)) + prim = "*"; + + xf86Msg( X_PROBED, "PCI:%s(%u@%u:%u:%u) ", prim, info->domain, + info->bus, info->dev, info->func ); + + if (vendorname) + xf86ErrorF("%s ", vendorname); + else + xf86ErrorF("unknown vendor (0x%04x) ", info->vendor_id); + + if (chipname) + xf86ErrorF("%s ", chipname); + else + xf86ErrorF("unknown chipset (0x%04x) ", info->device_id); + + xf86ErrorF("rev %d", info->revision); + + for (i = 0; i < 6; i++) { + struct pci_mem_region * r = & info->regions[i]; + + if ( r->size && ! r->is_IO ) { + if (!memdone) { + xf86ErrorF(", Mem @ "); + memdone = TRUE; + } else + xf86ErrorF(", "); + xf86ErrorF("0x%08lx/%ld", r->base_addr, r->size); + } + } + + for (i = 0; i < 6; i++) { + struct pci_mem_region * r = & info->regions[i]; + + if ( r->size && r->is_IO ) { + if (!iodone) { + xf86ErrorF(", I/O @ "); + iodone = TRUE; + } else + xf86ErrorF(", "); + xf86ErrorF("0x%08lx/%ld", r->base_addr, r->size); + } + } + + if ( info->rom_size ) { + xf86ErrorF(", BIOS @ 0x\?\?\?\?\?\?\?\?/%ld", info->rom_size); + } + + xf86ErrorF("\n"); + } } void diff --git a/hw/xfree86/os-support/bus/Pci.c b/hw/xfree86/os-support/bus/Pci.c index a34ed99d0..1ca0bd07a 100644 --- a/hw/xfree86/os-support/bus/Pci.c +++ b/hw/xfree86/os-support/bus/Pci.c @@ -268,18 +268,7 @@ pciAddrNOOP(PCITAG tag, PciAddrType type, ADDRESS addr) _X_EXPORT Bool xf86scanpci(void) { - static Bool done = FALSE; - static Bool success = FALSE; - - /* - * if we haven't found PCI devices checking for pci_devp may - * result in an endless recursion if platform/OS specific PCI - * bus probing code calls this function from with in it. - */ - if (done) - return success; - - done = TRUE; + Bool success = FALSE; success = (pci_system_init() == 0); pciInit(); |