Solved

PCI slot number (NDIS)

Posted on 1998-09-27
1
271 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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

If you have ever found yourself doing a repetitive action with the mouse and keyboard, and if you have even a little programming experience, there is a good chance that you can use a text editor to whip together a sort of macro to automate the proce…
This article describes a technique for converting RTF (Rich Text Format) data to HTML and provides C++ source that does it all in just a few lines of code. Although RTF is coming to be considered a "legacy" format, it is still in common use... po…
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…
Get a first impression of how PRTG looks and learn how it works.   This video is a short introduction to PRTG, as an initial overview or as a quick start for new PRTG users.

929 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

Need Help in Real-Time?

Connect with top rated Experts

14 Experts available now in Live!

Get 1:1 Help Now