On Sun, 29 May 2011 23:38:18 +0200
Stefan Tauner <stefan.tauner(a)student.tuwien.ac.at> wrote:
ah.. and btw (sorry for the spam!) it would be nice if
we could change
the behavior if the physmap function in the case of len=0.
the kernel interface has a nice property in this regard:
"If you want to get access to the complete BAR without checking for its
length first, pass 0."
i am not sure how the actual length is read out, but lspci shows it too
so it cant be that hard...
would you take a patch for that?
the code is easy.
we need 3 variables here: the pci device vendor id, device id and the
pci bar index.
len will contain the total length of the pci bar.
struct pci_dev *p = pci_dev_find(vendor, device);
pciaddr_t len = (p->known_fields & PCI_FILL_SIZES) ? p->size[bar_index] : 0;
we dont know this information inside physmap and thats probably better
but(!) we could enhance pcidev_init to return an already mapped address
with the whole pci bar mmaped. i have not looked at the all use cases of
pcidev_init though. if some of its users really just want the physical
address of a device's bar we could refactor pcidev_init to retain this
functionality and share most of its code with the new function.
if we sometimes dont want to map the whole bar then there should be way
to do this too.
Kind regards/Mit freundlichen Grüßen, Stefan Tauner