'\"macro stdmacro
.if n .pH ddi_dki.mmap @(#)mmap	40.7 of 10/10/89
.\" Copyright 1989 AT&T
.de IX
.ie '\\n(.z'' .tm .Index: \\$1 \\$2 \\$3 \\$4 \\$5 \\$6 \\$7 \\$8 \\$9	\\n%
.el \\!.IX \\$1 \\$2 \\$3 \\$4 \\$5 \\$6 \\$7 \\$8 \\$9
..
.nr X
.if \nX=0 .ds x} mmap D2K "" "DKI" "\&"
.if \nX=1 .ds x} mmap D2K "" "DKI"
.if \nX=2 .ds x} mmap D2K "" "\&"
.if \nX=3 .ds x} mmap "" "" "\&"
.TH \*(x}
.IX "\f4mmap\fP(D2K)"
.SH "NAME"
\f4mmap\f1 \- check virtual mapping for memory mapped device
.SH "SYNOPSIS"
.nf
.na
\f4#include <sys/types.h>
#include <sys/cred.h>
#include <sys/mman.h>
#include <sys/vm.h>
.sp 0.5
int \f2prefix\f4mmap(dev_t \f2dev, \f4off_t\f1 \f2off, \f4int\f1 \f2prot\f4);\f1
.ad
.fi
.SH "ARGUMENTS"
.RS 0n
.IP "\f2dev\f1" 10n
Device whose memory is to be mapped.
.IP "\f2off\f1" 10n
Offset within device memory at which mapping begins.
.IP "\f2prot\f1" 10n
Protection flag from \f4mman.h\f1 (e.g., \f4PROT_WRITE, PROT_READ\f1).
.RE
.SH DESCRIPTION
The \f4mmap\f1 entry point is a required entry point for character
drivers supporting memory-mapped devices.  A memory mapped
device has memory that can be mapped into a process's address space.  The
\f4mmap\f1(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 (no kernel
buffering overhead is required). 
.P
An \f4mmap\f1(D2K) routine checks if each offset is within the range
of pages supported by the device. For example, a device
that has 512 bytes of memory that can be mapped into user space
should not support offsets greater than 512.  If the offset does not
exist, then \f4-1\f1 is returned.  If the offset does exist,
\f4mmap\f1 returns the masked page table entry for the page
at offset \f2off\f1 in the device's memory.
.P
\f4mmap\f1 should only be supported for memory-mapped devices or
pseudo-devices.  See the \f4segmap\f1(D2K) reference page for
further information on memory-mapped device drivers.
.SH "RETURN VALUE"
If the protection and offset are valid for the device, the
driver should return the masked page table
entry, typically obtained using the function
\f4hat_getkpfnum\f1(D3K), for the page at offset \f2off\f1 in the device's
memory.  If not, \f4-1\f1 should be returned.
.SH "SEE ALSO"
.na
\f4segmap\f1(D2K),
\f4hat_getkpfnum\f1(D3K)
.ad
