参照元

説明

引数

返り値

参考

実装

static int dma_init_coherent_memory(phys_addr_t phys_addr, dma_addr_t device_addr,
                             size_t size, int flags,
                             struct dma_coherent_mem **mem)
{
        struct dma_coherent_mem *dma_mem = NULL;
        void __iomem *mem_base = NULL;
        int pages = size >> PAGE_SHIFT;
        int bitmap_size = BITS_TO_LONGS(pages) * sizeof(long);
        if ((flags & (DMA_MEMORY_MAP | DMA_MEMORY_IO)) == 0)
                goto out;
        if (!size)
                goto out;

        mem_base = ioremap(phys_addr, size);
        if (!mem_base)
                goto out;
        dma_mem = kzalloc(sizeof(struct dma_coherent_mem), GFP_KERNEL);
        if (!dma_mem)
                goto out;
        dma_mem->bitmap = kzalloc(bitmap_size, GFP_KERNEL);
        if (!dma_mem->bitmap)
                goto out;

        dma_mem->virt_base = mem_base;
        dma_mem->device_base = device_addr;
        dma_mem->pfn_base = PFN_DOWN(phys_addr);
        dma_mem->size = pages;
        dma_mem->flags = flags;
        spin_lock_init(&dma_mem->spinlock);
        *mem = dma_mem;

        if (flags & DMA_MEMORY_MAP)
                return DMA_MEMORY_MAP;

        return DMA_MEMORY_IO;

out:
        kfree(dma_mem);
        if (mem_base)
                iounmap(mem_base);
        return 0;
}

コメント


トップ   編集 凍結 差分 履歴 添付 複製 名前変更 リロード   新規 一覧 検索 最終更新   ヘルプ   最終更新のRSS
Last-modified: 2016-02-22 (月) 19:45:13