sched.h 6.1 KB

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