Yu Ke | 3e09967 | 2010-03-24 11:01:13 -0700 | [diff] [blame] | 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 | |
| 27 | #ifndef __XEN_PUBLIC_PLATFORM_H__ |
| 28 | #define __XEN_PUBLIC_PLATFORM_H__ |
| 29 | |
David Howells | a1ce392 | 2012-10-02 18:01:25 +0100 | [diff] [blame] | 30 | #include <xen/interface/xen.h> |
Yu Ke | 3e09967 | 2010-03-24 11:01:13 -0700 | [diff] [blame] | 31 | |
| 32 | #define XENPF_INTERFACE_VERSION 0x03000001 |
| 33 | |
| 34 | /* |
| 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>. |
| 37 | */ |
| 38 | #define XENPF_settime 17 |
| 39 | struct xenpf_settime { |
| 40 | /* IN variables. */ |
| 41 | uint32_t secs; |
| 42 | uint32_t nsecs; |
| 43 | uint64_t system_time; |
| 44 | }; |
| 45 | DEFINE_GUEST_HANDLE_STRUCT(xenpf_settime_t); |
| 46 | |
| 47 | /* |
| 48 | * Request memory range (@mfn, @mfn+@nr_mfns-1) to have type @type. |
| 49 | * On x86, @type is an architecture-defined MTRR memory type. |
| 50 | * On success, returns the MTRR that was used (@reg) and a handle that can |
| 51 | * be passed to XENPF_DEL_MEMTYPE to accurately tear down the new setting. |
| 52 | * (x86-specific). |
| 53 | */ |
| 54 | #define XENPF_add_memtype 31 |
| 55 | struct xenpf_add_memtype { |
| 56 | /* IN variables. */ |
Stefano Stabellini | bd3f79b | 2012-08-22 17:20:14 +0100 | [diff] [blame] | 57 | xen_pfn_t mfn; |
Yu Ke | 3e09967 | 2010-03-24 11:01:13 -0700 | [diff] [blame] | 58 | uint64_t nr_mfns; |
| 59 | uint32_t type; |
| 60 | /* OUT variables. */ |
| 61 | uint32_t handle; |
| 62 | uint32_t reg; |
| 63 | }; |
| 64 | DEFINE_GUEST_HANDLE_STRUCT(xenpf_add_memtype_t); |
| 65 | |
| 66 | /* |
| 67 | * Tear down an existing memory-range type. If @handle is remembered then it |
| 68 | * should be passed in to accurately tear down the correct setting (in case |
| 69 | * of overlapping memory regions with differing types). If it is not known |
| 70 | * then @handle should be set to zero. In all cases @reg must be set. |
| 71 | * (x86-specific). |
| 72 | */ |
| 73 | #define XENPF_del_memtype 32 |
| 74 | struct xenpf_del_memtype { |
| 75 | /* IN variables. */ |
| 76 | uint32_t handle; |
| 77 | uint32_t reg; |
| 78 | }; |
| 79 | DEFINE_GUEST_HANDLE_STRUCT(xenpf_del_memtype_t); |
| 80 | |
| 81 | /* Read current type of an MTRR (x86-specific). */ |
| 82 | #define XENPF_read_memtype 33 |
| 83 | struct xenpf_read_memtype { |
| 84 | /* IN variables. */ |
| 85 | uint32_t reg; |
| 86 | /* OUT variables. */ |
Stefano Stabellini | bd3f79b | 2012-08-22 17:20:14 +0100 | [diff] [blame] | 87 | xen_pfn_t mfn; |
Yu Ke | 3e09967 | 2010-03-24 11:01:13 -0700 | [diff] [blame] | 88 | uint64_t nr_mfns; |
| 89 | uint32_t type; |
| 90 | }; |
| 91 | DEFINE_GUEST_HANDLE_STRUCT(xenpf_read_memtype_t); |
| 92 | |
| 93 | #define XENPF_microcode_update 35 |
| 94 | struct xenpf_microcode_update { |
| 95 | /* IN variables. */ |
| 96 | GUEST_HANDLE(void) data; /* Pointer to microcode data */ |
| 97 | uint32_t length; /* Length of microcode data. */ |
| 98 | }; |
| 99 | DEFINE_GUEST_HANDLE_STRUCT(xenpf_microcode_update_t); |
| 100 | |
| 101 | #define XENPF_platform_quirk 39 |
| 102 | #define QUIRK_NOIRQBALANCING 1 /* Do not restrict IO-APIC RTE targets */ |
| 103 | #define QUIRK_IOAPIC_BAD_REGSEL 2 /* IO-APIC REGSEL forgets its value */ |
| 104 | #define QUIRK_IOAPIC_GOOD_REGSEL 3 /* IO-APIC REGSEL behaves properly */ |
| 105 | struct xenpf_platform_quirk { |
| 106 | /* IN variables. */ |
| 107 | uint32_t quirk_id; |
| 108 | }; |
| 109 | DEFINE_GUEST_HANDLE_STRUCT(xenpf_platform_quirk_t); |
| 110 | |
| 111 | #define XENPF_firmware_info 50 |
| 112 | #define XEN_FW_DISK_INFO 1 /* from int 13 AH=08/41/48 */ |
| 113 | #define XEN_FW_DISK_MBR_SIGNATURE 2 /* from MBR offset 0x1b8 */ |
| 114 | #define XEN_FW_VBEDDC_INFO 3 /* from int 10 AX=4f15 */ |
Konrad Rzeszutek Wilk | ffb8b23 | 2012-09-21 12:30:35 -0400 | [diff] [blame] | 115 | #define XEN_FW_KBD_SHIFT_FLAGS 5 /* Int16, Fn02: Get keyboard shift flags. */ |
Yu Ke | 3e09967 | 2010-03-24 11:01:13 -0700 | [diff] [blame] | 116 | struct xenpf_firmware_info { |
| 117 | /* IN variables. */ |
| 118 | uint32_t type; |
| 119 | uint32_t index; |
| 120 | /* OUT variables. */ |
| 121 | union { |
| 122 | struct { |
| 123 | /* Int13, Fn48: Check Extensions Present. */ |
| 124 | uint8_t device; /* %dl: bios device number */ |
| 125 | uint8_t version; /* %ah: major version */ |
| 126 | uint16_t interface_support; /* %cx: support bitmap */ |
| 127 | /* Int13, Fn08: Legacy Get Device Parameters. */ |
| 128 | uint16_t legacy_max_cylinder; /* %cl[7:6]:%ch: max cyl # */ |
| 129 | uint8_t legacy_max_head; /* %dh: max head # */ |
| 130 | uint8_t legacy_sectors_per_track; /* %cl[5:0]: max sector # */ |
| 131 | /* Int13, Fn41: Get Device Parameters (as filled into %ds:%esi). */ |
| 132 | /* NB. First uint16_t of buffer must be set to buffer size. */ |
| 133 | GUEST_HANDLE(void) edd_params; |
| 134 | } disk_info; /* XEN_FW_DISK_INFO */ |
| 135 | struct { |
| 136 | uint8_t device; /* bios device number */ |
| 137 | uint32_t mbr_signature; /* offset 0x1b8 in mbr */ |
| 138 | } disk_mbr_signature; /* XEN_FW_DISK_MBR_SIGNATURE */ |
| 139 | struct { |
| 140 | /* Int10, AX=4F15: Get EDID info. */ |
| 141 | uint8_t capabilities; |
| 142 | uint8_t edid_transfer_time; |
| 143 | /* must refer to 128-byte buffer */ |
| 144 | GUEST_HANDLE(uchar) edid; |
| 145 | } vbeddc_info; /* XEN_FW_VBEDDC_INFO */ |
Konrad Rzeszutek Wilk | ffb8b23 | 2012-09-21 12:30:35 -0400 | [diff] [blame] | 146 | |
| 147 | uint8_t kbd_shift_flags; /* XEN_FW_KBD_SHIFT_FLAGS */ |
Yu Ke | 3e09967 | 2010-03-24 11:01:13 -0700 | [diff] [blame] | 148 | } u; |
| 149 | }; |
| 150 | DEFINE_GUEST_HANDLE_STRUCT(xenpf_firmware_info_t); |
| 151 | |
| 152 | #define XENPF_enter_acpi_sleep 51 |
| 153 | struct xenpf_enter_acpi_sleep { |
| 154 | /* IN variables */ |
Ben Guthro | be6b25d | 2013-07-30 08:24:54 -0400 | [diff] [blame] | 155 | uint16_t val_a; /* PM1a control / sleep type A. */ |
| 156 | uint16_t val_b; /* PM1b control / sleep type B. */ |
Yu Ke | 3e09967 | 2010-03-24 11:01:13 -0700 | [diff] [blame] | 157 | uint32_t sleep_state; /* Which state to enter (Sn). */ |
Ben Guthro | be6b25d | 2013-07-30 08:24:54 -0400 | [diff] [blame] | 158 | #define XENPF_ACPI_SLEEP_EXTENDED 0x00000001 |
| 159 | uint32_t flags; /* XENPF_ACPI_SLEEP_*. */ |
Yu Ke | 3e09967 | 2010-03-24 11:01:13 -0700 | [diff] [blame] | 160 | }; |
| 161 | DEFINE_GUEST_HANDLE_STRUCT(xenpf_enter_acpi_sleep_t); |
| 162 | |
| 163 | #define XENPF_change_freq 52 |
| 164 | struct xenpf_change_freq { |
| 165 | /* IN variables */ |
| 166 | uint32_t flags; /* Must be zero. */ |
| 167 | uint32_t cpu; /* Physical cpu. */ |
| 168 | uint64_t freq; /* New frequency (Hz). */ |
| 169 | }; |
| 170 | DEFINE_GUEST_HANDLE_STRUCT(xenpf_change_freq_t); |
| 171 | |
| 172 | /* |
| 173 | * Get idle times (nanoseconds since boot) for physical CPUs specified in the |
| 174 | * @cpumap_bitmap with range [0..@cpumap_nr_cpus-1]. The @idletime array is |
| 175 | * indexed by CPU number; only entries with the corresponding @cpumap_bitmap |
| 176 | * bit set are written to. On return, @cpumap_bitmap is modified so that any |
| 177 | * non-existent CPUs are cleared. Such CPUs have their @idletime array entry |
| 178 | * cleared. |
| 179 | */ |
| 180 | #define XENPF_getidletime 53 |
| 181 | struct xenpf_getidletime { |
| 182 | /* IN/OUT variables */ |
| 183 | /* IN: CPUs to interrogate; OUT: subset of IN which are present */ |
| 184 | GUEST_HANDLE(uchar) cpumap_bitmap; |
| 185 | /* IN variables */ |
| 186 | /* Size of cpumap bitmap. */ |
| 187 | uint32_t cpumap_nr_cpus; |
| 188 | /* Must be indexable for every cpu in cpumap_bitmap. */ |
| 189 | GUEST_HANDLE(uint64_t) idletime; |
| 190 | /* OUT variables */ |
| 191 | /* System time when the idletime snapshots were taken. */ |
| 192 | uint64_t now; |
| 193 | }; |
| 194 | DEFINE_GUEST_HANDLE_STRUCT(xenpf_getidletime_t); |
| 195 | |
| 196 | #define XENPF_set_processor_pminfo 54 |
| 197 | |
| 198 | /* ability bits */ |
| 199 | #define XEN_PROCESSOR_PM_CX 1 |
| 200 | #define XEN_PROCESSOR_PM_PX 2 |
| 201 | #define XEN_PROCESSOR_PM_TX 4 |
| 202 | |
| 203 | /* cmd type */ |
| 204 | #define XEN_PM_CX 0 |
| 205 | #define XEN_PM_PX 1 |
| 206 | #define XEN_PM_TX 2 |
Konrad Rzeszutek Wilk | 73c154c | 2012-02-13 22:26:32 -0500 | [diff] [blame] | 207 | #define XEN_PM_PDC 3 |
Yu Ke | 3e09967 | 2010-03-24 11:01:13 -0700 | [diff] [blame] | 208 | /* Px sub info type */ |
| 209 | #define XEN_PX_PCT 1 |
| 210 | #define XEN_PX_PSS 2 |
| 211 | #define XEN_PX_PPC 4 |
| 212 | #define XEN_PX_PSD 8 |
| 213 | |
| 214 | struct xen_power_register { |
| 215 | uint32_t space_id; |
| 216 | uint32_t bit_width; |
| 217 | uint32_t bit_offset; |
| 218 | uint32_t access_size; |
| 219 | uint64_t address; |
| 220 | }; |
| 221 | |
| 222 | struct xen_processor_csd { |
| 223 | uint32_t domain; /* domain number of one dependent group */ |
| 224 | uint32_t coord_type; /* coordination type */ |
| 225 | uint32_t num; /* number of processors in same domain */ |
| 226 | }; |
| 227 | DEFINE_GUEST_HANDLE_STRUCT(xen_processor_csd); |
| 228 | |
| 229 | struct xen_processor_cx { |
| 230 | struct xen_power_register reg; /* GAS for Cx trigger register */ |
| 231 | uint8_t type; /* cstate value, c0: 0, c1: 1, ... */ |
| 232 | uint32_t latency; /* worst latency (ms) to enter/exit this cstate */ |
| 233 | uint32_t power; /* average power consumption(mW) */ |
| 234 | uint32_t dpcnt; /* number of dependency entries */ |
| 235 | GUEST_HANDLE(xen_processor_csd) dp; /* NULL if no dependency */ |
| 236 | }; |
| 237 | DEFINE_GUEST_HANDLE_STRUCT(xen_processor_cx); |
| 238 | |
| 239 | struct xen_processor_flags { |
| 240 | uint32_t bm_control:1; |
| 241 | uint32_t bm_check:1; |
| 242 | uint32_t has_cst:1; |
| 243 | uint32_t power_setup_done:1; |
| 244 | uint32_t bm_rld_set:1; |
| 245 | }; |
| 246 | |
| 247 | struct xen_processor_power { |
| 248 | uint32_t count; /* number of C state entries in array below */ |
| 249 | struct xen_processor_flags flags; /* global flags of this processor */ |
| 250 | GUEST_HANDLE(xen_processor_cx) states; /* supported c states */ |
| 251 | }; |
| 252 | |
| 253 | struct xen_pct_register { |
| 254 | uint8_t descriptor; |
| 255 | uint16_t length; |
| 256 | uint8_t space_id; |
| 257 | uint8_t bit_width; |
| 258 | uint8_t bit_offset; |
| 259 | uint8_t reserved; |
| 260 | uint64_t address; |
| 261 | }; |
| 262 | |
| 263 | struct xen_processor_px { |
| 264 | uint64_t core_frequency; /* megahertz */ |
| 265 | uint64_t power; /* milliWatts */ |
| 266 | uint64_t transition_latency; /* microseconds */ |
| 267 | uint64_t bus_master_latency; /* microseconds */ |
| 268 | uint64_t control; /* control value */ |
| 269 | uint64_t status; /* success indicator */ |
| 270 | }; |
| 271 | DEFINE_GUEST_HANDLE_STRUCT(xen_processor_px); |
| 272 | |
| 273 | struct xen_psd_package { |
| 274 | uint64_t num_entries; |
| 275 | uint64_t revision; |
| 276 | uint64_t domain; |
| 277 | uint64_t coord_type; |
| 278 | uint64_t num_processors; |
| 279 | }; |
| 280 | |
| 281 | struct xen_processor_performance { |
| 282 | uint32_t flags; /* flag for Px sub info type */ |
| 283 | uint32_t platform_limit; /* Platform limitation on freq usage */ |
| 284 | struct xen_pct_register control_register; |
| 285 | struct xen_pct_register status_register; |
| 286 | uint32_t state_count; /* total available performance states */ |
| 287 | GUEST_HANDLE(xen_processor_px) states; |
| 288 | struct xen_psd_package domain_info; |
| 289 | uint32_t shared_type; /* coordination type of this processor */ |
| 290 | }; |
| 291 | DEFINE_GUEST_HANDLE_STRUCT(xen_processor_performance); |
| 292 | |
| 293 | struct xenpf_set_processor_pminfo { |
| 294 | /* IN variables */ |
| 295 | uint32_t id; /* ACPI CPU ID */ |
| 296 | uint32_t type; /* {XEN_PM_CX, XEN_PM_PX} */ |
| 297 | union { |
| 298 | struct xen_processor_power power;/* Cx: _CST/_CSD */ |
| 299 | struct xen_processor_performance perf; /* Px: _PPC/_PCT/_PSS/_PSD */ |
Konrad Rzeszutek Wilk | 73c154c | 2012-02-13 22:26:32 -0500 | [diff] [blame] | 300 | GUEST_HANDLE(uint32_t) pdc; |
Yu Ke | 3e09967 | 2010-03-24 11:01:13 -0700 | [diff] [blame] | 301 | }; |
| 302 | }; |
| 303 | DEFINE_GUEST_HANDLE_STRUCT(xenpf_set_processor_pminfo); |
| 304 | |
Konrad Rzeszutek Wilk | 59a5680 | 2012-02-03 16:03:20 -0500 | [diff] [blame] | 305 | #define XENPF_get_cpuinfo 55 |
| 306 | struct xenpf_pcpuinfo { |
| 307 | /* IN */ |
| 308 | uint32_t xen_cpuid; |
| 309 | /* OUT */ |
| 310 | /* The maxium cpu_id that is present */ |
| 311 | uint32_t max_present; |
| 312 | #define XEN_PCPU_FLAGS_ONLINE 1 |
| 313 | /* Correponding xen_cpuid is not present*/ |
| 314 | #define XEN_PCPU_FLAGS_INVALID 2 |
| 315 | uint32_t flags; |
| 316 | uint32_t apic_id; |
| 317 | uint32_t acpi_id; |
| 318 | }; |
| 319 | DEFINE_GUEST_HANDLE_STRUCT(xenpf_pcpuinfo); |
| 320 | |
Liu, Jinsong | f65c9bb | 2012-06-11 20:38:08 +0800 | [diff] [blame] | 321 | #define XENPF_cpu_online 56 |
| 322 | #define XENPF_cpu_offline 57 |
| 323 | struct xenpf_cpu_ol { |
| 324 | uint32_t cpuid; |
| 325 | }; |
| 326 | DEFINE_GUEST_HANDLE_STRUCT(xenpf_cpu_ol); |
| 327 | |
Liu Jinsong | 39adc48 | 2013-01-25 15:43:34 +0800 | [diff] [blame] | 328 | #define XENPF_cpu_hotadd 58 |
| 329 | struct xenpf_cpu_hotadd { |
| 330 | uint32_t apic_id; |
| 331 | uint32_t acpi_id; |
| 332 | uint32_t pxm; |
| 333 | }; |
| 334 | |
Liu Jinsong | ef92e7c | 2013-01-24 20:19:47 +0800 | [diff] [blame] | 335 | #define XENPF_mem_hotadd 59 |
| 336 | struct xenpf_mem_hotadd { |
| 337 | uint64_t spfn; |
| 338 | uint64_t epfn; |
| 339 | uint32_t pxm; |
| 340 | uint32_t flags; |
| 341 | }; |
| 342 | |
Liu, Jinsong | 92e3229 | 2012-11-08 05:41:13 +0000 | [diff] [blame] | 343 | #define XENPF_core_parking 60 |
| 344 | struct xenpf_core_parking { |
| 345 | /* IN variables */ |
| 346 | #define XEN_CORE_PARKING_SET 1 |
| 347 | #define XEN_CORE_PARKING_GET 2 |
| 348 | uint32_t type; |
| 349 | /* IN variables: set cpu nums expected to be idled */ |
| 350 | /* OUT variables: get cpu nums actually be idled */ |
| 351 | uint32_t idle_nums; |
| 352 | }; |
| 353 | DEFINE_GUEST_HANDLE_STRUCT(xenpf_core_parking); |
| 354 | |
Yu Ke | 3e09967 | 2010-03-24 11:01:13 -0700 | [diff] [blame] | 355 | struct xen_platform_op { |
| 356 | uint32_t cmd; |
| 357 | uint32_t interface_version; /* XENPF_INTERFACE_VERSION */ |
| 358 | union { |
| 359 | struct xenpf_settime settime; |
| 360 | struct xenpf_add_memtype add_memtype; |
| 361 | struct xenpf_del_memtype del_memtype; |
| 362 | struct xenpf_read_memtype read_memtype; |
| 363 | struct xenpf_microcode_update microcode; |
| 364 | struct xenpf_platform_quirk platform_quirk; |
| 365 | struct xenpf_firmware_info firmware_info; |
| 366 | struct xenpf_enter_acpi_sleep enter_acpi_sleep; |
| 367 | struct xenpf_change_freq change_freq; |
| 368 | struct xenpf_getidletime getidletime; |
| 369 | struct xenpf_set_processor_pminfo set_pminfo; |
Konrad Rzeszutek Wilk | 59a5680 | 2012-02-03 16:03:20 -0500 | [diff] [blame] | 370 | struct xenpf_pcpuinfo pcpu_info; |
Liu, Jinsong | f65c9bb | 2012-06-11 20:38:08 +0800 | [diff] [blame] | 371 | struct xenpf_cpu_ol cpu_ol; |
Liu Jinsong | 39adc48 | 2013-01-25 15:43:34 +0800 | [diff] [blame] | 372 | struct xenpf_cpu_hotadd cpu_add; |
Liu Jinsong | ef92e7c | 2013-01-24 20:19:47 +0800 | [diff] [blame] | 373 | struct xenpf_mem_hotadd mem_add; |
Liu, Jinsong | 92e3229 | 2012-11-08 05:41:13 +0000 | [diff] [blame] | 374 | struct xenpf_core_parking core_parking; |
Yu Ke | 3e09967 | 2010-03-24 11:01:13 -0700 | [diff] [blame] | 375 | uint8_t pad[128]; |
| 376 | } u; |
| 377 | }; |
| 378 | DEFINE_GUEST_HANDLE_STRUCT(xen_platform_op_t); |
| 379 | |
| 380 | #endif /* __XEN_PUBLIC_PLATFORM_H__ */ |