From ace65b453151845bc361f21f3e5b651c35f9f126 Mon Sep 17 00:00:00 2001 From: Jon Santmyer Date: Wed, 22 May 2024 13:00:41 -0400 Subject: massive refactor for mp and organization --- arch/x86_64/tasking.c | 86 --------------------------------------------------- 1 file changed, 86 deletions(-) delete mode 100644 arch/x86_64/tasking.c (limited to 'arch/x86_64/tasking.c') diff --git a/arch/x86_64/tasking.c b/arch/x86_64/tasking.c deleted file mode 100644 index 9b29330..0000000 --- a/arch/x86_64/tasking.c +++ /dev/null @@ -1,86 +0,0 @@ -#include "usr/tasking.h" -#include "mem/memory.h" -#include "io/log.h" -#include "lib/hashtable.h" -#include "lib/string.h" -#include "paging.h" -#include "cpu.h" -#include "tss.h" - -struct TaskBody { - struct Task base; - struct Registers state; -}; - -struct Task *task_current; -uintptr_t _kernel_task_bp = 0; - -//static struct SLinkedList s_tasks; -static struct HashTable s_tasks; - -static struct SlabCache s_task_cache; -static struct SlabCache s_kbp_cache; - -static tid_t s_task_id_next = 1; - -static size_t -s_task_hash_func(const void* tid, size_t _) -{ - return (tid_t)tid; -} - -void -tasking_setup(void) -{ - hashtable_new(&s_tasks, struct TaskBody*, tid_t); - s_tasks.hash_function = s_task_hash_func; - - mem_slabcache_new(&s_task_cache, "tasks", sizeof(struct TaskBody)); - mem_slabcache_new(&s_kbp_cache, "kernel stacks", 4096); - - struct TaskBody *ktask = mem_slab_alloc(&s_task_cache); - *ktask = (struct TaskBody){ - .base.id = s_task_id_next++, - .base.kbp = ((uintptr_t)mem_slab_alloc(&s_kbp_cache)) + 0xFF0, - .base.perm = (size_t)-1, - .base.pd = current_page_directory - }; - hashtable_insert(&s_tasks, 0, ktask); - - task_current = (struct Task*)ktask; - tss_set_rsp(0, task_current->kbp); - _kernel_task_bp = task_current->kbp; -} - -struct Task* -task_new(struct Task *parent) -{ - struct TaskBody *new = mem_slab_alloc(&s_task_cache); - memcpy(new, parent, sizeof(struct TaskBody)); - new->base.id = s_task_id_next++; - - uintptr_t ksp_base = (uintptr_t)mem_slab_alloc(&s_kbp_cache); - new->base.kbp = ksp_base + 0xFFF; - new->base.perm = parent->perm; - - hashtable_insert(&s_tasks, (void*)new->base.id, new); - return (struct Task*)new; -} - -struct Task* -task_get(tid_t id) -{ - struct Task **task = hashtable_get(&s_tasks, (void*)id, struct Task*); - if(task == NULL) return NULL; - return *task; -} - -void -task_free(struct Task *task) -{ - struct TaskBody *body = (struct TaskBody*)task; - task->pd->ref--; - task->kbp -= 0xFFF; - mem_slab_free(&s_kbp_cache, (void*)(task->kbp)); - klogf("Need impl for task_free\n"); -} -- cgit v1.2.1