Re: mapping physical memory

From: Dan Maas (dmaas@dcine.com)
Date: Fri Jan 26 2001 - 05:39:38 EST


> I need to be able to obtain and pin approximately 8 MB of
> contiguous physical memory in user space. How would I go
> about doing that under Linux if it is at all possible?

The only way to allocate that much *physically* contiguous memory is by
writing a driver that grabs it at boot-time (I think the "bootmem" API is
used for this). This is an extreme measure and should rarely be necessary,
except in special cases such as primitive PCI cards that lack support for
scatter/gather DMA.

You can easily implement a mmap() interface to give user-space programs
access to the memory; there are plenty of examples of how to do this in
various character device drivers.
(well OK, if all you need is a one-off hack, you can use the method
developed by the Utah GLX people -- tell the kernel that you have 8MB *less*
RAM than is actually present using a "mem=" directive at boot, then grab
that last piece of memory by mmap'ing /dev/mem -- see
http://utah-glx.sourceforge.net/memory-usage.html)

Dan

-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
Please read the FAQ at http://www.tux.org/lkml/



This archive was generated by hypermail 2b29 : Wed Jan 31 2001 - 21:00:24 EST