• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

C++ bus_dmamem_unmap函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C++中bus_dmamem_unmap函数的典型用法代码示例。如果您正苦于以下问题:C++ bus_dmamem_unmap函数的具体用法?C++ bus_dmamem_unmap怎么用?C++ bus_dmamem_unmap使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了bus_dmamem_unmap函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。

示例1: gk20a_ram_put

static void
gk20a_ram_put(struct nouveau_fb *pfb, struct nouveau_mem **pmem)
{
	struct gk20a_mem *mem = to_gk20a_mem(*pmem);

	*pmem = NULL;
	if (unlikely(mem == NULL))
		return;

#if defined(__NetBSD__)
	if (likely(mem->base.pages)) {
		const bus_dma_tag_t dmat = nv_device(pfb)->platformdev->dmat;
		bus_dmamap_unload(dmat, mem->base.pages);
		bus_dmamem_unmap(dmat, mem->cpuaddr, mem->dmasize);
		bus_dmamap_destroy(dmat, mem->base.pages);
		bus_dmamem_free(dmat, &mem->dmaseg, 1);
	}
#else
	struct device *dev = nv_device_base(nv_device(pfb));
	if (likely(mem->cpuaddr))
		dma_free_coherent(dev, mem->base.size << PAGE_SHIFT,
				  mem->cpuaddr, mem->handle);

	kfree(mem->base.pages);
#endif
	kfree(mem);
}
开发者ID:ryo,项目名称:netbsd-src,代码行数:27,代码来源:nouveau_subdev_fb_ramgk20a.c


示例2: rtwn_free_tx_list

void
rtwn_free_tx_list(struct rtwn_pci_softc *sc, int qid)
{
	struct rtwn_tx_ring *tx_ring = &sc->tx_ring[qid];
	struct rtwn_tx_data *tx_data;
	int i;

	if (tx_ring->map != NULL) {
		if (tx_ring->desc != NULL) {
			bus_dmamap_unload(sc->sc_dmat, tx_ring->map);
			bus_dmamem_unmap(sc->sc_dmat, (caddr_t)tx_ring->desc,
			    sizeof (struct r92c_tx_desc_pci) *
			    RTWN_TX_LIST_COUNT);
			bus_dmamem_free(sc->sc_dmat, &tx_ring->seg, tx_ring->nsegs);
		}
		bus_dmamap_destroy(sc->sc_dmat, tx_ring->map);
	}

	for (i = 0; i < RTWN_TX_LIST_COUNT; i++) {
		tx_data = &tx_ring->tx_data[i];

		if (tx_data->m != NULL) {
			bus_dmamap_unload(sc->sc_dmat, tx_data->map);
			m_freem(tx_data->m);
			tx_data->m = NULL;
		}
		bus_dmamap_destroy(sc->sc_dmat, tx_data->map);
	}

	sc->qfullmsk &= ~(1 << qid);
	tx_ring->queued = 0;
	tx_ring->cur = 0;
}
开发者ID:mosconi,项目名称:openbsd,代码行数:33,代码来源:if_rtwn.c


示例3: s3c24x0_lcd_free_screen

void
s3c24x0_lcd_free_screen(void *v, void *cookie)
{
	struct s3c24x0_lcd_softc *sc = v;
	struct s3c24x0_lcd_screen *scr = cookie;

	LIST_REMOVE(scr, link);
	sc->n_screens--;
	if (scr == sc->active) {
		sc->active = NULL;

		/* XXX: We need a good procedure to shutdown the LCD. */

		s3c24x0_lcd_stop_dma(sc);
		s3c24x0_lcd_power(sc, 0);
	}

	if (scr->buf_va)
		bus_dmamem_unmap(sc->dma_tag, scr->buf_va, scr->map_size);

	if (scr->nsegs > 0)
		bus_dmamem_free(sc->dma_tag, scr->segs, scr->nsegs);

	free(scr, M_DEVBUF);
}
开发者ID:lacombar,项目名称:netbsd-alc,代码行数:25,代码来源:s3c24x0_lcd.c


