[feat] Simple Multitask

This commit is contained in:
2026-05-31 12:11:57 +08:00
Unverified
parent 45693c96b5
commit b8212e2127
5 changed files with 307 additions and 3 deletions
+30
View File
@@ -0,0 +1,30 @@
.intel_syntax noprefix
// void context_switch(UINT64* old_rsp, UINT64 new_rsp)
// rdi = &old_rsp (pointer to save current RSP)
// rsi = new_rsp (value of new stack pointer)
//
// Saves/restores callee-saved registers only.
// On first switch into a new task, ret lands on task_entry_trampoline.
.global context_switch
context_switch:
push rbx
push rbp
push r12
push r13
push r14
push r15
mov [rdi], rsp // save current RSP
mov rsp, rsi // switch to new stack
pop r15
pop r14
pop r13
pop r12
pop rbp
pop rbx
ret
.section .note.GNU-stack,"",@progbits