DMA 介绍

本文介绍了DMA的两种接口:dma_alloc_coherent和dma_alloc_writecombine。dma_alloc_coherent分配的内存不使用缓存和写缓冲,而dma_alloc_writecombine仅禁止缓存,仍使用写缓冲。详细阐述了C(Cacheable)和B(Bufferable)位的不同组合对内存操作的影响。
摘要由CSDN通过智能技术生成

1.介绍

 

2.DMA的一些接口


/*
* Allocate a writecombining region, in much the same way as
* dma_alloc_coherent above.
*/
void *
dma_alloc_writecombine(struct device *dev, size_t size, dma_addr_t *handle, gfp_t gfp)
{
    return __dma_alloc(dev, size, handle, gfp,  pgprot_writecombine(pgprot_kernel));
}


/*
* Allocate DMA-coherent memory space and return both the kernel remapped
* virtual and bus address for that space.
*/
void *
dma_alloc_coherent(struct device *dev, size_t size, dma_addr_t *handle, gfp_t gfp)
{
    void *memory;
 
    if (dma_alloc_from_coherent(dev, size, handle, &memory))
        return memory;
 
    if (arch_is_coherent()) {
        void *virt;
 
        virt = kmalloc(size, gfp);
        if (!virt)
            return NULL;
        *handle =  virt_to_dma(dev, virt);
 
        return virt;
    }
 
    return __dma_alloc(dev, size, handle, gfp, pgprot_noncached(pgprot_kernel));
}


#define pgprot_noncached(prot)  __
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值