This section describes an alternative set of functions used to manage DMA maps.
#include <machine/bus.h> int bus_dmamem_alloc(bus_dma_tag_t dmat, void **vaddr, int flags, bus_dmamap_t *mapp); void bus_dmamem_free(bus_dma_tag_t dmat, void *vaddr, bus_dmamap_t map);
The bus_dmamem_alloc
function creates a DMA map based on the DMA tag dmat
and stores the result in mapp
. This function also allocates maxsize
bytes of contiguous memory (where maxsize
is defined by dmat
). The address of this memory is returned in vaddr
. As you’ll soon see, this contiguous memory will eventually become your DMA buffer. The flags
argument modifies bus_dmamem_alloc
’s behavior. Valid values for this argument are shown in Table 12-4.
Table 12-4. bus_dmamem_alloc Symbolic Constants
Constant | Description |
---|---|
| Causes the allocated memory to be set to zero |
| Causes |
| Indicates that it is okay to wait for resources; if the allocation cannot be immediately fulfilled, the current process is put to sleep to wait for resources to become available. |
| Causes cache synchronization operations to be as cheap as possible for your DMA buffer; this flag is implemented only on arm and sparc64. |
| Prevents caching the DMA buffer, thereby causing all DMA transactions to be executed without reordering; this flag is implemented only on amd64 and i386. |
bus_dmamem_alloc
is used when you require a physically contiguous DMA buffer.
The bus_dmamem_free
function releases the memory at vaddr
that was previously allocated by bus_dmamem_alloc
. Then it tears down the DMA map map
.
18.221.208.183