#define SYS_POLL 11
#define SYS_BIND 12
+#define SYS_EXIT 0
+#define SYS_FORK 1
+#define SYS_VFORK 2
+#define SYS_WAIT 3
+#define SYS_WAITPID 4
+#define SYS_WAITID 5
+#define SYS_SETSID 6
+
#define IPC_SEND 0
#define IPC_RECV 1
#define IPC_SENDRECV 2
void sched_tick(void);
extern int sys_cxnet(long, long, long, long, long, long, long);
extern int sys_cxipc(long, long, long);
+#if FEATURE(POSIX)
+extern int sys_posixcall(long, long, long, long, long, long, long);
+#endif /* FEATURE(POSIX) */
static const char *_exc_name[] = {
"#DE", "#DB", "NMI", "#BP", "#OF", "#BR", "#UD", "#NM", "#DF", "#MF",
#if FEATURE(POSIX)
case SYS_VECTOR_POSIX:
- dbg_printf("_posix_call(0x%x, 0x%x, 0x%x);\n", ctx.eax, ctx.ebx, ctx.ecx);
+ ret_val = sys_posixcall(ctx.eax, ctx.ebx, ctx.ecx, ctx.edx, ctx.esi, ctx.edi, ctx.ebp);
break;
#endif /* FEATURE(POSIX) */
-OBJECTS = main.o process.o sched.o cxnet.o socket.o cxipc.o syscall.o
+OBJECTS = main.o process.o sched.o cxnet.o socket.o cxipc.o syscall.o posixcall.o
OUTPUT = core.o
INCLUDES = -I../include -I../../include -I../..
CFLAGS += $(INCLUDES)
--- /dev/null
+#include <config.h>
+
+#if FEATURE(POSIX)
+
+#include <corax/errno.h>
+#include <corax/syscall.h>
+#include <corax/types.h>
+
+int sys_exit(int status)
+{
+ return(-ENOSYS);
+}
+
+int sys_fork(void)
+{
+ return(-ENOSYS);
+}
+
+int sys_vfork(void)
+{
+ return(-ENOSYS);
+}
+
+int sys_wait(int *status)
+{
+ return(-ENOSYS);
+}
+
+int sys_waitpid(pid_t pid, int *status, int options)
+{
+ return(-ENOSYS);
+}
+
+int sys_setsid(void)
+{
+ return(-ENOSYS);
+}
+
+int sys_posixcall(long vec, long arg1, long arg2, long arg3, long arg4, long arg5, long arg6)
+{
+ int ret_val;
+
+ ret_val = -EFAULT;
+
+ switch(vec) {
+ case SYS_EXIT:
+ ret_val = sys_exit((int)arg1);
+ break;
+
+ case SYS_FORK:
+ ret_val = sys_fork();
+ break;
+
+ case SYS_VFORK:
+ ret_val = sys_vfork();
+ break;
+
+ case SYS_WAIT:
+ ret_val = sys_wait((int*)arg1);
+ break;
+
+ case SYS_WAITPID:
+ ret_val = sys_waitpid((pid_t)arg1, (int*)arg2, (int)arg3);
+ break;
+
+ case SYS_WAITID:
+ ret_val = -ENOSYS;
+ break;
+
+ case SYS_SETSID:
+ ret_val = sys_setsid();
+ break;
+
+ default:
+ ret_val = -EOPNOTSUPP;
+ break;
+ }
+
+ return(ret_val);
+}
+
+#endif /* FEATURE(POSIX) */
--- /dev/null
+#define __ASSEMBLY_SOURCE
+
+#include <config.h>
+#include <corax/syscall.h>
+
+/* FIXME: Add syscall stubs for amd64/Intel64 */
+
+.global fork
+fork:
+ pushl %ebx
+
+ movl $SYS_FORK, %eax
+ int $SYSCALL_POSIX
+
+ popl %ebx
+ ret
+
+.global vfork
+vfork:
+ pushl %ebx
+
+ movl $SYS_VFORK, %eax
+ int $SYSCALL_POSIX
+
+ popl %ebx
+ ret
+
+.global exit
+exit:
+ pushl %ebx
+
+ movl $SYS_EXIT, %eax
+ movl 8(%esp), %ebx
+ int $SYSCALL_POSIX
+
+ popl %ebx
+ ret
+
+.global wait
+wait:
+ pushl %ebx
+
+ movl $SYS_WAIT, %eax
+ movl 8(%esp), %ebx
+ int $SYSCALL_POSIX
+
+ popl %ebx
+ ret
+
+.global waitpid
+waitpid:
+ pushl %ebx
+
+ movl $SYS_WAITPID, %eax
+ movl 8(%esp), %ebx
+ movl 12(%esp), %ecx
+ movl 16(%esp), %edx
+ int $SYSCALL_POSIX
+
+ popl %ebx
+ ret
+
+.global waitid
+waitid:
+ pushl %ebx
+
+ movl $SYS_WAITID, %eax
+ movl 8(%esp), %ebx
+ movl 12(%esp), %ecx
+ movl 16(%esp), %edx
+ movl 20(%esp), %esi
+ int $SYSCALL_POSIX
+
+ popl %ebx
+ ret
+
+.global setsid
+setsid:
+ pushl %ebx
+
+ movl $SYS_SETSID, %eax
+ int $SYSCALL_POSIX
+
+ popl %ebx
+ ret