fuckfuckfuckfuck

This commit is contained in:
2025-05-16 16:44:13 +03:00
parent 5d012b410d
commit e2b596dcbd
3 changed files with 12 additions and 11 deletions
-1
View File
@@ -49,7 +49,6 @@ switchProcess:
trapret:
; Восстанавливаем общие регистры из trap frame
popal ; edi, esi, ebp, oesp, ebx, edx, ecx, eax
add esp, 4 ; Пропускаем oesp (не используется)
; Восстанавливаем сегментные регистры
pop gs
+11 -8
View File
@@ -48,19 +48,23 @@ Process* task_create(EntryPoint func, void** args, uint32_t arg_count, uint32_t
// Настраиваем trap frame для ring 3
sp -= sizeof(TrapFrame) / 4;
p->tf = (TrapFrame*)sp;
p->tf->cs = (SEG_UCODE << 3) | DPL_USER;
p->tf->ds = (SEG_UDATA << 3) | DPL_USER;
p->tf->cs = (SEG_UCODE) | DPL_USER;
p->tf->ds = (SEG_UDATA) | DPL_USER;
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->eflags = FL_IF;
p->tf->eip = (uint32_t)func;
p->tf->esp = 0x800000 + USTACKSIZE; // Предполагаем, что пользовательский стек настроен
p->tf->esp = 0x800000 + USTACKSIZE - 4; // Предполагаем, что пользовательский стек настроен
// Добавляем адрес возврата для trapret
sp -= 1;
*sp = (uint32_t)trapret;
sp -= sizeof(Context) / 4;
p->context = (Context*)sp;
p->context->eip = (uint32_t)processStartup;
} else {
p->tf = NULL; // Для ring 0 TrapFrame не нужен!
sp -= sizeof(Context) / 4; // Только контекст
@@ -69,7 +73,6 @@ Process* task_create(EntryPoint func, void** args, uint32_t arg_count, uint32_t
}
// Настраиваем начальный контекст
sp -= 5; // Место для edi, esi, ebx, ebp, eip
p->context = (Context*)sp;
p->context->edi = 0;
p->context->esi = 0;
p->context->ebx = 0;
@@ -149,12 +152,12 @@ void jump_usermode2(void) ;
void scheduler_init()
{
task_create((EntryPoint)&idle, NULL, 0, 0);
task_create((EntryPoint)&idle, NULL, 0, 0);
//task_create((EntryPoint)&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);
//task_create((EntryPoint)&task2, args2, 2, 0);
jump_usermode2();
}
@@ -221,7 +224,7 @@ void jump_usermode2(void) {
(code_pte & 0x4) ? "user" : "supervisor");
task_create(user_code_virt, NULL, 0, 3);
//task_create(second_user_code_virt, NULL, 0, 3);
task_create(second_user_code_virt, NULL, 0, 3);
return;
// Switch to user mode with interrupts enabled