From 8af18644a3184f691a86218c0639ee6875856bad Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thomas=20Lov=C3=A9n?= Date: Thu, 15 Feb 2018 12:09:37 +0100 Subject: [PATCH] Interface cleanup --- src/kernel/include/thread.h | 21 +-------------------- src/kernel/proc/thread.c | 21 +++++++++++++++++++++ 2 files changed, 22 insertions(+), 20 deletions(-) diff --git a/src/kernel/include/thread.h b/src/kernel/include/thread.h index bc36d42..d03a9e5 100644 --- a/src/kernel/include/thread.h +++ b/src/kernel/include/thread.h @@ -1,7 +1,7 @@ #pragma once #include #include -#include +#include struct thread { @@ -11,25 +11,6 @@ struct thread QUEUE_SPOT(READYQ); }; -#define TCB_OFFSET (PAGE_SIZE - sizeof(struct thread)) -#define SWTCH_STACK_SIZE (0x8*8) - -struct thread_stack -{ - uint8_t stack[TCB_OFFSET-SWTCH_STACK_SIZE]; - uint64_t RBP; - uint64_t RBX; - uint64_t R12; - uint64_t R13; - uint64_t R14; - uint64_t R15; - uint64_t RBP2; - uint64_t ret; - - struct thread tcb; -}__attribute__((packed)); - -#define thread_stack(th) (struct thread_stack *)((uintptr_t)th - TCB_OFFSET) struct thread *new_thread(void (*function)(void)); void yield(); diff --git a/src/kernel/proc/thread.c b/src/kernel/proc/thread.c index b969e05..21877f9 100644 --- a/src/kernel/proc/thread.c +++ b/src/kernel/proc/thread.c @@ -1,5 +1,26 @@ #include #include +#include + +#define TCB_OFFSET (PAGE_SIZE - sizeof(struct thread)) +#define SWTCH_STACK_SIZE (0x8*8) + +struct thread_stack +{ + uint8_t stack[TCB_OFFSET-SWTCH_STACK_SIZE]; + uint64_t RBP; + uint64_t RBX; + uint64_t R12; + uint64_t R13; + uint64_t R14; + uint64_t R15; + uint64_t RBP2; + uint64_t ret; + + struct thread tcb; +}__attribute__((packed)); + +#define thread_stack(th) (struct thread_stack *)((uintptr_t)th - TCB_OFFSET) struct thread boot_thread; struct thread *_current_thread = 0;