X-Git-Url: https://git.ucc.asn.au/?a=blobdiff_plain;f=AcessNative%2Facesskernel_src%2Fsyscalls.c;h=9b9fda4280af62a355d83979fe7042a5368bf975;hb=9d2ff6cf13e1a0ec5cbdc2773e1a3204e600b2e5;hp=d5c051b018b806179cff817b21023724fb4c2040;hpb=d497ef38c1c1e0aa5467722e115be0dc4baa47ab;p=tpg%2Facess2.git diff --git a/AcessNative/acesskernel_src/syscalls.c b/AcessNative/acesskernel_src/syscalls.c index d5c051b0..9b9fda42 100644 --- a/AcessNative/acesskernel_src/syscalls.c +++ b/AcessNative/acesskernel_src/syscalls.c @@ -4,9 +4,10 @@ * * Syscall Distribution */ -#define DEBUG 1 +#define DEBUG 0 #include #include +#include #include "../syscalls.h" // === IMPORTS === @@ -177,13 +178,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, a1); + *a0 = tmp; + } + else + rv = Proc_GetMessage(NULL, a1); + return rv; +); + +SYSCALL1(Syscall_WaitEvent, "i", int, + return Threads_WaitEvents(a0); +); + const tSyscallHandler caSyscalls[] = { Syscall_Null, Syscall_Exit, @@ -206,12 +237,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 +309,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 +352,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); @@ -367,7 +410,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);