Kernel: fix i386 MMU
This commit is contained in:
parent
7fcbb869e1
commit
4d8bdec16d
|
@ -70,10 +70,12 @@ MMU::MMU()
|
|||
void MMU::allocate_page(uintptr_t address, uint8_t flags)
|
||||
{
|
||||
#if MMU_DEBUG_PRINT
|
||||
dprintln("AllocatePage(0x{8H})", address & PAGE_MASK);
|
||||
dprintln("AllocatePage(0x{8H})", address);
|
||||
#endif
|
||||
ASSERT(flags & Flags::Present);
|
||||
|
||||
address &= PAGE_MASK;
|
||||
|
||||
uint32_t pdpte = (address & 0xC0000000) >> 30;
|
||||
uint32_t pde = (address & 0x3FE00000) >> 21;
|
||||
uint32_t pte = (address & 0x001FF000) >> 12;
|
||||
|
@ -87,9 +89,9 @@ void MMU::allocate_page(uintptr_t address, uint8_t flags)
|
|||
page_directory[pde] |= flags;
|
||||
|
||||
uint64_t* page_table = (uint64_t*)(page_directory[pde] & PAGE_MASK);
|
||||
page_table[pte] = (address & PAGE_MASK) | Flags::ReadWrite | Flags::Present;
|
||||
page_table[pte] = address | flags;
|
||||
|
||||
asm volatile("invlpg (%0)" :: "r"(address & PAGE_MASK) : "memory");
|
||||
asm volatile("invlpg (%0)" :: "r"(address) : "memory");
|
||||
}
|
||||
|
||||
void MMU::allocate_range(uintptr_t address, ptrdiff_t size, uint8_t flags)
|
||||
|
|
Loading…
Reference in New Issue