#pragma alloc_text(INIT, MmInitGlobalKernelPageDirectory)
#endif
+#define ADDR_TO_PDE_OFFSET MiAddressToPdeOffset
+#define ADDR_TO_PAGE_TABLE(v) (((ULONG)(v)) / (1024 * PAGE_SIZE))
/* GLOBALS *****************************************************************/
#define PTE_TO_PFN(X) ((X) >> PAGE_SHIFT)
#define PFN_TO_PTE(X) ((X) << PAGE_SHIFT)
+#define PAGE_MASK(x) ((x)&(~0xfff))
+
const
ULONG
MmProtectToPteMask[32] =
return(Attributes);
}
-/* Taken from ARM3/pagfault.c */
-FORCEINLINE
-BOOLEAN
-MiSynchronizeSystemPde(PMMPDE PointerPde)
-{
- MMPDE SystemPde;
- ULONG Index;
-
- /* Get the Index from the PDE */
- Index = ((ULONG_PTR)PointerPde & (SYSTEM_PD_SIZE - 1)) / sizeof(MMPTE);
-
- /* Copy the PDE from the double-mapped system page directory */
- SystemPde = MmSystemPagePtes[Index];
- *PointerPde = SystemPde;
-
- /* Make sure we re-read the PDE and PTE */
- KeMemoryBarrierWithoutFence();
-
- /* Return, if we had success */
- return SystemPde.u.Hard.Valid != 0;
-}
-
NTSTATUS
NTAPI
-MiDispatchFault(IN BOOLEAN StoreInstruction,
+MiDispatchFault(IN ULONG FaultCode,
IN PVOID Address,
IN PMMPTE PointerPte,
IN PMMPTE PointerProtoPte,
ASSERT(PointerPde->u.Long == 0);
MI_WRITE_INVALID_PTE(PointerPde, DemandZeroPde);
- Status = MiDispatchFault(TRUE,
+ // Tiny HACK: Parameter 1 is the architecture specific FaultCode for an access violation (i.e. page is present)
+ Status = MiDispatchFault(0x1,
Pt,
PointerPde,
NULL,
/* There should not be anything valid here */
if (Pte != 0)
{
- DPRINT1("Bad PTE %lx\n", Pte);
+ DPRINT1("Bad PTE %lx at %p for %p + %lu\n", Pte, Pt, Address, i);
KeBugCheck(MEMORY_MANAGEMENT);
}