2 * COPYRIGHT: See COPYING in the top level directory
3 * PROJECT: ReactOS NDIS library
5 * PURPOSE: Memory management routines
6 * PROGRAMMERS: Casper S. Hornstrup (chorns@users.sourceforge.net)
8 * CSH 01/08-2000 Created
15 NdisAllocateMemoryWithTag(
16 OUT PVOID
*VirtualAddress
,
28 return NDIS_STATUS_FAILURE
;
34 NdisCreateLookaheadBufferFromSharedMemory(
35 IN PVOID pSharedMemory
,
36 IN UINT LookaheadLength
,
37 OUT PVOID
*pLookaheadBuffer
)
45 NdisDestroyLookaheadBufferFromSharedMemory(
46 IN PVOID pLookaheadBuffer
)
54 NdisMoveFromMappedMemory(
55 OUT PVOID Destination
,
66 OUT PVOID Destination
,
76 NdisMoveToMappedMemory(
77 OUT PVOID Destination
,
87 NdisMUpdateSharedMemory(
88 IN NDIS_HANDLE MiniportAdapterHandle
,
90 IN PVOID VirtualAddress
,
91 IN NDIS_PHYSICAL_ADDRESS PhysicalAddress
)
100 OUT PVOID
*VirtualAddress
,
103 IN NDIS_PHYSICAL_ADDRESS HighestAcceptableAddress
)
105 * FUNCTION: Allocates a block of memory
107 * VirtualAddress = Address of buffer to place virtual
108 * address of the allocated memory
109 * Length = Size of the memory block to allocate
110 * MemoryFlags = Flags to specify special restrictions
111 * HighestAcceptableAddress = Specifies -1
116 if (MemoryFlags
& NDIS_MEMORY_CONTIGUOUS
) {
118 *VirtualAddress
= NULL
;
119 return NDIS_STATUS_FAILURE
;
122 if (MemoryFlags
& NDIS_MEMORY_NONCACHED
) {
124 *VirtualAddress
= NULL
;
125 return NDIS_STATUS_FAILURE
;
128 /* Plain nonpaged memory */
129 Block
= ExAllocatePool(NonPagedPool
, Length
);
130 *VirtualAddress
= Block
;
132 return NDIS_STATUS_FAILURE
;
134 return NDIS_STATUS_SUCCESS
;
141 IN PVOID VirtualAddress
,
145 * FUNCTION: Frees a memory block allocated with NdisAllocateMemory
147 * VirtualAddress = Pointer to the base virtual address of the allocated memory
148 * Length = Size of the allocated memory block as passed to NdisAllocateMemory
149 * MemoryFlags = Memory flags passed to NdisAllocateMemory
152 if (MemoryFlags
& NDIS_MEMORY_CONTIGUOUS
) {
157 if (MemoryFlags
& NDIS_MEMORY_NONCACHED
) {
162 /* Plain nonpaged memory */
163 ExFreePool(VirtualAddress
);
169 NdisImmediateReadSharedMemory(
170 IN NDIS_HANDLE WrapperConfigurationContext
,
171 IN ULONG SharedMemoryAddress
,
180 NdisImmediateWriteSharedMemory(
181 IN NDIS_HANDLE WrapperConfigurationContext
,
182 IN ULONG SharedMemoryAddress
,
192 NdisMAllocateSharedMemory(
193 IN NDIS_HANDLE MiniportAdapterHandle
,
196 OUT PVOID
*VirtualAddress
,
197 OUT PNDIS_PHYSICAL_ADDRESS PhysicalAddress
)
205 NdisMAllocateSharedMemoryAsync(
206 IN NDIS_HANDLE MiniportAdapterHandle
,
213 return NDIS_STATUS_FAILURE
;
219 NdisMFreeSharedMemory(
220 IN NDIS_HANDLE MiniportAdapterHandle
,
223 IN PVOID VirtualAddress
,
224 IN NDIS_PHYSICAL_ADDRESS PhysicalAddress
)