boucane/src/core/scheduler_asm.S

35 lines
534 B
ArmAsm
Raw Normal View History

2021-05-01 11:37:52 +02:00
.globl switch
2021-05-02 14:46:18 +02:00
.extern kvar_stack_pma
2021-05-01 11:37:52 +02:00
switch:
2021-05-02 14:46:18 +02:00
# TODO: Check if we come from kernel mode (use kernel stack)
# TODO: restore all registers
mov 96(%rdi), %ax
2021-05-01 11:37:52 +02:00
mov %ax, %ds
mov %ax, %es
mov %ax, %fs
mov %ax, %gs
2021-05-02 14:46:18 +02:00
mov (%rdi), %rax
mov %rax, %cr3
push 96(%rdi)
push 64(%rdi)
2021-05-01 11:37:52 +02:00
pushf
pop %rax
2021-05-02 14:46:18 +02:00
or $0x200, %rax # Enable interrupt
mov $0xffffffffbfff, %rbx # NT flag
2021-05-01 11:37:52 +02:00
and %rbx, %rax
push %rax
2021-05-02 14:46:18 +02:00
push 40(%rdi)
push 48(%rdi)
# Perform task switching
2021-05-01 11:37:52 +02:00
iretq