Microsoft KB Archive/137473

How to Initialize Ndis Miniports and PCI

PSS ID Number: Q137473 Article last modified on 10-02-1995

3.51

WINDOWS

= SUMMARY =

Ndis Miniport drivers, written for PCI adapters, are required to perform certain adapter initialization functions. This article describes the functions required and the preferred order of calling. The steps given are required to be in the adapter’s initialization routine. The adapters initialization routine is called by the NdisMRegisterMiniport call in the DriverEntry section of the driver.

= MORE INFORMATION =

  Select the appropriate media type from the array of media types. This is a common step required in all Ndis drivers. Basically, the transports will send a list of all supported media types to the wrapper. The wrapper will pass this list to the Miniport during initialization. The Miniport is required to parse this array and select the media type supported by this driver.   Allocate memory for the adapter structure using NdisAllocateMemory(…). The adapter structure is user defined, and provides adapter specific information storage.   Open the Configuration registry using NdisOpenConfiguration(…). A pointer to this driver’s registry entries (of type NDIS_HANDLE) is passed into the initialization function. This handle is used to open the registry and read the required registry keys.   Read the registry using NdisReadConfiguration(…). This function returns the value associated with the passed in parameter, in the Parameters subkey. After the required values are read from the registry, be sure to call NdisCloseConfiguration(…).   Use NdisPciReadSlotInformation(…) to locate the adapter’s slot number, and check each of the possible PCI slots for the adapter’s Device and Vendor ID’s. Note that the Ndis wrapper expects the Bus Type and the Bus Number to be in the stored in the registry. Information about the Bus Type and Bus Number registry values can be found in the Windows NT Resource kit under Registry Entries, BusNumber, and BusType. Also note that even though the parameter is specified for Slot Number is a ULONG, it is also a union, and some bit positions in this parameter have special meaning. Again, refer to the Resource kit documentation for additional information.   Call NdisMSetAttributes(…) to register the adapter type. This call tells the wrapper what type of adapter is supported by this Miniport.   Call NdisMPciAssignResources(…). This function reads the configuration information from the adapter, selects and assigns the required resources, and returns a structure with the required resource information. The structure definition can be found in: File -> NDIS.H, Typedef struct _CM_PARTIAL_RESOURCE_DESCRIPTOR This function reads the preferred resources and the alternates from the PCI configuration space. Then, based on current system resource allocation, it selects and indicates the system resources this adapter may use.   Call NdisMRegisterInterrupt(…). This function associates the MiniportISR function (in the characteristics table, passed to the NdisMRegisterMiniport(…) call) with interrupts generated by the network interface card. </li>  Call NdisMRegisterIoPortRange(…). This step is required only if the adapter uses system IO ports, namely those accessed by the NdisRawReadPortXxx or NdisRawWritePortXxx functions. </li>  Call NdisMMapIoSpace(…). This function associates virtual addresses with physical addresses. This function should be called for all memory regions used by this adapter. </li>  Call NdisMAllocateMapRegisters(…). This function is required for adapters that use DMA and shared memory. </li>  Perform any additional initialization that may be required by the adapter. If the adapter requires shutdown notification, it should call NdisRegisterAdapterShutdownHandler(…) to register its shutdown handler. This allows the wrapper to call this handler immediately before an Operating system shutdown. </li></ol>

IMPORTANT NOTE: These are the key steps required. Some adapters may require adapter specific initialization procedures that are not listed here.

Additional reference words: 3.51 KBCategory: kbprg KBSubcategory: Miniports NDIS WAN ============================================================================= Copyright Microsoft Corporation 1995.