随笔分类 -  PCI Express

PCI Express设备驱动 (7,linux对于多个MSI中断向量的支持)
摘要:从Linux2.6.30内核版本开始,Linux增加了对于请求多个MSI中断向量号的支持。下面的代码来自Linux2.6.38内核。(不同的cpu对MSI多中断的支持不尽相同,通过下面对Linux2.6.38内核源码的追溯分析,最终可以看到X86处理器不支持MSI多中断!!!)申请多个多个MSI中断向量号的函数为int pci_enable_msi_block(struct pci_dev *dev, unsigned int nvec);下面没有标志出处的源码都出自文件linux-2.6.38.6\drivers\pci\msi.c/** * pci_enable_msi_block - c 阅读全文

posted @ 2011-08-24 12:32 zzwworld 阅读(4307) 评论(0) 推荐(0)

PCI Express设备驱动 (6)
摘要:PCIe主控制器如何配置设备设备端的定义设备在自己的配置空间定义了自己的Capabilities list. 如果该设备支持MSI中断,在此capabilities list其中必定有一个节点的Capabilities ID=0x5D(0x5D 表明是MSI中断节点,其位置由设备自定义).主控制器1> 主控制器的工作是扫描到该设备后顺藤摸瓜,沿着Capabilities List找到MSI中断节点.2> 主控制器给设备上的Address Register和data register俩寄存器赋值(以MPC8548E为例,该值是中断控制器的MSI中断寄存器定义决定);设备MSI中断, 阅读全文

posted @ 2011-08-23 21:59 zzwworld 阅读(2082) 评论(0) 推荐(0)

PCI Express设备驱动 (5)
摘要:和传统中断在系统初始化扫描PCI bus tree时就已自动为设备分配好中断号不同,MSI中断是在设备驱动程序初始化时调用pci_enable_msi() kernel API 时才分配中断号的。所以如果使用传统中断,在设备驱动程序中直接调用request_irq(pDev->irq, handler,...) 注册设备中断处理函数即可。而使用MSI中断的话,需先调用pci_enable_msi() 初始化设备MSI 结构,分配MSI中断号,并替换INTx中断号,再调用request_irq(pDev->irq, handler,...) 注册设备中断处理函数。除了卸载中断处理函数 阅读全文

posted @ 2011-08-23 21:09 zzwworld 阅读(2945) 评论(0) 推荐(0)

PCI Express设备驱动 (3)
摘要://打开设备文件系统调用对应的操作static int card_open(struct inode *inode, struct file *filp){ return 0;}//关闭设备文件系统调用对应的操作static int card_release(struct inode *inode, struct file *filp){ return 0;}static ssize_t card_read(struct file *file, char __user *buf, size_t count, loff_t *f_pos){ void* virt_addr = ... 阅读全文

posted @ 2011-08-22 15:22 zzwworld 阅读(2611) 评论(0) 推荐(0)

PCI Express设备驱动 (2)
摘要:#include "card.h"#include <linux/time.h>#include <linux/spinlock.h>#define DMA_MASK 0xffffffff#define test_dri_major 249 // 主设备号//#define INT_ASSERT_W 0x02 // DMA Write Complete//#define INT_ASSERT_R 0x10 // DMA Read Complete/* PCI 驱动基本框架 */static struct pci_device_id card_ids[ 阅读全文

posted @ 2011-08-22 15:16 zzwworld 阅读(3059) 评论(1) 推荐(1)

PCI Express设备驱动 (1)
摘要:Virtex®-5 FPGA IntegratedEndpoint Block for PCI Express® designs.(the integrated Endpoint block embedded in Virtex-5 devices.)//头文件card.h#include <linux/module.h>#include <linux/init.h> //指定初始化和清楚函数#include <linux/fs.h> //文件系统相关的函数和头文件#include <linux/cdev.h> #includ 阅读全文

posted @ 2011-08-22 11:03 zzwworld 阅读(3530) 评论(1) 推荐(1)

导航