DMA Map Management Routines, Part 2

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 ...

Get FreeBSD Device Drivers now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.