Nun, ich hänge mal wieder beim Paging fest, das Problem ist folgendes:
Wenn eine neue Page gemappt werden soll, die dafür nötigen, höheren Level in der Pagingstruktur aber noch nicht vorhanden sind, werden diese zwar erstellt, müssen aber noch gemappt werden. Dies führt unweigerlich zu einer Rekursion und ich weiß einfach nicht, wie ich da raus komme.
void PagingManager::Map(uintptr_t virtual_address, uintptr_t physical_address)
{
this->UpdateIndexes(virtual_address & 0x000FFFFFFFFFF000LL);
PageMapLevel4Entry *pml4e = (PageMapLevel4Entry *)(page_map_level_4[pml4i].GetAddress());
if(pml4e->IsPresent() == false)
{
pml4e->Clear();
pml4e->SetAccess(PageAccess::UserWritable);
pml4e->SetAddress(memory.PAlloc());
pml4e->SetCachability(PageCachability::WriteThroughCachable);
pml4e->SetPresence(true);
}
PageDirectoryPointerEntry *pdpe = (PageDirectoryPointerEntry *)(pml4e[pdpi].GetAddress());
if(pdpe->IsPresent() == false)
{
pdpe->Clear();
pdpe->SetAccess(PageAccess::UserWritable);
pdpe->SetAddress(memory.PAlloc());
pdpe->SetCachability(PageCachability::WriteThroughCachable);
pdpe->SetPresence(true);
}
PageDirectoryEntry *pde = (PageDirectoryEntry *)(pdpe[pdi].GetAddress());
if(pde->IsPresent() == false)
{
pde->Clear();
pde->SetAccess(PageAccess::UserWritable);
pde->SetAddress(memory.PAlloc());
pde->SetCachability(PageCachability::WriteThroughCachable);
pde->SetPresence(true);
}
PageTableEntry *pte = (PageTableEntry *)(pde[pti].GetAddress());
pte->Clear();
pte->SetAccess(PageAccess::UserWritable);
pte->SetAddress(physical_address);
pte->SetCachability(PageCachability::WriteThroughCachable);
pte->SetPresence(true);
}