In post-pciaccess Xorg, we were ignoring the lists of resources registered. Let the userspace application control it again and put the application aware of multiple PCI resources.
Signed-off-by: Tiago Vignatti <[email protected]> --- hw/xfree86/common/xf86Bus.c | 26 ++++++++++++++++++++++++-- hw/xfree86/common/xf86pciBus.c | 32 ++++++++++++++++++++++++++++++++ hw/xfree86/common/xf86pciBus.h | 1 + 3 files changed, 57 insertions(+), 2 deletions(-) diff --git a/hw/xfree86/common/xf86Bus.c b/hw/xfree86/common/xf86Bus.c index 8040f58..87d97f0 100644 --- a/hw/xfree86/common/xf86Bus.c +++ b/hw/xfree86/common/xf86Bus.c @@ -1316,6 +1316,24 @@ xf86ConvertListToHost(int entityIndex, resPtr list) } } +static resList +xf86GetResourcesImplicitly(int entityIndex) +{ + if (entityIndex >= xf86NumEntities) return NULL; + + switch (xf86Entities[entityIndex]->bus.type) { + case BUS_ISA: + case BUS_NONE: + case BUS_SBUS: + return NULL; + case BUS_PCI: + return GetImplicitPciResources(entityIndex); + case BUS_last: + return NULL; + } + return NULL; +} + /* * xf86RegisterResources() -- attempts to register listed resources. * Returns a resPtr listing all resources not successfully registered, by @@ -1328,8 +1346,12 @@ xf86RegisterResources(int entityIndex, resList list, unsigned long access) resRange range; resList list_f = NULL; - if (!list) - return NULL; + if (!list) { + list = xf86GetResourcesImplicitly(entityIndex); + /* these resources have to be in host address space already */ + if (!list) return NULL; + list_f = list; + } while(list->type != ResEnd) { range = *list; diff --git a/hw/xfree86/common/xf86pciBus.c b/hw/xfree86/common/xf86pciBus.c index e87cb97..1e2c6da 100644 --- a/hw/xfree86/common/xf86pciBus.c +++ b/hw/xfree86/common/xf86pciBus.c @@ -886,3 +886,35 @@ pciConvertRange2Host(int entityIndex, resRange *pRange) pRange->type &= ~(ResDomain | ResBus); pRange->type |= pvp->domain << 24; } + +resList +GetImplicitPciResources(int entityIndex) +{ + int i, num = 0; + resList list = NULL; + + struct pci_device *const dev = xf86GetPciInfoForEntity(entityIndex); + if (!dev) + return NULL; + + for (i = 0; i < 6; i++) { + struct pci_mem_region *r = &dev->regions[i]; + if (r->size && !r->is_IO) { + list = xnfrealloc(list,sizeof(resRange) * (++num)); + list[num - 1].a = r->base_addr; + list[num - 1].b = r->base_addr + r->size - 1; + list[num - 1].type = ResShrMemBlock | ResBios; + } + /*TODO: not sure if this deals correctly with IO accesses. + else if (r->size && !r->is_IO) { + list = xnfrealloc(list,sizeof(resRange) * (++num)); + list[num - 1].a = r->base_addr; + list[num - 1].b = r->base_addr + r->size - 1; + list[num - 1].type = ResShrIoBlock | ResBios; + }*/ + } + list = xnfrealloc(list,sizeof(resRange) * (++num)); + list[num - 1].type = ResEnd; + + return list; +} diff --git a/hw/xfree86/common/xf86pciBus.h b/hw/xfree86/common/xf86pciBus.h index 1cbfa38..d0d501f 100644 --- a/hw/xfree86/common/xf86pciBus.h +++ b/hw/xfree86/common/xf86pciBus.h @@ -70,5 +70,6 @@ void PciBusStateEnter(void); void PciStateLeave(void); void PciBusStateLeave(void); void pciConvertRange2Host(int entityIndex, resRange *pRange); +resList GetImplicitPciResources(int entityIndex); #endif /* _XF86_PCI_BUS_H */ -- 1.5.4.3 _______________________________________________ xorg-devel mailing list [email protected] http://lists.x.org/mailman/listinfo/xorg-devel
