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