1/**
2 * \file
3 * \brief Generic dispatcher structure private to the user
4 */
5
6/*
7 * Copyright (c) 2007, 2008, 2009, 2010, 2011, ETH Zurich.
8 * All rights reserved.
9 *
10 * This file is distributed under the terms in the attached LICENSE file.
11 * If you do not find this file, copies can be found by writing to:
12 * ETH Zurich D-INFK, Haldeneggsteig 4, CH-8092 Zurich. Attn: Systems Group.
13 */
14
15#ifndef BARRELFISH_DISPATCHER_H
16#define BARRELFISH_DISPATCHER_H
17
18#include <barrelfish/dispatch.h>
19#include <barrelfish/core_state_arch.h>
20#include <barrelfish/heap.h>
21#include <barrelfish/threads.h>
22
23struct lmp_chan;
24struct ump_chan;
25struct deferred_event;
26struct notificator;
27
28/// Maximum number of buffered capability receive slots
29#define MAX_RECV_SLOTS   4
30
31// Architecture generic user only dispatcher struct
32struct dispatcher_generic {
33    /// stack for traps and disabled pagefaults
34    uintptr_t trap_stack[DISPATCHER_STACK_WORDS] __attribute__ ((aligned (16)));
35    /// all other dispatcher upcalls run on this stack
36    uintptr_t stack[DISPATCHER_STACK_WORDS] __attribute__ ((aligned (16)));
37
38    /// Currently-running (or last-run) thread, if any
39    struct thread *current;
40
41    /// Thread run queue (all threads eligible to be run)
42    struct thread *runq;
43
44    /// Cap to this dispatcher, used for creating new endpoints
45    struct capref dcb_cap;
46
47#ifdef CONFIG_INTERCONNECT_DRIVER_LMP
48    /// List of LMP endpoints to poll
49    struct lmp_endpoint *lmp_poll_list;
50
51    /// List of LMP channels waiting to retry a send
52    struct lmp_chan *lmp_send_events_list;
53    struct ump_chan *ump_send_events_list;
54
55    /// LMP endpoint heap state
56    struct heap lmp_endpoint_heap;
57#endif // CONFIG_INTERCONNECT_DRIVER_LMP
58
59    /// Queue of deferred events (i.e. timers)
60    struct deferred_event *deferred_events;
61
62    /// The core the dispatcher is running on
63    coreid_t core_id;
64
65    uintptr_t timeslice;
66
67    /// Per core dispatcher state
68    struct core_state_arch core_state;
69
70    /// Tracing buffer
71    struct trace_buffer *trace_buf;
72
73    struct thread *cleanupthread;
74    struct thread_mutex cleanupthread_lock;
75
76    /// Last FPU-using thread
77    struct thread *fpu_thread;
78
79    /// Domain ID cache
80    domainid_t domain_id;
81
82    /// virtual address of the eh_frame
83    lvaddr_t eh_frame;
84
85    /// size of the eh frame
86    size_t   eh_frame_size;
87
88    /// virtual address of the eh_frame
89    lvaddr_t eh_frame_hdr;
90
91    /// size of the eh frame
92    size_t   eh_frame_hdr_size;
93
94    /// list of polled channels
95    struct waitset_chanstate *polled_channels;
96
97    struct notificator *notificators;
98
99    struct capref recv_slots[MAX_RECV_SLOTS];///< Queued cap recv slots
100    int8_t recv_slot_count;                 ///< number of currently queued recv slots
101
102};
103
104#endif // BARRELFISH_DISPATCHER_H
105