mirror of
https://github.com/Mathewnd/Astral.git
synced 2026-11-01 23:18:21 +00:00
kernel: getpid syscall
This commit is contained in:
@@ -7,6 +7,7 @@ extern syscall_seek
|
|||||||
extern syscall_close
|
extern syscall_close
|
||||||
extern syscall_archctl
|
extern syscall_archctl
|
||||||
extern syscall_write
|
extern syscall_write
|
||||||
|
extern syscall_getpid
|
||||||
syscalltab:
|
syscalltab:
|
||||||
dq syscall_print
|
dq syscall_print
|
||||||
dq syscall_mmap
|
dq syscall_mmap
|
||||||
@@ -16,7 +17,8 @@ dq syscall_seek
|
|||||||
dq syscall_close
|
dq syscall_close
|
||||||
dq syscall_archctl
|
dq syscall_archctl
|
||||||
dq syscall_write
|
dq syscall_write
|
||||||
syscallcount equ 8
|
dq syscall_getpid
|
||||||
|
syscallcount equ 9
|
||||||
section .text
|
section .text
|
||||||
global arch_syscall_entry
|
global arch_syscall_entry
|
||||||
; on entry:
|
; on entry:
|
||||||
|
|||||||
@@ -0,0 +1,10 @@
|
|||||||
|
#include <kernel/syscalls.h>
|
||||||
|
#include <arch/cpu.h>
|
||||||
|
|
||||||
|
syscallret_t syscall_getpid(context_t *ctx) {
|
||||||
|
syscallret_t ret = {
|
||||||
|
.ret = _cpu()->thread->proc->pid,
|
||||||
|
.errno = 0
|
||||||
|
};
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
@@ -133,10 +133,10 @@ index 0000000..e5b087a
|
|||||||
+
|
+
|
||||||
diff --git mlibc-workdir/sysdeps/astral/generic/generic.cpp mlibc-workdir/sysdeps/astral/generic/generic.cpp
|
diff --git mlibc-workdir/sysdeps/astral/generic/generic.cpp mlibc-workdir/sysdeps/astral/generic/generic.cpp
|
||||||
new file mode 100644
|
new file mode 100644
|
||||||
index 0000000..30fd3b0
|
index 0000000..81ba749
|
||||||
--- /dev/null
|
--- /dev/null
|
||||||
+++ mlibc-workdir/sysdeps/astral/generic/generic.cpp
|
+++ mlibc-workdir/sysdeps/astral/generic/generic.cpp
|
||||||
@@ -0,0 +1,157 @@
|
@@ -0,0 +1,163 @@
|
||||||
+#include <bits/ensure.h>
|
+#include <bits/ensure.h>
|
||||||
+#include <mlibc/debug.hpp>
|
+#include <mlibc/debug.hpp>
|
||||||
+#include <mlibc/all-sysdeps.hpp>
|
+#include <mlibc/all-sysdeps.hpp>
|
||||||
@@ -200,6 +200,12 @@ index 0000000..30fd3b0
|
|||||||
+ return 0;
|
+ return 0;
|
||||||
+ }
|
+ }
|
||||||
+
|
+
|
||||||
|
+ pid_t sys_getpid() {
|
||||||
|
+ long ret;
|
||||||
|
+ syscall(SYSCALL_GETPID, &ret);
|
||||||
|
+ return ret;
|
||||||
|
+ }
|
||||||
|
+
|
||||||
+ void sys_libc_log(const char *message) {
|
+ void sys_libc_log(const char *message) {
|
||||||
+ long ret;
|
+ long ret;
|
||||||
+ syscall(SYSCALL_PRINT, &ret, (uint64_t)message);
|
+ syscall(SYSCALL_PRINT, &ret, (uint64_t)message);
|
||||||
@@ -313,10 +319,10 @@ index 0000000..990eca0
|
|||||||
+#endif
|
+#endif
|
||||||
diff --git mlibc-workdir/sysdeps/astral/include/astral/syscall.h mlibc-workdir/sysdeps/astral/include/astral/syscall.h
|
diff --git mlibc-workdir/sysdeps/astral/include/astral/syscall.h mlibc-workdir/sysdeps/astral/include/astral/syscall.h
|
||||||
new file mode 100644
|
new file mode 100644
|
||||||
index 0000000..ce00d62
|
index 0000000..fe5ea34
|
||||||
--- /dev/null
|
--- /dev/null
|
||||||
+++ mlibc-workdir/sysdeps/astral/include/astral/syscall.h
|
+++ mlibc-workdir/sysdeps/astral/include/astral/syscall.h
|
||||||
@@ -0,0 +1,31 @@
|
@@ -0,0 +1,32 @@
|
||||||
+#ifndef _SYSCALL_H_INCLUDE
|
+#ifndef _SYSCALL_H_INCLUDE
|
||||||
+#define _SYSCALL_H_INCLUDE
|
+#define _SYSCALL_H_INCLUDE
|
||||||
+
|
+
|
||||||
@@ -328,6 +334,7 @@ index 0000000..ce00d62
|
|||||||
+#define SYSCALL_CLOSE 5
|
+#define SYSCALL_CLOSE 5
|
||||||
+#define SYSCALL_ARCHCTL 6
|
+#define SYSCALL_ARCHCTL 6
|
||||||
+#define SYSCALL_WRITE 7
|
+#define SYSCALL_WRITE 7
|
||||||
|
+#define SYSCALL_GETPID 8
|
||||||
+
|
+
|
||||||
+#include <stddef.h>
|
+#include <stddef.h>
|
||||||
+#include <stdint.h>
|
+#include <stdint.h>
|
||||||
|
|||||||
Reference in New Issue
Block a user