Orange Pi5 kernel

Deprecated Linux kernel 5.10.110 for OrangePi 5/5B/5+ boards

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