Add specs for argenv interface with the kernel
[akaros.git] / kern / include / ros / syscall.h
index b4de63a..1e6d8f7 100644 (file)
@@ -1,65 +1,59 @@
-#ifndef ROS_INCLUDE_SYSCALL_H
-#define ROS_INCLUDE_SYSCALL_H
+#ifndef ROS_INC_SYSCALL_H
+#define ROS_INC_SYSCALL_H
 
-#include <arch/arch.h>
 #include <ros/bits/syscall.h>
 #include <ros/arch/syscall.h>
+#include <ros/event.h>
+#include <ros/atomic.h>
 
-/* Flags for an individual syscall */
-#define SC_DONE                                        0x0001
+/* Flags for an individual syscall. */
+#define SC_DONE                                        0x0001          /* SC is done */
+#define SC_PROGRESS                            0x0002          /* SC made progress */
+#define SC_UEVENT                              0x0004          /* user has an ev_q */
+#define SC_K_LOCK                              0x0008          /* kernel locked sysc */
+#define SC_ABORT                               0x0010          /* syscall abort attempted */
+
+#define MAX_ERRSTR_LEN                 128
 
 struct syscall {
        unsigned int                            num;
-       long                                            retval;
        int                                                     err;                    /* errno */
-       int                                                     flags;
+       long                                            retval;
+       atomic_t                                        flags;
+       struct event_queue                      *ev_q;
+       void                                            *u_data;
        long                                            arg0;
        long                                            arg1;
        long                                            arg2;
        long                                            arg3;
        long                                            arg4;
        long                                            arg5;
+       char                                            errstr[MAX_ERRSTR_LEN];
 };
 
-#ifndef ROS_KERNEL
-
-/* These are simple synchronous system calls, built on top of the kernel's async
- * interface.  This version makes no assumptions about errno.  You usually don't
- * want this. */
-static inline long __ros_syscall(long _num, long _a0, long _a1, long _a2,
-                                 long _a3, long _a4, int *errno_loc)
-{
-       int num_started;
-       struct syscall sysc = {0};
-       sysc.num = _num;
-       sysc.arg0 = _a0;
-       sysc.arg1 = _a1;
-       sysc.arg2 = _a2;
-       sysc.arg3 = _a3;
-       sysc.arg4 = _a4;
-       // TODO: arg5
-       num_started = __ros_arch_syscall(&sysc, 1, 0, 0, 0, 0);
-       while (!(sysc.flags & SC_DONE))
-               cpu_relax();
-       if (errno_loc)
-               *errno_loc = sysc.err;
-       return sysc.retval;
-}
-
-#include <errno.h>
+struct childfdmap {
+       unsigned int                            parentfd;
+       unsigned int                            childfd;
+       int                                                     ok;
+};
 
-/* This version knows about errno and will handle it. */
-static inline long __ros_syscall_errno(long _num, long _a0, long _a1, long _a2,
-                                       long _a3, long _a4)
-{
-       return __ros_syscall(_num, _a0, _a1, _a2, _a3, _a4, &errno);
-}
+struct argenv {
+       size_t argc;
+       size_t envc;
+       char buf[];
+       /* The buf array is laid out as follows:
+        * buf {
+        *   char *argv[argc]; // Offset of arg relative to &argbuf[0]
+        *   char *envp[envc]; // Offset of envvar relative to &argbuf[0]
+        *   char argbuf[sum(map(strlen + 1, argv + envp))];
+        * }
+        */
+};
 
-/* Convenience wrapper for __ros_syscall */
-#define ros_syscall(which,a0,a1,a2,a3,a4) \
-   __ros_syscall_errno(which, (long)(a0), (long)(a1), (long)(a2), (long)(a3), \
-                       (long)(a4))
+#ifndef ROS_KERNEL
 
+/* Temp hack, til the rest of glibc/userspace uses sys/syscall.h */
+#include <sys/syscall.h>
 #endif /* ifndef ROS_KERNEL */
 
-#endif /* !ROS_INCLUDE_SYSCALL_H */
+#endif /* ROS_INC_SYSCALL_H */