]> CyberLeo.Net >> Repos - FreeBSD/releng/10.0.git/blob - sys/xen/interface/platform.h
- Copy stable/10 (r259064) to releng/10.0 as part of the
[FreeBSD/releng/10.0.git] / sys / xen / interface / platform.h
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
30 #include "xen.h"
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 typedef struct xenpf_settime xenpf_settime_t;
46 DEFINE_XEN_GUEST_HANDLE(xenpf_settime_t);
47
48 /*
49  * Request memory range (@mfn, @mfn+@nr_mfns-1) to have type @type.
50  * On x86, @type is an architecture-defined MTRR memory type.
51  * On success, returns the MTRR that was used (@reg) and a handle that can
52  * be passed to XENPF_DEL_MEMTYPE to accurately tear down the new setting.
53  * (x86-specific).
54  */
55 #define XENPF_add_memtype         31
56 struct xenpf_add_memtype {
57     /* IN variables. */
58     xen_pfn_t mfn;
59     uint64_t nr_mfns;
60     uint32_t type;
61     /* OUT variables. */
62     uint32_t handle;
63     uint32_t reg;
64 };
65 typedef struct xenpf_add_memtype xenpf_add_memtype_t;
66 DEFINE_XEN_GUEST_HANDLE(xenpf_add_memtype_t);
67
68 /*
69  * Tear down an existing memory-range type. If @handle is remembered then it
70  * should be passed in to accurately tear down the correct setting (in case
71  * of overlapping memory regions with differing types). If it is not known
72  * then @handle should be set to zero. In all cases @reg must be set.
73  * (x86-specific).
74  */
75 #define XENPF_del_memtype         32
76 struct xenpf_del_memtype {
77     /* IN variables. */
78     uint32_t handle;
79     uint32_t reg;
80 };
81 typedef struct xenpf_del_memtype xenpf_del_memtype_t;
82 DEFINE_XEN_GUEST_HANDLE(xenpf_del_memtype_t);
83
84 /* Read current type of an MTRR (x86-specific). */
85 #define XENPF_read_memtype        33
86 struct xenpf_read_memtype {
87     /* IN variables. */
88     uint32_t reg;
89     /* OUT variables. */
90     xen_pfn_t mfn;
91     uint64_t nr_mfns;
92     uint32_t type;
93 };
94 typedef struct xenpf_read_memtype xenpf_read_memtype_t;
95 DEFINE_XEN_GUEST_HANDLE(xenpf_read_memtype_t);
96
97 #define XENPF_microcode_update    35
98 struct xenpf_microcode_update {
99     /* IN variables. */
100     XEN_GUEST_HANDLE(const_void) data;/* Pointer to microcode data */
101     uint32_t length;                  /* Length of microcode data. */
102 };
103 typedef struct xenpf_microcode_update xenpf_microcode_update_t;
104 DEFINE_XEN_GUEST_HANDLE(xenpf_microcode_update_t);
105
106 #define XENPF_platform_quirk      39
107 #define QUIRK_NOIRQBALANCING      1 /* Do not restrict IO-APIC RTE targets */
108 #define QUIRK_IOAPIC_BAD_REGSEL   2 /* IO-APIC REGSEL forgets its value    */
109 #define QUIRK_IOAPIC_GOOD_REGSEL  3 /* IO-APIC REGSEL behaves properly     */
110 struct xenpf_platform_quirk {
111     /* IN variables. */
112     uint32_t quirk_id;
113 };
114 typedef struct xenpf_platform_quirk xenpf_platform_quirk_t;
115 DEFINE_XEN_GUEST_HANDLE(xenpf_platform_quirk_t);
116
117 #define XENPF_efi_runtime_call    49
118 #define XEN_EFI_get_time                      1
119 #define XEN_EFI_set_time                      2
120 #define XEN_EFI_get_wakeup_time               3
121 #define XEN_EFI_set_wakeup_time               4
122 #define XEN_EFI_get_next_high_monotonic_count 5
123 #define XEN_EFI_get_variable                  6
124 #define XEN_EFI_set_variable                  7
125 #define XEN_EFI_get_next_variable_name        8
126 #define XEN_EFI_query_variable_info           9
127 #define XEN_EFI_query_capsule_capabilities   10
128 #define XEN_EFI_update_capsule               11
129 struct xenpf_efi_runtime_call {
130     uint32_t function;
131     /*
132      * This field is generally used for per sub-function flags (defined
133      * below), except for the XEN_EFI_get_next_high_monotonic_count case,
134      * where it holds the single returned value.
135      */
136     uint32_t misc;
137     unsigned long status;
138     union {
139 #define XEN_EFI_GET_TIME_SET_CLEARS_NS 0x00000001
140         struct {
141             struct xenpf_efi_time {
142                 uint16_t year;
143                 uint8_t month;
144                 uint8_t day;
145                 uint8_t hour;
146                 uint8_t min;
147                 uint8_t sec;
148                 uint32_t ns;
149                 int16_t tz;
150                 uint8_t daylight;
151             } time;
152             uint32_t resolution;
153             uint32_t accuracy;
154         } get_time;
155
156         struct xenpf_efi_time set_time;
157
158 #define XEN_EFI_GET_WAKEUP_TIME_ENABLED 0x00000001
159 #define XEN_EFI_GET_WAKEUP_TIME_PENDING 0x00000002
160         struct xenpf_efi_time get_wakeup_time;
161
162 #define XEN_EFI_SET_WAKEUP_TIME_ENABLE      0x00000001
163 #define XEN_EFI_SET_WAKEUP_TIME_ENABLE_ONLY 0x00000002
164         struct xenpf_efi_time set_wakeup_time;
165
166 #define XEN_EFI_VARIABLE_NON_VOLATILE       0x00000001
167 #define XEN_EFI_VARIABLE_BOOTSERVICE_ACCESS 0x00000002
168 #define XEN_EFI_VARIABLE_RUNTIME_ACCESS     0x00000004
169         struct {
170             XEN_GUEST_HANDLE(void) name;  /* UCS-2/UTF-16 string */
171             unsigned long size;
172             XEN_GUEST_HANDLE(void) data;
173             struct xenpf_efi_guid {
174                 uint32_t data1;
175                 uint16_t data2;
176                 uint16_t data3;
177                 uint8_t data4[8];
178             } vendor_guid;
179         } get_variable, set_variable;
180
181         struct {
182             unsigned long size;
183             XEN_GUEST_HANDLE(void) name;  /* UCS-2/UTF-16 string */
184             struct xenpf_efi_guid vendor_guid;
185         } get_next_variable_name;
186
187         struct {
188             uint32_t attr;
189             uint64_t max_store_size;
190             uint64_t remain_store_size;
191             uint64_t max_size;
192         } query_variable_info;
193
194         struct {
195             XEN_GUEST_HANDLE(void) capsule_header_array;
196             unsigned long capsule_count;
197             uint64_t max_capsule_size;
198             unsigned int reset_type;
199         } query_capsule_capabilities;
200
201         struct {
202             XEN_GUEST_HANDLE(void) capsule_header_array;
203             unsigned long capsule_count;
204             uint64_t sg_list; /* machine address */
205         } update_capsule;
206     } u;
207 };
208 typedef struct xenpf_efi_runtime_call xenpf_efi_runtime_call_t;
209 DEFINE_XEN_GUEST_HANDLE(xenpf_efi_runtime_call_t);
210
211 #define XENPF_firmware_info       50
212 #define XEN_FW_DISK_INFO          1 /* from int 13 AH=08/41/48 */
213 #define XEN_FW_DISK_MBR_SIGNATURE 2 /* from MBR offset 0x1b8 */
214 #define XEN_FW_VBEDDC_INFO        3 /* from int 10 AX=4f15 */
215 #define XEN_FW_EFI_INFO           4 /* from EFI */
216 #define  XEN_FW_EFI_VERSION        0
217 #define  XEN_FW_EFI_CONFIG_TABLE   1
218 #define  XEN_FW_EFI_VENDOR         2
219 #define  XEN_FW_EFI_MEM_INFO       3
220 #define  XEN_FW_EFI_RT_VERSION     4
221 struct xenpf_firmware_info {
222     /* IN variables. */
223     uint32_t type;
224     uint32_t index;
225     /* OUT variables. */
226     union {
227         struct {
228             /* Int13, Fn48: Check Extensions Present. */
229             uint8_t device;                   /* %dl: bios device number */
230             uint8_t version;                  /* %ah: major version      */
231             uint16_t interface_support;       /* %cx: support bitmap     */
232             /* Int13, Fn08: Legacy Get Device Parameters. */
233             uint16_t legacy_max_cylinder;     /* %cl[7:6]:%ch: max cyl # */
234             uint8_t legacy_max_head;          /* %dh: max head #         */
235             uint8_t legacy_sectors_per_track; /* %cl[5:0]: max sector #  */
236             /* Int13, Fn41: Get Device Parameters (as filled into %ds:%esi). */
237             /* NB. First uint16_t of buffer must be set to buffer size.      */
238             XEN_GUEST_HANDLE(void) edd_params;
239         } disk_info; /* XEN_FW_DISK_INFO */
240         struct {
241             uint8_t device;                   /* bios device number  */
242             uint32_t mbr_signature;           /* offset 0x1b8 in mbr */
243         } disk_mbr_signature; /* XEN_FW_DISK_MBR_SIGNATURE */
244         struct {
245             /* Int10, AX=4F15: Get EDID info. */
246             uint8_t capabilities;
247             uint8_t edid_transfer_time;
248             /* must refer to 128-byte buffer */
249             XEN_GUEST_HANDLE(uint8) edid;
250         } vbeddc_info; /* XEN_FW_VBEDDC_INFO */
251         union xenpf_efi_info {
252             uint32_t version;
253             struct {
254                 uint64_t addr;                /* EFI_CONFIGURATION_TABLE */
255                 uint32_t nent;
256             } cfg;
257             struct {
258                 uint32_t revision;
259                 uint32_t bufsz;               /* input, in bytes */
260                 XEN_GUEST_HANDLE(void) name;  /* UCS-2/UTF-16 string */
261             } vendor;
262             struct {
263                 uint64_t addr;
264                 uint64_t size;
265                 uint64_t attr;
266                 uint32_t type;
267             } mem;
268         } efi_info; /* XEN_FW_EFI_INFO */
269     } u;
270 };
271 typedef struct xenpf_firmware_info xenpf_firmware_info_t;
272 DEFINE_XEN_GUEST_HANDLE(xenpf_firmware_info_t);
273
274 #define XENPF_enter_acpi_sleep    51
275 struct xenpf_enter_acpi_sleep {
276     /* IN variables */
277     uint16_t pm1a_cnt_val;      /* PM1a control value. */
278     uint16_t pm1b_cnt_val;      /* PM1b control value. */
279     uint32_t sleep_state;       /* Which state to enter (Sn). */
280     uint32_t flags;             /* Must be zero. */
281 };
282 typedef struct xenpf_enter_acpi_sleep xenpf_enter_acpi_sleep_t;
283 DEFINE_XEN_GUEST_HANDLE(xenpf_enter_acpi_sleep_t);
284
285 #define XENPF_change_freq         52
286 struct xenpf_change_freq {
287     /* IN variables */
288     uint32_t flags; /* Must be zero. */
289     uint32_t cpu;   /* Physical cpu. */
290     uint64_t freq;  /* New frequency (Hz). */
291 };
292 typedef struct xenpf_change_freq xenpf_change_freq_t;
293 DEFINE_XEN_GUEST_HANDLE(xenpf_change_freq_t);
294
295 /*
296  * Get idle times (nanoseconds since boot) for physical CPUs specified in the
297  * @cpumap_bitmap with range [0..@cpumap_nr_cpus-1]. The @idletime array is
298  * indexed by CPU number; only entries with the corresponding @cpumap_bitmap
299  * bit set are written to. On return, @cpumap_bitmap is modified so that any
300  * non-existent CPUs are cleared. Such CPUs have their @idletime array entry
301  * cleared.
302  */
303 #define XENPF_getidletime         53
304 struct xenpf_getidletime {
305     /* IN/OUT variables */
306     /* IN: CPUs to interrogate; OUT: subset of IN which are present */
307     XEN_GUEST_HANDLE(uint8) cpumap_bitmap;
308     /* IN variables */
309     /* Size of cpumap bitmap. */
310     uint32_t cpumap_nr_cpus;
311     /* Must be indexable for every cpu in cpumap_bitmap. */
312     XEN_GUEST_HANDLE(uint64) idletime;
313     /* OUT variables */
314     /* System time when the idletime snapshots were taken. */
315     uint64_t now;
316 };
317 typedef struct xenpf_getidletime xenpf_getidletime_t;
318 DEFINE_XEN_GUEST_HANDLE(xenpf_getidletime_t);
319
320 #define XENPF_set_processor_pminfo      54
321
322 /* ability bits */
323 #define XEN_PROCESSOR_PM_CX     1
324 #define XEN_PROCESSOR_PM_PX     2
325 #define XEN_PROCESSOR_PM_TX     4
326
327 /* cmd type */
328 #define XEN_PM_CX   0
329 #define XEN_PM_PX   1
330 #define XEN_PM_TX   2
331 #define XEN_PM_PDC  3
332
333 /* Px sub info type */
334 #define XEN_PX_PCT   1
335 #define XEN_PX_PSS   2
336 #define XEN_PX_PPC   4
337 #define XEN_PX_PSD   8
338
339 struct xen_power_register {
340     uint32_t     space_id;
341     uint32_t     bit_width;
342     uint32_t     bit_offset;
343     uint32_t     access_size;
344     uint64_t     address;
345 };
346
347 struct xen_processor_csd {
348     uint32_t    domain;      /* domain number of one dependent group */
349     uint32_t    coord_type;  /* coordination type */
350     uint32_t    num;         /* number of processors in same domain */
351 };
352 typedef struct xen_processor_csd xen_processor_csd_t;
353 DEFINE_XEN_GUEST_HANDLE(xen_processor_csd_t);
354
355 struct xen_processor_cx {
356     struct xen_power_register  reg; /* GAS for Cx trigger register */
357     uint8_t     type;     /* cstate value, c0: 0, c1: 1, ... */
358     uint32_t    latency;  /* worst latency (ms) to enter/exit this cstate */
359     uint32_t    power;    /* average power consumption(mW) */
360     uint32_t    dpcnt;    /* number of dependency entries */
361     XEN_GUEST_HANDLE(xen_processor_csd_t) dp; /* NULL if no dependency */
362 };
363 typedef struct xen_processor_cx xen_processor_cx_t;
364 DEFINE_XEN_GUEST_HANDLE(xen_processor_cx_t);
365
366 struct xen_processor_flags {
367     uint32_t bm_control:1;
368     uint32_t bm_check:1;
369     uint32_t has_cst:1;
370     uint32_t power_setup_done:1;
371     uint32_t bm_rld_set:1;
372 };
373
374 struct xen_processor_power {
375     uint32_t count;  /* number of C state entries in array below */
376     struct xen_processor_flags flags;  /* global flags of this processor */
377     XEN_GUEST_HANDLE(xen_processor_cx_t) states; /* supported c states */
378 };
379
380 struct xen_pct_register {
381     uint8_t  descriptor;
382     uint16_t length;
383     uint8_t  space_id;
384     uint8_t  bit_width;
385     uint8_t  bit_offset;
386     uint8_t  reserved;
387     uint64_t address;
388 };
389
390 struct xen_processor_px {
391     uint64_t core_frequency; /* megahertz */
392     uint64_t power;      /* milliWatts */
393     uint64_t transition_latency; /* microseconds */
394     uint64_t bus_master_latency; /* microseconds */
395     uint64_t control;        /* control value */
396     uint64_t status;     /* success indicator */
397 };
398 typedef struct xen_processor_px xen_processor_px_t;
399 DEFINE_XEN_GUEST_HANDLE(xen_processor_px_t);
400
401 struct xen_psd_package {
402     uint64_t num_entries;
403     uint64_t revision;
404     uint64_t domain;
405     uint64_t coord_type;
406     uint64_t num_processors;
407 };
408
409 struct xen_processor_performance {
410     uint32_t flags;     /* flag for Px sub info type */
411     uint32_t platform_limit;  /* Platform limitation on freq usage */
412     struct xen_pct_register control_register;
413     struct xen_pct_register status_register;
414     uint32_t state_count;     /* total available performance states */
415     XEN_GUEST_HANDLE(xen_processor_px_t) states;
416     struct xen_psd_package domain_info;
417     uint32_t shared_type;     /* coordination type of this processor */
418 };
419 typedef struct xen_processor_performance xen_processor_performance_t;
420 DEFINE_XEN_GUEST_HANDLE(xen_processor_performance_t);
421
422 struct xenpf_set_processor_pminfo {
423     /* IN variables */
424     uint32_t id;    /* ACPI CPU ID */
425     uint32_t type;  /* {XEN_PM_CX, XEN_PM_PX} */
426     union {
427         struct xen_processor_power          power;/* Cx: _CST/_CSD */
428         struct xen_processor_performance    perf; /* Px: _PPC/_PCT/_PSS/_PSD */
429         XEN_GUEST_HANDLE(uint32)            pdc;  /* _PDC */
430     } u;
431 };
432 typedef struct xenpf_set_processor_pminfo xenpf_set_processor_pminfo_t;
433 DEFINE_XEN_GUEST_HANDLE(xenpf_set_processor_pminfo_t);
434
435 #define XENPF_get_cpuinfo 55
436 struct xenpf_pcpuinfo {
437     /* IN */
438     uint32_t xen_cpuid;
439     /* OUT */
440     /* The maxium cpu_id that is present */
441     uint32_t max_present;
442 #define XEN_PCPU_FLAGS_ONLINE   1
443     /* Correponding xen_cpuid is not present*/
444 #define XEN_PCPU_FLAGS_INVALID  2
445     uint32_t flags;
446     uint32_t apic_id;
447     uint32_t acpi_id;
448 };
449 typedef struct xenpf_pcpuinfo xenpf_pcpuinfo_t;
450 DEFINE_XEN_GUEST_HANDLE(xenpf_pcpuinfo_t);
451
452 #define XENPF_get_cpu_version 48
453 struct xenpf_pcpu_version {
454     /* IN */
455     uint32_t xen_cpuid;
456     /* OUT */
457     /* The maxium cpu_id that is present */
458     uint32_t max_present;
459     char vendor_id[12];
460     uint32_t family;
461     uint32_t model;
462     uint32_t stepping;
463 };
464 typedef struct xenpf_pcpu_version xenpf_pcpu_version_t;
465 DEFINE_XEN_GUEST_HANDLE(xenpf_pcpu_version_t);
466
467 #define XENPF_cpu_online    56
468 #define XENPF_cpu_offline   57
469 struct xenpf_cpu_ol
470 {
471     uint32_t cpuid;
472 };
473 typedef struct xenpf_cpu_ol xenpf_cpu_ol_t;
474 DEFINE_XEN_GUEST_HANDLE(xenpf_cpu_ol_t);
475
476 #define XENPF_cpu_hotadd    58
477 struct xenpf_cpu_hotadd
478 {
479         uint32_t apic_id;
480         uint32_t acpi_id;
481         uint32_t pxm;
482 };
483
484 #define XENPF_mem_hotadd    59
485 struct xenpf_mem_hotadd
486 {
487     uint64_t spfn;
488     uint64_t epfn;
489     uint32_t pxm;
490     uint32_t flags;
491 };
492
493 #define XENPF_core_parking  60
494
495 #define XEN_CORE_PARKING_SET 1
496 #define XEN_CORE_PARKING_GET 2
497 struct xenpf_core_parking {
498     /* IN variables */
499     uint32_t type;
500     /* IN variables:  set cpu nums expected to be idled */
501     /* OUT variables: get cpu nums actually be idled */
502     uint32_t idle_nums;
503 };
504 typedef struct xenpf_core_parking xenpf_core_parking_t;
505 DEFINE_XEN_GUEST_HANDLE(xenpf_core_parking_t);
506
507 /*
508  * ` enum neg_errnoval
509  * ` HYPERVISOR_platform_op(const struct xen_platform_op*);
510  */
511 struct xen_platform_op {
512     uint32_t cmd;
513     uint32_t interface_version; /* XENPF_INTERFACE_VERSION */
514     union {
515         struct xenpf_settime           settime;
516         struct xenpf_add_memtype       add_memtype;
517         struct xenpf_del_memtype       del_memtype;
518         struct xenpf_read_memtype      read_memtype;
519         struct xenpf_microcode_update  microcode;
520         struct xenpf_platform_quirk    platform_quirk;
521         struct xenpf_efi_runtime_call  efi_runtime_call;
522         struct xenpf_firmware_info     firmware_info;
523         struct xenpf_enter_acpi_sleep  enter_acpi_sleep;
524         struct xenpf_change_freq       change_freq;
525         struct xenpf_getidletime       getidletime;
526         struct xenpf_set_processor_pminfo set_pminfo;
527         struct xenpf_pcpuinfo          pcpu_info;
528         struct xenpf_pcpu_version      pcpu_version;
529         struct xenpf_cpu_ol            cpu_ol;
530         struct xenpf_cpu_hotadd        cpu_add;
531         struct xenpf_mem_hotadd        mem_add;
532         struct xenpf_core_parking      core_parking;
533         uint8_t                        pad[128];
534     } u;
535 };
536 typedef struct xen_platform_op xen_platform_op_t;
537 DEFINE_XEN_GUEST_HANDLE(xen_platform_op_t);
538
539 #endif /* __XEN_PUBLIC_PLATFORM_H__ */
540
541 /*
542  * Local variables:
543  * mode: C
544  * c-set-style: "BSD"
545  * c-basic-offset: 4
546  * tab-width: 4
547  * indent-tabs-mode: nil
548  * End:
549  */