FreeBSD/sys/sparc64/sparc64/iommu.c
/*
 * Allocate DVMA virtual memory for a map.  The map may not be on a queue,
 * so that it can be freely modified.
 */
Allocate DVMA virtual memory for a map.  The map may not be on a queue,
so that it can be freely modified.
Allocate DVMA virtual memory for a map . The map may not be on a queue so that it can be freely modified .
static int
iommu_dvma_valloc(bus_dma_tag_t t, struct iommu_state *is, bus_dmamap_t map,
    bus_size_t size)
{
	struct resource *res;
	struct bus_dmamap_res *bdr;
	bus_size_t align, sgsize;
	KASSERT(!map->dm_onq, ("%s: map on queue!", __func__));
	if ((bdr = malloc(sizeof(*bdr), M_IOMMU, M_NOWAIT)) == NULL)
		return (EAGAIN);
	align = (t->dt_alignment + IO_PAGE_MASK) >> IO_PAGE_SHIFT;
	sgsize = round_io_page(size) >> IO_PAGE_SHIFT;
	if (t->dt_boundary > 0 && t->dt_boundary < IO_PAGE_SIZE)
		panic("%s: illegal boundary specified", __func__);
	res = rman_reserve_resource_bound(&is->is_dvma_rman, 0L,
	    t->dt_lowaddr >> IO_PAGE_SHIFT, sgsize,
	    t->dt_boundary >> IO_PAGE_SHIFT,
	    RF_ACTIVE | rman_make_alignment_flags(align), NULL);
	if (res == NULL) {
		free(bdr, M_IOMMU);
		return (ENOMEM);
	}
	bdr->dr_res = res;
	bdr->dr_used = 0;
	SLIST_INSERT_HEAD(&map->dm_reslist, bdr, dr_link);
	return (0);
}
static int iommu_dvma_valloc ( bus_dma_tag_t t , struct iommu_state * is , bus_dmamap_t map , bus_size_t size ) { struct resource * res ; struct bus_dmamap_res * bdr ; bus_size_t align , sgsize ; KASSERT ( ! map -> dm_onq , ( " " , __func__ ) ) ; if ( ( bdr = malloc ( sizeof ( * bdr ) , M_IOMMU , M_NOWAIT ) ) == NULL ) return ( EAGAIN ) ; align = ( t -> dt_alignment + IO_PAGE_MASK ) >> IO_PAGE_SHIFT ; sgsize = round_io_page ( size ) >> IO_PAGE_SHIFT ; if ( t -> dt_boundary > 0 && t -> dt_boundary < IO_PAGE_SIZE ) panic ( " " , __func__ ) ; res = rman_reserve_resource_bound ( & is -> is_dvma_rman , 0L , t -> dt_lowaddr >> IO_PAGE_SHIFT , sgsize , t -> dt_boundary >> IO_PAGE_SHIFT , RF_ACTIVE | rman_make_alignment_flags ( align ) , NULL ) ; if ( res == NULL ) { free ( bdr , M_IOMMU ) ; return ( ENOMEM ) ; } bdr -> dr_res = res ; bdr -> dr_used = 0 ; SLIST_INSERT_HEAD ( & map -> dm_reslist , bdr , dr_link ) ; return ( 0 ) ; }
Allocate DVMA virtual memory for a map.
Allocate DVMA virtual memory for a map .
/*
	 * If a boundary is specified, a map cannot be larger than it; however
	 * we do not clip currently, as that does not play well with the lazy
	 * allocation code.
	 * Alignment to a page boundary is always enforced.
	 */