AcessNative - Mouse implimented, woot!
[tpg/acess2.git] / AcessNative / acesskernel_src / syscalls.c
index 58dc801..86c6d71 100644 (file)
@@ -4,7 +4,7 @@
  *
  * Syscall Distribution
  */
-#define DEBUG  1
+#define DEBUG  0
 #include <acess.h>
 #include <threads.h>
 #include <events.h>
@@ -137,7 +137,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,
@@ -194,10 +194,21 @@ SYSCALL2(Syscall_SendMessage, "id", int, void *,
        return Proc_SendMessage(a0, Sizes[1], a1);
 );
 
-SYSCALL2(Syscall_GetMessage, "dd", Uint *, void *,
-       if( Sizes[0] < sizeof(*a0) )
+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;
-       return Proc_GetMessage(a0, a1);
+       }
+       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,
@@ -298,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];
@@ -341,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,11 +384,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

UCC git Repository :: git.ucc.asn.au