mmap on PCI

Ronnie Sanford (ronnie@dgii.com)
Thu, 1 Aug 1996 13:24:53 -0500 (CDT)


We are having problems mapping in memory as returned by the base address
registers in PCI config space. In particular our device driver is reading
base address register 2 (0x18), anding out the last 4 bits to 0. (They
are flag bits ...) and passing this value up to an application which does
a mmap on it. It looks something like this

board[x].ram_addr = mmap(di->membase,ram_size,PROT_READ|PROT_WRITE,
MAP_SHARED|MAP_FILE, kmem_fd, (off_t)di->membase);

Initially when we did this the base address register returned a huge value
(0xff800000) which mmap failed with. Specifically it returned an
"invalid argument". In our next attempt we took the address returned to
us in the driver (From the base address register) and remmapped it with
the vremap call. We then passed this value (Newly remapped) back to the
application which did a mmap on it. This value was accepted by mmap (No
error was returned ...) but my card (A Digi PCI XR is still not working
properly). Do you think that the value returned by mmap is actually
referencing the PCI cards memory ? Are do you think that the value
returned is just pointing me to some area of random memory ? Can you
map memory in at the kernel level above memory, and then bring it in
to the apps domain via mmap ? If not do you know a way, I can address my
cards memory from an application ?

Any help you can give would be much appreciated. I am trying to add PCI
support to our latest Digi driver.

Thanks again,
Ronnie Sanford
Digi International