summaryrefslogtreecommitdiff
path: root/kc/core/arch_thread.c
diff options
context:
space:
mode:
authorAda Christine <adachristine18@gmail.com>2026-05-24 11:37:59 +0000
committerAda Christine <adachristine18@gmail.com>2026-05-24 11:37:59 +0000
commitc55c201952cdeb9285e519869f0c0939c3a5be9c (patch)
treef795c1c203bc7068b3ad4aa49e2a7370e210708b /kc/core/arch_thread.c
parentd07bd08dd0446e8c41eccaccbb07e9112200e8ee (diff)
arch file to cpu
Diffstat (limited to 'kc/core/arch_thread.c')
-rw-r--r--kc/core/arch_thread.c81
1 files changed, 0 insertions, 81 deletions
diff --git a/kc/core/arch_thread.c b/kc/core/arch_thread.c
deleted file mode 100644
index c0d707a..0000000
--- a/kc/core/arch_thread.c
+++ /dev/null
@@ -1,81 +0,0 @@
-#include <stdint.h>
-#include <stddef.h>
-#include <stdnoreturn.h>
-
-#include <libc/stdio.h>
-
-#include "task.h"
-
-struct arch_register_context
-{
- uint64_t
- r15,
- r14,
- r13,
- r12,
- r11,
- r10,
- r9,
- r8,
- rsi,
- rdi,
- rdx,
- rcx,
- rbx,
- rax,
- rbp,
- rsp;
-};
-
-extern uint64_t *get_tss_rsp0(void);
-
-struct arch_thread_context
-{
- struct arch_register_context register_context;
- void *return_address;
-};
-
-extern void arch_swap_thread_stack(
- void * volatile *outgoing_stack,
- void *incoming_stack);
-
-extern void arch_begin_thread(
- void *(func)(void *),
- void *params);
-
-void arch_create_thread(
- struct kc_thread *thread,
- void *(*func)(void *),
- void *params)
-{
- uintptr_t stack_pointer = (uintptr_t)thread->kernel_stack_pointer;
- struct arch_thread_context *context = (struct arch_thread_context *)
- (stack_pointer -= sizeof(*context));
- thread->kernel_stack_pointer = (void *)stack_pointer;
-
- context->return_address = (void *)arch_begin_thread;
- context->register_context.rdi = (uint64_t)func;
- context->register_context.rsi = (uint64_t)params;
- context->register_context.rdx = (uint64_t)thread;
- context->register_context.rsp = (uint64_t)&context->return_address;
-}
-
-void arch_swap_thread(
- struct kc_thread *outgoing,
- struct kc_thread *incoming)
-{
- arch_swap_thread_stack(&outgoing->kernel_stack_pointer, incoming->kernel_stack_pointer);
-}
-
-void *arch_idle_loop(void *)
-{
- for (;;) __asm__ ("hlt");
- return nullptr;
-}
-
-noreturn void arch_terminate_thread(union kc_thread_result result, struct kc_thread *)
-{
- kct_terminate(result);
- for (;;) __asm__ ("hlt");
-}
-