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;\
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 *,
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);
+ return VFS_OpenChild(a0, a1, a2|VFS_OPENFLAG_USER);
);
SYSCALL2(Syscall_GetACL, "id", int, void *,
if(Sizes[1] < sizeof(tVFS_ACL))
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;
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[] = {
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]);
/**
*(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 ++ )