Writing Device Drivers

Overview of Hotplugging

This section summarizes the sequence of events in hot removal and hot insertion that are relevant to the device driver.

Hotplugging typically involves:

  1. Preparation: Indicate to the system that a hotplug operation will take place on particular hardware.

  2. Isolation: Specify that the hardware be isolated in preparation for a safe insertion or removal.

  3. Removal, insertion, or both: Insert and/or replace the hardware.

  4. Verification: Verify that the card is accessible and perform minimal sanity checks.

  5. Integration: Re-integrate the hardware into the system.

  6. Configuration: Use kernel functions to configure the system, loading and attaching device drivers for newly installed hardware, and deconfiguring the system for removed hardware

Hot Removal With No Replacement

This operation is used to remove a card. You may want to remove a card because, for example, its failure mode affects system operation. To perform a hotplug removal:

  1. Indicate, using an administrative application, that a card needs to be removed or replaced.

  2. Through the administrative application, use kernel functions to take the appropriate driver offline.

    If the driver instance is busy or open, this operation may fail and you will first have to terminate the processes that are accessing the device.

  3. Through the administrative application, use kernel functions to turn off the appropriate slot; an optional slot-state indicator will show that the slot is off and it is now safe to remove the card.

  4. Remove the card.

  5. Inform the administrative application that the card has been removed.

Hot Insertion

This procedure is used to insert a card in a previously unused slot.

  1. Indicate, using an administrative application, that a card is to be inserted in a particular slot.

  2. Through the administrative application, use kernel functions to turn off the appropriate slot (if it isn't off already). An optional slot-state indicator may show that the slot is off.

  3. Insert the card.

  4. Indicate to the administrative application that the card has been inserted.

  5. Through the administrative application, use kernel functions to turn on the slot and the slot-state indicator.

  6. Through the kernel, configure the system, and load and attach the device driver for the newly installed hardware.

Hot Removal Followed by Insertion

This procedure is used to replace a card with either an identical or a different card.

  1. Indicate, using an administrative application, that a card is to be removed or replaced in a given slot.

  2. Through the administrative application, use kernel functions to place the appropriate driver offline.

    If the driver instance is busy or open, this operation may fail and you will first have to terminate any processes that are accessing the device.

  3. Use the administrative application to disable the appropriate slot, and turn on an optional slot-state indicator to indicate the physical slot and verify that it is now safe to remove the card.

  4. Remove the card.

  5. Insert the replacement card.

  6. Indicate to the administrative application that a card has been inserted.

  7. Through the administrative application, use kernel functions to turn on the slot, and, optionally, turn off the slot-state indicator.

  8. Through the kernel, configure the system, and load and attach the device driver for the newly installed hardware.