问题:我想用一个驱动程序实现多个PCI设备的驱动
PCI设备上挂接了4个串口转PCI的硬件设备,还有一个FPGA的PCI设备,我想用一个驱动程序实现这5个PCI设备的驱动,不知如何实现。
------解决方案--------------------
应该没有关系的吧,pdo不是都一样的吗?嗯~ o(* ̄▽ ̄*)o 因为硬件模块上已经有芯片转成了PCI接口的时序了,所以可以直接用DDK的程序模块去处理,这部分我们貌似也写不了。
楼主之前写过的PCI驱动应该能用的,对那几个设备都挂上这个驱动就可以了吧 "o((>ω< ))o" 我猜的。
如果是加驱动实例 WDM 驱动是在AddDevice里面加,NT 驱动在CreateDevice里面加。
给楼主一个 NT 驱动加两个设备的栗子,虽然不是PCI的 \( ̄︶ ̄)/
/************************************************************************
* 文件名称:Driver.cpp
* 作 者:张帆
* 完成日期:2007-11-1
*************************************************************************/
#include "Driver.h"
#pragma INITCODE
void Dump(IN PDRIVER_OBJECT pDriverObject)
{
KdPrint(("----------------------------------------------\n"));
KdPrint(("Begin Dump...\n"));
KdPrint(("Driver Address:0X%08X\n",pDriverObject));
KdPrint(("Driver name:%wZ\n",&pDriverObject->DriverName));
KdPrint(("Driver HardwareDatabase:%wZ\n",pDriverObject->HardwareDatabase));
KdPrint(("Driver first device:0X%08X\n",pDriverObject->DeviceObject));
PDEVICE_OBJECT pDevice = pDriverObject->DeviceObject;
int i=1;
for (;pDevice!=NULL;pDevice = pDevice->NextDevice)
{
KdPrint(("The %d device\n",i++));
KdPrint(("Device AttachedDevice:0X%08X\n",pDevice->AttachedDevice));
KdPrint(("Device NextDevice:0X%08X\n",pDevice->NextDevice));
KdPrint(("Device StackSize:%d\n",pDevice->StackSize));
KdPrint(("Device's DriverObject:0X%08X\n",pDevice->DriverObject));
}
KdPrint(("Dump over!\n"));
KdPrint(("----------------------------------------------\n"));
}
/************************************************************************
* 函数名称:CreateDevice
* 功能描述:初始化设备对象
* 参数列表:
pDriverObject:从I/O管理器中传进来的驱动对象
* 返回 值:返回初始化状态