EVT_SPB_CONTROLLER_LOCK callback function

An SPB controller driver's EvtSpbControllerLock event callback function locks the SPB controller for accesses of a single target device on the bus.



VOID EvtSpbControllerLock(
  _In_ WDFDEVICE  Controller,
  _In_ SPBTARGET  Target,
  _In_ SPBREQUEST LockRequest
{ ... }


Controller [in]

A WDFDEVICE handle to the framework device object that represents the SPB controller.

Target [in]

An SPBTARGET handle to the target for this I/O request. The target is a peripheral device or port that is attached to the bus. The SPB framework extension (SpbCx) previously assigned this handle to the target in the EvtSpbTargetConnect callback that opened the connection to the target.

LockRequest [in]

An SPBREQUEST handle to an I/O control request to lock the controller. Your SPB controller driver must complete this request either by performing the requested operation or by returning an error status. For more information, see Remarks.

Return value



SpbCx manages the I/O queue for the SPB controller. If the SPB controller driver registers an EvtSpbControllerLock callback function, SpbCx calls this function when a client (peripheral driver) of the controller sends an IOCTL_SPB_LOCK_CONTROLLER request to a target on the bus. The LockRequest parameter value is a handle that encapsulates this request.

The EvtSpbControllerLock and EvtSpbControllerUnlock functions perform complementary operations. Both functions are optional. If your SPB controller driver implements an EvtSpbControllerUnlock function, the driver is not required to implement an EvtSpbControllerLock function, but might do so. However, if your SPB controller driver implements an EvtSpbControllerLock function, it must also implement an EvtSpbControllerUnlock function. For more information, see Remarks in SPB_CONTROLLER_CONFIG.

While the lock is in effect, the controller must not allow accesses to targets on the bus other than the target designated by the LockRequest parameter.

If the SPB controller driver needs to change the mode of its controller to temporarily override the normal target selection mechanism, it can do so during the EvtSpbControllerLock callback. If this mode change involves a long delay or requires the driver to wait for a device interrupt, the driver should initiate the mode change and then return from the callback without delay. Later, the driver can complete the lock operation in a timer DPC or an interrupt DPC.

If the lock operation completes in a DPC, the SPB controller driver should previously have allocated all the resources that it needs for the lock operation.

An EvtSpbControllerLock callback must avoid failing a lock request. If Driver Verifier is enabled, such a failure will trigger a verifier trap, which will report to the Plug and Play manager that the controller has failed. SpbCx ignores the failure of an lock request and does not try to handle or mitigate the failure.

The EvtSpbControllerLock function does not return a value. Instead, the SPB controller driver indicates the status of the lock operation in the completion status of the I/O request that is identified by the LockRequest parameter. Set the completion status to STATUS_SUCCESS.

SpbCx calls the EvtSpbControllerUnlock event callback function to unlock a controller that was previously locked by an EvtSpbControllerLock callback.

To register an EvtSpbControllerLock callback function, call the SpbDeviceInitialize method.

For more information about the EvtSpbControllerLock function, see Handling Client-Implemented Sequences.


To define an EvtSpbControllerLock 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 an EvtSpbControllerLock callback function that is named MyEvtSpbControllerLock, use the EVT_SPB_CONTROLLER_LOCK function type, as shown in this code example:


Then, implement your callback function as follows:

    WDFDEVICE Controller,
    SPBTARGET Target,
    SPBREQUEST LockRequest
{ ... }

The EVT_SPB_CONTROLLER_LOCK function type is defined in the Spbcx.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 EVT_SPB_CONTROLLER_LOCK 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.


Target platform



Supported starting with Windows 8.





See also




Send comments about this topic to Microsoft