mirror of
https://github.com/Fennix-Project/Kernel.git
synced 2025-05-28 15:34:33 +00:00
Map address 0x0 to an empty page
This commit is contained in:
parent
8288de53a9
commit
4188a465d2
@ -36,8 +36,14 @@ __no_instrument_function void tracepagetable(PageTable4 *pt)
|
||||
#endif
|
||||
|
||||
__no_instrument_function void MapFromZero(PageTable4 *PT, BootInfo *Info)
|
||||
{
|
||||
static int once = 0;
|
||||
if (!once++)
|
||||
{
|
||||
Virtual va = Virtual(PT);
|
||||
void *NullAddress = KernelAllocator.RequestPage();
|
||||
memset(NullAddress, 0, PAGE_SIZE); // TODO: If the CPU instruction pointer hits this page, there should be function to handle it. (memcpy assembly code?)
|
||||
va.Map((void *)0, (void *)NullAddress, PTFlag::RW | PTFlag::US);
|
||||
uint64_t VirtualOffsetNormalVMA = NORMAL_VMA_OFFSET;
|
||||
uint64_t MemSize = Info->Memory.Size;
|
||||
for (uint64_t t = 0; t < MemSize; t += PAGE_SIZE)
|
||||
@ -47,6 +53,12 @@ __no_instrument_function void MapFromZero(PageTable4 *PT, BootInfo *Info)
|
||||
VirtualOffsetNormalVMA += PAGE_SIZE;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
error("MapFromZero() called more than once!");
|
||||
CPU::Stop();
|
||||
}
|
||||
}
|
||||
|
||||
__no_instrument_function void MapFramebuffer(PageTable4 *PT, BootInfo *Info)
|
||||
{
|
||||
@ -180,8 +192,7 @@ __no_instrument_function void InitializeMemoryManagement(BootInfo *Info)
|
||||
debug("Mapping from 0x0 to %#llx", Info->Memory.Size);
|
||||
MapFromZero(KernelPageTable, Info);
|
||||
debug("Mapping from 0x0 %#llx for Userspace Page Table", Info->Memory.Size);
|
||||
UserspaceKernelOnlyPageTable[0] = KernelPageTable[0]; // TODO: This is a hack to speed up the boot process
|
||||
// MapFromZero(UserspaceKernelOnlyPageTable, Info);
|
||||
UserspaceKernelOnlyPageTable[0] = KernelPageTable[0];
|
||||
|
||||
/* Mapping Framebuffer address */
|
||||
debug("Mapping Framebuffer");
|
||||
|
Loading…
x
Reference in New Issue
Block a user