The devmap(9E) entry point is called as a result of the mmap(2) system call. devmap(9E) is used to:
Validate the user mapping to the device or kernel memory.
Translate the logical offset within the application mapping to the corresponding offset within the device or kernel memory.
Pass the mapping information to the system for setting up the mapping.
int devmap(dev_t dev, devmap_cookie_t handle, offset_t off, size_t len, size_t *maplen, uint_t model);
Device whose memory is to be mapped
Device-mapping handle that the system creates and uses to describe a mapping to contiguous device or kernel memory
Logical offset within the application mapping which has to be translated by the driver to the corresponding offset within the device or kernel memory
Length (in bytes) of the memory being mapped.
Allows driver to associate different kernel memory regions or multiple physically discontiguous memory regions with one contiguous user application mapping
Data model type of the current thread
The system creates multiple mapping handles in one mmap(2) system call (for example, if the mapping contains multiple physically discontiguous memory regions).
Initially devmap(9E) is called with parameters off and len, which were passed by the application to mmap(2). devmap(9E) sets *maplen to the length from off to the end of a contiguous memory region. *maplen must be rounded up to a multiple of a page size. If *maplen is set to less than the original mapping length len, the system will repeatedly call devmap(9E) with a new mapping handle and adjusted off and len parameters until the initial mapping length is satisfied.
If a driver supports multiple application data models, model has to be passed to ddi_model_convert_from(9F) to determine whether there is a data model mismatch between the current thread and the device driver. The device driver might have to adjust the shape of data structures before exporting them to a user thread that supports a different data model. See Appendix C, Making a Device Driver 64-Bit Ready for more details.
devmap(9E) must return -1 if the logical offset, off, is out of the range of memory exported by the driver.