platform.h 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521
  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_efi_runtime_call 49
  102. #define XEN_EFI_get_time 1
  103. #define XEN_EFI_set_time 2
  104. #define XEN_EFI_get_wakeup_time 3
  105. #define XEN_EFI_set_wakeup_time 4
  106. #define XEN_EFI_get_next_high_monotonic_count 5
  107. #define XEN_EFI_get_variable 6
  108. #define XEN_EFI_set_variable 7
  109. #define XEN_EFI_get_next_variable_name 8
  110. #define XEN_EFI_query_variable_info 9
  111. #define XEN_EFI_query_capsule_capabilities 10
  112. #define XEN_EFI_update_capsule 11
  113. struct xenpf_efi_runtime_call {
  114. uint32_t function;
  115. /*
  116. * This field is generally used for per sub-function flags (defined
  117. * below), except for the XEN_EFI_get_next_high_monotonic_count case,
  118. * where it holds the single returned value.
  119. */
  120. uint32_t misc;
  121. xen_ulong_t status;
  122. union {
  123. #define XEN_EFI_GET_TIME_SET_CLEARS_NS 0x00000001
  124. struct {
  125. struct xenpf_efi_time {
  126. uint16_t year;
  127. uint8_t month;
  128. uint8_t day;
  129. uint8_t hour;
  130. uint8_t min;
  131. uint8_t sec;
  132. uint32_t ns;
  133. int16_t tz;
  134. uint8_t daylight;
  135. } time;
  136. uint32_t resolution;
  137. uint32_t accuracy;
  138. } get_time;
  139. struct xenpf_efi_time set_time;
  140. #define XEN_EFI_GET_WAKEUP_TIME_ENABLED 0x00000001
  141. #define XEN_EFI_GET_WAKEUP_TIME_PENDING 0x00000002
  142. struct xenpf_efi_time get_wakeup_time;
  143. #define XEN_EFI_SET_WAKEUP_TIME_ENABLE 0x00000001
  144. #define XEN_EFI_SET_WAKEUP_TIME_ENABLE_ONLY 0x00000002
  145. struct xenpf_efi_time set_wakeup_time;
  146. #define XEN_EFI_VARIABLE_NON_VOLATILE 0x00000001
  147. #define XEN_EFI_VARIABLE_BOOTSERVICE_ACCESS 0x00000002
  148. #define XEN_EFI_VARIABLE_RUNTIME_ACCESS 0x00000004
  149. struct {
  150. GUEST_HANDLE(void) name; /* UCS-2/UTF-16 string */
  151. xen_ulong_t size;
  152. GUEST_HANDLE(void) data;
  153. struct xenpf_efi_guid {
  154. uint32_t data1;
  155. uint16_t data2;
  156. uint16_t data3;
  157. uint8_t data4[8];
  158. } vendor_guid;
  159. } get_variable, set_variable;
  160. struct {
  161. xen_ulong_t size;
  162. GUEST_HANDLE(void) name; /* UCS-2/UTF-16 string */
  163. struct xenpf_efi_guid vendor_guid;
  164. } get_next_variable_name;
  165. struct {
  166. uint32_t attr;
  167. uint64_t max_store_size;
  168. uint64_t remain_store_size;
  169. uint64_t max_size;
  170. } query_variable_info;
  171. struct {
  172. GUEST_HANDLE(void) capsule_header_array;
  173. xen_ulong_t capsule_count;
  174. uint64_t max_capsule_size;
  175. uint32_t reset_type;
  176. } query_capsule_capabilities;
  177. struct {
  178. GUEST_HANDLE(void) capsule_header_array;
  179. xen_ulong_t capsule_count;
  180. uint64_t sg_list; /* machine address */
  181. } update_capsule;
  182. } u;
  183. };
  184. DEFINE_GUEST_HANDLE_STRUCT(xenpf_efi_runtime_call);
  185. #define XEN_FW_EFI_VERSION 0
  186. #define XEN_FW_EFI_CONFIG_TABLE 1
  187. #define XEN_FW_EFI_VENDOR 2
  188. #define XEN_FW_EFI_MEM_INFO 3
  189. #define XEN_FW_EFI_RT_VERSION 4
  190. #define XENPF_firmware_info 50
  191. #define XEN_FW_DISK_INFO 1 /* from int 13 AH=08/41/48 */
  192. #define XEN_FW_DISK_MBR_SIGNATURE 2 /* from MBR offset 0x1b8 */
  193. #define XEN_FW_VBEDDC_INFO 3 /* from int 10 AX=4f15 */
  194. #define XEN_FW_EFI_INFO 4 /* from EFI */
  195. #define XEN_FW_KBD_SHIFT_FLAGS 5 /* Int16, Fn02: Get keyboard shift flags. */
  196. struct xenpf_firmware_info {
  197. /* IN variables. */
  198. uint32_t type;
  199. uint32_t index;
  200. /* OUT variables. */
  201. union {
  202. struct {
  203. /* Int13, Fn48: Check Extensions Present. */
  204. uint8_t device; /* %dl: bios device number */
  205. uint8_t version; /* %ah: major version */
  206. uint16_t interface_support; /* %cx: support bitmap */
  207. /* Int13, Fn08: Legacy Get Device Parameters. */
  208. uint16_t legacy_max_cylinder; /* %cl[7:6]:%ch: max cyl # */
  209. uint8_t legacy_max_head; /* %dh: max head # */
  210. uint8_t legacy_sectors_per_track; /* %cl[5:0]: max sector # */
  211. /* Int13, Fn41: Get Device Parameters (as filled into %ds:%esi). */
  212. /* NB. First uint16_t of buffer must be set to buffer size. */
  213. GUEST_HANDLE(void) edd_params;
  214. } disk_info; /* XEN_FW_DISK_INFO */
  215. struct {
  216. uint8_t device; /* bios device number */
  217. uint32_t mbr_signature; /* offset 0x1b8 in mbr */
  218. } disk_mbr_signature; /* XEN_FW_DISK_MBR_SIGNATURE */
  219. struct {
  220. /* Int10, AX=4F15: Get EDID info. */
  221. uint8_t capabilities;
  222. uint8_t edid_transfer_time;
  223. /* must refer to 128-byte buffer */
  224. GUEST_HANDLE(uchar) edid;
  225. } vbeddc_info; /* XEN_FW_VBEDDC_INFO */
  226. union xenpf_efi_info {
  227. uint32_t version;
  228. struct {
  229. uint64_t addr; /* EFI_CONFIGURATION_TABLE */
  230. uint32_t nent;
  231. } cfg;
  232. struct {
  233. uint32_t revision;
  234. uint32_t bufsz; /* input, in bytes */
  235. GUEST_HANDLE(void) name;
  236. /* UCS-2/UTF-16 string */
  237. } vendor;
  238. struct {
  239. uint64_t addr;
  240. uint64_t size;
  241. uint64_t attr;
  242. uint32_t type;
  243. } mem;
  244. } efi_info; /* XEN_FW_EFI_INFO */
  245. uint8_t kbd_shift_flags; /* XEN_FW_KBD_SHIFT_FLAGS */
  246. } u;
  247. };
  248. DEFINE_GUEST_HANDLE_STRUCT(xenpf_firmware_info_t);
  249. #define XENPF_enter_acpi_sleep 51
  250. struct xenpf_enter_acpi_sleep {
  251. /* IN variables */
  252. uint16_t val_a; /* PM1a control / sleep type A. */
  253. uint16_t val_b; /* PM1b control / sleep type B. */
  254. uint32_t sleep_state; /* Which state to enter (Sn). */
  255. #define XENPF_ACPI_SLEEP_EXTENDED 0x00000001
  256. uint32_t flags; /* XENPF_ACPI_SLEEP_*. */
  257. };
  258. DEFINE_GUEST_HANDLE_STRUCT(xenpf_enter_acpi_sleep_t);
  259. #define XENPF_change_freq 52
  260. struct xenpf_change_freq {
  261. /* IN variables */
  262. uint32_t flags; /* Must be zero. */
  263. uint32_t cpu; /* Physical cpu. */
  264. uint64_t freq; /* New frequency (Hz). */
  265. };
  266. DEFINE_GUEST_HANDLE_STRUCT(xenpf_change_freq_t);
  267. /*
  268. * Get idle times (nanoseconds since boot) for physical CPUs specified in the
  269. * @cpumap_bitmap with range [0..@cpumap_nr_cpus-1]. The @idletime array is
  270. * indexed by CPU number; only entries with the corresponding @cpumap_bitmap
  271. * bit set are written to. On return, @cpumap_bitmap is modified so that any
  272. * non-existent CPUs are cleared. Such CPUs have their @idletime array entry
  273. * cleared.
  274. */
  275. #define XENPF_getidletime 53
  276. struct xenpf_getidletime {
  277. /* IN/OUT variables */
  278. /* IN: CPUs to interrogate; OUT: subset of IN which are present */
  279. GUEST_HANDLE(uchar) cpumap_bitmap;
  280. /* IN variables */
  281. /* Size of cpumap bitmap. */
  282. uint32_t cpumap_nr_cpus;
  283. /* Must be indexable for every cpu in cpumap_bitmap. */
  284. GUEST_HANDLE(uint64_t) idletime;
  285. /* OUT variables */
  286. /* System time when the idletime snapshots were taken. */
  287. uint64_t now;
  288. };
  289. DEFINE_GUEST_HANDLE_STRUCT(xenpf_getidletime_t);
  290. #define XENPF_set_processor_pminfo 54
  291. /* ability bits */
  292. #define XEN_PROCESSOR_PM_CX 1
  293. #define XEN_PROCESSOR_PM_PX 2
  294. #define XEN_PROCESSOR_PM_TX 4
  295. /* cmd type */
  296. #define XEN_PM_CX 0
  297. #define XEN_PM_PX 1
  298. #define XEN_PM_TX 2
  299. #define XEN_PM_PDC 3
  300. /* Px sub info type */
  301. #define XEN_PX_PCT 1
  302. #define XEN_PX_PSS 2
  303. #define XEN_PX_PPC 4
  304. #define XEN_PX_PSD 8
  305. struct xen_power_register {
  306. uint32_t space_id;
  307. uint32_t bit_width;
  308. uint32_t bit_offset;
  309. uint32_t access_size;
  310. uint64_t address;
  311. };
  312. struct xen_processor_csd {
  313. uint32_t domain; /* domain number of one dependent group */
  314. uint32_t coord_type; /* coordination type */
  315. uint32_t num; /* number of processors in same domain */
  316. };
  317. DEFINE_GUEST_HANDLE_STRUCT(xen_processor_csd);
  318. struct xen_processor_cx {
  319. struct xen_power_register reg; /* GAS for Cx trigger register */
  320. uint8_t type; /* cstate value, c0: 0, c1: 1, ... */
  321. uint32_t latency; /* worst latency (ms) to enter/exit this cstate */
  322. uint32_t power; /* average power consumption(mW) */
  323. uint32_t dpcnt; /* number of dependency entries */
  324. GUEST_HANDLE(xen_processor_csd) dp; /* NULL if no dependency */
  325. };
  326. DEFINE_GUEST_HANDLE_STRUCT(xen_processor_cx);
  327. struct xen_processor_flags {
  328. uint32_t bm_control:1;
  329. uint32_t bm_check:1;
  330. uint32_t has_cst:1;
  331. uint32_t power_setup_done:1;
  332. uint32_t bm_rld_set:1;
  333. };
  334. struct xen_processor_power {
  335. uint32_t count; /* number of C state entries in array below */
  336. struct xen_processor_flags flags; /* global flags of this processor */
  337. GUEST_HANDLE(xen_processor_cx) states; /* supported c states */
  338. };
  339. struct xen_pct_register {
  340. uint8_t descriptor;
  341. uint16_t length;
  342. uint8_t space_id;
  343. uint8_t bit_width;
  344. uint8_t bit_offset;
  345. uint8_t reserved;
  346. uint64_t address;
  347. };
  348. struct xen_processor_px {
  349. uint64_t core_frequency; /* megahertz */
  350. uint64_t power; /* milliWatts */
  351. uint64_t transition_latency; /* microseconds */
  352. uint64_t bus_master_latency; /* microseconds */
  353. uint64_t control; /* control value */
  354. uint64_t status; /* success indicator */
  355. };
  356. DEFINE_GUEST_HANDLE_STRUCT(xen_processor_px);
  357. struct xen_psd_package {
  358. uint64_t num_entries;
  359. uint64_t revision;
  360. uint64_t domain;
  361. uint64_t coord_type;
  362. uint64_t num_processors;
  363. };
  364. struct xen_processor_performance {
  365. uint32_t flags; /* flag for Px sub info type */
  366. uint32_t platform_limit; /* Platform limitation on freq usage */
  367. struct xen_pct_register control_register;
  368. struct xen_pct_register status_register;
  369. uint32_t state_count; /* total available performance states */
  370. GUEST_HANDLE(xen_processor_px) states;
  371. struct xen_psd_package domain_info;
  372. uint32_t shared_type; /* coordination type of this processor */
  373. };
  374. DEFINE_GUEST_HANDLE_STRUCT(xen_processor_performance);
  375. struct xenpf_set_processor_pminfo {
  376. /* IN variables */
  377. uint32_t id; /* ACPI CPU ID */
  378. uint32_t type; /* {XEN_PM_CX, XEN_PM_PX} */
  379. union {
  380. struct xen_processor_power power;/* Cx: _CST/_CSD */
  381. struct xen_processor_performance perf; /* Px: _PPC/_PCT/_PSS/_PSD */
  382. GUEST_HANDLE(uint32_t) pdc;
  383. };
  384. };
  385. DEFINE_GUEST_HANDLE_STRUCT(xenpf_set_processor_pminfo);
  386. #define XENPF_get_cpuinfo 55
  387. struct xenpf_pcpuinfo {
  388. /* IN */
  389. uint32_t xen_cpuid;
  390. /* OUT */
  391. /* The maxium cpu_id that is present */
  392. uint32_t max_present;
  393. #define XEN_PCPU_FLAGS_ONLINE 1
  394. /* Correponding xen_cpuid is not present*/
  395. #define XEN_PCPU_FLAGS_INVALID 2
  396. uint32_t flags;
  397. uint32_t apic_id;
  398. uint32_t acpi_id;
  399. };
  400. DEFINE_GUEST_HANDLE_STRUCT(xenpf_pcpuinfo);
  401. #define XENPF_cpu_online 56
  402. #define XENPF_cpu_offline 57
  403. struct xenpf_cpu_ol {
  404. uint32_t cpuid;
  405. };
  406. DEFINE_GUEST_HANDLE_STRUCT(xenpf_cpu_ol);
  407. #define XENPF_cpu_hotadd 58
  408. struct xenpf_cpu_hotadd {
  409. uint32_t apic_id;
  410. uint32_t acpi_id;
  411. uint32_t pxm;
  412. };
  413. #define XENPF_mem_hotadd 59
  414. struct xenpf_mem_hotadd {
  415. uint64_t spfn;
  416. uint64_t epfn;
  417. uint32_t pxm;
  418. uint32_t flags;
  419. };
  420. #define XENPF_core_parking 60
  421. struct xenpf_core_parking {
  422. /* IN variables */
  423. #define XEN_CORE_PARKING_SET 1
  424. #define XEN_CORE_PARKING_GET 2
  425. uint32_t type;
  426. /* IN variables: set cpu nums expected to be idled */
  427. /* OUT variables: get cpu nums actually be idled */
  428. uint32_t idle_nums;
  429. };
  430. DEFINE_GUEST_HANDLE_STRUCT(xenpf_core_parking);
  431. #define XENPF_get_symbol 63
  432. struct xenpf_symdata {
  433. /* IN/OUT variables */
  434. uint32_t namelen; /* size of 'name' buffer */
  435. /* IN/OUT variables */
  436. uint32_t symnum; /* IN: Symbol to read */
  437. /* OUT: Next available symbol. If same as IN */
  438. /* then we reached the end */
  439. /* OUT variables */
  440. GUEST_HANDLE(char) name;
  441. uint64_t address;
  442. char type;
  443. };
  444. DEFINE_GUEST_HANDLE_STRUCT(xenpf_symdata);
  445. struct xen_platform_op {
  446. uint32_t cmd;
  447. uint32_t interface_version; /* XENPF_INTERFACE_VERSION */
  448. union {
  449. struct xenpf_settime settime;
  450. struct xenpf_add_memtype add_memtype;
  451. struct xenpf_del_memtype del_memtype;
  452. struct xenpf_read_memtype read_memtype;
  453. struct xenpf_microcode_update microcode;
  454. struct xenpf_platform_quirk platform_quirk;
  455. struct xenpf_efi_runtime_call efi_runtime_call;
  456. struct xenpf_firmware_info firmware_info;
  457. struct xenpf_enter_acpi_sleep enter_acpi_sleep;
  458. struct xenpf_change_freq change_freq;
  459. struct xenpf_getidletime getidletime;
  460. struct xenpf_set_processor_pminfo set_pminfo;
  461. struct xenpf_pcpuinfo pcpu_info;
  462. struct xenpf_cpu_ol cpu_ol;
  463. struct xenpf_cpu_hotadd cpu_add;
  464. struct xenpf_mem_hotadd mem_add;
  465. struct xenpf_core_parking core_parking;
  466. struct xenpf_symdata symdata;
  467. uint8_t pad[128];
  468. } u;
  469. };
  470. DEFINE_GUEST_HANDLE_STRUCT(xen_platform_op_t);
  471. #endif /* __XEN_PUBLIC_PLATFORM_H__ */