From 72c6e9763ca61bc9d7de5f7080ee1c8a1c7c1562 Mon Sep 17 00:00:00 2001 From: Miguel Date: Tue, 21 Aug 2018 19:42:33 +0200 Subject: cleaning up a bit --- kernel/task.c | 223 ---------------------------------------------------------- 1 file changed, 223 deletions(-) delete mode 100644 kernel/task.c (limited to 'kernel/task.c') diff --git a/kernel/task.c b/kernel/task.c deleted file mode 100644 index 395c196..0000000 --- a/kernel/task.c +++ /dev/null @@ -1,223 +0,0 @@ -// http://hosted.cjmovie.net/TutMultitask.htm -// -// -#define FOOLOS_MODULE_NAME "task" - -#include "kernel.h" -#include "lib/logger/log.h" // logger facilities -#include "mem.h" -#include "timer.h" -#include "asm/x86.h" - -#include "vmem.h" -#include "syscalls.h" -#include "fs/fs.h" -#include "fs/ext2.h" - -#define MAX_TASKS 10 - -static volatile int volatile current_task=-1; - -static volatile struct task_list_struct -{ - volatile int parent; - volatile bool active; - volatile uint32_t esp; // stack pointer of the task; - volatile pdirectory *vmem; // number of virtual memory table to switch to - volatile bool waiting; - volatile bool skipwait; - volatile uint32_t brk; - -}volatile task_list[MAX_TASKS]; - -volatile int add_task(uint32_t esp, uint32_t vmem) -{ - - for(int i=0;i [%d] (free blocks remaining: %d )", current_task, pid,mem_get_free_blocks_count()); - return pid; -} - -// init task (root of all other tasks / processes) // -volatile void task_init(pdirectory *dir) -{ - current_task=0; - - // this is our main task on slot 0 - task_list[0].parent=0; - task_list[0].active=true; - task_list[0].waiting=false; - task_list[0].vmem=dir; - task_list[0].esp = kballoc(4); // 0; // will be set by next task_switch_next() call. - - task_list[1].parent=0; - task_list[1].active=true; - task_list[1].waiting=false; - task_list[1].vmem=dir; - task_list[1].esp = kballoc(4); // fresh 16kb stack from here. - - log(FOOLOS_MODULE_NAME,FOOLOS_LOG_INFO,"fresh esp on: 0x%08X",1,task_list[1].esp); - log(FOOLOS_MODULE_NAME,FOOLOS_LOG_INFO,"fresh esp on: 0x%08X",0,task_list[0].esp); - - task_pusha(task_list[1].esp); // pusha but to alternative location - task_pusha(task_list[0].esp); // pusha but to alternative location - - /* - current_task=0; - unsigned esp, ebp, eax, ebx, ecx, edx; - - asm( - "movl %%esp, %0;" - "movl %%ebp, %1;" - "movl %%eax, %2;" - "movl %%ebx, %3;" - "movl %%ecx, %4;" - "movl %%edx, %5;" - :"=r"(esp), "=r"(ebp), "=r"(eax), "=r"(ebx), "=r"(ecx), "=r"(edx) - ); - - // TODO: prepare stack so popa get's what it wants! - int i=task_fork(esp); - */ - - // finally enable interrrupts so the scheduler is called (by timer) - x86_sti(); - - // loop until scheduler kicks in and reschedules us... - while(1); - -} - -volatile int task_get_current_pid() -{ - return current_task; -} - -volatile uint32_t task_get_brk() -{ - return task_list[current_task].brk; -} - -volatile void task_set_brk(uint32_t brk) -{ - task_list[current_task].brk=brk; -} -- cgit v1.2.3