1 | /* $NetBSD: platform.h,v 1.1.1.2 2011/12/07 14:41:15 cegger Exp $ */ |
2 | /****************************************************************************** |
3 | * platform.h |
4 | * |
5 | * Hardware platform operations. Intended for use by domain-0 kernel. |
6 | * |
7 | * Permission is hereby granted, free of charge, to any person obtaining a copy |
8 | * of this software and associated documentation files (the "Software"), to |
9 | * deal in the Software without restriction, including without limitation the |
10 | * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or |
11 | * sell copies of the Software, and to permit persons to whom the Software is |
12 | * furnished to do so, subject to the following conditions: |
13 | * |
14 | * The above copyright notice and this permission notice shall be included in |
15 | * all copies or substantial portions of the Software. |
16 | * |
17 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR |
18 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, |
19 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE |
20 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER |
21 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING |
22 | * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER |
23 | * DEALINGS IN THE SOFTWARE. |
24 | * |
25 | * Copyright (c) 2002-2006, K Fraser |
26 | */ |
27 | |
28 | #ifndef __XEN_PUBLIC_PLATFORM_H__ |
29 | #define __XEN_PUBLIC_PLATFORM_H__ |
30 | |
31 | #include "xen.h" |
32 | |
33 | #define XENPF_INTERFACE_VERSION 0x03000001 |
34 | |
35 | /* |
36 | * Set clock such that it would read <secs,nsecs> after 00:00:00 UTC, |
37 | * 1 January, 1970 if the current system time was <system_time>. |
38 | */ |
39 | #define XENPF_settime 17 |
40 | struct xenpf_settime { |
41 | /* IN variables. */ |
42 | uint32_t secs; |
43 | uint32_t nsecs; |
44 | uint64_t system_time; |
45 | }; |
46 | typedef struct xenpf_settime xenpf_settime_t; |
47 | DEFINE_XEN_GUEST_HANDLE(xenpf_settime_t); |
48 | |
49 | /* |
50 | * Request memory range (@mfn, @mfn+@nr_mfns-1) to have type @type. |
51 | * On x86, @type is an architecture-defined MTRR memory type. |
52 | * On success, returns the MTRR that was used (@reg) and a handle that can |
53 | * be passed to XENPF_DEL_MEMTYPE to accurately tear down the new setting. |
54 | * (x86-specific). |
55 | */ |
56 | #define XENPF_add_memtype 31 |
57 | struct xenpf_add_memtype { |
58 | /* IN variables. */ |
59 | xen_pfn_t mfn; |
60 | uint64_t nr_mfns; |
61 | uint32_t type; |
62 | /* OUT variables. */ |
63 | uint32_t handle; |
64 | uint32_t reg; |
65 | }; |
66 | typedef struct xenpf_add_memtype xenpf_add_memtype_t; |
67 | DEFINE_XEN_GUEST_HANDLE(xenpf_add_memtype_t); |
68 | |
69 | /* |
70 | * Tear down an existing memory-range type. If @handle is remembered then it |
71 | * should be passed in to accurately tear down the correct setting (in case |
72 | * of overlapping memory regions with differing types). If it is not known |
73 | * then @handle should be set to zero. In all cases @reg must be set. |
74 | * (x86-specific). |
75 | */ |
76 | #define XENPF_del_memtype 32 |
77 | struct xenpf_del_memtype { |
78 | /* IN variables. */ |
79 | uint32_t handle; |
80 | uint32_t reg; |
81 | }; |
82 | typedef struct xenpf_del_memtype xenpf_del_memtype_t; |
83 | DEFINE_XEN_GUEST_HANDLE(xenpf_del_memtype_t); |
84 | |
85 | /* Read current type of an MTRR (x86-specific). */ |
86 | #define XENPF_read_memtype 33 |
87 | struct xenpf_read_memtype { |
88 | /* IN variables. */ |
89 | uint32_t reg; |
90 | /* OUT variables. */ |
91 | xen_pfn_t mfn; |
92 | uint64_t nr_mfns; |
93 | uint32_t type; |
94 | }; |
95 | typedef struct xenpf_read_memtype xenpf_read_memtype_t; |
96 | DEFINE_XEN_GUEST_HANDLE(xenpf_read_memtype_t); |
97 | |
98 | #define XENPF_microcode_update 35 |
99 | struct xenpf_microcode_update { |
100 | /* IN variables. */ |
101 | XEN_GUEST_HANDLE(const_void) data;/* Pointer to microcode data */ |
102 | uint32_t length; /* Length of microcode data. */ |
103 | }; |
104 | typedef struct xenpf_microcode_update xenpf_microcode_update_t; |
105 | DEFINE_XEN_GUEST_HANDLE(xenpf_microcode_update_t); |
106 | |
107 | #define XENPF_platform_quirk 39 |
108 | #define QUIRK_NOIRQBALANCING 1 /* Do not restrict IO-APIC RTE targets */ |
109 | #define QUIRK_IOAPIC_BAD_REGSEL 2 /* IO-APIC REGSEL forgets its value */ |
110 | #define QUIRK_IOAPIC_GOOD_REGSEL 3 /* IO-APIC REGSEL behaves properly */ |
111 | struct xenpf_platform_quirk { |
112 | /* IN variables. */ |
113 | uint32_t quirk_id; |
114 | }; |
115 | typedef struct xenpf_platform_quirk xenpf_platform_quirk_t; |
116 | DEFINE_XEN_GUEST_HANDLE(xenpf_platform_quirk_t); |
117 | |
118 | #define XENPF_firmware_info 50 |
119 | #define XEN_FW_DISK_INFO 1 /* from int 13 AH=08/41/48 */ |
120 | #define XEN_FW_DISK_MBR_SIGNATURE 2 /* from MBR offset 0x1b8 */ |
121 | #define XEN_FW_VBEDDC_INFO 3 /* from int 10 AX=4f15 */ |
122 | struct xenpf_firmware_info { |
123 | /* IN variables. */ |
124 | uint32_t type; |
125 | uint32_t index; |
126 | /* OUT variables. */ |
127 | union { |
128 | struct { |
129 | /* Int13, Fn48: Check Extensions Present. */ |
130 | uint8_t device; /* %dl: bios device number */ |
131 | uint8_t version; /* %ah: major version */ |
132 | uint16_t interface_support; /* %cx: support bitmap */ |
133 | /* Int13, Fn08: Legacy Get Device Parameters. */ |
134 | uint16_t legacy_max_cylinder; /* %cl[7:6]:%ch: max cyl # */ |
135 | uint8_t legacy_max_head; /* %dh: max head # */ |
136 | uint8_t legacy_sectors_per_track; /* %cl[5:0]: max sector # */ |
137 | /* Int13, Fn41: Get Device Parameters (as filled into %ds:%esi). */ |
138 | /* NB. First uint16_t of buffer must be set to buffer size. */ |
139 | XEN_GUEST_HANDLE(void) edd_params; |
140 | } disk_info; /* XEN_FW_DISK_INFO */ |
141 | struct { |
142 | uint8_t device; /* bios device number */ |
143 | uint32_t mbr_signature; /* offset 0x1b8 in mbr */ |
144 | } disk_mbr_signature; /* XEN_FW_DISK_MBR_SIGNATURE */ |
145 | struct { |
146 | /* Int10, AX=4F15: Get EDID info. */ |
147 | uint8_t capabilities; |
148 | uint8_t edid_transfer_time; |
149 | /* must refer to 128-byte buffer */ |
150 | XEN_GUEST_HANDLE(uint8) edid; |
151 | } vbeddc_info; /* XEN_FW_VBEDDC_INFO */ |
152 | } u; |
153 | }; |
154 | typedef struct xenpf_firmware_info xenpf_firmware_info_t; |
155 | DEFINE_XEN_GUEST_HANDLE(xenpf_firmware_info_t); |
156 | |
157 | #define XENPF_enter_acpi_sleep 51 |
158 | struct xenpf_enter_acpi_sleep { |
159 | /* IN variables */ |
160 | uint16_t pm1a_cnt_val; /* PM1a control value. */ |
161 | uint16_t pm1b_cnt_val; /* PM1b control value. */ |
162 | uint32_t sleep_state; /* Which state to enter (Sn). */ |
163 | uint32_t flags; /* Must be zero. */ |
164 | }; |
165 | typedef struct xenpf_enter_acpi_sleep xenpf_enter_acpi_sleep_t; |
166 | DEFINE_XEN_GUEST_HANDLE(xenpf_enter_acpi_sleep_t); |
167 | |
168 | #define XENPF_change_freq 52 |
169 | struct xenpf_change_freq { |
170 | /* IN variables */ |
171 | uint32_t flags; /* Must be zero. */ |
172 | uint32_t cpu; /* Physical cpu. */ |
173 | uint64_t freq; /* New frequency (Hz). */ |
174 | }; |
175 | typedef struct xenpf_change_freq xenpf_change_freq_t; |
176 | DEFINE_XEN_GUEST_HANDLE(xenpf_change_freq_t); |
177 | |
178 | /* |
179 | * Get idle times (nanoseconds since boot) for physical CPUs specified in the |
180 | * @cpumap_bitmap with range [0..@cpumap_nr_cpus-1]. The @idletime array is |
181 | * indexed by CPU number; only entries with the corresponding @cpumap_bitmap |
182 | * bit set are written to. On return, @cpumap_bitmap is modified so that any |
183 | * non-existent CPUs are cleared. Such CPUs have their @idletime array entry |
184 | * cleared. |
185 | */ |
186 | #define XENPF_getidletime 53 |
187 | struct xenpf_getidletime { |
188 | /* IN/OUT variables */ |
189 | /* IN: CPUs to interrogate; OUT: subset of IN which are present */ |
190 | XEN_GUEST_HANDLE(uint8) cpumap_bitmap; |
191 | /* IN variables */ |
192 | /* Size of cpumap bitmap. */ |
193 | uint32_t cpumap_nr_cpus; |
194 | /* Must be indexable for every cpu in cpumap_bitmap. */ |
195 | XEN_GUEST_HANDLE(uint64) idletime; |
196 | /* OUT variables */ |
197 | /* System time when the idletime snapshots were taken. */ |
198 | uint64_t now; |
199 | }; |
200 | typedef struct xenpf_getidletime xenpf_getidletime_t; |
201 | DEFINE_XEN_GUEST_HANDLE(xenpf_getidletime_t); |
202 | |
203 | #define XENPF_set_processor_pminfo 54 |
204 | |
205 | /* ability bits */ |
206 | #define XEN_PROCESSOR_PM_CX 1 |
207 | #define XEN_PROCESSOR_PM_PX 2 |
208 | #define XEN_PROCESSOR_PM_TX 4 |
209 | |
210 | /* cmd type */ |
211 | #define XEN_PM_CX 0 |
212 | #define XEN_PM_PX 1 |
213 | #define XEN_PM_TX 2 |
214 | |
215 | /* Px sub info type */ |
216 | #define XEN_PX_PCT 1 |
217 | #define XEN_PX_PSS 2 |
218 | #define XEN_PX_PPC 4 |
219 | #define XEN_PX_PSD 8 |
220 | |
221 | struct xen_power_register { |
222 | uint32_t space_id; |
223 | uint32_t bit_width; |
224 | uint32_t bit_offset; |
225 | uint32_t access_size; |
226 | uint64_t address; |
227 | }; |
228 | |
229 | struct xen_processor_csd { |
230 | uint32_t domain; /* domain number of one dependent group */ |
231 | uint32_t coord_type; /* coordination type */ |
232 | uint32_t num; /* number of processors in same domain */ |
233 | }; |
234 | typedef struct xen_processor_csd xen_processor_csd_t; |
235 | DEFINE_XEN_GUEST_HANDLE(xen_processor_csd_t); |
236 | |
237 | struct xen_processor_cx { |
238 | struct xen_power_register reg; /* GAS for Cx trigger register */ |
239 | uint8_t type; /* cstate value, c0: 0, c1: 1, ... */ |
240 | uint32_t latency; /* worst latency (ms) to enter/exit this cstate */ |
241 | uint32_t power; /* average power consumption(mW) */ |
242 | uint32_t dpcnt; /* number of dependency entries */ |
243 | XEN_GUEST_HANDLE(xen_processor_csd_t) dp; /* NULL if no dependency */ |
244 | }; |
245 | typedef struct xen_processor_cx xen_processor_cx_t; |
246 | DEFINE_XEN_GUEST_HANDLE(xen_processor_cx_t); |
247 | |
248 | struct xen_processor_flags { |
249 | uint32_t bm_control:1; |
250 | uint32_t bm_check:1; |
251 | uint32_t has_cst:1; |
252 | uint32_t power_setup_done:1; |
253 | uint32_t bm_rld_set:1; |
254 | }; |
255 | |
256 | struct xen_processor_power { |
257 | uint32_t count; /* number of C state entries in array below */ |
258 | struct xen_processor_flags flags; /* global flags of this processor */ |
259 | XEN_GUEST_HANDLE(xen_processor_cx_t) states; /* supported c states */ |
260 | }; |
261 | |
262 | struct xen_pct_register { |
263 | uint8_t descriptor; |
264 | uint16_t length; |
265 | uint8_t space_id; |
266 | uint8_t bit_width; |
267 | uint8_t bit_offset; |
268 | uint8_t reserved; |
269 | uint64_t address; |
270 | }; |
271 | |
272 | struct xen_processor_px { |
273 | uint64_t core_frequency; /* megahertz */ |
274 | uint64_t power; /* milliWatts */ |
275 | uint64_t transition_latency; /* microseconds */ |
276 | uint64_t bus_master_latency; /* microseconds */ |
277 | uint64_t control; /* control value */ |
278 | uint64_t status; /* success indicator */ |
279 | }; |
280 | typedef struct xen_processor_px xen_processor_px_t; |
281 | DEFINE_XEN_GUEST_HANDLE(xen_processor_px_t); |
282 | |
283 | struct xen_psd_package { |
284 | uint64_t num_entries; |
285 | uint64_t revision; |
286 | uint64_t domain; |
287 | uint64_t coord_type; |
288 | uint64_t num_processors; |
289 | }; |
290 | |
291 | struct xen_processor_performance { |
292 | uint32_t flags; /* flag for Px sub info type */ |
293 | uint32_t platform_limit; /* Platform limitation on freq usage */ |
294 | struct xen_pct_register control_register; |
295 | struct xen_pct_register status_register; |
296 | uint32_t state_count; /* total available performance states */ |
297 | XEN_GUEST_HANDLE(xen_processor_px_t) states; |
298 | struct xen_psd_package domain_info; |
299 | uint32_t shared_type; /* coordination type of this processor */ |
300 | }; |
301 | typedef struct xen_processor_performance xen_processor_performance_t; |
302 | DEFINE_XEN_GUEST_HANDLE(xen_processor_performance_t); |
303 | |
304 | struct xenpf_set_processor_pminfo { |
305 | /* IN variables */ |
306 | uint32_t id; /* ACPI CPU ID */ |
307 | uint32_t type; /* {XEN_PM_CX, XEN_PM_PX} */ |
308 | union { |
309 | struct xen_processor_power power;/* Cx: _CST/_CSD */ |
310 | struct xen_processor_performance perf; /* Px: _PPC/_PCT/_PSS/_PSD */ |
311 | } u; |
312 | }; |
313 | typedef struct xenpf_set_processor_pminfo xenpf_set_processor_pminfo_t; |
314 | DEFINE_XEN_GUEST_HANDLE(xenpf_set_processor_pminfo_t); |
315 | |
316 | #define XENPF_get_cpuinfo 55 |
317 | struct xenpf_pcpuinfo { |
318 | /* IN */ |
319 | uint32_t xen_cpuid; |
320 | /* OUT */ |
321 | /* The maxium cpu_id that is present */ |
322 | uint32_t max_present; |
323 | #define XEN_PCPU_FLAGS_ONLINE 1 |
324 | /* Correponding xen_cpuid is not present*/ |
325 | #define XEN_PCPU_FLAGS_INVALID 2 |
326 | uint32_t flags; |
327 | uint32_t apic_id; |
328 | uint32_t acpi_id; |
329 | }; |
330 | typedef struct xenpf_pcpuinfo xenpf_pcpuinfo_t; |
331 | DEFINE_XEN_GUEST_HANDLE(xenpf_pcpuinfo_t); |
332 | |
333 | #define XENPF_cpu_online 56 |
334 | #define XENPF_cpu_offline 57 |
335 | struct xenpf_cpu_ol |
336 | { |
337 | uint32_t cpuid; |
338 | }; |
339 | typedef struct xenpf_cpu_ol xenpf_cpu_ol_t; |
340 | DEFINE_XEN_GUEST_HANDLE(xenpf_cpu_ol_t); |
341 | |
342 | #define XENPF_cpu_hotadd 58 |
343 | struct xenpf_cpu_hotadd |
344 | { |
345 | uint32_t apic_id; |
346 | uint32_t acpi_id; |
347 | uint32_t pxm; |
348 | }; |
349 | |
350 | #define XENPF_mem_hotadd 59 |
351 | struct xenpf_mem_hotadd |
352 | { |
353 | uint64_t spfn; |
354 | uint64_t epfn; |
355 | uint32_t pxm; |
356 | uint32_t flags; |
357 | }; |
358 | |
359 | struct xen_platform_op { |
360 | uint32_t cmd; |
361 | uint32_t interface_version; /* XENPF_INTERFACE_VERSION */ |
362 | union { |
363 | struct xenpf_settime settime; |
364 | struct xenpf_add_memtype add_memtype; |
365 | struct xenpf_del_memtype del_memtype; |
366 | struct xenpf_read_memtype read_memtype; |
367 | struct xenpf_microcode_update microcode; |
368 | struct xenpf_platform_quirk platform_quirk; |
369 | struct xenpf_firmware_info firmware_info; |
370 | struct xenpf_enter_acpi_sleep enter_acpi_sleep; |
371 | struct xenpf_change_freq change_freq; |
372 | struct xenpf_getidletime getidletime; |
373 | struct xenpf_set_processor_pminfo set_pminfo; |
374 | struct xenpf_pcpuinfo pcpu_info; |
375 | struct xenpf_cpu_ol cpu_ol; |
376 | struct xenpf_cpu_hotadd cpu_add; |
377 | struct xenpf_mem_hotadd mem_add; |
378 | uint8_t pad[128]; |
379 | } u; |
380 | }; |
381 | typedef struct xen_platform_op xen_platform_op_t; |
382 | DEFINE_XEN_GUEST_HANDLE(xen_platform_op_t); |
383 | |
384 | #endif /* __XEN_PUBLIC_PLATFORM_H__ */ |
385 | |
386 | /* |
387 | * Local variables: |
388 | * mode: C |
389 | * c-set-style: "BSD" |
390 | * c-basic-offset: 4 |
391 | * tab-width: 4 |
392 | * indent-tabs-mode: nil |
393 | * End: |
394 | */ |
395 | |