Author: tkreuzer Date: Thu Aug 19 08:50:23 2010 New Revision: 48565
URL: http://svn.reactos.org/svn/reactos?rev=48565&view=rev Log: [NTOSKRNL] - Implement support for /BURNMEMORY option. - Don't stop boot on bad memory type Patch by Jay Smith, modified by Aleksey, even more modified by me.
See issue #4957 for more details.
Modified: trunk/reactos/ntoskrnl/ex/init.c trunk/reactos/ntoskrnl/mm/ARM3/mminit.c
Modified: trunk/reactos/ntoskrnl/ex/init.c URL: http://svn.reactos.org/svn/reactos/trunk/reactos/ntoskrnl/ex/init.c?rev=4856... ============================================================================== --- trunk/reactos/ntoskrnl/ex/init.c [iso-8859-1] (original) +++ trunk/reactos/ntoskrnl/ex/init.c [iso-8859-1] Thu Aug 19 08:50:23 2010 @@ -817,6 +817,51 @@
VOID NTAPI +ExBurnMemory(IN PLOADER_PARAMETER_BLOCK LoaderBlock, + IN ULONG PagesToDestroy, + IN TYPE_OF_MEMORY MemoryType) +{ + PLIST_ENTRY ListEntry; + PMEMORY_ALLOCATION_DESCRIPTOR MemDescriptor; + + DPRINT1("Burn RAM amount: %d pages\n", PagesToDestroy); + + /* Loop the memory descriptors, beginning at the end */ + for (ListEntry = LoaderBlock->MemoryDescriptorListHead.Blink; + ListEntry != &LoaderBlock->MemoryDescriptorListHead; + ListEntry = ListEntry->Blink) + { + /* Get the memory descriptor structure */ + MemDescriptor = CONTAINING_RECORD(ListEntry, + MEMORY_ALLOCATION_DESCRIPTOR, + ListEntry); + + /* Is memory free there or is it temporary? */ + if (MemDescriptor->MemoryType == LoaderFree || + MemDescriptor->MemoryType == LoaderFirmwareTemporary) + { + /* Check if the descriptor has more pages than we want */ + if (MemDescriptor->PageCount > PagesToDestroy) + { + /* Change block's page count, ntoskrnl doesn't care much */ + MemDescriptor->PageCount -= PagesToDestroy; + break; + } + else + { + /* Change block type */ + MemDescriptor->MemoryType = MemoryType; + PagesToDestroy -= MemDescriptor->PageCount; + + /* Check if we are done */ + if (PagesToDestroy == 0) break; + } + } + } +} + +VOID +NTAPI ExpInitializeExecutive(IN ULONG Cpu, IN PLOADER_PARAMETER_BLOCK LoaderBlock) { @@ -919,12 +964,7 @@ { /* Read the number of pages we'll use */ PerfMemUsed = atol(PerfMem + 1) * (1024 * 1024 / PAGE_SIZE); - if (PerfMem) - { - /* FIXME: TODO */ - DPRINT1("Burnable memory support not yet present." - "/BURNMEM option ignored.\n"); - } + if (PerfMemUsed) ExBurnMemory(LoaderBlock, PerfMemUsed, LoaderBad); } } }
Modified: trunk/reactos/ntoskrnl/mm/ARM3/mminit.c URL: http://svn.reactos.org/svn/reactos/trunk/reactos/ntoskrnl/mm/ARM3/mminit.c?r... ============================================================================== --- trunk/reactos/ntoskrnl/mm/ARM3/mminit.c [iso-8859-1] (original) +++ trunk/reactos/ntoskrnl/mm/ARM3/mminit.c [iso-8859-1] Thu Aug 19 08:50:23 2010 @@ -831,8 +831,7 @@ /* Check for bad RAM */ case LoaderBad:
- DPRINT1("You have damaged RAM modules. Stopping boot\n"); - while (TRUE); + DPRINT1("You either have specified /BURNMEMORY or damaged RAM modules.\n"); break;
/* Check for free RAM */