tasking: fix separate page directory creation for new ring0 tasks

This commit is contained in:
2025-06-01 00:15:06 +03:00
parent 9000d76441
commit f47a4a451d
3 changed files with 14 additions and 5 deletions
+5
View File
@@ -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;
+1
View File
@@ -33,6 +33,7 @@ switchProcess:
mov [current], edx ; current = next_process_ptr
mov eax, [edx + 40]
sub eax, 0xC0000000
mov cr3, eax
pop edi
+8 -5
View File
@@ -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"