X-Git-Url: https://git.ucc.asn.au/?a=blobdiff_plain;f=AcessNative%2Fld-acess_src%2Fexports.c;h=fc336c8eb9a2677c0073bda3899d05165860b047;hb=8c3572edcb27522e626c2629871857323169998d;hp=0c87bda674ef882eae453f55e7928a90d797fd8a;hpb=a41f3e5efdf853726d078dc03550de40e9d63bdd;p=tpg%2Facess2.git diff --git a/AcessNative/ld-acess_src/exports.c b/AcessNative/ld-acess_src/exports.c index 0c87bda6..fc336c8e 100644 --- a/AcessNative/ld-acess_src/exports.c +++ b/AcessNative/ld-acess_src/exports.c @@ -5,13 +5,14 @@ * - Exported functions */ #define DONT_INCLUDE_SYSCALL_NAMES 1 -#include "../../Usermode/include/acess/sys.h" +#include "../../Usermode/Libraries/ld-acess.so_src/include_exp/acess/sys.h" #include "../syscalls.h" #include "exports.h" #include #include #define DEBUG(v...) Debug(v) +#define PAGE_SIZE 4096 typedef struct sFILE FILE; @@ -67,14 +68,16 @@ int acess_reopen(int FD, const char *Path, int Flags) { size_t acess_read(int FD, void *Dest, size_t Bytes) { if(FD & NATIVE_FILE_MASK) return native_read(FD & (NATIVE_FILE_MASK-1), Dest, Bytes); - DEBUG("read(0x%x, 0x%x, *%p)", FD, Bytes, Dest); +// if( FD > 2 ) + DEBUG("read(0x%x, 0x%x, *%p)", FD, Bytes, Dest); return _Syscall(SYS_READ, ">i >i 2 ) + DEBUG("write(0x%x, 0x%x, %p\"%.*s\")", FD, Bytes, Src, Bytes, (char*)Src); return _Syscall(SYS_WRITE, ">i >i >d", FD, Bytes, Bytes, Src); } @@ -93,9 +96,14 @@ uint64_t acess_tell(int FD) { } int acess_ioctl(int fd, int id, void *data) { - // NOTE: 1024 byte size is a hack + int len; DEBUG("ioctl(%i, %i, %p)", fd, id, data); - return _Syscall(SYS_IOCTL, ">i >i ?d", fd, id, 1024, data); + // NOTE: The length here is hacky and could break + if( data == NULL ) + len = 0; + else + len = PAGE_SIZE - ((uintptr_t)data % PAGE_SIZE); + return _Syscall(SYS_IOCTL, ">i >i ?d", fd, id, len, data); } int acess_finfo(int fd, t_sysFInfo *info, int maxacls) { // DEBUG("offsetof(size, t_sysFInfo) = %i", offsetof(t_sysFInfo, size)); @@ -257,10 +265,19 @@ int acess_SysSendMessage(int DestTID, int Length, void *Data) int acess_SysGetMessage(int *SourceTID, void *Data) { - return _Syscall(SYS_GETMSG, "i", Mask); } // --- Logging @@ -270,7 +287,7 @@ void acess__SysDebug(const char *Format, ...) va_start(args, Format); - printf("[_SysDebug %i]", giSyscall_ClientID); + printf("[_SysDebug %i] ", giSyscall_ClientID); vprintf(Format, args); printf("\n"); @@ -321,7 +338,8 @@ const tSym caBuiltinSymbols[] = { DEFSYM(_SysAllocate), DEFSYM(_SysDebug), - DEFSYM(_SysSetFaultHandler) + DEFSYM(_SysSetFaultHandler), + DEFSYM(_SysWaitEvent) }; const int ciNumBuiltinSymbols = sizeof(caBuiltinSymbols)/sizeof(caBuiltinSymbols[0]);