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