GPIO_CLIENT_SAVE_BANK_HARDWARE_CONTEXT callback function (gpioclx.h)

The CLIENT_SaveBankHardwareContext event callback function saves the hardware context of a bank of general-purpose I/O (GPIO) pins.

Syntax

GPIO_CLIENT_SAVE_BANK_HARDWARE_CONTEXT GpioClientSaveBankHardwareContext;

void GpioClientSaveBankHardwareContext(
  [in] PVOID Context,
  [in] PGPIO_SAVE_RESTORE_BANK_HARDWARE_CONTEXT_PARAMETERS Parameters
)
{...}

Parameters

[in] Context

A pointer to the GPIO controller driver's device context.

[in] Parameters

A pointer to a GPIO_SAVE_RESTORE_BANK_HARDWARE_CONTEXT_PARAMETERS structure that describes the bank of GPIO pins to save.

Return value

None

Remarks

The CLIENT_SaveBankHardwareContext function returns STATUS_SUCCESS if the call is successful. Otherwise, it returns an appropriate error status code.

If a bank of GPIO pins supports component-level power management, GpioClx can switch the bank to a low-power Fx state if the bank is idle. If the GPIO controller bank loses its hardware context in the Fx state, the GPIO controller driver must save this context before the F0-to-Fx transition, and, later, restore the context after the Fx-to-F0 transition. Currently, F1 is the only low-power state that is defined for GPIO controllers that use GpioClx.

GpioClx calls the CLIENT_SaveBankHardwareContext function to save the bank's hardware context. Later, GpioClx calls the CLIENT_RestoreBankHardwareContext event callback function to restore the previously saved context.

Some GPIO controller devices enable selected banks of pins to be turned on and off independently of other banks in the same device. Thus, power can be saved by turning off a bank that is idle.

To register your driver's CLIENT_SaveBankHardwareContext 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_SaveBankHardwareContext function pointer.

GpioClx calls the CLIENT_SaveBankHardwareContext callback function either at PASSIVE_LEVEL or DIRQL, depending on the device information that the CLIENT_QueryControllerBasicInformation callback function supplies to GpioClx. The CLIENT_QueryControllerBasicInformation function provides device information in the form of a CLIENT_CONTROLLER_BASIC_INFORMATION structure. If the MemoryMappedController flag bit is set in the Flags member of this structure, GpioClx calls the CLIENT_SaveBankHardwareContext function at DIRQL, which is the IRQL at which the ISR in GpioClx runs. For more information about this flag bit, see Optional and Required GPIO Callback Functions.

Examples

To define a CLIENT_SaveBankHardwareContext 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_SaveBankHardwareContext callback function that is named MyEvtGpioSaveBankHardwareContext, use the GPIO_CLIENT_SAVE_BANK_HARDWARE_CONTEXT function type, as shown in this code example:

GPIO_CLIENT_SAVE_BANK_HARDWARE_CONTEXT MyEvtGpioSaveBankHardwareContext;

Then, implement your callback function as follows:

_Use_decl_annotations_
NTSTATUS
  MyEvtGpioSaveBankHardwareContext(
    PVOID Context,
    PGPIO_SAVE_RESTORE_BANK_HARDWARE_CONTEXT_PARAMETERS Parameters
    )
{ ... }

The GPIO_CLIENT_SAVE_BANK_HARDWARE_CONTEXT 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_SAVE_BANK_HARDWARE_CONTEXT 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 See Remarks.

See also

CLIENT_CONTROLLER_BASIC_INFORMATION

CLIENT_QueryControllerBasicInformation

CLIENT_RestoreBankHardwareContext

GPIO_CLIENT_REGISTRATION_PACKET

GPIO_CLX_RegisterClient

GPIO_SAVE_RESTORE_BANK_HARDWARE_CONTEXT_PARAMETERS