mirror of
https://github.com/ApfelTeeSaft/reactos.git
synced 2026-09-02 04:13:34 +00:00
- Fix handling of nonpaged contiguous memory in NdisAllocateMemory and NdisFreeMemory
svn path=/trunk/; revision=41207
This commit is contained in:
@@ -74,26 +74,26 @@ NdisAllocateMemory(
|
||||
{
|
||||
NDIS_DbgPrint(MAX_TRACE, ("Called.\n"));
|
||||
|
||||
if (MemoryFlags & NDIS_MEMORY_NONCACHED)
|
||||
{
|
||||
*VirtualAddress = MmAllocateNonCachedMemory(Length);
|
||||
if(!*VirtualAddress)
|
||||
return NDIS_STATUS_FAILURE;
|
||||
|
||||
return NDIS_STATUS_SUCCESS;
|
||||
}
|
||||
|
||||
if (MemoryFlags & NDIS_MEMORY_CONTIGUOUS)
|
||||
{
|
||||
*VirtualAddress = MmAllocateContiguousMemory(Length, HighestAcceptableAddress);
|
||||
if(!*VirtualAddress)
|
||||
return NDIS_STATUS_FAILURE;
|
||||
{
|
||||
/* Allocate contiguous memory (possibly noncached) */
|
||||
*VirtualAddress = MmAllocateContiguousMemorySpecifyCache(Length,
|
||||
RtlConvertUlongToLargeInteger(0),
|
||||
HighestAcceptableAddress,
|
||||
RtlConvertUlongToLargeInteger(0),
|
||||
(MemoryFlags & NDIS_MEMORY_NONCACHED) ? MmNonCached : MmCached);
|
||||
}
|
||||
else if (MemoryFlags & NDIS_MEMORY_NONCACHED)
|
||||
{
|
||||
/* Allocate noncached noncontiguous memory */
|
||||
*VirtualAddress = MmAllocateNonCachedMemory(Length);
|
||||
}
|
||||
else
|
||||
{
|
||||
/* Allocate plain nonpaged memory */
|
||||
*VirtualAddress = ExAllocatePool(NonPagedPool, Length);
|
||||
}
|
||||
|
||||
return NDIS_STATUS_SUCCESS;
|
||||
}
|
||||
|
||||
/* Plain nonpaged memory */
|
||||
*VirtualAddress = ExAllocatePool(NonPagedPool, Length);
|
||||
if (!*VirtualAddress)
|
||||
return NDIS_STATUS_FAILURE;
|
||||
|
||||
@@ -120,19 +120,23 @@ NdisFreeMemory(
|
||||
{
|
||||
NDIS_DbgPrint(MAX_TRACE, ("Called.\n"));
|
||||
|
||||
if (MemoryFlags & NDIS_MEMORY_NONCACHED)
|
||||
{
|
||||
MmFreeNonCachedMemory(VirtualAddress, Length);
|
||||
return;
|
||||
}
|
||||
|
||||
if (MemoryFlags & NDIS_MEMORY_CONTIGUOUS)
|
||||
{
|
||||
MmFreeContiguousMemory(VirtualAddress);
|
||||
return;
|
||||
}
|
||||
|
||||
ExFreePool(VirtualAddress);
|
||||
{
|
||||
/* Free contiguous memory (possibly noncached) */
|
||||
MmFreeContiguousMemorySpecifyCache(VirtualAddress,
|
||||
Length,
|
||||
(MemoryFlags & NDIS_MEMORY_NONCACHED) ? MmNonCached : MmCached);
|
||||
}
|
||||
else if (MemoryFlags & NDIS_MEMORY_NONCACHED)
|
||||
{
|
||||
/* Free noncached noncontiguous memory */
|
||||
MmFreeNonCachedMemory(VirtualAddress, Length);
|
||||
}
|
||||
else
|
||||
{
|
||||
/* Free nonpaged pool */
|
||||
ExFreePool(VirtualAddress);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user