#include #include #include #include uint64_t syscall(int num, ...); uint64_t OSTime() { return syscall(SYSCALL_TIME); } void OSExit(int status) { syscall(SYSCALL_EXIT); } uint64_t OSGetPID() { return syscall(SYSCALL_GETPID); } uint64_t OSSpawn(const char *path) { return syscall(SYSCALL_SPAWN, path); } uint64_t OSWait(uint64_t pid) { return syscall(SYSCALL_WAIT, pid); } void * OSMemMap(void *addr, uint64_t len, int flags) { return (void *)syscall(SYSCALL_MMAP, addr, len, flags); } int OSMemUnmap(void *addr, uint64_t len) { return syscall(SYSCALL_MUNMAP, addr, len); } int OSMemProtect(void *addr, uint64_t len, int flags) { return syscall(SYSCALL_MPROTECT, addr, len, flags); } int OSRead(uint64_t fd, void *addr, uint64_t off, uint64_t length) { return syscall(SYSCALL_READ, fd, addr, off, length); } int OSWrite(uint64_t fd, const void *addr, uint64_t off, uint64_t length) { return syscall(SYSCALL_WRITE, fd, addr, off, length); } int OSFlush(uint64_t fd) { return syscall(SYSCALL_FLUSH, fd); } uint64_t OSOpen(const char *path, uint64_t flags) { return syscall(SYSCALL_OPEN, path, flags); } int OSClose(uint64_t fd) { return syscall(SYSCALL_CLOSE, fd); } int OSStat(const char *path, struct stat *sb) { return syscall(SYSCALL_STAT, path, sb); } int OSReadDir(uint64_t fd, char *buf, size_t length, uint64_t *offset) { return syscall(SYSCALL_READDIR, fd, buf, length, offset); } int OSThreadCreate(uint64_t rip, uint64_t arg) { return syscall(SYSCALL_THREADCREATE, rip, arg); } int OSThreadExit(uint64_t status) { return syscall(SYSCALL_THREADEXIT, status); } int OSThreadSleep(uint64_t time) { return syscall(SYSCALL_THREADSLEEP, time); } int OSThreadWait(uint64_t tid) { return syscall(SYSCALL_THREADWAIT, tid); } int OSNICStat(uint64_t nicNo, NIC *nic) { return syscall(SYSCALL_NICSTAT, nicNo, nic); } int OSNICSend(uint64_t nicNo, MBuf *mbuf) { return syscall(SYSCALL_NICSEND, nicNo, mbuf); } int OSNICRecv(uint64_t nicNo, MBuf *mbuf) { return syscall(SYSCALL_NICRECV, nicNo, mbuf); }