Unleashed v1.4
[unleashed.git] / share / man / man9f / ddi_dma_addr_bind_handle.9f
blob71f9a003549caa356e054135994844b19b5c44d6
1 '\" te
2 .\"  Copyright (c) 2003 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_DMA_ADDR_BIND_HANDLE 9F "Jul 26, 1996"
7 .SH NAME
8 ddi_dma_addr_bind_handle \- binds an address to a DMA handle
9 .SH SYNOPSIS
10 .LP
11 .nf
12 #include <sys/ddi.h>
13 #include <sys/sunddi.h>
17 \fBint\fR \fBddi_dma_addr_bind_handle\fR(\fBddi_dma_handle_t\fR \fIhandle\fR, \fBstruct as *\fR\fIas\fR,
18      \fBcaddr_t\fR \fIaddr\fR, \fBsize_t\fR \fIlen\fR, \fBuint_t\fR \fIflags\fR, \fBint (*\fR\fIcallback\fR) (caddr_t) ,
19      \fBcaddr_t\fR \fIarg\fR, \fBddi_dma_cookie_t *\fR\fIcookiep\fR, \fBuint_t *\fR\fIccountp\fR);
20 .fi
22 .SH INTERFACE LEVEL
23 .sp
24 .LP
25 Solaris DDI specific (Solaris DDI).
26 .SH PARAMETERS
27 .sp
28 .ne 2
29 .na
30 \fB\fIhandle\fR \fR
31 .ad
32 .RS 13n
33 The  \fBDMA\fR handle previously allocated by a call to
34 \fBddi_dma_alloc_handle\fR(9F).
35 .RE
37 .sp
38 .ne 2
39 .na
40 \fB\fIas\fR \fR
41 .ad
42 .RS 13n
43 A pointer to an address space structure. This parameter should be set to
44 \fINULL\fR, which implies kernel address space.
45 .RE
47 .sp
48 .ne 2
49 .na
50 \fB\fIaddr\fR \fR
51 .ad
52 .RS 13n
53 Virtual address of the memory object.
54 .RE
56 .sp
57 .ne 2
58 .na
59 \fB\fIlen\fR \fR
60 .ad
61 .RS 13n
62 Length of the memory object in bytes.
63 .RE
65 .sp
66 .ne 2
67 .na
68 \fB\fIflags\fR \fR
69 .ad
70 .RS 13n
71 Valid flags include:
72 .sp
73 .ne 2
74 .na
75 \fB\fBDDI_DMA_WRITE\fR \fR
76 .ad
77 .RS 23n
78 Transfer direction is from memory to I/O.
79 .RE
81 .sp
82 .ne 2
83 .na
84 \fB\fBDDI_DMA_READ\fR \fR
85 .ad
86 .RS 23n
87 Transfer direction is from I/O to memory.
88 .RE
90 .sp
91 .ne 2
92 .na
93 \fB\fBDDI_DMA_RDWR\fR \fR
94 .ad
95 .RS 23n
96 Both read and write.
97 .RE
99 .sp
100 .ne 2
102 \fB\fBDDI_DMA_REDZONE\fR \fR
104 .RS 23n
105 Establish an \fBMMU\fR redzone at end of the object.
109 .ne 2
111 \fB\fBDDI_DMA_PARTIAL\fR \fR
113 .RS 23n
114 Partial resource allocation.
118 .ne 2
120 \fB\fBDDI_DMA_CONSISTENT\fR \fR
122 .RS 23n
123 Nonsequential, random, and small block transfers.
127 .ne 2
129 \fB\fBDDI_DMA_STREAMING\fR \fR
131 .RS 23n
132 Sequential, unidirectional, block-sized, and block-aligned transfers.
138 .ne 2
140 \fB\fIcallback\fR \fR
142 .RS 13n
143 The address of a function to call back later if resources are not currently
144 available. The following special function addresses may also  be used.
146 .ne 2
148 \fB\fBDDI_DMA_SLEEP\fR \fR
150 .RS 21n
151 Wait until resources are available.
155 .ne 2
157 \fB\fBDDI_DMA_DONTWAIT\fR \fR
159 .RS 21n
160 Do not wait until resources are available and do not schedule a callback.
166 .ne 2
168 \fB\fIarg\fR \fR
170 .RS 13n
171 Argument to be passed to the callback function,  \fIcallback\fR, if such a
172 function is specified.
176 .ne 2
178 \fB\fIcookiep\fR \fR
180 .RS 13n
181 A pointer to the first  \fBddi_dma_cookie\fR(9S) structure.
185 .ne 2
187 \fB\fIccountp\fR \fR
189 .RS 13n
190 Upon a successful return,  \fIccountp\fR points to a value representing the
191 number of cookies for this \fBDMA\fR object.
194 .SH DESCRIPTION
197 \fBddi_dma_addr_bind_handle()\fR allocates \fBDMA\fR resources for a memory
198 object  such that a device can perform \fBDMA\fR to or from the object.
199 \fBDMA\fR resources are allocated considering the device's \fBDMA\fR attributes
200 as expressed by \fBddi_dma_attr\fR(9S) (see \fBddi_dma_alloc_handle\fR(9F)).
203 \fBddi_dma_addr_bind_handle()\fR fills in the first \fBDMA\fR cookie pointed to
204 by \fIcookiep\fR with the appropriate address, length, and bus type.
205 \fB*\fR\fIccountp\fR is set to the number of \fBDMA\fR cookies representing
206 this \fBDMA\fR object. Subsequent \fBDMA\fR cookies must be retrieved by
207 calling \fBddi_dma_nextcookie\fR(9F) the number of times specified by
208 \fB*\fR\fIcountp\fR-1.
211 When a \fBDMA\fR transfer completes, the driver frees up system \fBDMA\fR
212 resources by calling \fBddi_dma_unbind_handle\fR(9F).
215 The \fIflags\fR argument contains information for mapping routines.
217 .ne 2
219 \fB\fBDDI_DMA_WRITE\fR, \fBDDI_DMA_READ\fR, \fBDDI_DMA_RDWR\fR\fR
221 .sp .6
222 .RS 4n
223 These flags describe the intended direction of the \fBDMA\fR transfer.
227 .ne 2
229 \fB\fBDDI_DMA_STREAMING\fR \fR
231 .sp .6
232 .RS 4n
233 This flag should be set if the device is doing sequential, unidirectional,
234 block-sized, and block-aligned transfers to or from memory.  The alignment and
235 padding constraints specified by the \fBminxfer\fR and \fBburstsizes\fR fields
236 in the \fBDMA\fR attribute structure, \fBddi_dma_attr\fR(9S) (see
237 \fBddi_dma_alloc_handle\fR(9F)) is used to allocate the most effective hardware
238 support for large transfers.
242 .ne 2
244 \fB\fBDDI_DMA_CONSISTENT\fR \fR
246 .sp .6
247 .RS 4n
248 This flag should be set if  the device accesses memory randomly, or if
249 synchronization steps using \fBddi_dma_sync\fR(9F) need to be as efficient as
250 possible. I/O parameter blocks used for communication between a device and a
251 driver should be allocated using \fBDDI_DMA_CONSISTENT\fR.
255 .ne 2
257 \fB\fBDDI_DMA_REDZONE\fR \fR
259 .sp .6
260 .RS 4n
261 If this flag is set, the system attempts to  establish a protected red zone
262 after the object. The \fBDMA\fR resource allocation functions do not guarantee
263 the success of this request as some implementations may not have the hardware
264 ability to support a red zone.
268 .ne 2
270 \fB\fBDDI_DMA_PARTIAL\fR \fR
272 .sp .6
273 .RS 4n
274 Setting this flag indicates the caller can accept resources for part of the
275 object. That is, if the size of the object exceeds the resources available,
276 only resources for a portion of the object are allocated. The system indicates
277 this condition by returning status \fBDDI_DMA_PARTIAL_MAP\fR. At a later point,
278 the caller can use \fBddi_dma_getwin\fR(9F) to change the valid portion of the
279 object for which resources are allocated. If resources were allocated for only
280 part of the object, \fBddi_dma_addr_bind_handle()\fR returns resources for the
281 first \fBDMA\fRwindow. Even when \fBDDI_DMA_PARTIAL\fR is set, the system may
282 decide to allocate resources for the entire object (less overhead) in which
283 case \fBDDI_DMA_MAPPED\fR is returned.
288 The callback function \fIcallback\fR indicates how a caller wants to handle the
289 possibility of resources not being available. If \fIcallback\fR is set to
290 \fBDDI_DMA_DONTWAIT\fR, the caller does not care if the allocation fails, and
291 can handle an allocation failure appropriately. If \fIcallback\fR is set to
292 \fBDDI_DMA_SLEEP\fR, the caller wishes to have the allocation routines wait for
293 resources to become available. If any other value is set and a \fBDMA\fR
294 resource allocation fails, this value is assumed to be the address of a
295 function to be called when resources  become available. When the specified
296 function is called,  \fIarg\fR is passed to it as an argument. The specified
297 callback function must  return either \fBDDI_DMA_CALLBACK_RUNOUT\fR or
298 \fBDDI_DMA_CALLBACK_DONE\fR. \fBDDI_DMA_CALLBACK_RUNOUT\fR indicates that the
299 callback function attempted to allocate \fBDMA\fR resources but failed.  In
300 this case, the callback function is put back on a list to be called again
301 later. \fBDDI_DMA_CALLBACK_DONE\fR indicates that either the allocation of
302 \fBDMA\fR resources was successful or the driver no longer wishes to retry.
305 The callback function is called in interrupt context. Therefore, only system
306 functions accessible from interrupt context are be available. The callback
307 function must take whatever steps are necessary to protect its critical
308 resources, data structures, queues, and so on.
309 .SH RETURN VALUES
312 \fBddi_dma_addr_bind_handle()\fR returns:
314 .ne 2
316 \fB\fBDDI_DMA_MAPPED\fR \fR
318 .RS 24n
319 Successfully allocated resources for the entire object.
323 .ne 2
325 \fB\fBDDI_DMA_PARTIAL_MAP\fR \fR
327 .RS 24n
328 Successfully allocated resources for a part of the object. This is acceptable
329 when partial transfers are permitted by setting the \fBDDI_DMA_PARTIAL\fR flag
330 in \fIflags\fR.
334 .ne 2
336 \fB\fBDDI_DMA_INUSE\fR \fR
338 .RS 24n
339 Another I/O transaction is using the \fBDMA\fR handle.
343 .ne 2
345 \fB\fBDDI_DMA_NORESOURCES\fR \fR
347 .RS 24n
348 No resources are available at the present time.
352 .ne 2
354 \fB\fBDDI_DMA_NOMAPPING\fR \fR
356 .RS 24n
357 The object cannot be reached by the device requesting the resources.
361 .ne 2
363 \fB\fBDDI_DMA_TOOBIG\fR \fR
365 .RS 24n
366 The object is too big.  A request of this size can never be  satisfied on this
367 particular system.  The maximum size varies depending on machine and
368 configuration.
371 .SH CONTEXT
374 \fBddi_dma_addr_bind_handle()\fR can be called from user, kernel, or interrupt
375 context, except when \fIcallback\fR is set to  \fBDDI_DMA_SLEEP\fR, in which
376 case it can only be called from user or kernel context.
377 .SH SEE ALSO
380 \fBddi_dma_alloc_handle\fR(9F), \fBddi_dma_free_handle\fR(9F),
381 \fBddi_dma_getwin\fR(9F), \fBddi_dma_mem_alloc\fR(9F),
382 \fBddi_dma_mem_free\fR(9F), \fBddi_dma_nextcookie\fR(9F),
383 \fBddi_dma_sync\fR(9F), \fBddi_dma_unbind_handle\fR(9F),
384 \fBddi_umem_iosetup\fR(9F), \fBddi_dma_attr\fR(9S), \fBddi_dma_cookie\fR(9S)
387 \fIWriting Device Drivers\fR
388 .SH NOTES
391 If the driver permits partial mapping with the  \fBDDI_DMA_PARTIAL\fR flag, the
392 number of cookies in each window may exceed the size of the device's
393 scatter/gather list as specified in the  \fBdma_attr_sgllen\fR field in the
394 \fBddi_dma_attr\fR(9S) structure. In this case, each set of cookies comprising
395 a  \fBDMA\fR window will satisfy the \fBDMA\fR attributes as described in the
396 \fBddi_dma_attr\fR(9S) structure in all aspects. The driver should set up its
397 \fBDMA\fR engine and perform one transfer for each set of cookies sufficient
398 for its scatter/gather list, up to the number of cookies for this window,
399 before advancing to the next window using \fBddi_dma_getwin\fR(9F).