aboutsummaryrefslogtreecommitdiff
path: root/src/core/scheduler_asm.S
diff options
context:
space:
mode:
authorLoic Guegan <manzerbredes@mailbox.org>2021-04-16 14:39:24 +0200
committerLoic Guegan <manzerbredes@mailbox.org>2021-04-16 14:39:24 +0200
commit98d524bc8acb7b19afb693afea3ac77629d6f4bf (patch)
tree86a883c01bbf521ef40e914d16939b44c08e7f01 /src/core/scheduler_asm.S
parent58b706d40f8ad0d71b667ca81d91b96ca537cb8e (diff)
Multitasking works!
Diffstat (limited to 'src/core/scheduler_asm.S')
-rw-r--r--src/core/scheduler_asm.S39
1 files changed, 20 insertions, 19 deletions
diff --git a/src/core/scheduler_asm.S b/src/core/scheduler_asm.S
index 92e3f2e..1f916ec 100644
--- a/src/core/scheduler_asm.S
+++ b/src/core/scheduler_asm.S
@@ -4,24 +4,24 @@
// to a PROC structure and jump
// to this process
task_switch:
- push 12(%esi) # eax (cf PROC struct)
- push 16(%esi) # ebx
- push 20(%esi) # ecx
- push 24(%esi) # edx
- push 44(%esi) # ebp
- push 48(%esi) # esi
- push 52(%esi) # edi
- push 56(%esi) # ds
- push 60(%esi) # es
- push 64(%esi) # fs
- push 68(%esi) # gs
+ 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 8(%esi), %eax
+ mov 4(%esi), %eax
mov %eax, %cr3
// Setup registers
@@ -30,7 +30,6 @@ task_switch:
pop %es
pop %ds
pop %edi
- pop %esi
pop %ebp
pop %edx
pop %ecx
@@ -38,9 +37,11 @@ task_switch:
pop %eax
// Perform the task switch
- push 36(%esi) # ss
- push 40(%esi) # esp
- push 72(%esi) # eflags
- push 28(%esi) # cs
- push 32(%esi) # eip
- iret
+ 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