wip: TSS added to the gdt and start to implement scheduler
This commit is contained in:
37
src/multitasking/switch_to_task.s
Normal file
37
src/multitasking/switch_to_task.s
Normal 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
|
||||
Reference in New Issue
Block a user