diff options
| author | Loic Guegan <manzerbredes@mailbox.org> | 2021-04-15 17:56:08 +0200 |
|---|---|---|
| committer | Loic Guegan <manzerbredes@mailbox.org> | 2021-04-15 17:56:08 +0200 |
| commit | 58b706d40f8ad0d71b667ca81d91b96ca537cb8e (patch) | |
| tree | cb68b9872ebc030fbe99fd9e1f4f1662ad82c287 /src/core/scheduler_asm.S | |
| parent | 28870fc37564dff19161306d865ccf329357a81f (diff) | |
Improve scheduler
Diffstat (limited to 'src/core/scheduler_asm.S')
| -rw-r--r-- | src/core/scheduler_asm.S | 46 |
1 files changed, 46 insertions, 0 deletions
diff --git a/src/core/scheduler_asm.S b/src/core/scheduler_asm.S new file mode 100644 index 0000000..92e3f2e --- /dev/null +++ b/src/core/scheduler_asm.S @@ -0,0 +1,46 @@ +.globl task_switch + +// This function takes a pointer +// 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 + + // Don't forget to clear the interrupt + movb $0x20, %al + outb %al, $0x20 + + // Setup process page directory + mov 8(%esi), %eax + mov %eax, %cr3 + + // Setup registers + pop %gs + pop %fs + pop %es + pop %ds + pop %edi + pop %esi + pop %ebp + pop %edx + pop %ecx + pop %ebx + 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 |
