Ahhh! You are truly the wise guru and I am but a charlatan! :)
void * mmap(void *start, size_t length, int prot , int flags, int fd,
off_t offset);
All is clear.
One final question though: Supposing for some reason you wanted to have
the pointer that mmap returns be the linear (kernel-space) address of
the memory you mapped. In other words, if you are using /dev/mem,
basically have start==offset. Would this work in most cases? I am not
sure if Linux/Unix allows holes in a processes' memory space, but I am
assuming it does..
It would be nice if the mmap man page told us exactly in what
circumstances void *start is discarded.... I am assuming it's only when
either start % getpagesize() != 0 or when start is already mapped.
But at any rate, mmap is quite clever. Actually I knew about mmap and I
used it once to map a file into memory, but it didn't occur to me that one
could take advantage of the /dev/mem 'device' driver to access physical
ram and/or talk to pci devices. Quite sexy!
I wonder how efficient it is though? I am assuming a trap is generated
whenever the user process accesses an mmapped file or device (so that the
device's driver can take over the details of reading/writing). I wonder
if that still happens in the case of mmapping /dev/mem, or if there is
some other workaround that linux applies to this case (like doing hackish
things with the page tables/MMU).
-Calin
On Wed, 19 Sep 2001 [EMAIL PROTECTED] wrote:
>
>
> > Unknown to linux? Well in some sense linux must have set up the memory
> > hardware to let the user program access that memory without a page fault..
> > so it must be known on some level right? :)
>
>
> Do a "man mmap". The mmap function will permit you to map any region
> (even if no memory is there ) into your program's memory space. You use
> mmap together with /dev/mem to access things outside linux memory space.
> There's a man page for "mem" as well.
>
> :-) Wayne
>
>
-- [rtl] ---
To unsubscribe:
echo "unsubscribe rtl" | mail [EMAIL PROTECTED] OR
echo "unsubscribe rtl <Your_email>" | mail [EMAIL PROTECTED]
--
For more information on Real-Time Linux see:
http://www.rtlinux.org/