Index: init.c =================================================================== --- init.c (revision 44108) +++ init.c (working copy) @@ -817,6 +817,63 @@ VOID NTAPI +ExBurnMemory(IN PLOADER_PARAMETER_BLOCK LoaderBlock, + IN ULONG PagesToDestroy, + IN TYPE_OF_MEMORY MemoryType) +{ + PLIST_ENTRY ListHeader; + PMEMORY_ALLOCATION_DESCRIPTOR MemDescriptor; + PLIST_ENTRY NextEntry; + ULONG PagesBurned; + + DPRINT1("Burn RAM amount: %d pages\n", PagesToDestroy); + + /* Initialize temporary variables */ + ListHeader = &LoaderBlock->MemoryDescriptorListHead; + NextEntry = ListHeader->Flink; + PagesBurned = 0; + + /* Let's do the main loop */ + do + { + /* Get the memory descriptor structure */ + MemDescriptor = CONTAINING_RECORD(NextEntry, + MEMORY_ALLOCATION_DESCRIPTOR, + ListEntry); + + /* Is memory free there or is it temporary? */ + if (MemDescriptor->MemoryType == LoaderFree || + MemDescriptor->MemoryType == LoaderFirmwareTemporary) + { + if (PagesBurned < PagesToDestroy) + { + /* We still have pages to destroy */ + if (MemDescriptor->PageCount > (PagesToDestroy - PagesBurned)) + { + /* Change block's page count, ntoskrnl doesn't care much */ + MemDescriptor->PageCount = MemDescriptor->PageCount - (PagesToDestroy - PagesBurned); + PagesBurned = PagesToDestroy; + } + else + { + /* We care, change block size */ + PagesBurned += MemDescriptor->PageCount; + MemDescriptor->MemoryType = MemoryType; + } + } + else + { + /* Nothing to do. */ + return; + } + } + /* Advance to the next descriptor */ + NextEntry = NextEntry->Flink; + } while (NextEntry != ListHeader); +} + +VOID +NTAPI ExpInitializeExecutive(IN ULONG Cpu, IN PLOADER_PARAMETER_BLOCK LoaderBlock) { @@ -919,12 +976,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); } } }