#ifndef ULIB_SYSTEM_SYSTEM_H_
#define ULIB_SYSTEM_SYSTEM_H_

#include <stdint.h>
#include <stddef.h>
#include <stdbool.h>
#include <sysdefs/dev.h>
#include <sysdefs/proc.h>
#include <sysdefs/fs.h>
#include <sysdefs/time.h>
#include <sysdefs/ipcnetsock.h>

void debugprint(const char *string);
int32_t mman_map(uint8_t *addr, size_t size, uint64_t prot, uint64_t flags, uint8_t **out);
int32_t mman_unmap(uint8_t *addr);
int32_t schedrelease(void);
int32_t rand(void);
int32_t vfsmount(char *mountpoint, char *fstype, Dev_t *dev, bool format);
int32_t vfsunmount(char *mountpoint);
int32_t ipc_piperead(PID_t pid, uint64_t pipenum, uint8_t *const buffer, size_t len);
int32_t ipc_pipewrite(PID_t pid, uint64_t pipenum, const uint8_t *buffer, size_t len);
int32_t ipc_pipemake(uint64_t pipenum);
int32_t ipc_pipedelete(uint64_t pipenum);
int32_t ipc_pipeconnect(PID_t pid1, uint64_t pipenum1, PID_t pid2, uint64_t pipenum2);
int32_t proc_kill(PID_t pid);
int32_t proc_spawn(char *path, char **args1, size_t argslen1);
int32_t proc_pollstate(PID_t pid);
int32_t proc_getpid(void);
int32_t proc_run(PID_t pid);
int32_t proc_arglen(PID_t pid);
int32_t proc_argv(PID_t pid, size_t *argslen1, char **argbuf1, size_t maxargs);
int32_t proc_listsize(void);
int32_t proc_stat(size_t idx, ProcStat *pstat);
int32_t fs_openf(char *path, uint64_t flags);
int32_t fs_closef(int32_t fsh);
int32_t fs_write(int32_t fsh, const uint8_t *buffer, size_t len, size_t off);
int32_t fs_read(int32_t fsh, uint8_t *const buffer, size_t len, size_t off);
int32_t fs_stat(char *path, FsStat *statbuf);
int32_t fs_fetchdirent(char *path, FsDirent *direntbuf, size_t idx);
int32_t fs_mkdir(char *path);
int32_t fs_delete(char *path);
int32_t dev_gethandle(Dev_t *dev, char *name);
int32_t dev_listsize(void);
int32_t dev_stat(DevStat *devstatbuf, size_t idx);
int32_t dev_cmd(Dev_t *dev, uint64_t cmd, void *buf, size_t len);
int32_t time(Time *time);
int32_t ipc_netsockmake(uint16_t net, uint16_t proto, uint16_t port);
int32_t ipc_netsocklisten(uint64_t netsock, size_t maxlisteners);
int32_t ipc_netsockpollev(uint64_t netsock);

#endif // ULIB_SYSTEM_SYSTEM_H_
