mirror of
https://github.com/ApfelTeeSaft/reactos.git
synced 2026-08-28 12:23:28 +00:00
[MM]
- implement MmInitGlobalKernelPageDirectory, MmInitializeHandBuiltProcess - fix MmUpdatePageDir svn path=/branches/ros-amd64-bringup/; revision=44025
This commit is contained in:
@@ -17,7 +17,8 @@ MmGetPageDirectory(VOID)
|
||||
#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
|
||||
|
||||
@@ -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 @@ NTAPI
|
||||
MmUpdatePageDir(PEPROCESS Process, PVOID Address, ULONG Size)
|
||||
{
|
||||
ULONG StartIndex, EndIndex, Index;
|
||||
PULONG64 Pde;
|
||||
PMMPTE Pte;
|
||||
|
||||
/* Sanity check */
|
||||
if (Address < MmSystemRangeStart)
|
||||
@@ -446,27 +448,32 @@ MmUpdatePageDir(PEPROCESS Process, PVOID Address, ULONG Size)
|
||||
}
|
||||
|
||||
/* Get pointer to the page directory to update */
|
||||
if (Process != NULL && Process != PsGetCurrentProcess())
|
||||
if (Process && Process != PsGetCurrentProcess())
|
||||
{
|
||||
// Pde = MmCreateHyperspaceMapping(PTE_TO_PFN(Process->Pcb.DirectoryTableBase[0]));
|
||||
// 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 @@ INIT_FUNCTION
|
||||
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 @@ NTAPI
|
||||
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
|
||||
|
||||
Reference in New Issue
Block a user