Allocate and map the Kernel Shared Data page at startup
This commit is contained in:
@@ -29,6 +29,7 @@ namespace MM
|
|||||||
STATIC XTAPI PPHYSICAL_MEMORY_DESCRIPTOR GetPhysicalMemoryBlock(VOID);
|
STATIC XTAPI PPHYSICAL_MEMORY_DESCRIPTOR GetPhysicalMemoryBlock(VOID);
|
||||||
STATIC XTAPI VOID InitializeMemoryLayout(VOID);
|
STATIC XTAPI VOID InitializeMemoryLayout(VOID);
|
||||||
STATIC XTAPI VOID InitializeMemoryManager(VOID);
|
STATIC XTAPI VOID InitializeMemoryManager(VOID);
|
||||||
|
STATIC XTAPI XTSTATUS MapKernelSharedData(VOID);
|
||||||
STATIC XTAPI BOOLEAN VerifyMemoryTypeFree(IN LOADER_MEMORY_TYPE MemoryType);
|
STATIC XTAPI BOOLEAN VerifyMemoryTypeFree(IN LOADER_MEMORY_TYPE MemoryType);
|
||||||
STATIC XTAPI BOOLEAN VerifyMemoryTypeInvisible(IN LOADER_MEMORY_TYPE MemoryType);
|
STATIC XTAPI BOOLEAN VerifyMemoryTypeInvisible(IN LOADER_MEMORY_TYPE MemoryType);
|
||||||
|
|
||||||
|
|||||||
@@ -50,11 +50,14 @@ KE::KernelInit::InitializeMachine(VOID)
|
|||||||
/* Initialize frame buffer */
|
/* Initialize frame buffer */
|
||||||
HL::FrameBuffer::InitializeFrameBuffer();
|
HL::FrameBuffer::InitializeFrameBuffer();
|
||||||
|
|
||||||
/* Initialize processor */
|
|
||||||
HL::Cpu::InitializeProcessor();
|
|
||||||
|
|
||||||
/* Initialize page map support */
|
/* Initialize page map support */
|
||||||
MM::Paging::InitializePageMapSupport();
|
MM::Paging::InitializePageMapSupport();
|
||||||
|
|
||||||
|
/* Map Kernel Shared Data (KSD) */
|
||||||
|
MM::Manager::MapKernelSharedData();
|
||||||
|
|
||||||
|
/* Initialize processor */
|
||||||
|
HL::Cpu::InitializeProcessor();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -50,11 +50,14 @@ KE::KernelInit::InitializeMachine(VOID)
|
|||||||
/* Initialize frame buffer */
|
/* Initialize frame buffer */
|
||||||
HL::FrameBuffer::InitializeFrameBuffer();
|
HL::FrameBuffer::InitializeFrameBuffer();
|
||||||
|
|
||||||
/* Initialize processor */
|
|
||||||
HL::Cpu::InitializeProcessor();
|
|
||||||
|
|
||||||
/* Initialize page map support */
|
/* Initialize page map support */
|
||||||
MM::Paging::InitializePageMapSupport();
|
MM::Paging::InitializePageMapSupport();
|
||||||
|
|
||||||
|
/* Map Kernel Shared Data (KSD) */
|
||||||
|
MM::Manager::MapKernelSharedData();
|
||||||
|
|
||||||
|
/* Initialize processor */
|
||||||
|
HL::Cpu::InitializeProcessor();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -282,6 +282,45 @@ MM::Manager::InitializeMemoryManager(VOID)
|
|||||||
AR::CpuFunc::FlushTlb();
|
AR::CpuFunc::FlushTlb();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Allocates and maps the Kernel Shared Data page to its hardcoded virtual address.
|
||||||
|
*
|
||||||
|
* @return This routine returns status code.
|
||||||
|
*
|
||||||
|
* @since XT 1.0
|
||||||
|
*/
|
||||||
|
XTAPI
|
||||||
|
XTSTATUS
|
||||||
|
MM::Manager::MapKernelSharedData(VOID)
|
||||||
|
{
|
||||||
|
PHYSICAL_ADDRESS PhysAddr;
|
||||||
|
PMMPTE PtePointer;
|
||||||
|
XTSTATUS Status;
|
||||||
|
|
||||||
|
/* Allocate one physical page from the hardware pool for the shared data */
|
||||||
|
Status = MM::HardwarePool::AllocateHardwareMemory(1, FALSE, &PhysAddr);
|
||||||
|
if(Status != STATUS_SUCCESS)
|
||||||
|
{
|
||||||
|
/* Memory allocation failed, return error code */
|
||||||
|
return Status;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Retrieve the Page Table Entry (PTE) corresponding to the KSD virtual address */
|
||||||
|
PtePointer = MM::Paging::GetPteAddress((PVOID)MM_KERNEL_SHARED_DATA_ADDRESS);
|
||||||
|
|
||||||
|
/* Manually map the corresponding PTE */
|
||||||
|
MM::Paging::SetPte(PtePointer, (PFN_NUMBER)(PhysAddr.QuadPart >> MM_PAGE_SHIFT), MM_PTE_READWRITE);
|
||||||
|
|
||||||
|
/* Flush the Translation Lookaside Buffer (TLB) */
|
||||||
|
MM::Paging::FlushTlb();
|
||||||
|
|
||||||
|
/* Zero the page content */
|
||||||
|
RTL::Memory::ZeroMemory((PVOID)MM_KERNEL_SHARED_DATA_ADDRESS, MM_PAGE_SIZE);
|
||||||
|
|
||||||
|
/* Return success */
|
||||||
|
return STATUS_SUCCESS;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Checks whether the specified memory type should be considered as free.
|
* Checks whether the specified memory type should be considered as free.
|
||||||
*
|
*
|
||||||
|
|||||||
Reference in New Issue
Block a user