HOWTO: Acquire NDIS 4.0 PCI Miniport Resources

ID: Q182329


The information in this article applies to:


SUMMARY

This article describes how to acquire the resources for an NDIS 4.0 PCI miniport driver. This method involves reading the Registry with NdisReadConfiguration for the adapter's BusNumber and SlotNumber during MiniportInitialize. Then you pass the SlotNumber to NdisMPciAssignResources, which returns the adapter's bus-relative resources that are used in subsequent calls to NdisMRegisterInterrupt, NdisMMapIoSpace, or NdisMRegisterIoPortRange as documented. You should not search for you adapter by scanning the PCI bus.


MORE INFORMATION

The adapter's BusNumber and SlotNumber are stored in the Registry during setup through the miniport's OEMSetup.inf install script. The miniport's OEMSetup.inf should shell out to Utility.inf, which provides the required PCI bus scanning functionality. Utility.inf resides in %SystemRoot%\system32 and also in %NTDDK%\src\setup\inf\ndis. Specifically, you should use:


   Shell $(UtilityInf), GetPCIInformation, $(Vendor) $(CFID) 

NDIS 4.0 miniport drivers are also recommended to add the AdapterCFID:REG_DWORD parameter to their adapter's Parameters section in the Registry. The AdapterCFID corresponds to the PCI Configuration Space's Device ID register. This allows NDIS to verify the slot number and to track the adapter if it is moved from slot to slot. NDIS reads the BusNumber and SlotNumber from the registry, and then attempts to read the AdapterCFID from the Registry. If the AdatpterCFID is there, NDIS will read the slot information and verify that the adapter is in that slot. If the AdapterCFID is not there then NDIS will trust the SlotNumber.

Also note that your MiniportInitialize handler is called for every installed adapter that the driver supports. NDIS knows what card you are initializing by maintaining internal information per NdisAdapterHandle. You simply call NdisMPciAssignResources and you are given the resources for that adapter. When MiniportInitialize is entered for the next installed card you call NdisMPciAssignResources again and you are given the resources for the next adapter.


REFERENCES

For more information, see Utility.inf.

For additional information about debugging your setup scripts, please see the following article in the Microsoft Knowledge Base:

Q126419 HOWTO: Enable Debug Output for OEMSetup.inf Scripts

Additional query words: NDIS OEMSetup.inf Utility.inf MiniportInitialize NdisMPciAssignResources NdisReadConfiguration NdisMRegisterInterrupt NdisMMapIoSpace NdisMRegisterIoPortRange


Keywords          : ntddkndis 
Version           : WINNT:4.0
Platform          : winnt 
Issue type        : kbhowto 

Last Reviewed: March 5, 1999