#define FOOLOS_MODULE_NAME "usermode" #include "usermode.h" #include "syscalls.h" #include "kmalloc.h" #include "asm/syscall.h" #include "asm/usermode.h" #include "kernel.h" #include "lib/logger/log.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(int cpu_no){ // now fill each value // set values necessary sys_tss.ss0 = 0x10; //kernel data sys_tss.esp0 = kballoc(4); // now set the IO bitmap (not necessary, so set above limit) // sys_tss.iomap = ( unsigned short ) sizeof( tss_struct ); } 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 TODO: switch to usermode before! if(task_get_current_pid()==0) { //usermode(&initfunc); while(1) { c2++; } } // kernel worker thread on pid1 if(task_get_current_pid()==1) { while(1) { c1++; } } }