Merge commit '9276b3991ba20d5a5660887ba81b0bc7bed25a0c'
[unleashed.git] / share / man / man9f / devmap_setup.9f
blob2c0182899b76e8697eb10c3cd51b008494f9d9b3
1 '\" te
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"
7 .SH NAME
8 devmap_setup, ddi_devmap_segmap \- set up a user mapping to device memory using
9 the devmap framework
10 .SH SYNOPSIS
11 .LP
12 .nf
13 #include <sys/ddi.h>
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);
21 .fi
23 .LP
24 .nf
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);
28 .fi
30 .SH INTERFACE LEVEL
31 .sp
32 .LP
33 Solaris DDI specific (Solaris DDI).
34 .SH PARAMETERS
35 .sp
36 .ne 2
37 .na
38 \fB\fIdev\fR \fR
39 .ad
40 .RS 12n
41 Device whose memory is to be mapped.
42 .RE
44 .sp
45 .ne 2
46 .na
47 \fB\fIoff\fR \fR
48 .ad
49 .RS 12n
50 User offset within the logical device memory at which the mapping begins.
51 .RE
53 .sp
54 .ne 2
55 .na
56 \fB\fIas\fR \fR
57 .ad
58 .RS 12n
59 An opaque data structure that describes the address space into which the device
60 memory should be mapped.
61 .RE
63 .sp
64 .ne 2
65 .na
66 \fB\fIaddrp\fR \fR
67 .ad
68 .RS 12n
69 Pointer to the starting address in the address space into which the device
70 memory should be mapped.
71 .RE
73 .sp
74 .ne 2
75 .na
76 \fB\fIlen\fR \fR
77 .ad
78 .RS 12n
79 Length (in bytes) of the memory to be mapped.
80 .RE
82 .sp
83 .ne 2
84 .na
85 \fB\fIprot\fR \fR
86 .ad
87 .RS 12n
88 A bit field that specifies the protections. Some possible settings combinations
89 are:
90 .sp
91 .ne 2
92 .na
93 \fB\fBPROT_READ\fR \fR
94 .ad
95 .RS 15n
96 Read access is desired.
97 .RE
99 .sp
100 .ne 2
102 \fB\fBPROT_WRITE\fR \fR
104 .RS 15n
105 Write access is desired.
109 .ne 2
111 \fB\fBPROT_EXEC\fR \fR
113 .RS 15n
114 Execute access is desired.
118 .ne 2
120 \fB\fBPROT_USER\fR \fR
122 .RS 15n
123 User-level access is desired (the mapping is being done as a result of a
124 \fBmmap\fR(2) system call).
128 .ne 2
130 \fB\fBPROT_ALL\fR \fR
132 .RS 15n
133 All access is desired.
139 .ne 2
141 \fB\fImaxprot\fR \fR
143 .RS 12n
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.
149 .ne 2
151 \fB\fIflags\fR \fR
153 .RS 12n
154 Flags indicating type of mapping. The following flags can be specified:
156 .ne 2
158 \fB\fBMAP_PRIVATE\fR \fR
160 .RS 16n
161 Changes are private.
165 .ne 2
167 \fB\fBMAP_SHARED\fR \fR
169 .RS 16n
170 Changes should be shared.
174 .ne 2
176 \fB\fBMAP_FIXED\fR \fR
178 .RS 16n
179 The user specified an address in  \fI*addrp\fR rather than letting the system
180 choose an address.
186 .ne 2
188 \fB\fIcred\fR \fR
190 .RS 12n
191 Pointer to the user credential structure.
194 .SH DESCRIPTION
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:
202 .RS +4
204 .ie t \(bu
205 .el o
206 use an optimal MMU pagesize to minimize address translations,
208 .RS +4
210 .ie t \(bu
211 .el o
212 conserve kernel resources,
214 .RS +4
216 .ie t \(bu
217 .el o
218 receive callbacks to manage events on the mapping,
220 .RS +4
222 .ie t \(bu
223 .el o
224 export kernel memory to applications,
226 .RS +4
228 .ie t \(bu
229 .el o
230 set up device contexts for the user mapping if the device requires context
231 switching,
233 .RS +4
235 .ie t \(bu
236 .el o
237 assign device access attributes to the user mapping, or
239 .RS +4
241 .ie t \(bu
242 .el o
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.
261 .SH RETURN VALUES
263 .ne 2
265 \fB\fB0\fR \fR
267 .RS 12n
268 Successful completion.
272 .ne 2
274 \fB\fBNon-zero\fR\fR
276 .RS 12n
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)
279 entry point.
282 .SH CONTEXT
285 \fBdevmap_setup()\fR and \fBddi_devmap_segmap()\fR can be called from user or
286 kernel context only.
287 .SH SEE ALSO
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