bringelle/src/core/scheduler_asm.S
2021-04-16 14:39:24 +02:00

47 lines
985 B
ArmAsm

.globl task_switch
// This function takes a pointer
// to a PROC structure and jump
// to this process
task_switch:
pop %esi
push 8(%esi) # eax (cf PROC struct)
push 12(%esi) # ebx
push 16(%esi) # ecx
push 20(%esi) # edx
push 40(%esi) # ebp
push 48(%esi) # edi
push 52(%esi) # ds
push 56(%esi) # es
push 60(%esi) # fs
push 64(%esi) # gs
// Don't forget to clear the interrupt
movb $0x20, %al
outb %al, $0x20
// Setup process page directory
mov 4(%esi), %eax
mov %eax, %cr3
// Setup registers
pop %gs
pop %fs
pop %es
pop %ds
pop %edi
pop %ebp
pop %edx
pop %ecx
pop %ebx
pop %eax
// Perform the task switch
push 32(%esi) # ss
push 36(%esi) # esp
push 68(%esi) # eflags
push 24(%esi) # cs
push 28(%esi) # eip
mov 52(%esi), %ds # Choose the right data segment
mov 44(%esi), %esi # Now restore task esi
iret # Launch task