Author: fireball Date: Sun Jan 13 15:53:49 2008 New Revision: 31755
URL: http://svn.reactos.org/svn/reactos?rev=31755&view=rev Log: - Sync up Mm interface with WinLdr branch (introduce the concept of a memory type at every allocation, however in freeldr's implementation it's just ignored now). - Copy winldr's files from the branch, with the only #ifdef WHEN_MERGE_COMPLETE hack.
Added: trunk/reactos/boot/freeldr/freeldr/include/winldr.h - copied unchanged from r31751, branches/winldr/include/winldr.h trunk/reactos/boot/freeldr/freeldr/windows/conversion.c - copied unchanged from r31751, branches/winldr/windows/conversion.c trunk/reactos/boot/freeldr/freeldr/windows/peloader.c - copied unchanged from r31751, branches/winldr/windows/peloader.c trunk/reactos/boot/freeldr/freeldr/windows/winldr.c - copied, changed from r31751, branches/winldr/windows/winldr.c trunk/reactos/boot/freeldr/freeldr/windows/wlmemory.c - copied unchanged from r31751, branches/winldr/windows/wlmemory.c trunk/reactos/boot/freeldr/freeldr/windows/wlregistry.c - copied unchanged from r31751, branches/winldr/windows/wlregistry.c Modified: trunk/reactos/boot/freeldr/freeldr/arch/i386/loader.c trunk/reactos/boot/freeldr/freeldr/include/mm.h trunk/reactos/boot/freeldr/freeldr/linuxboot.c trunk/reactos/boot/freeldr/freeldr/mm/meminit.c trunk/reactos/boot/freeldr/freeldr/mm/mm.c
Modified: trunk/reactos/boot/freeldr/freeldr/arch/i386/loader.c URL: http://svn.reactos.org/svn/reactos/trunk/reactos/boot/freeldr/freeldr/arch/i... ============================================================================== --- trunk/reactos/boot/freeldr/freeldr/arch/i386/loader.c (original) +++ trunk/reactos/boot/freeldr/freeldr/arch/i386/loader.c Sun Jan 13 15:53:49 2008 @@ -513,7 +513,7 @@
/* Allocate memory for the driver */ DriverSize = NtHeader->OptionalHeader.SizeOfImage; - LoadBase = MmAllocateMemoryAtAddress(DriverSize, LoadBase); + LoadBase = MmAllocateMemoryAtAddress(DriverSize, LoadBase, LoaderSystemCode); ASSERT(LoadBase);
/* Copy headers over */
Modified: trunk/reactos/boot/freeldr/freeldr/include/mm.h URL: http://svn.reactos.org/svn/reactos/trunk/reactos/boot/freeldr/freeldr/includ... ============================================================================== --- trunk/reactos/boot/freeldr/freeldr/include/mm.h (original) +++ trunk/reactos/boot/freeldr/freeldr/include/mm.h Sun Jan 13 15:53:49 2008 @@ -47,6 +47,14 @@ ( ((a) >> MM_PAGE_SHIFT) + ((a) & MM_PAGE_MASK ? 1 : 0) )
#endif // defined __i386__ or _PPC_ or _MIPS_ +// +// This is the zone which is used by the OS loader +// +#define LOADER_HIGH_ZONE ((16*1024*1024) >> MM_PAGE_SHIFT) //16Mb page + +// HEAP and STACK size +#define HEAP_PAGES 0x100//0x18 +#define STACK_PAGES 0x00
typedef struct { @@ -79,7 +87,7 @@ VOID MmSortBiosMemoryMap(PBIOS_MEMORY_MAP BiosMemoryMap, ULONG MapCount); // Sorts the BIOS_MEMORY_MAP array so the first element corresponds to the first address in memory VOID MmInitPageLookupTable(PVOID PageLookupTable, ULONG TotalPageCount, PBIOS_MEMORY_MAP BiosMemoryMap, ULONG MapCount); // Inits the page lookup table according to the memory types in the memory map VOID MmMarkPagesInLookupTable(PVOID PageLookupTable, ULONG StartPage, ULONG PageCount, TYPE_OF_MEMORY PageAllocated); // Marks the specified pages as allocated or free in the lookup table -VOID MmAllocatePagesInLookupTable(PVOID PageLookupTable, ULONG StartPage, ULONG PageCount); // Allocates the specified pages in the lookup table +VOID MmAllocatePagesInLookupTable(PVOID PageLookupTable, ULONG StartPage, ULONG PageCount, TYPE_OF_MEMORY MemoryType); // Allocates the specified pages in the lookup table ULONG MmCountFreePagesInLookupTable(PVOID PageLookupTable, ULONG TotalPageCount); // Returns the number of free pages in the lookup table ULONG MmFindAvailablePages(PVOID PageLookupTable, ULONG TotalPageCount, ULONG PagesNeeded, BOOLEAN FromEnd); // Returns the page number of the first available page range from the beginning or end of memory ULONG MmFindAvailablePagesBeforePage(PVOID PageLookupTable, ULONG TotalPageCount, ULONG PagesNeeded, ULONG LastPage); // Returns the page number of the first available page range before the specified page @@ -93,12 +101,17 @@
//BOOLEAN MmInitializeMemoryManager(ULONG LowMemoryStart, ULONG LowMemoryLength); BOOLEAN MmInitializeMemoryManager(VOID); +VOID MmInitializeHeap(PVOID PageLookupTable); PVOID MmAllocateMemory(ULONG MemorySize); +PVOID MmAllocateMemoryWithType(ULONG MemorySize, TYPE_OF_MEMORY MemoryType); VOID MmFreeMemory(PVOID MemoryPointer); VOID MmChangeAllocationPolicy(BOOLEAN PolicyAllocatePagesFromEnd); //PVOID MmAllocateLowMemory(ULONG MemorySize); //VOID MmFreeLowMemory(PVOID MemoryPointer); -PVOID MmAllocateMemoryAtAddress(ULONG MemorySize, PVOID DesiredAddress); -PVOID MmAllocateHighestMemoryBelowAddress(ULONG MemorySize, PVOID DesiredAddress); +PVOID MmAllocateMemoryAtAddress(ULONG MemorySize, PVOID DesiredAddress, TYPE_OF_MEMORY MemoryType); +PVOID MmAllocateHighestMemoryBelowAddress(ULONG MemorySize, PVOID DesiredAddress, TYPE_OF_MEMORY MemoryType); + +PVOID MmHeapAlloc(ULONG MemorySize); +VOID MmHeapFree(PVOID MemoryPointer);
#endif // defined __MEMORY_H
Modified: trunk/reactos/boot/freeldr/freeldr/linuxboot.c URL: http://svn.reactos.org/svn/reactos/trunk/reactos/boot/freeldr/freeldr/linuxb... ============================================================================== --- trunk/reactos/boot/freeldr/freeldr/linuxboot.c (original) +++ trunk/reactos/boot/freeldr/freeldr/linuxboot.c Sun Jan 13 15:53:49 2008 @@ -374,7 +374,7 @@ UiDrawStatusText(StatusText);
// Allocate memory for Linux kernel - LinuxKernelLoadAddress = MmAllocateMemoryAtAddress(LinuxKernelSize, (PVOID)LINUX_KERNEL_LOAD_ADDRESS); + LinuxKernelLoadAddress = MmAllocateMemoryAtAddress(LinuxKernelSize, (PVOID)LINUX_KERNEL_LOAD_ADDRESS, LoaderSystemCode); if (LinuxKernelLoadAddress != (PVOID)LINUX_KERNEL_LOAD_ADDRESS) { return FALSE; @@ -451,11 +451,11 @@ //LinuxInitrdLoadAddress = MmAllocateMemoryAtAddress(LinuxInitrdSize, (PVOID)ROUND_UP((LINUX_KERNEL_LOAD_ADDRESS + LinuxKernelSize), 0x100000)); if (LinuxSetupSector->Version <= 0x0202) { - LinuxInitrdLoadAddress = MmAllocateHighestMemoryBelowAddress(LinuxInitrdSize, (PVOID)LINUX_MAX_INITRD_ADDRESS); - } - else - { - LinuxInitrdLoadAddress = MmAllocateHighestMemoryBelowAddress(LinuxInitrdSize, (PVOID)LinuxSetupSector->InitrdAddressMax); + LinuxInitrdLoadAddress = MmAllocateHighestMemoryBelowAddress(LinuxInitrdSize, (PVOID)LINUX_MAX_INITRD_ADDRESS, LoaderSystemCode); + } + else + { + LinuxInitrdLoadAddress = MmAllocateHighestMemoryBelowAddress(LinuxInitrdSize, (PVOID)LinuxSetupSector->InitrdAddressMax, LoaderSystemCode); } if (LinuxInitrdLoadAddress == NULL) {
Modified: trunk/reactos/boot/freeldr/freeldr/mm/meminit.c URL: http://svn.reactos.org/svn/reactos/trunk/reactos/boot/freeldr/freeldr/mm/mem... ============================================================================== --- trunk/reactos/boot/freeldr/freeldr/mm/meminit.c (original) +++ trunk/reactos/boot/freeldr/freeldr/mm/meminit.c Sun Jan 13 15:53:49 2008 @@ -281,7 +281,7 @@ DbgPrint((DPRINT_MEMORY, "MmMarkPagesInLookupTable() Done\n")); }
-VOID MmAllocatePagesInLookupTable(PVOID PageLookupTable, ULONG StartPage, ULONG PageCount) +VOID MmAllocatePagesInLookupTable(PVOID PageLookupTable, ULONG StartPage, ULONG PageCount, TYPE_OF_MEMORY MemoryType) { PPAGE_LOOKUP_TABLE_ITEM RealPageLookupTable = (PPAGE_LOOKUP_TABLE_ITEM)PageLookupTable; ULONG Index;
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 Sun Jan 13 15:53:49 2008 @@ -57,7 +57,7 @@ AllocateFromEnd = PolicyAllocatePagesFromEnd; }
-PVOID MmAllocateMemory(ULONG MemorySize) +PVOID MmAllocateMemoryWithType(ULONG MemorySize, TYPE_OF_MEMORY MemoryType) { ULONG PagesNeeded; ULONG FirstFreePageFromEnd; @@ -100,7 +100,7 @@ return NULL; }
- MmAllocatePagesInLookupTable(PageLookupTableAddress, FirstFreePageFromEnd, PagesNeeded); + MmAllocatePagesInLookupTable(PageLookupTableAddress, FirstFreePageFromEnd, PagesNeeded, MemoryType);
FreePagesInLookupTable -= PagesNeeded; MemPointer = (PVOID)(FirstFreePageFromEnd * MM_PAGE_SIZE); @@ -123,7 +123,13 @@ return MemPointer; }
-PVOID MmAllocateMemoryAtAddress(ULONG MemorySize, PVOID DesiredAddress) +PVOID MmAllocateMemory(ULONG MemorySize) +{ + // Temporary forwarder... + return MmAllocateMemoryWithType(MemorySize, LoaderOsloaderHeap); +} + +PVOID MmAllocateMemoryAtAddress(ULONG MemorySize, PVOID DesiredAddress, TYPE_OF_MEMORY MemoryType) { ULONG PagesNeeded; ULONG StartPageNumber; @@ -166,7 +172,7 @@ return NULL; }
- MmAllocatePagesInLookupTable(PageLookupTableAddress, StartPageNumber, PagesNeeded); + MmAllocatePagesInLookupTable(PageLookupTableAddress, StartPageNumber, PagesNeeded, MemoryType);
FreePagesInLookupTable -= PagesNeeded; MemPointer = (PVOID)(StartPageNumber * MM_PAGE_SIZE); @@ -182,7 +188,7 @@ return MemPointer; }
-PVOID MmAllocateHighestMemoryBelowAddress(ULONG MemorySize, PVOID DesiredAddress) +PVOID MmAllocateHighestMemoryBelowAddress(ULONG MemorySize, PVOID DesiredAddress, TYPE_OF_MEMORY MemoryType) { ULONG PagesNeeded; ULONG FirstFreePageFromEnd; @@ -221,7 +227,7 @@ return NULL; }
- MmAllocatePagesInLookupTable(PageLookupTableAddress, FirstFreePageFromEnd, PagesNeeded); + MmAllocatePagesInLookupTable(PageLookupTableAddress, FirstFreePageFromEnd, PagesNeeded, MemoryType);
FreePagesInLookupTable -= PagesNeeded; MemPointer = (PVOID)(FirstFreePageFromEnd * MM_PAGE_SIZE); @@ -301,6 +307,18 @@ //VerifyHeap(); #endif // DBG } + +PVOID MmHeapAlloc(ULONG MemorySize) +{ + // Stub for WinLdr + return NULL; +} + +VOID MmHeapFree(PVOID MemoryPointer) +{ + // Stub for WinLdr +} +
#ifdef DBG VOID VerifyHeap(VOID)
Copied: trunk/reactos/boot/freeldr/freeldr/windows/winldr.c (from r31751, branches/winldr/windows/winldr.c) URL: http://svn.reactos.org/svn/reactos/trunk/reactos/boot/freeldr/freeldr/window... ============================================================================== --- branches/winldr/windows/winldr.c (original) +++ trunk/reactos/boot/freeldr/freeldr/windows/winldr.c Sun Jan 13 15:53:49 2008 @@ -429,7 +429,11 @@ AllocateAndInitLPB(&LoaderBlock);
/* Detect hardware */ +#if WHEN_MERGE_COMPLETE MachHwDetect(&LoaderBlock->ConfigurationRoot); +#else + MachHwDetect(); +#endif
/* Load kernel */ strcpy(FileName, BootPath); @@ -491,7 +495,7 @@
/* "Stop all motors", change videomode */ DiskStopFloppyMotor(); - MachVideoPrepareForReactOS(); + MachVideoPrepareForReactOS(FALSE);
/* Debugging... */ //DumpMemoryAllocMap();