diff options
author | Freya Murphy <freya@freyacat.org> | 2025-04-30 21:07:46 -0400 |
---|---|---|
committer | Freya Murphy <freya@freyacat.org> | 2025-05-01 15:51:32 -0400 |
commit | 1a10a3725e7bea67e558715f6e9f78abcb415b3a (patch) | |
tree | 1f35cf35f61cd58a86f2a8e7ea14c565db20a211 /user/lib | |
parent | tarfs (diff) | |
download | comus-1a10a3725e7bea67e558715f6e9f78abcb415b3a.tar.gz comus-1a10a3725e7bea67e558715f6e9f78abcb415b3a.tar.bz2 comus-1a10a3725e7bea67e558715f6e9f78abcb415b3a.zip |
finish syscall impls
Diffstat (limited to 'user/lib')
-rw-r--r-- | user/lib/entry.S | 5 | ||||
-rw-r--r-- | user/lib/fclose.c | 10 | ||||
-rw-r--r-- | user/lib/fseek.c | 16 | ||||
-rw-r--r-- | user/lib/syscall.S | 3 |
4 files changed, 31 insertions, 3 deletions
diff --git a/user/lib/entry.S b/user/lib/entry.S index 40570b5..efaa652 100644 --- a/user/lib/entry.S +++ b/user/lib/entry.S @@ -5,7 +5,6 @@ .section .text .code64 _start: - call main - subq $16, %rsp # ??? - pushq %rax + call main + movq %rax, %rdi call exit diff --git a/user/lib/fclose.c b/user/lib/fclose.c new file mode 100644 index 0000000..be31421 --- /dev/null +++ b/user/lib/fclose.c @@ -0,0 +1,10 @@ +#include <stdio.h> +#include <unistd.h> + +void fclose(FILE *stream) +{ + int fd; + + fd = (uintptr_t)stream; + close(fd); +} diff --git a/user/lib/fseek.c b/user/lib/fseek.c new file mode 100644 index 0000000..a7a3377 --- /dev/null +++ b/user/lib/fseek.c @@ -0,0 +1,16 @@ +#include <stdio.h> +#include <unistd.h> + +int fseek(FILE *stream, long off, int whence) +{ + int fd; + fd = (uintptr_t)stream; + return seek(fd, off, whence); +} + +long ftell(FILE *stream) +{ + int fd; + fd = (uintptr_t)stream; + return seek(fd, 0, SEEK_CUR); +} diff --git a/user/lib/syscall.S b/user/lib/syscall.S index 2ba4dc0..9f7025e 100644 --- a/user/lib/syscall.S +++ b/user/lib/syscall.S @@ -13,6 +13,8 @@ SYSCALL exit SYS_exit SYSCALL waitpid SYS_waitpid SYSCALL fork SYS_fork SYSCALL exec SYS_exec +SYSCALL open SYS_open +SYSCALL close SYS_close SYSCALL read SYS_read SYSCALL write SYS_write SYSCALL getpid SYS_getpid @@ -27,3 +29,4 @@ SYSCALL sbrk SYS_sbrk SYSCALL poweroff SYS_poweroff SYSCALL drm SYS_drm SYSCALL ticks SYS_ticks +SYSCALL seek SYS_seek |