3.2.2 Reading Configuration Information
For all types of adapters, MiniportInitialize should do the following:
·Allocate and zero-initialize a structure to contain adapter-specific information as already described.
·Call NdisOpenConfiguration to open and get a handle to \\HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\DeviceName\Parameters in order to read whatever the installation script wrote to the registry about the adapter managed by the miniport.
·Call NdisReadConfiguration to read the device-specific value entries in the subkeys of the associated Parameters stored in the registry. The miniport calls NdisReadConfiguration once for each keyword to retrieve the associated value. NdisReadConfiguration finds the value entry name that matches the keyword and returns the value and NDIS_STATUS_SUCCESS to the miniport.
·Obtain bus-type-specific information with bus-type-specific functions if such functions exist for the type of I/O bus on which the adapter is connected.
For example, if the bus-type is EISA, the miniport calls NdisReadEisaSlotInformation to obtain such information as the major and minor revision numbers of the adapter or information about the IRQ. This EISA-specific information is defined in the NDIS_EISA_SLOT_INFORMATION structure and a single NDIS_EISA_FUNCTION_INFORMATION structure. The NDIS_EISA_SLOT_INFORMATION structure specifies revision number, compressed device identification, and the number of possible functions. If the device is configurable it will have more than one EISA function. Each NDIS_EISA_FUNCTION_INFORMATION structure describes such things as IRQ, the bus-relative memory range used by the device, etc. If the NIC has only one function, the miniport calls NdisReadEisaSlotInformation. If the number of functions are not known, a miniport can call NdisReadEisaSlotInformation to determine the number of functions and then call NdisReadEisaSlotInformationEx with a buffer big enough to contain all the possible functions (configurations). Or, if the number of possible configurations the device has is known, the miniport can just call NdisReadEisaSlotInformationEx without making the other call first. Once read, the miniport picks a configuration from the set of possible configurations and uses it in subsequent calls to claim hardware resources in the registry, to program the device, and to register the interrupt to support that configuration.
·If the card is software-programmable, call NdisReadNetworkAddress to read the network address of the adapter from the registry so that the address subsequently can be written to the adapter EPROM.
·After a miniport has obtained the values it requires from the registry, call NdisCloseConfiguration. When NdisCloseConfiguration returns, the handle to the registry subkey is no longer valid.
After the miniport has read the information it needs to describe the characteristics of the NIC and stored the information as required into the adapter-specific structure, the miniport calls NdisMSetAttributes or NdisSetAttributesEx. The miniport passes a handle to the adapter-specific structure it uses to represent its NIC, the bus-type for its NIC, and a Boolean that specifies whether its NIC is a busmaster DMA device. A driver calls NdisMSetAttributesEx instead of NdisMSetAttributes to change the default behavior of NDIS with respect to timeouts and Token Ring errors. See the definition of these functions in the Network Driver Reference for details. NDIS will pass the handle to this adapter-specific context area back to the miniport when it calls any MiniportXxx function.