Loading (DMA) Buffers into DMA Maps

The FreeBSD kernel provides four functions for loading a buffer into the device visible address associated with a DMA map:

  • bus_dmamap_load

  • bus_dmamap_load_mbuf

  • bus_dmamap_load_mbuf_sg

  • bus_dmamap_load_uio

Before I describe these functions, an explanation of bus_dma_segment structures is needed.

bus_dma_segment Structures

A bus_dma_segment structure describes a single DMA segment.

typedef struct bus_dma_segment {
        bus_addr_t     ds_addr;
        bus_size_t     ds_len;
} bus_dma_segment_t;

The ds_addr field contains its device visible address ...

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.