2 .\" Copyright (c) 1996, Sun Microsystems, Inc. All Rights Reserved
3 .\" The contents of this file are subject to the terms of the Common Development and Distribution License (the "License"). You may not use this file except in compliance with the License.
4 .\" You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE or http://www.opensolaris.org/os/licensing. See the License for the specific language governing permissions and limitations under the License.
5 .\" When distributing Covered Code, include this CDDL HEADER in each file and include the License file at usr/src/OPENSOLARIS.LICENSE. If applicable, add the following below this CDDL HEADER, with the fields enclosed by brackets "[]" replaced with your own identifying information: Portions Copyright [yyyy] [name of copyright owner]
6 .TH DEVMAP_SETUP 9F "Jan 22, 1997"
8 devmap_setup, ddi_devmap_segmap \- set up a user mapping to device memory using
14 #include <sys/sunddi.h>
18 \fBint\fR \fBdevmap_setup\fR(\fBdev_t\fR \fIdev\fR, \fBoffset_t\fR \fIoff\fR, \fBddi_as_handle_t\fR \fIas\fR,
19 \fBcaddr_t *\fR\fIaddrp\fR, \fBsize_t\fR\fIlen\fR, \fBuint_t\fR \fIprot\fR, \fBuint_t\fR \fImaxprot\fR,
20 \fBuint_t\fR \fIflags\fR, \fBcred_t *\fR\fIcred\fR);
25 \fBint\fR \fBddi_devmap_segmap\fR(\fBdev_t\fR \fIdev\fR, \fBoff_t\fR \fIoff\fR, \fBddi_as_handle_t\fR \fIas\fR,
26 \fBcaddr_t *\fR\fIaddrp\fR, \fBoff_t\fR\fIlen\fR, \fBuint_t\fR \fIprot\fR, \fBuint_t\fR \fImaxprot\fR,
27 \fBuint_t\fR \fIflags\fR, \fBcred_t *\fR\fIcred\fR);
33 Solaris DDI specific (Solaris DDI).
41 Device whose memory is to be mapped.
50 User offset within the logical device memory at which the mapping begins.
59 An opaque data structure that describes the address space into which the device
60 memory should be mapped.
69 Pointer to the starting address in the address space into which the device
70 memory should be mapped.
79 Length (in bytes) of the memory to be mapped.
88 A bit field that specifies the protections. Some possible settings combinations
93 \fB\fBPROT_READ\fR \fR
96 Read access is desired.
102 \fB\fBPROT_WRITE\fR \fR
105 Write access is desired.
111 \fB\fBPROT_EXEC\fR \fR
114 Execute access is desired.
120 \fB\fBPROT_USER\fR \fR
123 User-level access is desired (the mapping is being done as a result of a
124 \fBmmap\fR(2) system call).
130 \fB\fBPROT_ALL\fR \fR
133 All access is desired.
144 Maximum protection flag possible for attempted mapping; the \fBPROT_WRITE\fR
145 bit may be masked out if the user opened the special file read-only.
154 Flags indicating type of mapping. The following flags can be specified:
158 \fB\fBMAP_PRIVATE\fR \fR
167 \fB\fBMAP_SHARED\fR \fR
170 Changes should be shared.
176 \fB\fBMAP_FIXED\fR \fR
179 The user specified an address in \fI*addrp\fR rather than letting the system
191 Pointer to the user credential structure.
197 \fBdevmap_setup()\fR and \fBddi_devmap_segmap()\fR allow device drivers to use
198 the devmap framework to set up user mappings to device memory. The devmap
199 framework provides several advantages over the default device mapping framework
200 that is used by \fBddi_segmap\fR(9F) or \fBddi_segmap_setup\fR(9F). Device
201 drivers should use the devmap framework, if the driver wants to:
206 use an optimal MMU pagesize to minimize address translations,
212 conserve kernel resources,
218 receive callbacks to manage events on the mapping,
224 export kernel memory to applications,
230 set up device contexts for the user mapping if the device requires context
237 assign device access attributes to the user mapping, or
243 change the maximum protection for the mapping.
247 \fBdevmap_setup()\fR must be called in the \fBsegmap\fR(9E) entry point to
248 establish the mapping for the application. \fBddi_devmap_segmap()\fR can be
249 called in, or be used as, the \fBsegmap\fR(9E) entry point. The differences
250 between \fBdevmap_setup()\fR and \fBddi_devmap_segmap()\fR are in the data
251 type used for \fIoff\fR and \fIlen\fR.
254 When setting up the mapping, \fBdevmap_setup()\fR and
255 \fBddi_devmap_segmap()\fR call the \fBdevmap\fR(9E) entry point to validate the
256 range to be mapped. The \fBdevmap\fR(9E) entry point also translates the
257 logical offset (as seen by the application) to the corresponding physical
258 offset within the device address space. If the driver does not provide its own
259 \fBdevmap\fR(9E) entry point, \fBEINVAL\fR will be returned to the
260 \fBmmap\fR(2) system call.
268 Successful completion.
277 An error occurred. The return value of \fBdevmap_setup()\fR and
278 \fBddi_devmap_segmap()\fR should be used directly in the \fBsegmap\fR(9E)
285 \fBdevmap_setup()\fR and \fBddi_devmap_segmap()\fR can be called from user or
290 \fBmmap\fR(2), \fBdevmap\fR(9E), \fBsegmap\fR(9E), \fBddi_segmap\fR(9F),
291 \fBddi_segmap_setup\fR(9F), \fBcb_ops\fR(9S)
294 \fIWriting Device Drivers\fR