#define SYS_COPYFD 69 // Create a copy of a file handle
#define SYS_FDCTL 70 // Modify flags of a file descriptor
#define SYS_READ 71 // Read from an open file
-#define SYS_WRITE 72 // Write to an open file
-#define SYS_IOCTL 73 // Perform an IOCtl Call
-#define SYS_SEEK 74 // Seek to a new position in the file
-#define SYS_READDIR 75 // Read from an open directory
-#define SYS_GETACL 76 // Get an ACL Value
-#define SYS_SETACL 77 // Set an ACL Value
-#define SYS_FINFO 78 // Get file information
-#define SYS_MKDIR 79 // Create a new directory
-#define SYS_LINK 80 // Create a new link to a file
-#define SYS_SYMLINK 81 // Create a symbolic link
-#define SYS_UNLINK 82 // Delete a file
-#define SYS_TELL 83 // Return the current file position
-#define SYS_CHDIR 84 // Change current directory
-#define SYS_GETCWD 85 // Get current directory
-#define SYS_MOUNT 86 // Mount a filesystem
-#define SYS_SELECT 87 // Wait for file handles
+#define SYS_READAT 72 // Read from an open file (with offset)
+#define SYS_WRITE 73 // Write to an open file
+#define SYS_WRITEAT 74 // Write to an open file (with offset)
+#define SYS_IOCTL 75 // Perform an IOCtl Call
+#define SYS_SEEK 76 // Seek to a new position in the file
+#define SYS_READDIR 77 // Read from an open directory
+#define SYS_GETACL 78 // Get an ACL Value
+#define SYS_SETACL 79 // Set an ACL Value
+#define SYS_FINFO 80 // Get file information
+#define SYS_MKDIR 81 // Create a new directory
+#define SYS_LINK 82 // Create a new link to a file
+#define SYS_SYMLINK 83 // Create a symbolic link
+#define SYS_UNLINK 84 // Delete a file
+#define SYS_TELL 85 // Return the current file position
+#define SYS_CHDIR 86 // Change current directory
+#define SYS_GETCWD 87 // Get current directory
+#define SYS_MOUNT 88 // Mount a filesystem
+#define SYS_SELECT 89 // Wait for file handles
-#define NUM_SYSCALLS 88
+#define NUM_SYSCALLS 90
#define SYS_DEBUG 0x100
#define SYS_DEBUGHEX 0x101
"SYS_COPYFD",
"SYS_FDCTL",
"SYS_READ",
+ "SYS_READAT",
"SYS_WRITE",
+ "SYS_WRITEAT",
"SYS_IOCTL",
"SYS_SEEK",
"SYS_READDIR",
%define SYS_COPYFD 69 ;Create a copy of a file handle
%define SYS_FDCTL 70 ;Modify flags of a file descriptor
%define SYS_READ 71 ;Read from an open file
-%define SYS_WRITE 72 ;Write to an open file
-%define SYS_IOCTL 73 ;Perform an IOCtl Call
-%define SYS_SEEK 74 ;Seek to a new position in the file
-%define SYS_READDIR 75 ;Read from an open directory
-%define SYS_GETACL 76 ;Get an ACL Value
-%define SYS_SETACL 77 ;Set an ACL Value
-%define SYS_FINFO 78 ;Get file information
-%define SYS_MKDIR 79 ;Create a new directory
-%define SYS_LINK 80 ;Create a new link to a file
-%define SYS_SYMLINK 81 ;Create a symbolic link
-%define SYS_UNLINK 82 ;Delete a file
-%define SYS_TELL 83 ;Return the current file position
-%define SYS_CHDIR 84 ;Change current directory
-%define SYS_GETCWD 85 ;Get current directory
-%define SYS_MOUNT 86 ;Mount a filesystem
-%define SYS_SELECT 87 ;Wait for file handles
+%define SYS_READAT 72 ;Read from an open file (with offset)
+%define SYS_WRITE 73 ;Write to an open file
+%define SYS_WRITEAT 74 ;Write to an open file (with offset)
+%define SYS_IOCTL 75 ;Perform an IOCtl Call
+%define SYS_SEEK 76 ;Seek to a new position in the file
+%define SYS_READDIR 77 ;Read from an open directory
+%define SYS_GETACL 78 ;Get an ACL Value
+%define SYS_SETACL 79 ;Set an ACL Value
+%define SYS_FINFO 80 ;Get file information
+%define SYS_MKDIR 81 ;Create a new directory
+%define SYS_LINK 82 ;Create a new link to a file
+%define SYS_SYMLINK 83 ;Create a symbolic link
+%define SYS_UNLINK 84 ;Delete a file
+%define SYS_TELL 85 ;Return the current file position
+%define SYS_CHDIR 86 ;Change current directory
+%define SYS_GETCWD 87 ;Get current directory
+%define SYS_MOUNT 88 ;Mount a filesystem
+%define SYS_SELECT 89 ;Wait for file handles
if(tmp[i]) break;\
} while(0)
+#if BITS==64
+#define ARG64(idx1,idx2) ***ARG64 not used on 64-bit***
+#else
+#define ARG64(idx1, idx2) (Regs->Arg##idx1|(((Uint64)Regs->Arg##idx2)<<32))
+#endif
+
// === IMPORTS ===
extern Uint Binary_Load(const char *file, Uint *entryPoint);
#if BITS == 64
ret = VFS_Seek( Regs->Arg1, Regs->Arg2, Regs->Arg3 );
#else
- ret = VFS_Seek( Regs->Arg1, Regs->Arg2|(((Uint64)Regs->Arg3)<<32), Regs->Arg4 );
+ ret = VFS_Seek( Regs->Arg1, ARG64(2, 3), Regs->Arg4 );
#endif
break;
CHECK_NUM_NONULL( (void*)Regs->Arg2, Regs->Arg3 );
ret = VFS_Write( Regs->Arg1, Regs->Arg3, (void*)Regs->Arg2 );
break;
+ case SYS_WRITEAT:
+ #if BITS == 64
+ CHECK_NUM_NONULL( (void*)Regs->Arg5, Regs->Arg3 );
+ ret = VFS_WriteAt( Regs->Arg1, Regs->Arg2, Regs->Arg3, (void*)Regs->Arg4 );
+ #else
+ CHECK_NUM_NONULL( (void*)Regs->Arg5, Regs->Arg4 );
+ Debug("VFS_WriteAt(%i, %lli, %i, %p)",
+ Regs->Arg1, ARG64(2, 3), Regs->Arg4, (void*)Regs->Arg5);
+ ret = VFS_WriteAt( Regs->Arg1, ARG64(2, 3), Regs->Arg4, (void*)Regs->Arg5 );
+ #endif
+ break;
case SYS_READ:
CHECK_NUM_NONULL( (void*)Regs->Arg2, Regs->Arg3 );
ret = VFS_Read( Regs->Arg1, Regs->Arg3, (void*)Regs->Arg2 );
break;
+ case SYS_READAT:
+ CHECK_NUM_NONULL( (void*)Regs->Arg5, Regs->Arg2 );
+ #if BITS == 64
+ ret = VFS_ReadAt( Regs->Arg1, Regs->Arg2, Regs->Arg3, (void*)Regs->Arg4 );
+ #else
+ ret = VFS_ReadAt( Regs->Arg1, Regs->Arg2, ARG64(3, 4), (void*)Regs->Arg5 );
+ #endif
+ break;
case SYS_FINFO:
CHECK_NUM_NONULL( (void*)Regs->Arg2, sizeof(tFInfo) + Regs->Arg3*sizeof(tVFS_ACL) );
SYS_COPYFD Create a copy of a file handle
SYS_FDCTL Modify flags of a file descriptor
SYS_READ Read from an open file
+SYS_READAT Read from an open file (with offset)
SYS_WRITE Write to an open file
+SYS_WRITEAT Write to an open file (with offset)
SYS_IOCTL Perform an IOCtl Call
SYS_SEEK Seek to a new position in the file
SYS_READDIR Read from an open directory
SYSCALL3(_SysFDFlags, SYS_FDCTL) // int, int, int
SYSCALL1(_SysClose, SYS_CLOSE) // int
SYSCALL3(_SysRead, SYS_READ) // int, uint, void*
+SYSCALL5(_SysReadAt, SYS_READAT) // int, uint, uint64, void*
SYSCALL3(_SysWrite, SYS_WRITE) // int, uint, void*
+SYSCALL5(_SysWriteAt, SYS_WRITEAT) // int, uint, uint64, void*
SYSCALL4(_SysSeek, SYS_SEEK) // int, uint64_t, int
SYSCALL1(_SysTell, SYS_TELL) // int
SYSCALL3(_SysFInfo, SYS_FINFO) // int, void*, int
struct ptycmd_header
{
uint8_t cmd;
+ // NOTE: Length is encoded as a count of 32-bit words
uint8_t len_low;
uint16_t len_hi;
} PACKED;
char data[];
} PACKED;
+struct ptycmd_senddata
+{
+ struct ptycmd_header hdr;
+ uint32_t ofs;
+} PACKED;
+
#endif
extern int _SysCopyFD(int srcfd, int dstfd);
extern int _SysFDFlags(int fd, int mask, int newflags);
extern size_t _SysRead(int fd, void *buffer, size_t length);
+extern size_t _SysReadAt(int fd, uint64_t offset, size_t length, void *buffer);
extern int _SysClose(int fd);
extern int _SysFDCtl(int fd, int option, ...);
extern size_t _SysWrite(int fd, const void *buffer, size_t length);
+extern size_t _SysWriteAt(int fd, uint64_t offset, size_t length, const void *buffer);
extern int _SysSeek(int fd, int64_t offset, int whence);
extern uint64_t _SysTell(int fd);
extern int _SysIOCtl(int fd, int id, void *data);