From edc42358664e9d70227e274273321ab032394a7e Mon Sep 17 00:00:00 2001 From: Ada Christine Date: Wed, 20 May 2026 23:04:06 +0000 Subject: new thread code works fine --- kc/core/cpu/cpu_thread.S | 57 ++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 57 insertions(+) create mode 100644 kc/core/cpu/cpu_thread.S (limited to 'kc/core/cpu/cpu_thread.S') diff --git a/kc/core/cpu/cpu_thread.S b/kc/core/cpu/cpu_thread.S new file mode 100644 index 0000000..c4d04e1 --- /dev/null +++ b/kc/core/cpu/cpu_thread.S @@ -0,0 +1,57 @@ +.section .text + +.extern arch_terminate_thread + +.global arch_begin_thread +arch_begin_thread: + movq %rdi, %rax + movq %rsi, %rdi + pushq %rdx + pushq %rbp + movq %rsp, %rbp + andq $-16, %rsp + callq *%rax + movq %rax, %rdi + movq 8(%rbp), %rsi + callq arch_terminate_thread + +.global arch_swap_thread_stack +arch_swap_thread_stack: + pushq %rsp + pushq %rbp + pushq %rax + pushq %rbx + pushq %rcx + pushq %rdx + pushq %rdi + pushq %rsi + pushq %r8 + pushq %r9 + pushq %r10 + pushq %r11 + pushq %r12 + pushq %r13 + pushq %r14 + pushq %r15 + movq %rsp, (%rdi) + .Lenter_thread: + movq %rsi, %rsp + popq %r15 + popq %r14 + popq %r13 + popq %r12 + popq %r11 + popq %r10 + popq %r9 + popq %r8 + popq %rsi + popq %rdi + popq %rdx + popq %rcx + popq %rbx + popq %rax + popq %rbp + popq %rsp + retq + + -- cgit v1.3.1-1-g115d