Author: tkreuzer
Date: Sun Nov 8 04:49:08 2009
New Revision: 44025
URL:
http://svn.reactos.org/svn/reactos?rev=44025&view=rev
Log:
[MM]
- implement MmInitGlobalKernelPageDirectory, MmInitializeHandBuiltProcess
- fix MmUpdatePageDir
Modified:
branches/ros-amd64-bringup/reactos/ntoskrnl/include/internal/amd64/mm.h
branches/ros-amd64-bringup/reactos/ntoskrnl/mm/amd64/page.c
Modified: branches/ros-amd64-bringup/reactos/ntoskrnl/include/internal/amd64/mm.h
URL:
http://svn.reactos.org/svn/reactos/branches/ros-amd64-bringup/reactos/ntosk…
==============================================================================
--- branches/ros-amd64-bringup/reactos/ntoskrnl/include/internal/amd64/mm.h [iso-8859-1]
(original)
+++ branches/ros-amd64-bringup/reactos/ntoskrnl/include/internal/amd64/mm.h [iso-8859-1]
Sun Nov 8 04:49:08 2009
@@ -17,7 +17,8 @@
#define PAGE_MASK(x) ((x)&(~0xfff))
#define PAE_PAGE_MASK(x) ((x)&(~0xfffLL))
-#define HYPER_SPACE 0xFFFFF70000000000ULL
+#define MI_HYPER_SPACE_START 0xFFFFF70000000000ULL
+#define MI_HYPER_SPACE_END 0xFFFFF77FFFFFFFFFULL
/* Base addresses of PTE and PDE */
//#define PAGETABLE_MAP PTE_BASE
Modified: branches/ros-amd64-bringup/reactos/ntoskrnl/mm/amd64/page.c
URL:
http://svn.reactos.org/svn/reactos/branches/ros-amd64-bringup/reactos/ntosk…
==============================================================================
--- branches/ros-amd64-bringup/reactos/ntoskrnl/mm/amd64/page.c [iso-8859-1] (original)
+++ branches/ros-amd64-bringup/reactos/ntoskrnl/mm/amd64/page.c [iso-8859-1] Sun Nov 8
04:49:08 2009
@@ -18,10 +18,12 @@
#pragma alloc_text(INIT, MiInitPageDirectoryMap)
#endif
+extern MMPTE HyperTemplatePte;
/* GLOBALS *****************************************************************/
ULONG64 MmGlobalKernelPageDirectory[512];
+ULONG Ke386GlobalPagesEnabled = 0;
/* PRIVATE FUNCTIONS *******************************************************/
@@ -437,7 +439,7 @@
MmUpdatePageDir(PEPROCESS Process, PVOID Address, ULONG Size)
{
ULONG StartIndex, EndIndex, Index;
- PULONG64 Pde;
+ PMMPTE Pte;
/* Sanity check */
if (Address < MmSystemRangeStart)
@@ -446,27 +448,32 @@
}
/* Get pointer to the page directory to update */
- if (Process != NULL && Process != PsGetCurrentProcess())
- {
-// Pde =
MmCreateHyperspaceMapping(PTE_TO_PFN(Process->Pcb.DirectoryTableBase[0]));
+ if (Process && Process != PsGetCurrentProcess())
+ {
+// Pte =
MmCreateHyperspaceMapping(PTE_TO_PFN(Process->Pcb.DirectoryTableBase[0]));
}
else
{
- Pde = (PULONG64)PXE_BASE;
+ Pte = (PMMPTE)PXE_BASE;
}
/* Update PML4 entries */
StartIndex = VAtoPXI(Address);
- EndIndex = VAtoPXI((ULONG64)Address + Size);
+ EndIndex = VAtoPXI((ULONG64)Address + Size - 1);
for (Index = StartIndex; Index <= EndIndex; Index++)
{
if (Index != VAtoPXI(PXE_BASE))
{
- (void)InterlockedCompareExchangePointer((PVOID*)&Pde[Index],
-
(PVOID)MmGlobalKernelPageDirectory[Index],
- 0);
+ InterlockedCompareExchange64(&Pte[Index].u.Long,
+ MmGlobalKernelPageDirectory[Index],
+ 0);
+ if (!MiIsHyperspaceAddress(Pte))
+ __invlpg((PVOID)((ULONG64)Index * PAGE_SIZE));
}
}
+
+ if (MiIsHyperspaceAddress(Pte))
+ MmDeleteHyperspaceMapping((PVOID)PAGE_ROUND_DOWN(Pte));
}
VOID
@@ -474,7 +481,35 @@
NTAPI
MmInitGlobalKernelPageDirectory(VOID)
{
- UNIMPLEMENTED;
+ PULONG64 CurrentPageDirectory = (PULONG64)PXE_BASE;
+ MMPTE Pte;
+ ULONG i;
+
+ /* Setup template pte */
+ HyperTemplatePte.u.Long = 0;
+ HyperTemplatePte.u.Hard.Valid = 1;
+ HyperTemplatePte.u.Hard.Write = 1;
+ HyperTemplatePte.u.Hard.Dirty = 1;
+ HyperTemplatePte.u.Hard.Accessed = 1;
+ if (Ke386GlobalPagesEnabled)
+ HyperTemplatePte.u.Hard.Global = 1;
+
+ for (i = VAtoPXI(MmSystemRangeStart); i < 512; i++)
+ {
+ if ((i < VAtoPXI(PTE_BASE) || i > VAtoPXI(PTE_TOP)) &&
+ (i < VAtoPXI(MI_HYPER_SPACE_START) || i > VAtoPXI(MI_HYPER_SPACE_END))
&&
+ MmGlobalKernelPageDirectory[i] == 0 &&
+ CurrentPageDirectory[i] != 0)
+ {
+ Pte.u.Long = CurrentPageDirectory[i];
+ if (Ke386GlobalPagesEnabled)
+ {
+ Pte.u.Hard.Global = 1;
+ CurrentPageDirectory[i] = Pte.u.Hard.Global;
+ }
+ MmGlobalKernelPageDirectory[i] = Pte.u.Hard.Global;
+ }
+ }
}
NTSTATUS
@@ -482,8 +517,19 @@
MmInitializeHandBuiltProcess(IN PEPROCESS Process,
IN PULONG_PTR DirectoryTableBase)
{
- UNIMPLEMENTED;
- return STATUS_UNSUCCESSFUL;
+ /* Share the directory base with the idle process */
+ DirectoryTableBase[0] = PsGetCurrentProcess()->Pcb.DirectoryTableBase[0];
+ DirectoryTableBase[1] = PsGetCurrentProcess()->Pcb.DirectoryTableBase[1];
+
+ /* Initialize the Addresss Space */
+ KeInitializeGuardedMutex(&Process->AddressCreationLock);
+ Process->Vm.WorkingSetExpansionLinks.Flink = NULL;
+ ASSERT(Process->VadRoot.NumberGenericTableElements == 0);
+ Process->VadRoot.BalancedRoot.u1.Parent = &Process->VadRoot.BalancedRoot;
+
+ /* The process now has an address space */
+ Process->HasAddressSpace = TRUE;
+ return STATUS_SUCCESS;
}
BOOLEAN