*
* Syscall Distribution
*/
+#define DEBUG 1
#include <acess.h>
#include <threads.h>
#include "../syscalls.h"
a2 = *(_t2*)Args;Args+=sizeof(_t2);\
a3 = *(_t3*)Args;Args+=sizeof(_t3);\
a4 = *(_t4*)Args;Args+=sizeof(_t4);\
+ LOG("SYSCALL5 '%s' %p %p %p %p %p", Fmt, (intptr_t)a0,(intptr_t)a1,(intptr_t)a2,(intptr_t)a3,(intptr_t)a4);\
_call\
}
#define SYSCALL4(_name, _fmtstr, _t0, _t1, _t2, _t3, _call) int _name(Uint*Errno,const char*Fmt,void*Args,int*Sizes){\
a1 = *(_t1*)Args;Args+=sizeof(_t1);\
a2 = *(_t2*)Args;Args+=sizeof(_t2);\
a3 = *(_t3*)Args;Args+=sizeof(_t3);\
+ LOG("SYSCALL4 '%s' %p %p %p %p", Fmt, (intptr_t)a0,(intptr_t)a1,(intptr_t)a2,(intptr_t)a3);\
_call\
}
a0 = *(_t0*)Args;Args+=sizeof(_t0);\
a1 = *(_t1*)Args;Args+=sizeof(_t1);\
a2 = *(_t2*)Args;Args+=sizeof(_t2);\
+ LOG("SYSCALL3 '%s' %p %p %p", Fmt, (intptr_t)a0,(intptr_t)a1,(intptr_t)a2);\
_call\
}
if(strcmp(Fmt,_fmtstr)!=0)return 0;\
a0 = *(_t0*)Args;Args+=sizeof(_t0);\
a1 = *(_t1*)Args;Args+=sizeof(_t1);\
+ LOG("SYSCALL2 '%s' %p %p", Fmt, (intptr_t)a0,(intptr_t)a1);\
_call;\
}
_t0 a0;\
if(strcmp(Fmt,_fmtstr)!=0)return 0;\
a0 = *(_t0*)Args;Args+=sizeof(_t0);\
+ LOG("SYSCALL1 '%s' %p", Fmt,(intptr_t)a0);\
_call;\
}
#define SYSCALL0(_name, _call) int _name(Uint*Errno,const char*Fmt, void*Args,int*Sizes){\
if(strcmp(Fmt,"")!=0)return 0;\
+ LOG("SYSCALL0");\
_call;\
}
return VFS_IOCtl(a0, a1, a2);
);
SYSCALL3(Syscall_FInfo, "idi", int, void *, int,
- if( Sizes[1] < sizeof(tFInfo)+a2*sizeof(tVFS_ACL))
+ if( Sizes[1] < sizeof(tFInfo)+a2*sizeof(tVFS_ACL)) {
+ LOG("offsetof(size) = %i", offsetof(tFInfo, size));
+ LOG("Bad size %i < %i", Sizes[1], sizeof(tFInfo)+a2*sizeof(tVFS_ACL));
+ *Errno = -EINVAL;
return -1;
+ }
return VFS_FInfo(a0, a1, a2);
);
SYSCALL2(Syscall_ReadDir, "id", int, char *,
case ARG_TYPE_VOID:
break;
case ARG_TYPE_INT32:
- LOG("Syscalls", "%i INT32: 0x%x", i, *(Uint32*)inData);
+ LOG("%i INT32: 0x%x", i, *(Uint32*)inData);
*(Uint32*)&argListData[argListLen] = *(Uint32*)inData;
argListLen += sizeof(Uint32);
inData += sizeof(Uint32);
break;
case ARG_TYPE_INT64:
- LOG("Syscalls", "%i INT64: 0x%llx", i, *(Uint64*)inData);
+ LOG("%i INT64: 0x%llx", i, *(Uint64*)inData);
*(Uint64*)&argListData[argListLen] = *(Uint64*)inData;
argListLen += sizeof(Uint64);
inData += sizeof(Uint64);
break;
case ARG_TYPE_STRING:
- LOG("Syscalls", "%i STR: '%s'", i, (char*)inData);
+ LOG("%i STR: '%s'", i, (char*)inData);
*(char**)&argListData[argListLen] = (char*)inData;
argListLen += sizeof(void*);
inData += Request->Params[i].Length;
{
// Allocate and zero the buffer
returnData[i] = calloc(1, Request->Params[i].Length);
- LOG("Syscalls", "%i ZDAT: %i %p", i,
+ LOG("%i ZDAT: %i %p", i,
Request->Params[i].Length, returnData[i]);
*(void**)&argListData[argListLen] = returnData[i];
argListLen += sizeof(void*);
else
{
returnData[i] = (void*)inData;
- LOG("Syscalls", "%i DATA: %i %p", i,
+ LOG("%i DATA: %i %p", i,
Request->Params[i].Length, returnData[i]);
*(void**)&argListData[argListLen] = (void*)inData;
argListLen += sizeof(void*);
return _Syscall(SYS_IOCTL, ">i >i ?d", fd, id, 1024, data);
}
int acess_finfo(int fd, t_sysFInfo *info, int maxacls) {
+ DEBUG("offsetof(size, t_sysFInfo) = %i", offsetof(t_sysFInfo, size));
+ DEBUG("finfo(%i, %p, %i)", fd, info, maxacls);
return _Syscall(SYS_FINFO, ">i <d >i",
fd,
sizeof(t_sysFInfo)+maxacls*sizeof(t_sysACL), info,
- maxacls);
+ maxacls
+ );
}
int acess_readdir(int fd, char *dest) {
}
int acess__SysGetACL(int fd, t_sysACL *dest) {
- return _Syscall(SYS_GETACL, "<i >i <d", fd, sizeof(t_sysACL), dest);
+ return _Syscall(SYS_GETACL, ">i <d", fd, sizeof(t_sysACL), dest);
}
int acess__SysMount(const char *Device, const char *Directory, const char *Type, const char *Options) {
// --- Error Handler
-int acess__SysSetFaultHandler(int (*Handler)(int)) {
+int acess__SysSetFaultHandler(int (*Handler)(int)) {
printf("TODO: Set fault handler (asked to set to %p)\n", Handler);
return 0;
}