#define FOOLOS_MODULE_NAME "usermode" #include "usermode.h" #include "syscalls.h" #include "kmalloc.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 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 switch_to_user_mode() { asm_usermode(); } char *argv_init[]={"/bin/init",NULL}; char *env_init[]={"var1=dupa","var2=mundl",NULL}; // THIS WILL BE RUN IN RING 3! void userfunc() { syscall(SYSCALL_EXECVE,"/bin/init",argv_init,env_init); while(1); // we should never get here. }