Power Handler

Power handler services are intended for use by Configuration Manager only. Virtual devices that require notification of power changes should install a message hook procedure using the _SHELL_HookSystemBroadcast service.

A power handler is a device-driver-supplied routine that carries out power-related tasks during power suspension and resumption. VPOWERD calls all registered power handlers as part of its normal sequence of shutting down and starting up power.

VPOWERD typically schedules an application-time event, using the SHELL_CallAtAppyTime service, when the request to suspend occurs. Within the application-time event, VPOWERD calls each handler once for each POWERFUNC_SUSPEND value. It orders the calls such that all handlers receive a POWERFUNC_SUSPEND_PHASE1 call before any receives a POWERFUNC_SUSPEND_PHASE2 call and so on.

When power is resumed, VPOWERD calls each handler once for each POWERFUNC_RESUME value. It orders the calls such that all handlers receive a POWERFUNC_SUSPEND_PHASE2 call before any receives a POWERFUNC_SUSPEND_PHASE1 call.

VPOWERD calls the handlers in the order specified by their initialization order, as given when a handler is registered. The PFG_REVERSE is set for the suspend messages and not for the resume messages. That is, VPOWERD normally calls the suspend in reverse load order, like a shutdown, so that the highest priority devices get suspended last yet resume first.

If at any point a handler fails a call, VPOWERD restores the system to the previous state. For example, if a handler rejects a POWERFUNC_SUSPEND_PHASE2 call, VPOWERD makes POWERFUNC_RESUME_PHASE2 and subsequent POWERFUNC_RESUME_PHASE1 calls to all handlers that had previously accepted the suspension.