tasking: fix separate page directory creation for new ring0 tasks
This commit is contained in:
@@ -141,6 +141,11 @@ uint32_t create_page_dir()
|
|||||||
new_pd[i] = current_pd[i];
|
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
|
new_pd[1023] = (uint32_t)ppp | 0x03; // Present + Read/Write
|
||||||
|
|
||||||
return (uint32_t)new_pd;
|
return (uint32_t)new_pd;
|
||||||
|
|||||||
@@ -33,6 +33,7 @@ switchProcess:
|
|||||||
mov [current], edx ; current = next_process_ptr
|
mov [current], edx ; current = next_process_ptr
|
||||||
|
|
||||||
mov eax, [edx + 40]
|
mov eax, [edx + 40]
|
||||||
|
sub eax, 0xC0000000
|
||||||
mov cr3, eax
|
mov cr3, eax
|
||||||
|
|
||||||
pop edi
|
pop edi
|
||||||
|
|||||||
+8
-5
@@ -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* 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));
|
memset(p, 0, sizeof(Process));
|
||||||
p->pid = ++pid_counter;
|
p->pid = ++pid_counter;
|
||||||
p->state = Ready;
|
p->state = Ready;
|
||||||
p->ring = ring;
|
p->ring = ring;
|
||||||
|
|
||||||
// Выделяем стек ядра
|
// Выделяем стек ядра
|
||||||
p->kstack = (char*)alloc_page();
|
void *kstack_physical = alloc_page();
|
||||||
map_page(p->kstack, p->kstack, PAGE_PRESENT | PAGE_RW);
|
p->kstack = (char*)((uint32_t)kstack_physical+0xC0000000);
|
||||||
|
map_page(kstack_physical, p->kstack, PAGE_PRESENT | PAGE_RW);
|
||||||
printf("kstack: %X!!!!!!!!!!!!\n", p->kstack);
|
printf("kstack: %X!!!!!!!!!!!!\n", p->kstack);
|
||||||
uint8_t* sp = (uint8_t*)(p->kstack + KSTACKSIZE);
|
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->context->eip = (uint32_t)trapret;
|
||||||
p->kesp = (uint32_t)sp;
|
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;
|
p->next = 0;
|
||||||
|
|
||||||
@@ -144,7 +147,7 @@ void scheduler_init()
|
|||||||
task_create((uint32_t)task1, args1, 2, 0);
|
task_create((uint32_t)task1, args1, 2, 0);
|
||||||
void* args2[] = {(void*)69, (void*)420};
|
void* args2[] = {(void*)69, (void*)420};
|
||||||
task_create((uint32_t)task2, args2, 2, 0);
|
task_create((uint32_t)task2, args2, 2, 0);
|
||||||
jump_usermode2();
|
//jump_usermode2();
|
||||||
}
|
}
|
||||||
|
|
||||||
#include "../include/string.h"
|
#include "../include/string.h"
|
||||||
|
|||||||
Reference in New Issue
Block a user