MCPcopy Create free account
hub / github.com/F-Stack/f-stack / allocate_map

Function allocate_map

freebsd/arm/arm/busdma_machdep.c:685–709  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

683}
684
685static bus_dmamap_t
686allocate_map(bus_dma_tag_t dmat, int mflags)
687{
688 int mapsize, segsize;
689 bus_dmamap_t map;
690
691 /*
692 * Allocate the map. The map structure ends with an embedded
693 * variable-sized array of sync_list structures. Following that
694 * we allocate enough extra space to hold the array of bus_dma_segments.
695 */
696 KASSERT(dmat->nsegments <= MAX_DMA_SEGMENTS,
697 ("cannot allocate %u dma segments (max is %u)",
698 dmat->nsegments, MAX_DMA_SEGMENTS));
699 segsize = sizeof(struct bus_dma_segment) * dmat->nsegments;
700 mapsize = sizeof(*map) + sizeof(struct sync_list) * dmat->nsegments;
701 map = malloc(mapsize + segsize, M_BUSDMA, mflags | M_ZERO);
702 if (map == NULL) {
703 CTR3(KTR_BUSDMA, "%s: tag %p error %d", __func__, dmat, ENOMEM);
704 return (NULL);
705 }
706 map->segments = (bus_dma_segment_t *)((uintptr_t)map + mapsize);
707 STAILQ_INIT(&map->bpages);
708 return (map);
709}
710
711/*
712 * Allocate a handle for mapping from kva/uva/physical

Callers 2

bus_dmamap_createFunction · 0.85
bus_dmamem_allocFunction · 0.85

Calls 1

mallocFunction · 0.85

Tested by

no test coverage detected