system calls

This commit is contained in:
Matheus
2022-08-15 21:52:57 -03:00
parent 21e6a0ad1a
commit 432e85b837
17 changed files with 187 additions and 26 deletions
+13 -9
View File
@@ -1,15 +1,21 @@
global arch_switchcontext
arch_switchcontext:
mov rsp,rdi
add rsp, 8 ; cr2
pop rax
mov gs,rax
pop rax
mov fs,rax
pop rax
add rsp, 24 ; cr2 gs fs
mov rbx,es
pop rax
cmp rax,rbx
jne .segswap
add rsp,8 ; ds
jmp .genreg
.segswap:
swapgs
mov es,rax
pop rax
pop rax
mov ds,rax
.genreg:
pop rax
pop rbx
pop rcx
@@ -27,6 +33,4 @@ arch_switchcontext:
pop rbp
add rsp,8 ; remove error code
swapgs
iretq