fix: simple multitasking work !!!!

add a stack at every task, and execute task while multitasking switching
This commit is contained in:
2025-01-24 12:33:29 +01:00
parent dc84d5856b
commit 95fec015f2
5 changed files with 40 additions and 24 deletions

View File

@ -14,41 +14,40 @@ switch_to_task:
// save the current stack pointer to the old stack
mov [eax+0], esp
// save the old eip pointer
mov ebx, [[[esp_backup]]]
mov [eax+16], ebx
// stack pointer + the 4 regs pushed
// and + 1 to get the argument (next task)
mov esi, [esp+(4+1)*4]
mov [current_task], esi
mov edi, [current_task]
mov eax, [current_task]
mov esp, [edi+0] // esp
mov eax, [edi+4] // esp0
// mov ebx, [edi+8] // cr3
// mov edi, [edi+12] // page_directory
// mov [page_directory], edi
// mov [TSS+4], eax // tss.esp0
// mov ecx, cr3
mov esp, [eax+0] // get esp
// if cr3 hasn't change, do nothing
// cmp ecx, ebx
// je .END
// mov cr3, ebx
.END:
mov eax, [edi+16]
mov ebx, [esp_backup]
mov [ebx], eax
pop esi
pop edi
pop ebp
pop ebx
mov ecx, 0
cmp [eax+16], ecx
je .END
sti
push [eax+16] // store func_ptr
mov [eax+16], ecx // clear eip in current_task
push 0
call pic_send_eoi
pop edx // remove pic_send_eoi argument
pop edx // get func_ptr
call edx
// TODO HANDLE TASK RETURN
.END:
ret