WdfInterruptAcquireLock メソッド

The WdfInterruptAcquireLock method begins a code sequence that executes at the device's DIRQL while holding an interrupt object's spin lock.

構文

VOID WdfInterruptAcquireLock(
  [in]  WDFINTERRUPT Interrupt
);

パラメーター

  • Interrupt [in]
    A handle to a framework interrupt object.

戻り値

None.

A bug check occurs if the driver supplies an invalid object handle.

解説

When a driver calls WdfInterruptAcquireLock, the system raises the processor's IRQL to the device's DIRQL and acquires the spin lock that the driver specified in the interrupt object's WDF_INTERRUPT_CONFIG structure. As a result, the interrupt object's EvtInterruptIsr and EvtInterruptSynchronize callback functions (and any other code that calls WdfInterruptAcquireLock for the same interrupt object) cannot execute.

When the driver calls WdfInterruptReleaseLock, the system returns the processor's IRQL to its previous level and releases the spin lock.

You can use WdfInterruptAcquireLock and WdfInterruptAcquireLock if your driver must execute a few lines of code without being preempted and with servicing of device interrupts effectively disabled. For larger sections of code, your driver should provide an EvtInterruptSynchronize callback function.

Your driver cannot call WdfInterruptAcquireLock before the framework has called the driver's EvtInterruptEnable callback function or after the framework has called the driver's EvtInterruptDisable callback function.

After your driver calls WdfInterruptAcquireLock, it must not call the method again for the same interrupt object before calling WdfInterruptAcquireLock.

For more information about the WdfInterruptAcquireLock method, see Synchronizing Interrupt Code.

For more information about handling interrupts in framework-based drivers, see Handling Hardware Interrupts.

The following code example shows how an EvtProgramDma callback function might acquire an interrupt object's spin lock before it accesses device registers to program a DMA transfer. For a complete example of an EvtProgramDma callback function, see the PLX9x5x sample driver.

  BOOLEAN
PLxEvtProgramReadDma(
    IN  WDFDMATRANSACTION  Transaction,
    IN  WDFDEVICE  Device,
    IN  WDFCONTEXT  Context, 
    IN  WDF_DMA_DIRECTION  Direction,
    IN  PSCATTER_GATHER_LIST  SgList
    )
{
    //
    // Obtain driver-defined device object context.
    //
    devExt = PLxGetDeviceContext(Device);

    //
    // Acquire the device interrupt's spin lock.
    //
    WdfInterruptAcquireLock(devExt->Interrupt);

    //
    // Access device registers to program the DMA transfer here. 
    //
...

    //
    // Release the device interrupt's spin lock.
    //
    WdfInterruptReleaseLock(devExt->Interrupt);
}

要件

バージョン

Available in version 1.0 and later versions of KMDF.

ヘッダー

Wdfinterrupt.h (includeWdf.h)

ライブラリ

Wdf<MajorVersionNumber>000.sys (see Framework Library Versions.)

IRQL

<=DISPATCH_LEVEL

参照

WdfInterruptReleaseLock

WdfInterruptSynchronize

WDF_INTERRUPT_CONFIG

EvtInterruptDisable

EvtInterruptEnable

EvtInterruptIsr

EvtInterruptSynchronize