The Mapping driver module


Mapping


Description:

The Maptest module shows how a piece of memory in the kernel space can be mapped to the user memory. Xfree uses this method to access the video board memory directly from user level via /dev/kmem. It is also possible to map a DMA buffer or whatever. 'normal' memory is usually not used for mapping so it has to be marked as 'reserved' before it can be used for mapping. The driver allocates one page of kernel memory that will be initialized with a string. In user space this memory area can be used for reading and writing (see maptest.c) maptest supports reading and writing the buffer just by adding a commandline argument: maptest "test content" will show the old content of the buffer and change it to the new value. The 'procinfo' method is used to make this buffer visible in the /proc/Maptest file. cat /proc/Maptest shows Proc entry from Maptest: Message: 'Test Content'


Driver inodes:

The driver inode in /dev is usually created by

mknod /dev/Mapping c major minor
If another major is needed it can be specified by the Mapping_major option to insmod:

insmod Mapping.o Mapping_major=new_major

Driver inodes:

All driver generated with LDDK have debugging information compiled into the code that can be configured with the dbgMask option to insmod. The bits of dbgMask specifies the debugging verbosity:

For example:

insmod Mapping.o dbgMask=0x06 logs all function entrys and exits to the kernel log daemon.

Wed Dec 23 17:44:56 1998