platform.h 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339
  1. /******************************************************************************
  2. * platform.h
  3. *
  4. * Hardware platform operations. Intended for use by domain-0 kernel.
  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) 2002-2006, K Fraser
  25. */
  26. #ifndef __XEN_PUBLIC_PLATFORM_H__
  27. #define __XEN_PUBLIC_PLATFORM_H__
  28. #include "xen.h"
  29. #define XENPF_INTERFACE_VERSION 0x03000001
  30. /*
  31. * Set clock such that it would read <secs,nsecs> after 00:00:00 UTC,
  32. * 1 January, 1970 if the current system time was <system_time>.
  33. */
  34. #define XENPF_settime 17
  35. struct xenpf_settime {
  36. /* IN variables. */
  37. uint32_t secs;
  38. uint32_t nsecs;
  39. uint64_t system_time;
  40. };
  41. DEFINE_GUEST_HANDLE_STRUCT(xenpf_settime_t);
  42. /*
  43. * Request memory range (@mfn, @mfn+@nr_mfns-1) to have type @type.
  44. * On x86, @type is an architecture-defined MTRR memory type.
  45. * On success, returns the MTRR that was used (@reg) and a handle that can
  46. * be passed to XENPF_DEL_MEMTYPE to accurately tear down the new setting.
  47. * (x86-specific).
  48. */
  49. #define XENPF_add_memtype 31
  50. struct xenpf_add_memtype {
  51. /* IN variables. */
  52. unsigned long mfn;
  53. uint64_t nr_mfns;
  54. uint32_t type;
  55. /* OUT variables. */
  56. uint32_t handle;
  57. uint32_t reg;
  58. };
  59. DEFINE_GUEST_HANDLE_STRUCT(xenpf_add_memtype_t);
  60. /*
  61. * Tear down an existing memory-range type. If @handle is remembered then it
  62. * should be passed in to accurately tear down the correct setting (in case
  63. * of overlapping memory regions with differing types). If it is not known
  64. * then @handle should be set to zero. In all cases @reg must be set.
  65. * (x86-specific).
  66. */
  67. #define XENPF_del_memtype 32
  68. struct xenpf_del_memtype {
  69. /* IN variables. */
  70. uint32_t handle;
  71. uint32_t reg;
  72. };
  73. DEFINE_GUEST_HANDLE_STRUCT(xenpf_del_memtype_t);
  74. /* Read current type of an MTRR (x86-specific). */
  75. #define XENPF_read_memtype 33
  76. struct xenpf_read_memtype {
  77. /* IN variables. */
  78. uint32_t reg;
  79. /* OUT variables. */
  80. unsigned long mfn;
  81. uint64_t nr_mfns;
  82. uint32_t type;
  83. };
  84. DEFINE_GUEST_HANDLE_STRUCT(xenpf_read_memtype_t);
  85. #define XENPF_microcode_update 35
  86. struct xenpf_microcode_update {
  87. /* IN variables. */
  88. GUEST_HANDLE(void) data; /* Pointer to microcode data */
  89. uint32_t length; /* Length of microcode data. */
  90. };
  91. DEFINE_GUEST_HANDLE_STRUCT(xenpf_microcode_update_t);
  92. #define XENPF_platform_quirk 39
  93. #define QUIRK_NOIRQBALANCING 1 /* Do not restrict IO-APIC RTE targets */
  94. #define QUIRK_IOAPIC_BAD_REGSEL 2 /* IO-APIC REGSEL forgets its value */
  95. #define QUIRK_IOAPIC_GOOD_REGSEL 3 /* IO-APIC REGSEL behaves properly */
  96. struct xenpf_platform_quirk {
  97. /* IN variables. */
  98. uint32_t quirk_id;
  99. };
  100. DEFINE_GUEST_HANDLE_STRUCT(xenpf_platform_quirk_t);
  101. #define XENPF_firmware_info 50
  102. #define XEN_FW_DISK_INFO 1 /* from int 13 AH=08/41/48 */
  103. #define XEN_FW_DISK_MBR_SIGNATURE 2 /* from MBR offset 0x1b8 */
  104. #define XEN_FW_VBEDDC_INFO 3 /* from int 10 AX=4f15 */
  105. struct xenpf_firmware_info {
  106. /* IN variables. */
  107. uint32_t type;
  108. uint32_t index;
  109. /* OUT variables. */
  110. union {
  111. struct {
  112. /* Int13, Fn48: Check Extensions Present. */
  113. uint8_t device; /* %dl: bios device number */
  114. uint8_t version; /* %ah: major version */
  115. uint16_t interface_support; /* %cx: support bitmap */
  116. /* Int13, Fn08: Legacy Get Device Parameters. */
  117. uint16_t legacy_max_cylinder; /* %cl[7:6]:%ch: max cyl # */
  118. uint8_t legacy_max_head; /* %dh: max head # */
  119. uint8_t legacy_sectors_per_track; /* %cl[5:0]: max sector # */
  120. /* Int13, Fn41: Get Device Parameters (as filled into %ds:%esi). */
  121. /* NB. First uint16_t of buffer must be set to buffer size. */
  122. GUEST_HANDLE(void) edd_params;
  123. } disk_info; /* XEN_FW_DISK_INFO */
  124. struct {
  125. uint8_t device; /* bios device number */
  126. uint32_t mbr_signature; /* offset 0x1b8 in mbr */
  127. } disk_mbr_signature; /* XEN_FW_DISK_MBR_SIGNATURE */
  128. struct {
  129. /* Int10, AX=4F15: Get EDID info. */
  130. uint8_t capabilities;
  131. uint8_t edid_transfer_time;
  132. /* must refer to 128-byte buffer */
  133. GUEST_HANDLE(uchar) edid;
  134. } vbeddc_info; /* XEN_FW_VBEDDC_INFO */
  135. } u;
  136. };
  137. DEFINE_GUEST_HANDLE_STRUCT(xenpf_firmware_info_t);
  138. #define XENPF_enter_acpi_sleep 51
  139. struct xenpf_enter_acpi_sleep {
  140. /* IN variables */
  141. uint16_t pm1a_cnt_val; /* PM1a control value. */
  142. uint16_t pm1b_cnt_val; /* PM1b control value. */
  143. uint32_t sleep_state; /* Which state to enter (Sn). */
  144. uint32_t flags; /* Must be zero. */
  145. };
  146. DEFINE_GUEST_HANDLE_STRUCT(xenpf_enter_acpi_sleep_t);
  147. #define XENPF_change_freq 52
  148. struct xenpf_change_freq {
  149. /* IN variables */
  150. uint32_t flags; /* Must be zero. */
  151. uint32_t cpu; /* Physical cpu. */
  152. uint64_t freq; /* New frequency (Hz). */
  153. };
  154. DEFINE_GUEST_HANDLE_STRUCT(xenpf_change_freq_t);
  155. /*
  156. * Get idle times (nanoseconds since boot) for physical CPUs specified in the
  157. * @cpumap_bitmap with range [0..@cpumap_nr_cpus-1]. The @idletime array is
  158. * indexed by CPU number; only entries with the corresponding @cpumap_bitmap
  159. * bit set are written to. On return, @cpumap_bitmap is modified so that any
  160. * non-existent CPUs are cleared. Such CPUs have their @idletime array entry
  161. * cleared.
  162. */
  163. #define XENPF_getidletime 53
  164. struct xenpf_getidletime {
  165. /* IN/OUT variables */
  166. /* IN: CPUs to interrogate; OUT: subset of IN which are present */
  167. GUEST_HANDLE(uchar) cpumap_bitmap;
  168. /* IN variables */
  169. /* Size of cpumap bitmap. */
  170. uint32_t cpumap_nr_cpus;
  171. /* Must be indexable for every cpu in cpumap_bitmap. */
  172. GUEST_HANDLE(uint64_t) idletime;
  173. /* OUT variables */
  174. /* System time when the idletime snapshots were taken. */
  175. uint64_t now;
  176. };
  177. DEFINE_GUEST_HANDLE_STRUCT(xenpf_getidletime_t);
  178. #define XENPF_set_processor_pminfo 54
  179. /* ability bits */
  180. #define XEN_PROCESSOR_PM_CX 1
  181. #define XEN_PROCESSOR_PM_PX 2
  182. #define XEN_PROCESSOR_PM_TX 4
  183. /* cmd type */
  184. #define XEN_PM_CX 0
  185. #define XEN_PM_PX 1
  186. #define XEN_PM_TX 2
  187. #define XEN_PM_PDC 3
  188. /* Px sub info type */
  189. #define XEN_PX_PCT 1
  190. #define XEN_PX_PSS 2
  191. #define XEN_PX_PPC 4
  192. #define XEN_PX_PSD 8
  193. struct xen_power_register {
  194. uint32_t space_id;
  195. uint32_t bit_width;
  196. uint32_t bit_offset;
  197. uint32_t access_size;
  198. uint64_t address;
  199. };
  200. struct xen_processor_csd {
  201. uint32_t domain; /* domain number of one dependent group */
  202. uint32_t coord_type; /* coordination type */
  203. uint32_t num; /* number of processors in same domain */
  204. };
  205. DEFINE_GUEST_HANDLE_STRUCT(xen_processor_csd);
  206. struct xen_processor_cx {
  207. struct xen_power_register reg; /* GAS for Cx trigger register */
  208. uint8_t type; /* cstate value, c0: 0, c1: 1, ... */
  209. uint32_t latency; /* worst latency (ms) to enter/exit this cstate */
  210. uint32_t power; /* average power consumption(mW) */
  211. uint32_t dpcnt; /* number of dependency entries */
  212. GUEST_HANDLE(xen_processor_csd) dp; /* NULL if no dependency */
  213. };
  214. DEFINE_GUEST_HANDLE_STRUCT(xen_processor_cx);
  215. struct xen_processor_flags {
  216. uint32_t bm_control:1;
  217. uint32_t bm_check:1;
  218. uint32_t has_cst:1;
  219. uint32_t power_setup_done:1;
  220. uint32_t bm_rld_set:1;
  221. };
  222. struct xen_processor_power {
  223. uint32_t count; /* number of C state entries in array below */
  224. struct xen_processor_flags flags; /* global flags of this processor */
  225. GUEST_HANDLE(xen_processor_cx) states; /* supported c states */
  226. };
  227. struct xen_pct_register {
  228. uint8_t descriptor;
  229. uint16_t length;
  230. uint8_t space_id;
  231. uint8_t bit_width;
  232. uint8_t bit_offset;
  233. uint8_t reserved;
  234. uint64_t address;
  235. };
  236. struct xen_processor_px {
  237. uint64_t core_frequency; /* megahertz */
  238. uint64_t power; /* milliWatts */
  239. uint64_t transition_latency; /* microseconds */
  240. uint64_t bus_master_latency; /* microseconds */
  241. uint64_t control; /* control value */
  242. uint64_t status; /* success indicator */
  243. };
  244. DEFINE_GUEST_HANDLE_STRUCT(xen_processor_px);
  245. struct xen_psd_package {
  246. uint64_t num_entries;
  247. uint64_t revision;
  248. uint64_t domain;
  249. uint64_t coord_type;
  250. uint64_t num_processors;
  251. };
  252. struct xen_processor_performance {
  253. uint32_t flags; /* flag for Px sub info type */
  254. uint32_t platform_limit; /* Platform limitation on freq usage */
  255. struct xen_pct_register control_register;
  256. struct xen_pct_register status_register;
  257. uint32_t state_count; /* total available performance states */
  258. GUEST_HANDLE(xen_processor_px) states;
  259. struct xen_psd_package domain_info;
  260. uint32_t shared_type; /* coordination type of this processor */
  261. };
  262. DEFINE_GUEST_HANDLE_STRUCT(xen_processor_performance);
  263. struct xenpf_set_processor_pminfo {
  264. /* IN variables */
  265. uint32_t id; /* ACPI CPU ID */
  266. uint32_t type; /* {XEN_PM_CX, XEN_PM_PX} */
  267. union {
  268. struct xen_processor_power power;/* Cx: _CST/_CSD */
  269. struct xen_processor_performance perf; /* Px: _PPC/_PCT/_PSS/_PSD */
  270. GUEST_HANDLE(uint32_t) pdc;
  271. };
  272. };
  273. DEFINE_GUEST_HANDLE_STRUCT(xenpf_set_processor_pminfo);
  274. #define XENPF_get_cpuinfo 55
  275. struct xenpf_pcpuinfo {
  276. /* IN */
  277. uint32_t xen_cpuid;
  278. /* OUT */
  279. /* The maxium cpu_id that is present */
  280. uint32_t max_present;
  281. #define XEN_PCPU_FLAGS_ONLINE 1
  282. /* Correponding xen_cpuid is not present*/
  283. #define XEN_PCPU_FLAGS_INVALID 2
  284. uint32_t flags;
  285. uint32_t apic_id;
  286. uint32_t acpi_id;
  287. };
  288. DEFINE_GUEST_HANDLE_STRUCT(xenpf_pcpuinfo);
  289. struct xen_platform_op {
  290. uint32_t cmd;
  291. uint32_t interface_version; /* XENPF_INTERFACE_VERSION */
  292. union {
  293. struct xenpf_settime settime;
  294. struct xenpf_add_memtype add_memtype;
  295. struct xenpf_del_memtype del_memtype;
  296. struct xenpf_read_memtype read_memtype;
  297. struct xenpf_microcode_update microcode;
  298. struct xenpf_platform_quirk platform_quirk;
  299. struct xenpf_firmware_info firmware_info;
  300. struct xenpf_enter_acpi_sleep enter_acpi_sleep;
  301. struct xenpf_change_freq change_freq;
  302. struct xenpf_getidletime getidletime;
  303. struct xenpf_set_processor_pminfo set_pminfo;
  304. struct xenpf_pcpuinfo pcpu_info;
  305. uint8_t pad[128];
  306. } u;
  307. };
  308. DEFINE_GUEST_HANDLE_STRUCT(xen_platform_op_t);
  309. #endif /* __XEN_PUBLIC_PLATFORM_H__ */