[MULTITASKING] Context switching and scheduler

This commit is contained in:
2016-11-05 19:55:54 +01:00
parent 1f06c0bcf1
commit 5e8fbcbb78
9 changed files with 288 additions and 0 deletions

28
kernel/proc/swtch.S Normal file
View File

@@ -0,0 +1,28 @@
.intel_syntax noprefix
.global swtch
swtch:
# void swtch(uint64_t *old, uint64_t *new)
# Switches stacks preserving callee preserved registers according to System V ABI
push rbp
mov rbp, rsp
push r15
push r14
push r13
push r12
push rbx
push rbp
cmp rdi, 0x0
jz .switch_in
mov [rdi], rsp
.switch_in:
mov rsp, [rsi]
pop rbp
pop rbx
pop r12
pop r13
pop r14
pop r15
leaveq
ret