1 1.1 cherry /****************************************************************************** 2 1.1 cherry * sched.h 3 1.1 cherry * 4 1.1 cherry * Scheduler state interactions 5 1.1 cherry * 6 1.1 cherry * Permission is hereby granted, free of charge, to any person obtaining a copy 7 1.1 cherry * of this software and associated documentation files (the "Software"), to 8 1.1 cherry * deal in the Software without restriction, including without limitation the 9 1.1 cherry * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or 10 1.1 cherry * sell copies of the Software, and to permit persons to whom the Software is 11 1.1 cherry * furnished to do so, subject to the following conditions: 12 1.1 cherry * 13 1.1 cherry * The above copyright notice and this permission notice shall be included in 14 1.1 cherry * all copies or substantial portions of the Software. 15 1.1 cherry * 16 1.1 cherry * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 1.1 cherry * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 1.1 cherry * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 1.1 cherry * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 1.1 cherry * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 21 1.1 cherry * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 22 1.1 cherry * DEALINGS IN THE SOFTWARE. 23 1.1 cherry * 24 1.1 cherry * Copyright (c) 2005, Keir Fraser <keir (at) xensource.com> 25 1.1 cherry */ 26 1.1 cherry 27 1.1 cherry #ifndef __XEN_PUBLIC_SCHED_H__ 28 1.1 cherry #define __XEN_PUBLIC_SCHED_H__ 29 1.1 cherry 30 1.1 cherry #include "event_channel.h" 31 1.1 cherry 32 1.1 cherry /* 33 1.1 cherry * `incontents 150 sched Guest Scheduler Operations 34 1.1 cherry * 35 1.1 cherry * The SCHEDOP interface provides mechanisms for a guest to interact 36 1.1 cherry * with the scheduler, including yield, blocking and shutting itself 37 1.1 cherry * down. 38 1.1 cherry */ 39 1.1 cherry 40 1.1 cherry /* 41 1.1 cherry * The prototype for this hypercall is: 42 1.1 cherry * ` long HYPERVISOR_sched_op(enum sched_op cmd, void *arg, ...) 43 1.1 cherry * 44 1.1 cherry * @cmd == SCHEDOP_??? (scheduler operation). 45 1.1 cherry * @arg == Operation-specific extra argument(s), as described below. 46 1.1 cherry * ... == Additional Operation-specific extra arguments, described below. 47 1.1 cherry * 48 1.1 cherry * Versions of Xen prior to 3.0.2 provided only the following legacy version 49 1.1 cherry * of this hypercall, supporting only the commands yield, block and shutdown: 50 1.1 cherry * long sched_op(int cmd, unsigned long arg) 51 1.1 cherry * @cmd == SCHEDOP_??? (scheduler operation). 52 1.1 cherry * @arg == 0 (SCHEDOP_yield and SCHEDOP_block) 53 1.1 cherry * == SHUTDOWN_* code (SCHEDOP_shutdown) 54 1.1 cherry * 55 1.1 cherry * This legacy version is available to new guests as: 56 1.1 cherry * ` long HYPERVISOR_sched_op_compat(enum sched_op cmd, unsigned long arg) 57 1.1 cherry */ 58 1.1 cherry 59 1.1 cherry /* ` enum sched_op { // SCHEDOP_* => struct sched_* */ 60 1.1 cherry /* 61 1.1 cherry * Voluntarily yield the CPU. 62 1.1 cherry * @arg == NULL. 63 1.1 cherry */ 64 1.1 cherry #define SCHEDOP_yield 0 65 1.1 cherry 66 1.1 cherry /* 67 1.1 cherry * Block execution of this VCPU until an event is received for processing. 68 1.1 cherry * If called with event upcalls masked, this operation will atomically 69 1.1 cherry * reenable event delivery and check for pending events before blocking the 70 1.1 cherry * VCPU. This avoids a "wakeup waiting" race. 71 1.1 cherry * @arg == NULL. 72 1.1 cherry */ 73 1.1 cherry #define SCHEDOP_block 1 74 1.1 cherry 75 1.1 cherry /* 76 1.1 cherry * Halt execution of this domain (all VCPUs) and notify the system controller. 77 1.1 cherry * @arg == pointer to sched_shutdown_t structure. 78 1.1 cherry * 79 1.1 cherry * If the sched_shutdown_t reason is SHUTDOWN_suspend then 80 1.1 cherry * x86 PV guests must also set RDX (EDX for 32-bit guests) to the MFN 81 1.1 cherry * of the guest's start info page. RDX/EDX is the third hypercall 82 1.1 cherry * argument. 83 1.1 cherry * 84 1.1 cherry * In addition, which reason is SHUTDOWN_suspend this hypercall 85 1.1 cherry * returns 1 if suspend was cancelled or the domain was merely 86 1.1 cherry * checkpointed, and 0 if it is resuming in a new domain. 87 1.1 cherry */ 88 1.1 cherry #define SCHEDOP_shutdown 2 89 1.1 cherry 90 1.1 cherry /* 91 1.1 cherry * Poll a set of event-channel ports. Return when one or more are pending. An 92 1.1 cherry * optional timeout may be specified. 93 1.1 cherry * @arg == pointer to sched_poll_t structure. 94 1.1 cherry */ 95 1.1 cherry #define SCHEDOP_poll 3 96 1.1 cherry 97 1.1 cherry /* 98 1.1 cherry * Declare a shutdown for another domain. The main use of this function is 99 1.1 cherry * in interpreting shutdown requests and reasons for fully-virtualized 100 1.1 cherry * domains. A para-virtualized domain may use SCHEDOP_shutdown directly. 101 1.1 cherry * @arg == pointer to sched_remote_shutdown_t structure. 102 1.1 cherry */ 103 1.1 cherry #define SCHEDOP_remote_shutdown 4 104 1.1 cherry 105 1.1 cherry /* 106 1.1 cherry * Latch a shutdown code, so that when the domain later shuts down it 107 1.1 cherry * reports this code to the control tools. 108 1.1 cherry * @arg == sched_shutdown_t, as for SCHEDOP_shutdown. 109 1.1 cherry */ 110 1.1 cherry #define SCHEDOP_shutdown_code 5 111 1.1 cherry 112 1.1 cherry /* 113 1.1 cherry * Setup, poke and destroy a domain watchdog timer. 114 1.1 cherry * @arg == pointer to sched_watchdog_t structure. 115 1.1 cherry * With id == 0, setup a domain watchdog timer to cause domain shutdown 116 1.1 cherry * after timeout, returns watchdog id. 117 1.1 cherry * With id != 0 and timeout == 0, destroy domain watchdog timer. 118 1.1 cherry * With id != 0 and timeout != 0, poke watchdog timer and set new timeout. 119 1.1 cherry */ 120 1.1 cherry #define SCHEDOP_watchdog 6 121 1.1 cherry 122 1.1 cherry /* 123 1.1 cherry * Override the current vcpu affinity by pinning it to one physical cpu or 124 1.1 cherry * undo this override restoring the previous affinity. 125 1.1 cherry * @arg == pointer to sched_pin_override_t structure. 126 1.1 cherry * 127 1.1 cherry * A negative pcpu value will undo a previous pin override and restore the 128 1.1 cherry * previous cpu affinity. 129 1.1 cherry * This call is allowed for the hardware domain only and requires the cpu 130 1.1 cherry * to be part of the domain's cpupool. 131 1.1 cherry */ 132 1.1 cherry #define SCHEDOP_pin_override 7 133 1.1 cherry /* ` } */ 134 1.1 cherry 135 1.1 cherry struct sched_shutdown { 136 1.1 cherry unsigned int reason; /* SHUTDOWN_* => enum sched_shutdown_reason */ 137 1.1 cherry }; 138 1.1 cherry typedef struct sched_shutdown sched_shutdown_t; 139 1.1 cherry DEFINE_XEN_GUEST_HANDLE(sched_shutdown_t); 140 1.1 cherry 141 1.1 cherry struct sched_poll { 142 1.1 cherry XEN_GUEST_HANDLE(evtchn_port_t) ports; 143 1.1 cherry unsigned int nr_ports; 144 1.1 cherry uint64_t timeout; 145 1.1 cherry }; 146 1.1 cherry typedef struct sched_poll sched_poll_t; 147 1.1 cherry DEFINE_XEN_GUEST_HANDLE(sched_poll_t); 148 1.1 cherry 149 1.1 cherry struct sched_remote_shutdown { 150 1.1 cherry domid_t domain_id; /* Remote domain ID */ 151 1.1 cherry unsigned int reason; /* SHUTDOWN_* => enum sched_shutdown_reason */ 152 1.1 cherry }; 153 1.1 cherry typedef struct sched_remote_shutdown sched_remote_shutdown_t; 154 1.1 cherry DEFINE_XEN_GUEST_HANDLE(sched_remote_shutdown_t); 155 1.1 cherry 156 1.1 cherry struct sched_watchdog { 157 1.1 cherry uint32_t id; /* watchdog ID */ 158 1.1 cherry uint32_t timeout; /* timeout */ 159 1.1 cherry }; 160 1.1 cherry typedef struct sched_watchdog sched_watchdog_t; 161 1.1 cherry DEFINE_XEN_GUEST_HANDLE(sched_watchdog_t); 162 1.1 cherry 163 1.1 cherry struct sched_pin_override { 164 1.1 cherry int32_t pcpu; 165 1.1 cherry }; 166 1.1 cherry typedef struct sched_pin_override sched_pin_override_t; 167 1.1 cherry DEFINE_XEN_GUEST_HANDLE(sched_pin_override_t); 168 1.1 cherry 169 1.1 cherry /* 170 1.1 cherry * Reason codes for SCHEDOP_shutdown. These may be interpreted by control 171 1.1 cherry * software to determine the appropriate action. For the most part, Xen does 172 1.1 cherry * not care about the shutdown code. 173 1.1 cherry */ 174 1.1 cherry /* ` enum sched_shutdown_reason { */ 175 1.1 cherry #define SHUTDOWN_poweroff 0 /* Domain exited normally. Clean up and kill. */ 176 1.1 cherry #define SHUTDOWN_reboot 1 /* Clean up, kill, and then restart. */ 177 1.1 cherry #define SHUTDOWN_suspend 2 /* Clean up, save suspend info, kill. */ 178 1.1 cherry #define SHUTDOWN_crash 3 /* Tell controller we've crashed. */ 179 1.1 cherry #define SHUTDOWN_watchdog 4 /* Restart because watchdog time expired. */ 180 1.1 cherry 181 1.1 cherry /* 182 1.1 cherry * Domain asked to perform 'soft reset' for it. The expected behavior is to 183 1.1 cherry * reset internal Xen state for the domain returning it to the point where it 184 1.1 cherry * was created but leaving the domain's memory contents and vCPU contexts 185 1.1 cherry * intact. This will allow the domain to start over and set up all Xen specific 186 1.1 cherry * interfaces again. 187 1.1 cherry */ 188 1.1 cherry #define SHUTDOWN_soft_reset 5 189 1.1 cherry #define SHUTDOWN_MAX 5 /* Maximum valid shutdown reason. */ 190 1.1 cherry /* ` } */ 191 1.1 cherry 192 1.1 cherry #endif /* __XEN_PUBLIC_SCHED_H__ */ 193 1.1 cherry 194 1.1 cherry /* 195 1.1 cherry * Local variables: 196 1.1 cherry * mode: C 197 1.1 cherry * c-file-style: "BSD" 198 1.1 cherry * c-basic-offset: 4 199 1.1 cherry * tab-width: 4 200 1.1 cherry * indent-tabs-mode: nil 201 1.1 cherry * End: 202 1.1 cherry */ 203