GPIO_CLIENT_START_CONTROLLER callback function (gpioclx.h)
The CLIENT_StartController event callback function performs operations that are needed when the general-purpose I/O (GPIO) controller device enters the D0 power state.
Syntax
GPIO_CLIENT_START_CONTROLLER GpioClientStartController;
NTSTATUS GpioClientStartController(
[in] PVOID Context,
[in] BOOLEAN RestoreContext,
[in] WDF_POWER_DEVICE_STATE PreviousPowerState
)
{...}
Parameters
[in] Context
A pointer to the GPIO controller driver's device context.
[in] RestoreContext
Whether the client driver should restore the GPIO controller to a previously saved hardware context. If TRUE, the hardware context should be restored. If FALSE, the hardware context should not be restored. For more information, see Remarks.
[in] PreviousPowerState
The previous device power state. This parameter is a WDF_POWER_DEVICE_STATE enumeration value that specifies the low-power state from which the device entered the D0 power state. The GPIO controller driver can use this information to determine how to configure the controller device so that it is ready to use.
Return value
The CLIENT_StartController function returns STATUS_SUCCESS if the call is successful. Otherwise, it returns an appropriate error code.
Remarks
This callback function is implemented by the GPIO controller driver. The GPIO framework extension (GpioClx) calls this function to place the GPIO controller device in a known, initial state at system startup or when the device transitions from a low-power state to a working state. This callback function must perform any operations that are necessary after the device wakes from a low-power state, such as restoring any information that the driver needs after the device enters the D0 power state.
Typically, a CLIENT_StartController callback function sets all the GPIO pins to their default state.
To register your driver's CLIENT_StartController callback function, call the GPIO_CLX_RegisterClient method. This method accepts, as an input parameter, a pointer to a GPIO_CLIENT_REGISTRATION_PACKET structure that contains a CLIENT_StartController function pointer.
Although the CLIENT_StartController callback function is called at IRQL = PASSIVE_LEVEL, you should not make this function pageable. The CLIENT_StartController callback is in the critical timing path for restoring power to the devices in the hardware platform and, for performance reasons, it should not be delayed by page faults.
Examples
To define a CLIENT_StartController callback function, you must first provide a function declaration that identifies the type of callback function you're defining. Windows provides a set of callback function types for drivers. Declaring a function using the callback function types helps Code Analysis for Drivers, Static Driver Verifier (SDV), and other verification tools find errors, and it's a requirement for writing drivers for the Windows operating system.
For example, to define a CLIENT_StartController callback function that is named MyEvtGpioStartController
, use the GPIO_CLIENT_START_CONTROLLER function type, as shown in this code example:
GPIO_CLIENT_START_CONTROLLER MyEvtGpioStartController;
Then, implement your callback function as follows:
_Use_decl_annotations_
VOID
MyEvtGpioStartController(
PVOID Context,
BOOLEAN RestoreContext,
WDF_POWER_DEVICE_STATE PreviousPowerState
)
{ ... }
The GPIO_CLIENT_START_CONTROLLER function type is defined in the Gpioclx.h header file. To more accurately identify errors when you run the code analysis tools, be sure to add the Use_decl_annotations annotation to your function definition. The Use_decl_annotations annotation ensures that the annotations that are applied to the GPIO_CLIENT_START_CONTROLLER function type in the header file are used. For more information about the requirements for function declarations, see Declaring Functions by Using Function Role Types for KMDF Drivers. For more information about Use_decl_annotations, see Annotating Function Behavior.
Requirements
Requirement | Value |
---|---|
Minimum supported client | Supported starting with Windows 8. |
Target Platform | Desktop |
Header | gpioclx.h |
IRQL | Called at PASSIVE_LEVEL (see Remarks). |