示例4: cs428x_allocmem

/* Internal functions */
int
cs428x_allocmem(struct cs428x_softc *sc, 
		size_t size, int pool, int flags,
		struct cs428x_dma *p)
{
	int error;
	size_t align;

	align   = sc->dma_align;
	p->size = sc->dma_size;
	/* allocate memory for upper audio driver */
	p->dum  = malloc(size, pool, flags);
	if (p->dum == NULL)
		return 1;

	error = bus_dmamem_alloc(sc->sc_dmatag, p->size, align, 0,
				 p->segs, sizeof(p->segs)/sizeof(p->segs[0]),
				 &p->nsegs, BUS_DMA_NOWAIT);
	if (error) {
		printf("%s: unable to allocate dma. error=%d\n",
		       sc->sc_dev.dv_xname, error);
		goto allfree;
	}

	error = bus_dmamem_map(sc->sc_dmatag, p->segs, p->nsegs, p->size,
			       &p->addr, BUS_DMA_NOWAIT|BUS_DMA_COHERENT);
	if (error) {
		printf("%s: unable to map dma, error=%d\n",
		       sc->sc_dev.dv_xname, error);
		goto free;
	}

	error = bus_dmamap_create(sc->sc_dmatag, p->size, 1, p->size,
				  0, BUS_DMA_NOWAIT, &p->map);
	if (error) {
		printf("%s: unable to create dma map, error=%d\n",
		       sc->sc_dev.dv_xname, error);
		goto unmap;
	}

	error = bus_dmamap_load(sc->sc_dmatag, p->map, p->addr, p->size, NULL,
				BUS_DMA_NOWAIT);
	if (error) {
		printf("%s: unable to load dma map, error=%d\n",
		       sc->sc_dev.dv_xname, error);
		goto destroy;
	}
	return 0;

 destroy:
	bus_dmamap_destroy(sc->sc_dmatag, p->map);
 unmap:
	bus_dmamem_unmap(sc->sc_dmatag, p->addr, p->size);
 free:
	bus_dmamem_free(sc->sc_dmatag, p->segs, p->nsegs);
 allfree:
	free(p->dum, pool);

	return error;
}
开发者ID:MarginC,项目名称:kame,代码行数:61,代码来源:cs428x.c


示例5: ubmemfree

void
ubmemfree(struct uba_softc *uh, struct ubinfo *ui)
{
	bus_dmamem_unmap(uh->uh_dmat, ui->ui_vaddr, ui->ui_size);
	bus_dmamem_free(uh->uh_dmat, &ui->ui_seg, ui->ui_rseg);
	ubfree(uh, ui);
}
开发者ID:orumin,项目名称:openbsd-efivars,代码行数:7,代码来源:uba.c


示例6: ld_virtio_detach

static int
ld_virtio_detach(device_t self, int flags)
{
	struct ld_virtio_softc *sc = device_private(self);
	struct ld_softc *ld = &sc->sc_ld;
	bus_dma_tag_t dmat = sc->sc_virtio->sc_dmat;
	int r, i, qsize;

	qsize = sc->sc_vq.vq_num;
	r = ldbegindetach(ld, flags);
	if (r != 0)
		return r;
	virtio_reset(sc->sc_virtio);
	virtio_free_vq(sc->sc_virtio, &sc->sc_vq);

	for (i = 0; i < qsize; i++) {
		bus_dmamap_destroy(dmat,
				   sc->sc_reqs[i].vr_cmdsts);
		bus_dmamap_destroy(dmat,
				   sc->sc_reqs[i].vr_payload);
	}
	bus_dmamem_unmap(dmat, sc->sc_reqs,
			 sizeof(struct virtio_blk_req) * qsize);
	bus_dmamem_free(dmat, &sc->sc_reqs_seg, 1);

	ldenddetach(ld);

	return 0;
}
开发者ID:ryo,项目名称:netbsd-src,代码行数:29,代码来源:ld_virtio.c


示例7: n8_FreeLargeAllocation

void
n8_FreeLargeAllocation(N8_MemoryType_t bankIndex,
                       unsigned char   debug)
{
    NspInstance_t	*nip  = &NSPDeviceTable_g[0];	/* can only attach once */
    struct nsp_softc *sc = (struct nsp_softc *)nip->dev;

    printf("n8_FreeLargeAllocation: freeing %p for bankIndex %d\n",
           BasePointer_g[bankIndex], bankIndex);
    if (debug) {
        printf("n8_FreeLargeAllocation: freeing %p for bankIndex %d\n",
               BasePointer_g[bankIndex], bankIndex);
    }

    if (BasePointer_g[bankIndex]) {
        /* contigfree(BasePointer_g[bankIndex], MemSize_g[bankIndex], M_DEVBUF); */
        printf("n8_FreeLargeAllocation: bus_dmamap_unload(bank %d) (kva=%p)\n",
               bankIndex, BasePointer_g[bankIndex]);
        bus_dmamap_unload(sc->dma_tag, DmaMap_g[bankIndex]);
        printf("n8_FreeLargeAllocation: bus_dmamap_destroy()\n");
        bus_dmamap_destroy(sc->dma_tag, DmaMap_g[bankIndex]);
        printf("n8_FreeLargeAllocation: bus_dmamap_unmap()\n");
        bus_dmamem_unmap(sc->dma_tag, BasePointer_g[bankIndex],
                         MemSize_g[bankIndex]);
        printf("n8_FreeLargeAllocation: bus_dmamap_unmap()\n");
        bus_dmamem_free(sc->dma_tag, &Seg_g[bankIndex], Rseg_g[bankIndex]);
    }
    BasePointer_g[bankIndex] = NULL;
}
开发者ID:NetBsdDriverProxy,项目名称:NetBsdDriverProxy,代码行数:29,代码来源:n8_memory_bsd.c


示例8: coram_allocmem

static int
coram_allocmem(struct coram_softc *sc, size_t size, size_t align,
    struct coram_dma *p)
{
	int err;

	p->size = size;
	err = bus_dmamem_alloc(sc->sc_dmat, p->size, align, 0,
	    p->segs, sizeof(p->segs) / sizeof(p->segs[0]),
	    &p->nsegs, BUS_DMA_NOWAIT);
	if (err)
		return err;
	err = bus_dmamem_map(sc->sc_dmat, p->segs, p->nsegs, p->size,
	    &p->addr, BUS_DMA_NOWAIT|BUS_DMA_COHERENT);
	if (err)
		goto free;
	err = bus_dmamap_create(sc->sc_dmat, p->size, 1, p->size, 0,
	    BUS_DMA_NOWAIT, &p->map);
	if (err)
		goto unmap;
	err = bus_dmamap_load(sc->sc_dmat, p->map, p->addr, p->size, NULL,
	    BUS_DMA_NOWAIT);
	if (err)
		goto destroy;

	return 0;
destroy:
	bus_dmamap_destroy(sc->sc_dmat, p->map);
unmap:
	bus_dmamem_unmap(sc->sc_dmat, p->addr, p->size);
free:
	bus_dmamem_free(sc->sc_dmat, p->segs, p->nsegs);

	return err;
}
开发者ID:RyanLucchese,项目名称:rumpkernel-netbsd-src,代码行数:35,代码来源:coram.c


示例9: dmac_free_channel

int
dmac_free_channel(device_t self, int ch, void *channel)
{
	struct intio_softc *intio = device_private(self);
	struct dmac_softc *dmac = device_private(intio->sc_dmac);
	struct dmac_channel_stat *chan = &dmac->sc_channels[ch];

	DPRINTF(3, ("dmac_free_channel, %d\n", ch));
	DPRINTF(3, ("dmamap=%p\n", (void *)chan->ch_xfer.dx_dmamap));
	if (chan != channel)
		return -1;
	if (ch != chan->ch_channel)
		return -1;

#ifdef DMAC_ARRAYCHAIN
	bus_dmamem_unmap(intio->sc_dmat, (void *)chan->ch_map,
			 sizeof(struct dmac_sg_array) * DMAC_MAPSIZE);
	bus_dmamem_free(intio->sc_dmat, &chan->ch_seg[0], 1);
#endif
	chan->ch_name[0] = 0;
	intio_intr_disestablish(chan->ch_normalv, channel);
	intio_intr_disestablish(chan->ch_errorv, channel);

	return 0;
}
开发者ID:ryo,项目名称:netbsd-src,代码行数:25,代码来源:intio_dmac.c


