|
IO memory emulation
Thanks to Greg Lonnon, UML (as of
2.4.6-4um) has support for I/O memory emulation. This allows a host
file to be specified as an I/O region on the kernel command line.
That file will be mapped into UML's kernel address space where a
driver can locate it and do whatever it wants with the memory,
including providing an interface to it for UML processes to use.
Specifying an iomem region on the kernel command line is done as
follows:
iomem=name,file
The name is defined by the driver that will use the I/O area and the
file is the name of the host file that will be mapped in.
The driver finds its I/O area by calling find_iomem
unsigned long find_iomem(char *driver, unsigned long *len_out)
which returns the address of the beginning of the area and passes its
length out in len_out. The driver argument is the name of the I/O
area as defined on the command line.
Once the driver has located its I/O area, it can do whatever it wants
with it, including
-
providing a file interface to it
-
allowing processes to mmap it into their own address spaces
-
use it as a backing store for some other kind of interface, such as an
X server using it as a framebuffer and providing an X protocol
interface to it
arch/um/drivers/mmapper_kern.c contains a simple example driver which
locates the iomem area named "mmapper" and makes it available for
mapping through /dev/mmapper.
Here is a little
program which will mmap the /dev/mmapper device and print its contents.
To run this driver, compile it into the kernel by turning on
CONFIG_MMAPPER, and assign a file to it by putting
iomem=mmapper,file
on the command line.
|