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"
|
||||
|
||||
@@ -32,6 +32,9 @@ switchProcess:
|
||||
mov esp, [edx + 4] ; esp = next_process_ptr->kesp
|
||||
mov [current], edx ; current = next_process_ptr
|
||||
|
||||
mov eax, [edx + 40]
|
||||
mov cr3, eax
|
||||
|
||||
pop edi
|
||||
pop esi
|
||||
pop ebx
|
||||
|
||||
+1
-1
@@ -71,7 +71,7 @@ Process* task_create(uint32_t func, void** args, uint32_t arg_count, uint32_t ri
|
||||
p->context->eip = (uint32_t)trapret;
|
||||
p->kesp = (uint32_t)sp;
|
||||
|
||||
p->page_directory = kpage_dir;
|
||||
p->page_directory = ring == 0 ? kpage_dir : (uint32_t*)create_page_dir();
|
||||
|
||||
p->next = 0;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user