diff --git a/kernel-src/arch/x86-64/syscall.asm b/kernel-src/arch/x86-64/syscall.asm index d06319f8..1ac411c8 100644 --- a/kernel-src/arch/x86-64/syscall.asm +++ b/kernel-src/arch/x86-64/syscall.asm @@ -7,6 +7,7 @@ extern syscall_seek extern syscall_close extern syscall_archctl extern syscall_write +extern syscall_getpid syscalltab: dq syscall_print dq syscall_mmap @@ -16,7 +17,8 @@ dq syscall_seek dq syscall_close dq syscall_archctl dq syscall_write -syscallcount equ 8 +dq syscall_getpid +syscallcount equ 9 section .text global arch_syscall_entry ; on entry: diff --git a/kernel-src/sys/syscalls/getpid.c b/kernel-src/sys/syscalls/getpid.c new file mode 100644 index 00000000..c30d225c --- /dev/null +++ b/kernel-src/sys/syscalls/getpid.c @@ -0,0 +1,10 @@ +#include +#include + +syscallret_t syscall_getpid(context_t *ctx) { + syscallret_t ret = { + .ret = _cpu()->thread->proc->pid, + .errno = 0 + }; + return ret; +} diff --git a/patches/mlibc/jinx-working-patch.patch b/patches/mlibc/jinx-working-patch.patch index 45015c4f..abe5fd36 100644 --- a/patches/mlibc/jinx-working-patch.patch +++ b/patches/mlibc/jinx-working-patch.patch @@ -133,10 +133,10 @@ index 0000000..e5b087a + diff --git mlibc-workdir/sysdeps/astral/generic/generic.cpp mlibc-workdir/sysdeps/astral/generic/generic.cpp new file mode 100644 -index 0000000..30fd3b0 +index 0000000..81ba749 --- /dev/null +++ mlibc-workdir/sysdeps/astral/generic/generic.cpp -@@ -0,0 +1,157 @@ +@@ -0,0 +1,163 @@ +#include +#include +#include @@ -200,6 +200,12 @@ index 0000000..30fd3b0 + return 0; + } + ++ pid_t sys_getpid() { ++ long ret; ++ syscall(SYSCALL_GETPID, &ret); ++ return ret; ++ } ++ + void sys_libc_log(const char *message) { + long ret; + syscall(SYSCALL_PRINT, &ret, (uint64_t)message); @@ -313,10 +319,10 @@ index 0000000..990eca0 +#endif diff --git mlibc-workdir/sysdeps/astral/include/astral/syscall.h mlibc-workdir/sysdeps/astral/include/astral/syscall.h new file mode 100644 -index 0000000..ce00d62 +index 0000000..fe5ea34 --- /dev/null +++ mlibc-workdir/sysdeps/astral/include/astral/syscall.h -@@ -0,0 +1,31 @@ +@@ -0,0 +1,32 @@ +#ifndef _SYSCALL_H_INCLUDE +#define _SYSCALL_H_INCLUDE + @@ -328,6 +334,7 @@ index 0000000..ce00d62 +#define SYSCALL_CLOSE 5 +#define SYSCALL_ARCHCTL 6 +#define SYSCALL_WRITE 7 ++#define SYSCALL_GETPID 8 + +#include +#include