13e0996798a6a113efae9e0187c5581491bdb07a7Yu Ke/******************************************************************************
23e0996798a6a113efae9e0187c5581491bdb07a7Yu Ke * platform.h
33e0996798a6a113efae9e0187c5581491bdb07a7Yu Ke *
43e0996798a6a113efae9e0187c5581491bdb07a7Yu Ke * Hardware platform operations. Intended for use by domain-0 kernel.
53e0996798a6a113efae9e0187c5581491bdb07a7Yu Ke *
63e0996798a6a113efae9e0187c5581491bdb07a7Yu Ke * Permission is hereby granted, free of charge, to any person obtaining a copy
73e0996798a6a113efae9e0187c5581491bdb07a7Yu Ke * of this software and associated documentation files (the "Software"), to
83e0996798a6a113efae9e0187c5581491bdb07a7Yu Ke * deal in the Software without restriction, including without limitation the
93e0996798a6a113efae9e0187c5581491bdb07a7Yu Ke * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
103e0996798a6a113efae9e0187c5581491bdb07a7Yu Ke * sell copies of the Software, and to permit persons to whom the Software is
113e0996798a6a113efae9e0187c5581491bdb07a7Yu Ke * furnished to do so, subject to the following conditions:
123e0996798a6a113efae9e0187c5581491bdb07a7Yu Ke *
133e0996798a6a113efae9e0187c5581491bdb07a7Yu Ke * The above copyright notice and this permission notice shall be included in
143e0996798a6a113efae9e0187c5581491bdb07a7Yu Ke * all copies or substantial portions of the Software.
153e0996798a6a113efae9e0187c5581491bdb07a7Yu Ke *
163e0996798a6a113efae9e0187c5581491bdb07a7Yu Ke * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
173e0996798a6a113efae9e0187c5581491bdb07a7Yu Ke * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
183e0996798a6a113efae9e0187c5581491bdb07a7Yu Ke * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
193e0996798a6a113efae9e0187c5581491bdb07a7Yu Ke * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
203e0996798a6a113efae9e0187c5581491bdb07a7Yu Ke * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
213e0996798a6a113efae9e0187c5581491bdb07a7Yu Ke * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
223e0996798a6a113efae9e0187c5581491bdb07a7Yu Ke * DEALINGS IN THE SOFTWARE.
233e0996798a6a113efae9e0187c5581491bdb07a7Yu Ke *
243e0996798a6a113efae9e0187c5581491bdb07a7Yu Ke * Copyright (c) 2002-2006, K Fraser
253e0996798a6a113efae9e0187c5581491bdb07a7Yu Ke */
263e0996798a6a113efae9e0187c5581491bdb07a7Yu Ke
273e0996798a6a113efae9e0187c5581491bdb07a7Yu Ke#ifndef __XEN_PUBLIC_PLATFORM_H__
283e0996798a6a113efae9e0187c5581491bdb07a7Yu Ke#define __XEN_PUBLIC_PLATFORM_H__
293e0996798a6a113efae9e0187c5581491bdb07a7Yu Ke
303e0996798a6a113efae9e0187c5581491bdb07a7Yu Ke#include "xen.h"
313e0996798a6a113efae9e0187c5581491bdb07a7Yu Ke
323e0996798a6a113efae9e0187c5581491bdb07a7Yu Ke#define XENPF_INTERFACE_VERSION 0x03000001
333e0996798a6a113efae9e0187c5581491bdb07a7Yu Ke
343e0996798a6a113efae9e0187c5581491bdb07a7Yu Ke/*
353e0996798a6a113efae9e0187c5581491bdb07a7Yu Ke * Set clock such that it would read <secs,nsecs> after 00:00:00 UTC,
363e0996798a6a113efae9e0187c5581491bdb07a7Yu Ke * 1 January, 1970 if the current system time was <system_time>.
373e0996798a6a113efae9e0187c5581491bdb07a7Yu Ke */
383e0996798a6a113efae9e0187c5581491bdb07a7Yu Ke#define XENPF_settime             17
393e0996798a6a113efae9e0187c5581491bdb07a7Yu Kestruct xenpf_settime {
403e0996798a6a113efae9e0187c5581491bdb07a7Yu Ke	/* IN variables. */
413e0996798a6a113efae9e0187c5581491bdb07a7Yu Ke	uint32_t secs;
423e0996798a6a113efae9e0187c5581491bdb07a7Yu Ke	uint32_t nsecs;
433e0996798a6a113efae9e0187c5581491bdb07a7Yu Ke	uint64_t system_time;
443e0996798a6a113efae9e0187c5581491bdb07a7Yu Ke};
453e0996798a6a113efae9e0187c5581491bdb07a7Yu KeDEFINE_GUEST_HANDLE_STRUCT(xenpf_settime_t);
463e0996798a6a113efae9e0187c5581491bdb07a7Yu Ke
473e0996798a6a113efae9e0187c5581491bdb07a7Yu Ke/*
483e0996798a6a113efae9e0187c5581491bdb07a7Yu Ke * Request memory range (@mfn, @mfn+@nr_mfns-1) to have type @type.
493e0996798a6a113efae9e0187c5581491bdb07a7Yu Ke * On x86, @type is an architecture-defined MTRR memory type.
503e0996798a6a113efae9e0187c5581491bdb07a7Yu Ke * On success, returns the MTRR that was used (@reg) and a handle that can
513e0996798a6a113efae9e0187c5581491bdb07a7Yu Ke * be passed to XENPF_DEL_MEMTYPE to accurately tear down the new setting.
523e0996798a6a113efae9e0187c5581491bdb07a7Yu Ke * (x86-specific).
533e0996798a6a113efae9e0187c5581491bdb07a7Yu Ke */
543e0996798a6a113efae9e0187c5581491bdb07a7Yu Ke#define XENPF_add_memtype         31
553e0996798a6a113efae9e0187c5581491bdb07a7Yu Kestruct xenpf_add_memtype {
563e0996798a6a113efae9e0187c5581491bdb07a7Yu Ke	/* IN variables. */
573e0996798a6a113efae9e0187c5581491bdb07a7Yu Ke	unsigned long mfn;
583e0996798a6a113efae9e0187c5581491bdb07a7Yu Ke	uint64_t nr_mfns;
593e0996798a6a113efae9e0187c5581491bdb07a7Yu Ke	uint32_t type;
603e0996798a6a113efae9e0187c5581491bdb07a7Yu Ke	/* OUT variables. */
613e0996798a6a113efae9e0187c5581491bdb07a7Yu Ke	uint32_t handle;
623e0996798a6a113efae9e0187c5581491bdb07a7Yu Ke	uint32_t reg;
633e0996798a6a113efae9e0187c5581491bdb07a7Yu Ke};
643e0996798a6a113efae9e0187c5581491bdb07a7Yu KeDEFINE_GUEST_HANDLE_STRUCT(xenpf_add_memtype_t);
653e0996798a6a113efae9e0187c5581491bdb07a7Yu Ke
663e0996798a6a113efae9e0187c5581491bdb07a7Yu Ke/*
673e0996798a6a113efae9e0187c5581491bdb07a7Yu Ke * Tear down an existing memory-range type. If @handle is remembered then it
683e0996798a6a113efae9e0187c5581491bdb07a7Yu Ke * should be passed in to accurately tear down the correct setting (in case
693e0996798a6a113efae9e0187c5581491bdb07a7Yu Ke * of overlapping memory regions with differing types). If it is not known
703e0996798a6a113efae9e0187c5581491bdb07a7Yu Ke * then @handle should be set to zero. In all cases @reg must be set.
713e0996798a6a113efae9e0187c5581491bdb07a7Yu Ke * (x86-specific).
723e0996798a6a113efae9e0187c5581491bdb07a7Yu Ke */
733e0996798a6a113efae9e0187c5581491bdb07a7Yu Ke#define XENPF_del_memtype         32
743e0996798a6a113efae9e0187c5581491bdb07a7Yu Kestruct xenpf_del_memtype {
753e0996798a6a113efae9e0187c5581491bdb07a7Yu Ke	/* IN variables. */
763e0996798a6a113efae9e0187c5581491bdb07a7Yu Ke	uint32_t handle;
773e0996798a6a113efae9e0187c5581491bdb07a7Yu Ke	uint32_t reg;
783e0996798a6a113efae9e0187c5581491bdb07a7Yu Ke};
793e0996798a6a113efae9e0187c5581491bdb07a7Yu KeDEFINE_GUEST_HANDLE_STRUCT(xenpf_del_memtype_t);
803e0996798a6a113efae9e0187c5581491bdb07a7Yu Ke
813e0996798a6a113efae9e0187c5581491bdb07a7Yu Ke/* Read current type of an MTRR (x86-specific). */
823e0996798a6a113efae9e0187c5581491bdb07a7Yu Ke#define XENPF_read_memtype        33
833e0996798a6a113efae9e0187c5581491bdb07a7Yu Kestruct xenpf_read_memtype {
843e0996798a6a113efae9e0187c5581491bdb07a7Yu Ke	/* IN variables. */
853e0996798a6a113efae9e0187c5581491bdb07a7Yu Ke	uint32_t reg;
863e0996798a6a113efae9e0187c5581491bdb07a7Yu Ke	/* OUT variables. */
873e0996798a6a113efae9e0187c5581491bdb07a7Yu Ke	unsigned long mfn;
883e0996798a6a113efae9e0187c5581491bdb07a7Yu Ke	uint64_t nr_mfns;
893e0996798a6a113efae9e0187c5581491bdb07a7Yu Ke	uint32_t type;
903e0996798a6a113efae9e0187c5581491bdb07a7Yu Ke};
913e0996798a6a113efae9e0187c5581491bdb07a7Yu KeDEFINE_GUEST_HANDLE_STRUCT(xenpf_read_memtype_t);
923e0996798a6a113efae9e0187c5581491bdb07a7Yu Ke
933e0996798a6a113efae9e0187c5581491bdb07a7Yu Ke#define XENPF_microcode_update    35
943e0996798a6a113efae9e0187c5581491bdb07a7Yu Kestruct xenpf_microcode_update {
953e0996798a6a113efae9e0187c5581491bdb07a7Yu Ke	/* IN variables. */
963e0996798a6a113efae9e0187c5581491bdb07a7Yu Ke	GUEST_HANDLE(void) data;          /* Pointer to microcode data */
973e0996798a6a113efae9e0187c5581491bdb07a7Yu Ke	uint32_t length;                  /* Length of microcode data. */
983e0996798a6a113efae9e0187c5581491bdb07a7Yu Ke};
993e0996798a6a113efae9e0187c5581491bdb07a7Yu KeDEFINE_GUEST_HANDLE_STRUCT(xenpf_microcode_update_t);
1003e0996798a6a113efae9e0187c5581491bdb07a7Yu Ke
1013e0996798a6a113efae9e0187c5581491bdb07a7Yu Ke#define XENPF_platform_quirk      39
1023e0996798a6a113efae9e0187c5581491bdb07a7Yu Ke#define QUIRK_NOIRQBALANCING      1 /* Do not restrict IO-APIC RTE targets */
1033e0996798a6a113efae9e0187c5581491bdb07a7Yu Ke#define QUIRK_IOAPIC_BAD_REGSEL   2 /* IO-APIC REGSEL forgets its value    */
1043e0996798a6a113efae9e0187c5581491bdb07a7Yu Ke#define QUIRK_IOAPIC_GOOD_REGSEL  3 /* IO-APIC REGSEL behaves properly     */
1053e0996798a6a113efae9e0187c5581491bdb07a7Yu Kestruct xenpf_platform_quirk {
1063e0996798a6a113efae9e0187c5581491bdb07a7Yu Ke	/* IN variables. */
1073e0996798a6a113efae9e0187c5581491bdb07a7Yu Ke	uint32_t quirk_id;
1083e0996798a6a113efae9e0187c5581491bdb07a7Yu Ke};
1093e0996798a6a113efae9e0187c5581491bdb07a7Yu KeDEFINE_GUEST_HANDLE_STRUCT(xenpf_platform_quirk_t);
1103e0996798a6a113efae9e0187c5581491bdb07a7Yu Ke
1113e0996798a6a113efae9e0187c5581491bdb07a7Yu Ke#define XENPF_firmware_info       50
1123e0996798a6a113efae9e0187c5581491bdb07a7Yu Ke#define XEN_FW_DISK_INFO          1 /* from int 13 AH=08/41/48 */
1133e0996798a6a113efae9e0187c5581491bdb07a7Yu Ke#define XEN_FW_DISK_MBR_SIGNATURE 2 /* from MBR offset 0x1b8 */
1143e0996798a6a113efae9e0187c5581491bdb07a7Yu Ke#define XEN_FW_VBEDDC_INFO        3 /* from int 10 AX=4f15 */
1153e0996798a6a113efae9e0187c5581491bdb07a7Yu Kestruct xenpf_firmware_info {
1163e0996798a6a113efae9e0187c5581491bdb07a7Yu Ke	/* IN variables. */
1173e0996798a6a113efae9e0187c5581491bdb07a7Yu Ke	uint32_t type;
1183e0996798a6a113efae9e0187c5581491bdb07a7Yu Ke	uint32_t index;
1193e0996798a6a113efae9e0187c5581491bdb07a7Yu Ke	/* OUT variables. */
1203e0996798a6a113efae9e0187c5581491bdb07a7Yu Ke	union {
1213e0996798a6a113efae9e0187c5581491bdb07a7Yu Ke		struct {
1223e0996798a6a113efae9e0187c5581491bdb07a7Yu Ke			/* Int13, Fn48: Check Extensions Present. */
1233e0996798a6a113efae9e0187c5581491bdb07a7Yu Ke			uint8_t device;                   /* %dl: bios device number */
1243e0996798a6a113efae9e0187c5581491bdb07a7Yu Ke			uint8_t version;                  /* %ah: major version      */
1253e0996798a6a113efae9e0187c5581491bdb07a7Yu Ke			uint16_t interface_support;       /* %cx: support bitmap     */
1263e0996798a6a113efae9e0187c5581491bdb07a7Yu Ke			/* Int13, Fn08: Legacy Get Device Parameters. */
1273e0996798a6a113efae9e0187c5581491bdb07a7Yu Ke			uint16_t legacy_max_cylinder;     /* %cl[7:6]:%ch: max cyl # */
1283e0996798a6a113efae9e0187c5581491bdb07a7Yu Ke			uint8_t legacy_max_head;          /* %dh: max head #         */
1293e0996798a6a113efae9e0187c5581491bdb07a7Yu Ke			uint8_t legacy_sectors_per_track; /* %cl[5:0]: max sector #  */
1303e0996798a6a113efae9e0187c5581491bdb07a7Yu Ke			/* Int13, Fn41: Get Device Parameters (as filled into %ds:%esi). */
1313e0996798a6a113efae9e0187c5581491bdb07a7Yu Ke			/* NB. First uint16_t of buffer must be set to buffer size.      */
1323e0996798a6a113efae9e0187c5581491bdb07a7Yu Ke			GUEST_HANDLE(void) edd_params;
1333e0996798a6a113efae9e0187c5581491bdb07a7Yu Ke		} disk_info; /* XEN_FW_DISK_INFO */
1343e0996798a6a113efae9e0187c5581491bdb07a7Yu Ke		struct {
1353e0996798a6a113efae9e0187c5581491bdb07a7Yu Ke			uint8_t device;                   /* bios device number  */
1363e0996798a6a113efae9e0187c5581491bdb07a7Yu Ke			uint32_t mbr_signature;           /* offset 0x1b8 in mbr */
1373e0996798a6a113efae9e0187c5581491bdb07a7Yu Ke		} disk_mbr_signature; /* XEN_FW_DISK_MBR_SIGNATURE */
1383e0996798a6a113efae9e0187c5581491bdb07a7Yu Ke		struct {
1393e0996798a6a113efae9e0187c5581491bdb07a7Yu Ke			/* Int10, AX=4F15: Get EDID info. */
1403e0996798a6a113efae9e0187c5581491bdb07a7Yu Ke			uint8_t capabilities;
1413e0996798a6a113efae9e0187c5581491bdb07a7Yu Ke			uint8_t edid_transfer_time;
1423e0996798a6a113efae9e0187c5581491bdb07a7Yu Ke			/* must refer to 128-byte buffer */
1433e0996798a6a113efae9e0187c5581491bdb07a7Yu Ke			GUEST_HANDLE(uchar) edid;
1443e0996798a6a113efae9e0187c5581491bdb07a7Yu Ke		} vbeddc_info; /* XEN_FW_VBEDDC_INFO */
1453e0996798a6a113efae9e0187c5581491bdb07a7Yu Ke	} u;
1463e0996798a6a113efae9e0187c5581491bdb07a7Yu Ke};
1473e0996798a6a113efae9e0187c5581491bdb07a7Yu KeDEFINE_GUEST_HANDLE_STRUCT(xenpf_firmware_info_t);
1483e0996798a6a113efae9e0187c5581491bdb07a7Yu Ke
1493e0996798a6a113efae9e0187c5581491bdb07a7Yu Ke#define XENPF_enter_acpi_sleep    51
1503e0996798a6a113efae9e0187c5581491bdb07a7Yu Kestruct xenpf_enter_acpi_sleep {
1513e0996798a6a113efae9e0187c5581491bdb07a7Yu Ke	/* IN variables */
1523e0996798a6a113efae9e0187c5581491bdb07a7Yu Ke	uint16_t pm1a_cnt_val;      /* PM1a control value. */
1533e0996798a6a113efae9e0187c5581491bdb07a7Yu Ke	uint16_t pm1b_cnt_val;      /* PM1b control value. */
1543e0996798a6a113efae9e0187c5581491bdb07a7Yu Ke	uint32_t sleep_state;       /* Which state to enter (Sn). */
1553e0996798a6a113efae9e0187c5581491bdb07a7Yu Ke	uint32_t flags;             /* Must be zero. */
1563e0996798a6a113efae9e0187c5581491bdb07a7Yu Ke};
1573e0996798a6a113efae9e0187c5581491bdb07a7Yu KeDEFINE_GUEST_HANDLE_STRUCT(xenpf_enter_acpi_sleep_t);
1583e0996798a6a113efae9e0187c5581491bdb07a7Yu Ke
1593e0996798a6a113efae9e0187c5581491bdb07a7Yu Ke#define XENPF_change_freq         52
1603e0996798a6a113efae9e0187c5581491bdb07a7Yu Kestruct xenpf_change_freq {
1613e0996798a6a113efae9e0187c5581491bdb07a7Yu Ke	/* IN variables */
1623e0996798a6a113efae9e0187c5581491bdb07a7Yu Ke	uint32_t flags; /* Must be zero. */
1633e0996798a6a113efae9e0187c5581491bdb07a7Yu Ke	uint32_t cpu;   /* Physical cpu. */
1643e0996798a6a113efae9e0187c5581491bdb07a7Yu Ke	uint64_t freq;  /* New frequency (Hz). */
1653e0996798a6a113efae9e0187c5581491bdb07a7Yu Ke};
1663e0996798a6a113efae9e0187c5581491bdb07a7Yu KeDEFINE_GUEST_HANDLE_STRUCT(xenpf_change_freq_t);
1673e0996798a6a113efae9e0187c5581491bdb07a7Yu Ke
1683e0996798a6a113efae9e0187c5581491bdb07a7Yu Ke/*
1693e0996798a6a113efae9e0187c5581491bdb07a7Yu Ke * Get idle times (nanoseconds since boot) for physical CPUs specified in the
1703e0996798a6a113efae9e0187c5581491bdb07a7Yu Ke * @cpumap_bitmap with range [0..@cpumap_nr_cpus-1]. The @idletime array is
1713e0996798a6a113efae9e0187c5581491bdb07a7Yu Ke * indexed by CPU number; only entries with the corresponding @cpumap_bitmap
1723e0996798a6a113efae9e0187c5581491bdb07a7Yu Ke * bit set are written to. On return, @cpumap_bitmap is modified so that any
1733e0996798a6a113efae9e0187c5581491bdb07a7Yu Ke * non-existent CPUs are cleared. Such CPUs have their @idletime array entry
1743e0996798a6a113efae9e0187c5581491bdb07a7Yu Ke * cleared.
1753e0996798a6a113efae9e0187c5581491bdb07a7Yu Ke */
1763e0996798a6a113efae9e0187c5581491bdb07a7Yu Ke#define XENPF_getidletime         53
1773e0996798a6a113efae9e0187c5581491bdb07a7Yu Kestruct xenpf_getidletime {
1783e0996798a6a113efae9e0187c5581491bdb07a7Yu Ke	/* IN/OUT variables */
1793e0996798a6a113efae9e0187c5581491bdb07a7Yu Ke	/* IN: CPUs to interrogate; OUT: subset of IN which are present */
1803e0996798a6a113efae9e0187c5581491bdb07a7Yu Ke	GUEST_HANDLE(uchar) cpumap_bitmap;
1813e0996798a6a113efae9e0187c5581491bdb07a7Yu Ke	/* IN variables */
1823e0996798a6a113efae9e0187c5581491bdb07a7Yu Ke	/* Size of cpumap bitmap. */
1833e0996798a6a113efae9e0187c5581491bdb07a7Yu Ke	uint32_t cpumap_nr_cpus;
1843e0996798a6a113efae9e0187c5581491bdb07a7Yu Ke	/* Must be indexable for every cpu in cpumap_bitmap. */
1853e0996798a6a113efae9e0187c5581491bdb07a7Yu Ke	GUEST_HANDLE(uint64_t) idletime;
1863e0996798a6a113efae9e0187c5581491bdb07a7Yu Ke	/* OUT variables */
1873e0996798a6a113efae9e0187c5581491bdb07a7Yu Ke	/* System time when the idletime snapshots were taken. */
1883e0996798a6a113efae9e0187c5581491bdb07a7Yu Ke	uint64_t now;
1893e0996798a6a113efae9e0187c5581491bdb07a7Yu Ke};
1903e0996798a6a113efae9e0187c5581491bdb07a7Yu KeDEFINE_GUEST_HANDLE_STRUCT(xenpf_getidletime_t);
1913e0996798a6a113efae9e0187c5581491bdb07a7Yu Ke
1923e0996798a6a113efae9e0187c5581491bdb07a7Yu Ke#define XENPF_set_processor_pminfo      54
1933e0996798a6a113efae9e0187c5581491bdb07a7Yu Ke
1943e0996798a6a113efae9e0187c5581491bdb07a7Yu Ke/* ability bits */
1953e0996798a6a113efae9e0187c5581491bdb07a7Yu Ke#define XEN_PROCESSOR_PM_CX	1
1963e0996798a6a113efae9e0187c5581491bdb07a7Yu Ke#define XEN_PROCESSOR_PM_PX	2
1973e0996798a6a113efae9e0187c5581491bdb07a7Yu Ke#define XEN_PROCESSOR_PM_TX	4
1983e0996798a6a113efae9e0187c5581491bdb07a7Yu Ke
1993e0996798a6a113efae9e0187c5581491bdb07a7Yu Ke/* cmd type */
2003e0996798a6a113efae9e0187c5581491bdb07a7Yu Ke#define XEN_PM_CX   0
2013e0996798a6a113efae9e0187c5581491bdb07a7Yu Ke#define XEN_PM_PX   1
2023e0996798a6a113efae9e0187c5581491bdb07a7Yu Ke#define XEN_PM_TX   2
20373c154c60be106b47f15d1111fc2d75cc7a436f2Konrad Rzeszutek Wilk#define XEN_PM_PDC  3
2043e0996798a6a113efae9e0187c5581491bdb07a7Yu Ke/* Px sub info type */
2053e0996798a6a113efae9e0187c5581491bdb07a7Yu Ke#define XEN_PX_PCT   1
2063e0996798a6a113efae9e0187c5581491bdb07a7Yu Ke#define XEN_PX_PSS   2
2073e0996798a6a113efae9e0187c5581491bdb07a7Yu Ke#define XEN_PX_PPC   4
2083e0996798a6a113efae9e0187c5581491bdb07a7Yu Ke#define XEN_PX_PSD   8
2093e0996798a6a113efae9e0187c5581491bdb07a7Yu Ke
2103e0996798a6a113efae9e0187c5581491bdb07a7Yu Kestruct xen_power_register {
2113e0996798a6a113efae9e0187c5581491bdb07a7Yu Ke	uint32_t     space_id;
2123e0996798a6a113efae9e0187c5581491bdb07a7Yu Ke	uint32_t     bit_width;
2133e0996798a6a113efae9e0187c5581491bdb07a7Yu Ke	uint32_t     bit_offset;
2143e0996798a6a113efae9e0187c5581491bdb07a7Yu Ke	uint32_t     access_size;
2153e0996798a6a113efae9e0187c5581491bdb07a7Yu Ke	uint64_t     address;
2163e0996798a6a113efae9e0187c5581491bdb07a7Yu Ke};
2173e0996798a6a113efae9e0187c5581491bdb07a7Yu Ke
2183e0996798a6a113efae9e0187c5581491bdb07a7Yu Kestruct xen_processor_csd {
2193e0996798a6a113efae9e0187c5581491bdb07a7Yu Ke	uint32_t    domain;      /* domain number of one dependent group */
2203e0996798a6a113efae9e0187c5581491bdb07a7Yu Ke	uint32_t    coord_type;  /* coordination type */
2213e0996798a6a113efae9e0187c5581491bdb07a7Yu Ke	uint32_t    num;         /* number of processors in same domain */
2223e0996798a6a113efae9e0187c5581491bdb07a7Yu Ke};
2233e0996798a6a113efae9e0187c5581491bdb07a7Yu KeDEFINE_GUEST_HANDLE_STRUCT(xen_processor_csd);
2243e0996798a6a113efae9e0187c5581491bdb07a7Yu Ke
2253e0996798a6a113efae9e0187c5581491bdb07a7Yu Kestruct xen_processor_cx {
2263e0996798a6a113efae9e0187c5581491bdb07a7Yu Ke	struct xen_power_register  reg; /* GAS for Cx trigger register */
2273e0996798a6a113efae9e0187c5581491bdb07a7Yu Ke	uint8_t     type;     /* cstate value, c0: 0, c1: 1, ... */
2283e0996798a6a113efae9e0187c5581491bdb07a7Yu Ke	uint32_t    latency;  /* worst latency (ms) to enter/exit this cstate */
2293e0996798a6a113efae9e0187c5581491bdb07a7Yu Ke	uint32_t    power;    /* average power consumption(mW) */
2303e0996798a6a113efae9e0187c5581491bdb07a7Yu Ke	uint32_t    dpcnt;    /* number of dependency entries */
2313e0996798a6a113efae9e0187c5581491bdb07a7Yu Ke	GUEST_HANDLE(xen_processor_csd) dp; /* NULL if no dependency */
2323e0996798a6a113efae9e0187c5581491bdb07a7Yu Ke};
2333e0996798a6a113efae9e0187c5581491bdb07a7Yu KeDEFINE_GUEST_HANDLE_STRUCT(xen_processor_cx);
2343e0996798a6a113efae9e0187c5581491bdb07a7Yu Ke
2353e0996798a6a113efae9e0187c5581491bdb07a7Yu Kestruct xen_processor_flags {
2363e0996798a6a113efae9e0187c5581491bdb07a7Yu Ke	uint32_t bm_control:1;
2373e0996798a6a113efae9e0187c5581491bdb07a7Yu Ke	uint32_t bm_check:1;
2383e0996798a6a113efae9e0187c5581491bdb07a7Yu Ke	uint32_t has_cst:1;
2393e0996798a6a113efae9e0187c5581491bdb07a7Yu Ke	uint32_t power_setup_done:1;
2403e0996798a6a113efae9e0187c5581491bdb07a7Yu Ke	uint32_t bm_rld_set:1;
2413e0996798a6a113efae9e0187c5581491bdb07a7Yu Ke};
2423e0996798a6a113efae9e0187c5581491bdb07a7Yu Ke
2433e0996798a6a113efae9e0187c5581491bdb07a7Yu Kestruct xen_processor_power {
2443e0996798a6a113efae9e0187c5581491bdb07a7Yu Ke	uint32_t count;  /* number of C state entries in array below */
2453e0996798a6a113efae9e0187c5581491bdb07a7Yu Ke	struct xen_processor_flags flags;  /* global flags of this processor */
2463e0996798a6a113efae9e0187c5581491bdb07a7Yu Ke	GUEST_HANDLE(xen_processor_cx) states; /* supported c states */
2473e0996798a6a113efae9e0187c5581491bdb07a7Yu Ke};
2483e0996798a6a113efae9e0187c5581491bdb07a7Yu Ke
2493e0996798a6a113efae9e0187c5581491bdb07a7Yu Kestruct xen_pct_register {
2503e0996798a6a113efae9e0187c5581491bdb07a7Yu Ke	uint8_t  descriptor;
2513e0996798a6a113efae9e0187c5581491bdb07a7Yu Ke	uint16_t length;
2523e0996798a6a113efae9e0187c5581491bdb07a7Yu Ke	uint8_t  space_id;
2533e0996798a6a113efae9e0187c5581491bdb07a7Yu Ke	uint8_t  bit_width;
2543e0996798a6a113efae9e0187c5581491bdb07a7Yu Ke	uint8_t  bit_offset;
2553e0996798a6a113efae9e0187c5581491bdb07a7Yu Ke	uint8_t  reserved;
2563e0996798a6a113efae9e0187c5581491bdb07a7Yu Ke	uint64_t address;
2573e0996798a6a113efae9e0187c5581491bdb07a7Yu Ke};
2583e0996798a6a113efae9e0187c5581491bdb07a7Yu Ke
2593e0996798a6a113efae9e0187c5581491bdb07a7Yu Kestruct xen_processor_px {
2603e0996798a6a113efae9e0187c5581491bdb07a7Yu Ke	uint64_t core_frequency; /* megahertz */
2613e0996798a6a113efae9e0187c5581491bdb07a7Yu Ke	uint64_t power;      /* milliWatts */
2623e0996798a6a113efae9e0187c5581491bdb07a7Yu Ke	uint64_t transition_latency; /* microseconds */
2633e0996798a6a113efae9e0187c5581491bdb07a7Yu Ke	uint64_t bus_master_latency; /* microseconds */
2643e0996798a6a113efae9e0187c5581491bdb07a7Yu Ke	uint64_t control;        /* control value */
2653e0996798a6a113efae9e0187c5581491bdb07a7Yu Ke	uint64_t status;     /* success indicator */
2663e0996798a6a113efae9e0187c5581491bdb07a7Yu Ke};
2673e0996798a6a113efae9e0187c5581491bdb07a7Yu KeDEFINE_GUEST_HANDLE_STRUCT(xen_processor_px);
2683e0996798a6a113efae9e0187c5581491bdb07a7Yu Ke
2693e0996798a6a113efae9e0187c5581491bdb07a7Yu Kestruct xen_psd_package {
2703e0996798a6a113efae9e0187c5581491bdb07a7Yu Ke	uint64_t num_entries;
2713e0996798a6a113efae9e0187c5581491bdb07a7Yu Ke	uint64_t revision;
2723e0996798a6a113efae9e0187c5581491bdb07a7Yu Ke	uint64_t domain;
2733e0996798a6a113efae9e0187c5581491bdb07a7Yu Ke	uint64_t coord_type;
2743e0996798a6a113efae9e0187c5581491bdb07a7Yu Ke	uint64_t num_processors;
2753e0996798a6a113efae9e0187c5581491bdb07a7Yu Ke};
2763e0996798a6a113efae9e0187c5581491bdb07a7Yu Ke
2773e0996798a6a113efae9e0187c5581491bdb07a7Yu Kestruct xen_processor_performance {
2783e0996798a6a113efae9e0187c5581491bdb07a7Yu Ke	uint32_t flags;     /* flag for Px sub info type */
2793e0996798a6a113efae9e0187c5581491bdb07a7Yu Ke	uint32_t platform_limit;  /* Platform limitation on freq usage */
2803e0996798a6a113efae9e0187c5581491bdb07a7Yu Ke	struct xen_pct_register control_register;
2813e0996798a6a113efae9e0187c5581491bdb07a7Yu Ke	struct xen_pct_register status_register;
2823e0996798a6a113efae9e0187c5581491bdb07a7Yu Ke	uint32_t state_count;     /* total available performance states */
2833e0996798a6a113efae9e0187c5581491bdb07a7Yu Ke	GUEST_HANDLE(xen_processor_px) states;
2843e0996798a6a113efae9e0187c5581491bdb07a7Yu Ke	struct xen_psd_package domain_info;
2853e0996798a6a113efae9e0187c5581491bdb07a7Yu Ke	uint32_t shared_type;     /* coordination type of this processor */
2863e0996798a6a113efae9e0187c5581491bdb07a7Yu Ke};
2873e0996798a6a113efae9e0187c5581491bdb07a7Yu KeDEFINE_GUEST_HANDLE_STRUCT(xen_processor_performance);
2883e0996798a6a113efae9e0187c5581491bdb07a7Yu Ke
2893e0996798a6a113efae9e0187c5581491bdb07a7Yu Kestruct xenpf_set_processor_pminfo {
2903e0996798a6a113efae9e0187c5581491bdb07a7Yu Ke	/* IN variables */
2913e0996798a6a113efae9e0187c5581491bdb07a7Yu Ke	uint32_t id;    /* ACPI CPU ID */
2923e0996798a6a113efae9e0187c5581491bdb07a7Yu Ke	uint32_t type;  /* {XEN_PM_CX, XEN_PM_PX} */
2933e0996798a6a113efae9e0187c5581491bdb07a7Yu Ke	union {
2943e0996798a6a113efae9e0187c5581491bdb07a7Yu Ke		struct xen_processor_power          power;/* Cx: _CST/_CSD */
2953e0996798a6a113efae9e0187c5581491bdb07a7Yu Ke		struct xen_processor_performance    perf; /* Px: _PPC/_PCT/_PSS/_PSD */
29673c154c60be106b47f15d1111fc2d75cc7a436f2Konrad Rzeszutek Wilk		GUEST_HANDLE(uint32_t)              pdc;
2973e0996798a6a113efae9e0187c5581491bdb07a7Yu Ke	};
2983e0996798a6a113efae9e0187c5581491bdb07a7Yu Ke};
2993e0996798a6a113efae9e0187c5581491bdb07a7Yu KeDEFINE_GUEST_HANDLE_STRUCT(xenpf_set_processor_pminfo);
3003e0996798a6a113efae9e0187c5581491bdb07a7Yu Ke
30159a56802918100c1e39e68c30a2e5ae9f7d837f0Konrad Rzeszutek Wilk#define XENPF_get_cpuinfo 55
30259a56802918100c1e39e68c30a2e5ae9f7d837f0Konrad Rzeszutek Wilkstruct xenpf_pcpuinfo {
30359a56802918100c1e39e68c30a2e5ae9f7d837f0Konrad Rzeszutek Wilk	/* IN */
30459a56802918100c1e39e68c30a2e5ae9f7d837f0Konrad Rzeszutek Wilk	uint32_t xen_cpuid;
30559a56802918100c1e39e68c30a2e5ae9f7d837f0Konrad Rzeszutek Wilk	/* OUT */
30659a56802918100c1e39e68c30a2e5ae9f7d837f0Konrad Rzeszutek Wilk	/* The maxium cpu_id that is present */
30759a56802918100c1e39e68c30a2e5ae9f7d837f0Konrad Rzeszutek Wilk	uint32_t max_present;
30859a56802918100c1e39e68c30a2e5ae9f7d837f0Konrad Rzeszutek Wilk#define XEN_PCPU_FLAGS_ONLINE   1
30959a56802918100c1e39e68c30a2e5ae9f7d837f0Konrad Rzeszutek Wilk	/* Correponding xen_cpuid is not present*/
31059a56802918100c1e39e68c30a2e5ae9f7d837f0Konrad Rzeszutek Wilk#define XEN_PCPU_FLAGS_INVALID  2
31159a56802918100c1e39e68c30a2e5ae9f7d837f0Konrad Rzeszutek Wilk	uint32_t flags;
31259a56802918100c1e39e68c30a2e5ae9f7d837f0Konrad Rzeszutek Wilk	uint32_t apic_id;
31359a56802918100c1e39e68c30a2e5ae9f7d837f0Konrad Rzeszutek Wilk	uint32_t acpi_id;
31459a56802918100c1e39e68c30a2e5ae9f7d837f0Konrad Rzeszutek Wilk};
31559a56802918100c1e39e68c30a2e5ae9f7d837f0Konrad Rzeszutek WilkDEFINE_GUEST_HANDLE_STRUCT(xenpf_pcpuinfo);
31659a56802918100c1e39e68c30a2e5ae9f7d837f0Konrad Rzeszutek Wilk
3173e0996798a6a113efae9e0187c5581491bdb07a7Yu Kestruct xen_platform_op {
3183e0996798a6a113efae9e0187c5581491bdb07a7Yu Ke	uint32_t cmd;
3193e0996798a6a113efae9e0187c5581491bdb07a7Yu Ke	uint32_t interface_version; /* XENPF_INTERFACE_VERSION */
3203e0996798a6a113efae9e0187c5581491bdb07a7Yu Ke	union {
3213e0996798a6a113efae9e0187c5581491bdb07a7Yu Ke		struct xenpf_settime           settime;
3223e0996798a6a113efae9e0187c5581491bdb07a7Yu Ke		struct xenpf_add_memtype       add_memtype;
3233e0996798a6a113efae9e0187c5581491bdb07a7Yu Ke		struct xenpf_del_memtype       del_memtype;
3243e0996798a6a113efae9e0187c5581491bdb07a7Yu Ke		struct xenpf_read_memtype      read_memtype;
3253e0996798a6a113efae9e0187c5581491bdb07a7Yu Ke		struct xenpf_microcode_update  microcode;
3263e0996798a6a113efae9e0187c5581491bdb07a7Yu Ke		struct xenpf_platform_quirk    platform_quirk;
3273e0996798a6a113efae9e0187c5581491bdb07a7Yu Ke		struct xenpf_firmware_info     firmware_info;
3283e0996798a6a113efae9e0187c5581491bdb07a7Yu Ke		struct xenpf_enter_acpi_sleep  enter_acpi_sleep;
3293e0996798a6a113efae9e0187c5581491bdb07a7Yu Ke		struct xenpf_change_freq       change_freq;
3303e0996798a6a113efae9e0187c5581491bdb07a7Yu Ke		struct xenpf_getidletime       getidletime;
3313e0996798a6a113efae9e0187c5581491bdb07a7Yu Ke		struct xenpf_set_processor_pminfo set_pminfo;
33259a56802918100c1e39e68c30a2e5ae9f7d837f0Konrad Rzeszutek Wilk		struct xenpf_pcpuinfo          pcpu_info;
3333e0996798a6a113efae9e0187c5581491bdb07a7Yu Ke		uint8_t                        pad[128];
3343e0996798a6a113efae9e0187c5581491bdb07a7Yu Ke	} u;
3353e0996798a6a113efae9e0187c5581491bdb07a7Yu Ke};
3363e0996798a6a113efae9e0187c5581491bdb07a7Yu KeDEFINE_GUEST_HANDLE_STRUCT(xen_platform_op_t);
3373e0996798a6a113efae9e0187c5581491bdb07a7Yu Ke
3383e0996798a6a113efae9e0187c5581491bdb07a7Yu Ke#endif /* __XEN_PUBLIC_PLATFORM_H__ */
339