blob: 1673866a314570cbb87824207966ef1e93a7c065 [file] [log] [blame]
[bits 32]
[extern _do_switch_task]
[global switch_task]
switch_task:
pusha ; Save everything
push esp ; Arguments for _do_switch_task(eip, ebp, esp)
push ebp
push .after
call _do_switch_task
.after:
;; add esp, 12 ; Clear the arguments
popa ; Reset everything
xor eax, eax ; Return 0
pop ebx ; This is just to make debugging easy
jmp ebx
[global _switch_to_task]
;; _switch_to_task(uint page_directory, uint eip, uint ebp, uint esp)
_switch_to_task: ; (page_directory, eip, ebp, esp)
add esp, 4 ; We don't care about the return address
pop ecx ; Page directory
pop eax ; eip
pop ebp
pop ebx ; esp
mov esp, ebx ; Reset old stack
mov cr3, ecx ; Set page directory
sti
jmp eax ; Jump back to code
[extern _init_tasks]
[global init_tasks]
init_tasks:
lea eax, [esp + 4] ; Stack pointer before call
mov ebx, [esp] ; Return address
push ebx ; eip
push ebp ; ebp
push eax ; esp
call _init_tasks
add esp, 12
ret