DOC HOME SITE MAP MAN PAGES GNU INFO SEARCH PRINT BOOK
 
SVR5

drv_mmap(D3)


drv_mmap -- map device memory into user space

Synopsis (Not in current DDI version)

   #include <sys/types.h>
   #include <sys/mman.h>
   #include <sys/ddi.h>
   

int drv_mmap(vaddr_t vaddr, paddr_t paddr, size_t len, vaddr_t *uvaddrp, uint_t prot, uint_t maxprot, uint_t flags)

Description

The drv_mmap( ) function provides a convenient interface for setting up a user mapping to a range of kernel virtual or physical addresses.

Arguments


vaddr
Kernel address of the object to be mapped. If vaddr is non-zero, it is the kernel address of the object to be mapped (and paddr is ignored). Otherwise, paddr is the physical address of the object.

paddr
paddr is the physical address of the object to be mapped.

len
Number of bytes to map into user space.

*uvaddrp
User address at which to map the object. If the MAP_FIXED flag is set, the value passed in *uvaddrp is used as the address; otherwise, the kernel assigns an address.

prot
Initial protection flags. This determines whether read, write, execute, or some combination of these accesses are permitted to the pages being mapped. The protection options are:

PROT_READ
Page can be read.

PROT_WRITE
Page can be written.

PROT_EXEN
Page can be executed.

PROT_NONE
Page cannot be accessed.

maxprot
Maximum protection. This is similar to prot, but specifies the maximum permissions the user can subsequently assign through mprotect.

flags
Specifies whether the user address is supplied by the driver or the kernel. If the MAP_FIXED flag is used, *uvaddrp is used as the user address at which to map the object; any previous mapping at this address will be replaced. Otherwise, the kernel chooses a currently unused user address and place it into *uvaddrp.

Return values

If the parameters are valid, drv_mmap( ) returns with the user address for the object map in *uvaddrp, and returns 0. Otherwise, a non-zero errno is returned.

Usage

A typical use for drv_mmap( ) is for video frame buffers mapped through ioctls rather than of mmap(D2) for compatibility with pre-SVR4 applications.

Note that the mapping is at a page granularity. You can pass in addresses and lengths that are not page-aligned, but the user will have access to entire pages.

Not all implementations literally provide all possible combinations. For example, PROT_WRITE is often implemented as PROT_READ|PROT_WRITE and PROT_EXEC as PROT_READ|PROT_EXEC. However, no implementation permits a write to succeed if PROT_WRITE has not been set, because it might still be set from a previous operation.

To release a mapping acquired by drv_mmap( ), use drv_munmap(D3).

Context and synchronization

User context.

Hardware applicability

All

Version applicability

ddi: 5, 5mp, 6, 6mp, 7, 7mp, 7.1, 7.1mp

Differences between versions

This function was removed from the DDI 8 definition because of implementation difficulties involved in providing support for DMA access of memory greater than 4GB. The drv_munmap(D3) function was not removed from DDI 8, although it is rendered meaningless without drv_mmap( ).

Future directions

SCO expects to restore drv_mmap( ) functionality in a DDI version after version 8.

References

drv_munmap(D3), mmap(D2)
19 June 2005
© 2005 The SCO Group, Inc. All rights reserved.
OpenServer 6 and UnixWare (SVR5) HDK - June 2005