[Zion] Add task switching for SSE registers and enable them in userspace.

This commit is contained in:
Drew Galbraith 2023-11-21 15:50:31 -08:00
parent 2a984a93ec
commit 96063126cb
7 changed files with 43 additions and 5 deletions

View file

@ -1,5 +1,10 @@
.global context_switch
context_switch:
# %rdi -> Prev Task RSP address
# %rsi -> New Task RSP Address
# %rdx -> Prev Task FXSAVE Address
# %rcx -> New Task FXRSTOR Address
push %rax
push %rcx
push %rdx
@ -18,9 +23,25 @@ context_switch:
mov %cr3, %rax
push %rax
// For the sleep thread rdx will
// be a nullptr.
test %rdx, %rdx
jz switch
fxsave (%rdx)
switch:
mov %rsp, (%rdi) # Save rsp to the prev task.
mov (%rsi), %rsp # Load the next task's rsp.
// For the sleep thread rcx will
// be a nullptr.
test %rcx, %rcx
jz restore
fxrstor (%rcx)
restore:
pop %rax
mov %rax, %cr3
pop %r15