mirror of
https://github.com/Mathewnd/Astral.git
synced 2026-11-01 23:18:21 +00:00
syscall: allow userspace to call new system calls
This commit is contained in:
@@ -16,6 +16,10 @@ extern syscall_exit
|
|||||||
extern syscall_waitpid
|
extern syscall_waitpid
|
||||||
extern syscall_munmap
|
extern syscall_munmap
|
||||||
extern syscall_getdents
|
extern syscall_getdents
|
||||||
|
extern syscall_dup
|
||||||
|
extern syscall_dup2
|
||||||
|
extern syscall_dup3
|
||||||
|
extern syscall_fcntl
|
||||||
syscalltab:
|
syscalltab:
|
||||||
dq syscall_print
|
dq syscall_print
|
||||||
dq syscall_mmap
|
dq syscall_mmap
|
||||||
@@ -34,7 +38,11 @@ dq syscall_exit
|
|||||||
dq syscall_waitpid
|
dq syscall_waitpid
|
||||||
dq syscall_munmap
|
dq syscall_munmap
|
||||||
dq syscall_getdents
|
dq syscall_getdents
|
||||||
syscallcount equ 17
|
dq syscall_dup
|
||||||
|
dq syscall_dup2
|
||||||
|
dq syscall_dup3
|
||||||
|
dq syscall_fcntl
|
||||||
|
syscallcount equ 21
|
||||||
section .text
|
section .text
|
||||||
global arch_syscall_entry
|
global arch_syscall_entry
|
||||||
; on entry:
|
; on entry:
|
||||||
|
|||||||
@@ -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..c177a55
|
index 0000000..74b6be1
|
||||||
--- /dev/null
|
--- /dev/null
|
||||||
+++ mlibc-workdir/sysdeps/astral/generic/generic.cpp
|
+++ mlibc-workdir/sysdeps/astral/generic/generic.cpp
|
||||||
@@ -0,0 +1,206 @@
|
@@ -0,0 +1,226 @@
|
||||||
+#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>
|
||||||
@@ -192,6 +192,26 @@ index 0000000..c177a55
|
|||||||
+ return 0;
|
+ return 0;
|
||||||
+ }
|
+ }
|
||||||
+
|
+
|
||||||
|
+ int sys_fcntl(int fd, int request, va_list args, int *result) {
|
||||||
|
+ long arg = va_arg(args, uint64_t);
|
||||||
|
+ long ret;
|
||||||
|
+ long err = syscall(SYSCALL_FCNTL, &ret, fd, request, arg);
|
||||||
|
+ *result = ret;
|
||||||
|
+ return err;
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
+ int sys_dup(int fd, int flags, int *newfd) {
|
||||||
|
+ long ret;
|
||||||
|
+ long err = syscall(SYSCALL_DUP, &ret, fd);
|
||||||
|
+ *newfd = ret;
|
||||||
|
+ return err;
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
+ int sys_dup2(int fd, int flags, int newfd) {
|
||||||
|
+ long ret;
|
||||||
|
+ return syscall(SYSCALL_DUP2, &ret, fd, newfd);
|
||||||
|
+ }
|
||||||
|
+
|
||||||
+ int sys_read_entries(int handle, void *buffer, size_t max_size, size_t *bytes_read) {
|
+ int sys_read_entries(int handle, void *buffer, size_t max_size, size_t *bytes_read) {
|
||||||
+ long ret;
|
+ long ret;
|
||||||
+ long err = syscall(SYSCALL_GETDENTS, &ret, handle, (uint64_t)buffer, max_size);
|
+ long err = syscall(SYSCALL_GETDENTS, &ret, handle, (uint64_t)buffer, max_size);
|
||||||
@@ -362,10 +382,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..6b0e993
|
index 0000000..f884f36
|
||||||
--- /dev/null
|
--- /dev/null
|
||||||
+++ mlibc-workdir/sysdeps/astral/include/astral/syscall.h
|
+++ mlibc-workdir/sysdeps/astral/include/astral/syscall.h
|
||||||
@@ -0,0 +1,40 @@
|
@@ -0,0 +1,44 @@
|
||||||
+#ifndef _SYSCALL_H_INCLUDE
|
+#ifndef _SYSCALL_H_INCLUDE
|
||||||
+#define _SYSCALL_H_INCLUDE
|
+#define _SYSCALL_H_INCLUDE
|
||||||
+
|
+
|
||||||
@@ -386,6 +406,10 @@ index 0000000..6b0e993
|
|||||||
+#define SYSCALL_WAITPID 14
|
+#define SYSCALL_WAITPID 14
|
||||||
+#define SYSCALL_MUNMAP 15
|
+#define SYSCALL_MUNMAP 15
|
||||||
+#define SYSCALL_GETDENTS 16
|
+#define SYSCALL_GETDENTS 16
|
||||||
|
+#define SYSCALL_DUP 17
|
||||||
|
+#define SYSCALL_DUP2 18
|
||||||
|
+#define SYSCALL_DUP3 19
|
||||||
|
+#define SYSCALL_FCNTL 20
|
||||||
+
|
+
|
||||||
+#include <stddef.h>
|
+#include <stddef.h>
|
||||||
+#include <stdint.h>
|
+#include <stdint.h>
|
||||||
|
|||||||
Reference in New Issue
Block a user