current bttv tries to find a PCI device for the given physical address by
walking all PCI devices, then check whenever the address falls into one of the
dev->resource memory ranges. Works fine on i386, but I'm not sure whenever
this works on other platforms, where phys == bus isn't true.
Right now it only sanity-checks the given physical address this way (see
below), but of course I could also pass the found pci_dev to some pci->pci
API.
What addresses are in dev->resource? Physical? Bus address? Are they
unique?
Gerd
---------------------------- cut here -------------------------
static int
find_videomem(unsigned long from, unsigned long to)
{
struct pci_dev *dev = NULL;
int i,match,found;
found = 0;
dprintk(KERN_DEBUG "bttv: checking video framebuffer address"
" (%lx-%lx)\n",from,to);
pci_for_each_dev(dev) {
if (dev->class != PCI_CLASS_NOT_DEFINED_VGA &&
dev->class >> 16 != PCI_BASE_CLASS_DISPLAY)
continue;
dprintk(KERN_DEBUG
" pci display adapter %04x:%04x at %02x:%02x.%x\n",
dev->vendor,dev->device,dev->bus->number,
PCI_SLOT(dev->devfn),PCI_FUNC(dev->devfn));
for (i = 0; i < DEVICE_COUNT_RESOURCE; i++) {
if (!(dev->resource[i].flags & IORESOURCE_MEM))
continue;
if (dev->resource[i].flags & IORESOURCE_READONLY)
continue;
match = (from >= dev->resource[i].start) &&
(to-1 <= dev->resource[i].end);
if (match)
found = 1;
dprintk(KERN_DEBUG " memory at %08lx-%08lx%s\n",
dev->resource[i].start,
dev->resource[i].end,
match ? " (check passed)" : "");
}
}
return found;
}
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/