extern int Proc_GetMessage(Uint *Err, Uint *Source, void *Buffer);
extern int Proc_Execve(char *File, char **ArgV, char **EnvP);
extern Uint Binary_Load(char *file, Uint *entryPoint);
-extern int Threads_SetName(char *NewName);
-extern int Threads_GetPID();
-extern int Threads_GetTID();
-extern tUID Threads_GetUID();
extern int Threads_SetUID(Uint *errno, tUID ID);
-extern tGID Threads_GetGID();
extern int Threads_SetGID(Uint *errno, tGID ID);
extern int Threads_SetFaultHandler(Uint Handler);
{
Uint64 ret = 0;
Uint err = -EOK;
+ int callNum = Regs->Num;
- ENTER("iThread iNum", Threads_GetTID(), Regs->Num);
- if(Regs->Num < NUM_SYSCALLS)
- LOG("Syscall %s", cSYSCALL_NAMES[Regs->Num]);
+ #if DEBUG < 2
+ if(callNum != SYS_READ && callNum != SYS_WRITE) {
+ #endif
+ ENTER("iThread iNum", Threads_GetTID(), callNum);
+ if(callNum < NUM_SYSCALLS)
+ LOG("Syscall %s", cSYSCALL_NAMES[callNum]);
LOG("Arg1: 0x%x, Arg2: 0x%x, Arg3: 0x%x, Arg4: 0x%x", Regs->Arg1, Regs->Arg2, Regs->Arg3, Regs->Arg4);
+ #if DEBUG < 2
+ }
+ #endif
switch(Regs->Num)
{
// -- Check for messages
case SYS_GETMSG:
CHECK_NUM_NULLOK(Regs->Arg1, sizeof(Uint));
- if( Regs->Arg2 && Regs->Arg2 != -1 && !MM_IsUser(Regs->Arg2) )
- {
+ if( Regs->Arg2 && Regs->Arg2 != -1 && !MM_IsUser(Regs->Arg2) ) {
err = -EINVAL; ret = -1; break;
}
// *Source, *Data
ret = Proc_GetMessage(&err, (Uint*)Regs->Arg1, (void*)Regs->Arg2);
break;
+ // -- Get the current timestamp
+ case SYS_GETTIME:
+ ret = now();
+ break;
+
// -- Set the thread's name
case SYS_SETNAME:
CHECK_STR_NONULL(Regs->Arg1);
// ---
// Binary Control
// ---
+ // -- Replace the current process with another
case SYS_EXECVE:
CHECK_STR_NONULL(Regs->Arg1);
- //Log(" Regs = {Arg2: %x, Arg3: %x}", Regs->Arg2, Regs->Arg3);
+ // Check the argument arrays
{
int i;
char **tmp = (char**)Regs->Arg2;
}
LEAVE('s', "Assuming 0");
// Path, **Argv, **Envp
- ret = Proc_Execve((char*)Regs->Arg1, (char**)Regs->Arg2, (char**)Regs->Arg3);
+ ret = Proc_Execve( (char*)Regs->Arg1, (char**)Regs->Arg2, (char**)Regs->Arg3 );
break;
+ // -- Load a binary into the current process
case SYS_LOADBIN:
if( !Syscall_ValidString(Regs->Arg1)
|| !Syscall_Valid(sizeof(Uint), Regs->Arg2) ) {
ret = -1;
break;
}
+ LOG("VFS_Open(\"%s\", 0x%x)", (char*)Regs->Arg1, Regs->Arg2 | VFS_OPENFLAG_USER);
ret = VFS_Open((char*)Regs->Arg1, Regs->Arg2 | VFS_OPENFLAG_USER);
break;
case SYS_CLOSE:
+ LOG("VFS_Close(%i)", Regs->Arg1);
VFS_Close( Regs->Arg1 );
break;
#if BITS == 64
ret = VFS_Seek( Regs->Arg1, Regs->Arg2, Regs->Arg3 );
#else
- ret = VFS_Seek( Regs->Arg1, Regs->Arg2|((Uint64)Regs->Arg3<<64), Regs->Arg4 );
+ ret = VFS_Seek( Regs->Arg1, Regs->Arg2|(((Uint64)Regs->Arg3)<<32), Regs->Arg4 );
#endif
break;
// Read Directory
case SYS_READDIR:
+ // TODO: What if the filename is longer?
+ // Maybe force it to be a 256 byte buffer
if( !Syscall_Valid(8, Regs->Arg2) ) {
err = -EINVAL;
ret = -1;
#endif
Regs->Error = err;
#if DEBUG
+ # if DEBUG < 2
+ if( callNum != SYS_READ && callNum != SYS_WRITE ) {
+ # endif
LOG("err = %i", err);
if(Regs->Num != SYS_EXECVE)
LEAVE('x', ret);
else
LOG("Actual %i", ret);
+ # if DEBUG < 2
+ }
+ # endif
#endif
}