• 大小: 4.07MB
    文件类型: .zip
    金币: 1
    下载: 0 次
    发布日期: 2023-08-13
  • 语言: 其他
  • 标签:

资源简介

基于WDM的PCIe设备驱动代码例子,需要开发PCIe设备驱动的可以参考。

资源截图

代码片段和文件信息

/*************************************************************************
  Demo.
  Copyright (c) 2012 Demo.
   PCIe driver
      Version 1.0.0
**************************************************************************/

#include “pci.h“

NTSTATUS TSTDPciCreateClose(PDEVICE_object Deviceobject PIRP pIrp)
{
PIO_STACK_LOCATION pIoStack = IoGetCurrentIrpStackLocation(pIrp);
PTSTDPCI_DEVICE_EXT pDevExt = Deviceobject->DeviceExtension;

DebugPrint(“TSTDPciCreateClose() Start\n“);
/* Flag setting when driver is being used */
TSTDPciRequestIncrement(pDevExt);

if(pIoStack->MajorFunction == IRP_MJ_CREATE)
{
InterlockedIncrement(&pDevExt->OpenCounter);
}
else if(pIoStack->MajorFunction == IRP_MJ_CLOSE)
{
InterlockedDecrement(&pDevExt->OpenCounter);
}

pIrp->IoStatus.Status = STATUS_SUCCESS;
if ( (pIoStack->MajorFunction == IRP_MJ_CREATE) && (pDevExt->State < STATE_ALL_BELOW_FAIL) ) 
{
pIrp->IoStatus.Status = STATUS_UNSUCCESSFUL;
}
pIrp->IoStatus.Information = 0;
IoCompleteRequest(pIrp IO_NO_INCREMENT);

if(pIoStack->MajorFunction==IRP_MJ_CLOSE && pDevExt->OpenCounter==0)
{
#if 0
// Force to free common buffer
if(pDevExt->CmnBuffSysVirAddr != NULL)
CommonBufferFree(pDevExt NULL);
for(i=0; i {
if(pDevExt->InterruptEvent[i])
{
ZwClose(pDevExt->EventHandle[i]);
pDevExt->EventHandle[i] = NULL;
pDevExt->InterruptEvent[i] = NULL;
}
}
#endif
}

/* Flag release when driver is being used */
TSTDPciRequestDecrement(pDevExt);

DebugPrint(“TSTDPciCreateClose() End\n“);

return(STATUS_SUCCESS);
}


 属性            大小     日期    时间   名称
----------- ---------  ---------- -----  ----
     目录           0  2013-12-27 14:21  Pcie_driver\
     目录           0  2013-12-27 14:21  Pcie_driver\cmn\
     文件        3909  2013-08-14 15:34  Pcie_driver\cmn\dll_if.h
     文件         456  2013-08-14 15:32  Pcie_driver\cmn\guids.h
     文件        5517  2013-08-14 15:34  Pcie_driver\cmn\sys_if.h
     目录           0  2013-12-27 14:21  Pcie_driver\Driver\
     文件        5970  2012-12-07 08:29  Pcie_driver\Driver\buildchk_win7_amd64.log
     文件        1671  2013-08-14 15:33  Pcie_driver\Driver\create_close.c
     文件         925  2013-08-14 15:31  Pcie_driver\Driver\DebugPrint.h
     文件        1511  2013-08-14 15:32  Pcie_driver\Driver\entry_unload.c
     文件         268  2011-08-05 16:27  Pcie_driver\Driver\makefile
     文件        8952  2013-04-18 10:25  Pcie_driver\Driver\Nmake2MSBuild_sources.log
     目录           0  2013-12-27 14:21  Pcie_driver\Driver\obj\
     目录           0  2013-12-27 14:21  Pcie_driver\Driver\objchk_win7_amd64\
     目录           0  2013-12-27 14:21  Pcie_driver\Driver\objchk_win7_amd64\amd64\
     文件       80302  2012-12-07 08:29  Pcie_driver\Driver\objchk_win7_amd64\amd64\create_close.obj
     文件       80326  2012-12-07 08:29  Pcie_driver\Driver\objchk_win7_amd64\amd64\entry_unload.obj
     文件        8560  2012-12-07 08:31  Pcie_driver\Driver\objchk_win7_amd64\amd64\entry_unload.obj.oacr.root.amd64chk.pft.xml
     文件       19096  2012-12-07 08:29  Pcie_driver\Driver\objchk_win7_amd64\amd64\pcie_driver.map
     文件      248832  2012-12-07 08:29  Pcie_driver\Driver\objchk_win7_amd64\amd64\pcie_driver.pdb
     文件       21376  2012-12-07 08:29  Pcie_driver\Driver\objchk_win7_amd64\amd64\pcie_driver.sys
     文件       81965  2012-12-07 08:29  Pcie_driver\Driver\objchk_win7_amd64\amd64\pci_ctl.obj
     文件         574  2012-12-07 08:31  Pcie_driver\Driver\objchk_win7_amd64\amd64\pci_ctl.obj.oacr.root.amd64chk.pft.xml
     文件       86204  2012-12-07 08:29  Pcie_driver\Driver\objchk_win7_amd64\amd64\pci_dma.obj
     文件        7493  2012-12-07 08:32  Pcie_driver\Driver\objchk_win7_amd64\amd64\pci_dma.obj.oacr.root.amd64chk.pft.xml
     文件       81640  2012-12-07 08:29  Pcie_driver\Driver\objchk_win7_amd64\amd64\pci_isr.obj
     文件        1050  2012-12-07 08:31  Pcie_driver\Driver\objchk_win7_amd64\amd64\pci_isr.obj.oacr.root.amd64chk.pft.xml
     文件       91516  2012-12-07 08:29  Pcie_driver\Driver\objchk_win7_amd64\amd64\pci_msc.obj
     文件         956  2012-12-07 08:32  Pcie_driver\Driver\objchk_win7_amd64\amd64\pci_msc.obj.oacr.root.amd64chk.pft.xml
     文件       99524  2012-12-07 08:29  Pcie_driver\Driver\objchk_win7_amd64\amd64\pci_pnp.obj
     文件       13635  2012-12-07 08:32  Pcie_driver\Driver\objchk_win7_amd64\amd64\pci_pnp.obj.oacr.root.amd64chk.pft.xml
............此处省略86个文件信息

评论

共有 条评论

相关资源