+ printf("%02x ", ((uint8_t*)Request)[i]);
+ if( i % 16 == 15 ) printf("\n");
+ }
+ printf("\n");
+ }
+ #endif
+ #if DEBUG
+ {
+ int i;
+ char *data = (char*)&Request->Params[Request->NParams];
+ DEBUG_S("Request #%i (%s) -", Request->CallID, casSYSCALL_NAMES[Request->CallID]);
+ for( i = 0; i < Request->NParams; i ++ )
+ {
+ switch(Request->Params[i].Type)
+ {
+ case ARG_TYPE_INT32:
+ DEBUG_S(" 0x%08x", *(uint32_t*)data);
+ data += sizeof(uint32_t);
+ break;
+ case ARG_TYPE_INT64:
+ DEBUG_S(" 0x%016"PRIx64"", *(uint64_t*)data);
+ data += sizeof(uint64_t);
+ break;
+ case ARG_TYPE_STRING:
+ DEBUG_S(" '%s'", (char*)data);
+ data += Request->Params[i].Length;
+ break;
+ case ARG_TYPE_DATA:
+ DEBUG_S(" %p:0x%x", (char*)data, Request->Params[i].Length);
+ if( !(Request->Params[i].Flags & ARG_FLAG_ZEROED) )
+ data += Request->Params[i].Length;
+ break;
+ }
+ }
+ DEBUG_S("\n");
+ }
+ #endif
+
+ // Send it off
+ SendData(Request, RequestSize);
+
+ if( Request->CallID == SYS_EXIT ) return 0;
+
+ // Wait for a response (no timeout)
+ 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 ) {