Subject: RE: simple access to mem mapped peripheral

From: "Francis Litterio" <[email-masked]>
Date: Thu, 4 Oct 2001 11:34:01 -0400

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
[email-masked]
978-371-9115 x131

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