00001 
00002 
00003 
00004 
00005 
00006 
00007 
00008 
00009 
00010 
00011 
00012 
00013 
00014 
00015 
00016 
00017 
00018 
00019 
00020 
00021 
00022 
00023 
00024 
00025 
00026 
00027 
00028 
00029 
00030 #include <ubixos/syscall.h>
00031 #include <ubixos/syscalls.h>
00032 #include <ubixos/sched.h>
00033 #include <ubixos/types.h>
00034 #include <ubixos/exec.h>
00035 #include <ubixos/elf.h>
00036 #include <ubixos/endtask.h>
00037 #include <ubixos/time.h>
00038 #include <sys/video.h>
00039 #include <sys/trap.h>
00040 #include <vfs/file.h>
00041 #include <ubixfs/ubixfs.h>
00042 #include <lib/string.h>
00043 #include <lib/kprintf.h>
00044 #include <lib/kmalloc.h>
00045 #include <ubixos/vitals.h>
00046 
00047 #include <mpi/mpi.h>
00048 #include <vmm/vmm.h>
00049 
00050 long   fuword(const void *base);
00051 
00052 void sdeTestThread();
00053 
00054 asm(
00055   ".globl _sysCallNew           \n"
00056   "_sysCallNew:                 \n"
00057   "  pusha                      \n"
00058   "  push %ss                   \n"
00059   "  push %ds                   \n"
00060   "  push %es                   \n"
00061   "  push %fs                   \n"
00062   "  push %gs                   \n"
00063   "  cmpl totalCalls,%eax       \n"
00064   "  jae  invalidSysCallNew     \n"
00065   "  mov  %esp,%ebx             \n"
00066   "  add  $12,%ebx              \n"
00067   "  push (%ebx)                \n"
00068   "  call *systemCalls(,%eax,4) \n"
00069   "  add  $4,%esp               \n"
00070   "  jmp  doneNew               \n"
00071   "invalidSysCallNew:           \n"
00072   "  call InvalidSystemCall     \n"
00073   "doneNew:                     \n"
00074   "  pop %gs                    \n"
00075   "  pop %fs                    \n" 
00076   "  pop %es                    \n"
00077   "  pop %ds                    \n"
00078   "  pop %ss                    \n"
00079   "  popa                       \n"
00080   "  iret                       \n"
00081   );
00082 
00083 void InvalidSystemCall()
00084 {
00085         kprintf("attempt was made to an invalid system call\n");
00086         return;
00087 }
00088 
00089 typedef struct _UbixUser UbixUser;
00090 struct _UbixUser
00091 {
00092         char *username;
00093         char *password;
00094         int uid;
00095         int gid;
00096         char *home;
00097         char *shell;
00098 };
00099 
00100 void sysAuth(UbixUser *uu)
00101 {
00102         kprintf("authenticating user %s\n", uu->username);
00103         if(uu->username == "root" && uu->password == "user")
00104         {
00105                 uu->uid = 0;
00106                 uu->gid = 0;
00107         }
00108         uu->uid = -1;
00109         uu->gid = -1;
00110         return;
00111 }
00112 
00113 void sysPasswd(char *passwd)
00114 {
00115         kprintf("changing user password for user %d\n", _current->uid);
00116         return;
00117 }
00118 
00119 void sysAddModule()
00120 {
00121         return;
00122 }
00123 
00124 void sysRmModule()
00125 {
00126         return;
00127 }
00128 
00129 void sysGetpid(int *pid)
00130 {
00131         if (pid)
00132                 *pid = _current->id;
00133                 return;
00134 }
00135 
00136 void sysGetUid(int *uid) {
00137   if (uid)
00138     *uid = _current->uid;
00139   return;
00140   }
00141 
00142 void sysGetGid(int *gid) {
00143   if (gid)
00144     *gid = _current->gid;
00145   return;
00146   }
00147 
00148 void sysSetUid(int uid,int *status) {
00149   if (_current->uid == 0x0) {
00150     _current->uid = uid;
00151     if (status)
00152       *status = 0x0;
00153     }
00154   else {
00155     if (status)
00156       *status = 1;
00157     }
00158   return;
00159   }
00160 
00161 void sysSetGid(int gid,int *status) {
00162   if (_current->gid == 0x0) {
00163     _current->gid = gid;
00164     if (status)
00165       *status = 0x0;
00166     }
00167   else {
00168     if (status)
00169       *status = 1;
00170     }
00171   return;
00172   }  
00173 
00174 void sysExit(int status)
00175 {
00176         endTask(_current->id);
00177 }
00178 
00179 void sysCheckPid(int pid,int *ptr)
00180 {
00181         kTask_t *tmpTask = schedFindTask(pid);
00182         if ((tmpTask != 0x0) && (ptr != 0x0))
00183                 *ptr = tmpTask->state;
00184         else
00185                 *ptr = 0x0;
00186         return;
00187 }
00188 
00189 
00190 
00191 
00192 
00193 
00194 
00195   
00196 void sysGetFreePage(long *ptr,int count,int type) {
00197   if (ptr) {
00198     if (type == 2)
00199       *ptr = (long) vmmGetFreeVirtualPage(_current->id,count,VM_THRD);
00200     else
00201       *ptr = (long) vmmGetFreeVirtualPage(_current->id,count,VM_TASK);
00202     }
00203   return;
00204   }
00205 
00206 void sysGetDrives(uInt32 *ptr)
00207 {
00208         if (ptr)
00209                 *ptr = 0x0;
00210         return;
00211 }
00212 
00213 void sysGetUptime(uInt32 *ptr)
00214 {
00215         if (ptr)
00216                 *ptr = systemVitals->sysTicks;
00217         return;
00218 }
00219 
00220 void sysGetTime(uInt32 *ptr)
00221 {
00222         if (ptr)
00223                 *ptr = systemVitals->sysUptime + systemVitals->timeStart;
00224         return;
00225 }
00226 
00227 
00228 void sysGetCwd(char *data,int len)
00229 {
00230         if (data)
00231                 sprintf(data,"%s", _current->oInfo.cwd);
00232         return;
00233 }
00234 
00235 void sysSchedYield() {
00236   sched_yield();
00237   }
00238 
00239 void sysStartSDE() {
00240   int i = 0x0;
00241   for (i=0;i<1400;i++) {
00242     asm("hlt");
00243     }
00244   
00245   for (i=0;i<1400;i++) {
00246     asm("hlt");
00247     }
00248   return;
00249   }
00250 
00251 void invalidCall(int sys_call) {
00252   kprintf("Invalid System Call #[%i]\n",sys_call);
00253   return;
00254   }
00255 
00256 
00257 
00258 
00259