Changeset View
Standalone View
sys/sys/bus_dma.h
Show First 20 Lines • Show All 343 Lines • ▼ Show 20 Lines | |||||
bus_dma_segment_t *_bus_dmamap_complete(bus_dma_tag_t dmat, | bus_dma_segment_t *_bus_dmamap_complete(bus_dma_tag_t dmat, | ||||
bus_dmamap_t map, | bus_dmamap_t map, | ||||
bus_dma_segment_t *segs, | bus_dma_segment_t *segs, | ||||
int nsegs, int error); | int nsegs, int error); | ||||
#endif /* __sparc64__ */ | #endif /* __sparc64__ */ | ||||
/* | |||||
* A wrapper API to simplify management of static mappings. | |||||
*/ | |||||
struct bus_dmamem { | |||||
bus_dma_tag_t dma_tag; | |||||
bus_dmamap_t dma_map; | |||||
void *dma_vaddr; | |||||
bus_addr_t dma_baddr; | |||||
}; | |||||
/* Optional properties of a DMA memory allocation request. */ | |||||
struct bus_dmamem_args { | |||||
size_t dma_size; | |||||
bus_size_t dma_alignment; | |||||
bus_addr_t dma_boundary; | |||||
bus_addr_t dma_lowaddr; | |||||
bus_addr_t dma_highaddr; | |||||
cem: These could be named more descriptively — they really describe an excluded region, right? | |||||
jhbAuthorUnsubmitted Not Done Inline ActionsThese match the args to bus_dma_tag_create. We could perhaps boil that ocean when revisiting bus_dma_tag_create, but I think it is worth it to be consistent for now. jhb: These match the args to bus_dma_tag_create. We could perhaps boil that ocean when revisiting… | |||||
cemUnsubmitted Not Done Inline ActionsYeah, I understood where they came from, but I don't think we care about matching names exactly with bus_dma_tag_create. C consumers do not use parameter names in invocation, so it's not like any driver today initializes with anything other than the equivalent of a struct literal with an ordered list of member values. We can change it later, but it's always easier to change before anything is written down, so to speak. Any name change to struct members won't be MFCable, for example, and that pretty much poisons ever changing it once the struct lands in a stable branch. cem: Yeah, I understood where they came from, but I don't think we care about matching names exactly… | |||||
}; | |||||
void bus_dma_mem_args_init_impl(struct bus_dmamem_args *args, size_t sz); | |||||
#define bus_dma_mem_args_init(a) \ | |||||
bus_dma_mem_args_init_impl((a), sizeof(struct bus_dmamem_args)) | |||||
cemUnsubmitted Not Done Inline ActionsI guess this could be a static inline function too. cem: I guess this could be a `static inline` function too. | |||||
jhbAuthorUnsubmitted Not Done Inline ActionsHmm, possibly. This is the style that make_dev_s() uses which is what I modeled this on. It is very important that it uses the caller's size and not a size compiled into the kernel (so if the compiler ever chose to not inline it by treating the 'inline' as advisory only and still generating a real function that it called it would be fatal) jhb: Hmm, possibly. This is the style that make_dev_s() uses which is what I modeled this on. It… | |||||
cemUnsubmitted Not Done Inline ActionsYeah, I agree that inline is definitely not safe on its own. I think static inline is safe — I don't believe the compiler is allowed to treat the static as advisory. cem: Yeah, I agree that `inline` is definitely not safe on its own. I think `static inline` is safe… | |||||
/* | |||||
* Allocates memory for DMA and maps it. On success, zero is returned | |||||
* and the 'dma_vaddr' and 'dma_baddr' fields are populated with the | |||||
* virtual and bus addresses, respectively, of the mapping. | |||||
*/ | |||||
int bus_dma_mem_alloc(bus_dma_tag_t parent, bus_size_t len, int flags, | |||||
struct bus_dmamem_args *args, struct bus_dmamem *mem); | |||||
/* | |||||
* Wrapper for bus_dmamap_sync() for memory allocated via | |||||
* bus_dma_mem_alloc(). | |||||
*/ | |||||
#define bus_dma_mem_sync(mem, op) \ | |||||
cemUnsubmitted Not Done Inline ActionsThere's no reason this should not be an inline function instead. cem: There's no reason this should not be an inline function instead. | |||||
bus_dmamap_sync((mem)->dma_tag, (mem)->dma_map, (op)) | |||||
/* | |||||
* Release a mapping created by bus_dma_mem_alloc(). | |||||
*/ | |||||
void bus_dma_mem_free(struct bus_dmamem *mem); | |||||
#endif /* _BUS_DMA_H_ */ | #endif /* _BUS_DMA_H_ */ |
These could be named more descriptively — they really describe an excluded region, right?