2 #ifndef _MACHINE_BUS_DMA_H_
3 #define _MACHINE_BUS_DMA_H_
5 #define WANT_INLINE_DMAMAP
6 #include <sys/bus_dma.h>
8 #include <machine/bus_dma_impl.h>
11 * Allocate a handle for mapping from kva/uva/physical
12 * address space into bus device space.
15 bus_dmamap_create(bus_dma_tag_t dmat, int flags, bus_dmamap_t *mapp)
17 struct bus_dma_tag_common *tc;
19 tc = (struct bus_dma_tag_common *)dmat;
20 return (tc->impl->map_create(dmat, flags, mapp));
24 * Destroy a handle for mapping from kva/uva/physical
25 * address space into bus device space.
28 bus_dmamap_destroy(bus_dma_tag_t dmat, bus_dmamap_t map)
30 struct bus_dma_tag_common *tc;
32 tc = (struct bus_dma_tag_common *)dmat;
33 return (tc->impl->map_destroy(dmat, map));
37 * Allocate a piece of memory that can be efficiently mapped into
38 * bus device space based on the constraints listed in the dma tag.
39 * A dmamap to for use with dmamap_load is also allocated.
42 bus_dmamem_alloc(bus_dma_tag_t dmat, void** vaddr, int flags,
45 struct bus_dma_tag_common *tc;
47 tc = (struct bus_dma_tag_common *)dmat;
48 return (tc->impl->mem_alloc(dmat, vaddr, flags, mapp));
52 * Free a piece of memory and it's allociated dmamap, that was allocated
53 * via bus_dmamem_alloc. Make the same choice for free/contigfree.
56 bus_dmamem_free(bus_dma_tag_t dmat, void *vaddr, bus_dmamap_t map)
58 struct bus_dma_tag_common *tc;
60 tc = (struct bus_dma_tag_common *)dmat;
61 tc->impl->mem_free(dmat, vaddr, map);
65 * Release the mapping held by map.
68 bus_dmamap_unload(bus_dma_tag_t dmat, bus_dmamap_t map)
70 struct bus_dma_tag_common *tc;
72 tc = (struct bus_dma_tag_common *)dmat;
73 tc->impl->map_unload(dmat, map);
77 bus_dmamap_sync(bus_dma_tag_t dmat, bus_dmamap_t map, bus_dmasync_op_t op)
79 struct bus_dma_tag_common *tc;
81 tc = (struct bus_dma_tag_common *)dmat;
82 tc->impl->map_sync(dmat, map, op);
86 _bus_dmamap_load_phys(bus_dma_tag_t dmat, bus_dmamap_t map, vm_paddr_t buf,
87 bus_size_t buflen, int flags, bus_dma_segment_t *segs, int *segp)
89 struct bus_dma_tag_common *tc;
91 tc = (struct bus_dma_tag_common *)dmat;
92 return (tc->impl->load_phys(dmat, map, buf, buflen, flags, segs,
97 _bus_dmamap_load_ma(bus_dma_tag_t dmat, bus_dmamap_t map, struct vm_page **ma,
98 bus_size_t tlen, int ma_offs, int flags, bus_dma_segment_t *segs,
101 struct bus_dma_tag_common *tc;
103 tc = (struct bus_dma_tag_common *)dmat;
104 return (tc->impl->load_ma(dmat, map, ma, tlen, ma_offs, flags,
109 _bus_dmamap_load_buffer(bus_dma_tag_t dmat, bus_dmamap_t map, void *buf,
110 bus_size_t buflen, struct pmap *pmap, int flags, bus_dma_segment_t *segs,
113 struct bus_dma_tag_common *tc;
115 tc = (struct bus_dma_tag_common *)dmat;
116 return (tc->impl->load_buffer(dmat, map, buf, buflen, pmap, flags, segs,
121 _bus_dmamap_waitok(bus_dma_tag_t dmat, bus_dmamap_t map,
122 struct memdesc *mem, bus_dmamap_callback_t *callback, void *callback_arg)
124 struct bus_dma_tag_common *tc;
126 tc = (struct bus_dma_tag_common *)dmat;
127 tc->impl->map_waitok(dmat, map, mem, callback, callback_arg);
130 static inline bus_dma_segment_t *
131 _bus_dmamap_complete(bus_dma_tag_t dmat, bus_dmamap_t map,
132 bus_dma_segment_t *segs, int nsegs, int error)
134 struct bus_dma_tag_common *tc;
136 tc = (struct bus_dma_tag_common *)dmat;
137 return (tc->impl->map_complete(dmat, map, segs, nsegs, error));
140 #endif /* !_MACHINE_BUS_DMA_H_ */