Scheduler with working threads.

Currently only one process but it is a start.
This commit is contained in:
Drew Galbraith 2023-05-18 13:24:02 -07:00
parent 960cbf9519
commit cb41953354
10 changed files with 136 additions and 5 deletions

View file

@ -0,0 +1,41 @@
.global context_switch
context_switch:
push %rax
push %rcx
push %rdx
push %rbx
push %rbp
push %rsi
push %rdi
push %r8
push %r9
push %r10
push %r11
push %r12
push %r13
push %r14
push %r15
mov %cr3, %rax
push %rax
mov %rsp, (%rdi) # Save rsp to the prev task.
mov (%rsi), %rsp # Load the next task's rsp.
pop %rax
mov %rax, %cr3
pop %r15
pop %r14
pop %r13
pop %r12
pop %r11
pop %r10
pop %r9
pop %r8
pop %rdi
pop %rsi
pop %rbp
pop %rbx
pop %rdx
pop %rcx
pop %rax
retq