mirror of
https://github.com/reactos/reactos.git
synced 2025-07-31 05:51:44 +00:00
- Fix handling of nonpaged contiguous memory in NdisAllocateMemory and NdisFreeMemory
svn path=/trunk/; revision=41207
This commit is contained in:
parent
c52c28e739
commit
a9826865bc
1 changed files with 34 additions and 30 deletions
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue