DriverStudio开发PCI设备DMA数据传输

DriverWizard向导可以创建基本的wDM驱动程序框架,包括总线类型,地址空间,中断源,DMA资源,以及IOCTL(i/o控制代码)的定义等等。详细情况可参看DriverStudio的帮助文档,以下主要介绍如何用DriverWorks编写DMA方式的驱动程序。

 

    DriverWorks关于DMA操作。封装了三个类:KDmaAdapter, KDmaTransfer和KCommonCmaBuffer。KDmaAdapter类用于建立一个DMA适配器。说明DMA通道的特

性; KDmaTransfer类用于控制DMA传输: KCommonCmaBuffer类用于申请公共缓冲区。

 

    DriverWorks中很少涉及到映射寄存器。只是提到KDmaTransfer类“由于硬件或者缓冲区大小的限制。将一个DMA请求分段进行。为每个段提供了一个传输段描述符数组,当设备不支持分散/集中时,这个数组中的描述符只有一个。每个描述符包含一个物理地址和相应的字节数。其结构如下:

typedef struct TRANSFERDESCRIPTOR

{

PHYSICAL_ADDRESS td_PhysAddr;,

http://blog.sina.com.cn/s/blog_163f91c5e0102wnyx.html 


http://blog.sina.com.cn/s/blog_14d8952290102wii0.html


http://blog.sina.com.cn/s/blog_15e1433c30102wd1v.html


http://blog.sina.com.cn/s/blog_15e1433c30102wd1x.html
http://blog.sina.com.cn/s/blog_14d8952290102wii4.html
http://blog.sina.com.cn/s/blog_15e1433c30102wd20.html
http://tieba.baidu.com/p/4665234070
http://tieba.baidu.com/p/4667230793
http://tieba.baidu.com/p/4667235501

 DriverWorks关于DMA的驱动编程步骤如下:

(1)定义适配器对象。在驱动程序基类的成员变量中定义一个KDmaAdapter类的适配器对象,并且在启动设备的时候对其初始化,正确的建立适配器描述符(DEVICE_DIS—CRItrflON),说明是否为总线主设备、是否支持分散/集中以及总线类型等特征,详细定义参考DDK文档。

(2)定义KDmaTransfer类的对象。可在全局范围内静态定义,也可定义为驱动程序基类的成员变量,或者在需要时在内存堆上分配。进~TDMA传输的设备使用Queuelrp串行IRP,于是DMA传输通常在成员函数Startlo中初始化,同时定义一个DMA回调例程(作为KDmaTransfer类初始化成员函数的一个参数)。

(3)写DMA回调例程。如前所述,KDmaTransfer类的一个重要功能就是根据硬件或者缓冲区大小的限制将一个传输分解成段。每当准备传输一个新段时,KDmaTransfer的对象将通知驱动程序调用回调例程。回调函数的原型typedef DMAREADY— CALLBACK指定, 通常使用宏DEVMEM—BER— DMAREADY,声明回调函数为驱动程序基类的成员函数。调函数首先检查传输是否完成。调用成员函数BytesRemaining,如果返回为0, 回调函数将调用成员函数Terminate,完成相应的IRP。否则,回调函数继续传输。

(4)编写处理当前DMA段传输结束的代码。一段传输结束,通常硬件以一个DMA中断通知系统。在中断服务例程中判断是否为DMA中断,如果是,就请求DPC (延迟调用过程)。在DPC中,驱动程序必须调用成员函数Continue通知传输对象此段传输完成。这个成员函数按照需要清空缓冲区,更新传输状态。如果整个传输并没有完成。则建立下一段传输调用DMA回调例程。

http://blog.sina.com.cn/s/blog_163f91c5e0102wnyx.html 


http://blog.sina.com.cn/s/blog_14d8952290102wii0.html


http://blog.sina.com.cn/s/blog_15e1433c30102wd1v.html


http://blog.sina.com.cn/s/blog_15e1433c30102wd1x.html
http://blog.sina.com.cn/s/blog_14d8952290102wii4.html
http://blog.sina.com.cn/s/blog_15e1433c30102wd20.html
http://tieba.baidu.com/p/4665234070
http://tieba.baidu.com/p/4667230793
http://tieba.baidu.com/p/4667235501

KIoRange m_IoConfig;

KIoRange m_LocalAddrSpace0;

NTSTATUS status = m_IoConfig.Initialize(pTranslated,pRaw,0);

NTSTATUS status = m_LocalAddrSpace0.Initialize(pTranslated,pRaw,1);

其中第3个参数为I/O口对应的基地址.用来转换成特定端口资源的序数。在将硬件中断与中断服务例程连接之前.先要关闭PCI采集卡中断.方法是将9052控制芯片I/0基地址偏移0x4Ch的INTCSR寄存器中断使能位(第6位)屏蔽。方法如下:

m_IoConfig&=~PLX9052_INTCSR]&=~PLx9552_INTCSR_IE.其中PLX9052 INTCSR、PLX9052 INTCSR IE定义分别为

#define PLX9052_INTCSR ULONG(0x004C)

#define PLX9052_INTCSR_IE ULONG(1<<6)


  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
xilliix pcie dma 驱动 (基于 xilnx xdma ip核 4.0 的WDF驱动) --- # XDMA Windows Driver This project is Xilinx's sample Windows driver for 'DMA/Bridge Subsystem for PCI Express v4.0' (XDMA) IP. *Please note that this driver and associated software are supplied to give a basic generic reference implementation only. Customers may have specific use-cases and/or requirements for which this driver is not suitable.* ### Dependencies * Target machine running Windows 7 or Windows 10 * Development machine running Windows 7 (or later) * Visual Studio 2015 (or later) installed on development machine * Windows Driver Kit (WDK) version 1703 (or later) installed on development machine ## Directory Structure ``` / |__ build/ - Generated directory containing build output binaries. |__ exe/ - Contains sample client application source code. | |__ simple_dma/ - Sample code for AXI-MM configured XDMA IP. | |__ streaming_dma/ - Sample code for AXI-ST configured XDMA IP. | |__ user_events/ - Sample code for access to user event interrupts. | |__ xdma_info/ - Utility application which prints out the XDMA core ip | | configuration. | |__ xdma_rw/ - Utility for reading/writing to/from xdma device nodes such | | as control, user, bypass, h2c_0, c2h_0 etc. | |__ xdma_test/ - Basic test application which performs H2C/C2H transfers on | all present channels. |__ inc/ - Contains public API header file for XDMA driver. |__ libxdma/ - Static kernel library for XDMA IP. |__ sys/ - Reference driver source code which uses libxdma |__ README.md - This file. |__ XDMA.sln - Visual Studio Solution. ```

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值