Remove EVENT_JUSTHANDLEIT (XCC)
[akaros.git] / kern / include / ros / event.h
index d4e89fa..dee54b0 100644 (file)
@@ -9,26 +9,27 @@
 
 #include <ros/common.h>
 #include <ros/atomic.h>
-#include <ros/arch/trapframe.h>
+#include <ros/trapframe.h>
 /* #include <ros/ucq.h> included below */
 
 /* Event Delivery Flags from the process to the kernel */
-#define EVENT_IPI                              0x001   /* IPI the vcore (usually with INDIR) */
-#define EVENT_INDIR                            0x002   /* send an indirection event to vcore */
-#define EVENT_FALLBACK                 0x004   /* pick another vcore if it's offline */
-#define EVENT_NOMSG                            0x008   /* just send the bit, not the msg */
-#define EVENT_ROUNDROBIN               0x010   /* pick a vcore, RR style */
-#define EVENT_VCORE_APPRO              0x020   /* send to where the kernel wants */
-#define EVENT_NOTHROTTLE               0x040   /* send all alerts (no throttling) */
-/* Flags from the program to the 2LS */
-#define EVENT_JUSTHANDLEIT             0x100   /* 2LS should handle the ev_q */
-#define EVENT_THREAD                   0x200   /* spawn thread to handle ev_q */
+#define EVENT_IPI                              0x00001 /* IPI the vcore (usually with INDIR) */
+#define EVENT_NOMSG                            0x00002 /* just send the bit, not the msg */
+#define EVENT_SPAM_PUBLIC              0x00004 /* spam the msg to public vcpd mboxes */
+#define EVENT_INDIR                            0x00008 /* send an indirection event to vcore */
+#define EVENT_VCORE_PRIVATE            0x00010 /* Will go to the private VCPD mbox */
+#define EVENT_SPAM_INDIR               0x00020 /* spam INDIRs if the vcore's offline */
+#define EVENT_VCORE_MUST_RUN   0x00040 /* spams go to a vcore that will run */
+#define EVENT_NOTHROTTLE               0x00080 /* send all INDIRs (no throttling) */
+#define EVENT_ROUNDROBIN               0x00100 /* pick a vcore, RR style */
+#define EVENT_VCORE_APPRO              0x00200 /* send to where the kernel wants */
+#define EVENT_WAKEUP                   0x00400 /* wake up the process after sending */
 
 /* Event Message Types */
 #define EV_NONE                                         0
 #define EV_PREEMPT_PENDING              1
 #define EV_GANG_PREMPT_PENDING  2
-#define EV_VCORE_REVOKE                         3
+#define EV_VCORE_PREEMPT                3
 #define EV_GANG_RETURN                  4
 #define EV_USER_IPI                             5
 #define EV_PAGE_FAULT                   6
@@ -36,7 +37,9 @@
 #define EV_EVENT                                8
 #define EV_FREE_APPLE_PIE               9
 #define EV_SYSCALL                             10
-#define NR_EVENT_TYPES                 11 /* keep me last */
+#define EV_CHECK_MSGS                  11
+#define EV_POSIX_SIGNAL                        12
+#define NR_EVENT_TYPES                 25 /* keep me last (and 1 > the last one) */
 
 /* Will probably have dynamic notifications later */
 #define MAX_NR_DYN_EVENT               25
@@ -62,6 +65,7 @@ struct event_msg {
  * sent (and no message). */
 struct event_mbox {
        struct ucq                                      ev_msgs;
+       bool                                            ev_check_bits;
        uint8_t                                         ev_bitmap[(MAX_NR_EVENT - 1) / 8 + 1];
 };
 
@@ -73,6 +77,7 @@ struct event_queue {
        bool                                            ev_alert_pending;
        uint32_t                                        ev_vcore;
        void                                            (*ev_handler)(struct event_queue *);
+       void                                            *ev_udata;
 };
 
 /* Big version, contains storage space for the ev_mbox.  Never access the
@@ -80,22 +85,37 @@ struct event_queue {
 struct event_queue_big {
        struct event_mbox                       *ev_mbox;
        int                                                     ev_flags;
+       bool                                            ev_alert_pending;
        uint32_t                                        ev_vcore;
        void                                            (*ev_handler)(struct event_queue *);
+       void                                            *ev_udata;
        struct event_mbox                       ev_imbox;
 };
 
+/* Vcore state flags.  K_LOCK means the kernel is writing */
+#define VC_K_LOCK                              0x001                           /* CASing with the kernel */
+#define VC_PREEMPTED                   0x002                           /* VC is preempted */
+#define VC_CAN_RCV_MSG                 0x004                           /* someone will get msg */
+#define VC_UTHREAD_STEALING            0x008                           /* Uthread being stolen */
+#define VC_SCP_NOVCCTX                 0x010                           /* can't go into vc ctx */
+
+/* Racy flags, where we don't need the atomics */
+#define VC_FPU_SAVED                   0x1000                          /* valid FPU state in anc */
+
 /* Per-core data about preemptions and notifications */
 struct preempt_data {
-       struct user_trapframe           preempt_tf;
+       struct user_context                     vcore_ctx;                      /* for preemptions */
        struct ancillary_state          preempt_anc;
-       struct user_trapframe           notif_tf;
-       uintptr_t                                       transition_stack;       /* advertised by the user */
-       bool                                            notif_enabled;          /* vcore willing to recv */
+       struct user_context                     uthread_ctx;            /* for preempts or notifs */
+       uintptr_t                                       vcore_entry;            /* advertised by the user */
+       uintptr_t                                       vcore_stack;            /* advertised by the user */
+       uintptr_t                                       vcore_tls_desc;         /* advertised by the user */
+       atomic_t                                        flags;
+       int                                                     rflags;                         /* racy flags */
+       bool                                            notif_disabled;         /* vcore unwilling to recv*/
        bool                                            notif_pending;          /* notif k_msg on the way */
-       bool                                            can_rcv_msg;            /* can receive FALLBACK */
-       seq_ctr_t                                       preempt_tf_valid;
-       struct event_mbox                       ev_mbox;
+       struct event_mbox                       ev_mbox_public;         /* can be read remotely */
+       struct event_mbox                       ev_mbox_private;        /* for this vcore only */
 };
 
 #endif /* ROS_INC_EVENT_H */