Changeset View
Changeset View
Standalone View
Standalone View
head/sys/sys/bus_dma.h
Show First 20 Lines • Show All 242 Lines • ▼ Show 20 Lines | |||||
* Placeholder for use by busdma implementations which do not benefit | * Placeholder for use by busdma implementations which do not benefit | ||||
* from optimized procedure to load an array of vm_page_t. Falls back | * from optimized procedure to load an array of vm_page_t. Falls back | ||||
* to do _bus_dmamap_load_phys() in loop. | * to do _bus_dmamap_load_phys() in loop. | ||||
*/ | */ | ||||
int bus_dmamap_load_ma_triv(bus_dma_tag_t dmat, bus_dmamap_t map, | int bus_dmamap_load_ma_triv(bus_dma_tag_t dmat, bus_dmamap_t map, | ||||
struct vm_page **ma, bus_size_t tlen, int ma_offs, int flags, | struct vm_page **ma, bus_size_t tlen, int ma_offs, int flags, | ||||
bus_dma_segment_t *segs, int *segp); | bus_dma_segment_t *segs, int *segp); | ||||
/* | #ifdef WANT_INLINE_DMAMAP | ||||
* XXX sparc64 uses the same interface, but a much different implementation. | #define BUS_DMAMAP_OP static inline | ||||
* <machine/bus_dma.h> for the sparc64 arch contains the equivalent | #else | ||||
* declarations. | #define BUS_DMAMAP_OP | ||||
*/ | #endif | ||||
#if !defined(__sparc64__) | |||||
/* | /* | ||||
* Allocate a handle for mapping from kva/uva/physical | * Allocate a handle for mapping from kva/uva/physical | ||||
* address space into bus device space. | * address space into bus device space. | ||||
*/ | */ | ||||
int bus_dmamap_create(bus_dma_tag_t dmat, int flags, bus_dmamap_t *mapp); | BUS_DMAMAP_OP int bus_dmamap_create(bus_dma_tag_t dmat, int flags, bus_dmamap_t *mapp); | ||||
/* | /* | ||||
* Destroy a handle for mapping from kva/uva/physical | * Destroy a handle for mapping from kva/uva/physical | ||||
* address space into bus device space. | * address space into bus device space. | ||||
*/ | */ | ||||
int bus_dmamap_destroy(bus_dma_tag_t dmat, bus_dmamap_t map); | BUS_DMAMAP_OP int bus_dmamap_destroy(bus_dma_tag_t dmat, bus_dmamap_t map); | ||||
/* | /* | ||||
* Allocate a piece of memory that can be efficiently mapped into | * Allocate a piece of memory that can be efficiently mapped into | ||||
* bus device space based on the constraints listed in the dma tag. | * bus device space based on the constraints listed in the dma tag. | ||||
* A dmamap to for use with dmamap_load is also allocated. | * A dmamap to for use with dmamap_load is also allocated. | ||||
*/ | */ | ||||
int bus_dmamem_alloc(bus_dma_tag_t dmat, void** vaddr, int flags, | BUS_DMAMAP_OP int bus_dmamem_alloc(bus_dma_tag_t dmat, void** vaddr, int flags, | ||||
bus_dmamap_t *mapp); | bus_dmamap_t *mapp); | ||||
/* | /* | ||||
* Free a piece of memory and its allocated dmamap, that was allocated | * Free a piece of memory and its allocated dmamap, that was allocated | ||||
* via bus_dmamem_alloc. | * via bus_dmamem_alloc. | ||||
*/ | */ | ||||
void bus_dmamem_free(bus_dma_tag_t dmat, void *vaddr, bus_dmamap_t map); | BUS_DMAMAP_OP void bus_dmamem_free(bus_dma_tag_t dmat, void *vaddr, bus_dmamap_t map); | ||||
/* | /* | ||||
* Perform a synchronization operation on the given map. If the map | * Perform a synchronization operation on the given map. If the map | ||||
* is NULL we have a fully IO-coherent system. On every ARM architecture | * is NULL we have a fully IO-coherent system. | ||||
* there must be a memory barrier placed to ensure that all data | |||||
* accesses are visible before going any further. | |||||
*/ | */ | ||||
void _bus_dmamap_sync(bus_dma_tag_t, bus_dmamap_t, bus_dmasync_op_t); | BUS_DMAMAP_OP void bus_dmamap_sync(bus_dma_tag_t dmat, bus_dmamap_t dmamap, bus_dmasync_op_t op); | ||||
#if defined(__arm__) | |||||
#define __BUS_DMAMAP_SYNC_DEFAULT mb() | |||||
#elif defined(__aarch64__) | |||||
#define __BUS_DMAMAP_SYNC_DEFAULT dmb(sy) | |||||
#else | |||||
#define __BUS_DMAMAP_SYNC_DEFAULT do {} while (0) | |||||
#endif | |||||
#define bus_dmamap_sync(dmat, dmamap, op) \ | |||||
do { \ | |||||
if ((dmamap) != NULL) \ | |||||
_bus_dmamap_sync(dmat, dmamap, op); \ | |||||
else \ | |||||
__BUS_DMAMAP_SYNC_DEFAULT; \ | |||||
} while (0) | |||||
/* | /* | ||||
* Release the mapping held by map. | * Release the mapping held by map. | ||||
*/ | */ | ||||
void _bus_dmamap_unload(bus_dma_tag_t dmat, bus_dmamap_t map); | BUS_DMAMAP_OP void bus_dmamap_unload(bus_dma_tag_t dmat, bus_dmamap_t dmamap); | ||||
#define bus_dmamap_unload(dmat, dmamap) \ | |||||
do { \ | |||||
if ((dmamap) != NULL) \ | |||||
_bus_dmamap_unload(dmat, dmamap); \ | |||||
} while (0) | |||||
/* | #undef BUS_DMAMAP_OP | ||||
* The following functions define the interface between the MD and MI | |||||
* busdma layers. These are not intended for consumption by driver | |||||
* software. | |||||
*/ | |||||
void __bus_dmamap_waitok(bus_dma_tag_t dmat, bus_dmamap_t map, | |||||
struct memdesc *mem, | |||||
bus_dmamap_callback_t *callback, | |||||
void *callback_arg); | |||||
#define _bus_dmamap_waitok(dmat, map, mem, callback, callback_arg) \ | |||||
do { \ | |||||
if ((map) != NULL) \ | |||||
__bus_dmamap_waitok(dmat, map, mem, callback, \ | |||||
callback_arg); \ | |||||
} while (0); | |||||
int _bus_dmamap_load_buffer(bus_dma_tag_t dmat, bus_dmamap_t map, | |||||
void *buf, bus_size_t buflen, struct pmap *pmap, | |||||
int flags, bus_dma_segment_t *segs, int *segp); | |||||
int _bus_dmamap_load_phys(bus_dma_tag_t dmat, bus_dmamap_t map, | |||||
vm_paddr_t paddr, bus_size_t buflen, | |||||
int flags, bus_dma_segment_t *segs, int *segp); | |||||
int _bus_dmamap_load_ma(bus_dma_tag_t dmat, bus_dmamap_t map, | |||||
struct vm_page **ma, bus_size_t tlen, int ma_offs, int flags, | |||||
bus_dma_segment_t *segs, int *segp); | |||||
bus_dma_segment_t *_bus_dmamap_complete(bus_dma_tag_t dmat, | |||||
bus_dmamap_t map, | |||||
bus_dma_segment_t *segs, | |||||
int nsegs, int error); | |||||
#endif /* __sparc64__ */ | |||||
#endif /* _BUS_DMA_H_ */ | #endif /* _BUS_DMA_H_ */ |