示例10: tsec_dmamem_free

void
tsec_dmamem_free(struct tsec_softc *sc, struct tsec_dmamem *tdm)
{
	bus_dmamem_unmap(sc->sc_dmat, tdm->tdm_kva, tdm->tdm_size);
	bus_dmamem_free(sc->sc_dmat, &tdm->tdm_seg, 1);
	bus_dmamap_destroy(sc->sc_dmat, tdm->tdm_map);
	free(tdm, M_DEVBUF);
}
开发者ID:bradla,项目名称:OpenBSD-Hammer2,代码行数:8,代码来源:if_tsec.c


示例11: pxa2x0_i2s_allocm

void *
pxa2x0_i2s_allocm(void *hdl, int direction, size_t size, int type, int flags)
{
	struct device *sc_dev = hdl;
	struct pxa2x0_i2s_softc *sc =
	    (struct pxa2x0_i2s_softc *)((struct device *)hdl + 1);
	struct pxa2x0_i2s_dma *p;
	int error;
	int rseg;

	p = malloc(sizeof(*p), type, flags);
	if (!p)
		return 0;

	p->size = size;
	if ((error = bus_dmamem_alloc(sc->sc_dmat, size, NBPG, 0, &p->seg, 1,
	    &rseg, BUS_DMA_NOWAIT)) != 0) {
		printf("%s: unable to allocate dma, error = %d\n",
		    sc_dev->dv_xname, error);
		goto fail_alloc;
	}

	if ((error = bus_dmamem_map(sc->sc_dmat, &p->seg, rseg, size, &p->addr,
	    BUS_DMA_NOWAIT | BUS_DMA_COHERENT)) != 0) {
		printf("%s: unable to map dma, error = %d\n",
		    sc_dev->dv_xname, error);
		goto fail_map;
	}

	if ((error = bus_dmamap_create(sc->sc_dmat, size, 1, size, 0,
	    BUS_DMA_NOWAIT, &p->map)) != 0) {
		printf("%s: unable to create dma map, error = %d\n",
		    sc_dev->dv_xname, error);
		goto fail_create;
	}

	if ((error = bus_dmamap_load(sc->sc_dmat, p->map, p->addr, size, NULL,
	    BUS_DMA_NOWAIT)) != 0) {
		printf("%s: unable to load dma map, error = %d\n",
		    sc_dev->dv_xname, error);
		goto fail_load;
	}

	p->next = sc->sc_dmas;
	sc->sc_dmas = p;

	return p->addr;

fail_load:
	bus_dmamap_destroy(sc->sc_dmat, p->map);
fail_create:
	bus_dmamem_unmap(sc->sc_dmat, p->addr, size);
fail_map:
	bus_dmamem_free(sc->sc_dmat, &p->seg, 1);
fail_alloc:
	free(p, type);
	return 0;
}
开发者ID:repos-holder,项目名称:openbsd-patches,代码行数:58,代码来源:pxa2x0_i2s.c


示例12: imxenet_dma_malloc

/*
 * Manage DMA'able memory.
 */
int
imxenet_dma_malloc(struct imxenet_softc *sc, bus_size_t size,
    struct imxenet_dma_alloc *dma)
{
	int r;

	dma->dma_tag = sc->sc_dma_tag;
	r = bus_dmamem_alloc(dma->dma_tag, size, ENET_ALIGNMENT, 0, &dma->dma_seg,
	    1, &dma->dma_nseg, BUS_DMA_NOWAIT);
	if (r != 0) {
		printf("%s: imxenet_dma_malloc: bus_dmammem_alloc failed; "
			"size %lu, error %d\n", sc->sc_dev.dv_xname,
			(unsigned long)size, r);
		goto fail_0;
	}

	r = bus_dmamem_map(dma->dma_tag, &dma->dma_seg, dma->dma_nseg, size,
	    &dma->dma_vaddr, BUS_DMA_NOWAIT|BUS_DMA_COHERENT);
	if (r != 0) {
		printf("%s: imxenet_dma_malloc: bus_dmammem_map failed; "
			"size %lu, error %d\n", sc->sc_dev.dv_xname,
			(unsigned long)size, r);
		goto fail_1;
	}

	r = bus_dmamap_create(dma->dma_tag, size, 1,
	    size, 0, BUS_DMA_NOWAIT, &dma->dma_map);
	if (r != 0) {
		printf("%s: imxenet_dma_malloc: bus_dmamap_create failed; "
			"error %u\n", sc->sc_dev.dv_xname, r);
		goto fail_2;
	}

	r = bus_dmamap_load(dma->dma_tag, dma->dma_map,
			    dma->dma_vaddr, size, NULL,
			    BUS_DMA_NOWAIT);
	if (r != 0) {
		printf("%s: imxenet_dma_malloc: bus_dmamap_load failed; "
			"error %u\n", sc->sc_dev.dv_xname, r);
		goto fail_3;
	}

	dma->dma_size = size;
	dma->dma_paddr = dma->dma_map->dm_segs[0].ds_addr;
	return (0);

fail_3:
	bus_dmamap_destroy(dma->dma_tag, dma->dma_map);
fail_2:
	bus_dmamem_unmap(dma->dma_tag, dma->dma_vaddr, size);
fail_1:
	bus_dmamem_free(dma->dma_tag, &dma->dma_seg, dma->dma_nseg);
fail_0:
	dma->dma_map = NULL;
	dma->dma_tag = NULL;

	return (r);
}
开发者ID:appleorange1,项目名称:bitrig,代码行数:61,代码来源:imxenet.c


示例13: ldc_map_alloc

struct ldc_map *
ldc_map_alloc(int nentries)
#endif
{
	struct ldc_map *lm;
	bus_size_t size;
	vaddr_t va = 0;

#if OPENBSD_BUSDMA
	int nsegs;
#endif
	lm = kmem_zalloc(sizeof(struct ldc_map), KM_NOSLEEP);
	if (lm == NULL)
		return NULL;

	size = roundup(nentries * sizeof(struct ldc_map_slot), PAGE_SIZE);

#if OPENBSD_BUSDMA
	if (bus_dmamap_create(t, size, 1, size, 0,
			      BUS_DMA_NOWAIT | BUS_DMA_ALLOCNOW, &lm->lm_map) != 0) {
		DPRINTF(("ldc_map_alloc() - bus_dmamap_create() failed\n"));
		return (NULL);
	}

	if (bus_dmamem_alloc(t, size, PAGE_SIZE, 0, &lm->lm_seg, 1,
			     &nsegs, BUS_DMA_NOWAIT) != 0) {
		DPRINTF(("ldc_map_alloc() - bus_dmamem_alloc() failed\n"));
		goto destroy;
	}

	if (bus_dmamem_map(t, &lm->lm_seg, 1, size, (void *)&va,
			   BUS_DMA_NOWAIT) != 0) {
		DPRINTF(("ldc_map_alloc() - bus_dmamem_map() failed\n"));
		goto free;
	}
	if (bus_dmamap_load(t, lm->lm_map, (void*)va, size, NULL,
			    BUS_DMA_NOWAIT) != 0) {
		DPRINTF(("ldc_map_alloc() - bus_dmamap_load() failed\n"));
		goto unmap;
	}
#else
	va = (vaddr_t)kmem_zalloc(size, KM_NOSLEEP);
#endif
	lm->lm_slot = (struct ldc_map_slot *)va;
	lm->lm_nentries = nentries;
	bzero(lm->lm_slot, nentries * sizeof(struct ldc_map_slot));
	return (lm);

#if OPENBSD_BUSDMA
unmap:
	bus_dmamem_unmap(t, (void*)va, size);
free:
	bus_dmamem_free(t, &lm->lm_seg, 1);
destroy:
	bus_dmamap_destroy(t, lm->lm_map);
#endif
	return (NULL);
}
开发者ID:ryo,项目名称:netbsd-src,代码行数:58,代码来源:ldc.c


