This commit is contained in:
Alex 2022-12-05 20:43:10 +02:00
parent a32ca16d2b
commit 7bff9f260e
Signed by untrusted user who does not match committer: enderice2
GPG Key ID: EACC3AD603BAB4DD
3 changed files with 33 additions and 33 deletions

View File

@ -198,9 +198,9 @@ __no_instrument_function void InitializeMemoryManagement(BootInfo *Info)
trace("Applying new page table from address %p", KernelPageTable); trace("Applying new page table from address %p", KernelPageTable);
#ifdef DEBUG #ifdef DEBUG
debug("Kernel:"); debug("Kernel:");
tracepagetable(KernelPageTable); // tracepagetable(KernelPageTable);
debug("Userspace:"); debug("Userspace:");
tracepagetable(UserspaceKernelOnlyPageTable); // tracepagetable(UserspaceKernelOnlyPageTable);
#endif #endif
#if defined(__amd64__) || defined(__i386__) #if defined(__amd64__) || defined(__i386__)
asmv("mov %0, %%cr3" ::"r"(KernelPageTable)); asmv("mov %0, %%cr3" ::"r"(KernelPageTable));

View File

@ -50,9 +50,9 @@ namespace Memory
} }
PageMapIndexer Index = PageMapIndexer((uint64_t)VirtualAddress); PageMapIndexer Index = PageMapIndexer((uint64_t)VirtualAddress);
PageMapLevel4 PML4 = this->Table->Entries[Index.PMLIndex]; PageMapLevel4 PML4 = this->Table->Entries[Index.PMLIndex];
PageDirectoryPointerTableEntryPtr *PDPTEPtr = nullptr; PageDirectoryPointerTableEntryPtr *PDPTEPtr = nullptr;
if (!PML4.Present) if (!PML4.Present)
{ {
PDPTEPtr = (PageDirectoryPointerTableEntryPtr *)KernelAllocator.RequestPage(); PDPTEPtr = (PageDirectoryPointerTableEntryPtr *)KernelAllocator.RequestPage();
@ -128,8 +128,8 @@ namespace Memory
if (!this->Check(VirtualAddress, (PTFlag)Flags)) // quick workaround just to see where it fails if (!this->Check(VirtualAddress, (PTFlag)Flags)) // quick workaround just to see where it fails
{ {
this->Check(VirtualAddress, (PTFlag)Flags); // this->Check(VirtualAddress, (PTFlag)Flags);
warn("Failed to map %#lx - %#lx with flags: " BYTE_TO_BINARY_PATTERN, VirtualAddress, PhysicalAddress, BYTE_TO_BINARY(Flags)); // warn("Failed to map %#lx - %#lx with flags: " BYTE_TO_BINARY_PATTERN, VirtualAddress, PhysicalAddress, BYTE_TO_BINARY(Flags));
} }
#endif #endif
} }

View File

@ -169,7 +169,7 @@ namespace Memory
bool Global : 1; // 8 bool Global : 1; // 8
uint8_t Available0 : 3; // 9-11 uint8_t Available0 : 3; // 9-11
uint64_t Address : 40; // 12-51 uint64_t Address : 40; // 12-51
uint32_t Available1 : 11; // 52-58 uint32_t Available1 : 7; // 52-58
bool ProtectionKey : 4; // 59-62 bool ProtectionKey : 4; // 59-62
bool ExecuteDisable : 1; // 63 bool ExecuteDisable : 1; // 63
}; };
@ -215,15 +215,15 @@ namespace Memory
{ {
struct struct
{ {
bool Present : 1; // 0 bool Present : 1; // 0
bool ReadWrite : 1; // 1 bool ReadWrite : 1; // 1
bool UserSupervisor : 1; // 2 bool UserSupervisor : 1; // 2
bool WriteThrough : 1; // 3 bool WriteThrough : 1; // 3
bool CacheDisable : 1; // 4 bool CacheDisable : 1; // 4
bool Accessed : 1; // 5 bool Accessed : 1; // 5
bool Available0 : 1; // 6 bool Available0 : 1; // 6
bool PageSize : 1; // 7 bool PageSize : 1; // 7
uint8_t Available1 : 4; // 8-11 uint8_t Available1 : 4; // 8-11
uint64_t Address : 40; // 12-51 uint64_t Address : 40; // 12-51
uint32_t Available2 : 11; // 52-62 uint32_t Available2 : 11; // 52-62
bool ExecuteDisable : 1; // 63 bool ExecuteDisable : 1; // 63
@ -270,15 +270,15 @@ namespace Memory
{ {
struct struct
{ {
bool Present : 1; // 0 bool Present : 1; // 0
bool ReadWrite : 1; // 1 bool ReadWrite : 1; // 1
bool UserSupervisor : 1; // 2 bool UserSupervisor : 1; // 2
bool WriteThrough : 1; // 3 bool WriteThrough : 1; // 3
bool CacheDisable : 1; // 4 bool CacheDisable : 1; // 4
bool Accessed : 1; // 5 bool Accessed : 1; // 5
bool Available0 : 1; // 6 bool Available0 : 1; // 6
bool PageSize : 1; // 7 bool PageSize : 1; // 7
uint8_t Available1 : 4; // 8-11 uint8_t Available1 : 4; // 8-11
uint64_t Address : 40; // 12-51 uint64_t Address : 40; // 12-51
uint32_t Available2 : 11; // 52-62 uint32_t Available2 : 11; // 52-62
bool ExecuteDisable : 1; // 63 bool ExecuteDisable : 1; // 63
@ -325,15 +325,15 @@ namespace Memory
{ {
struct struct
{ {
bool Present : 1; // 0 bool Present : 1; // 0
bool ReadWrite : 1; // 1 bool ReadWrite : 1; // 1
bool UserSupervisor : 1; // 2 bool UserSupervisor : 1; // 2
bool WriteThrough : 1; // 3 bool WriteThrough : 1; // 3
bool CacheDisable : 1; // 4 bool CacheDisable : 1; // 4
bool Accessed : 1; // 5 bool Accessed : 1; // 5
bool Available0 : 1; // 6 bool Available0 : 1; // 6
bool Reserved0 : 1; // 7 bool Reserved0 : 1; // 7
uint8_t Available1 : 4; // 8-11 uint8_t Available1 : 4; // 8-11
uint64_t Address : 40; // 12-51 uint64_t Address : 40; // 12-51
uint32_t Available2 : 11; // 52-62 uint32_t Available2 : 11; // 52-62
bool ExecuteDisable : 1; // 63 bool ExecuteDisable : 1; // 63