platform.h 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379
  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/interface/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. xen_pfn_t 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. xen_pfn_t 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. #define XEN_FW_KBD_SHIFT_FLAGS 5 /* Int16, Fn02: Get keyboard shift flags. */
  106. struct xenpf_firmware_info {
  107. /* IN variables. */
  108. uint32_t type;
  109. uint32_t index;
  110. /* OUT variables. */
  111. union {
  112. struct {
  113. /* Int13, Fn48: Check Extensions Present. */
  114. uint8_t device; /* %dl: bios device number */
  115. uint8_t version; /* %ah: major version */
  116. uint16_t interface_support; /* %cx: support bitmap */
  117. /* Int13, Fn08: Legacy Get Device Parameters. */
  118. uint16_t legacy_max_cylinder; /* %cl[7:6]:%ch: max cyl # */
  119. uint8_t legacy_max_head; /* %dh: max head # */
  120. uint8_t legacy_sectors_per_track; /* %cl[5:0]: max sector # */
  121. /* Int13, Fn41: Get Device Parameters (as filled into %ds:%esi). */
  122. /* NB. First uint16_t of buffer must be set to buffer size. */
  123. GUEST_HANDLE(void) edd_params;
  124. } disk_info; /* XEN_FW_DISK_INFO */
  125. struct {
  126. uint8_t device; /* bios device number */
  127. uint32_t mbr_signature; /* offset 0x1b8 in mbr */
  128. } disk_mbr_signature; /* XEN_FW_DISK_MBR_SIGNATURE */
  129. struct {
  130. /* Int10, AX=4F15: Get EDID info. */
  131. uint8_t capabilities;
  132. uint8_t edid_transfer_time;
  133. /* must refer to 128-byte buffer */
  134. GUEST_HANDLE(uchar) edid;
  135. } vbeddc_info; /* XEN_FW_VBEDDC_INFO */
  136. uint8_t kbd_shift_flags; /* XEN_FW_KBD_SHIFT_FLAGS */
  137. } u;
  138. };
  139. DEFINE_GUEST_HANDLE_STRUCT(xenpf_firmware_info_t);
  140. #define XENPF_enter_acpi_sleep 51
  141. struct xenpf_enter_acpi_sleep {
  142. /* IN variables */
  143. uint16_t pm1a_cnt_val; /* PM1a control value. */
  144. uint16_t pm1b_cnt_val; /* PM1b control value. */
  145. uint32_t sleep_state; /* Which state to enter (Sn). */
  146. uint32_t flags; /* Must be zero. */
  147. };
  148. DEFINE_GUEST_HANDLE_STRUCT(xenpf_enter_acpi_sleep_t);
  149. #define XENPF_change_freq 52
  150. struct xenpf_change_freq {
  151. /* IN variables */
  152. uint32_t flags; /* Must be zero. */
  153. uint32_t cpu; /* Physical cpu. */
  154. uint64_t freq; /* New frequency (Hz). */
  155. };
  156. DEFINE_GUEST_HANDLE_STRUCT(xenpf_change_freq_t);
  157. /*
  158. * Get idle times (nanoseconds since boot) for physical CPUs specified in the
  159. * @cpumap_bitmap with range [0..@cpumap_nr_cpus-1]. The @idletime array is
  160. * indexed by CPU number; only entries with the corresponding @cpumap_bitmap
  161. * bit set are written to. On return, @cpumap_bitmap is modified so that any
  162. * non-existent CPUs are cleared. Such CPUs have their @idletime array entry
  163. * cleared.
  164. */
  165. #define XENPF_getidletime 53
  166. struct xenpf_getidletime {
  167. /* IN/OUT variables */
  168. /* IN: CPUs to interrogate; OUT: subset of IN which are present */
  169. GUEST_HANDLE(uchar) cpumap_bitmap;
  170. /* IN variables */
  171. /* Size of cpumap bitmap. */
  172. uint32_t cpumap_nr_cpus;
  173. /* Must be indexable for every cpu in cpumap_bitmap. */
  174. GUEST_HANDLE(uint64_t) idletime;
  175. /* OUT variables */
  176. /* System time when the idletime snapshots were taken. */
  177. uint64_t now;
  178. };
  179. DEFINE_GUEST_HANDLE_STRUCT(xenpf_getidletime_t);
  180. #define XENPF_set_processor_pminfo 54
  181. /* ability bits */
  182. #define XEN_PROCESSOR_PM_CX 1
  183. #define XEN_PROCESSOR_PM_PX 2
  184. #define XEN_PROCESSOR_PM_TX 4
  185. /* cmd type */
  186. #define XEN_PM_CX 0
  187. #define XEN_PM_PX 1
  188. #define XEN_PM_TX 2
  189. #define XEN_PM_PDC 3
  190. /* Px sub info type */
  191. #define XEN_PX_PCT 1
  192. #define XEN_PX_PSS 2
  193. #define XEN_PX_PPC 4
  194. #define XEN_PX_PSD 8
  195. struct xen_power_register {
  196. uint32_t space_id;
  197. uint32_t bit_width;
  198. uint32_t bit_offset;
  199. uint32_t access_size;
  200. uint64_t address;
  201. };
  202. struct xen_processor_csd {
  203. uint32_t domain; /* domain number of one dependent group */
  204. uint32_t coord_type; /* coordination type */
  205. uint32_t num; /* number of processors in same domain */
  206. };
  207. DEFINE_GUEST_HANDLE_STRUCT(xen_processor_csd);
  208. struct xen_processor_cx {
  209. struct xen_power_register reg; /* GAS for Cx trigger register */
  210. uint8_t type; /* cstate value, c0: 0, c1: 1, ... */
  211. uint32_t latency; /* worst latency (ms) to enter/exit this cstate */
  212. uint32_t power; /* average power consumption(mW) */
  213. uint32_t dpcnt; /* number of dependency entries */
  214. GUEST_HANDLE(xen_processor_csd) dp; /* NULL if no dependency */
  215. };
  216. DEFINE_GUEST_HANDLE_STRUCT(xen_processor_cx);
  217. struct xen_processor_flags {
  218. uint32_t bm_control:1;
  219. uint32_t bm_check:1;
  220. uint32_t has_cst:1;
  221. uint32_t power_setup_done:1;
  222. uint32_t bm_rld_set:1;
  223. };
  224. struct xen_processor_power {
  225. uint32_t count; /* number of C state entries in array below */
  226. struct xen_processor_flags flags; /* global flags of this processor */
  227. GUEST_HANDLE(xen_processor_cx) states; /* supported c states */
  228. };
  229. struct xen_pct_register {
  230. uint8_t descriptor;
  231. uint16_t length;
  232. uint8_t space_id;
  233. uint8_t bit_width;
  234. uint8_t bit_offset;
  235. uint8_t reserved;
  236. uint64_t address;
  237. };
  238. struct xen_processor_px {
  239. uint64_t core_frequency; /* megahertz */
  240. uint64_t power; /* milliWatts */
  241. uint64_t transition_latency; /* microseconds */
  242. uint64_t bus_master_latency; /* microseconds */
  243. uint64_t control; /* control value */
  244. uint64_t status; /* success indicator */
  245. };
  246. DEFINE_GUEST_HANDLE_STRUCT(xen_processor_px);
  247. struct xen_psd_package {
  248. uint64_t num_entries;
  249. uint64_t revision;
  250. uint64_t domain;
  251. uint64_t coord_type;
  252. uint64_t num_processors;
  253. };
  254. struct xen_processor_performance {
  255. uint32_t flags; /* flag for Px sub info type */
  256. uint32_t platform_limit; /* Platform limitation on freq usage */
  257. struct xen_pct_register control_register;
  258. struct xen_pct_register status_register;
  259. uint32_t state_count; /* total available performance states */
  260. GUEST_HANDLE(xen_processor_px) states;
  261. struct xen_psd_package domain_info;
  262. uint32_t shared_type; /* coordination type of this processor */
  263. };
  264. DEFINE_GUEST_HANDLE_STRUCT(xen_processor_performance);
  265. struct xenpf_set_processor_pminfo {
  266. /* IN variables */
  267. uint32_t id; /* ACPI CPU ID */
  268. uint32_t type; /* {XEN_PM_CX, XEN_PM_PX} */
  269. union {
  270. struct xen_processor_power power;/* Cx: _CST/_CSD */
  271. struct xen_processor_performance perf; /* Px: _PPC/_PCT/_PSS/_PSD */
  272. GUEST_HANDLE(uint32_t) pdc;
  273. };
  274. };
  275. DEFINE_GUEST_HANDLE_STRUCT(xenpf_set_processor_pminfo);
  276. #define XENPF_get_cpuinfo 55
  277. struct xenpf_pcpuinfo {
  278. /* IN */
  279. uint32_t xen_cpuid;
  280. /* OUT */
  281. /* The maxium cpu_id that is present */
  282. uint32_t max_present;
  283. #define XEN_PCPU_FLAGS_ONLINE 1
  284. /* Correponding xen_cpuid is not present*/
  285. #define XEN_PCPU_FLAGS_INVALID 2
  286. uint32_t flags;
  287. uint32_t apic_id;
  288. uint32_t acpi_id;
  289. };
  290. DEFINE_GUEST_HANDLE_STRUCT(xenpf_pcpuinfo);
  291. #define XENPF_cpu_online 56
  292. #define XENPF_cpu_offline 57
  293. struct xenpf_cpu_ol {
  294. uint32_t cpuid;
  295. };
  296. DEFINE_GUEST_HANDLE_STRUCT(xenpf_cpu_ol);
  297. #define XENPF_cpu_hotadd 58
  298. struct xenpf_cpu_hotadd {
  299. uint32_t apic_id;
  300. uint32_t acpi_id;
  301. uint32_t pxm;
  302. };
  303. #define XENPF_mem_hotadd 59
  304. struct xenpf_mem_hotadd {
  305. uint64_t spfn;
  306. uint64_t epfn;
  307. uint32_t pxm;
  308. uint32_t flags;
  309. };
  310. #define XENPF_core_parking 60
  311. struct xenpf_core_parking {
  312. /* IN variables */
  313. #define XEN_CORE_PARKING_SET 1
  314. #define XEN_CORE_PARKING_GET 2
  315. uint32_t type;
  316. /* IN variables: set cpu nums expected to be idled */
  317. /* OUT variables: get cpu nums actually be idled */
  318. uint32_t idle_nums;
  319. };
  320. DEFINE_GUEST_HANDLE_STRUCT(xenpf_core_parking);
  321. struct xen_platform_op {
  322. uint32_t cmd;
  323. uint32_t interface_version; /* XENPF_INTERFACE_VERSION */
  324. union {
  325. struct xenpf_settime settime;
  326. struct xenpf_add_memtype add_memtype;
  327. struct xenpf_del_memtype del_memtype;
  328. struct xenpf_read_memtype read_memtype;
  329. struct xenpf_microcode_update microcode;
  330. struct xenpf_platform_quirk platform_quirk;
  331. struct xenpf_firmware_info firmware_info;
  332. struct xenpf_enter_acpi_sleep enter_acpi_sleep;
  333. struct xenpf_change_freq change_freq;
  334. struct xenpf_getidletime getidletime;
  335. struct xenpf_set_processor_pminfo set_pminfo;
  336. struct xenpf_pcpuinfo pcpu_info;
  337. struct xenpf_cpu_ol cpu_ol;
  338. struct xenpf_cpu_hotadd cpu_add;
  339. struct xenpf_mem_hotadd mem_add;
  340. struct xenpf_core_parking core_parking;
  341. uint8_t pad[128];
  342. } u;
  343. };
  344. DEFINE_GUEST_HANDLE_STRUCT(xen_platform_op_t);
  345. #endif /* __XEN_PUBLIC_PLATFORM_H__ */