akaros/kern/include/ros/event.h
<<
>>
Prefs
   1/* Copyright (c) 2010-2011 The Regents of the University of California
   2 * Barret Rhoden <brho@cs.berkeley.edu>
   3 * See LICENSE for details.
   4 *
   5 * Kernel interface for event/notification delivery and preemption. */
   6
   7#pragma once
   8
   9#include <ros/bits/event.h>
  10#include <ros/atomic.h>
  11#include <ros/trapframe.h>
  12
  13#include <ros/ucq.h>
  14#include <ros/evbitmap.h>
  15#include <ros/ceq.h>
  16
  17#define EV_MBOX_UCQ             1
  18#define EV_MBOX_BITMAP          2
  19#define EV_MBOX_CEQ             3
  20
  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). */
  24struct event_mbox {
  25        int                             type;
  26        union {
  27                struct ucq              ucq;
  28                struct evbitmap         evbm;
  29                struct ceq              ceq;
  30        };
  31};
  32
  33/* The kernel sends messages to this structure, which describes how and where
  34 * to receive messages, including optional IPIs. */
  35struct event_queue {
  36        struct event_mbox               *ev_mbox;
  37        int                             ev_flags;
  38        bool                            ev_alert_pending;
  39        uint32_t                        ev_vcore;
  40        void                            (*ev_handler)(struct event_queue *);
  41        void                            *ev_udata;
  42};
  43
  44/* Big version, contains storage space for the ev_mbox.  Never access the
  45 * internal mbox directly. */
  46struct event_queue_big {
  47        struct event_mbox               *ev_mbox;
  48        int                             ev_flags;
  49        bool                            ev_alert_pending;
  50        uint32_t                        ev_vcore;
  51        void                            (*ev_handler)(struct event_queue *);
  52        void                            *ev_udata;
  53        struct event_mbox               ev_imbox;
  54};
  55
  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 */
  62
  63/* Racy flags, where we don't need the atomics */
  64#define VC_FPU_SAVED            0x1000  /* valid FPU state in anc */
  65
  66/* Per-core data about preemptions and notifications */
  67struct preempt_data {
  68        struct user_context             vcore_ctx;
  69        struct ancillary_state          preempt_anc;
  70        struct user_context             uthread_ctx;
  71        uintptr_t                       vcore_entry;
  72        uintptr_t                       vcore_stack;
  73        uintptr_t                       vcore_tls_desc;
  74        atomic_t                        flags;
  75        int                             rflags;         /* racy flags */
  76        bool                            notif_disabled;
  77        bool                            notif_pending;
  78        struct event_mbox               ev_mbox_public;
  79        struct event_mbox               ev_mbox_private;
  80};
  81