MiniportSynchronizeInterrupt routine

A miniport driver must provide a MiniportSynchronizeInterrupt handler if any driver function that runs at less than DIRQL shares resources with the MiniportInterrupt function.

Note  You must declare the function by using the MINIPORT_SYNCHRONIZE_INTERRUPT type. For more information, see the following Examples section.

Syntax


MINIPORT_SYNCHRONIZE_INTERRUPT MiniportSynchronizeInterrupt;

BOOLEAN MiniportSynchronizeInterrupt(
  _In_  NDIS_HANDLE SynchronizeContext
)
{ ... }

Parameters

SynchronizeContext [in]

A handle to a context area that is supplied when the miniport driver's MiniportXxx or internal function called the NdisMSynchronizeWithInterruptEx function.

Return value

MiniportSynchronizeInterrupt returns a Boolean value with a driver-determined meaning. NDIS returns the same value when NDIS returns from NdisMSynchronizeWithInterruptEx.

Remarks

If any miniport driver function that runs at less than DIRQL shares resources, such as NIC registers, with the driver's MiniportInterrupt function, that driver cannot access those resources directly. If such a lower priority function attempts to access the shared resources directly, it might be preempted by MiniportInterrupt. MiniportInterrupt could override the state changes of the lower priority driver function.

To synchronize access to shared resources with MiniportInterrupt, lower priority driver functions must call the NdisMSynchronizeWithInterruptEx function. The driver's MiniportSynchronizeInterrupt function accesses the shared resources at DIRQL. Calling NdisMSynchronizeWithInterruptEx prevents race conditions and deadlocks in such a miniport driver.

Any lower priority driver functions that share resources among themselves (but not with any function that runs at DIRQL) should use a spin lock to protect those shared resources.

MiniportSynchronizeInterrupt runs at the DIRQL assigned when the driver's MiniportInitializeEx function calls the NdisMRegisterInterruptEx function. Like any driver function that runs at DIRQL, MiniportSynchronizeInterrupt should return control back to the caller as quickly as possible, and it can call only those NdisXxx functions that are safe to call at any IRQL.

Examples

To define a MiniportSynchronizeInterrupt function, you must first provide a function declaration that identifies the type of function you're defining. Windows provides a set of function types for drivers. Declaring a function using the 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 MiniportSynchronizeInterrupt function that is named "MySynchronizeInterrupt", use the MINIPORT_SYNCHRONIZE_INTERRUPT type as shown in this code example:


MINIPORT_SYNCHRONIZE_INTERRUPT MySynchronizeInterrupt;

Then, implement your function as follows:


_Use_decl_annotations_
BOOLEAN
 MySynchronizeInterrupt(
    NDIS_HANDLE  SynchronizeContext
    )
  {...}

The MINIPORT_SYNCHRONIZE_INTERRUPT function type is defined in the Ndis.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 MINIPORT_SYNCHRONIZE_INTERRUPT 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 NDIS Drivers. For information about _Use_decl_annotations_, see Annotating Function Behavior.

Requirements

Version

Supported in NDIS 6.0 and later.

Header

Ndis.h (include Ndis.h)

IRQL

See Remarks section

See also

MiniportInitializeEx
MiniportInetrrupt
NdisAllocateSpinLock
NdisMRegisterInterruptEx
NdisMSynchronizeWithInterruptEx

 

 

Send comments about this topic to Microsoft

Show:
© 2014 Microsoft