Modify xf86BusAccWindowsFromOS and xf86AccResFromOS to use the

libpciaccess interfaces.
This commit is contained in:
Ian Romanick 2006-07-24 12:23:23 -07:00
parent 4b474cbc1a
commit e487627992

View File

@ -107,6 +107,12 @@ static pciBusInfo_t linuxPci0 = {
/* bridge */ NULL /* bridge */ NULL
}; };
static const struct pci_id_match match_host_bridge = {
PCI_MATCH_ANY, PCI_MATCH_ANY, PCI_MATCH_ANY, PCI_MATCH_ANY,
(PCI_CLASS_BRIDGE << 16) | (PCI_SUBCLASS_BRIDGE_HOST << 8),
0x0000ffff00, 0
};
/* from lnx_pci.c. */ /* from lnx_pci.c. */
extern int lnxPciInit(void); extern int lnxPciInit(void);
@ -775,20 +781,20 @@ xf86ReadDomainMemory(PCITAG Tag, ADDRESS Base, int Len, unsigned char *Buf)
resPtr resPtr
xf86BusAccWindowsFromOS(void) xf86BusAccWindowsFromOS(void)
{ {
pciConfigPtr *ppPCI, pPCI; struct pci_device *dev;
sturct pci_device_iterator *iter;
resPtr pRes = NULL; resPtr pRes = NULL;
resRange range; resRange range;
unsigned long io_size, mem_size; unsigned long io_size, mem_size;
int domain;
if ((ppPCI = xf86scanpci(0))) {
for (; (pPCI = *ppPCI); ppPCI++) {
if ((pPCI->pci_base_class != PCI_CLASS_BRIDGE) ||
(pPCI->pci_sub_class != PCI_SUBCLASS_BRIDGE_HOST))
continue;
domain = xf86GetPciDomain(pPCI->tag); iter = pci_id_match_iterator_create(& match_host_bridge);
linuxGetSizes(pPCI->tag, &io_size, &mem_size); while ((dev = pci_device_next(iter)) != NULL) {
const PCITAG tag = PCI_MAKE_TAG(PCI_MAKE_BUS(dev->domain, dev->bus),
dev->dev, dev->func);
const int domain = xf86GetPciDomain(tag);
linuxGetSizes(tag, &io_size, &mem_size);
RANGE(range, 0, (ADDRESS)(mem_size - 1), RANGE(range, 0, (ADDRESS)(mem_size - 1),
RANGE_TYPE(ResExcMemBlock, domain)); RANGE_TYPE(ResExcMemBlock, domain));
@ -801,7 +807,8 @@ xf86BusAccWindowsFromOS(void)
if (domain <= 0) if (domain <= 0)
break; break;
} }
}
pci_iterator_destroy(iter);
return pRes; return pRes;
} }
@ -816,19 +823,18 @@ xf86PciBusAccWindowsFromOS(void)
resPtr resPtr
xf86AccResFromOS(resPtr pRes) xf86AccResFromOS(resPtr pRes)
{ {
pciConfigPtr *ppPCI, pPCI; struct pci_device *dev;
sturct pci_device_iterator *iter;
resRange range; resRange range;
unsigned long io_size, mem_size; unsigned long io_size, mem_size;
int domain;
if ((ppPCI = xf86scanpci(0))) { iter = pci_id_match_iterator_create(& match_host_bridge);
for (; (pPCI = *ppPCI); ppPCI++) { while ((dev = pci_device_next(iter)) != NULL) {
if ((pPCI->pci_base_class != PCI_CLASS_BRIDGE) || const PCITAG tag = PCI_MAKE_TAG(PCI_MAKE_BUS(dev->domain, dev->bus),
(pPCI->pci_sub_class != PCI_SUBCLASS_BRIDGE_HOST)) dev->dev, dev->func);
continue; const int domain = xf86GetPciDomain(tag);
domain = xf86GetPciDomain(pPCI->tag); linuxGetSizes(tag, &io_size, &mem_size);
linuxGetSizes(pPCI->tag, &io_size, &mem_size);
/* /*
* At minimum, the top and bottom resources must be claimed, so * At minimum, the top and bottom resources must be claimed, so
@ -859,7 +865,8 @@ xf86AccResFromOS(resPtr pRes)
if (domain <= 0) if (domain <= 0)
break; break;
} }
}
pci_iterator_destroy(iter);
return pRes; return pRes;
} }