fuckfuckfuckfuck
This commit is contained in:
+1
-2
@@ -38,8 +38,7 @@ typedef struct __attribute__((packed)) TrapFrame {
|
|||||||
uint32_t edi;
|
uint32_t edi;
|
||||||
uint32_t esi;
|
uint32_t esi;
|
||||||
uint32_t ebp;
|
uint32_t ebp;
|
||||||
uint32_t oesp;
|
uint32_t ebx; // Убрано oesp
|
||||||
uint32_t ebx;
|
|
||||||
uint32_t edx;
|
uint32_t edx;
|
||||||
uint32_t ecx;
|
uint32_t ecx;
|
||||||
uint32_t eax;
|
uint32_t eax;
|
||||||
|
|||||||
@@ -49,7 +49,6 @@ switchProcess:
|
|||||||
trapret:
|
trapret:
|
||||||
; Восстанавливаем общие регистры из trap frame
|
; Восстанавливаем общие регистры из trap frame
|
||||||
popal ; edi, esi, ebp, oesp, ebx, edx, ecx, eax
|
popal ; edi, esi, ebp, oesp, ebx, edx, ecx, eax
|
||||||
add esp, 4 ; Пропускаем oesp (не используется)
|
|
||||||
|
|
||||||
; Восстанавливаем сегментные регистры
|
; Восстанавливаем сегментные регистры
|
||||||
pop gs
|
pop gs
|
||||||
|
|||||||
+11
-8
@@ -48,19 +48,23 @@ Process* task_create(EntryPoint func, void** args, uint32_t arg_count, uint32_t
|
|||||||
// Настраиваем trap frame для ring 3
|
// Настраиваем trap frame для ring 3
|
||||||
sp -= sizeof(TrapFrame) / 4;
|
sp -= sizeof(TrapFrame) / 4;
|
||||||
p->tf = (TrapFrame*)sp;
|
p->tf = (TrapFrame*)sp;
|
||||||
p->tf->cs = (SEG_UCODE << 3) | DPL_USER;
|
p->tf->cs = (SEG_UCODE) | DPL_USER;
|
||||||
p->tf->ds = (SEG_UDATA << 3) | DPL_USER;
|
p->tf->ds = (SEG_UDATA) | DPL_USER;
|
||||||
p->tf->es = p->tf->ds;
|
p->tf->es = p->tf->ds;
|
||||||
p->tf->fs = p->tf->ds;
|
p->tf->fs = p->tf->ds;
|
||||||
p->tf->gs = p->tf->ds;
|
p->tf->gs = p->tf->ds;
|
||||||
p->tf->ss = p->tf->ds;
|
p->tf->ss = p->tf->ds;
|
||||||
p->tf->eflags = FL_IF;
|
p->tf->eflags = FL_IF;
|
||||||
p->tf->eip = (uint32_t)func;
|
p->tf->eip = (uint32_t)func;
|
||||||
p->tf->esp = 0x800000 + USTACKSIZE; // Предполагаем, что пользовательский стек настроен
|
p->tf->esp = 0x800000 + USTACKSIZE - 4; // Предполагаем, что пользовательский стек настроен
|
||||||
|
|
||||||
// Добавляем адрес возврата для trapret
|
// Добавляем адрес возврата для trapret
|
||||||
sp -= 1;
|
sp -= 1;
|
||||||
*sp = (uint32_t)trapret;
|
*sp = (uint32_t)trapret;
|
||||||
|
|
||||||
|
sp -= sizeof(Context) / 4;
|
||||||
|
p->context = (Context*)sp;
|
||||||
|
p->context->eip = (uint32_t)processStartup;
|
||||||
} else {
|
} else {
|
||||||
p->tf = NULL; // Для ring 0 TrapFrame не нужен!
|
p->tf = NULL; // Для ring 0 TrapFrame не нужен!
|
||||||
sp -= sizeof(Context) / 4; // Только контекст
|
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
|
sp -= 5; // Место для edi, esi, ebx, ebp, eip
|
||||||
p->context = (Context*)sp;
|
|
||||||
p->context->edi = 0;
|
p->context->edi = 0;
|
||||||
p->context->esi = 0;
|
p->context->esi = 0;
|
||||||
p->context->ebx = 0;
|
p->context->ebx = 0;
|
||||||
@@ -149,12 +152,12 @@ void jump_usermode2(void) ;
|
|||||||
void scheduler_init()
|
void scheduler_init()
|
||||||
{
|
{
|
||||||
task_create((EntryPoint)&idle, NULL, 0, 0);
|
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"};
|
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};
|
void* args2[] = {(void*)69, (void*)420};
|
||||||
task_create((EntryPoint)&task2, args2, 2, 0);
|
//task_create((EntryPoint)&task2, args2, 2, 0);
|
||||||
jump_usermode2();
|
jump_usermode2();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -221,7 +224,7 @@ void jump_usermode2(void) {
|
|||||||
(code_pte & 0x4) ? "user" : "supervisor");
|
(code_pte & 0x4) ? "user" : "supervisor");
|
||||||
|
|
||||||
task_create(user_code_virt, NULL, 0, 3);
|
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;
|
return;
|
||||||
// Switch to user mode with interrupts enabled
|
// Switch to user mode with interrupts enabled
|
||||||
|
|||||||
Reference in New Issue
Block a user