1/******************************************************************************
2 * sched.h
3 *
4 * Scheduler state interactions
5 *
6 * Permission is hereby granted, free of charge, to any person obtaining a copy
7 * of this software and associated documentation files (the "Software"), to
8 * deal in the Software without restriction, including without limitation the
9 * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
10 * sell copies of the Software, and to permit persons to whom the Software is
11 * furnished to do so, subject to the following conditions:
12 *
13 * The above copyright notice and this permission notice shall be included in
14 * all copies or substantial portions of the Software.
15 *
16 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
21 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
22 * DEALINGS IN THE SOFTWARE.
23 *
24 * Copyright (c) 2005, Keir Fraser <keir@xensource.com>
25 */
26
27#ifndef __XEN_PUBLIC_SCHED_H__
28#define __XEN_PUBLIC_SCHED_H__
29
30#include "event_channel.h"
31
32/*
33 * The prototype for this hypercall is:
34 *  long sched_op(int cmd, void *arg)
35 * @cmd == SCHEDOP_??? (scheduler operation).
36 * @arg == Operation-specific extra argument(s), as described below.
37 *
38 * Versions of Xen prior to 3.0.2 provided only the following legacy version
39 * of this hypercall, supporting only the commands yield, block and shutdown:
40 *  long sched_op(int cmd, unsigned long arg)
41 * @cmd == SCHEDOP_??? (scheduler operation).
42 * @arg == 0               (SCHEDOP_yield and SCHEDOP_block)
43 *      == SHUTDOWN_* code (SCHEDOP_shutdown)
44 * This legacy version is available to new guests as sched_op_compat().
45 */
46
47/*
48 * Voluntarily yield the CPU.
49 * @arg == NULL.
50 */
51#define SCHEDOP_yield       0
52
53/*
54 * Block execution of this VCPU until an event is received for processing.
55 * If called with event upcalls masked, this operation will atomically
56 * reenable event delivery and check for pending events before blocking the
57 * VCPU. This avoids a "wakeup waiting" race.
58 * @arg == NULL.
59 */
60#define SCHEDOP_block       1
61
62/*
63 * Halt execution of this domain (all VCPUs) and notify the system controller.
64 * @arg == pointer to sched_shutdown structure.
65 */
66#define SCHEDOP_shutdown    2
67struct sched_shutdown {
68    unsigned int reason; /* SHUTDOWN_* */
69};
70typedef struct sched_shutdown sched_shutdown_t;
71DEFINE_XEN_GUEST_HANDLE(sched_shutdown_t);
72
73/*
74 * Poll a set of event-channel ports. Return when one or more are pending. An
75 * optional timeout may be specified.
76 * @arg == pointer to sched_poll structure.
77 */
78#define SCHEDOP_poll        3
79struct sched_poll {
80    XEN_GUEST_HANDLE(evtchn_port_t) ports;
81    unsigned int nr_ports;
82    uint64_t timeout;
83};
84typedef struct sched_poll sched_poll_t;
85DEFINE_XEN_GUEST_HANDLE(sched_poll_t);
86
87/*
88 * Declare a shutdown for another domain. The main use of this function is
89 * in interpreting shutdown requests and reasons for fully-virtualized
90 * domains.  A para-virtualized domain may use SCHEDOP_shutdown directly.
91 * @arg == pointer to sched_remote_shutdown structure.
92 */
93#define SCHEDOP_remote_shutdown        4
94struct sched_remote_shutdown {
95    domid_t domain_id;         /* Remote domain ID */
96    unsigned int reason;       /* SHUTDOWN_xxx reason */
97};
98typedef struct sched_remote_shutdown sched_remote_shutdown_t;
99DEFINE_XEN_GUEST_HANDLE(sched_remote_shutdown_t);
100
101/*
102 * Latch a shutdown code, so that when the domain later shuts down it
103 * reports this code to the control tools.
104 * @arg == as for SCHEDOP_shutdown.
105 */
106#define SCHEDOP_shutdown_code 5
107
108/*
109 * Setup, poke and destroy a domain watchdog timer.
110 * @arg == pointer to sched_watchdog structure.
111 * With id == 0, setup a domain watchdog timer to cause domain shutdown
112 *               after timeout, returns watchdog id.
113 * With id != 0 and timeout == 0, destroy domain watchdog timer.
114 * With id != 0 and timeout != 0, poke watchdog timer and set new timeout.
115 */
116#define SCHEDOP_watchdog    6
117struct sched_watchdog {
118    uint32_t id;                /* watchdog ID */
119    uint32_t timeout;           /* timeout */
120};
121typedef struct sched_watchdog sched_watchdog_t;
122DEFINE_XEN_GUEST_HANDLE(sched_watchdog_t);
123
124/*
125 * Reason codes for SCHEDOP_shutdown. These may be interpreted by control
126 * software to determine the appropriate action. For the most part, Xen does
127 * not care about the shutdown code.
128 */
129#define SHUTDOWN_poweroff   0  /* Domain exited normally. Clean up and kill. */
130#define SHUTDOWN_reboot     1  /* Clean up, kill, and then restart.          */
131#define SHUTDOWN_suspend    2  /* Clean up, save suspend info, kill.         */
132#define SHUTDOWN_crash      3  /* Tell controller we've crashed.             */
133#define SHUTDOWN_watchdog   4  /* Restart because watchdog time expired.     */
134
135#endif /* __XEN_PUBLIC_SCHED_H__ */
136
137/*
138 * Local variables:
139 * mode: C
140 * c-set-style: "BSD"
141 * c-basic-offset: 4
142 * tab-width: 4
143 * indent-tabs-mode: nil
144 * End:
145 */
146