]> git.corax.cc Git - corax/commitdiff
Temporarily add assembly stubs for syscalls, to avoid having to link against the...
authorMatthias Kruk <m@m10k.eu>
Sun, 27 Oct 2019 16:20:19 +0000 (01:20 +0900)
committerMatthias Kruk <m@m10k.eu>
Sun, 27 Oct 2019 16:20:19 +0000 (01:20 +0900)
kernel/core/Makefile
kernel/core/syscall.S [new file with mode: 0644]

index 2839bfcfc12fd1de06dfd9c823ba26f3020f6368..e1c8b78675f5c29b10342952340ba25262259d05 100644 (file)
@@ -1,4 +1,4 @@
-OBJECTS = main.o process.o sched.o cxnet.o socket.o cxipc.o
+OBJECTS = main.o process.o sched.o cxnet.o socket.o cxipc.o syscall.o
 OUTPUT = core.o
 INCLUDES = -I../include -I../../include -I../..
 CFLAGS += $(INCLUDES)
diff --git a/kernel/core/syscall.S b/kernel/core/syscall.S
new file mode 100644 (file)
index 0000000..8226ea6
--- /dev/null
@@ -0,0 +1,227 @@
+#define __ASSEMBLY_SOURCE
+
+#include <corax/syscall.h>
+
+.global socket
+socket:
+       pushl   %ebx
+
+       movl    $SYS_SOCKET, %eax
+       movl    8(%esp), %ebx
+       movl    12(%esp), %ecx
+       movl    16(%esp), %edx
+       int             $SYSCALL_CXNET
+
+       popl    %ebx
+       ret
+
+.global close
+close:
+       pushl   %ebx
+
+       movl    $SYS_CLOSE, %eax
+       movl    8(%esp), %ebx
+       int             $SYSCALL_CXNET
+
+       popl    %ebx
+       ret
+
+.global sendto
+sendto:
+       /*
+        * sendto() and recvfrom() have 6 arguments, so we also have
+        * to preserve the ebp register in order to repurpose it
+        */
+       pushl   %ebx
+       pushl   %ebp
+
+       movl    $SYS_SENDTO, %eax
+       movl    12(%esp), %ebx
+       movl    16(%esp), %ecx
+       movl    20(%esp), %edx
+       movl    24(%esp), %esi
+       movl    28(%esp), %edi
+       movl    32(%esp), %ebp
+       int             $SYSCALL_CXNET
+
+       popl    %ebp
+       popl    %ebx
+       ret
+
+.global recvfrom
+recvfrom:
+       pushl   %ebx
+       pushl   %ebp
+
+       movl    $SYS_RECVFROM, %eax
+       movl    12(%esp), %ebx
+       movl    16(%esp), %ecx
+       movl    20(%esp), %edx
+       movl    24(%esp), %esi
+       movl    28(%esp), %edi
+       movl    32(%esp), %ebp
+       int             $SYSCALL_CXNET
+
+       popl    %ebp
+       popl    %ebx
+       ret
+
+.global connect
+connect:
+       pushl   %ebx
+
+       movl    $SYS_CONNECT, %eax
+       movl    8(%esp), %ebx
+       movl    12(%esp), %ecx
+       movl    16(%esp), %edx
+       int             $SYSCALL_CXNET
+
+       popl    %ebx
+       ret
+
+.global listen
+listen:
+       pushl   %ebx
+
+       movl    $SYS_LISTEN, %eax
+       movl    8(%esp), %ebx
+       movl    12(%esp), %ecx
+       int             $SYSCALL_CXNET
+
+       popl    %ebx
+       ret
+
+.global accept
+accept:
+       pushl   %ebx
+
+       movl    $SYS_ACCEPT, %eax
+       movl    8(%esp), %ebx
+       movl    12(%esp), %ecx
+       movl    16(%esp), %edx
+       int             $SYSCALL_CXNET
+
+       popl    %ebx
+       ret
+
+.global setsockopt
+setsockopt:
+       pushl   %ebx
+
+       movl    $SYS_SETSOCKOPT, %eax
+       movl    8(%esp), %ebx
+       movl    12(%esp), %ecx
+       movl    16(%esp), %edx
+       movl    20(%esp), %esi
+       movl    24(%esp), %edi
+       int             $SYSCALL_CXNET
+
+       popl    %ebx
+       ret
+
+.global getsockopt
+getsockopt:
+       pushl   %ebx
+
+       movl    $SYS_GETSOCKOPT, %eax
+       movl    8(%esp), %ebx
+       movl    12(%esp), %ecx
+       movl    16(%esp), %edx
+       movl    20(%esp), %esi
+       movl    24(%esp), %edi
+       int             $SYSCALL_CXNET
+
+       popl    %ebx
+       ret
+
+.global shutdown
+shutdown:
+       pushl   %ebx
+
+       movl    $SYS_SHUTDOWN, %eax
+       movl    8(%esp), %ebx
+       movl    12(%esp), %ecx
+       int             $SYSCALL_CXNET
+
+       popl    %ebx
+       ret
+
+.global select
+select:
+       pushl   %ebx
+
+       movl    $SYS_SELECT, %eax
+       movl    8(%esp), %ebx
+       movl    12(%esp), %ecx
+       movl    16(%esp), %edx
+       movl    20(%esp), %esi
+       movl    24(%esp), %edi
+       int             $SYSCALL_CXNET
+
+       popl    %ebx
+       ret
+
+.global poll
+poll:
+       pushl   %ebx
+
+       movl    $SYS_POLL, %eax
+       movl    8(%esp), %ebx
+       movl    12(%esp), %ecx
+       movl    16(%esp), %edx
+       int             $SYSCALL_CXNET
+
+       popl    %ebx
+       ret
+
+.global bind
+bind:
+       pushl   %ebx
+
+       movl    $SYS_BIND, %eax
+       movl    8(%esp), %ebx
+       movl    12(%esp), %ecx
+       movl    16(%esp), %edx
+       int             $SYSCALL_CXNET
+
+       popl    %ebx
+       ret
+
+/* int cxsend(pid_t dst, struct ipc_msg *buf) */
+
+.global cxsend
+cxsend:
+       pushl   %ebx
+
+       movl    $IPC_SEND, %eax
+       movl    8(%esp), %ebx
+       movl    12(%esp), %ecx
+       int             $SYSCALL_CXIPC
+
+       popl    %ebx
+       ret
+
+/* int cxrecv(pid_t src, struct ipc_msg *buf) */
+.global cxrecv
+cxrecv:
+       pushl   %ebx
+
+       movl    $IPC_RECV, %eax
+       movl    8(%esp), %ebx
+       movl    12(%esp), %ecx
+       int             $SYSCALL_CXIPC
+
+       popl    %ebx
+       ret
+
+.global cxsendrecv
+cxsendrecv:
+       pushl   %ebx
+
+       movl    $IPC_SENDRECV, %eax
+       movl    8(%esp), %ebx
+       movl    12(%esp), %ecx
+       int             $SYSCALL_CXIPC
+
+       popl    %ebx
+       ret