X-Git-Url: https://git.ucc.asn.au/?a=blobdiff_plain;f=AcessNative%2Facesskernel_src%2Fsyscalls.c;h=69192399417fb5959fbf928dd6f6f24f278ecb05;hb=9d234f984c149fcc6b1f5aab21a0ca227c060e32;hp=d5c051b018b806179cff817b21023724fb4c2040;hpb=d497ef38c1c1e0aa5467722e115be0dc4baa47ab;p=tpg%2Facess2.git diff --git a/AcessNative/acesskernel_src/syscalls.c b/AcessNative/acesskernel_src/syscalls.c index d5c051b0..69192399 100644 --- a/AcessNative/acesskernel_src/syscalls.c +++ b/AcessNative/acesskernel_src/syscalls.c @@ -4,9 +4,13 @@ * * Syscall Distribution */ -#define DEBUG 1 +#define DEBUG 0 #include #include +#include +#if DEBUG == 0 +# define DONT_INCLUDE_SYSCALL_NAMES +#endif #include "../syscalls.h" // === IMPORTS === @@ -136,7 +140,7 @@ SYSCALL2(Syscall_ReadDir, "id", int, char *, return -1; return VFS_ReadDir(a0, a1); ); -SYSCALL6(Syscall_select, "iddddi", int, fd_set *, fd_set *, fd_set *, time_t *, unsigned int, +SYSCALL6(Syscall_select, "iddddi", int, fd_set *, fd_set *, fd_set *, tTime *, unsigned int, return VFS_Select(a0, a1, a2, a3, a4, a5, 0); ); SYSCALL3(Syscall_OpenChild, "isi", int, const char *, int, @@ -177,13 +181,43 @@ SYSCALL1(Syscall_SetGID, "i", int, return Threads_SetGID(a0); ); -SYSCALL1(Syscall_Fork, "d", int *, +SYSCALL0(Syscall_GetTID, return Threads_GetTID()); +SYSCALL0(Syscall_GetPID, return Threads_GetPID()); +SYSCALL0(Syscall_GetUID, return Threads_GetUID()); +SYSCALL0(Syscall_GetGID, return Threads_GetGID()); + +SYSCALL1(Syscall_AN_Fork, "d", int *, if(Sizes[0] < sizeof(int)) return -1; *a0 = Threads_Fork(); return *a0; ); +SYSCALL2(Syscall_SendMessage, "id", int, void *, + return Proc_SendMessage(a0, Sizes[1], a1); +); + +SYSCALL2(Syscall_GetMessage, "dd", uint32_t *, void *, + if( a0 && Sizes[0] < sizeof(*a0) ) { + Log_Notice("Syscalls", "Syscall_GetMessage - Arg 1 Undersize (%i < %i)", + Sizes[0], sizeof(*a0)); + return -1; + } + Uint tmp; + int rv; + if( a0 ) { + rv = Proc_GetMessage(&tmp, Sizes[1], a1); + *a0 = tmp; + } + else + rv = Proc_GetMessage(NULL, Sizes[1], a1); + return rv; +); + +SYSCALL1(Syscall_WaitEvent, "i", int, + return Threads_WaitEvents(a0); +); + const tSyscallHandler caSyscalls[] = { Syscall_Null, Syscall_Exit, @@ -206,12 +240,18 @@ const tSyscallHandler caSyscalls[] = { Syscall_SetUID, Syscall_SetGID, + Syscall_GetTID, + Syscall_GetPID, + Syscall_GetUID, + Syscall_GetGID, + Syscall_Sleep, - Syscall_Fork, + Syscall_AN_Fork, - NULL, - NULL, - Syscall_select + Syscall_SendMessage, + Syscall_GetMessage, + Syscall_select, + Syscall_WaitEvent }; const int ciNumSyscalls = sizeof(caSyscalls)/sizeof(caSyscalls[0]); /** @@ -272,7 +312,7 @@ tRequestHeader *SyscallRecieve(tRequestHeader *Request, int *ReturnLength) } formatString[i] = '\0'; - //LOG("Request %i(%s) '%s'", Request->CallID, casSYSCALL_NAMES[Request->CallID], formatString); + LOG("Request %i(%s) '%s'", Request->CallID, casSYSCALL_NAMES[Request->CallID], formatString); { char argListData[argListLen]; @@ -315,7 +355,13 @@ tRequestHeader *SyscallRecieve(tRequestHeader *Request, int *ReturnLength) } // Check for non-resident data - if( Request->Params[i].Flags & ARG_FLAG_ZEROED ) + if( Request->Params[i].Length == 0 ) + { + returnData[i] = NULL; + *(void**)&argListData[argListLen] = NULL; + argListLen += sizeof(void*); + } + else if( Request->Params[i].Flags & ARG_FLAG_ZEROED ) { // Allocate and zero the buffer returnData[i] = calloc(1, Request->Params[i].Length); @@ -341,11 +387,12 @@ tRequestHeader *SyscallRecieve(tRequestHeader *Request, int *ReturnLength) } // Allocate the return - ret = malloc(sizeof(tRequestHeader) + retValueCount * sizeof(tRequestValue) - + retDataLen); + size_t msglen = sizeof(tRequestHeader) + retValueCount * sizeof(tRequestValue) + retDataLen; + ret = malloc(msglen); ret->ClientID = Request->ClientID; ret->CallID = Request->CallID; ret->NParams = retValueCount; + ret->MessageLength = msglen; inData = (char*)&ret->Params[ ret->NParams ]; // Static Uint64 return value @@ -355,7 +402,7 @@ tRequestHeader *SyscallRecieve(tRequestHeader *Request, int *ReturnLength) *(Uint64*)inData = retVal; inData += sizeof(Uint64); - Log_Debug("Syscalls", "Return 0x%llx", retVal); + //Log_Debug("Syscalls", "Return 0x%llx", retVal); retValueCount = 1; for( i = 0; i < Request->NParams; i ++ ) @@ -367,7 +414,7 @@ tRequestHeader *SyscallRecieve(tRequestHeader *Request, int *ReturnLength) ret->Params[retValueCount].Flags = 0; ret->Params[retValueCount].Length = Request->Params[i].Length; - LOG("Syscalls", "Ret %i: Type %i, Len %i", + LOG("Ret %i: Type %i, Len %i", i, Request->Params[i].Type, Request->Params[i].Length); memcpy(inData, returnData[i], Request->Params[i].Length);