metal-cos/lib/libc/syscall.c

76 lines
1.1 KiB
C

#include <stdbool.h>
#include <stdint.h>
#include <sys/syscall.h>
#include <syscall.h>
uint64_t syscall(int num, ...);
uint64_t
SystemTime()
{
return syscall(SYSCALL_TIME);
}
void
SystemExit(int status)
{
syscall(SYSCALL_EXIT);
}
uint64_t
SystemGetPID()
{
return syscall(SYSCALL_GETPID);
}
void *
SystemMemMap(void *addr, uint64_t len, int flags)
{
return (void *)syscall(SYSCALL_MMAP, addr, len, flags);
}
int
SystemMemUnmap(void *addr, uint64_t len)
{
return syscall(SYSCALL_MUNMAP, addr, len);
}
int
SystemMemProtect(void *addr, uint64_t len, int flags)
{
return syscall(SYSCALL_MPROTECT, addr, len, flags);
}
int
SystemRead(uint64_t fd, void *addr, uint64_t off, uint64_t length)
{
return syscall(SYSCALL_READ, fd, addr, off, length);
}
int
SystemWrite(uint64_t fd, const void *addr, uint64_t off, uint64_t length)
{
return syscall(SYSCALL_WRITE, fd, addr, off, length);
}
int
SystemFlush(uint64_t fd)
{
return syscall(SYSCALL_FLUSH, fd);
}
uint64_t
SystemOpen(const char *path, uint64_t flags)
{
return syscall(SYSCALL_OPEN, path, flags);
}
int
SystemClose(uint64_t fd)
{
return syscall(SYSCALL_CLOSE, fd);
}