mirror of
https://github.com/reactos/reactos.git
synced 2025-08-05 16:23:01 +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"));
|
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)
|
if (MemoryFlags & NDIS_MEMORY_CONTIGUOUS)
|
||||||
{
|
{
|
||||||
*VirtualAddress = MmAllocateContiguousMemory(Length, HighestAcceptableAddress);
|
/* Allocate contiguous memory (possibly noncached) */
|
||||||
if(!*VirtualAddress)
|
*VirtualAddress = MmAllocateContiguousMemorySpecifyCache(Length,
|
||||||
return NDIS_STATUS_FAILURE;
|
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)
|
if (!*VirtualAddress)
|
||||||
return NDIS_STATUS_FAILURE;
|
return NDIS_STATUS_FAILURE;
|
||||||
|
|
||||||
|
@ -120,19 +120,23 @@ NdisFreeMemory(
|
||||||
{
|
{
|
||||||
NDIS_DbgPrint(MAX_TRACE, ("Called.\n"));
|
NDIS_DbgPrint(MAX_TRACE, ("Called.\n"));
|
||||||
|
|
||||||
if (MemoryFlags & NDIS_MEMORY_NONCACHED)
|
|
||||||
{
|
|
||||||
MmFreeNonCachedMemory(VirtualAddress, Length);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (MemoryFlags & NDIS_MEMORY_CONTIGUOUS)
|
if (MemoryFlags & NDIS_MEMORY_CONTIGUOUS)
|
||||||
{
|
{
|
||||||
MmFreeContiguousMemory(VirtualAddress);
|
/* Free contiguous memory (possibly noncached) */
|
||||||
return;
|
MmFreeContiguousMemorySpecifyCache(VirtualAddress,
|
||||||
}
|
Length,
|
||||||
|
(MemoryFlags & NDIS_MEMORY_NONCACHED) ? MmNonCached : MmCached);
|
||||||
ExFreePool(VirtualAddress);
|
}
|
||||||
|
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