示例14: auvia_malloc

void *
auvia_malloc(void *addr, int direction, size_t size, int pool, int flags)
{
	struct auvia_softc *sc = addr;
	struct auvia_dma *p;
	int error;
	int rseg;

	p = malloc(sizeof(*p), pool, flags);
	if (!p)
		return 0;

	p->size = size;
	if ((error = bus_dmamem_alloc(sc->sc_dmat, size, PAGE_SIZE, 0, &p->seg,
	    1, &rseg, BUS_DMA_NOWAIT)) != 0) {
		printf("%s: unable to allocate dma, error = %d\n",
		    sc->sc_dev.dv_xname, error);
		goto fail_alloc;
	}

	if ((error = bus_dmamem_map(sc->sc_dmat, &p->seg, rseg, size, &p->addr,
	    BUS_DMA_NOWAIT | BUS_DMA_COHERENT)) != 0) {
		printf("%s: unable to map dma, error = %d\n",
		    sc->sc_dev.dv_xname, error);
		goto fail_map;
	}

	if ((error = bus_dmamap_create(sc->sc_dmat, size, 1, size, 0,
	    BUS_DMA_NOWAIT, &p->map)) != 0) {
		printf("%s: unable to create dma map, error = %d\n",
		    sc->sc_dev.dv_xname, error);
		goto fail_create;
	}

	if ((error = bus_dmamap_load(sc->sc_dmat, p->map, p->addr, size, NULL,
	    BUS_DMA_NOWAIT)) != 0) {
		printf("%s: unable to load dma map, error = %d\n",
		    sc->sc_dev.dv_xname, error);
		goto fail_load;
	}

	p->next = sc->sc_dmas;
	sc->sc_dmas = p;

	return p->addr;


fail_load:
	bus_dmamap_destroy(sc->sc_dmat, p->map);
fail_create:
	bus_dmamem_unmap(sc->sc_dmat, p->addr, size);
fail_map:
	bus_dmamem_free(sc->sc_dmat, &p->seg, 1);
fail_alloc:
	free(p, pool);
	return 0;
}
开发者ID:alenichev,项目名称:openbsd-kernel,代码行数:57,代码来源:auvia.c


示例15: auich_alloc_cdata

static int
auich_alloc_cdata(struct auich_softc *sc)
{
	bus_dma_segment_t seg;
	int error, rseg;

	/*
	 * Allocate the control data structure, and create and load the
	 * DMA map for it.
	 */
	if ((error = bus_dmamem_alloc(sc->dmat,
				      sizeof(struct auich_cdata),
				      PAGE_SIZE, 0, &seg, 1, &rseg, 0)) != 0) {
		aprint_error_dev(sc->sc_dev, "unable to allocate control data, error = %d\n", error);
		goto fail_0;
	}

	if ((error = bus_dmamem_map(sc->dmat, &seg, rseg,
				    sizeof(struct auich_cdata),
				    (void **) &sc->sc_cdata,
				    sc->sc_dmamap_flags)) != 0) {
		aprint_error_dev(sc->sc_dev, "unable to map control data, error = %d\n", error);
		goto fail_1;
	}

	if ((error = bus_dmamap_create(sc->dmat, sizeof(struct auich_cdata), 1,
				       sizeof(struct auich_cdata), 0, 0,
				       &sc->sc_cddmamap)) != 0) {
		aprint_error_dev(sc->sc_dev, "unable to create control data DMA map, "
		    "error = %d\n", error);
		goto fail_2;
	}

	if ((error = bus_dmamap_load(sc->dmat, sc->sc_cddmamap,
				     sc->sc_cdata, sizeof(struct auich_cdata),
				     NULL, 0)) != 0) {
		aprint_error_dev(sc->sc_dev, "unable tp load control data DMA map, "
		    "error = %d\n", error);
		goto fail_3;
	}

	sc->pcmo.dmalist = sc->sc_cdata->ic_dmalist_pcmo;
	sc->pcmi.dmalist = sc->sc_cdata->ic_dmalist_pcmi;
	sc->mici.dmalist = sc->sc_cdata->ic_dmalist_mici;

	return 0;

 fail_3:
	bus_dmamap_destroy(sc->dmat, sc->sc_cddmamap);
 fail_2:
	bus_dmamem_unmap(sc->dmat, (void *) sc->sc_cdata,
	    sizeof(struct auich_cdata));
 fail_1:
	bus_dmamem_free(sc->dmat, &seg, rseg);
 fail_0:
	return error;
}
开发者ID:RyanLucchese,项目名称:rumpkernel-netbsd-src,代码行数:57,代码来源:auich.c


