[feat] 100Hz task switch

This commit is contained in:
2026-05-31 18:35:25 +08:00
Unverified
parent 4ff227bc75
commit daccb0a763
16 changed files with 1172 additions and 36 deletions
+13 -1
View File
@@ -5,7 +5,19 @@
// 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.
// The caller-saved registers are already saved on the task's stack
// by the ISR stub (for preemptive switching) or are not in use
// (for the initial switch).
//
// For preemptive switching:
// - Timer IRQ fires, ISR stub pushes rax-r11 + trap_frame
// - C code runs (isr_dispatch timer handler scheduler)
// - context_switch saves/restores callee-saved regs + switches RSP
// - On return, C code unwinds, isr_common pops rax-r11 + iretq
//
// For new tasks:
// - task_create sets up a fake trap_frame on the stack
// - context_switch pops callee-saved regs, returns into task_entry_trampoline
.global context_switch
context_switch:
push rbx