Specifications

This is the Title of the Book, eMatter Edition
Copyright © 2005 O’Reilly & Associates, Inc. All rights reserved.
420
|
Chapter 15: Memory Mapping and DMA
Each field in /proc/*/maps (except the image name) corresponds to a field in struct
vm_area_struct
:
start
end
The beginning and ending virtual addresses for this memory area.
perm
A bit mask with the memory area’s read, write, and execute permissions. This
field describes what the process is allowed to do with pages belonging to the
area. The last character in the field is either
p for “private” or s for “shared.”
offset
Where the memory area begins in the file that it is mapped to. An offset of 0
means that the beginning of the memory area corresponds to the beginning of
the file.
major
minor
The major and minor numbers of the device holding the file that has been
mapped. Confusingly, for device mappings, the major and minor numbers refer
to the disk partition holding the device special file that was opened by the user,
and not the device itself.
inode
The inode number of the mapped file.
image
The name of the file (usually an executable image) that has been mapped.
The vm_area_struct structure
When a user-space process calls mmap to map device memory into its address space,
the system responds by creating a new VMA to represent that mapping. A driver that
supports mmap (and, thus, that implements the mmap method) needs to help that
process by completing the initialization of that VMA. The driver writer should, there-
fore, have at least a minimal understanding of VMAs in order to support mmap.
Let’s look at the most important fields in
struct vm_area_struct (defined in <linux/
mm.h>). These fields may be used by device drivers in their mmap implementation.
Note that the kernel maintains lists and trees of VMAs to optimize area lookup, and
several fields of
vm_area_struct are used to maintain this organization. Therefore,
VMAs can’t be created at will by a driver, or the structures break. The main fields of
,ch15.13676 Page 420 Friday, January 21, 2005 11:04 AM