您好,欢迎来到叨叨游戏网。
搜索
您的当前位置:首页dma_alloc_coherent (建立一致性 DMA 映射函数)

dma_alloc_coherent (建立一致性 DMA 映射函数)

来源:叨叨游戏网

1、函数申明

/**
 * dma_alloc_coherent - allocate consistent memory for DMA
 * @dev: valid struct device pointer, or NULL for ISA and EISA-like devices
 * @size: required memory size
 * @handle: bus-specific DMA address
 *
 * Allocate some uncached, unbuffered memory for a device for
 * performing DMA.  This function allocates pages, and will
 * return the CPU-viewed address, and sets @handle to be the
 * device-viewed address.
 */
void *dma_alloc_coherent(struct device *dev, size_t size, dma_addr_t *dma_handle, int flag);

2、调用

A =dma_alloc_coherent(B,C,D,GFP_KERNEL);
含义:
A: 内存的虚拟起始地址,在内核要用此地址来操作所分配的内存
B: struct device指针。能够平台初始化里指定。主要是dma_mask之类。可參考framebuffer
C: 实际分配大小,传入dma_map_size就可以
D: 返回的内存物理地址,dma就能够用。
所以,A和D是一一相应的,仅仅只是,A是虚拟地址,而D是物理地址。

对 随意一个操作都将改变缓冲区内容。当然要注意操作环境。

注size最好以页为单位分配。

因篇幅问题不能全部显示,请点此查看更多更全内容

Copyright © 2019- gamedaodao.net 版权所有 湘ICP备2024080961号-6

违法及侵权请联系:TEL:199 18 7713 E-MAIL:2724546146@qq.com

本站由北京市万商天勤律师事务所王兴未律师提供法律服务