Merge commit '9276b3991ba20d5a5660887ba81b0bc7bed25a0c'
[unleashed.git] / share / man / man9f / devmap_devmem_setup.9f
blobb7c36e80877ed03f12b646f0b432be9db1fad80a
1 '\" te
2 .\"  Copyright (c) 2006, 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_DEVMEM_SETUP 9F "Jun 05, 2006"
7 .SH NAME
8 devmap_devmem_setup, devmap_umem_setup \- set driver memory mapping parameters
9 .SH SYNOPSIS
10 .LP
11 .nf
12 #include <sys/ddi.h>
13 #include <sys/sunddi.h>
17 \fBint\fR \fBdevmap_devmem_setup\fR(\fBdevmap_cookie_t\fR \fIdhp\fR, \fBdev_info_t *\fR\fIdip\fR,
18      \fBstruct devmap_callback_ctl *\fR\fIcallbackops\fR, \fBuint_t\fR \fIrnumber\fR,
19      \fBoffset_t\fR \fIroff\fR,  \fBsize_t\fR \fIlen\fR, \fBuint_t\fR \fImaxprot\fR,
20      \fBuint_t\fR \fIflags\fR, \fBddi_device_acc_attr_t *\fR\fIaccattrp\fR);
21 .fi
23 .LP
24 .nf
25 \fBint\fR \fBdevmap_umem_setup\fR(\fBdevmap_cookie_t\fR \fIdhp\fR, \fBdev_info_t *\fR\fIdip\fR,
26      \fBstruct devmap_callback_ctl *\fR\fIcallbackops\fR, \fBddi_umem_cookie_t\fR \fIcookie\fR,
27      \fBoffset_t\fR \fIkoff\fR, \fBsize_t\fR \fIlen\fR, \fBuint_t\fR \fImaxprot\fR, \fBuint_t\fR \fIflags\fR,
28      \fBddi_device_acc_attr_t *\fR\fIaccattrp\fR);
29 .fi
31 .SH INTERFACE LEVEL
32 .sp
33 .LP
34 Solaris DDI specific (Solaris DDI).
35 .SH PARAMETERS
36 .sp
37 .LP
38 \fBdevmap_devmem_setup()\fR parameters:
39 .sp
40 .ne 2
41 .na
42 \fB\fIdhp\fR\fR
43 .ad
44 .RS 15n
45 An opaque mapping handle that the system uses to describe the mapping.
46 .RE
48 .sp
49 .ne 2
50 .na
51 \fB\fIdip\fR\fR
52 .ad
53 .RS 15n
54 Pointer to the device's \fBdev_info\fR structure.
55 .RE
57 .sp
58 .ne 2
59 .na
60 \fB\fIcallbackops\fR\fR
61 .ad
62 .RS 15n
63 Pointer to a \fBdevmap_callback_ctl\fR(9S) structure. The structure contains
64 pointers to device driver-supplied functions that manage events on the device
65 mapping. The framework will copy the structure to the system private memory.
66 .RE
68 .sp
69 .ne 2
70 .na
71 \fB\fIrnumber\fR\fR
72 .ad
73 .RS 15n
74 Index number to the register address space set.
75 .RE
77 .sp
78 .ne 2
79 .na
80 \fB\fIroff\fR\fR
81 .ad
82 .RS 15n
83 Offset into the register address space.
84 .RE
86 .sp
87 .ne 2
88 .na
89 \fB\fIlen\fR\fR
90 .ad
91 .RS 15n
92 Length (in bytes) of the mapping to be mapped.
93 .RE
95 .sp
96 .ne 2
97 .na
98 \fB\fImaxprot\fR\fR
99 .ad
100 .RS 15n
101 Maximum protection flag possible for attempted mapping. Some combinations of
102 possible settings are:
104 .ne 2
106 \fB\fBPROT_READ\fR\fR
108 .RS 14n
109 Read access is allowed.
113 .ne 2
115 \fB\fBPROT_WRITE\fR\fR
117 .RS 14n
118 Write access is allowed.
122 .ne 2
124 \fB\fBPROT_EXEC\fR\fR
126 .RS 14n
127 Execute access is allowed.
131 .ne 2
133 \fB\fBPROT_USER\fR\fR
135 .RS 14n
136 User-level access is allowed. The mapping is done as a result of a
137 \fBmmap\fR(2) system call.
141 .ne 2
143 \fB\fBPROT_ALL\fR\fR
145 .RS 14n
146 All access is allowed.
152 .ne 2
154 \fB\fIflags\fR\fR
156 .RS 15n
157 Used to determine the cache attribute.
159 Possible values of the cache attribute are:
161 .ne 2
163 \fB\fBIOMEM_DATA_CACHED\fR\fR
165 .RS 28n
166 The CPU can cache the data it fetches and push it to memory at a later time.
167 This is the default attribute that is used if no cache attributes are
168 specified.
172 .ne 2
174 \fB\fBIOMEM_DATA_UC_WR_COMBINE\fR\fR
176 .RS 28n
177 The CPU never caches the data, but writes can occur out of order or can be
178 combined. Reordering is implied.
180 If \fBIOMEM_DATA_UC_WR_COMBINE\fR is specified but not supported,
181 \fBIOMEM_DATA_UNCACHED\fR is used instead.
185 .ne 2
187 \fB\fBIOMEM_DATA_UNCACHED\fR\fR
189 .RS 28n
190 The CPU never caches data, but has uncacheable access to memory. Strict
191 ordering is implied.
194 The cache attributes are mutually exclusive. Any combination of the values
195 leads to a failure. On the SPARC architecture, only \fBIOMEM_DATA_CACHED\fR is
196 meaningful. Others lead to a failure.
200 .ne 2
202 \fB\fIaccattrp\fR\fR
204 .RS 15n
205 Pointer to a \fBddi_device_acc_attr()\fR structure of the device. See
206 \fBddi_device_acc_attr\fR(9S). The value in \fBdevacc_attr_dataorder\fR is
207 ignored in the current release. The value in \fBdevacc_attr_endian_flags\fR is
208 meaningful on the SPARC architecture only.
213 \fBdevmap_umem_setup()\fR parameters:
215 .ne 2
217 \fB\fIdhp\fR\fR
219 .RS 15n
220 An opaque data structure that the system uses to describe the mapping.
224 .ne 2
226 \fB\fIdip\fR\fR
228 .RS 15n
229 Pointer to the device's \fBdev_info\fR structure.
233 .ne 2
235 \fB\fIcallbackops\fR\fR
237 .RS 15n
238 Pointer to a \fBdevmap_callback_ctl\fR(9S) structure. The structure contains
239 pointers to device driver-supplied functions that manage events on the device
240 mapping.
244 .ne 2
246 \fB\fIcookie\fR\fR
248 .RS 15n
249 A kernel memory \fIcookie\fR (see \fBddi_umem_alloc\fR(9F)).
253 .ne 2
255 \fB\fIkoff\fR\fR
257 .RS 15n
258 Offset into the kernel memory defined by \fIcookie\fR.
262 .ne 2
264 \fB\fIlen\fR\fR
266 .RS 15n
267 Length (in bytes) of the mapping to be mapped.
271 .ne 2
273 \fB\fImaxprot\fR\fR
275 .RS 15n
276 Maximum protection flag possible for attempted mapping. Some combinations of
277 possible settings are:
279 .ne 2
281 \fB\fBPROT_READ\fR\fR
283 .RS 14n
284 Read access is allowed.
288 .ne 2
290 \fB\fBPROT_WRITE\fR\fR
292 .RS 14n
293 Write access is allowed.
297 .ne 2
299 \fB\fBPROT_EXEC\fR\fR
301 .RS 14n
302 Execute access is allowed.
306 .ne 2
308 \fB\fBPROT_USER\fR\fR
310 .RS 14n
311 User-level access is allowed (the mapping is being done as a result of a
312 \fBmmap\fR(2) system call).
316 .ne 2
318 \fB\fBPROT_ALL\fR\fR
320 .RS 14n
321 All access is allowed.
327 .ne 2
329 \fB\fIflags\fR\fR
331 .RS 15n
332 Must be set to \fB0\fR.
336 .ne 2
338 \fB\fIaccattrp\fR\fR
340 .RS 15n
341 Pointer to a \fBddi_device_acc_attr\fR(9S) structure. Ignored in the current
342 release. Reserved for future use.
345 .SH DESCRIPTION
348 The \fBdevmap_devmem_setup()\fR and \fBdevmap_umem_setup()\fR functions are
349 used in the \fBdevmap\fR(9E) entry point to pass mapping parameters from the
350 driver to the system.
353 The \fIdhp\fR argument specifies a device mapping handle that the system uses
354 to store all mapping parameters of a physical contiguous memory. The system
355 copies the data pointed to by \fIcallbackops\fR to a system private memory.
356 This allows the driver to free the data after returning from either
357 \fBdevmap_devmem_setup()\fR or \fBdevmap_umem_setup()\fR. The driver is
358 notified of user events on the mappings via the entry points defined by
359 \fBdevmap_callback_ctl\fR(9S). The driver is notified of the following user
360 events:
362 .ne 2
364 \fBMapping Setup\fR
366 .RS 17n
367 User has called \fBmmap\fR(2) to create a mapping to the device memory.
371 .ne 2
373 \fBAccess\fR
375 .RS 17n
376 User has accessed an address in the mapping that has no translations.
380 .ne 2
382 \fBDuplication\fR
384 .RS 17n
385 User has duplicated the mapping. Mappings are duplicated when the process calls
386 \fBfork\fR(2).
390 .ne 2
392 \fBUnmapping\fR
394 .RS 17n
395 User has called \fBmunmap\fR(2) on the mapping or is exiting, \fBexit\fR(2).
400 See \fBdevmap_map\fR(9E), \fBdevmap_access\fR(9E), \fBdevmap_dup\fR(9E), and
401 \fBdevmap_unmap\fR(9E) for details on these entry points.
404 By specifying a valid \fIcallbackops\fR to the system, device drivers can
405 manage events on a device mapping. For example, the \fBdevmap_access\fR(9E)
406 entry point allows the drivers to perform context switching by unloading the
407 mappings of other processes and to load the mapping of the calling process.
408 Device drivers may specify \fINULL\fR to \fIcallbackops\fR which means the
409 drivers do not want to be notified by the system.
412 The maximum protection allowed for the mapping is specified in \fImaxprot\fR.
413 \fIaccattrp\fR defines the device access attributes. See
414 \fBddi_device_acc_attr\fR(9S) for more details.
417 \fBdevmap_devmem_setup()\fR is used for device memory to map in the register
418 set given by \fIrnumber\fR and the offset into the register address space given
419 by \fIroff\fR. The system uses \fIrnumber\fR and \fIroff\fR to go up the device
420 tree to get the physical address that corresponds to \fIroff\fR. The range to
421 be affected is defined by \fIlen\fR and \fIroff\fR. The range from \fIroff\fR
422 to \fIroff\fR \fI+\fR \fIlen\fR must be a physical contiguous memory and page
423 aligned.
426 Drivers use \fBdevmap_umem_setup()\fR for kernel memory to map in the kernel
427 memory described by \fIcookie\fR and the offset into the kernel memory space
428 given by \fIkoff\fR. \fIcookie\fR is a kernel memory pointer obtained from
429 \fBddi_umem_alloc\fR(9F). If \fIcookie\fR is \fINULL,\fR
430 \fBdevmap_umem_setup()\fR returns \fB-1.\fR The range to be affected is defined
431 by \fIlen\fR and \fIkoff\fR. The range from \fIkoff\fR to \fIkoff\fR \fI+\fR
432 \fIlen\fR must be within the limits of the kernel memory described by
433 \fIkoff\fR \fI+\fR \fIlen\fR and must be page aligned.
436 Drivers use \fBdevmap_umem_setup()\fR to export the kernel memory allocated by
437 \fBddi_umem_alloc\fR(9F) to user space. The system selects a user virtual
438 address that is aligned with the kernel virtual address being mapped to avoid
439 cache incoherence if the mapping is not \fBMAP_FIXED.\fR
440 .SH RETURN VALUES
442 .ne 2
444 \fB\fB0\fR\fR
446 .RS 6n
447 Successful completion.
451 .ne 2
453 \fB\fB-1\fR\fR
455 .RS 6n
456 An error occurred.
459 .SH CONTEXT
462 \fBdevmap_devmem_setup()\fR and \fBdevmap_umem_setup()\fR can be called from
463 user, kernel, and interrupt context.
464 .SH SEE ALSO
467 \fBexit\fR(2), \fBfork\fR(2), \fBmmap\fR(2), \fBmunmap\fR(2), \fBdevmap\fR(9E),
468 \fBddi_umem_alloc\fR(9F), \fBddi_device_acc_attr\fR(9S),
469 \fBdevmap_callback_ctl\fR(9S)
472 \fIWriting Device Drivers\fR