aboutsummaryrefslogtreecommitdiff
path: root/src/core/scheduler_asm.S
diff options
context:
space:
mode:
Diffstat (limited to 'src/core/scheduler_asm.S')
-rw-r--r--src/core/scheduler_asm.S27
1 files changed, 17 insertions, 10 deletions
diff --git a/src/core/scheduler_asm.S b/src/core/scheduler_asm.S
index fc8bc50..8f417c4 100644
--- a/src/core/scheduler_asm.S
+++ b/src/core/scheduler_asm.S
@@ -2,26 +2,33 @@
-
+.extern kvar_stack_pma
switch:
-
- mov $0x23, %ax
+ # TODO: Check if we come from kernel mode (use kernel stack)
+ # TODO: restore all registers
+
+ mov 96(%rdi), %ax
mov %ax, %ds
mov %ax, %es
mov %ax, %fs
mov %ax, %gs
- push $0x23 #
- push $0x80
+ mov (%rdi), %rax
+ mov %rax, %cr3
+
+ push 96(%rdi)
+ push 64(%rdi)
pushf
pop %rax
- #orl $0x200, %%eax
- mov $0xffffbfff, %rbx
+ or $0x200, %rax # Enable interrupt
+ mov $0xffffffffbfff, %rbx # NT flag
and %rbx, %rax
push %rax
- push $0x1B
- push $0x0
-
+ push 40(%rdi)
+ push 48(%rdi)
+
+
+ # Perform task switching
iretq