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