From 8e3411139b27a3421e9ac75c13f14f99f6dd3137 Mon Sep 17 00:00:00 2001 From: Miguel Date: Sun, 2 Sep 2018 00:08:42 +0200 Subject: syscalls --- kernel/usermode.c | 36 +++--------------------------------- 1 file changed, 3 insertions(+), 33 deletions(-) (limited to 'kernel/usermode.c') diff --git a/kernel/usermode.c b/kernel/usermode.c index 3befefd..7153e29 100644 --- a/kernel/usermode.c +++ b/kernel/usermode.c @@ -1,53 +1,26 @@ - #include "usermode.h" #include "syscalls.h" #include "kmalloc.h" -#include "asm/syscall.h" #include "asm/usermode.h" #include "kernel.h" #include -//https://wiki.osdev.org/Task_State_Segment -tss_struct sys_tss; //Define the TSS as a global structure - -static volatile uint32_t c1; -static volatile uint32_t c2; - -void install_tss(uint32_t esp0){ - - // now fill each value - // set values necessary - sys_tss.ss0 = 0x10; //kernel data - sys_tss.esp0 = esp0; - - // now set the IO bitmap (not necessary, so set above limit) - // sys_tss.iomap = ( unsigned short ) sizeof( tss_struct ); -} - -void initfunc() -{ - while(1) - { - c2++; - } -} - void userfunc() { // we need enable here again (since the pushed eflags have it disabled)! x86_sti(); - // if we are pid 0, replace ourselves with /bin/init and enter via usermode + // if we are pid 0, replace ourselves with /bin/init and enter usermode if(task_get_current_pid()==0) { uint32_t alloc; uint32_t entry_global=load_elf(BIN_INIT,&alloc); task_set_brk(alloc); - usermode(entry_global); + asm_usermode(entry_global); } // kernel worker thread: SLEEPER @@ -62,10 +35,7 @@ void userfunc() // kernel worker thread: SYSCALL CHECKER if(task_get_current_pid()==2) { - while(1) - { - task_syscall_worker(); - } + task_syscall_worker(); } } -- cgit v1.2.3