1 /* $NetBSD: platform.h,v 1.3 2008/05/04 19:56:28 cegger Exp $ */
2 /******************************************************************************
5 * Hardware platform operations. Intended for use by domain-0 kernel.
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:
14 * The above copyright notice and this permission notice shall be included in
15 * all copies or substantial portions of the Software.
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.
25 * Copyright (c) 2002-2006, K Fraser
28 #ifndef __XEN_PUBLIC_PLATFORM_H__
29 #define __XEN_PUBLIC_PLATFORM_H__
33 #define XENPF_INTERFACE_VERSION 0x03000001
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>.
39 #define XENPF_settime 17
40 struct xenpf_settime
{
46 typedef struct xenpf_settime xenpf_settime_t
;
47 DEFINE_XEN_GUEST_HANDLE(xenpf_settime_t
);
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.
56 #define XENPF_add_memtype 31
57 struct xenpf_add_memtype
{
66 typedef struct xenpf_add_memtype xenpf_add_memtype_t
;
67 DEFINE_XEN_GUEST_HANDLE(xenpf_add_memtype_t
);
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.
76 #define XENPF_del_memtype 32
77 struct xenpf_del_memtype
{
82 typedef struct xenpf_del_memtype xenpf_del_memtype_t
;
83 DEFINE_XEN_GUEST_HANDLE(xenpf_del_memtype_t
);
85 /* Read current type of an MTRR (x86-specific). */
86 #define XENPF_read_memtype 33
87 struct xenpf_read_memtype
{
95 typedef struct xenpf_read_memtype xenpf_read_memtype_t
;
96 DEFINE_XEN_GUEST_HANDLE(xenpf_read_memtype_t
);
98 #define XENPF_microcode_update 35
99 struct xenpf_microcode_update
{
101 XEN_GUEST_HANDLE(void) data
; /* Pointer to microcode data */
102 uint32_t length
; /* Length of microcode data. */
104 typedef struct xenpf_microcode_update xenpf_microcode_update_t
;
105 DEFINE_XEN_GUEST_HANDLE(xenpf_microcode_update_t
);
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
{
115 typedef struct xenpf_platform_quirk xenpf_platform_quirk_t
;
116 DEFINE_XEN_GUEST_HANDLE(xenpf_platform_quirk_t
);
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
{
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 */
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 */
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 */
154 typedef struct xenpf_firmware_info xenpf_firmware_info_t
;
155 DEFINE_XEN_GUEST_HANDLE(xenpf_firmware_info_t
);
157 #define XENPF_enter_acpi_sleep 51
158 struct xenpf_enter_acpi_sleep
{
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. */
165 typedef struct xenpf_enter_acpi_sleep xenpf_enter_acpi_sleep_t
;
166 DEFINE_XEN_GUEST_HANDLE(xenpf_enter_acpi_sleep_t
);
168 #define XENPF_change_freq 52
169 struct xenpf_change_freq
{
171 uint32_t flags
; /* Must be zero. */
172 uint32_t cpu
; /* Physical cpu. */
173 uint64_t freq
; /* New frequency (Hz). */
175 typedef struct xenpf_change_freq xenpf_change_freq_t
;
176 DEFINE_XEN_GUEST_HANDLE(xenpf_change_freq_t
);
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
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
;
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
;
197 /* System time when the idletime snapshots were taken. */
200 typedef struct xenpf_getidletime xenpf_getidletime_t
;
201 DEFINE_XEN_GUEST_HANDLE(xenpf_getidletime_t
);
203 #define XENPF_set_processor_pminfo 54
206 #define XEN_PROCESSOR_PM_CX 1
207 #define XEN_PROCESSOR_PM_PX 2
208 #define XEN_PROCESSOR_PM_TX 4
215 /* Px sub info type */
221 struct xen_power_register
{
225 uint32_t access_size
;
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 */
234 typedef struct xen_processor_csd xen_processor_csd_t
;
235 DEFINE_XEN_GUEST_HANDLE(xen_processor_csd_t
);
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 */
245 typedef struct xen_processor_cx xen_processor_cx_t
;
246 DEFINE_XEN_GUEST_HANDLE(xen_processor_cx_t
);
248 struct xen_processor_flags
{
249 uint32_t bm_control
:1;
252 uint32_t power_setup_done
:1;
253 uint32_t bm_rld_set
:1;
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 */
262 struct xen_pct_register
{
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 */
280 typedef struct xen_processor_px xen_processor_px_t
;
281 DEFINE_XEN_GUEST_HANDLE(xen_processor_px_t
);
283 struct xen_psd_package
{
284 uint64_t num_entries
;
288 uint64_t num_processors
;
291 struct xen_processor_performance
{
292 uint32_t flags
; /* flag for Px sub info type */
293 uint32_t ppc
; /* 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 */
301 typedef struct xen_processor_performance xen_processor_performance_t
;
302 DEFINE_XEN_GUEST_HANDLE(xen_processor_performance_t
);
304 struct xenpf_set_processor_pminfo
{
306 uint32_t id
; /* ACPI CPU ID */
307 uint32_t type
; /* {XEN_PM_CX, XEN_PM_PX} */
309 struct xen_processor_power power
;/* Cx: _CST/_CSD */
310 struct xen_processor_performance perf
; /* Px: _PPC/_PCT/_PSS/_PSD */
313 typedef struct xenpf_set_processor_pminfo xenpf_set_processor_pminfo_t
;
314 DEFINE_XEN_GUEST_HANDLE(xenpf_set_processor_pminfo_t
);
316 struct xen_platform_op
{
318 uint32_t interface_version
; /* XENPF_INTERFACE_VERSION */
320 struct xenpf_settime settime
;
321 struct xenpf_add_memtype add_memtype
;
322 struct xenpf_del_memtype del_memtype
;
323 struct xenpf_read_memtype read_memtype
;
324 struct xenpf_microcode_update microcode
;
325 struct xenpf_platform_quirk platform_quirk
;
326 struct xenpf_firmware_info firmware_info
;
327 struct xenpf_enter_acpi_sleep enter_acpi_sleep
;
328 struct xenpf_change_freq change_freq
;
329 struct xenpf_getidletime getidletime
;
330 struct xenpf_set_processor_pminfo set_pminfo
;
334 typedef struct xen_platform_op xen_platform_op_t
;
335 DEFINE_XEN_GUEST_HANDLE(xen_platform_op_t
);
337 #endif /* __XEN_PUBLIC_PLATFORM_H__ */
345 * indent-tabs-mode: nil