i'm so close
This commit is contained in:
+1
-1
@@ -180,7 +180,7 @@ void destroy_page_dir(uint32_t* page_dir_virt) {
|
||||
|
||||
// If the page table entry is present, free the physical page (frame) it points to
|
||||
if (pte & PAGE_PRESENT) {
|
||||
debug_log("freeing page %X\n", pte);
|
||||
//debug_log("freeing page %X\n", pte);
|
||||
free_page((void*)(pte & ~0xFFF));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -103,7 +103,14 @@ int sys_fork(TrapFrame *tf)
|
||||
sp -= sizeof(TrapFrame);
|
||||
child->tf = (TrapFrame*)sp;
|
||||
|
||||
*child->tf = *tf;
|
||||
memcpy(&child->tf->gs, &tf->gs, 12 * sizeof(uint32_t));
|
||||
uint32_t* parent_cpu_state_ptr = (uint32_t*)&tf->interrupt;
|
||||
child->tf->eip = parent_cpu_state_ptr[0];
|
||||
child->tf->cs = parent_cpu_state_ptr[1];
|
||||
child->tf->eflags = parent_cpu_state_ptr[2];
|
||||
child->tf->usermode_esp = parent_cpu_state_ptr[3];
|
||||
child->tf->usermode_ss = parent_cpu_state_ptr[4];
|
||||
|
||||
child->tf->eax = 0; // Child returns 0
|
||||
debug_log("Parent returns PID: %X, Child returns 0\n", child->pid);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user