Writing Device Drivers

Entry Points for Memory Mapped Devices

For certain devices, such as frame buffers, providing application programs with direct access to device memory is more efficient than byte-stream I/O. Applications can map device memory into their address spaces using the mmap(2) system call. To support memory mapping, device drivers implement segmap(9E) and devmap(9E) entry points. For information on devmap(9E), see Chapter 10, Mapping Device and Kernel Memory. For information on segmap(9E), see Chapter 15, Drivers for Character Devices.

Drivers that define the devmap(9E) entry point usually do not define read(9E) and write(9E) entry points, because application programs perform I/O directly to the devices after calling mmap(2).

The following table lists additional entry points that can be used by character device drivers that use the devmap framework to perform memory mapping. For other entry points, see Entry Points Common to All Drivers and Entry Points for Character Device Drivers.

Table 1–5 Entry Points for Character Drivers That Use devmap for Memory Mapping

Entry Point 

Usage 

Description 

devmap(9E)

Required 

Validates and translates virtual mapping for a memory-mapped device. Additional information: Exporting the Mapping

devmap_access(9E)

Optional 

Notifies drivers when an access is made to a mapping with validation or protection problems. Additional information: devmap_access() Entry Point

devmap_contextmgt(9E)

Required 

Performs device context switching on a mapping. Additional information: devmap_contextmgt() Entry Point

devmap_dup(9E)

Optional 

Duplicates a device mapping. Additional information: devmap_dup() Entry Point

devmap_map(9E)

Optional 

Creates a device mapping. Additional information: devmap_map() Entry Point

devmap_unmap(9E)

Optional 

Cancels a device mapping. Additional information: devmap_unmap() Entry Point