AcessNative - Added message length to simplfy message reception
authorJohn Hodge <[email protected]>
Sun, 7 Oct 2012 08:57:15 +0000 (16:57 +0800)
committerJohn Hodge <[email protected]>
Sun, 7 Oct 2012 08:57:15 +0000 (16:57 +0800)
AcessNative/acesskernel_src/syscalls.c
AcessNative/ld-acess_src/request.c
AcessNative/ld-acess_src/syscalls.c
AcessNative/syscalls.h
BuildConf/x86/Makefile.cfg
BuildConf/x86_64/Makefile.cfg

index 446da3d..9cee8e3 100644 (file)
@@ -384,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
index 7a9b3b3..1560eb7 100644 (file)
@@ -190,6 +190,7 @@ int SendRequest(tRequestHeader *Request, int RequestSize, int ResponseSize)
                printf("\n");
        }
        #endif
+       #if DEBUG
        {
                 int    i;
                char    *data = (char*)&Request->Params[Request->NParams];
@@ -219,6 +220,7 @@ int SendRequest(tRequestHeader *Request, int RequestSize, int ResponseSize)
                }
                DEBUG_S("\n");
        }
+       #endif
        
        // Send it off
        SendData(Request, RequestSize);
@@ -226,7 +228,23 @@ int SendRequest(tRequestHeader *Request, int RequestSize, int ResponseSize)
        if( Request->CallID == SYS_EXIT )       return 0;
 
        // Wait for a response (no timeout)
-       return ReadData(Request, ResponseSize, 0);
+       ReadData(Request, sizeof(*Request), 0);
+       // TODO: Sanity
+       size_t  recvbytes = sizeof(*Request), expbytes = Request->MessageLength;
+       char    *ptr = (void*)Request->Params;
+       while( recvbytes < expbytes )
+       {
+               size_t  len = ReadData(ptr, expbytes - recvbytes, 1000);
+               if( len == -1 ) {
+                       return -1;
+               }
+               recvbytes += len;
+               ptr += len;
+       }
+       if( recvbytes > expbytes ) {
+               // TODO: Warning
+       }
+       return recvbytes;
 }
 
 void SendData(void *Data, int Length)
index a5ec8de..5c26870 100644 (file)
@@ -206,6 +206,7 @@ uint64_t _Syscall(int SyscallID, const char *ArgTypes, ...)
        req->ClientID = 0;      //< Filled later
        req->CallID = SyscallID;
        req->NParams = paramCount;
+       req->MessageLength = dataLength;
        dataPtr = &req->Params[paramCount];
        
        // Fill `output` and `input`
@@ -253,6 +254,11 @@ uint64_t _Syscall(int SyscallID, const char *ArgTypes, ...)
        }
        
        // Write changes to buffers
+       if( req->NParams - 1 != retCount ) {
+               fprintf(stderr, "syscalls.c: Return count inbalance (%i - 1 != exp %i) [Call %i]\n",
+                       req->NParams, retCount, SyscallID);
+               exit(127);
+       }
        retCount = 0;
        for( i = 1; i < req->NParams; i ++ )
        {
index e6dbd28..d7ee2d5 100644 (file)
@@ -29,6 +29,7 @@ typedef struct sRequestValue {
 typedef struct sRequestHeader {
        uint16_t        ClientID;
        uint16_t        CallID; //!< \see eSyscalls
+       uint32_t        MessageLength;
        uint16_t        NParams;
        
        tRequestValue   Params[];
index 76c3d3c..7d5dcc1 100644 (file)
@@ -2,10 +2,10 @@
 # Acess2 Build Configuration
 #
 
-#CC = i586-elf-gcc
-#LD = i586-elf-ld
-CC = gcc
-LD = ld
+CC = i586-elf-gcc
+LD = i586-elf-ld
+#CC = gcc
+#LD = ld
 AS = nasm
 #OBJDUMP = i586-elf-objdump
 OBJDUMP = objdump
index 6aa3afc..ebca2d9 100644 (file)
@@ -1,6 +1,6 @@
 
-PREFIX := x86_64-pc-elf
-#PREFIX := x86_64-none-elf
+#PREFIX := x86_64-pc-elf
+PREFIX := x86_64-none-elf
 
 CC := $(PREFIX)-gcc
 LD := $(PREFIX)-ld

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