wip: TSS added to the gdt and start to implement scheduler

This commit is contained in:
2025-01-13 15:46:09 +01:00
parent 916e8b6f19
commit b9691b1948
9 changed files with 156 additions and 8 deletions

View File

@ -0,0 +1,37 @@
.intel_syntax noprefix
.section .text
.global switch_to_task
switch_to_task:
push ebx
push ebp
push edi
push esi
// save the current stack pointer to the old stack
mov [current_task], esp
// 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 esp, [current_task]
mov eax, [current_task+4]
mov ebx, [current_task+8]
mov [TSS + 4], eax
mov ecx, cr3
// if cr3 hasn't change, do nothing
cmp ecx, ebx
je .END
mov cr3, ebx
.END:
pop esi
pop edi
pop ebp
pop ebx
ret