2.4.2  Registering Network Interface Cards

Registering a network interface card

The NDIS library calls a driver’s initialization function once for each of the installed network cards supported by the driver. MiniportInitialize reads the configuration registry database to determine parameters for the NIC it is initializing, by calling NdisOpenConfiguration, NdisReadConfiguration, and NdisCloseConfiguration. For bus-type-specific configuration information about specialized network cards, EISA-based drivers can call NdisReadEisaSlotInformation, MCA-based drivers can call NdisReadMcaPosInformation, and PCI-based drivers can call NdisReadPciSlotInformation, as examples.

When the miniport has the appropriate configuration data, it stores the information in a previously allocated NIC-specific context structure and then makes a call to NdisMSetAttributes or NdisMSetAttributesEx to pass a handle to this context structure, information about its NIC and if the extended version is called, to change the default behavior of the check-for-hang logic.

After NdisMSetAttributes(Ex) returns, the miniport can further initialize the NIC by calling other NDIS functions appropriate to the adapter, such as NdisRawWritePortXxx, NdisRawWriteXxx,  and functions to set up device memory and claim I/O resources such as NdisMAllocateSharedMemory, NdisMMapIoSpace, and NdisMRegisterIoPortRange. When it has completely initialized the network card, if its NIC generates interrupts, the miniport must set up interrupt handling by calling NdisMRegisterInterrupt. If the miniport has a non-interrupting device, it calls NdisMInitializeTimer to set up a polling timer for its device.

Finally, the driver must register a shutdown handler by calling NdisMRegisterAdapterShutdownHandler.