2 .\" Copyright (c) 2002, 2003, 2004 The DragonFly Project. All rights reserved.
4 .\" This code is derived from software contributed to The DragonFly Project
5 .\" by Hiten Pandya <hmp@backplane.com>.
7 .\" Redistribution and use in source and binary forms, with or without
8 .\" modification, are permitted provided that the following conditions
11 .\" 1. Redistributions of source code must retain the above copyright
12 .\" notice, this list of conditions and the following disclaimer.
13 .\" 2. Redistributions in binary form must reproduce the above copyright
14 .\" notice, this list of conditions and the following disclaimer in
15 .\" the documentation and/or other materials provided with the
17 .\" 3. Neither the name of The DragonFly Project nor the names of its
18 .\" contributors may be used to endorse or promote products derived
19 .\" from this software without specific, prior written permission.
21 .\" THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
22 .\" ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
23 .\" LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
24 .\" FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
25 .\" COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
26 .\" INCIDENTAL, SPECIAL, EXEMPLARY OR CONSEQUENTIAL DAMAGES (INCLUDING,
27 .\" BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
28 .\" LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
29 .\" AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
30 .\" OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
31 .\" OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
34 .\" Copyright (c) 1996, 1997, 1998, 2001 The NetBSD Foundation, Inc.
35 .\" All rights reserved.
37 .\" This code is derived from software contributed to The NetBSD Foundation
38 .\" by Jason R. Thorpe of the Numerical Aerospace Simulation Facility,
39 .\" NASA Ames Research Center.
41 .\" Redistribution and use in source and binary forms, with or without
42 .\" modification, are permitted provided that the following conditions
44 .\" 1. Redistributions of source code must retain the above copyright
45 .\" notice, this list of conditions and the following disclaimer.
46 .\" 2. Redistributions in binary form must reproduce the above copyright
47 .\" notice, this list of conditions and the following disclaimer in the
48 .\" documentation and/or other materials provided with the distribution.
49 .\" 3. All advertising materials mentioning features or use of this software
50 .\" must display the following acknowledgment:
51 .\" This product includes software developed by the NetBSD
52 .\" Foundation, Inc. and its contributors.
53 .\" 4. Neither the name of The NetBSD Foundation nor the names of its
54 .\" contributors may be used to endorse or promote products derived
55 .\" from this software without specific prior written permission.
57 .\" THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
58 .\" ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
59 .\" TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
60 .\" PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
61 .\" BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
62 .\" CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
63 .\" SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
64 .\" INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
65 .\" CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
66 .\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
67 .\" POSSIBILITY OF SUCH DAMAGE.
69 .\" $FreeBSD: /repoman/r/ncvs/src/share/man/man9/bus_dma.9,v 1.7 2003/07/27 14:05:29 mux Exp $
70 .\" $NetBSD: bus_dma.9,v 1.25 2002/10/14 13:43:16 wiz Exp $
77 .Nm bus_dma_tag_create ,
78 .Nm bus_dma_tag_destroy ,
79 .Nm bus_dmamap_create ,
80 .Nm bus_dmamap_destroy ,
82 .Nm bus_dmamap_load_mbuf ,
83 .Nm bus_dmamap_load_mbuf_segment ,
84 .Nm bus_dmamap_load_mbuf_defrag ,
85 .Nm bus_dmamap_load_uio ,
86 .Nm bus_dmamap_unload ,
88 .Nm bus_dmamem_alloc ,
89 .Nm bus_dmamem_coherent ,
90 .Nm bus_dmamem_coherent_any ,
92 .Nd Bus and Machine Independent DMA Mapping Interface
96 .Fn bus_dma_tag_create "bus_dma_tag_t parent" "bus_size_t alignment" \
97 "bus_size_t boundary" "bus_addr_t lowaddr" "bus_addr_t highaddr" \
98 "bus_dma_filter_t *filtfunc" "void *filtfuncarg" "bus_size_t maxsize" \
99 "int nsegments" "bus_size_t maxsegsz" "int flags" "bus_dma_tag_t *dmat"
101 .Fn bus_dma_tag_destroy "bus_dma_tag_t dmat"
103 .Fn bus_dmamap_create "bus_dma_tag_t dmat" "int flags" "bus_dmamap_t *mapp"
105 .Fn bus_dmamap_destroy "bus_dma_tag_t dmat" "bus_dmamap_t map"
107 .Fn bus_dmamap_load "bus_dma_tag_t dmat" "bus_dmamap_t map" "void *buf" \
108 "bus_size_t buflen" "bus_dmamap_callback_t *callback" "void *callback_arg" \
111 .Fn bus_dmamap_load_mbuf "bus_dma_tag_t dmat" "bus_dmamap_t map" \
112 "struct mbuf *mbuf" "bus_dmamap_callback2_t *callback" "void *callback_arg" \
115 .Fn bus_dmamap_load_mbuf_segment "bus_dma_tag_t dmat" "bus_dmamap_t map" \
116 "struct mbuf *mbuf" "bus_dma_segment_t *segs" "int maxsegs" "int *nsegs" \
119 .Fn bus_dmamap_load_mbuf_defrag "bus_dma_tag_t dmat" "bus_dmamap_t map" \
120 "struct mbuf **mbuf" "bus_dma_segment_t *segs" "int maxsegs" "int *nsegs" \
123 .Fn bus_dmamap_load_uio "bus_dma_tag_t dmat" "bus_dmamap_t map" \
124 "struct uio *uio" "bus_dmamap_callback2_t *callback" "void *callback_arg" \
127 .Fn bus_dmamem_alloc "bus_dma_tag_t dmat" "void **vaddr" \
128 "int flags" "bus_dmamap_t *mapp"
130 .Fn bus_dmamem_coherent "bus_dma_tag_t parent" "bus_size_t alignment" \
131 "bus_size_t boundary" "bus_addr_t lowaddr" "bus_addr_t highaddr" \
132 "bus_size_t maxsize" "int flags" "bus_dmamem_t *dmem"
134 .Fn bus_dmamem_coherent_any "bus_dma_tag_t parent" "bus_size_t alignment" \
135 "bus_size_t maxsize" "int flags" "bus_dma_tag_t *dtag" "bus_dmamap_t *dmap" \
136 "bus_addr_t *busaddr"
138 .Fn bus_dmamap_unload "bus_dma_tag_t dmat" "bus_dmamap_t map"
140 .Fn bus_dmamap_sync "bus_dma_tag_t dmat" "bus_dmamap_t map" \
141 "bus_dmasync_op_t op"
143 .Fn bus_dmamem_free "bus_dma_tag_t dmat" "void *vaddr" \
146 Direct Memory Access (DMA) is a method of transferring data
147 without involving the CPU, thus providing higher performance.
148 A DMA transaction can be achieved between device to memory,
149 device to device, or memory to memory.
153 API is a bus, device, and machine-independent (MI) interface to
155 It provides the client with flexibility and simplicity by
156 abstracting machine dependent issues like setting up
157 DMA mappings, handling cache issues, bus specific features
159 .Sh STRUCTURES AND TYPES
160 .Bl -tag -width compact
162 A machine-dependent (MD) opaque type that describes the
163 characteristics of DMA transactions.
164 DMA tags are organized into a hierarchy, with each child
165 tag inheriting the restrictions of its parent.
166 This allows all devices along the path of DMA transactions
167 to contribute to the constraints of those transactions.
168 .It Vt bus_dma_filter_t
169 Client specified address filter having the format:
170 .Bl -tag -width compact
172 .Fn "client_filter" "void *filtarg" "bus_addr_t testaddr"
175 Address filters can be specified during tag creation to allow
176 for devices who's DMA address restrictions cannot be specified
180 is client specified during tag creation to be passed to all
181 invocations of the callback.
184 argument contains a potential starting address of a DMA mapping.
185 The filter function operates on the set of addresses from
188 .Ql trunc_page(testaddr) + PAGE_SIZE - 1 ,
190 The filter function should return zero for any mapping in this range
191 that can be accommodated by the device and non-zero otherwise.
192 .It Vt bus_dma_segment_t
193 A machine-dependent type that describes individual
202 field contains the device visible address of the DMA segment, and
204 contains the length of the DMA segment.
205 Although the DMA segments returned by a mapping call will adhere to
206 all restrictions necessary for a successful DMA operation, some conversion
207 (e.g. a conversion from host byte order to the device's byte order) is
208 almost always required when presenting segment information to the device.
210 A machine-dependent opaque type describing an individual mapping.
211 Multiple DMA maps can be associated with one DMA tag.
213 A machine-dependent type that describes DMA memory created by
214 .Fn bus_dmamem_coherent .
216 bus_dma_tag_t dmem_tag;
217 bus_dmamap_t dmem_map;
219 bus_addr_t dmem_busaddr;
224 field contains the DMA tag of the DMA memory and
226 field contains the DMA map of the DMA memory.
229 field points to the allocated DMA memory in kernel virtual address space.
232 field contains the device visible address of the DMA memory.
233 .It Vt bus_dmamap_callback_t
234 Client specified callback for receiving mapping information resulting from
238 .Fn bus_dmamap_load .
239 Callbacks are of the format:
240 .Bl -tag -width compact
242 .Fn "client_callback" "void *callback_arg" "bus_dma_segment_t *segs" \
243 "int nseg" "int error"
248 is the callback argument passed to dmamap load functions.
253 parameters describe an array of
254 .Vt bus_dma_segment_t
255 structures that represent the mapping.
256 This array is only valid within the scope of the callback function.
257 The success or failure of the mapping is indicated by the
260 More information on the use of callbacks can be found in the
261 description of the individual dmamap load functions.
262 .It Vt bus_dmamap_callback2_t
263 Client specified callback for receiving mapping information resulting from
267 .Fn bus_dmamap_load_uio
269 .Fn bus_dmamap_load_mbuf .
271 Callback2s are of the format:
272 .Bl -tag -width compact
274 .Fn "client_callback2" "void *callback_arg" "bus_dma_segment_t *segs" \
275 "int nseg" "bus_size_t mapsize" "int error"
278 Callback2's behavior is the same as
279 .Vt bus_dmamap_callback_t
280 with the addition that the length of the data mapped is provided via
282 .It Vt bus_dmasync_op_t
283 Memory synchronization operation specifier.
284 Bus DMA requires explicit synchronization of memory with it's device
285 visible mapping in order to guarantee memory coherency.
288 allows the type of DMA operation that will be or has been performed
289 to be communicated to the system so that the correct coherency measures
291 All operations specified below are performed from the DMA engine's
293 .Bl -tag -width BUS_DMASYNC_POSTWRITE
294 .It Dv BUS_DMASYNC_PREREAD
295 Perform any synchronization required after an update of memory by the CPU
296 but prior to DMA read operations.
297 .It Dv BUS_DMASYNC_PREWRITE
298 Perform any synchronization required after an update of memory by the CPU
299 but prior to DMA write operations.
300 .It Dv BUS_DMASYNC_POSTREAD
301 Perform any synchronization required after DMA read operations, but prior
302 to CPU access of the memory.
303 .It Dv BUS_DMASYNC_POSTWRITE
304 Perform any synchronization required after DMA write operations, but prior
305 to CPU access of the memory.
310 .Bl -tag -width compact
311 .It Fn bus_dma_tag_create "parent" "alignment" "boundary" "lowaddr" \
312 "highaddr" "*filtfunc" "*filtfuncarg" "maxsize" "nsegments" "maxsegsz" \
314 Allocates a device specific DMA tag, and initializes it according to
315 the arguments provided:
316 .Bl -tag -width *filtfuncarg -compact
318 Indicates restrictions between the parent bridge, CPU memory, and the
320 May be NULL, if no DMA restrictions are to be inherited.
322 Alignment constraint, in bytes, of any mappings created using this tag.
323 The alignment must be a power of 2.
324 Hardware that can DMA starting at any address would specify
327 Hardware requiring DMA transfers to start on a multiple of 4K
331 Boundary constraint, in bytes, of the target DMA memory region.
332 The boundary indicates the set of addresses, all multiples of the
333 boundary argument, that cannot be crossed by a single
334 .Vt bus_dma_segment_t .
335 The boundary must be either a power of 2 or 0.
337 indicates that there are no boundary restrictions.
340 Bounds of the window of bus address space that
342 be directly accessed by the device.
343 The window contains all address greater than lowaddr and
344 less than or equal to highaddr.
345 For example, a device incapable of DMA above 4GB, would specify
347 .Dv BUS_SPACE_MAXADDR
349 .Dv BUS_SPACE_MAXADDR_32BIT .
350 Similarly a device that can only dma to addresses bellow 16MB would
351 specify a highaddr of
352 .Dv BUS_SPACE_MAXADDR
354 .Dv BUS_SPACE_MAXADDR_24BIT .
355 Some implementations requires that some region of device visible
356 address space, overlapping available host memory, be outside the
360 is used to bounce requests that would otherwise conflict with
361 the exclusion window.
363 Optional filter function (may be NULL) to be called for any attempt to
364 map memory into the window described by
368 A filter function is only required when the single window described
373 cannot adequately describe the constraints of the device.
374 The filter function will be called for every machine page
375 that overlaps the exclusion window.
377 Argument passed to all calls to the filter function for this tag.
380 Maximum size, in bytes, of the sum of all segment lengths in a given
381 DMA mapping associated with this tag.
383 Number of discontinuities (scatter/gather segments) allowed
384 in a DMA mapped region.
385 If there is no restriction,
386 .Dv BUS_SPACE_UNRESTRICTED
387 may be specified for the tag intended to be used as the parent.
388 .Dv BUS_SPACE_UNRESTRICTED
389 must not be specified for the tags
390 which will be used to create maps.
391 For tags which will be used to create maps,
392 this argument must be less than 16384 on x86_64.
394 Maximum size, in bytes, of a segment in any DMA mapped region associated
399 .Bl -tag -width ".Dv BUS_DMA_PRIVBZONE" -compact
400 .It Dv BUS_DMA_ALLOCNOW
401 Allocate the minimum resources necessary to guarantee that all map load
402 operations associated with this tag may not block.
403 If sufficient resources are not available,
406 .It Dv BUS_DMA_WAITOK
407 Indicates that it is OK to wait for resources.
411 it is not guaranteed that the resource allocation will succeed.
412 This flag is the default one,
416 .It Dv BUS_DMA_NOWAIT
417 If the resource allocation request cannot be immediately fulfilled,
420 .It Dv BUS_DMA_ONEBPAGE
421 Allocte one bounce page at most,
424 indicates that multiple bounce pages are needed.
425 .It Dv BUS_DMA_ALIGNED
426 Indicates that all memory to be loaded into the DMA maps associated
427 with this DMA tag is properly aligned according to
432 will be allocated due to the
435 If unaligned memory was loaded into the DMA maps associated with this DMA tag,
437 .It Dv BUS_DMA_PRIVBZONE
438 Uses a private bounce zone instead of a shared one.
439 A private bounce zone will vanish if the DMA tag is destroyed.
440 .It Dv BUS_DMA_ALLOCALL
441 Allocate all required resources (mainly the bounce buffer).
442 If any allocation fails,
443 .Fn bus_dma_tag_create
445 .It Dv BUS_DMA_PROTECTED
446 All of the functions called with the DMA tag are already protected by the
449 code need not protect the internal data structures.
452 Pointer to a bus_dma_tag_t where the resulting DMA tag will
458 if sufficient memory is not available for tag creation
459 or allocating mapping resources.
460 .It Fn bus_dma_tag_destroy "dmat"
461 Deallocate the DMA tag
464 .Fn bus_dma_tag_create .
468 if any DMA maps remain associated with
473 .It Fn bus_dmamap_create "dmat" "flags" "*mapp"
474 Allocates and initializes a DMA map.
475 Arguments are as follows:
476 .Bl -tag -width nsegments -compact
481 .Bl -tag -width ".Dv BUS_DMA_ONEBPAGE" -compact
482 .It Dv BUS_DMA_WAITOK
483 Indicates that it is OK to wait for resources.
487 it is not guaranteed that the resource allocation will succeed.
488 This flag is the default one,
492 .It Dv BUS_DMA_NOWAIT
493 If the resource allocation request cannot be immediately fulfilled,
496 .It Dv BUS_DMA_ONEBPAGE
497 Allocte one bounce page at most,
502 indicates that multiple bounce pages are needed.
507 where the resulting DMA map will be stored.
512 if sufficient memory is not available for creating the
513 map or allocating mapping resources.
514 .It Fn bus_dmamap_destroy "dmat" "map"
515 Frees all resources associated with a given DMA map.
516 Arguments are as follows:
517 .Bl -tag -width dmat -compact
519 DMA tag used to allocate
522 The DMA map to destroy.
527 if a mapping is still active for
529 .It Fn bus_dmamap_load "dmat" "map" "buf" "buflen" "*callback" "..."
530 Creates a mapping in device visible address space of
534 associated with the DMA map
536 Arguments are as follows:
537 .Bl -tag -width buflen -compact
539 DMA tag used to allocate
542 A DMA map without a currently active mapping.
544 A kernel virtual address pointer to a contiguous (in KVA) buffer, to be
545 mapped into device visible address space.
547 The size of the buffer.
548 .It Fa callback Fa callback_arg
549 The callback function, and its argument.
551 The value of this argument is currently undefined, and should be
556 Return values to the caller are as follows:
557 .Bl -tag -width ".Er EINPROGRESS" -compact
559 The callback has been called and completed.
560 The status of the mapping has been delivered to the callback.
562 The mapping has been deferred for lack of resources.
563 The callback will be called as soon as resources are available.
564 Callbacks are serviced in FIFO order.
565 DMA maps created from DMA tags that are allocated with
568 flag will never return this status for a load operation.
570 The load request was invalid.
571 The callback has not, and will not be called.
572 This error value may indicate that
582 argument used to create the dma tag
586 When the callback is called, it is presented with an error value
587 indicating the disposition of the mapping.
588 Error may be one of the following:
589 .Bl -tag -width ".Er EINPROGRESS" -compact
591 The mapping was successful and the
593 callback argument contains an array of
594 .Vt bus_dma_segment_t
595 elements describing the mapping.
596 This array is only valid during the scope of the callback function.
598 A mapping could not be achieved within the segment constraints provided
599 in the tag even though the requested allocation size was less than maxsize.
601 .It Fn bus_dmamap_load_mbuf "dmat" "map" "mbuf" "callback2" "callback_arg" \
603 This is a variation of
605 which maps mbuf chains
609 argument is also passed to the callback routine, which
610 contains the mbuf chain's packet header length.
612 Mbuf chains are assumed to be in kernel virtual address space.
616 if the size of the mbuf chain exceeds the maximum limit of the
618 .It Fn bus_dmamap_load_mbuf_segment "dmat" "map" "mbuf" "*segs" "maxsegs" \
621 .Fn bus_dmamap_load_mbuf
623 Segmentation information are saved in the
627 if the loading is successful.
630 which indicates the number of elements in the
632 must be set by the caller and must be at least 1 and at most equal the
642 This function will not block.
643 When system is short of DMA resources,
644 this function will return
648 .It Fn bus_dmamap_load_mbuf_defrag "dmat" "map" "*mbuf" "*segs" "maxsegs" \
650 This function is like
651 .Fn bus_dmamap_load_mbuf_segment ,
657 if low level code indicates too many fragments in the
661 will be updated under this situation.
664 would not be freed by this function,
674 .It Fn bus_dmamap_load_uio "dmat" "map" "uio" "callback2" "callback_arg" "flags"
675 This is a variation of
677 which maps buffers pointed to by
682 argument is also passed to the callback routine, which contains the size of
691 then it is assumed that the buffer,
694 .Fa "uio->uio_td->td_proc" Ns 's
696 User space memory must be in-core and wired prior to attempting a map
698 .It Fn bus_dmamap_unload "dmat" "map"
700 Arguments are as follows:
701 .Bl -tag -width dmam -compact
703 DMA tag used to allocate
706 The DMA map that is to be unloaded.
709 .Fn bus_dmamap_unload
710 will not perform any implicit synchronization of DMA buffers.
711 This must be done explicitly by a call to
713 prior to unloading the map.
714 .It Fn bus_dmamap_sync "dmat" "map" "op"
715 Performs synchronization of a device visible mapping with the CPU visible
716 memory referenced by that mapping.
717 Arguments are as follows:
718 .Bl -tag -width dmat -compact
720 DMA tag used to allocate
723 The DMA mapping to be synchronized.
725 Type of synchronization operation to perform.
726 See the definition of
728 for a description of the acceptable values for
733 is the method used to ensure that CPU and device DMA access to shared
735 For example, the CPU might be used to setup the contents of a buffer
736 that is to be DMA'ed into a device.
737 To ensure that the data are visible via the device's mapping of that
738 memory, the buffer must be loaded and a dma sync operation of
739 .Dv BUS_DMASYNC_PREREAD
741 Additional sync operations must be performed after every CPU write
742 to this memory if additional DMA reads are to be performed.
743 Conversely, for the DMA write case, the buffer must be loaded,
744 and a dma sync operation of
745 .Dv BUS_DMASYNC_PREWRITE
747 The CPU will only be able to see the results of this DMA write
748 once the DMA has completed and a
749 .Dv BUS_DMASYNC_POSTWRITE
750 operation has been performed.
752 If DMA read and write operations are not preceded and followed by the
753 appropriate synchronization operations, behavior is undefined.
754 .It Fn bus_dmamem_alloc "dmat" "**vaddr" "flags" "mapp"
755 Allocates memory that is mapped into KVA at the address returned
758 that is permanently loaded into the newly created
762 Arguments are as follows:
763 .Bl -tag -width alignment -compact
765 DMA tag describing the constraints of the DMA mapping.
767 Pointer to a pointer that will hold the returned KVA mapping of
768 the allocated region.
770 Flags are defined as follows:
771 .Bl -tag -width ".Dv BUS_DMA_COHERENT" -compact
772 .It Dv BUS_DMA_WAITOK
773 The routine can safely wait (sleep) for resources.
774 .It Dv BUS_DMA_NOWAIT
775 The routine is not allowed to wait for resources.
776 If resources are not available,
779 .It Dv BUS_DMA_COHERENT
780 Attempt to map this memory such that cache sync operations are
781 as cheap as possible.
782 This flag is typically set on memory that will be accessed by both
783 a CPU and a DMA engine, frequently.
784 Use of this flag does not remove the requirement of using
785 bus_dmamap_sync, but it may reduce the cost of performing
788 Causes the allocated memory to be set to all zeros.
789 .It Dv BUS_DMA_NOCACHE
790 The allocated memory will not be cached in the processor caches.
791 All memory accesses appear on the bus and are executed
796 Strong Uncacheable PAT to be set for the allocated virtual address range.
799 Pointer to storage for the returned DMA map.
802 The size of memory to be allocated is
807 The current implementation of
809 will allocate all requests as a single segment.
811 Although no explicit loading is required to access the memory
812 referenced by the returned map, the synchronization requirements
819 if sufficient memory is not available for completing
821 .It Fn bus_dmamem_coherent "parent" "alignment" "boundary" "lowaddr" \
822 "highaddr" "maxsize" "flags" "*dmem"
823 This is a convenient function to create one segment of DMA memory.
824 It combines following
828 bus_dma_tag_create(..., dtag);
829 bus_dmamem_alloc(*dtag, vaddr, ..., dmap);
830 bus_dmamap_load(*dtag, *dmap, *vaddr, ..., \\
831 callback, busaddr, ...);
834 The final results of the above function calls are:
837 DMA memory's kernel virtual address and
838 its device visible address.
839 .Fn bus_dmamem_coherent
851 .Fn bus_dma_tag_create
856 .Fn bus_dma_tag_create
864 .Fn bus_dma_tag_create
871 will be first or'ed with
874 The final results of the above three functions,
877 DMA memory's kernel virtual address and
878 its device visible address,
881 If any of the three functions failed,
882 this function will return the error code and the
885 .It Fn bus_dmamem_coherent_any "parent" "alignment" "maxsize" "flags" \
886 "*dtag" "*dmap" "*busaddr"
887 This function is a simplified version of
888 .Fn bus_dmamem_coherent
896 .Dv BUS_SPACE_MAXADDR
900 .Dv BUS_SPACE_MAXADDR .
903 usually should not be NULL.
905 Return the DMA memory's kernel virtual address.
906 The DMA tag, DMA map and device visible address are returned in
911 If this function failed,
912 NULL will be returned;
918 .It Fn bus_dmamem_free "dmat" "*vaddr" "map"
919 Frees memory previously allocated by
920 .Fn bus_dmamem_alloc .
923 Arguments are as follows:
924 .Bl -tag -width vaddr -compact
928 Kernel virtual address of the memory.
930 DMA map to be invalidated.
934 Behavior is undefined if invalid arguments are passed to
935 any of the above functions.
936 If sufficient resources cannot be allocated for a given
941 routines that are not of type,
943 will return 0 on success or an error
944 code, as discussed above.
948 routines will succeed if provided with valid arguments.
955 .%A "Jason R. Thorpe"
956 .%T "A Machine-Independent DMA Framework for NetBSD"
957 .%J "Proceedings of the Summer 1998 USENIX Technical Conference"
958 .%Q "USENIX Association"
964 interface first appeared in
971 for use in the CAM SCSI subsystem.
972 The alterations to the original API were aimed to remove the need for
974 .Vt bus_dma_segment_t
977 while allowing callers to queue up on scarce resources.
981 interface was designed and implemented by
983 of the Numerical Aerospace Simulation Facility, NASA Ames Research Center.
984 Additional input on the
986 design was provided by
988 .An Chris Demetriou ,
996 This manual page was written by
999 .An Justin T. Gibbs .