diff --git a/bin/shell/shell.c b/bin/shell/shell.c index 2b7ad7a..f113315 100644 --- a/bin/shell/shell.c +++ b/bin/shell/shell.c @@ -63,7 +63,7 @@ Cmd_List(int argc, const char *argv[]) return; } - fd = SystemOpen(argv[1], 0); + fd = OSOpen(argv[1], 0); if (fd < 0) { fputs("Cannot open directory\n", stdout); return; @@ -72,7 +72,7 @@ Cmd_List(int argc, const char *argv[]) while (1) { struct dirent de; - status = SystemReadDir(fd, (char *)&de, sizeof(de), &offset); + status = OSReadDir(fd, (char *)&de, sizeof(de), &offset); if (status == 0) { break; } @@ -98,17 +98,17 @@ Cmd_Cat(int argc, const char *argv[]) return; } - status = SystemStat(argv[1], &sb); + status = OSStat(argv[1], &sb); if (status != 0) { fputs("Cannot stat file\n", stdout); return; } - fd = SystemOpen(argv[1], 0); + fd = OSOpen(argv[1], 0); for (i = 0; i < sb.st_size; i += 256) { int len = (sb.st_size - i > 256) ? 256 : (sb.st_size - i); - SystemRead(fd, &buf, i, len); - SystemWrite(1, &buf, 0, len); + OSRead(fd, &buf, i, len); + OSWrite(1, &buf, 0, len); } } diff --git a/include/syscall.h b/include/syscall.h index ee12c51..271358a 100644 --- a/include/syscall.h +++ b/include/syscall.h @@ -4,29 +4,29 @@ #include -uint64_t SystemTime(); -void SystemExit(int status); -uint64_t SystemGetPID(); -uint64_t SystemSpawn(const char *path); +uint64_t OSTime(); +void OSExit(int status); +uint64_t OSGetPID(); +uint64_t OSSpawn(const char *path); // Memory -void *SystemMemMap(void *addr, uint64_t len, int flags); -int SystemMemUnmap(void *addr, uint64_t len); -int SystemMemProtect(void *addr, uint64_t len, int flags); +void *OSMemMap(void *addr, uint64_t len, int flags); +int OSMemUnmap(void *addr, uint64_t len); +int OSMemProtect(void *addr, uint64_t len, int flags); // IO -int SystemRead(uint64_t fd, void *addr, uint64_t off, uint64_t length); -int SystemWrite(uint64_t fd, const void *addr, uint64_t off, uint64_t length); -int SystemFlush(uint64_t fd); -uint64_t SystemOpen(const char *path, uint64_t flags); -int SystemClose(uint64_t fd); +int OSRead(uint64_t fd, void *addr, uint64_t off, uint64_t length); +int OSWrite(uint64_t fd, const void *addr, uint64_t off, uint64_t length); +int OSFlush(uint64_t fd); +uint64_t OSOpen(const char *path, uint64_t flags); +int OSClose(uint64_t fd); // Directory -int SystemStat(const char *path, struct stat *sb); -int SystemReadDir(uint64_t fd, char *buf, size_t length, uint64_t *offset); +int OSStat(const char *path, struct stat *sb); +int OSReadDir(uint64_t fd, char *buf, size_t length, uint64_t *offset); // Threads -int SystemThreadSleep(uint64_t time); +int OSThreadSleep(uint64_t time); #endif /* __SYSCALL_H__ */ diff --git a/lib/libc/amd64/entry.S b/lib/libc/amd64/entry.S index fa4a4da..448e144 100644 --- a/lib/libc/amd64/entry.S +++ b/lib/libc/amd64/entry.S @@ -9,6 +9,6 @@ _start: call main movq %rax, %rdi - call SystemExit + call OSExit int $3 diff --git a/lib/libc/exit.c b/lib/libc/exit.c index 9e6a14c..14d210f 100644 --- a/lib/libc/exit.c +++ b/lib/libc/exit.c @@ -40,7 +40,7 @@ exit(int status) _atexit_last = _atexit_last->next; } - SystemExit(status); + OSExit(status); __builtin_unreachable(); } diff --git a/lib/libc/file.c b/lib/libc/file.c index 896fce5..d1b80f3 100644 --- a/lib/libc/file.c +++ b/lib/libc/file.c @@ -66,7 +66,7 @@ fopen(const char *path, const char *mode) FILE *fh; // XXX: handle mode - fd = SystemOpen(path, 0); + fd = OSOpen(path, 0); if (fd == 0) return NULL; @@ -82,7 +82,7 @@ fopen(const char *path, const char *mode) int fclose(FILE *fh) { - int status = SystemClose(fh->fd); + int status = OSClose(fh->fd); _free_file(fh); @@ -102,14 +102,14 @@ fflush(FILE *fh) size_t fread(void *buf, size_t size, size_t nmemb, FILE *fh) { - return SystemRead(fh->fd, buf, 0, size * nmemb); + return OSRead(fh->fd, buf, 0, size * nmemb); // set errno } size_t fwrite(const void *buf, size_t size, size_t nmemb, FILE *fh) { - return SystemWrite(fh->fd, buf, 0, size * nmemb); + return OSWrite(fh->fd, buf, 0, size * nmemb); // set errno } diff --git a/lib/libc/syscall.c b/lib/libc/syscall.c index 26e0d8a..1030c9f 100644 --- a/lib/libc/syscall.c +++ b/lib/libc/syscall.c @@ -8,91 +8,91 @@ uint64_t syscall(int num, ...); uint64_t -SystemTime() +OSTime() { return syscall(SYSCALL_TIME); } void -SystemExit(int status) +OSExit(int status) { syscall(SYSCALL_EXIT); } uint64_t -SystemGetPID() +OSGetPID() { return syscall(SYSCALL_GETPID); } uint64_t -SystemSpawn(const char *path) +OSSpawn(const char *path) { return syscall(SYSCALL_SPAWN, path); } void * -SystemMemMap(void *addr, uint64_t len, int flags) +OSMemMap(void *addr, uint64_t len, int flags) { return (void *)syscall(SYSCALL_MMAP, addr, len, flags); } int -SystemMemUnmap(void *addr, uint64_t len) +OSMemUnmap(void *addr, uint64_t len) { return syscall(SYSCALL_MUNMAP, addr, len); } int -SystemMemProtect(void *addr, uint64_t len, int flags) +OSMemProtect(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) +OSRead(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) +OSWrite(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) +OSFlush(uint64_t fd) { return syscall(SYSCALL_FLUSH, fd); } uint64_t -SystemOpen(const char *path, uint64_t flags) +OSOpen(const char *path, uint64_t flags) { return syscall(SYSCALL_OPEN, path, flags); } int -SystemClose(uint64_t fd) +OSClose(uint64_t fd) { return syscall(SYSCALL_CLOSE, fd); } int -SystemStat(const char *path, struct stat *sb) +OSStat(const char *path, struct stat *sb) { return syscall(SYSCALL_STAT, path, sb); } int -SystemReadDir(uint64_t fd, char *buf, size_t length, uint64_t *offset) +OSReadDir(uint64_t fd, char *buf, size_t length, uint64_t *offset) { return syscall(SYSCALL_READDIR, fd, buf, length, offset); } int -SystemThreadSleep(uint64_t time) +OSThreadSleep(uint64_t time) { return syscall(SYSCALL_THREADSLEEP, time); } diff --git a/lib/libc/time.c b/lib/libc/time.c index ce255ff..aa17c38 100644 --- a/lib/libc/time.c +++ b/lib/libc/time.c @@ -17,7 +17,7 @@ static const char *months[12] = { time_t time(time_t *t) { - uint64_t nsec = SystemTime(); + uint64_t nsec = OSTime(); time_t sec = nsec / 1000000000; printf("%ld\n", nsec); @@ -31,7 +31,7 @@ time(time_t *t) int gettimeofday(struct timeval *tv, struct timezone *tz) { - uint64_t nsec = SystemTime(); + uint64_t nsec = OSTime(); tv->tv_sec = nsec / 1000000000; tv->tv_usec = (nsec % 1000000000) / 1000; diff --git a/sbin/init/init.c b/sbin/init/init.c index 16bced4..cbedd37 100644 --- a/sbin/init/init.c +++ b/sbin/init/init.c @@ -6,10 +6,10 @@ main(int argc, const char *argv[]) { fputs("Init spawning shell\n", stdout); - SystemSpawn("/bin/shell"); + OSSpawn("/bin/shell"); while (1) { - SystemThreadSleep(0); + OSThreadSleep(0); } }