Solved

PCI slot number (NDIS)

Posted on 1998-09-27
1
281 Views
Last Modified: 2013-12-03
How can I determine in the Miniport NIC driver the slot number of my card ??? Please give me a sample code.
0
Comment
Question by:kaccup
1 Comment
 
LVL 4

Accepted Solution

by:
agreen earned 350 total points
ID: 1414850
You can do that by walking through the possible PCI slot numbers and examining the Vendor ID, Device ID and Revision Number of the card. Here is the sample:

#define MAX_PCI_SLOTS 25

#define VENDOR_ID  <your vendor id>
#define DEVICE_ID  <your device id>
#define REV_NUM    <revision number>

typedef struct _CMDD_PCI_CONFIG {
    USHORT VendorID;       
    USHORT DeviceID;
    USHORT Command;
    USHORT Status;
    UCHAR RevisionID;
    UCHAR ProgIf;
    UCHAR SubClass;
    UCHAR BaseClass;      
    UCHAR CacheLineSize;      
    UCHAR LatencyTimer;      
    UCHAR HeaderType;
    UCHAR BIST;      

    union {
         struct _PCI_HEADER_TYPE_0 {
             ULONG BaseAddresses[6];
             ULONG Reserved1[2];
             ULONG ROMBaseAddress;
             ULONG Reserved2[2];
             UCHAR InterruptLine;
             UCHAR InterruptPin;
             UCHAR MinimumGrant;
             UCHAR MaximumLatency;
         } type0;
     } u;
     UCHAR DeviceSpecific[192];
} PCI_CONFIG, *PPCI_CONFIG;

LONG
SlotNumber(
      PMY_ADAPTER Adapter
      )
{
    PCI_CONFIG PciConfig;
    UINT i;

    for(i=0; i<MAX_PCI_SLOTS; i++) {

        NdisReadPciSlotInformation(
          (NDIS_HANDLE)Adapter,
          i, 0, &PciConfig, sizeof(PCI_CONFIG));

        if(PciConfig.VendorID == VENDOR_ID && 
         PciConfig.DeviceID == DEVICE_ID &&
           PciConfig.RevisionID & 0x0f == REV_NUM) {

            // Place your code here

            return i;

        }

    return -1;
}
0

Featured Post

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In this article, I will show how to use the Ribbon IDs Tool Window to assign the built-in Office icons to a ribbon button.  This tool will help us to find the OfficeImageId that corresponds to our desired built-in Office icon. The tool is part of…
For most people, the WrapPanel seems like a magic when they switch from WinForms to WPF. Most of us will think that the code that is used to write a control like that would be difficult. However, most of the work is done by the WPF engine, and the W…
This is Part 3 in a 3-part series on Experts Exchange to discuss error handling in VBA code written for Excel. Part 1 of this series discussed basic error handling code using VBA. http://www.experts-exchange.com/videos/1478/Excel-Error-Handlin…
Email security requires an ever evolving service that stays up to date with counter-evolving threats. The Email Laundry perform Research and Development to ensure their email security service evolves faster than cyber criminals. We apply our Threat…

856 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question