Driver Re-Initialization (Compact 2013)

3/26/2014

Much of the work that is required to implement snapshot boot involves making sure your drivers are fully power managed and that driver state is correctly restored following a snapshot boot.

A driver’s state cannot be known when it is active, so your drivers are put into a power-off state before the snapshot is taken. When the device reboots from snapshot, you have to resume all your drivers as if the device was just powered on.

Your drivers must support power management through the XXX_PowerUp (Device Manager), XXX_PowerDown (Device Manager) functions, or else through IOCTL_POWER_SET, so that you can re-initialize them to a cold-boot state. Examples of the driver’s you will have to re-initialize include the DMA controller, UART, graphics adapter, touch driver, and so on.

Because the process of taking a snapshot suspends and then resumes the device, you may have to distinguish between a typical suspend/resume and a suspend/resume initiated by taking a snapshot so that you do not unnecessarily re-initialize your hardware. Use GetSnapshotState to determine whether you have to initialize a driver when taking a snapshot. For example, if GetSnapshotState() returns eSnapBoot, you are booting from a snapshot and should reinitialize your driver because the system was in a powered off state. If GetSnapshotState() returns eSnapPass2, a snapshot is being taken and you do not have to reinitialize your hardware.

When you boot from a snapshot, all global variable state is restored. If you have any initialization code that relies on reference counting, and it checks for a reference count of zero before initializing a device, you will have to clear the reference count first so that your initialization code correctly initializes the affected hardware. For example, if you have clocks that were being used before you took the snapshot, and reference counting is used to enable the clocks, then you must either re-initialize the reference count so that the clocks are enabled, or ignore the reference count and forcefully enable the clocks.

Show: