mmap(D2) mmap(D2)
NAME
mmap - support virtual mapping for memory-mapped device
SYNOPSIS
#include <sys/types.h>
#include <sys/mman.h>
#include <sys/vm.h>
#include <sys/ddi.h>
int prefixmmap(dev_t dev, off_t off, int prot);
Arguments
dev Device whose memory is to be mapped.
off Offset within device memory at which mapping begins.
prot Protection flags from mman.h.
DESCRIPTION
The mmap entry point provides a way to support character
drivers for memory-mapped devices. A memory-mapped device has
memory that can be mapped into a process's address space. The
mmap(2) system call, when applied to a character special file,
allows this device memory to be mapped into user space for
direct access by the user application (this way no kernel
buffering or system call overhead is incurred).
The mmap routine checks if the offset is within the range of
pages supported by the device. For example, a device that has
32K bytes of memory that can be mapped into user space should
not support offsets greater than, or equal to, 32K. If the
offset does not exist, then NOPAGE is returned. If the offset
does exist, the mmap routine returns the physical page ID for
the page at offset off in the device's memory.
Return Values
If the protection and offset are valid for the device, the
driver should return the physical page ID. Otherwise, NOPAGE
should be returned.
USAGE
This entry point is optional, and valid for memory-mapped
character device or character pseudo-device drivers only.
Valid values for prot are:
Copyright 1994 Novell, Inc. Page 1
mmap(D2) mmap(D2)
PROT_READ Page can be read.
PROT_WRITE Page can be written.
PROT_EXEC Page can be executed.
PROT_USER Page is accessible from user-level.
PROT_ALL All of the above.
A physical page ID is a machine-specific token that uniquely
identifies a page of physical memory in the system (either
kernel memory or device memory). To get the physical page ID
for a given virtual address, drivers should use the
hat_getkpfnum(D3) function (on SVR4.0, SVR4.1ES and SVR4.2
systems) or the kvtoppid(D3) function (on SVR4MP and SVR4.2 MP
systems). To get the physical page ID for a given physical
address, drivers should use the hat_getppfnum(D3) function (on
SVR4.0, SVR4.1ES and SVR4.2 systems) or the phystoppid(D3)
function (on SVR4MP and SVR4.2 MP systems).
No assumptions should be made about the format of a physical
page ID.
Synchronization Constraints
The mmap routine has user context and can sleep.
REFERENCES
hat_getkpfnum(D3), hat_getppfnum(D3), kvtoppid(D3), mmap(2),
phystoppid(D3)
NOTICES
Portability
All processors
Applicability
ddi: 1, 2, 3, 4, 5, 5mp, 6, 6mp, 7, 7mp
Copyright 1994 Novell, Inc. Page 2