1 /* Copyright (c) 2010-2011 The Regents of the University of California
2 * Barret Rhoden <brho@cs.berkeley.edu>
3 * See LICENSE for details.
5 * Kernel interface for event/notification delivery and preemption. */
9 #include <ros/bits/event.h>
10 #include <ros/atomic.h>
11 #include <ros/trapframe.h>
14 #include <ros/evbitmap.h>
18 #define EV_MBOX_BITMAP 2
21 /* Structure for storing / receiving event messages. An overflow causes the
22 * bit of the event to get set in the bitmap. You can also have just the bit
23 * sent (and no message). */
33 /* The kernel sends messages to this structure, which describes how and where
34 * to receive messages, including optional IPIs. */
36 struct event_mbox *ev_mbox;
38 bool ev_alert_pending;
40 void (*ev_handler)(struct event_queue *);
44 /* Big version, contains storage space for the ev_mbox. Never access the
45 * internal mbox directly. */
46 struct event_queue_big {
47 struct event_mbox *ev_mbox;
49 bool ev_alert_pending;
51 void (*ev_handler)(struct event_queue *);
53 struct event_mbox ev_imbox;
56 /* Vcore state flags. K_LOCK means the kernel is writing */
57 #define VC_K_LOCK 0x001 /* CASing with the kernel */
58 #define VC_PREEMPTED 0x002 /* VC is preempted */
59 #define VC_CAN_RCV_MSG 0x004 /* someone will get msg */
60 #define VC_UTHREAD_STEALING 0x008 /* Uthread being stolen */
61 #define VC_SCP_NOVCCTX 0x010 /* can't go into vc ctx */
63 /* Racy flags, where we don't need the atomics */
64 #define VC_FPU_SAVED 0x1000 /* valid FPU state in anc */
66 /* Per-core data about preemptions and notifications */
68 struct user_context vcore_ctx; /* for preemptions */
69 struct ancillary_state preempt_anc;
70 struct user_context uthread_ctx; /* for preempts or notifs */
71 uintptr_t vcore_entry; /* advertised by the user */
72 uintptr_t vcore_stack; /* advertised by the user */
73 uintptr_t vcore_tls_desc; /* advertised by the user */
75 int rflags; /* racy flags */
76 bool notif_disabled; /* vcore unwilling to recv*/
77 bool notif_pending; /* notif k_msg on the way */
78 struct event_mbox ev_mbox_public; /* can be read remotely */
79 struct event_mbox ev_mbox_private; /* for this vcore only */