Merge commit '9276b3991ba20d5a5660887ba81b0bc7bed25a0c'
[unleashed.git] / share / man / man9f / ddi_umem_lock.9f
blobdc7598870aef750b9f66171f2927aeca9c871a03
1 '\" te
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"
7 .SH NAME
8 ddi_umem_lock, ddi_umem_unlock \- lock and unlock memory pages
9 .SH SYNOPSIS
10 .LP
11 .nf
12 #include <sys/ddi.h>
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);
17 .fi
19 .LP
20 .nf
21 \fBvoid\fR \fBddi_umem_unlock\fR(\fBddi_umem_cookie_t\fR \fIcookie\fR);
22 .fi
24 .SH INTERFACE LEVEL
25 .sp
26 .LP
27 Solaris DDI specific (Solaris DDI)
28 .SH PARAMETERS
29 .SS "ddi_umem_lock"
30 .sp
31 .ne 2
32 .na
33 \fB\fIaddr\fR\fR
34 .ad
35 .RS 11n
36 Virtual address of memory object
37 .RE
39 .sp
40 .ne 2
41 .na
42 \fB\fIlen\fR\fR
43 .ad
44 .RS 11n
45 Length of memory object in bytes
46 .RE
48 .sp
49 .ne 2
50 .na
51 \fB\fIflags\fR\fR
52 .ad
53 .RS 11n
54 Valid flags include:
55 .sp
56 .ne 2
57 .na
58 \fBDDI_UMEMLOCK_READ\fR
59 .ad
60 .RS 21n
61 Memory pages are locked to be read from. (Disk write or a network send.)
62 .RE
64 .sp
65 .ne 2
66 .na
67 \fBDDI_UMEMLOCK_WRITE\fR
68 .ad
69 .RS 22n
70 Memory pages are locked to be written to. (Disk read or a network receive.)
71 .RE
73 .RE
75 .sp
76 .ne 2
77 .na
78 \fB\fIcookiep\fR\fR
79 .ad
80 .RS 11n
81 Pointer to a kernel memory cookie.
82 .RE
84 .SS "ddi_umem_unlock"
85 .sp
86 .ne 2
87 .na
88 \fBcookie\fR
89 .ad
90 .RS 10n
91 Kernel memory cookie allocated by \fBddi_umem_lock()\fR.
92 .RE
94 .SH DESCRIPTION
95 .sp
96 .LP
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).
127 .SH RETURN VALUES
130 On success, a \fB0\fR is returned. Otherwise, one of the following \fBerrno\fR
131 values is returned.
133 .ne 2
135 \fB\fBEFAULT\fR\fR
137 .RS 10n
138 User process has no mapping at that address range or does not support locking
142 .ne 2
144 \fB\fBEACCES\fR\fR
146 .RS 10n
147 User process does not have the required permission.
151 .ne 2
153 \fB\fBENOMEM\fR\fR
155 .RS 10n
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.
161 .ne 2
163 \fB\fBEAGAIN\fR\fR
165 .RS 10n
166 Could not allocate system resources required to lock the pages. The
167 \fBddi_umem_lock()\fR could succeed at a later time.
171 .ne 2
173 \fB\fBEINVAL\fR\fR
175 .RS 10n
176 Requested memory is not aligned on a system page boundary.
179 .SH CONTEXT
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.
184 .SH SEE ALSO
187 \fBddi_umem_iosetup\fR(9F), \fBddi_dma_buf_bind_handle\fR(9F),
188 \fBdevmap_umem_setup\fR(9F), \fBddi_umem_alloc\fR(9F)
189 .SH NOTES
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.