gonna ask tsoding for help, fuck this shit
This commit is contained in:
+9
-8
@@ -30,7 +30,7 @@ static void processStartup()
|
||||
// Возврат из этой функции приведёт к вызову trapret
|
||||
}
|
||||
|
||||
Process* task_create(EntryPoint 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 = alloc_page();//heap_alloc(sizeof(Process));
|
||||
p->pid = ++pid_counter;
|
||||
@@ -53,10 +53,10 @@ Process* task_create(EntryPoint func, void** args, uint32_t arg_count, uint32_t
|
||||
p->tf->es = p->tf->ds;
|
||||
p->tf->fs = p->tf->ds;
|
||||
p->tf->gs = p->tf->ds;
|
||||
p->tf->ss = p->tf->ds;
|
||||
p->tf->usermode_ss = p->tf->ds;
|
||||
p->tf->eflags = FL_IF;
|
||||
p->tf->eip = (uint32_t)func;
|
||||
p->tf->esp = 0x800000; // Предполагаем, что пользовательский стек настроен
|
||||
p->tf->usermode_esp = 0x800000; // Предполагаем, что пользовательский стек настроен
|
||||
|
||||
sp -= sizeof(Context);
|
||||
p->context = (Context*)sp;
|
||||
@@ -111,6 +111,7 @@ void schedule()
|
||||
if (next != current)
|
||||
{
|
||||
//loadPageDirectory(next->page_directory);
|
||||
printf("switching to %X\n", next->pid);
|
||||
switchProcess(next);
|
||||
}
|
||||
}
|
||||
@@ -137,11 +138,11 @@ void jump_usermode2(void) ;
|
||||
|
||||
void scheduler_init()
|
||||
{
|
||||
task_create((EntryPoint)&idle, NULL, 0, 0);
|
||||
//task_create((EntryPoint)&idle, NULL, 0, 0);
|
||||
task_create((uint32_t)idle, NULL, 0, 0);
|
||||
task_create((uint32_t)idle, NULL, 0, 0);
|
||||
|
||||
void* args1[] = {(void*)42, (void*)"ebalo"};
|
||||
task_create((EntryPoint)&task1, args1, 2, 0);
|
||||
//task_create((EntryPoint)task1, args1, 2, 0);
|
||||
void* args2[] = {(void*)69, (void*)420};
|
||||
//task_create((EntryPoint)&task2, args2, 2, 0);
|
||||
//jump_usermode2();
|
||||
@@ -209,8 +210,8 @@ void jump_usermode2(void) {
|
||||
(code_pte & 0x2) ? "writable" : "read-only",
|
||||
(code_pte & 0x4) ? "user" : "supervisor");
|
||||
|
||||
task_create(user_code_virt, NULL, 0, 3);
|
||||
task_create(second_user_code_virt, NULL, 0, 3);
|
||||
task_create((uint32_t)user_code_virt, NULL, 0, 3);
|
||||
//task_create(second_user_code_virt, NULL, 0, 3);
|
||||
|
||||
return;
|
||||
// Switch to user mode with interrupts enabled
|
||||
|
||||
Reference in New Issue
Block a user