2 .\" Copyright (c) 2007, 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 DDI_UMEM_LOCK 9F "Apr 10, 2007"
8 ddi_umem_lock, ddi_umem_unlock \- lock and unlock memory pages
13 #include <sys/sunddi.h>
15 \fBint\fR \fBddi_umem_lock\fR(\fBcaddr_t\fR \fIaddr\fR, \fBsize_t\fR \fIlen\fR, \fBint\fR \fIflags\fR,
16 \fBddi_umem_cookie_t\fR *\fIcookiep\fR);
21 \fBvoid\fR \fBddi_umem_unlock\fR(\fBddi_umem_cookie_t\fR \fIcookie\fR);
27 Solaris DDI specific (Solaris DDI)
36 Virtual address of memory object
45 Length of memory object in bytes
58 \fBDDI_UMEMLOCK_READ\fR
61 Memory pages are locked to be read from. (Disk write or a network send.)
67 \fBDDI_UMEMLOCK_WRITE\fR
70 Memory pages are locked to be written to. (Disk read or a network receive.)
81 Pointer to a kernel memory cookie.
91 Kernel memory cookie allocated by \fBddi_umem_lock()\fR.
97 The \fBddi_umem_lock()\fR function locks down the physical pages (including I/O
98 pages) that correspond to the current process' virtual address range
99 [\fIaddr\fR, \fIaddr\fR + \fIsize\fR) and fills in a cookie representing the
100 locked pages. This cookie can be used to create a \fBbuf\fR(9S) structure that
101 can be used to perform I/O (see \fBddi_umem_iosetup\fR(9F) and
102 \fBddi_dma_buf_bind_handle\fR(9F), or it can be used with
103 \fBdevmap_umem_setup\fR(9F) to export the memory to an application.
106 The virtual address and length specified must be at a page boundary and the
107 mapping performed in terms of the system page size. See \fBpagesize\fR(1).
110 The flags argument indicates the intended use of the locked memory. Set flags
111 to \fBDDI_UMEMLOCK_READ\fR if the memory pages will be read (for example, in a
112 disk write or a network send.) Set flags to \fBDDI_UMEMLOCK_WRITE\fR if the
113 memory pages will be written (for example, in a disk read or a network
114 receive). You must choose one (and only one) of these values.
117 To unlock the locked pages, the drivers call \fBddi_umem_unlock(9F)\fR with the
118 cookie obtained from \fBddi_umem_lock()\fR.
121 The process is not allowed to \fBexec\fR(2) or \fBfork\fR(2) while its physical
122 pages are locked down by the device driver.
125 The device driver must ensure that the physical pages have been unlocked after
126 the application has called \fBclose\fR(2).
130 On success, a \fB0\fR is returned. Otherwise, one of the following \fBerrno\fR
138 User process has no mapping at that address range or does not support locking
147 User process does not have the required permission.
156 The system does not have sufficient resources to lock memory, or locking
157 \fIlen\fR memory would exceed a limit or resource control on locked memory.
166 Could not allocate system resources required to lock the pages. The
167 \fBddi_umem_lock()\fR could succeed at a later time.
176 Requested memory is not aligned on a system page boundary.
182 The \fBddi_umem_lock()\fR function can only be called from user context;
183 \fBddi_umem_unlock()\fR from user, kernel, and interrupt contexts.
187 \fBddi_umem_iosetup\fR(9F), \fBddi_dma_buf_bind_handle\fR(9F),
188 \fBdevmap_umem_setup\fR(9F), \fBddi_umem_alloc\fR(9F)
192 The \fBddi_umem_unlock()\fR function consumes physical memory. The driver is
193 responsible for a speedy unlock to free up the resources.
196 The \fBddi_umem_unlock()\fR function can defer unlocking of the pages to a
197 later time depending on the implementation.