Author: fireball
Date: Sun Feb 24 21:03:17 2008
New Revision: 32471
URL: http://svn.reactos.org/svn/reactos?rev=32471&view=rev
Log:
- Do not *silently* hardcode USER_SHARED_DATA to physical page 2! It's purely FreeLdr's decision to place PCR on the page 1. Instead, rely on an assumption that shared data always follows PCR's page. NT relies on the same assumption.
Modified:
trunk/reactos/ntoskrnl/mm/mminit.c
Modified: trunk/reactos/ntoskrnl/mm/mminit.c
URL: http://svn.reactos.org/svn/reactos/trunk/reactos/ntoskrnl/mm/mminit.c?rev=3…
==============================================================================
--- trunk/reactos/ntoskrnl/mm/mminit.c (original)
+++ trunk/reactos/ntoskrnl/mm/mminit.c Sun Feb 24 21:03:17 2008
@@ -182,7 +182,10 @@
TRUE,
0,
BoundaryAddressMultiple);
- MmSharedDataPagePhysicalAddress.QuadPart = 2 << PAGE_SHIFT;
+
+ /* Shared data are always located the next page after PCR */
+ MmSharedDataPagePhysicalAddress = MmGetPhysicalAddress((PVOID)PCR);
+ MmSharedDataPagePhysicalAddress.QuadPart += PAGE_SIZE;
/*
*
Author: fireball
Date: Sun Feb 24 20:19:00 2008
New Revision: 32470
URL: http://svn.reactos.org/svn/reactos?rev=32470&view=rev
Log:
- ntldr marks pages allocated for PCR and USER_SHARED_DATA as StartupPcrPage, not as MemoryData. In fact, it's the only way of finding where the PCR page is located physically.
Modified:
trunk/reactos/ntoskrnl/ke/freeldr.c
Modified: trunk/reactos/ntoskrnl/ke/freeldr.c
URL: http://svn.reactos.org/svn/reactos/trunk/reactos/ntoskrnl/ke/freeldr.c?rev=…
==============================================================================
--- trunk/reactos/ntoskrnl/ke/freeldr.c (original)
+++ trunk/reactos/ntoskrnl/ke/freeldr.c Sun Feb 24 20:19:00 2008
@@ -477,7 +477,7 @@
#endif
/* Build an entry for the KPCR and KUSER_SHARED_DATA */
- Status = KiRosAllocateArcDescriptor(1, 3, LoaderMemoryData);
+ Status = KiRosAllocateArcDescriptor(1, 3, LoaderStartupPcrPage);
if (Status != STATUS_SUCCESS) return Status;
/* Build an entry for the PDE and return the status */
Author: fireball
Date: Sun Feb 24 20:06:10 2008
New Revision: 32469
URL: http://svn.reactos.org/svn/reactos?rev=32469&view=rev
Log:
- Isolate the NLS-tables hack so that it's applied only when really needed (freeldr boot process always requires the hack, winldr boot process does not).
Modified:
trunk/reactos/ntoskrnl/ex/init.c
Modified: trunk/reactos/ntoskrnl/ex/init.c
URL: http://svn.reactos.org/svn/reactos/trunk/reactos/ntoskrnl/ex/init.c?rev=324…
==============================================================================
--- trunk/reactos/ntoskrnl/ex/init.c (original)
+++ trunk/reactos/ntoskrnl/ex/init.c Sun Feb 24 20:06:10 2008
@@ -239,27 +239,33 @@
if (!ExpNlsTableBase) KeBugCheck(PHASE0_INITIALIZATION_FAILED);
/* Copy the codepage data in its new location. */
- //RtlCopyMemory(ExpNlsTableBase,
- // LoaderBlock->NlsData->AnsiCodePageData,
- // ExpNlsTableSize);
-
- /*
- * In NT, the memory blocks are contiguous, but in ReactOS they aren't,
- * so unless someone fixes FreeLdr, we'll have to use this icky hack.
- */
- RtlCopyMemory(ExpNlsTableBase,
- LoaderBlock->NlsData->AnsiCodePageData,
- NlsTableSizes[0]);
-
- RtlCopyMemory((PVOID)((ULONG_PTR)ExpNlsTableBase + NlsTableSizes[0]),
- LoaderBlock->NlsData->OemCodePageData,
- NlsTableSizes[1]);
-
- RtlCopyMemory((PVOID)((ULONG_PTR)ExpNlsTableBase + NlsTableSizes[0] +
- NlsTableSizes[1]),
- LoaderBlock->NlsData->UnicodeCodePageData,
- NlsTableSizes[2]);
- /* End of Hack */
+ if (NlsTablesEncountered == 1)
+ {
+ /* Ntldr-way boot process */
+ RtlCopyMemory(ExpNlsTableBase,
+ LoaderBlock->NlsData->AnsiCodePageData,
+ ExpNlsTableSize);
+ }
+ else
+ {
+ /*
+ * In NT, the memory blocks are contiguous, but in ReactOS they aren't,
+ * so unless someone fixes FreeLdr, we'll have to use this icky hack.
+ */
+ RtlCopyMemory(ExpNlsTableBase,
+ LoaderBlock->NlsData->AnsiCodePageData,
+ NlsTableSizes[0]);
+
+ RtlCopyMemory((PVOID)((ULONG_PTR)ExpNlsTableBase + NlsTableSizes[0]),
+ LoaderBlock->NlsData->OemCodePageData,
+ NlsTableSizes[1]);
+
+ RtlCopyMemory((PVOID)((ULONG_PTR)ExpNlsTableBase + NlsTableSizes[0] +
+ NlsTableSizes[1]),
+ LoaderBlock->NlsData->UnicodeCodePageData,
+ NlsTableSizes[2]);
+ /* End of Hack */
+ }
/* Initialize and reset the NLS TAbles */
RtlInitNlsTables((PVOID)((ULONG_PTR)ExpNlsTableBase +
Author: fireball
Date: Sun Feb 24 13:43:56 2008
New Revision: 32463
URL: http://svn.reactos.org/svn/reactos?rev=32463&view=rev
Log:
- Save original value of the free descriptor we're using to alloc early pages from.
- Fix handling of PFN database pages inside PFN: largest free descriptor does not always end with the highest usable physical page (MmPageArraySize). This removes the need for a "good hack" introduced in revision 32405. As a result, the memory above the largest free descriptor (if it exists) is now correctly marked in the PFN database as free and added to the unzeroed list.
Modified:
trunk/reactos/ntoskrnl/include/internal/mm.h
trunk/reactos/ntoskrnl/mm/freelist.c
trunk/reactos/ntoskrnl/mm/mminit.c
Modified: trunk/reactos/ntoskrnl/include/internal/mm.h
URL: http://svn.reactos.org/svn/reactos/trunk/reactos/ntoskrnl/include/internal/…
==============================================================================
--- trunk/reactos/ntoskrnl/include/internal/mm.h (original)
+++ trunk/reactos/ntoskrnl/include/internal/mm.h Sun Feb 24 13:43:56 2008
@@ -19,6 +19,7 @@
extern ULONG MmPagedPoolSize;
extern PMEMORY_ALLOCATION_DESCRIPTOR MiFreeDescriptor;
+extern MEMORY_ALLOCATION_DESCRIPTOR MiFreeDescriptorOrg;
extern ULONG MmHighestPhysicalPage;
extern PVOID MmPfnDatabase;
Modified: trunk/reactos/ntoskrnl/mm/freelist.c
URL: http://svn.reactos.org/svn/reactos/trunk/reactos/ntoskrnl/mm/freelist.c?rev…
==============================================================================
--- trunk/reactos/ntoskrnl/mm/freelist.c (original)
+++ trunk/reactos/ntoskrnl/mm/freelist.c Sun Feb 24 13:43:56 2008
@@ -54,13 +54,13 @@
/* Make sure the PFN number is valid */
ASSERT(Pfn <= MmPageArraySize);
-
+
/* Get the entry */
Page = &MmPageArray[Pfn];
-
+
/* Make sure it's valid */
ASSERT_PFN(Page);
-
+
/* Return it */
return Page;
}
@@ -368,20 +368,14 @@
}
}
}
-
+
/* Finally handle the pages describing the PFN database themselves */
for (i = (MiFreeDescriptor->BasePage + MiFreeDescriptor->PageCount);
- i <= MmPageArraySize;
+ i < (MiFreeDescriptorOrg.BasePage + MiFreeDescriptorOrg.PageCount);
i++)
{
- /* If this page was marked as free it should be removed from
- the unzeroed free pages list */
- if (MmPageArray[i].Flags.Type == MM_PHYSICAL_PAGE_FREE)
- {
- RemoveEntryList(&MmPageArray[i].ListEntry);
- UnzeroedPageCount--;
- MmStats.NrFreePages--;
- }
+ /* Ensure this page was not added previously */
+ ASSERT(MmPageArray[i].Flags.Type == 0);
/* Mark it as used kernel memory */
MmPageArray[i] = UsedPage;
@@ -764,7 +758,7 @@
MiZeroPage(PfnOffset);
return PfnOffset;
}
-
+
DPRINT1("MmAllocPage(): Out of memory\n");
KeReleaseSpinLock(&PageListLock, oldIrql);
return 0;
Modified: trunk/reactos/ntoskrnl/mm/mminit.c
URL: http://svn.reactos.org/svn/reactos/trunk/reactos/ntoskrnl/mm/mminit.c?rev=3…
==============================================================================
--- trunk/reactos/ntoskrnl/mm/mminit.c (original)
+++ trunk/reactos/ntoskrnl/mm/mminit.c Sun Feb 24 13:43:56 2008
@@ -55,6 +55,7 @@
PVOID MmPfnDatabase;
ULONG_PTR MmPfnDatabaseEnd;
PMEMORY_ALLOCATION_DESCRIPTOR MiFreeDescriptor;
+MEMORY_ALLOCATION_DESCRIPTOR MiFreeDescriptorOrg;
extern KMUTANT MmSystemLoadLock;
BOOLEAN MiDbgEnableMdDump =
#ifdef _ARM_
@@ -246,6 +247,10 @@
}
}
}
+
+ /* Save original values of the free descriptor, since it'll be
+ altered by early allocations */
+ MiFreeDescriptorOrg = *MiFreeDescriptor;
}
VOID