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"
8 ddi_dma_addr_bind_handle \- binds an address to a DMA handle
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);
25 Solaris DDI specific (Solaris DDI).
33 The \fBDMA\fR handle previously allocated by a call to
34 \fBddi_dma_alloc_handle\fR(9F).
43 A pointer to an address space structure. This parameter should be set to
44 \fINULL\fR, which implies kernel address space.
53 Virtual address of the memory object.
62 Length of the memory object in bytes.
75 \fB\fBDDI_DMA_WRITE\fR \fR
78 Transfer direction is from memory to I/O.
84 \fB\fBDDI_DMA_READ\fR \fR
87 Transfer direction is from I/O to memory.
93 \fB\fBDDI_DMA_RDWR\fR \fR
102 \fB\fBDDI_DMA_REDZONE\fR \fR
105 Establish an \fBMMU\fR redzone at end of the object.
111 \fB\fBDDI_DMA_PARTIAL\fR \fR
114 Partial resource allocation.
120 \fB\fBDDI_DMA_CONSISTENT\fR \fR
123 Nonsequential, random, and small block transfers.
129 \fB\fBDDI_DMA_STREAMING\fR \fR
132 Sequential, unidirectional, block-sized, and block-aligned transfers.
140 \fB\fIcallback\fR \fR
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.
148 \fB\fBDDI_DMA_SLEEP\fR \fR
151 Wait until resources are available.
157 \fB\fBDDI_DMA_DONTWAIT\fR \fR
160 Do not wait until resources are available and do not schedule a callback.
171 Argument to be passed to the callback function, \fIcallback\fR, if such a
172 function is specified.
181 A pointer to the first \fBddi_dma_cookie\fR(9S) structure.
190 Upon a successful return, \fIccountp\fR points to a value representing the
191 number of cookies for this \fBDMA\fR object.
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.
219 \fB\fBDDI_DMA_WRITE\fR, \fBDDI_DMA_READ\fR, \fBDDI_DMA_RDWR\fR\fR
223 These flags describe the intended direction of the \fBDMA\fR transfer.
229 \fB\fBDDI_DMA_STREAMING\fR \fR
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.
244 \fB\fBDDI_DMA_CONSISTENT\fR \fR
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.
257 \fB\fBDDI_DMA_REDZONE\fR \fR
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.
270 \fB\fBDDI_DMA_PARTIAL\fR \fR
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.
312 \fBddi_dma_addr_bind_handle()\fR returns:
316 \fB\fBDDI_DMA_MAPPED\fR \fR
319 Successfully allocated resources for the entire object.
325 \fB\fBDDI_DMA_PARTIAL_MAP\fR \fR
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
336 \fB\fBDDI_DMA_INUSE\fR \fR
339 Another I/O transaction is using the \fBDMA\fR handle.
345 \fB\fBDDI_DMA_NORESOURCES\fR \fR
348 No resources are available at the present time.
354 \fB\fBDDI_DMA_NOMAPPING\fR \fR
357 The object cannot be reached by the device requesting the resources.
363 \fB\fBDDI_DMA_TOOBIG\fR \fR
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
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.
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
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).