dma_alloc_coherent (建立一致性 DMA 映射函数)
2015-07-25 19:24
477 查看
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);
该函数实际获得两个地址,
1、函数的返回值是一个 void *,代表缓冲区的内核虚拟地址
2、相关的总线地址(物理地址),保存在dma_handle中
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最好以页为单位分配。
相关文章推荐
- 快速排序算法笔记
- hd2277
- UVA - 10976 Fractions Again?!
- js输入当前页面的HTML代码
- 【LeetCode】239. Sliding Window Maximum
- 数据类型运算符和变量
- 2015.07.25总结
- OC_路径寻找
- 股票学习(技术指标--个股贡献度)
- 图的深度遍历
- springMVC的前端控制器的配置
- Combination Sum III
- Android 限制只输入某些值包括数字、字母等
- 在PL/SQL中使用日期类型
- 车道检测数据集
- 特拉帕尼中文离线地图App上线
- OC_继承,便利构造器,初始化方法
- Android 解析AsyncTask(一)
- c# BackGroundWorker 多线程操作的小例子
- UVa 10570 - Meeting with Aliens(构造法)