如何通过DMA从RAM到RAM传输数据? [英] How to transfer data via DMA from RAM to RAM?

查看:394
本文介绍了如何通过DMA从RAM到RAM传输数据?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想编写一个内核模块,该模块可以通过DMA从RAM到RAM传输数据.有一些讨论这个问题的帖子,但是我真的不明白.有人说可能别人说不是.

I want to write a kernel module that can transfer data via DMA from RAM to RAM. There are some posts that discuss this, but I don't really get it. Some say it is possible others say it isn’t.

如果我对ldd3的理解正确,那么使用Linux的DMA API无法将RAM复制到RAM,但是 driver/dma/dmaengine.c 为"DMA传输类型"提供了标志DMA_MEMCPY ,所以应该有办法.

If I understood ldd3 right, RAM to RAM copying isn‘t possible with the DMA API of linux, but the driver/dma/dmaengine.c provides a flag DMA_MEMCPY for a "DMA Transfer Type", so there should be a way.

这是正确的吗,我可以使用dma引擎将数据从一个ram地址传输到另一个ram地址吗?

Is this correct, can I use a dma engine to transfer data from one ram address to another?

如果取决于硬件,如何确定我的系统是否支持dma memcpy?

If it is hardware dependent, how can I determine if my system supports dma memcpy?

推荐答案

正如您正确指出的那样,应使用DMA_MEMCPY执行RAM到RAM的复制.在 Documentation/dmaengine/provider.txt 中进行了描述. .这只是一个相关摘录,请查看整个文件以了解更多详细信息:

As you correctly pointed out, DMA_MEMCPY should be used to perform RAM-to-RAM copy. It is described in Documentation/dmaengine/provider.txt. Here is just a related excerpt, please see the whole file for more details:

支持的交易类型

下一步,您需要设置设备的交易类型 (和驱动程序)支持.

Supported transaction types

The next thing you need is to set which transaction types your device (and driver) supports.

我们的dma_device结构具有一个名为cap_mask的字段,其中包含 支持各种类型的交易,您需要对此进行修改 使用dma_cap_set功能的蒙版,取决于 您支持作为参数的交易类型.

Our dma_device structure has a field called cap_mask that holds the various types of transaction supported, and you need to modify this mask using the dma_cap_set function, with various flags depending on transaction types you support as an argument.

所有这些功能都在dma_transaction_type枚举中定义, 在include/linux/dmaengine.h

All those capabilities are defined in the dma_transaction_type enum, in include/linux/dmaengine.h

当前,可用的类型为:

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