2 * Acess2 System Interface Header
8 #include <stddef.h> // size_t
9 #include "syscall_types.h"
13 # define NULL ((void*)0)
16 #define THREAD_EVENT_VFS 0x0001
17 #define THREAD_EVENT_IPCMSG 0x0002
18 #define THREAD_EVENT_SIGNAL 0x0004
20 #define OPENFLAG_EXEC 0x01
21 #define OPENFLAG_READ 0x02
22 #define OPENFLAG_WRITE 0x04
23 #define OPENFLAG_RDWR (OPENFLAG_READ|OPENFLAG_WRITE)
24 #define OPENFLAG_TRUNCATE 0x10
25 #define OPENFLAG_APPEND 0x20
26 #define OPENFLAG_NOLINK 0x40
27 #define OPENFLAG_CREATE 0x80
28 #define OPENFLAG_NONBLOCK 0x100 // How would this work?
34 #define GETMSG_IGNORE ((void*)-1)
35 #define FILEFLAG_DIRECTORY 0x10
36 #define FILEFLAG_SYMLINK 0x20
39 #ifdef ARCHDIR_is_native
40 # include "_native_syscallmod.h"
49 extern void _SysDebug(const char *format, ...);
51 extern void _exit(int status) __attribute__((noreturn));
52 extern int _SysKill(int pid, int sig);
53 extern int _SysWaitEvent(int EventMask);
54 extern int _SysWaitTID(int id, int *status);
55 extern int _SysClone(int flags, void *stack);
56 extern int _SysExecVE(const char *path, char **argv, char **envp);
57 extern int _SysSpawn(const char *Path, const char **argv, const char **envp, int nFDs, int *FDs, struct s_sys_spawninfo *info);
58 extern int gettid(void);
59 extern int _SysGetPID(void);
60 extern int _SysSetFaultHandler(int (*Handler)(int));
61 extern void _SysSetName(const char *Name);
62 extern int _SysGetName(char *NameDest);
63 extern int _SysSetPri(int Priority);
65 extern int _SysLoadModule(const char *Module);
66 // --- Timekeeping ---
67 extern int64_t _SysTimestamp(void);
68 extern void _SysTimedSleep(int64_t Delay);
70 // --- Permissions ---
71 extern int _SysGetUID(void);
72 extern int _SysGetGID(void);
73 extern void setuid(int id);
74 extern void setgid(int id);
77 extern int _SysChdir(const char *dir);
78 extern int _SysChroot(const char *dir);
80 extern int _SysOpen(const char *path, int flags, ...);
81 extern int _SysOpenChild(int fd, const char *name, int flags);
82 extern int _SysOpenPipe(int *read, int *write, int flags);
83 extern int _SysReopen(int fd, const char *path, int flags);
84 extern int _SysCopyFD(int srcfd, int dstfd);
85 extern int _SysFDFlags(int fd, int mask, int newflags);
86 extern size_t _SysRead(int fd, void *buffer, size_t length);
87 extern int _SysClose(int fd);
88 extern int _SysFDCtl(int fd, int option, ...);
89 extern size_t _SysWrite(int fd, const void *buffer, size_t length);
90 extern int _SysSeek(int fd, int64_t offset, int whence);
91 extern uint64_t _SysTell(int fd);
92 extern int _SysIOCtl(int fd, int id, void *data);
93 extern int _SysFInfo(int fd, t_sysFInfo *info, int maxacls);
94 extern int _SysReadDir(int fd, char *dest);
95 extern int _SysGetACL(int fd, t_sysACL *dest);
96 extern int _SysMount(const char *Device, const char *Directory, const char *Type, const char *Options);
97 extern int _SysSelect(int nfds, fd_set *read, fd_set *write, fd_set *err, int64_t *timeout, unsigned int extraevents);
98 //#define select(nfs, rdfds, wrfds, erfds, timeout) _SysSelect(nfs, rdfds, wrfds, erfds, timeout, 0)
99 extern int _SysMkDir(const char *dirname);
100 extern int _SysUnlink(const char *pathname);
103 extern int _SysSendMessage(int dest, size_t length, const void *Data);
104 extern int _SysGetMessage(int *src, size_t buflen, void *Data);
107 extern uint64_t _SysGetPhys(uintptr_t vaddr);
108 extern uint64_t _SysAllocate(uintptr_t vaddr);
109 extern uint32_t _SysSetMemFlags(uintptr_t vaddr, uint32_t flags, uint32_t mask);
110 extern void *_SysLoadBin(const char *path, void **entry);
111 extern int _SysUnloadBin(void *base);
112 extern void SysSetFaultHandler(int (*Hanlder)(int));