示例16: fms_malloc

static void *
fms_malloc(void *addr, int direction, size_t size)
{
	struct fms_softc *sc;
	struct fms_dma *p;
	int error;
	int rseg;

	sc = addr;
	p = kmem_alloc(sizeof(*p), KM_SLEEP);
	if (p == NULL)
		return NULL;

	p->size = size;
	if ((error = bus_dmamem_alloc(sc->sc_dmat, size, PAGE_SIZE, 0, &p->seg,
				      1, &rseg, BUS_DMA_WAITOK)) != 0) {
		aprint_error_dev(sc->sc_dev, "unable to allocate DMA, error = %d\n", error);
		goto fail_alloc;
	}

	if ((error = bus_dmamem_map(sc->sc_dmat, &p->seg, rseg, size, &p->addr,
				    BUS_DMA_WAITOK | BUS_DMA_COHERENT)) != 0) {
		aprint_error_dev(sc->sc_dev, "unable to map DMA, error = %d\n",
		       error);
		goto fail_map;
	}

	if ((error = bus_dmamap_create(sc->sc_dmat, size, 1, size, 0,
				       BUS_DMA_WAITOK, &p->map)) != 0) {
		aprint_error_dev(sc->sc_dev, "unable to create DMA map, error = %d\n",
		       error);
		goto fail_create;
	}

	if ((error = bus_dmamap_load(sc->sc_dmat, p->map, p->addr, size, NULL,
				     BUS_DMA_WAITOK)) != 0) {
		aprint_error_dev(sc->sc_dev, "unable to load DMA map, error = %d\n",
		       error);
		goto fail_load;
	}

	p->next = sc->sc_dmas;
	sc->sc_dmas = p;

	return p->addr;


fail_load:
	bus_dmamap_destroy(sc->sc_dmat, p->map);
fail_create:
	bus_dmamem_unmap(sc->sc_dmat, p->addr, size);
fail_map:
	bus_dmamem_free(sc->sc_dmat, &p->seg, 1);
fail_alloc:
	kmem_free(p, sizeof(*p));
	return NULL;
}
开发者ID:RyanLucchese,项目名称:rumpkernel-netbsd-src,代码行数:57,代码来源:fms.c


示例17: auacer_freemem

static int
auacer_freemem(struct auacer_softc *sc, struct auacer_dma *p)
{

	bus_dmamap_unload(sc->dmat, p->map);
	bus_dmamap_destroy(sc->dmat, p->map);
	bus_dmamem_unmap(sc->dmat, p->addr, p->size);
	bus_dmamem_free(sc->dmat, p->segs, p->nsegs);
	return 0;
}
开发者ID:NetBsdDriverProxy,项目名称:NetBsdDriverProxy,代码行数:10,代码来源:auacer.c


示例18: drm_pci_alloc

