00001 /***************************************************************************************** 00002 Copyright (c) 2002-2004 The UbixOS Project 00003 All rights reserved. 00004 00005 Redistribution and use in source and binary forms, with or without modification, are 00006 permitted provided that the following conditions are met: 00007 00008 Redistributions of source code must retain the above copyright notice, this list of 00009 conditions, the following disclaimer and the list of authors. Redistributions in binary 00010 form must reproduce the above copyright notice, this list of conditions, the following 00011 disclaimer and the list of authors in the documentation and/or other materials provided 00012 with the distribution. Neither the name of the UbixOS Project nor the names of its 00013 contributors may be used to endorse or promote products derived from this software 00014 without specific prior written permission. 00015 00016 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY 00017 EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 00018 MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL 00019 THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 00020 SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT 00021 OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 00022 HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR 00023 TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 00024 SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 00025 00026 $Id: syscall__new_8c-source.html 88 2016-01-12 00:11:29Z reddawg $ 00027 00028 *****************************************************************************************/ 00029 00030 #include <ubixos/syscalls_new.h> 00031 #include <ubixos/sched.h> 00032 #include <ubixos/types.h> 00033 #include <ubixos/endtask.h> 00034 #include <ubixos/spinlock.h> 00035 #include <sys/trap.h> 00036 #include <lib/string.h> 00037 #include <lib/kprintf.h> 00038 00039 spinLock_t Master = SPIN_LOCK_INITIALIZER; 00040 00041 void syscall(struct trapframe frame) { 00042 uInt32 code = 0x0; 00043 caddr_t params; 00044 struct thread *td = &_current->td; 00045 int args[8]; 00046 int error = 0x0; 00047 00048 params = (caddr_t)frame.tf_esp + sizeof(int); 00049 00050 code = frame.tf_eax; 00051 if (code == 198) { 00052 memcpy(&code,params,sizeof(int)); 00053 params += sizeof(quad_t); 00054 } 00055 00056 if (code > totalCalls_new) { 00057 kprintf("Invalid Call: [%i]\n",frame.tf_eax); 00058 } 00059 else if ((uInt32)systemCalls_new[code] == 0x0) { 00060 kprintf("Invalid Call: [%i][0x%X]\n",code,(uInt32)systemCalls_new[code]); 00061 frame.tf_eax = -1; 00062 frame.tf_edx = 0x0; 00063 } 00064 else { 00065 memcpy(args,params,8 * sizeof(int)); 00066 td->td_retval[0] = 0; 00067 td->td_retval[1] = frame.tf_edx; 00068 00069 error = (int)systemCalls_new[code](td,args); 00070 switch (error) { 00071 case 0: 00072 frame.tf_eax = td->td_retval[0]; 00073 frame.tf_edx = td->td_retval[1]; 00074 frame.tf_eflags &= ~PSL_C; 00075 break; 00076 case ERESTART: 00077 frame.tf_eip -= frame.tf_err; 00078 break; 00079 case EJUSTRETURN: 00080 break; 00081 default: 00082 frame.tf_eax = error; 00083 frame.tf_eflags |= PSL_C; 00084 break; 00085 00086 } 00087 } 00088 } 00089 00090 00091 /*** 00092 END 00093 ***/ 00094