man Pages(9E): DDI and DKI Driver Entry Points
  Search only this book
Download this book in PDF

NAME

mmap - check virtual mapping for memory mapped device

SYNOPSIS

#include <sys/types.h>
#include <sys/cred.h>
#include <sys/mman.h>
#include <sys/vm.h>
#include <sys/ddi.h>
#include <sys/sunddi.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
A bit field that specifies the protections this page of memory will receive. Possible settings are:
PROT_READ
Read access will be granted.
PROT_WRITE Write access will be granted.
PROT_EXEC
Execute access will be granted.
PROT_USER
User-level access will be granted.
PROT_ALL
All access will be granted.

INTERFACE LEVEL

Architecture independent level 1 (DDI/DKI).

DESCRIPTION

The mmap( ) 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 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.
An mmap( ) routine checks if the 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 -1 is returned. If the offset does exist, mmap( ) returns the value returned by hat_getkpfnum(9F) for the page at offset off in the device's memory.
mmap( ) should only be supported for memory-mapped devices. See the segmap (9E) reference page for further information on memory-mapped device drivers.

RETURN VALUES

If the protection and offset are valid for the device, the driver should return the value returned by hat_getkpfnum(9F), for the page at offset off in the device's memory. If not, -1 should be returned.

SEE ALSO

mmap(2), hat_getkpfnum(9F), segmap (9E)
Writing Device Drivers