tasking: continue working on page directory switching
This commit is contained in:
@@ -123,6 +123,29 @@ void set_page_dir(uint32_t new_page_dir) {
|
||||
asm volatile("mov %0, %%cr3" : : "r" (new_page_dir));
|
||||
}
|
||||
|
||||
uint32_t phys_to_virt(uint32_t phys)
|
||||
{
|
||||
return phys+0xC0000000;
|
||||
}
|
||||
|
||||
uint32_t create_page_dir()
|
||||
{
|
||||
void* ppp = alloc_page();
|
||||
memset(ppp, 0, 0x1000);
|
||||
|
||||
uint32_t* current_pd = (uint32_t*)0xFFFFF000; // Current PD (self-mapped)
|
||||
uint32_t* new_pd = (uint32_t*)phys_to_virt((uint32_t)ppp);
|
||||
|
||||
for(int i = 768; i < 1023; i++)
|
||||
{
|
||||
new_pd[i] = current_pd[i];
|
||||
}
|
||||
|
||||
new_pd[1023] = (uint32_t)ppp | 0x03; // Present + Read/Write
|
||||
|
||||
return (uint32_t)new_pd;
|
||||
}
|
||||
|
||||
void enablePaging() {
|
||||
asm volatile (
|
||||
"mov %%cr0, %%eax\n"
|
||||
|
||||
Reference in New Issue
Block a user