X-Git-Url: https://git.ucc.asn.au/?a=blobdiff_plain;f=AcessNative%2Facesskernel_src%2Fsyscalls.c;h=4194a36acc235ef9f567ddfb7ad35bb70d3e8b16;hb=b2144260ceb723742e8f8b60ae94ad10c3be63ca;hp=827d611032639fe0da707bbdd13eed0ed2a84738;hpb=9d101ee5f5231954a7102da36997aa8d568a6157;p=tpg%2Facess2.git diff --git a/AcessNative/acesskernel_src/syscalls.c b/AcessNative/acesskernel_src/syscalls.c index 827d6110..4194a36a 100644 --- a/AcessNative/acesskernel_src/syscalls.c +++ b/AcessNative/acesskernel_src/syscalls.c @@ -30,7 +30,7 @@ typedef int (*tSyscallHandler)(Uint *Errno, const char *Format, void *Args, int a3 = *(_t3*)Args;Args+=sizeof(_t3);\ a4 = *(_t4*)Args;Args+=sizeof(_t4);\ a5 = *(_t5*)Args;Args+=sizeof(_t5);\ - LOG("SYSCALL5 '%s' %p %p %p %p %p %p", Fmt, (intptr_t)a0,(intptr_t)a1,(intptr_t)a2,(intptr_t)a3,(intptr_t)a4,(intptr_t)a5);\ + LOG("SYSCALL6 '%s' %p %p %p %p %p %p", Fmt, (intptr_t)a0,(intptr_t)a1,(intptr_t)a2,(intptr_t)a3,(intptr_t)a4,(intptr_t)a5);\ _call\ } #define SYSCALL5(_name, _fmtstr, _t0, _t1, _t2, _t3, _t4, _call) int _name(Uint*Errno,const char*Fmt,void*Args,int*Sizes){\ @@ -119,6 +119,7 @@ SYSCALL3(Syscall_Read, "iid", int, int, void *, ); SYSCALL3(Syscall_Write, "iid", int, int, const void *, if( Sizes[2] < a1 ) { + Log_Warning("Syscalls", "Write - %x < %x", (int)Sizes[2], (int)a1); *Errno = EINVAL; return -1; } @@ -235,26 +236,28 @@ SYSCALL1(Syscall_WaitEvent, "i", int, ); const tSyscallHandler caSyscalls[] = { - Syscall_Null, - Syscall_Exit, - Syscall_Open, - Syscall_Close, - Syscall_Read, - Syscall_Write, - Syscall_Seek, - Syscall_Tell, - Syscall_IOCtl, - Syscall_FInfo, - Syscall_ReadDir, - Syscall_OpenChild, - Syscall_GetACL, - Syscall_Mount, - NULL, // SYS_REOPEN - Syscall_Chdir, + [SYS_NULL] = Syscall_Null, + [SYS_EXIT] = Syscall_Exit, + [SYS_OPEN] = Syscall_Open, + [SYS_CLOSE] = Syscall_Close, + [SYS_COPYFD] = NULL, + [SYS_FDFLAGS] = NULL, + [SYS_READ] = Syscall_Read, + [SYS_WRITE] = Syscall_Write, + [SYS_SEEK] = Syscall_Seek, + [SYS_TELL] = Syscall_Tell, + [SYS_IOCTL] = Syscall_IOCtl, + [SYS_FINFO] = Syscall_FInfo, + [SYS_READDIR] = Syscall_ReadDir, + [SYS_OPENCHILD] = Syscall_OpenChild, + [SYS_GETACL] = Syscall_GetACL, + [SYS_MOUNT] = Syscall_Mount, + [SYS_REOPEN] = NULL, // SYS_REOPEN + [SYS_CHDIR] = Syscall_Chdir, - Syscall_WaitTID, - Syscall_SetUID, - Syscall_SetGID, + [SYS_WAITTID] = Syscall_WaitTID, + [SYS_SETUID] = Syscall_SetUID, + [SYS_SETGID] = Syscall_SetGID, Syscall_GetTID, Syscall_GetPID, @@ -281,12 +284,15 @@ tRequestHeader *SyscallRecieve(tRequestHeader *Request, int *ReturnLength) int argListLen = 0; int i, retVal; tRequestHeader *ret; - int retValueCount = 1; - int retDataLen = sizeof(Uint64); + int retValueCount; + int retDataLen; void *returnData[Request->NParams]; int argSizes[Request->NParams]; Uint ret_errno = 0; + // Clear errno (Acess verson) at the start of the request + errno = 0; + // Sanity check if( Request->CallID >= ciNumSyscalls ) { Log_Notice("Syscalls", "Unknown syscall number %i", Request->CallID); @@ -297,7 +303,11 @@ tRequestHeader *SyscallRecieve(tRequestHeader *Request, int *ReturnLength) Log_Notice("Syscalls", "Unimplemented syscall %i", Request->CallID); return NULL; } - + + // Init return count/size + retValueCount = 2; + retDataLen = sizeof(Uint64) + sizeof(Uint32); + // Get size of argument list for( i = 0; i < Request->NParams; i ++ ) { @@ -318,12 +328,19 @@ tRequestHeader *SyscallRecieve(tRequestHeader *Request, int *ReturnLength) case ARG_TYPE_DATA: formatString[i] = 'd'; argListLen += sizeof(void*); + // Prepare the return values + if( Request->Params[i].Flags & ARG_FLAG_RETURN ) + { + retDataLen += Request->Params[i].Length; + retValueCount ++; + } break; case ARG_TYPE_STRING: formatString[i] = 's'; argListLen += sizeof(char*); break; default: + Log_Error("Syscalls", "Unknown param type %i", Request->Params[i].Type); return NULL; // ERROR! } } @@ -364,13 +381,6 @@ tRequestHeader *SyscallRecieve(tRequestHeader *Request, int *ReturnLength) // Data gets special handling, because only it can be returned to the user // (ARG_TYPE_DATA is a pointer) case ARG_TYPE_DATA: - // Prepare the return values - if( Request->Params[i].Flags & ARG_FLAG_RETURN ) - { - retDataLen += Request->Params[i].Length; - retValueCount ++; - } - // Check for non-resident data if( Request->Params[i].Length == 0 ) { @@ -406,9 +416,9 @@ tRequestHeader *SyscallRecieve(tRequestHeader *Request, int *ReturnLength) // ---------- Return - if( ret_errno == 0 ) { - perror("Syscall?"); + if( ret_errno == 0 && errno != 0 ) { ret_errno = errno; + LOG("errno = %i", errno); } // Allocate the return @@ -427,9 +437,18 @@ tRequestHeader *SyscallRecieve(tRequestHeader *Request, int *ReturnLength) *(Uint64*)inData = retVal; inData += sizeof(Uint64); + // Static Uint32 errno value + ret->Params[1].Type = ARG_TYPE_INT32; + ret->Params[1].Flags = 0; + ret->Params[1].Length = sizeof(Uint32); + *(Uint32*)inData = ret_errno; + inData += sizeof(Uint32); + + LOG("Ret: %llx, errno=%i", retVal, ret_errno); + //Log_Debug("Syscalls", "Return 0x%llx", retVal); - retValueCount = 1; + retValueCount = 2; for( i = 0; i < Request->NParams; i ++ ) { if( Request->Params[i].Type != ARG_TYPE_DATA ) continue; @@ -450,9 +469,7 @@ tRequestHeader *SyscallRecieve(tRequestHeader *Request, int *ReturnLength) retValueCount ++; } - *ReturnLength = sizeof(tRequestHeader) - + retValueCount * sizeof(tRequestValue) - + retDataLen; + *ReturnLength = ret->MessageLength; return ret; }