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