Index: init.c =================================================================== --- init.c (revision 44086) +++ init.c (working copy) @@ -75,6 +75,14 @@ BOOLEAN ExCmosClockIsSane = TRUE; BOOLEAN ExpRealTimeIsUniversal; +/* BBT stuff */ +PFN_COUNT BBTReservedPages; +#define BBT_INIT_TRACEFLAGS(Option, Action) +extern MEMORY_ALLOCATION_DESCRIPTOR BBTMemDescriptor; + +/* Referenced Internal Protos */ +VOID +ExBurnMemory( IN PLOADER_PARAMETER_BLOCK LoaderBlock); /* FUNCTIONS ****************************************************************/ NTSTATUS @@ -922,8 +930,7 @@ if (PerfMem) { /* FIXME: TODO */ - DPRINT1("Burnable memory support not yet present." - "/BURNMEM option ignored.\n"); + ExBurnMemory(LoaderBlock); } } } @@ -1907,3 +1914,85 @@ /* Jump into zero page thread */ MmZeroPageThreadMain(NULL); } + + +VOID +ExBurnMemory(IN PLOADER_PARAMETER_BLOCK LoaderBlock) +{ + PLIST_ENTRY ListHeader; + PMEMORY_ALLOCATION_DESCRIPTOR MemDescriptor; + PLIST_ENTRY NextEntry; + PCHAR Options; + PCHAR BurnMemOption; + ULONG BurnMemoryAmount; + ULONG PagesToDestroy; + ULONG PagesBurned; + + if (LoaderBlock->LoadOptions == NULL) { + return; + } + + Options = LoaderBlock->LoadOptions; + _strupr(Options); + /* Do we have burnmemory? */ + BurnMemOption = strstr(Options, "BURNMEMORY"); + if (BurnMemOption == NULL ) { + return; + } + + BurnMemOption = strstr(BurnMemOption,"="); + if (BurnMemOption == NULL ) { + return; + } + + /* If we do, multiply memory amount by 1024^2 and divide by 4096 */ + BurnMemoryAmount = atol(BurnMemOption+1); + PagesToDestroy = (BurnMemoryAmount*(1024*1024))/PAGE_SIZE; + + /* Print out burned ram amount for people using Kdbg */ + DPRINT1("ExBurnMemory(): Burn RAM Amount: %dmb -> %d pages\n",BurnMemoryAmount,PagesToDestroy); + + ListHeader = &LoaderBlock->MemoryDescriptorListHead; + NextEntry = ListHeader->Flink; + PagesBurned = 0; + /* Let's do the main routine */ + do { + 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 = LoaderBad; + } + } + else { + /* Nothing to do. */ + return; + } + } + + NextEntry = NextEntry->Flink; + + } while (NextEntry != ListHeader); + +} + +/* EOF */