simple access to mem mapped peripheral

Francis Litterio litterio at pyxsys.net
Fri Oct 5 01:34:01 EST 2001


Matthias Fuchs wrote:

> thanks. mmap is working fine for my problem ! I wonder why
> lseek'ing and reading does not work.

Because in linux/drivers/char/mem.c the function memory_lseek(), which
implements the lseek() system call for /dev/mem, does not call
remap_page_range(), but function mmap_mem(), which implements the mmap()
system call for /dev/mem, does call remap_page_range().

remap_page_range() is a kernel function that builds virtual memory page
table entries for physical pages.  In this case, the physical pages are
your device memory that is mapped into RAM by the PCI bus.

Without the PTEs for those physical pages, attempts to read from those
pages (e.g., via lseek() and read()) will segfault just as if you had
dereferenced a pointer that does not point to a valid page in your user
address space.
--
Francis Litterio
Software Engineer
Pyxsys Corproration
litterio at pyxsys.net
978-371-9115 x131


** Sent via the linuxppc-embedded mail list. See http://lists.linuxppc.org/





More information about the Linuxppc-embedded mailing list