misc.c

来自「用C语言写得PCI8052的WDM结构驱动程序」· C语言 代码 · 共 76 行

C
76
字号
//  Programmer:桂凯    西安电子科技大学
// 
//  email:wwwguikai@21cn.com
//  All right reserved 

//
//
//
/*
static NTSTATUS 
MainDispatch ( 
    IN PDEVICE_OBJECT DeviceObject, 
    IN PIRP Irp 
    );

*/
#include <ntddk.h>
#include <ndis.h>
#include <pci9052hw.h>
#include <pci9052sw.h>

//-----------------------------------------------------------------------------
NTSTATUS
Detect9052(
    IN PDEVICE_OBJECT DeviceObject
    )
{
    ULONG busNumber = 0;
    ULONG deviceNumber = 0;
    PCI_SLOT_NUMBER slotNumber;
    ULONG length = 0;
    PCI_COMMON_CONFIG  configInfo ;
    ULONG found9052 = 0;
    
//    KdPrint(( "Detect9052 \n"));
    for( busNumber=0; busNumber<MAX_BUS_NUMBER; busNumber++)
    {
      for( deviceNumber=0; deviceNumber<PCI_MAX_DEVICES; deviceNumber++)
      {
    	slotNumber.u.bits.Reserved = 0;
        slotNumber.u.bits.DeviceNumber = deviceNumber;
        slotNumber.u.bits.FunctionNumber = 0;
        slotNumber.u.AsULONG = deviceNumber;
        
        length = HalGetBusData(PCIConfiguration,
                               busNumber,
                               slotNumber.u.AsULONG,
                               &configInfo,
                               sizeof(PCI_COMMON_CONFIG) );

        
            // If there's nothing in this slot, PCI_INVALID_VENDORID is returned
            // as the vendor ID.  If this is the case, just continue running
            // the bus.
            //
         if ( configInfo.VendorID == PCI_INVALID_VENDORID)
             continue;
             
         if ( (configInfo.VendorID == PLX9052ID_VENID)&&(configInfo.DeviceID == PLX9052ID_DEVID) )  
         {
                found9052 = 1;
                break;
         }
       }
    }
    if ( found9052 == 1 )
    {
      return(STATUS_SUCCESS);
    }
    else 
      return(STATUS_NO_SUCH_DEVICE);
    	
}


⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?