}
// 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
printf("\n");
}
#endif
+ #if DEBUG
{
int i;
char *data = (char*)&Request->Params[Request->NParams];
}
DEBUG_S("\n");
}
+ #endif
// Send it off
SendData(Request, RequestSize);
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)
req->ClientID = 0; //< Filled later
req->CallID = SyscallID;
req->NParams = paramCount;
+ req->MessageLength = dataLength;
dataPtr = &req->Params[paramCount];
// Fill `output` and `input`
}
// 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 ++ )
{
typedef struct sRequestHeader {
uint16_t ClientID;
uint16_t CallID; //!< \see eSyscalls
+ uint32_t MessageLength;
uint16_t NParams;
tRequestValue Params[];
# 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
-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