Author: tkreuzer
Date: Sun Apr  1 15:23:08 2012
New Revision: 56304
URL: 
http://svn.reactos.org/svn/reactos?rev=56304&view=rev
Log:
[NTOSKRNL]
Use MiFillSystemPageDirectory on amd64, too
Modified:
    trunk/reactos/ntoskrnl/include/internal/amd64/mm.h
    trunk/reactos/ntoskrnl/mm/ARM3/section.c
    trunk/reactos/ntoskrnl/mm/amd64/init.c
Modified: trunk/reactos/ntoskrnl/include/internal/amd64/mm.h
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/ntoskrnl/include/internal/…
==============================================================================
--- trunk/reactos/ntoskrnl/include/internal/amd64/mm.h [iso-8859-1] (original)
+++ trunk/reactos/ntoskrnl/include/internal/amd64/mm.h [iso-8859-1] Sun Apr  1 15:23:08
2012
@@ -256,6 +256,10 @@
 #define MiPdeToPte(PDE) ((PMMPTE)MiPteToAddress(PDE))
 #define MiPteToPde(PTE) ((PMMPDE)MiAddressToPte(PTE))
+#define MiPdeToPpe(Pde) ((PMMPPE)MiAddressToPte(Pde))
+
+/* Sign extend 48 bits */
+#define MiProtoPteToPte(x) (PMMPTE)(((LONG64)(x)->u.Long) >> 16)
 FORCEINLINE
 VOID
@@ -263,17 +267,13 @@
                       IN PMMPTE PointerPte)
 {
     /* Store the Address */
-    NewPte->u.Long = (ULONG64)PointerPte;
+    NewPte->u.Long = (ULONG64)PointerPte << 16;
     /* Mark this as a prototype PTE */
     NewPte->u.Proto.Prototype = 1;
-    NewPte->u.Proto.Valid  = 1;
-    NewPte->u.Proto.ReadOnly = 0;
-    NewPte->u.Proto.Protection = 0;
-}
-
-/* Sign extend 48 bits */
-#define MiProtoPteToPte(x) (PMMPTE)((LONG64)(x)->u.Proto.ProtoAddress)
+
+    ASSERT(MiProtoPteToPte(NewPte) == PointerPte);
+}
 VOID
 FORCEINLINE
Modified: trunk/reactos/ntoskrnl/mm/ARM3/section.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/ntoskrnl/mm/ARM3/section.c…
==============================================================================
--- trunk/reactos/ntoskrnl/mm/ARM3/section.c [iso-8859-1] (original)
+++ trunk/reactos/ntoskrnl/mm/ARM3/section.c [iso-8859-1] Sun Apr  1 15:23:08 2012
@@ -410,7 +410,6 @@
     return STATUS_SUCCESS;
 }
-#if (_MI_PAGING_LEVELS == 2)
 VOID
 NTAPI
 MiFillSystemPageDirectory(IN PVOID Base,
@@ -418,7 +417,7 @@
 {
     PMMPDE PointerPde, LastPde, SystemMapPde;
     MMPDE TempPde;
-    PFN_NUMBER PageFrameIndex;
+    PFN_NUMBER PageFrameIndex, ParentPage;
     KIRQL OldIrql;
     PAGED_CODE();
@@ -426,8 +425,13 @@
     PointerPde = MiAddressToPde(Base);
     LastPde = MiAddressToPde((PVOID)((ULONG_PTR)Base + NumberOfBytes - 1));
+#if (_MI_PAGING_LEVELS == 2)
     /* Find the system double-mapped PDE that describes this mapping */
     SystemMapPde = &MmSystemPagePtes[((ULONG_PTR)PointerPde & (SYSTEM_PD_SIZE -
1)) / sizeof(MMPTE)];
+#else
+    /* We don't have a double mapping */
+    SystemMapPde = PointerPde;
+#endif
     /* Use the PDE template and loop the PDEs */
     TempPde = ValidKernelPde;
@@ -446,10 +450,15 @@
             ASSERT(PageFrameIndex);
             TempPde.u.Hard.PageFrameNumber = PageFrameIndex;
+#if (_MI_PAGING_LEVELS == 2)
+            ParentPage = MmSystemPageDirectory[(PointerPde - MiAddressToPde(NULL)) /
PDE_COUNT];
+#else
+            ParentPage = MiPdeToPpe(PointerPde)->u.Hard.PageFrameNumber;
+#endif
             /* Initialize its PFN entry, with the parent system page directory page table
*/
             MiInitializePfnForOtherProcess(PageFrameIndex,
                                            (PMMPTE)PointerPde,
-                                           MmSystemPageDirectory[(PointerPde -
MiAddressToPde(NULL)) / PDE_COUNT]);
+                                           ParentPage);
             /* Make the system PDE entry valid */
             MI_WRITE_VALID_PDE(SystemMapPde, TempPde);
@@ -468,7 +477,6 @@
         PointerPde++;
     }
 }
-#endif
 NTSTATUS
 NTAPI
@@ -734,10 +742,8 @@
     Base = MiInsertInSystemSpace(Session, Buckets, ControlArea);
     ASSERT(Base);
-#if (_MI_PAGING_LEVELS == 2)
     /* Create the PDEs needed for this mapping, and double-map them if needed */
     MiFillSystemPageDirectory(Base, Buckets * MI_SYSTEM_VIEW_BUCKET_SIZE);
-#endif
     /* Create the actual prototype PTEs for this mapping */
     Status = MiAddMappedPtes(MiAddressToPte(Base),
Modified: trunk/reactos/ntoskrnl/mm/amd64/init.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/ntoskrnl/mm/amd64/init.c?r…
==============================================================================
--- trunk/reactos/ntoskrnl/mm/amd64/init.c [iso-8859-1] (original)
+++ trunk/reactos/ntoskrnl/mm/amd64/init.c [iso-8859-1] Sun Apr  1 15:23:08 2012
@@ -241,6 +241,9 @@
     /* Setup 1 PPE for hyper space */
     MiMapPPEs((PVOID)HYPER_SPACE, (PVOID)HYPER_SPACE_END);
+
+    /* Setup PPEs for system space view */
+    MiMapPPEs(MiSystemViewStart, (PCHAR)MiSystemViewStart + MmSystemViewSize);
     /* Setup the mapping PDEs */
     MiMapPDEs((PVOID)MI_MAPPING_RANGE_START, (PVOID)MI_MAPPING_RANGE_END);