MINIPORT_ALLOCATE_SHARED_MEM_COMPLETE callback function

NDIS calls a miniport driver's MiniportSharedMemoryAllocateComplete function to complete a shared memory allocation request that the miniport driver started by calling the NdisMAllocateSharedMemoryAsyncEx function.

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

Syntax


MINIPORT_ALLOCATE_SHARED_MEM_COMPLETE MiniportSharedMemoryAllocateComplete;

VOID MiniportSharedMemoryAllocateComplete(
  _In_ NDIS_HANDLE            MiniportAdapterContext,
  _In_ PVOID                  VirtualAddress,
  _In_ PNDIS_PHYSICAL_ADDRESS PhysicalAddress,
  _In_ ULONG                  Length,
  _In_ PVOID                  Context
)
{ ... }

Parameters

MiniportAdapterContext [in]

The handle to a context area allocated by the miniport driver in which the driver maintains state information for a NIC. The driver allocates this context area in the MiniportInitializeEx function.

VirtualAddress [in]

The base virtual address of the shared memory that the miniport driver allocated by calling NdisMAllocateSharedMemoryAsyncEx. VirtualAddress is NULL if the allocation attempt failed.

PhysicalAddress [in]

The base physical address for the NIC to use that is mapped to the address that the VirtualAddress parameter specifies.

Length [in]

The number of bytes that NdisMAllocateSharedMemoryAsyncEx allocated.

Context [in]

A pointer to a context area that the miniport driver specified in the preceding call to NdisMAllocateSharedMemoryAsyncEx.

Return value

None

Remarks

MiniportAllocateSharedMemoryComplete is an optional function for miniport drivers. A miniport driver registers a MiniportAllocateSharedMemoryComplete function in the NDIS_SG_DMA_DESCRIPTION structure that the driver passed to the NdisMRegisterScatterGatherDma function.

Miniport drivers call NdisMAllocateSharedMemoryAsyncEx to allocate shared memory. If NdisMAllocateSharedMemoryAsyncEx returns NDIS_STATUS_PENDING, NDIS calls MiniportAllocateSharedMemoryComplete to pass the memory to the miniport driver.

NDIS calls MiniportSharedMemoryAllocateComplete at IRQL PASSIVE_LEVEL.

Examples

To define a MiniportSharedMemoryAllocateComplete 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 MiniportSharedMemoryAllocateComplete function that is named "MySharedMemoryAllocateComplete", use the MINIPORT_ALLOCATE_SHARED_MEM_COMPLETE type as shown in this code example:


MINIPORT_ALLOCATE_SHARED_MEM_COMPLETE MySharedMemoryAllocateComplete;

Then, implement your function as follows:


_Use_decl_annotations_
VOID
 MySharedMemoryAllocateComplete(
    NDIS_HANDLE  MiniportAdapterContext,
    PVOID  VirtualAddress,
    PNDIS_PHYSICAL_ADDRESS  PhysicalAddress,
    ULONG  Length,
    PVOID  Context
    )
  {...}

The MINIPORT_ALLOCATE_SHARED_MEM_COMPLETE 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_ALLOCATE_SHARED_MEM_COMPLETE 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

PASSIVE_LEVEL

See also

MiniportInitializeEx
NdisMAllocateSharedMemoryAsyncEx
NdisMRegisterScatterGatherDma

 

 

Send comments about this topic to Microsoft

Show: