xref: /titanic_41/usr/src/uts/common/xen/public/sched.h (revision ae5b046d8f8cec187d40041c4b74b43f561d5ac7)
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
67 struct sched_shutdown {
68     unsigned int reason; /* SHUTDOWN_* */
69 };
70 typedef struct sched_shutdown sched_shutdown_t;
71 DEFINE_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
79 struct sched_poll {
80     XEN_GUEST_HANDLE(evtchn_port_t) ports;
81     unsigned int nr_ports;
82     uint64_t timeout;
83 };
84 typedef struct sched_poll sched_poll_t;
85 DEFINE_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
94 struct sched_remote_shutdown {
95     domid_t domain_id;         /* Remote domain ID */
96     unsigned int reason;       /* SHUTDOWN_xxx reason */
97 };
98 typedef struct sched_remote_shutdown sched_remote_shutdown_t;
99 DEFINE_XEN_GUEST_HANDLE(sched_remote_shutdown_t);
100 
101 /*
102  * Reason codes for SCHEDOP_shutdown. These may be interpreted by control
103  * software to determine the appropriate action. For the most part, Xen does
104  * not care about the shutdown code.
105  */
106 #define SHUTDOWN_poweroff   0  /* Domain exited normally. Clean up and kill. */
107 #define SHUTDOWN_reboot     1  /* Clean up, kill, and then restart.          */
108 #define SHUTDOWN_suspend    2  /* Clean up, save suspend info, kill.         */
109 #define SHUTDOWN_crash      3  /* Tell controller we've crashed.             */
110 
111 #endif /* __XEN_PUBLIC_SCHED_H__ */
112 
113 /*
114  * Local variables:
115  * mode: C
116  * c-set-style: "BSD"
117  * c-basic-offset: 4
118  * tab-width: 4
119  * indent-tabs-mode: nil
120  * End:
121  */
122