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"
8 devmap_devmem_setup, devmap_umem_setup \- set driver memory mapping parameters
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);
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);
34 Solaris DDI specific (Solaris DDI).
38 \fBdevmap_devmem_setup()\fR parameters:
45 An opaque mapping handle that the system uses to describe the mapping.
54 Pointer to the device's \fBdev_info\fR structure.
60 \fB\fIcallbackops\fR\fR
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.
74 Index number to the register address space set.
83 Offset into the register address space.
92 Length (in bytes) of the mapping to be mapped.
101 Maximum protection flag possible for attempted mapping. Some combinations of
102 possible settings are:
106 \fB\fBPROT_READ\fR\fR
109 Read access is allowed.
115 \fB\fBPROT_WRITE\fR\fR
118 Write access is allowed.
124 \fB\fBPROT_EXEC\fR\fR
127 Execute access is allowed.
133 \fB\fBPROT_USER\fR\fR
136 User-level access is allowed. The mapping is done as a result of a
137 \fBmmap\fR(2) system call.
146 All access is allowed.
157 Used to determine the cache attribute.
159 Possible values of the cache attribute are:
163 \fB\fBIOMEM_DATA_CACHED\fR\fR
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
174 \fB\fBIOMEM_DATA_UC_WR_COMBINE\fR\fR
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.
187 \fB\fBIOMEM_DATA_UNCACHED\fR\fR
190 The CPU never caches data, but has uncacheable access to memory. Strict
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.
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:
220 An opaque data structure that the system uses to describe the mapping.
229 Pointer to the device's \fBdev_info\fR structure.
235 \fB\fIcallbackops\fR\fR
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
249 A kernel memory \fIcookie\fR (see \fBddi_umem_alloc\fR(9F)).
258 Offset into the kernel memory defined by \fIcookie\fR.
267 Length (in bytes) of the mapping to be mapped.
276 Maximum protection flag possible for attempted mapping. Some combinations of
277 possible settings are:
281 \fB\fBPROT_READ\fR\fR
284 Read access is allowed.
290 \fB\fBPROT_WRITE\fR\fR
293 Write access is allowed.
299 \fB\fBPROT_EXEC\fR\fR
302 Execute access is allowed.
308 \fB\fBPROT_USER\fR\fR
311 User-level access is allowed (the mapping is being done as a result of a
312 \fBmmap\fR(2) system call).
321 All access is allowed.
332 Must be set to \fB0\fR.
341 Pointer to a \fBddi_device_acc_attr\fR(9S) structure. Ignored in the current
342 release. Reserved for future use.
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
367 User has called \fBmmap\fR(2) to create a mapping to the device memory.
376 User has accessed an address in the mapping that has no translations.
385 User has duplicated the mapping. Mappings are duplicated when the process calls
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
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
447 Successful completion.
462 \fBdevmap_devmem_setup()\fR and \fBdevmap_umem_setup()\fR can be called from
463 user, kernel, and interrupt context.
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