Solved

PCI slot number (NDIS)

Posted on 1998-09-27
1
265 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
Comment Utility
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

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

This article shows a few slightly more advanced techniques for Windows 7 gadget programming, including how to save and restore user settings for your gadget and how to populate the "details" panel that is displayed in the Windows 7 gadget gallery.  …
This article shows how to make a Windows 7 gadget that accepts files dropped from the Windows Explorer.  It also illustrates how to give your gadget a non-rectangular shape and how to add some nifty visual effects to text displayed in a your gadget.…
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…
When you create an app prototype with Adobe XD, you can insert system screens -- sharing or Control Center, for example -- with just a few clicks. This video shows you how. You can take the full course on Experts Exchange at http://bit.ly/XDcourse.

744 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

13 Experts available now in Live!

Get 1:1 Help Now