Author: rharabien
Date: Tue Jun 14 17:33:56 2011
New Revision: 52234
URL:
http://svn.reactos.org/svn/reactos?rev=52234&view=rev
Log:
[FREELDR]
- Return const pointers instead of converting them
- Fix MemoryMapSizeInPages calculation
- Don't use pages after 4GB limit on x86 (PAE is not supported yet)
- Should fix starting ROS on 4GB machines
See issue #6031 for more details.
Modified:
trunk/reactos/boot/freeldr/freeldr/arcemul/mm.c
trunk/reactos/boot/freeldr/freeldr/include/arcemul.h
trunk/reactos/boot/freeldr/freeldr/include/machine.h
trunk/reactos/boot/freeldr/freeldr/include/mm.h
trunk/reactos/boot/freeldr/freeldr/mm/meminit.c
trunk/reactos/boot/freeldr/freeldr/windows/wlmemory.c
Modified: trunk/reactos/boot/freeldr/freeldr/arcemul/mm.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/boot/freeldr/freeldr/arcem…
==============================================================================
--- trunk/reactos/boot/freeldr/freeldr/arcemul/mm.c [iso-8859-1] (original)
+++ trunk/reactos/boot/freeldr/freeldr/arcemul/mm.c [iso-8859-1] Tue Jun 14 17:33:56 2011
@@ -34,8 +34,8 @@
#endif
};
-MEMORY_DESCRIPTOR*
-ArcGetMemoryDescriptor(MEMORY_DESCRIPTOR* Current)
+const MEMORY_DESCRIPTOR*
+ArcGetMemoryDescriptor(const MEMORY_DESCRIPTOR* Current)
{
MEMORY_DESCRIPTOR_INT* CurrentDescriptor;
BIOS_MEMORY_MAP BiosMemoryMap[32];
@@ -114,7 +114,7 @@
//
// Return first fixed memory descriptor
//
- return (MEMORY_DESCRIPTOR*)&MemoryDescriptors[0].m;
+ return &MemoryDescriptors[0].m;
}
else
{
@@ -141,7 +141,7 @@
//
// Return first fixed memory descriptor
//
- return (MEMORY_DESCRIPTOR*)&MemoryDescriptors[0].m;
+ return &MemoryDescriptors[0].m;
}
else
{
@@ -161,7 +161,7 @@
//
// Return next fixed descriptor
//
- return (MEMORY_DESCRIPTOR*)&MemoryDescriptors[CurrentDescriptor->Index
+ 1].m;
+ return &MemoryDescriptors[CurrentDescriptor->Index + 1].m;
}
else
{
Modified: trunk/reactos/boot/freeldr/freeldr/include/arcemul.h
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/boot/freeldr/freeldr/inclu…
==============================================================================
--- trunk/reactos/boot/freeldr/freeldr/include/arcemul.h [iso-8859-1] (original)
+++ trunk/reactos/boot/freeldr/freeldr/include/arcemul.h [iso-8859-1] Tue Jun 14 17:33:56
2011
@@ -35,8 +35,8 @@
CONFIGURATION_COMPONENT* Component);
/* mm.c */
-MEMORY_DESCRIPTOR*
-ArcGetMemoryDescriptor(MEMORY_DESCRIPTOR* Current);
+const MEMORY_DESCRIPTOR*
+ArcGetMemoryDescriptor(const MEMORY_DESCRIPTOR* Current);
/* time.c */
TIMEINFO* ArcGetTime(VOID);
Modified: trunk/reactos/boot/freeldr/freeldr/include/machine.h
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/boot/freeldr/freeldr/inclu…
==============================================================================
--- trunk/reactos/boot/freeldr/freeldr/include/machine.h [iso-8859-1] (original)
+++ trunk/reactos/boot/freeldr/freeldr/include/machine.h [iso-8859-1] Tue Jun 14 17:33:56
2011
@@ -92,7 +92,6 @@
VOID MachVideoGetPaletteColor(UCHAR Color, UCHAR *Red, UCHAR *Green, UCHAR *Blue);
VOID MachVideoSync(VOID);
VOID MachBeep(VOID);
-MEMORY_DESCRIPTOR* ArcGetMemoryDescriptor(MEMORY_DESCRIPTOR* Current);
BOOLEAN MachDiskGetBootPath(char *BootPath, unsigned Size);
BOOLEAN MachDiskNormalizeSystemPath(char *SystemPath, unsigned Size);
BOOLEAN MachDiskReadLogicalSectors(ULONG DriveNumber, ULONGLONG SectorNumber, ULONG
SectorCount, PVOID Buffer);
Modified: trunk/reactos/boot/freeldr/freeldr/include/mm.h
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/boot/freeldr/freeldr/inclu…
==============================================================================
--- trunk/reactos/boot/freeldr/freeldr/include/mm.h [iso-8859-1] (original)
+++ trunk/reactos/boot/freeldr/freeldr/include/mm.h [iso-8859-1] Tue Jun 14 17:33:56 2011
@@ -42,6 +42,7 @@
#define MM_PAGE_SIZE 4096
#define MM_PAGE_MASK 0xFFF
#define MM_PAGE_SHIFT 12
+#define MM_MAX_PAGE 0xFFFFF
#define MM_SIZE_TO_PAGES(a) \
( ((a) >> MM_PAGE_SHIFT) + ((a) & MM_PAGE_MASK ? 1 : 0) )
@@ -53,6 +54,7 @@
#define MM_PAGE_SIZE 4096
#define MM_PAGE_MASK 0xFFF
#define MM_PAGE_SHIFT 12
+#define MM_MAX_PAGE 0xFFFFFFFFFFFFF
#define MM_SIZE_TO_PAGES(a) \
( ((a) >> MM_PAGE_SHIFT) + ((a) & MM_PAGE_MASK ? 1 : 0) )
Modified: trunk/reactos/boot/freeldr/freeldr/mm/meminit.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/boot/freeldr/freeldr/mm/me…
==============================================================================
--- trunk/reactos/boot/freeldr/freeldr/mm/meminit.c [iso-8859-1] (original)
+++ trunk/reactos/boot/freeldr/freeldr/mm/meminit.c [iso-8859-1] Tue Jun 14 17:33:56 2011
@@ -57,7 +57,7 @@
BOOLEAN MmInitializeMemoryManager(VOID)
{
#if DBG
- MEMORY_DESCRIPTOR* MemoryDescriptor = NULL;
+ const MEMORY_DESCRIPTOR* MemoryDescriptor = NULL;
#endif
DPRINTM(DPRINT_MEMORY, "Initializing Memory Manager.\n");
@@ -158,7 +158,7 @@
ULONG MmGetAddressablePageCountIncludingHoles(VOID)
{
- MEMORY_DESCRIPTOR* MemoryDescriptor = NULL;
+ const MEMORY_DESCRIPTOR* MemoryDescriptor = NULL;
ULONG PageCount;
//
@@ -197,7 +197,7 @@
PVOID MmFindLocationForPageLookupTable(ULONG TotalPageCount)
{
- MEMORY_DESCRIPTOR* MemoryDescriptor = NULL;
+ const MEMORY_DESCRIPTOR* MemoryDescriptor = NULL;
ULONG PageLookupTableSize;
ULONG PageLookupTablePages;
ULONG PageLookupTableStartPage = 0;
@@ -240,6 +240,17 @@
// Is it at a higher address than previous suitable address?
//
if (MemoryDescriptor->BasePage < PageLookupTableStartPage)
+ {
+ //
+ // No. Process next descriptor
+ //
+ continue;
+ }
+
+ //
+ // Can we use this address?
+ //
+ if (MemoryDescriptor->BasePage >= MM_MAX_PAGE)
{
//
// No. Process next descriptor
@@ -263,7 +274,7 @@
VOID MmInitPageLookupTable(PVOID PageLookupTable, ULONG TotalPageCount)
{
- MEMORY_DESCRIPTOR* MemoryDescriptor = NULL;
+ const MEMORY_DESCRIPTOR* MemoryDescriptor = NULL;
TYPE_OF_MEMORY MemoryMapPageAllocated;
ULONG PageLookupTableStartPage;
ULONG PageLookupTablePageCount;
Modified: trunk/reactos/boot/freeldr/freeldr/windows/wlmemory.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/boot/freeldr/freeldr/windo…
==============================================================================
--- trunk/reactos/boot/freeldr/freeldr/windows/wlmemory.c [iso-8859-1] (original)
+++ trunk/reactos/boot/freeldr/freeldr/windows/wlmemory.c [iso-8859-1] Tue Jun 14 17:33:56
2011
@@ -139,15 +139,27 @@
BOOLEAN Status;
//
- // Check for some weird stuff at the top
- //
- if (BasePage + PageCount > 0xF0000)
+ // Check for memory block after 4GB - we don't support it yet
+ // Note: Even last page before 4GB limit is not supported
+ //
+ if (BasePage >= MM_MAX_PAGE)
{
//
// Just skip this, without even adding to MAD list
//
return;
}
+
+ //
+ // Check if last page is after 4GB limit and shorten this block if needed
+ //
+ if (BasePage + PageCount > MM_MAX_PAGE)
+ {
+ //
+ // shorten this block
+ //
+ PageCount = MM_MAX_PAGE - BasePage;
+ }
//
// Set Base page, page count and type
@@ -255,7 +267,7 @@
// Calculate parameters of the memory map
MemoryMapStartPage = (ULONG_PTR)MemoryMap >> MM_PAGE_SHIFT;
- MemoryMapSizeInPages = NoEntries * sizeof(PAGE_LOOKUP_TABLE_ITEM);
+ MemoryMapSizeInPages = (NoEntries * sizeof(PAGE_LOOKUP_TABLE_ITEM) + MM_PAGE_SIZE
- 1) / MM_PAGE_SIZE;
DPRINTM(DPRINT_WINDOWS, "Got memory map with %d entries\n", NoEntries);