[freeldr]

- Do not use GetSystemMemorySize(), which truncates size to 32 bit.
- Other minor changes.

svn path=/trunk/; revision=44974
This commit is contained in:
Dmitry Gorbachev 2010-01-06 11:44:54 +00:00
parent a71c3f0d12
commit 15269e4b77
6 changed files with 14 additions and 34 deletions

View file

@ -1 +0,0 @@
obj

View file

@ -89,7 +89,7 @@ BOOLEAN CacheInitializeDrive(ULONG DriveNumber)
CacheManagerDrive.BlockSize = MachDiskGetCacheableBlockCount(DriveNumber); CacheManagerDrive.BlockSize = MachDiskGetCacheableBlockCount(DriveNumber);
CacheBlockCount = 0; CacheBlockCount = 0;
CacheSizeLimit = GetSystemMemorySize() / 8; CacheSizeLimit = TotalPagesInLookupTable / 8 * MM_PAGE_SIZE;
CacheSizeCurrent = 0; CacheSizeCurrent = 0;
if (CacheSizeLimit < (64 * 1024)) if (CacheSizeLimit < (64 * 1024))
{ {

View file

@ -104,7 +104,6 @@ VOID MmUpdateLastFreePageHint(PVOID PageLookupTable, ULONG TotalPageCount); // S
BOOLEAN MmAreMemoryPagesAvailable(PVOID PageLookupTable, ULONG TotalPageCount, PVOID PageAddress, ULONG PageCount); // Returns TRUE if the specified pages of memory are available, otherwise FALSE BOOLEAN MmAreMemoryPagesAvailable(PVOID PageLookupTable, ULONG TotalPageCount, PVOID PageAddress, ULONG PageCount); // Returns TRUE if the specified pages of memory are available, otherwise FALSE
VOID MmSetMemoryType(PVOID MemoryAddress, ULONG MemorySize, TYPE_OF_MEMORY NewType); // Use with EXTREME caution! VOID MmSetMemoryType(PVOID MemoryAddress, ULONG MemorySize, TYPE_OF_MEMORY NewType); // Use with EXTREME caution!
ULONG GetSystemMemorySize(VOID); // Returns the amount of total memory in the system
PPAGE_LOOKUP_TABLE_ITEM MmGetMemoryMap(ULONG *NoEntries); // Returns a pointer to the memory mapping table and a number of entries in it PPAGE_LOOKUP_TABLE_ITEM MmGetMemoryMap(ULONG *NoEntries); // Returns a pointer to the memory mapping table and a number of entries in it

View file

@ -337,11 +337,6 @@ VOID DumpMemoryAllocMap(VOID)
} }
#endif // DBG #endif // DBG
ULONG GetSystemMemorySize(VOID)
{
return (TotalPagesInLookupTable * MM_PAGE_SIZE);
}
PPAGE_LOOKUP_TABLE_ITEM MmGetMemoryMap(ULONG *NoEntries) PPAGE_LOOKUP_TABLE_ITEM MmGetMemoryMap(ULONG *NoEntries)
{ {
PPAGE_LOOKUP_TABLE_ITEM RealPageLookupTable = (PPAGE_LOOKUP_TABLE_ITEM)PageLookupTableAddress; PPAGE_LOOKUP_TABLE_ITEM RealPageLookupTable = (PPAGE_LOOKUP_TABLE_ITEM)PageLookupTableAddress;

View file

@ -53,13 +53,13 @@ MempAllocatePageTables()
// Max number of entries = MaxPageNum >> 10 // Max number of entries = MaxPageNum >> 10
// FIXME: This is a number to describe ALL physical memory // FIXME: This is a number to describe ALL physical memory
// and windows doesn't expect ALL memory mapped... // and windows doesn't expect ALL memory mapped...
NumPageTables = (GetSystemMemorySize() >> MM_PAGE_SHIFT) >> 10; NumPageTables = TotalPagesInLookupTable >> 10;
DPRINTM(DPRINT_WINDOWS, "NumPageTables = %d\n", NumPageTables); DPRINTM(DPRINT_WINDOWS, "NumPageTables = %d\n", NumPageTables);
// Allocate memory block for all these things: // Allocate memory block for all these things:
// PDE, HAL mapping page table, physical mapping, kernel mapping // PDE, HAL mapping page table, physical mapping, kernel mapping
TotalSize = (1+1+NumPageTables*2)*MM_PAGE_SIZE; TotalSize = (1 + 1 + NumPageTables * 2) * MM_PAGE_SIZE;
// PDE+HAL+KernelPTEs == MemoryData // PDE+HAL+KernelPTEs == MemoryData
Buffer = MmAllocateMemoryWithType(TotalSize, LoaderMemoryData); Buffer = MmAllocateMemoryWithType(TotalSize, LoaderMemoryData);
@ -141,7 +141,7 @@ MempAllocatePTE(ULONG Entry, PHARDWARE_PTE *PhysicalPT, PHARDWARE_PTE *KernelPT)
BOOLEAN BOOLEAN
MempSetupPaging(IN ULONG StartPage, MempSetupPaging(IN ULONG StartPage,
IN ULONG NumberOfPages) IN ULONG NumberOfPages)
{ {
PHARDWARE_PTE PhysicalPT; PHARDWARE_PTE PhysicalPT;
PHARDWARE_PTE KernelPT; PHARDWARE_PTE KernelPT;
@ -163,7 +163,7 @@ MempSetupPaging(IN ULONG StartPage,
// //
// Now actually set up the page tables for identity mapping // Now actually set up the page tables for identity mapping
// //
for (Page=StartPage; Page < StartPage+NumberOfPages; Page++) for (Page = StartPage; Page < StartPage + NumberOfPages; Page++)
{ {
Entry = Page >> 10; Entry = Page >> 10;
@ -177,26 +177,13 @@ MempSetupPaging(IN ULONG StartPage,
KernelPT = (PHARDWARE_PTE)(PDE[Entry+(KSEG0_BASE >> 22)].PageFrameNumber << MM_PAGE_SHIFT); KernelPT = (PHARDWARE_PTE)(PDE[Entry+(KSEG0_BASE >> 22)].PageFrameNumber << MM_PAGE_SHIFT);
} }
if (Page == 0) PhysicalPT[Page & 0x3ff].PageFrameNumber = Page;
{ PhysicalPT[Page & 0x3ff].Valid = (Page != 0);
PhysicalPT[Page & 0x3ff].PageFrameNumber = Page; PhysicalPT[Page & 0x3ff].Write = (Page != 0);
PhysicalPT[Page & 0x3ff].Valid = 0;
PhysicalPT[Page & 0x3ff].Write = 0;
KernelPT[Page & 0x3ff].PageFrameNumber = Page; KernelPT[Page & 0x3ff].PageFrameNumber = Page;
KernelPT[Page & 0x3ff].Valid = 0; KernelPT[Page & 0x3ff].Valid = (Page != 0);
KernelPT[Page & 0x3ff].Write = 0; KernelPT[Page & 0x3ff].Write = (Page != 0);
}
else
{
PhysicalPT[Page & 0x3ff].PageFrameNumber = Page;
PhysicalPT[Page & 0x3ff].Valid = 1;
PhysicalPT[Page & 0x3ff].Write = 1;
KernelPT[Page & 0x3ff].PageFrameNumber = Page;
KernelPT[Page & 0x3ff].Valid = 1;
KernelPT[Page & 0x3ff].Write = 1;
}
} }
return TRUE; return TRUE;

View file

@ -184,7 +184,7 @@ MempAddMemoryBlock(IN OUT PLOADER_PARAMETER_BLOCK LoaderBlock,
MadCount++; MadCount++;
// //
// Map it (don't map low 1Mb because it was already contigiously // Map it (don't map low 1Mb because it was already contiguously
// mapped in WinLdrTurnOnPaging) // mapped in WinLdrTurnOnPaging)
// //
if (BasePage >= 0x100) if (BasePage >= 0x100)
@ -255,7 +255,7 @@ WinLdrTurnOnPaging(IN OUT PLOADER_PARAMETER_BLOCK LoaderBlock,
DPRINTM(DPRINT_WINDOWS, "Got memory map with %d entries\n", NoEntries); DPRINTM(DPRINT_WINDOWS, "Got memory map with %d entries\n", NoEntries);
// Always contigiously map low 1Mb of memory // Always contiguously map low 1Mb of memory
Status = MempSetupPaging(0, 0x100); Status = MempSetupPaging(0, 0x100);
if (!Status) if (!Status)
{ {
@ -270,7 +270,7 @@ WinLdrTurnOnPaging(IN OUT PLOADER_PARAMETER_BLOCK LoaderBlock,
PagesCount = 1; PagesCount = 1;
LastPageIndex = 0; LastPageIndex = 0;
LastPageType = MemoryMap[0].PageAllocated; LastPageType = MemoryMap[0].PageAllocated;
for(i=1;i<NoEntries;i++) for (i = 1; i < NoEntries; i++)
{ {
// Check if its memory map itself // Check if its memory map itself
if (i >= MemoryMapStartPage && if (i >= MemoryMapStartPage &&