NdisMFreeSharedMemory function (ndis.h)

NdisMFreeSharedMemory frees memory that was previously allocated by NdisMAllocateSharedMemory or NdisMAllocateSharedMemoryAsyncEx by the driver of a DMA NIC.

Syntax

void NdisMFreeSharedMemory(
  [in] NDIS_HANDLE           MiniportAdapterHandle,
  [in] ULONG                 Length,
  [in] BOOLEAN               Cached,
  [in] PVOID                 VirtualAddress,
  [in] NDIS_PHYSICAL_ADDRESS PhysicalAddress
);

Parameters

[in] MiniportAdapterHandle

Specifies the handle originally input to MiniportInitializeEx.

[in] Length

Specifies the number of bytes originally allocated.

[in] Cached

Specifies TRUE if the original allocation was cacheable.

[in] VirtualAddress

Specifies the base virtual address returned by NdisMAllocateSharedMemory or NdisMAllocateSharedMemoryAsyncEx.

[in] PhysicalAddress

Specifies the corresponding physical address returned by NdisMAllocateSharedMemory or NdisMAllocateSharedMemoryAsyncEx.

Return value

None

Remarks

If it has already made a successful call to NdisMAllocateSharedMemory or NdisMAllocateSharedMemoryAsyncEx, the miniport driver of a DMA device calls NdisMFreeSharedMemory if any of the following occurs:

  • Its MiniportInitializeEx function is unable to initialize the NIC, so this function must release all existing claims on hardware resources for that NIC before it returns control.
  • The NIC for which the miniport driver allocated the memory is being removed.
  • The driver is being unloaded, whether because the system is shutting down or because the user reconfigured the network components used in the machine.
  • The driver allocated additional shared memory with NdisMAllocateSharedMemoryAsyncEx when I/O demand on a NIC was high but network traffic has now subsided to an average level.
A miniport driver cannot call NdisMFreeSharedMemory to free a subrange within an allocated shared memory range. The parameters passed to NdisMFreeSharedMemory must match exactly those that were passed to NdisMAllocateSharedMemory or NdisMAllocateSharedMemoryAsyncEx.

NdisMFreeSharedMemory cannot be called from a MiniportShutdownEx function.

Microsoft Windows Server 2003, Windows XP Service Pack 1, and later versions of Windows allow both bus-master DMA NICs and subordinate DMA NICs to call NdisMFreeSharedMemory. Prior releases allow only bus-master DMA NICs to call NdisMFreeSharedMemory.

Requirements

Requirement Value
Minimum supported client Supported for NDIS 6.0 and NDIS 5.1 drivers (see NdisMFreeSharedMemory (NDIS 5.1)) in Windows Vista. Supported for NDIS 5.1 drivers (see NdisMFreeSharedMemory (NDIS 5.1)) in Windows XP.
Target Platform Universal
Header ndis.h (include Ndis.h)
Library Ndis.lib
IRQL <= DISPATCH_LEVEL
DDI compliance rules Irql_Miniport_Driver_Function(ndis), NdisMFreeSharedMemory(ndis)

See also

MiniportHaltEx

MiniportInitializeEx

MiniportSharedMemoryAllocateComplete

MiniportShutdownEx

NdisMAllocateSharedMemory

NdisMAllocateSharedMemoryAsyncEx