UCQs now use mcs_pdr_locks (XCC)
[akaros.git] / kern / include / ros / syscall.h
index 28f6ff0..5c3d8e9 100644 (file)
@@ -1,22 +1,23 @@
-#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 <arch/atomic.h>
+#include <ros/atomic.h>
 
 /* Flags for an individual syscall.
  * Careful, sparc can't handle flags in byte 3. */
 #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 */
 
 struct syscall {
        unsigned int                            num;
-       long                                            retval;
        int                                                     err;                    /* errno */
+       long                                            retval;
        atomic_t                                        flags;
        struct event_queue                      *ev_q;
        void                                            *u_data;
@@ -30,6 +31,8 @@ struct syscall {
 
 #ifndef ROS_KERNEL
 
+#include <arch/atomic.h>
+
 /* Attempts to block on sysc, returning when it is done or progress has been
  * made. */
 void ros_syscall_blockon(struct syscall *sysc);
@@ -64,6 +67,10 @@ static inline long __ros_syscall(unsigned int _num, long _a0, long _a1, long _a2
        /* Don't proceed til we are done */
        while (!(atomic_read(&sysc.flags) & SC_DONE))
                ros_syscall_blockon(&sysc);
+       /* Need to wait til it is unlocked.  It's not really done until SC_DONE &
+        * !SC_K_LOCK. */
+       while (atomic_read(&sysc.flags) & SC_K_LOCK)
+               cpu_relax();
        if (errno_loc)
                *errno_loc = sysc.err;
        return sysc.retval;
@@ -85,4 +92,4 @@ static inline long __ros_syscall_errno(unsigned int _num, long _a0, long _a1,
 
 #endif /* ifndef ROS_KERNEL */
 
-#endif /* !ROS_INCLUDE_SYSCALL_H */
+#endif /* ROS_INC_SYSCALL_H */