diff --git a/src/mm/paging.c b/src/mm/paging.c index 73ccfad..40d7ebf 100644 --- a/src/mm/paging.c +++ b/src/mm/paging.c @@ -141,6 +141,11 @@ uint32_t create_page_dir() new_pd[i] = current_pd[i]; } + int vga_pde_index = 0; // Virtual address 0x000B8000 is covered by PDE[0] + if (current_pd[vga_pde_index] & PAGE_PRESENT) { + new_pd[vga_pde_index] = current_pd[vga_pde_index]; + } + new_pd[1023] = (uint32_t)ppp | 0x03; // Present + Read/Write return (uint32_t)new_pd; diff --git a/src/tasking/switch.asm b/src/tasking/switch.asm index 9fd51cd..ac5f0f8 100644 --- a/src/tasking/switch.asm +++ b/src/tasking/switch.asm @@ -33,6 +33,7 @@ switchProcess: mov [current], edx ; current = next_process_ptr mov eax, [edx + 40] + sub eax, 0xC0000000 mov cr3, eax pop edi diff --git a/src/tasking/task.c b/src/tasking/task.c index 75912ed..0d1e842 100644 --- a/src/tasking/task.c +++ b/src/tasking/task.c @@ -24,15 +24,18 @@ extern uint32_t task_count; Process* task_create(uint32_t func, void** args, uint32_t arg_count, uint32_t ring) { - Process* p = (Process*)alloc_page(); + void *p_physical = alloc_page(); + Process* p = (Process*)((uint32_t)p_physical+0xC0000000); + map_page(p_physical, (void*)p, PAGE_PRESENT | PAGE_RW); memset(p, 0, sizeof(Process)); p->pid = ++pid_counter; p->state = Ready; p->ring = ring; // Выделяем стек ядра - p->kstack = (char*)alloc_page(); - map_page(p->kstack, p->kstack, PAGE_PRESENT | PAGE_RW); + void *kstack_physical = alloc_page(); + p->kstack = (char*)((uint32_t)kstack_physical+0xC0000000); + map_page(kstack_physical, p->kstack, PAGE_PRESENT | PAGE_RW); printf("kstack: %X!!!!!!!!!!!!\n", p->kstack); uint8_t* sp = (uint8_t*)(p->kstack + KSTACKSIZE); @@ -71,7 +74,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 = ring == 0 ? kpage_dir : (uint32_t*)create_page_dir(); + p->page_directory = (uint32_t*)create_page_dir(); p->next = 0; @@ -144,7 +147,7 @@ void scheduler_init() task_create((uint32_t)task1, args1, 2, 0); void* args2[] = {(void*)69, (void*)420}; task_create((uint32_t)task2, args2, 2, 0); - jump_usermode2(); + //jump_usermode2(); } #include "../include/string.h"