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