drm_dma_handle_t *
drm_pci_alloc(drm_device_t *dev, size_t size, size_t align, dma_addr_t maxaddr)
{
    drm_dma_handle_t *h;
    int error, nsegs;


    /* Need power-of-two alignment, so fail the allocation if it isn't. */
    if ((align & (align - 1)) != 0) {
        DRM_ERROR("drm_pci_alloc with non-power-of-two alignment %d\n",
                  (int)align);
        return NULL;
    }

    h = malloc(sizeof(drm_dma_handle_t), M_DRM, M_ZERO | M_NOWAIT);

    if (h == NULL)
        return NULL;
    if ((error = bus_dmamem_alloc(dev->pa.pa_dmat, size, align, 0,
                                  h->segs, 1, &nsegs, BUS_DMA_NOWAIT)) != 0) {
        printf("drm: Unable to allocate DMA, error %d\n", error);
        goto fail;
    }
    if ((error = bus_dmamem_map(dev->pa.pa_dmat, h->segs, nsegs, size,
                                &h->addr, BUS_DMA_NOWAIT | BUS_DMA_COHERENT)) != 0) {
        printf("drm: Unable to map DMA, error %d\n", error);
        goto free;
    }
    if ((error = bus_dmamap_create(dev->pa.pa_dmat, size, 1, size, 0,
                                   BUS_DMA_NOWAIT | BUS_DMA_ALLOCNOW, &h->map)) != 0) {
        printf("drm: Unable to create DMA map, error %d\n", error);
        goto unmap;
    }
    if ((error = bus_dmamap_load(dev->pa.pa_dmat, h->map, h->addr, size,
                                 NULL, BUS_DMA_NOWAIT)) != 0) {
        printf("drm: Unable to load DMA map, error %d\n", error);
        goto destroy;
    }
    h->busaddr = DRM_PCI_DMAADDR(h);
    h->vaddr = h->addr;
    h->size = size;

    return h;

destroy:
    bus_dmamap_destroy(dev->pa.pa_dmat, h->map);
unmap:
    bus_dmamem_unmap(dev->pa.pa_dmat, h->addr, size);
free:
    bus_dmamem_free(dev->pa.pa_dmat, h->segs, 1);
fail:
    free(h, M_DRM);
    return NULL;

}
开发者ID:lacombar,项目名称:netbsd-alc,代码行数:55,代码来源:drm_pci.c


示例19: drm_pci_free

/*
 * Release the bus DMA mappings and memory in dmah, and deallocate it.
 */
void
drm_pci_free(struct drm_device *dev, struct drm_dma_handle *dmah)
{

	bus_dmamap_unload(dmah->dmah_tag, dmah->dmah_map);
	bus_dmamap_destroy(dmah->dmah_tag, dmah->dmah_map);
	bus_dmamem_unmap(dmah->dmah_tag, dmah->vaddr, dmah->size);
	bus_dmamem_free(dmah->dmah_tag, &dmah->dmah_seg, 1);
	dmah->dmah_tag = NULL;	/* XXX paranoia */
	kmem_free(dmah, sizeof(*dmah));
}
开发者ID:eyberg,项目名称:rumpkernel-netbsd-src,代码行数:14,代码来源:drm_memory.c


示例20: drm_pci_free

void
drm_pci_free(drm_device_t *dev, drm_dma_handle_t *h)
{
    if (h == NULL)
        return;
    bus_dmamap_unload(dev->pa.pa_dmat, h->map);
    bus_dmamap_destroy(dev->pa.pa_dmat, h->map);
    bus_dmamem_unmap(dev->pa.pa_dmat, h->addr, h->size);
    bus_dmamem_free(dev->pa.pa_dmat, h->segs, 1);

    free(h, M_DRM);
}
开发者ID:lacombar,项目名称:netbsd-alc,代码行数:12,代码来源:drm_pci.c



注:本文中的bus_dmamem_unmap函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C++ bus_find_device函数代码示例发布时间:2022-05-30
下一篇:
C++ bus_dmamem_free函数代码示例发布时间:2022-05-30
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap