Author: arty
Date: Mon Sep 3 09:29:03 2007
New Revision: 28801
URL:
http://svn.reactos.org/svn/reactos?rev=28801&view=rev
Log:
Move mismerged segment to the right place; claim from openfirmware if we
don't have enough reserve.
Modified:
trunk/reactos/boot/freeldr/freeldr/mm/mm.c
Modified: trunk/reactos/boot/freeldr/freeldr/mm/mm.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/boot/freeldr/freeldr/mm/mm…
==============================================================================
--- trunk/reactos/boot/freeldr/freeldr/mm/mm.c (original)
+++ trunk/reactos/boot/freeldr/freeldr/mm/mm.c Mon Sep 3 09:29:03 2007
@@ -68,36 +68,38 @@
if (MemorySize == 0)
{
+ DbgPrint((DPRINT_MEMORY, "MmAllocateMemory() called for 0 bytes. Returning
NULL.\n"));
+ UiMessageBoxCritical("Memory allocation failed: MmAllocateMemory() called for 0
bytes.");
+ return NULL;
+ }
+
+ MemorySize = ROUND_UP(MemorySize, 4);
+ if (MemorySize <= SubAllocationRest)
+ {
+ MemPointer = (PVOID)((ULONG_PTR)SubAllocationPage + MM_PAGE_SIZE - SubAllocationRest);
+ SubAllocationRest -= MemorySize;
+ return MemPointer;
+ }
+
+ // Find out how many blocks it will take to
+ // satisfy this allocation
+ PagesNeeded = ROUND_UP(MemorySize, MM_PAGE_SIZE) / MM_PAGE_SIZE;
+
+ // If we don't have enough available mem
+ // then return NULL
+ if (FreePagesInLookupTable < PagesNeeded)
+ {
#ifdef _M_PPC
ULONG ptr;
printf("Allocating %d bytes directly ...\n", MemorySize);
ptr = ofw_claim(0,MemorySize,MM_PAGE_SIZE);
MemPointer = (PVOID)(ptr);
-#endif
- DbgPrint((DPRINT_MEMORY, "MmAllocateMemory() called for 0 bytes. Returning
NULL.\n"));
- UiMessageBoxCritical("Memory allocation failed: MmAllocateMemory() called for 0
bytes.");
- return NULL;
- }
-
- MemorySize = ROUND_UP(MemorySize, 4);
- if (MemorySize <= SubAllocationRest)
- {
- MemPointer = (PVOID)((ULONG_PTR)SubAllocationPage + MM_PAGE_SIZE - SubAllocationRest);
- SubAllocationRest -= MemorySize;
- return MemPointer;
- }
-
- // Find out how many blocks it will take to
- // satisfy this allocation
- PagesNeeded = ROUND_UP(MemorySize, MM_PAGE_SIZE) / MM_PAGE_SIZE;
-
- // If we don't have enough available mem
- // then return NULL
- if (FreePagesInLookupTable < PagesNeeded)
- {
+ return MemPointer;
+#else
DbgPrint((DPRINT_MEMORY, "Memory allocation failed in MmAllocateMemory(). Not
enough free memory to allocate %d bytes. AllocationCount: %d\n", MemorySize,
AllocationCount));
UiMessageBoxCritical("Memory allocation failed: out of memory.");
return NULL;
+#endif
}
FirstFreePageFromEnd = MmFindAvailablePages(PageLookupTableAddress,
TotalPagesInLookupTable, PagesNeeded, AllocateFromEnd);