Device driver question (PCI I/O memory)
Roger Oberholtzer
roger
Mon May 17 11:43:17 PDT 2004
This is not, perhaps, the best forum for this. But, as I am running out
of resources, here goes:
I am writing a device driver for a DPS card (not our own manufacture). Most
everything seems to be going as I would expect. With one exception.
I am mapping the PCI memory (256 bytes of registers in this case) into user
address space with the kernel's remap_page_range(). I have discovered that
this works on some computers and not on others. Upon investigation, I see
that the memory I want to map is not always placed on a page boundary by the
BIOS. On machines where the mapping works, the BIOS has placed this memory
at the top of a page boundary (e.g., efeff000). On machines where this does
not work, the memory is placed inside a page (e.g., fefefc00). Pages in this
sense are a Linux kernel abstraction. The BIOS knows nothing of their size
or alignment. So, the BIOS will remain free to put the card's memory
wherever it sees fit.
The problem (as I see it) is that in the 2.4.x kernels, remap_page_range()
maps the memory asked for - starting at the beginning of the page the memory
occurs on. Fair enough. But I see no mechanism to add back that page offset
to a mmap()'s pointer.
By manipulating the mmap pointer, I can 'deal' with this in a user program.
But this is absolutely not the way it should be. A user program does not
know about how the card's memory is relative to a page boundary.
And, the device driver does not return the mapped address directly. The
mmap() call has a layer that actually returns the memory pointer.
I have looked through lots of discussion lists and docs, and none describe
how to deal with this.
Anyone know what I am going on about?
--
+????????????????????????????+???????????????????????????????+
? Roger Oberholtzer ? E-mail: roger at opq.se ?
? OPQ Systems AB ? WWW: http://www.opq.se/ ?
? Erik Dahlbergsgatan 41-43 ? Phone: Int + 46 8 314223 ?
? 115 34 Stockholm ? Mobile: Int + 46 733 621657 ?
? Sweden ? Fax: Int + 46 8 302602 ?
+????????????????????????????+???????????????????????????????+
More information about the Linux-users
mailing list