1 /******************************************************************************
4 * Hardware platform operations. Intended for use by domain-0 kernel.
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:
13 * The above copyright notice and this permission notice shall be included in
14 * all copies or substantial portions of the Software.
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.
24 * Copyright (c) 2002-2006, K Fraser
27 #ifndef __XEN_PUBLIC_PLATFORM_H__
28 #define __XEN_PUBLIC_PLATFORM_H__
32 #define XENPF_INTERFACE_VERSION 0x03000001
35 * Set clock such that it would read <secs,nsecs> after 00:00:00 UTC,
36 * 1 January, 1970 if the current system time was <system_time>.
38 #define XENPF_settime32 17
39 struct xenpf_settime32 {
45 #define XENPF_settime64 62
46 struct xenpf_settime64 {
53 #if __XEN_INTERFACE_VERSION__ < 0x00040600
54 #define XENPF_settime XENPF_settime32
55 #define xenpf_settime xenpf_settime32
57 #define XENPF_settime XENPF_settime64
58 #define xenpf_settime xenpf_settime64
60 typedef struct xenpf_settime xenpf_settime_t;
61 DEFINE_XEN_GUEST_HANDLE(xenpf_settime_t);
64 * Request memory range (@mfn, @mfn+@nr_mfns-1) to have type @type.
65 * On x86, @type is an architecture-defined MTRR memory type.
66 * On success, returns the MTRR that was used (@reg) and a handle that can
67 * be passed to XENPF_DEL_MEMTYPE to accurately tear down the new setting.
70 #define XENPF_add_memtype 31
71 struct xenpf_add_memtype {
80 typedef struct xenpf_add_memtype xenpf_add_memtype_t;
81 DEFINE_XEN_GUEST_HANDLE(xenpf_add_memtype_t);
84 * Tear down an existing memory-range type. If @handle is remembered then it
85 * should be passed in to accurately tear down the correct setting (in case
86 * of overlapping memory regions with differing types). If it is not known
87 * then @handle should be set to zero. In all cases @reg must be set.
90 #define XENPF_del_memtype 32
91 struct xenpf_del_memtype {
96 typedef struct xenpf_del_memtype xenpf_del_memtype_t;
97 DEFINE_XEN_GUEST_HANDLE(xenpf_del_memtype_t);
99 /* Read current type of an MTRR (x86-specific). */
100 #define XENPF_read_memtype 33
101 struct xenpf_read_memtype {
109 typedef struct xenpf_read_memtype xenpf_read_memtype_t;
110 DEFINE_XEN_GUEST_HANDLE(xenpf_read_memtype_t);
112 #define XENPF_microcode_update 35
113 struct xenpf_microcode_update {
115 XEN_GUEST_HANDLE(const_void) data;/* Pointer to microcode data */
116 uint32_t length; /* Length of microcode data. */
118 typedef struct xenpf_microcode_update xenpf_microcode_update_t;
119 DEFINE_XEN_GUEST_HANDLE(xenpf_microcode_update_t);
121 #define XENPF_platform_quirk 39
122 #define QUIRK_NOIRQBALANCING 1 /* Do not restrict IO-APIC RTE targets */
123 #define QUIRK_IOAPIC_BAD_REGSEL 2 /* IO-APIC REGSEL forgets its value */
124 #define QUIRK_IOAPIC_GOOD_REGSEL 3 /* IO-APIC REGSEL behaves properly */
125 struct xenpf_platform_quirk {
129 typedef struct xenpf_platform_quirk xenpf_platform_quirk_t;
130 DEFINE_XEN_GUEST_HANDLE(xenpf_platform_quirk_t);
132 #define XENPF_efi_runtime_call 49
133 #define XEN_EFI_get_time 1
134 #define XEN_EFI_set_time 2
135 #define XEN_EFI_get_wakeup_time 3
136 #define XEN_EFI_set_wakeup_time 4
137 #define XEN_EFI_get_next_high_monotonic_count 5
138 #define XEN_EFI_get_variable 6
139 #define XEN_EFI_set_variable 7
140 #define XEN_EFI_get_next_variable_name 8
141 #define XEN_EFI_query_variable_info 9
142 #define XEN_EFI_query_capsule_capabilities 10
143 #define XEN_EFI_update_capsule 11
145 struct xenpf_efi_time {
157 struct xenpf_efi_guid {
164 struct xenpf_efi_runtime_call {
167 * This field is generally used for per sub-function flags (defined
168 * below), except for the XEN_EFI_get_next_high_monotonic_count case,
169 * where it holds the single returned value.
174 #define XEN_EFI_GET_TIME_SET_CLEARS_NS 0x00000001
176 struct xenpf_efi_time time;
181 struct xenpf_efi_time set_time;
183 #define XEN_EFI_GET_WAKEUP_TIME_ENABLED 0x00000001
184 #define XEN_EFI_GET_WAKEUP_TIME_PENDING 0x00000002
185 struct xenpf_efi_time get_wakeup_time;
187 #define XEN_EFI_SET_WAKEUP_TIME_ENABLE 0x00000001
188 #define XEN_EFI_SET_WAKEUP_TIME_ENABLE_ONLY 0x00000002
189 struct xenpf_efi_time set_wakeup_time;
191 #define XEN_EFI_VARIABLE_NON_VOLATILE 0x00000001
192 #define XEN_EFI_VARIABLE_BOOTSERVICE_ACCESS 0x00000002
193 #define XEN_EFI_VARIABLE_RUNTIME_ACCESS 0x00000004
195 XEN_GUEST_HANDLE(void) name; /* UCS-2/UTF-16 string */
197 XEN_GUEST_HANDLE(void) data;
198 struct xenpf_efi_guid vendor_guid;
199 } get_variable, set_variable;
203 XEN_GUEST_HANDLE(void) name; /* UCS-2/UTF-16 string */
204 struct xenpf_efi_guid vendor_guid;
205 } get_next_variable_name;
207 #define XEN_EFI_VARINFO_BOOT_SNAPSHOT 0x00000001
210 uint64_t max_store_size;
211 uint64_t remain_store_size;
213 } query_variable_info;
216 XEN_GUEST_HANDLE(void) capsule_header_array;
217 xen_ulong_t capsule_count;
218 uint64_t max_capsule_size;
220 } query_capsule_capabilities;
223 XEN_GUEST_HANDLE(void) capsule_header_array;
224 xen_ulong_t capsule_count;
225 uint64_t sg_list; /* machine address */
229 typedef struct xenpf_efi_runtime_call xenpf_efi_runtime_call_t;
230 DEFINE_XEN_GUEST_HANDLE(xenpf_efi_runtime_call_t);
232 #define XENPF_firmware_info 50
233 #define XEN_FW_DISK_INFO 1 /* from int 13 AH=08/41/48 */
234 #define XEN_FW_DISK_MBR_SIGNATURE 2 /* from MBR offset 0x1b8 */
235 #define XEN_FW_VBEDDC_INFO 3 /* from int 10 AX=4f15 */
236 #define XEN_FW_EFI_INFO 4 /* from EFI */
237 #define XEN_FW_EFI_VERSION 0
238 #define XEN_FW_EFI_CONFIG_TABLE 1
239 #define XEN_FW_EFI_VENDOR 2
240 #define XEN_FW_EFI_MEM_INFO 3
241 #define XEN_FW_EFI_RT_VERSION 4
242 #define XEN_FW_EFI_PCI_ROM 5
243 #define XEN_FW_KBD_SHIFT_FLAGS 5
244 struct xenpf_firmware_info {
251 /* Int13, Fn48: Check Extensions Present. */
252 uint8_t device; /* %dl: bios device number */
253 uint8_t version; /* %ah: major version */
254 uint16_t interface_support; /* %cx: support bitmap */
255 /* Int13, Fn08: Legacy Get Device Parameters. */
256 uint16_t legacy_max_cylinder; /* %cl[7:6]:%ch: max cyl # */
257 uint8_t legacy_max_head; /* %dh: max head # */
258 uint8_t legacy_sectors_per_track; /* %cl[5:0]: max sector # */
259 /* Int13, Fn41: Get Device Parameters (as filled into %ds:%esi). */
260 /* NB. First uint16_t of buffer must be set to buffer size. */
261 XEN_GUEST_HANDLE(void) edd_params;
262 } disk_info; /* XEN_FW_DISK_INFO */
264 uint8_t device; /* bios device number */
265 uint32_t mbr_signature; /* offset 0x1b8 in mbr */
266 } disk_mbr_signature; /* XEN_FW_DISK_MBR_SIGNATURE */
268 /* Int10, AX=4F15: Get EDID info. */
269 uint8_t capabilities;
270 uint8_t edid_transfer_time;
271 /* must refer to 128-byte buffer */
272 XEN_GUEST_HANDLE(uint8) edid;
273 } vbeddc_info; /* XEN_FW_VBEDDC_INFO */
274 union xenpf_efi_info {
277 uint64_t addr; /* EFI_CONFIGURATION_TABLE */
282 uint32_t bufsz; /* input, in bytes */
283 XEN_GUEST_HANDLE(void) name; /* UCS-2/UTF-16 string */
302 } efi_info; /* XEN_FW_EFI_INFO */
304 /* Int16, Fn02: Get keyboard shift flags. */
305 uint8_t kbd_shift_flags; /* XEN_FW_KBD_SHIFT_FLAGS */
308 typedef struct xenpf_firmware_info xenpf_firmware_info_t;
309 DEFINE_XEN_GUEST_HANDLE(xenpf_firmware_info_t);
311 #define XENPF_enter_acpi_sleep 51
312 struct xenpf_enter_acpi_sleep {
314 #if __XEN_INTERFACE_VERSION__ < 0x00040300
315 uint16_t pm1a_cnt_val; /* PM1a control value. */
316 uint16_t pm1b_cnt_val; /* PM1b control value. */
318 uint16_t val_a; /* PM1a control / sleep type A. */
319 uint16_t val_b; /* PM1b control / sleep type B. */
321 uint32_t sleep_state; /* Which state to enter (Sn). */
322 #define XENPF_ACPI_SLEEP_EXTENDED 0x00000001
323 uint32_t flags; /* XENPF_ACPI_SLEEP_*. */
325 typedef struct xenpf_enter_acpi_sleep xenpf_enter_acpi_sleep_t;
326 DEFINE_XEN_GUEST_HANDLE(xenpf_enter_acpi_sleep_t);
328 #define XENPF_change_freq 52
329 struct xenpf_change_freq {
331 uint32_t flags; /* Must be zero. */
332 uint32_t cpu; /* Physical cpu. */
333 uint64_t freq; /* New frequency (Hz). */
335 typedef struct xenpf_change_freq xenpf_change_freq_t;
336 DEFINE_XEN_GUEST_HANDLE(xenpf_change_freq_t);
339 * Get idle times (nanoseconds since boot) for physical CPUs specified in the
340 * @cpumap_bitmap with range [0..@cpumap_nr_cpus-1]. The @idletime array is
341 * indexed by CPU number; only entries with the corresponding @cpumap_bitmap
342 * bit set are written to. On return, @cpumap_bitmap is modified so that any
343 * non-existent CPUs are cleared. Such CPUs have their @idletime array entry
346 #define XENPF_getidletime 53
347 struct xenpf_getidletime {
348 /* IN/OUT variables */
349 /* IN: CPUs to interrogate; OUT: subset of IN which are present */
350 XEN_GUEST_HANDLE(uint8) cpumap_bitmap;
352 /* Size of cpumap bitmap. */
353 uint32_t cpumap_nr_cpus;
354 /* Must be indexable for every cpu in cpumap_bitmap. */
355 XEN_GUEST_HANDLE(uint64) idletime;
357 /* System time when the idletime snapshots were taken. */
360 typedef struct xenpf_getidletime xenpf_getidletime_t;
361 DEFINE_XEN_GUEST_HANDLE(xenpf_getidletime_t);
363 #define XENPF_set_processor_pminfo 54
366 #define XEN_PROCESSOR_PM_CX 1
367 #define XEN_PROCESSOR_PM_PX 2
368 #define XEN_PROCESSOR_PM_TX 4
376 /* Px sub info type */
382 struct xen_power_register {
386 uint32_t access_size;
390 struct xen_processor_csd {
391 uint32_t domain; /* domain number of one dependent group */
392 uint32_t coord_type; /* coordination type */
393 uint32_t num; /* number of processors in same domain */
395 typedef struct xen_processor_csd xen_processor_csd_t;
396 DEFINE_XEN_GUEST_HANDLE(xen_processor_csd_t);
398 struct xen_processor_cx {
399 struct xen_power_register reg; /* GAS for Cx trigger register */
400 uint8_t type; /* cstate value, c0: 0, c1: 1, ... */
401 uint32_t latency; /* worst latency (ms) to enter/exit this cstate */
402 uint32_t power; /* average power consumption(mW) */
403 uint32_t dpcnt; /* number of dependency entries */
404 XEN_GUEST_HANDLE(xen_processor_csd_t) dp; /* NULL if no dependency */
406 typedef struct xen_processor_cx xen_processor_cx_t;
407 DEFINE_XEN_GUEST_HANDLE(xen_processor_cx_t);
409 struct xen_processor_flags {
410 uint32_t bm_control:1;
413 uint32_t power_setup_done:1;
414 uint32_t bm_rld_set:1;
417 struct xen_processor_power {
418 uint32_t count; /* number of C state entries in array below */
419 struct xen_processor_flags flags; /* global flags of this processor */
420 XEN_GUEST_HANDLE(xen_processor_cx_t) states; /* supported c states */
423 struct xen_pct_register {
433 struct xen_processor_px {
434 uint64_t core_frequency; /* megahertz */
435 uint64_t power; /* milliWatts */
436 uint64_t transition_latency; /* microseconds */
437 uint64_t bus_master_latency; /* microseconds */
438 uint64_t control; /* control value */
439 uint64_t status; /* success indicator */
441 typedef struct xen_processor_px xen_processor_px_t;
442 DEFINE_XEN_GUEST_HANDLE(xen_processor_px_t);
444 struct xen_psd_package {
445 uint64_t num_entries;
449 uint64_t num_processors;
452 struct xen_processor_performance {
453 uint32_t flags; /* flag for Px sub info type */
454 uint32_t platform_limit; /* Platform limitation on freq usage */
455 struct xen_pct_register control_register;
456 struct xen_pct_register status_register;
457 uint32_t state_count; /* total available performance states */
458 XEN_GUEST_HANDLE(xen_processor_px_t) states;
459 struct xen_psd_package domain_info;
460 uint32_t shared_type; /* coordination type of this processor */
462 typedef struct xen_processor_performance xen_processor_performance_t;
463 DEFINE_XEN_GUEST_HANDLE(xen_processor_performance_t);
465 struct xenpf_set_processor_pminfo {
467 uint32_t id; /* ACPI CPU ID */
468 uint32_t type; /* {XEN_PM_CX, XEN_PM_PX} */
470 struct xen_processor_power power;/* Cx: _CST/_CSD */
471 struct xen_processor_performance perf; /* Px: _PPC/_PCT/_PSS/_PSD */
472 XEN_GUEST_HANDLE(uint32) pdc; /* _PDC */
475 typedef struct xenpf_set_processor_pminfo xenpf_set_processor_pminfo_t;
476 DEFINE_XEN_GUEST_HANDLE(xenpf_set_processor_pminfo_t);
478 #define XENPF_get_cpuinfo 55
479 struct xenpf_pcpuinfo {
483 /* The maxium cpu_id that is present */
484 uint32_t max_present;
485 #define XEN_PCPU_FLAGS_ONLINE 1
486 /* Correponding xen_cpuid is not present*/
487 #define XEN_PCPU_FLAGS_INVALID 2
492 typedef struct xenpf_pcpuinfo xenpf_pcpuinfo_t;
493 DEFINE_XEN_GUEST_HANDLE(xenpf_pcpuinfo_t);
495 #define XENPF_get_cpu_version 48
496 struct xenpf_pcpu_version {
500 /* The maxium cpu_id that is present */
501 uint32_t max_present;
507 typedef struct xenpf_pcpu_version xenpf_pcpu_version_t;
508 DEFINE_XEN_GUEST_HANDLE(xenpf_pcpu_version_t);
510 #define XENPF_cpu_online 56
511 #define XENPF_cpu_offline 57
516 typedef struct xenpf_cpu_ol xenpf_cpu_ol_t;
517 DEFINE_XEN_GUEST_HANDLE(xenpf_cpu_ol_t);
519 #define XENPF_cpu_hotadd 58
520 struct xenpf_cpu_hotadd
527 #define XENPF_mem_hotadd 59
528 struct xenpf_mem_hotadd
536 #define XENPF_core_parking 60
538 #define XEN_CORE_PARKING_SET 1
539 #define XEN_CORE_PARKING_GET 2
540 struct xenpf_core_parking {
543 /* IN variables: set cpu nums expected to be idled */
544 /* OUT variables: get cpu nums actually be idled */
547 typedef struct xenpf_core_parking xenpf_core_parking_t;
548 DEFINE_XEN_GUEST_HANDLE(xenpf_core_parking_t);
551 * Access generic platform resources(e.g., accessing MSR, port I/O, etc)
552 * in unified way. Batch resource operations in one call are supported and
553 * they are always non-preemptible and executed in their original order.
554 * The batch itself returns a negative integer for general errors, or a
555 * non-negative integer for the number of successful operations. For the latter
556 * case, the @ret in the failed entry (if any) indicates the exact error.
558 #define XENPF_resource_op 61
560 #define XEN_RESOURCE_OP_MSR_READ 0
561 #define XEN_RESOURCE_OP_MSR_WRITE 1
564 * Specially handled MSRs:
566 * READ: Returns the scaled system time(ns) instead of raw timestamp. In
567 * multiple entry case, if other MSR read is followed by a MSR_IA32_TSC
568 * read, then both reads are guaranteed to be performed atomically (with
569 * IRQ disabled). The return time indicates the point of reading that MSR.
570 * WRITE: Not supported.
573 struct xenpf_resource_entry {
575 uint32_t cmd; /* IN: XEN_RESOURCE_OP_* */
576 int32_t ret; /* OUT: return value for failed entry */
578 uint32_t rsvd; /* IN: padding and must be zero */
579 uint64_t idx; /* IN: resource address to access */
580 uint64_t val; /* IN/OUT: resource value to set/get */
582 typedef struct xenpf_resource_entry xenpf_resource_entry_t;
583 DEFINE_XEN_GUEST_HANDLE(xenpf_resource_entry_t);
585 struct xenpf_resource_op {
586 uint32_t nr_entries; /* number of resource entry */
587 uint32_t cpu; /* which cpu to run */
588 XEN_GUEST_HANDLE(xenpf_resource_entry_t) entries;
590 typedef struct xenpf_resource_op xenpf_resource_op_t;
591 DEFINE_XEN_GUEST_HANDLE(xenpf_resource_op_t);
593 #define XENPF_get_symbol 63
594 struct xenpf_symdata {
595 /* IN/OUT variables */
596 uint32_t namelen; /* IN: size of name buffer */
597 /* OUT: strlen(name) of hypervisor symbol (may be */
598 /* larger than what's been copied to guest) */
599 uint32_t symnum; /* IN: Symbol to read */
600 /* OUT: Next available symbol. If same as IN then */
601 /* we reached the end */
604 XEN_GUEST_HANDLE(char) name;
608 typedef struct xenpf_symdata xenpf_symdata_t;
609 DEFINE_XEN_GUEST_HANDLE(xenpf_symdata_t);
612 * ` enum neg_errnoval
613 * ` HYPERVISOR_platform_op(const struct xen_platform_op*);
615 struct xen_platform_op {
617 uint32_t interface_version; /* XENPF_INTERFACE_VERSION */
619 struct xenpf_settime settime;
620 struct xenpf_settime32 settime32;
621 struct xenpf_settime64 settime64;
622 struct xenpf_add_memtype add_memtype;
623 struct xenpf_del_memtype del_memtype;
624 struct xenpf_read_memtype read_memtype;
625 struct xenpf_microcode_update microcode;
626 struct xenpf_platform_quirk platform_quirk;
627 struct xenpf_efi_runtime_call efi_runtime_call;
628 struct xenpf_firmware_info firmware_info;
629 struct xenpf_enter_acpi_sleep enter_acpi_sleep;
630 struct xenpf_change_freq change_freq;
631 struct xenpf_getidletime getidletime;
632 struct xenpf_set_processor_pminfo set_pminfo;
633 struct xenpf_pcpuinfo pcpu_info;
634 struct xenpf_pcpu_version pcpu_version;
635 struct xenpf_cpu_ol cpu_ol;
636 struct xenpf_cpu_hotadd cpu_add;
637 struct xenpf_mem_hotadd mem_add;
638 struct xenpf_core_parking core_parking;
639 struct xenpf_resource_op resource_op;
640 struct xenpf_symdata symdata;
644 typedef struct xen_platform_op xen_platform_op_t;
645 DEFINE_XEN_GUEST_HANDLE(xen_platform_op_t);
647 #endif /* __XEN_PUBLIC_PLATFORM_H__ */
652 * c-file-style: "BSD"
655 * indent-tabs-mode: nil