3 * \brief Kernel management of dispatchers
7 * Copyright (c) 2007, 2008, 2009, 2010, ETH Zurich.
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.
15 #ifndef KERNEL_DISPATCH_H
16 #define KERNEL_DISPATCH_H
18 #include <barrelfish_kpi/cpu.h>
19 #include <barrelfish_kpi/dispatcher_shared_arch.h>
20 #include <capabilities.h>
23 extern uint64_t context_switch_counter;
26 * \brief Structure to hold information regarding AMD SVM
29 struct cte monitor_ep; ///< The endpoint to the monitor
30 struct cte ctrl; ///< The VMKit guest shared data structure
31 struct cte vmcb; ///< The physical address of the AMD VMCB
35 * \brief The dispatcher control block.
37 * This block holds necessary kernel data to control a user-space dispatcher
40 dispatcher_handle_t disp; ///< User-mode dispatcher frame pointer
41 bool disabled; ///< Was dispatcher disabled when last saved?
42 struct cte cspace; ///< Cap slot for CSpace
43 lpaddr_t vspace; ///< Address of VSpace root
45 unsigned int faults_taken; ///< # of disabled faults or traps taken
46 /// Indicates whether this domain shall be executed in VM guest mode
48 struct guest guest_desc; ///< Descriptor of the VM Guest
49 uint64_t domain_id; ///< ID of dispatcher's domain
50 systime_t wakeup_time; ///< Time to wakeup this dispatcher
51 struct dcb *wakeup_prev, *wakeup_next; ///< Next/prev in timeout queue
53 struct dcb *next; ///< Next DCB in schedule
54 struct dcb *prev; ///< Previous DCB in schedule
55 /// (only valid iff CONFIG_SCHEDULER_RR)
56 #if defined(CONFIG_SCHEDULER_RBED)
57 unsigned long release_time, etime, last_dispatch;
58 unsigned long wcet, period, deadline;
59 unsigned short weight;
64 static inline const char *get_disp_name(struct dcb *dcb)
66 struct dispatcher_shared_generic *dst =
67 get_dispatcher_shared_generic(dcb->disp);
71 /// The currently running dispatcher and FPU dispatcher
72 extern struct dcb *dcb_current, *fpu_dcb;
74 void dispatch(struct dcb *dcb) __attribute__ ((noreturn));
75 errval_t lmp_can_deliver_payload(struct capability *ep,
77 errval_t lmp_deliver_payload(struct capability *ep, struct dcb *send,
78 uintptr_t *payload, size_t payload_len,
80 errval_t lmp_deliver(struct capability *ep, struct dcb *send,
81 uintptr_t *payload, size_t payload_len,
82 capaddr_t send_cptr, uint8_t send_bits, bool give_away);
84 /// Deliver an empty LMP as a notification
85 static inline errval_t lmp_deliver_notification(struct capability *ep)
87 return lmp_deliver_payload(ep, NULL, NULL, 0, false);
91 static inline void dispatch_csc_reset(void)
93 context_switch_counter = 0;
97 static inline uint64_t dispatch_get_csc(void)
99 return context_switch_counter;