X-Git-Url: https://git.ucc.asn.au/?a=blobdiff_plain;f=AcessNative%2Facesskernel_src%2Fsyscalls.c;h=b41e3544fa354f38c67e2be3679b48e02f4e705e;hb=1474ce5c1ba164bbccfefa411883805d12a0dc62;hp=f48b1a98ae3921115bc34a3f2d6ca3b4943e38ee;hpb=7f80ab30017689efe0aaaab18abc7ceda689d859;p=tpg%2Facess2.git diff --git a/AcessNative/acesskernel_src/syscalls.c b/AcessNative/acesskernel_src/syscalls.c index f48b1a98..b41e3544 100644 --- a/AcessNative/acesskernel_src/syscalls.c +++ b/AcessNative/acesskernel_src/syscalls.c @@ -15,6 +15,16 @@ extern int Threads_Fork(void); // AcessNative only function typedef int (*tSyscallHandler)(Uint *Errno, const char *Format, void *Args, int *Sizes); // === MACROS === +#define SYSCALL5(_name, _fmtstr, _t0, _t1, _t2, _t3, _t4, _call) int _name(Uint*Errno,const char*Fmt,void*Args,int*Sizes){\ + _t0 a0;_t1 a1;_t2 a2;_t3 a3;_t4 a4;\ + if(strcmp(Fmt,_fmtstr)!=0)return 0;\ + a0 = *(_t0*)Args;Args+=sizeof(_t0);\ + a1 = *(_t1*)Args;Args+=sizeof(_t1);\ + a2 = *(_t2*)Args;Args+=sizeof(_t2);\ + a3 = *(_t3*)Args;Args+=sizeof(_t3);\ + a4 = *(_t4*)Args;Args+=sizeof(_t4);\ + _call\ +} #define SYSCALL4(_name, _fmtstr, _t0, _t1, _t2, _t3, _call) int _name(Uint*Errno,const char*Fmt,void*Args,int*Sizes){\ _t0 a0;_t1 a1;_t2 a2;_t3 a3;\ if(strcmp(Fmt,_fmtstr)!=0)return 0;\ @@ -73,8 +83,10 @@ SYSCALL1(Syscall_Close, "i", int, return 0; ); SYSCALL3(Syscall_Read, "iid", int, int, void *, - if( Sizes[2] < a1 ) + if( Sizes[2] < a1 ) { + Log_Warning("Syscalls", "Read - %i < %i", Sizes[2], a1); return -1; + } return VFS_Read(a0, a1, a2); ); SYSCALL3(Syscall_Write, "iid", int, int, const void *, @@ -101,6 +113,9 @@ SYSCALL2(Syscall_ReadDir, "id", int, char *, return -1; return VFS_ReadDir(a0, a1); ); +SYSCALL5(Syscall_select, "idddd", int, fd_set *, fd_set *, fd_set *, time_t *, + return VFS_Select(a0, a1, a2, a3, a4, 0); +); SYSCALL3(Syscall_OpenChild, "isi", int, const char *, int, return VFS_OpenChild(NULL, a0, a1, a2|VFS_OPENFLAG_USER); ); @@ -112,6 +127,9 @@ SYSCALL2(Syscall_GetACL, "id", int, void *, SYSCALL4(Syscall_Mount, "ssss", const char *, const char *, const char *, const char *, return VFS_Mount(a0, a1, a2, a3); ); +SYSCALL1(Syscall_Chdir, "s", const char *, + return VFS_ChDir(a0); +); SYSCALL0(Syscall_Sleep, Threads_Sleep(); return 0; @@ -136,8 +154,11 @@ SYSCALL1(Syscall_SetGID, "i", int, return Threads_SetGID(Errno, a0); ); -SYSCALL0(Syscall_Fork, - return Threads_Fork(); +SYSCALL1(Syscall_Fork, "d", int *, + if(Sizes[0] < sizeof(int)) + return -1; + *a0 = Threads_Fork(); + return *a0; ); const tSyscallHandler caSyscalls[] = { @@ -156,13 +177,18 @@ const tSyscallHandler caSyscalls[] = { Syscall_GetACL, Syscall_Mount, NULL, // SYS_REOPEN + Syscall_Chdir, Syscall_WaitTID, Syscall_SetUID, Syscall_SetGID, Syscall_Sleep, - Syscall_Fork + Syscall_Fork, + + NULL, + NULL, + Syscall_select }; const int ciNumSyscalls = sizeof(caSyscalls)/sizeof(caSyscalls[0]); /** @@ -306,7 +332,7 @@ tRequestHeader *SyscallRecieve(tRequestHeader *Request, int *ReturnLength) *(Uint64*)inData = retVal; inData += sizeof(Uint64); - LOG("Syscalls", "Return 0x%llx", retVal); + Log_Debug("Syscalls", "Return 0x%llx", retVal); retValueCount = 1; for( i = 0; i < Request->NParams; i ++ )