18c2ecf20Sopenharmony_ci/******************************************************************************
28c2ecf20Sopenharmony_ci * platform.h
38c2ecf20Sopenharmony_ci *
48c2ecf20Sopenharmony_ci * Hardware platform operations. Intended for use by domain-0 kernel.
58c2ecf20Sopenharmony_ci *
68c2ecf20Sopenharmony_ci * Permission is hereby granted, free of charge, to any person obtaining a copy
78c2ecf20Sopenharmony_ci * of this software and associated documentation files (the "Software"), to
88c2ecf20Sopenharmony_ci * deal in the Software without restriction, including without limitation the
98c2ecf20Sopenharmony_ci * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
108c2ecf20Sopenharmony_ci * sell copies of the Software, and to permit persons to whom the Software is
118c2ecf20Sopenharmony_ci * furnished to do so, subject to the following conditions:
128c2ecf20Sopenharmony_ci *
138c2ecf20Sopenharmony_ci * The above copyright notice and this permission notice shall be included in
148c2ecf20Sopenharmony_ci * all copies or substantial portions of the Software.
158c2ecf20Sopenharmony_ci *
168c2ecf20Sopenharmony_ci * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
178c2ecf20Sopenharmony_ci * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
188c2ecf20Sopenharmony_ci * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
198c2ecf20Sopenharmony_ci * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
208c2ecf20Sopenharmony_ci * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
218c2ecf20Sopenharmony_ci * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
228c2ecf20Sopenharmony_ci * DEALINGS IN THE SOFTWARE.
238c2ecf20Sopenharmony_ci *
248c2ecf20Sopenharmony_ci * Copyright (c) 2002-2006, K Fraser
258c2ecf20Sopenharmony_ci */
268c2ecf20Sopenharmony_ci
278c2ecf20Sopenharmony_ci#ifndef __XEN_PUBLIC_PLATFORM_H__
288c2ecf20Sopenharmony_ci#define __XEN_PUBLIC_PLATFORM_H__
298c2ecf20Sopenharmony_ci
308c2ecf20Sopenharmony_ci#include <xen/interface/xen.h>
318c2ecf20Sopenharmony_ci
328c2ecf20Sopenharmony_ci#define XENPF_INTERFACE_VERSION 0x03000001
338c2ecf20Sopenharmony_ci
348c2ecf20Sopenharmony_ci/*
358c2ecf20Sopenharmony_ci * Set clock such that it would read <secs,nsecs> after 00:00:00 UTC,
368c2ecf20Sopenharmony_ci * 1 January, 1970 if the current system time was <system_time>.
378c2ecf20Sopenharmony_ci */
388c2ecf20Sopenharmony_ci#define XENPF_settime32             17
398c2ecf20Sopenharmony_cistruct xenpf_settime32 {
408c2ecf20Sopenharmony_ci	/* IN variables. */
418c2ecf20Sopenharmony_ci	uint32_t secs;
428c2ecf20Sopenharmony_ci	uint32_t nsecs;
438c2ecf20Sopenharmony_ci	uint64_t system_time;
448c2ecf20Sopenharmony_ci};
458c2ecf20Sopenharmony_ciDEFINE_GUEST_HANDLE_STRUCT(xenpf_settime32_t);
468c2ecf20Sopenharmony_ci#define XENPF_settime64           62
478c2ecf20Sopenharmony_cistruct xenpf_settime64 {
488c2ecf20Sopenharmony_ci    /* IN variables. */
498c2ecf20Sopenharmony_ci    uint64_t secs;
508c2ecf20Sopenharmony_ci    uint32_t nsecs;
518c2ecf20Sopenharmony_ci    uint32_t mbz;
528c2ecf20Sopenharmony_ci    uint64_t system_time;
538c2ecf20Sopenharmony_ci};
548c2ecf20Sopenharmony_ciDEFINE_GUEST_HANDLE_STRUCT(xenpf_settime64_t);
558c2ecf20Sopenharmony_ci
568c2ecf20Sopenharmony_ci/*
578c2ecf20Sopenharmony_ci * Request memory range (@mfn, @mfn+@nr_mfns-1) to have type @type.
588c2ecf20Sopenharmony_ci * On x86, @type is an architecture-defined MTRR memory type.
598c2ecf20Sopenharmony_ci * On success, returns the MTRR that was used (@reg) and a handle that can
608c2ecf20Sopenharmony_ci * be passed to XENPF_DEL_MEMTYPE to accurately tear down the new setting.
618c2ecf20Sopenharmony_ci * (x86-specific).
628c2ecf20Sopenharmony_ci */
638c2ecf20Sopenharmony_ci#define XENPF_add_memtype         31
648c2ecf20Sopenharmony_cistruct xenpf_add_memtype {
658c2ecf20Sopenharmony_ci	/* IN variables. */
668c2ecf20Sopenharmony_ci	xen_pfn_t mfn;
678c2ecf20Sopenharmony_ci	uint64_t nr_mfns;
688c2ecf20Sopenharmony_ci	uint32_t type;
698c2ecf20Sopenharmony_ci	/* OUT variables. */
708c2ecf20Sopenharmony_ci	uint32_t handle;
718c2ecf20Sopenharmony_ci	uint32_t reg;
728c2ecf20Sopenharmony_ci};
738c2ecf20Sopenharmony_ciDEFINE_GUEST_HANDLE_STRUCT(xenpf_add_memtype_t);
748c2ecf20Sopenharmony_ci
758c2ecf20Sopenharmony_ci/*
768c2ecf20Sopenharmony_ci * Tear down an existing memory-range type. If @handle is remembered then it
778c2ecf20Sopenharmony_ci * should be passed in to accurately tear down the correct setting (in case
788c2ecf20Sopenharmony_ci * of overlapping memory regions with differing types). If it is not known
798c2ecf20Sopenharmony_ci * then @handle should be set to zero. In all cases @reg must be set.
808c2ecf20Sopenharmony_ci * (x86-specific).
818c2ecf20Sopenharmony_ci */
828c2ecf20Sopenharmony_ci#define XENPF_del_memtype         32
838c2ecf20Sopenharmony_cistruct xenpf_del_memtype {
848c2ecf20Sopenharmony_ci	/* IN variables. */
858c2ecf20Sopenharmony_ci	uint32_t handle;
868c2ecf20Sopenharmony_ci	uint32_t reg;
878c2ecf20Sopenharmony_ci};
888c2ecf20Sopenharmony_ciDEFINE_GUEST_HANDLE_STRUCT(xenpf_del_memtype_t);
898c2ecf20Sopenharmony_ci
908c2ecf20Sopenharmony_ci/* Read current type of an MTRR (x86-specific). */
918c2ecf20Sopenharmony_ci#define XENPF_read_memtype        33
928c2ecf20Sopenharmony_cistruct xenpf_read_memtype {
938c2ecf20Sopenharmony_ci	/* IN variables. */
948c2ecf20Sopenharmony_ci	uint32_t reg;
958c2ecf20Sopenharmony_ci	/* OUT variables. */
968c2ecf20Sopenharmony_ci	xen_pfn_t mfn;
978c2ecf20Sopenharmony_ci	uint64_t nr_mfns;
988c2ecf20Sopenharmony_ci	uint32_t type;
998c2ecf20Sopenharmony_ci};
1008c2ecf20Sopenharmony_ciDEFINE_GUEST_HANDLE_STRUCT(xenpf_read_memtype_t);
1018c2ecf20Sopenharmony_ci
1028c2ecf20Sopenharmony_ci#define XENPF_microcode_update    35
1038c2ecf20Sopenharmony_cistruct xenpf_microcode_update {
1048c2ecf20Sopenharmony_ci	/* IN variables. */
1058c2ecf20Sopenharmony_ci	GUEST_HANDLE(void) data;          /* Pointer to microcode data */
1068c2ecf20Sopenharmony_ci	uint32_t length;                  /* Length of microcode data. */
1078c2ecf20Sopenharmony_ci};
1088c2ecf20Sopenharmony_ciDEFINE_GUEST_HANDLE_STRUCT(xenpf_microcode_update_t);
1098c2ecf20Sopenharmony_ci
1108c2ecf20Sopenharmony_ci#define XENPF_platform_quirk      39
1118c2ecf20Sopenharmony_ci#define QUIRK_NOIRQBALANCING      1 /* Do not restrict IO-APIC RTE targets */
1128c2ecf20Sopenharmony_ci#define QUIRK_IOAPIC_BAD_REGSEL   2 /* IO-APIC REGSEL forgets its value    */
1138c2ecf20Sopenharmony_ci#define QUIRK_IOAPIC_GOOD_REGSEL  3 /* IO-APIC REGSEL behaves properly     */
1148c2ecf20Sopenharmony_cistruct xenpf_platform_quirk {
1158c2ecf20Sopenharmony_ci	/* IN variables. */
1168c2ecf20Sopenharmony_ci	uint32_t quirk_id;
1178c2ecf20Sopenharmony_ci};
1188c2ecf20Sopenharmony_ciDEFINE_GUEST_HANDLE_STRUCT(xenpf_platform_quirk_t);
1198c2ecf20Sopenharmony_ci
1208c2ecf20Sopenharmony_ci#define XENPF_efi_runtime_call    49
1218c2ecf20Sopenharmony_ci#define XEN_EFI_get_time                      1
1228c2ecf20Sopenharmony_ci#define XEN_EFI_set_time                      2
1238c2ecf20Sopenharmony_ci#define XEN_EFI_get_wakeup_time               3
1248c2ecf20Sopenharmony_ci#define XEN_EFI_set_wakeup_time               4
1258c2ecf20Sopenharmony_ci#define XEN_EFI_get_next_high_monotonic_count 5
1268c2ecf20Sopenharmony_ci#define XEN_EFI_get_variable                  6
1278c2ecf20Sopenharmony_ci#define XEN_EFI_set_variable                  7
1288c2ecf20Sopenharmony_ci#define XEN_EFI_get_next_variable_name        8
1298c2ecf20Sopenharmony_ci#define XEN_EFI_query_variable_info           9
1308c2ecf20Sopenharmony_ci#define XEN_EFI_query_capsule_capabilities   10
1318c2ecf20Sopenharmony_ci#define XEN_EFI_update_capsule               11
1328c2ecf20Sopenharmony_ci
1338c2ecf20Sopenharmony_cistruct xenpf_efi_runtime_call {
1348c2ecf20Sopenharmony_ci	uint32_t function;
1358c2ecf20Sopenharmony_ci	/*
1368c2ecf20Sopenharmony_ci	 * This field is generally used for per sub-function flags (defined
1378c2ecf20Sopenharmony_ci	 * below), except for the XEN_EFI_get_next_high_monotonic_count case,
1388c2ecf20Sopenharmony_ci	 * where it holds the single returned value.
1398c2ecf20Sopenharmony_ci	 */
1408c2ecf20Sopenharmony_ci	uint32_t misc;
1418c2ecf20Sopenharmony_ci	xen_ulong_t status;
1428c2ecf20Sopenharmony_ci	union {
1438c2ecf20Sopenharmony_ci#define XEN_EFI_GET_TIME_SET_CLEARS_NS 0x00000001
1448c2ecf20Sopenharmony_ci		struct {
1458c2ecf20Sopenharmony_ci			struct xenpf_efi_time {
1468c2ecf20Sopenharmony_ci				uint16_t year;
1478c2ecf20Sopenharmony_ci				uint8_t month;
1488c2ecf20Sopenharmony_ci				uint8_t day;
1498c2ecf20Sopenharmony_ci				uint8_t hour;
1508c2ecf20Sopenharmony_ci				uint8_t min;
1518c2ecf20Sopenharmony_ci				uint8_t sec;
1528c2ecf20Sopenharmony_ci				uint32_t ns;
1538c2ecf20Sopenharmony_ci				int16_t tz;
1548c2ecf20Sopenharmony_ci				uint8_t daylight;
1558c2ecf20Sopenharmony_ci			} time;
1568c2ecf20Sopenharmony_ci			uint32_t resolution;
1578c2ecf20Sopenharmony_ci			uint32_t accuracy;
1588c2ecf20Sopenharmony_ci		} get_time;
1598c2ecf20Sopenharmony_ci
1608c2ecf20Sopenharmony_ci		struct xenpf_efi_time set_time;
1618c2ecf20Sopenharmony_ci
1628c2ecf20Sopenharmony_ci#define XEN_EFI_GET_WAKEUP_TIME_ENABLED 0x00000001
1638c2ecf20Sopenharmony_ci#define XEN_EFI_GET_WAKEUP_TIME_PENDING 0x00000002
1648c2ecf20Sopenharmony_ci		struct xenpf_efi_time get_wakeup_time;
1658c2ecf20Sopenharmony_ci
1668c2ecf20Sopenharmony_ci#define XEN_EFI_SET_WAKEUP_TIME_ENABLE      0x00000001
1678c2ecf20Sopenharmony_ci#define XEN_EFI_SET_WAKEUP_TIME_ENABLE_ONLY 0x00000002
1688c2ecf20Sopenharmony_ci		struct xenpf_efi_time set_wakeup_time;
1698c2ecf20Sopenharmony_ci
1708c2ecf20Sopenharmony_ci#define XEN_EFI_VARIABLE_NON_VOLATILE       0x00000001
1718c2ecf20Sopenharmony_ci#define XEN_EFI_VARIABLE_BOOTSERVICE_ACCESS 0x00000002
1728c2ecf20Sopenharmony_ci#define XEN_EFI_VARIABLE_RUNTIME_ACCESS     0x00000004
1738c2ecf20Sopenharmony_ci		struct {
1748c2ecf20Sopenharmony_ci			GUEST_HANDLE(void) name;  /* UCS-2/UTF-16 string */
1758c2ecf20Sopenharmony_ci			xen_ulong_t size;
1768c2ecf20Sopenharmony_ci			GUEST_HANDLE(void) data;
1778c2ecf20Sopenharmony_ci			struct xenpf_efi_guid {
1788c2ecf20Sopenharmony_ci				uint32_t data1;
1798c2ecf20Sopenharmony_ci				uint16_t data2;
1808c2ecf20Sopenharmony_ci				uint16_t data3;
1818c2ecf20Sopenharmony_ci				uint8_t data4[8];
1828c2ecf20Sopenharmony_ci			} vendor_guid;
1838c2ecf20Sopenharmony_ci		} get_variable, set_variable;
1848c2ecf20Sopenharmony_ci
1858c2ecf20Sopenharmony_ci		struct {
1868c2ecf20Sopenharmony_ci			xen_ulong_t size;
1878c2ecf20Sopenharmony_ci			GUEST_HANDLE(void) name;  /* UCS-2/UTF-16 string */
1888c2ecf20Sopenharmony_ci			struct xenpf_efi_guid vendor_guid;
1898c2ecf20Sopenharmony_ci		} get_next_variable_name;
1908c2ecf20Sopenharmony_ci
1918c2ecf20Sopenharmony_ci		struct {
1928c2ecf20Sopenharmony_ci			uint32_t attr;
1938c2ecf20Sopenharmony_ci			uint64_t max_store_size;
1948c2ecf20Sopenharmony_ci			uint64_t remain_store_size;
1958c2ecf20Sopenharmony_ci			uint64_t max_size;
1968c2ecf20Sopenharmony_ci		} query_variable_info;
1978c2ecf20Sopenharmony_ci
1988c2ecf20Sopenharmony_ci		struct {
1998c2ecf20Sopenharmony_ci			GUEST_HANDLE(void) capsule_header_array;
2008c2ecf20Sopenharmony_ci			xen_ulong_t capsule_count;
2018c2ecf20Sopenharmony_ci			uint64_t max_capsule_size;
2028c2ecf20Sopenharmony_ci			uint32_t reset_type;
2038c2ecf20Sopenharmony_ci		} query_capsule_capabilities;
2048c2ecf20Sopenharmony_ci
2058c2ecf20Sopenharmony_ci		struct {
2068c2ecf20Sopenharmony_ci			GUEST_HANDLE(void) capsule_header_array;
2078c2ecf20Sopenharmony_ci			xen_ulong_t capsule_count;
2088c2ecf20Sopenharmony_ci			uint64_t sg_list; /* machine address */
2098c2ecf20Sopenharmony_ci		} update_capsule;
2108c2ecf20Sopenharmony_ci	} u;
2118c2ecf20Sopenharmony_ci};
2128c2ecf20Sopenharmony_ciDEFINE_GUEST_HANDLE_STRUCT(xenpf_efi_runtime_call);
2138c2ecf20Sopenharmony_ci
2148c2ecf20Sopenharmony_ci#define  XEN_FW_EFI_VERSION        0
2158c2ecf20Sopenharmony_ci#define  XEN_FW_EFI_CONFIG_TABLE   1
2168c2ecf20Sopenharmony_ci#define  XEN_FW_EFI_VENDOR         2
2178c2ecf20Sopenharmony_ci#define  XEN_FW_EFI_MEM_INFO       3
2188c2ecf20Sopenharmony_ci#define  XEN_FW_EFI_RT_VERSION     4
2198c2ecf20Sopenharmony_ci
2208c2ecf20Sopenharmony_ci#define XENPF_firmware_info       50
2218c2ecf20Sopenharmony_ci#define XEN_FW_DISK_INFO          1 /* from int 13 AH=08/41/48 */
2228c2ecf20Sopenharmony_ci#define XEN_FW_DISK_MBR_SIGNATURE 2 /* from MBR offset 0x1b8 */
2238c2ecf20Sopenharmony_ci#define XEN_FW_VBEDDC_INFO        3 /* from int 10 AX=4f15 */
2248c2ecf20Sopenharmony_ci#define XEN_FW_EFI_INFO           4 /* from EFI */
2258c2ecf20Sopenharmony_ci#define XEN_FW_KBD_SHIFT_FLAGS    5 /* Int16, Fn02: Get keyboard shift flags. */
2268c2ecf20Sopenharmony_ci
2278c2ecf20Sopenharmony_cistruct xenpf_firmware_info {
2288c2ecf20Sopenharmony_ci	/* IN variables. */
2298c2ecf20Sopenharmony_ci	uint32_t type;
2308c2ecf20Sopenharmony_ci	uint32_t index;
2318c2ecf20Sopenharmony_ci	/* OUT variables. */
2328c2ecf20Sopenharmony_ci	union {
2338c2ecf20Sopenharmony_ci		struct {
2348c2ecf20Sopenharmony_ci			/* Int13, Fn48: Check Extensions Present. */
2358c2ecf20Sopenharmony_ci			uint8_t device;                   /* %dl: bios device number */
2368c2ecf20Sopenharmony_ci			uint8_t version;                  /* %ah: major version      */
2378c2ecf20Sopenharmony_ci			uint16_t interface_support;       /* %cx: support bitmap     */
2388c2ecf20Sopenharmony_ci			/* Int13, Fn08: Legacy Get Device Parameters. */
2398c2ecf20Sopenharmony_ci			uint16_t legacy_max_cylinder;     /* %cl[7:6]:%ch: max cyl # */
2408c2ecf20Sopenharmony_ci			uint8_t legacy_max_head;          /* %dh: max head #         */
2418c2ecf20Sopenharmony_ci			uint8_t legacy_sectors_per_track; /* %cl[5:0]: max sector #  */
2428c2ecf20Sopenharmony_ci			/* Int13, Fn41: Get Device Parameters (as filled into %ds:%esi). */
2438c2ecf20Sopenharmony_ci			/* NB. First uint16_t of buffer must be set to buffer size.      */
2448c2ecf20Sopenharmony_ci			GUEST_HANDLE(void) edd_params;
2458c2ecf20Sopenharmony_ci		} disk_info; /* XEN_FW_DISK_INFO */
2468c2ecf20Sopenharmony_ci		struct {
2478c2ecf20Sopenharmony_ci			uint8_t device;                   /* bios device number  */
2488c2ecf20Sopenharmony_ci			uint32_t mbr_signature;           /* offset 0x1b8 in mbr */
2498c2ecf20Sopenharmony_ci		} disk_mbr_signature; /* XEN_FW_DISK_MBR_SIGNATURE */
2508c2ecf20Sopenharmony_ci		struct {
2518c2ecf20Sopenharmony_ci			/* Int10, AX=4F15: Get EDID info. */
2528c2ecf20Sopenharmony_ci			uint8_t capabilities;
2538c2ecf20Sopenharmony_ci			uint8_t edid_transfer_time;
2548c2ecf20Sopenharmony_ci			/* must refer to 128-byte buffer */
2558c2ecf20Sopenharmony_ci			GUEST_HANDLE(uchar) edid;
2568c2ecf20Sopenharmony_ci		} vbeddc_info; /* XEN_FW_VBEDDC_INFO */
2578c2ecf20Sopenharmony_ci
2588c2ecf20Sopenharmony_ci		union xenpf_efi_info {
2598c2ecf20Sopenharmony_ci			uint32_t version;
2608c2ecf20Sopenharmony_ci			struct {
2618c2ecf20Sopenharmony_ci				uint64_t addr;   /* EFI_CONFIGURATION_TABLE */
2628c2ecf20Sopenharmony_ci				uint32_t nent;
2638c2ecf20Sopenharmony_ci			} cfg;
2648c2ecf20Sopenharmony_ci			struct {
2658c2ecf20Sopenharmony_ci				uint32_t revision;
2668c2ecf20Sopenharmony_ci				uint32_t bufsz;  /* input, in bytes */
2678c2ecf20Sopenharmony_ci				GUEST_HANDLE(void) name;
2688c2ecf20Sopenharmony_ci				/* UCS-2/UTF-16 string */
2698c2ecf20Sopenharmony_ci			} vendor;
2708c2ecf20Sopenharmony_ci			struct {
2718c2ecf20Sopenharmony_ci				uint64_t addr;
2728c2ecf20Sopenharmony_ci				uint64_t size;
2738c2ecf20Sopenharmony_ci				uint64_t attr;
2748c2ecf20Sopenharmony_ci				uint32_t type;
2758c2ecf20Sopenharmony_ci			} mem;
2768c2ecf20Sopenharmony_ci		} efi_info; /* XEN_FW_EFI_INFO */
2778c2ecf20Sopenharmony_ci
2788c2ecf20Sopenharmony_ci		uint8_t kbd_shift_flags; /* XEN_FW_KBD_SHIFT_FLAGS */
2798c2ecf20Sopenharmony_ci	} u;
2808c2ecf20Sopenharmony_ci};
2818c2ecf20Sopenharmony_ciDEFINE_GUEST_HANDLE_STRUCT(xenpf_firmware_info_t);
2828c2ecf20Sopenharmony_ci
2838c2ecf20Sopenharmony_ci#define XENPF_enter_acpi_sleep    51
2848c2ecf20Sopenharmony_cistruct xenpf_enter_acpi_sleep {
2858c2ecf20Sopenharmony_ci	/* IN variables */
2868c2ecf20Sopenharmony_ci	uint16_t val_a;             /* PM1a control / sleep type A. */
2878c2ecf20Sopenharmony_ci	uint16_t val_b;             /* PM1b control / sleep type B. */
2888c2ecf20Sopenharmony_ci	uint32_t sleep_state;       /* Which state to enter (Sn). */
2898c2ecf20Sopenharmony_ci#define XENPF_ACPI_SLEEP_EXTENDED 0x00000001
2908c2ecf20Sopenharmony_ci	uint32_t flags;             /* XENPF_ACPI_SLEEP_*. */
2918c2ecf20Sopenharmony_ci};
2928c2ecf20Sopenharmony_ciDEFINE_GUEST_HANDLE_STRUCT(xenpf_enter_acpi_sleep_t);
2938c2ecf20Sopenharmony_ci
2948c2ecf20Sopenharmony_ci#define XENPF_change_freq         52
2958c2ecf20Sopenharmony_cistruct xenpf_change_freq {
2968c2ecf20Sopenharmony_ci	/* IN variables */
2978c2ecf20Sopenharmony_ci	uint32_t flags; /* Must be zero. */
2988c2ecf20Sopenharmony_ci	uint32_t cpu;   /* Physical cpu. */
2998c2ecf20Sopenharmony_ci	uint64_t freq;  /* New frequency (Hz). */
3008c2ecf20Sopenharmony_ci};
3018c2ecf20Sopenharmony_ciDEFINE_GUEST_HANDLE_STRUCT(xenpf_change_freq_t);
3028c2ecf20Sopenharmony_ci
3038c2ecf20Sopenharmony_ci/*
3048c2ecf20Sopenharmony_ci * Get idle times (nanoseconds since boot) for physical CPUs specified in the
3058c2ecf20Sopenharmony_ci * @cpumap_bitmap with range [0..@cpumap_nr_cpus-1]. The @idletime array is
3068c2ecf20Sopenharmony_ci * indexed by CPU number; only entries with the corresponding @cpumap_bitmap
3078c2ecf20Sopenharmony_ci * bit set are written to. On return, @cpumap_bitmap is modified so that any
3088c2ecf20Sopenharmony_ci * non-existent CPUs are cleared. Such CPUs have their @idletime array entry
3098c2ecf20Sopenharmony_ci * cleared.
3108c2ecf20Sopenharmony_ci */
3118c2ecf20Sopenharmony_ci#define XENPF_getidletime         53
3128c2ecf20Sopenharmony_cistruct xenpf_getidletime {
3138c2ecf20Sopenharmony_ci	/* IN/OUT variables */
3148c2ecf20Sopenharmony_ci	/* IN: CPUs to interrogate; OUT: subset of IN which are present */
3158c2ecf20Sopenharmony_ci	GUEST_HANDLE(uchar) cpumap_bitmap;
3168c2ecf20Sopenharmony_ci	/* IN variables */
3178c2ecf20Sopenharmony_ci	/* Size of cpumap bitmap. */
3188c2ecf20Sopenharmony_ci	uint32_t cpumap_nr_cpus;
3198c2ecf20Sopenharmony_ci	/* Must be indexable for every cpu in cpumap_bitmap. */
3208c2ecf20Sopenharmony_ci	GUEST_HANDLE(uint64_t) idletime;
3218c2ecf20Sopenharmony_ci	/* OUT variables */
3228c2ecf20Sopenharmony_ci	/* System time when the idletime snapshots were taken. */
3238c2ecf20Sopenharmony_ci	uint64_t now;
3248c2ecf20Sopenharmony_ci};
3258c2ecf20Sopenharmony_ciDEFINE_GUEST_HANDLE_STRUCT(xenpf_getidletime_t);
3268c2ecf20Sopenharmony_ci
3278c2ecf20Sopenharmony_ci#define XENPF_set_processor_pminfo      54
3288c2ecf20Sopenharmony_ci
3298c2ecf20Sopenharmony_ci/* ability bits */
3308c2ecf20Sopenharmony_ci#define XEN_PROCESSOR_PM_CX	1
3318c2ecf20Sopenharmony_ci#define XEN_PROCESSOR_PM_PX	2
3328c2ecf20Sopenharmony_ci#define XEN_PROCESSOR_PM_TX	4
3338c2ecf20Sopenharmony_ci
3348c2ecf20Sopenharmony_ci/* cmd type */
3358c2ecf20Sopenharmony_ci#define XEN_PM_CX   0
3368c2ecf20Sopenharmony_ci#define XEN_PM_PX   1
3378c2ecf20Sopenharmony_ci#define XEN_PM_TX   2
3388c2ecf20Sopenharmony_ci#define XEN_PM_PDC  3
3398c2ecf20Sopenharmony_ci/* Px sub info type */
3408c2ecf20Sopenharmony_ci#define XEN_PX_PCT   1
3418c2ecf20Sopenharmony_ci#define XEN_PX_PSS   2
3428c2ecf20Sopenharmony_ci#define XEN_PX_PPC   4
3438c2ecf20Sopenharmony_ci#define XEN_PX_PSD   8
3448c2ecf20Sopenharmony_ci
3458c2ecf20Sopenharmony_cistruct xen_power_register {
3468c2ecf20Sopenharmony_ci	uint32_t     space_id;
3478c2ecf20Sopenharmony_ci	uint32_t     bit_width;
3488c2ecf20Sopenharmony_ci	uint32_t     bit_offset;
3498c2ecf20Sopenharmony_ci	uint32_t     access_size;
3508c2ecf20Sopenharmony_ci	uint64_t     address;
3518c2ecf20Sopenharmony_ci};
3528c2ecf20Sopenharmony_ci
3538c2ecf20Sopenharmony_cistruct xen_processor_csd {
3548c2ecf20Sopenharmony_ci	uint32_t    domain;      /* domain number of one dependent group */
3558c2ecf20Sopenharmony_ci	uint32_t    coord_type;  /* coordination type */
3568c2ecf20Sopenharmony_ci	uint32_t    num;         /* number of processors in same domain */
3578c2ecf20Sopenharmony_ci};
3588c2ecf20Sopenharmony_ciDEFINE_GUEST_HANDLE_STRUCT(xen_processor_csd);
3598c2ecf20Sopenharmony_ci
3608c2ecf20Sopenharmony_cistruct xen_processor_cx {
3618c2ecf20Sopenharmony_ci	struct xen_power_register  reg; /* GAS for Cx trigger register */
3628c2ecf20Sopenharmony_ci	uint8_t     type;     /* cstate value, c0: 0, c1: 1, ... */
3638c2ecf20Sopenharmony_ci	uint32_t    latency;  /* worst latency (ms) to enter/exit this cstate */
3648c2ecf20Sopenharmony_ci	uint32_t    power;    /* average power consumption(mW) */
3658c2ecf20Sopenharmony_ci	uint32_t    dpcnt;    /* number of dependency entries */
3668c2ecf20Sopenharmony_ci	GUEST_HANDLE(xen_processor_csd) dp; /* NULL if no dependency */
3678c2ecf20Sopenharmony_ci};
3688c2ecf20Sopenharmony_ciDEFINE_GUEST_HANDLE_STRUCT(xen_processor_cx);
3698c2ecf20Sopenharmony_ci
3708c2ecf20Sopenharmony_cistruct xen_processor_flags {
3718c2ecf20Sopenharmony_ci	uint32_t bm_control:1;
3728c2ecf20Sopenharmony_ci	uint32_t bm_check:1;
3738c2ecf20Sopenharmony_ci	uint32_t has_cst:1;
3748c2ecf20Sopenharmony_ci	uint32_t power_setup_done:1;
3758c2ecf20Sopenharmony_ci	uint32_t bm_rld_set:1;
3768c2ecf20Sopenharmony_ci};
3778c2ecf20Sopenharmony_ci
3788c2ecf20Sopenharmony_cistruct xen_processor_power {
3798c2ecf20Sopenharmony_ci	uint32_t count;  /* number of C state entries in array below */
3808c2ecf20Sopenharmony_ci	struct xen_processor_flags flags;  /* global flags of this processor */
3818c2ecf20Sopenharmony_ci	GUEST_HANDLE(xen_processor_cx) states; /* supported c states */
3828c2ecf20Sopenharmony_ci};
3838c2ecf20Sopenharmony_ci
3848c2ecf20Sopenharmony_cistruct xen_pct_register {
3858c2ecf20Sopenharmony_ci	uint8_t  descriptor;
3868c2ecf20Sopenharmony_ci	uint16_t length;
3878c2ecf20Sopenharmony_ci	uint8_t  space_id;
3888c2ecf20Sopenharmony_ci	uint8_t  bit_width;
3898c2ecf20Sopenharmony_ci	uint8_t  bit_offset;
3908c2ecf20Sopenharmony_ci	uint8_t  reserved;
3918c2ecf20Sopenharmony_ci	uint64_t address;
3928c2ecf20Sopenharmony_ci};
3938c2ecf20Sopenharmony_ci
3948c2ecf20Sopenharmony_cistruct xen_processor_px {
3958c2ecf20Sopenharmony_ci	uint64_t core_frequency; /* megahertz */
3968c2ecf20Sopenharmony_ci	uint64_t power;      /* milliWatts */
3978c2ecf20Sopenharmony_ci	uint64_t transition_latency; /* microseconds */
3988c2ecf20Sopenharmony_ci	uint64_t bus_master_latency; /* microseconds */
3998c2ecf20Sopenharmony_ci	uint64_t control;        /* control value */
4008c2ecf20Sopenharmony_ci	uint64_t status;     /* success indicator */
4018c2ecf20Sopenharmony_ci};
4028c2ecf20Sopenharmony_ciDEFINE_GUEST_HANDLE_STRUCT(xen_processor_px);
4038c2ecf20Sopenharmony_ci
4048c2ecf20Sopenharmony_cistruct xen_psd_package {
4058c2ecf20Sopenharmony_ci	uint64_t num_entries;
4068c2ecf20Sopenharmony_ci	uint64_t revision;
4078c2ecf20Sopenharmony_ci	uint64_t domain;
4088c2ecf20Sopenharmony_ci	uint64_t coord_type;
4098c2ecf20Sopenharmony_ci	uint64_t num_processors;
4108c2ecf20Sopenharmony_ci};
4118c2ecf20Sopenharmony_ci
4128c2ecf20Sopenharmony_cistruct xen_processor_performance {
4138c2ecf20Sopenharmony_ci	uint32_t flags;     /* flag for Px sub info type */
4148c2ecf20Sopenharmony_ci	uint32_t platform_limit;  /* Platform limitation on freq usage */
4158c2ecf20Sopenharmony_ci	struct xen_pct_register control_register;
4168c2ecf20Sopenharmony_ci	struct xen_pct_register status_register;
4178c2ecf20Sopenharmony_ci	uint32_t state_count;     /* total available performance states */
4188c2ecf20Sopenharmony_ci	GUEST_HANDLE(xen_processor_px) states;
4198c2ecf20Sopenharmony_ci	struct xen_psd_package domain_info;
4208c2ecf20Sopenharmony_ci	uint32_t shared_type;     /* coordination type of this processor */
4218c2ecf20Sopenharmony_ci};
4228c2ecf20Sopenharmony_ciDEFINE_GUEST_HANDLE_STRUCT(xen_processor_performance);
4238c2ecf20Sopenharmony_ci
4248c2ecf20Sopenharmony_cistruct xenpf_set_processor_pminfo {
4258c2ecf20Sopenharmony_ci	/* IN variables */
4268c2ecf20Sopenharmony_ci	uint32_t id;    /* ACPI CPU ID */
4278c2ecf20Sopenharmony_ci	uint32_t type;  /* {XEN_PM_CX, XEN_PM_PX} */
4288c2ecf20Sopenharmony_ci	union {
4298c2ecf20Sopenharmony_ci		struct xen_processor_power          power;/* Cx: _CST/_CSD */
4308c2ecf20Sopenharmony_ci		struct xen_processor_performance    perf; /* Px: _PPC/_PCT/_PSS/_PSD */
4318c2ecf20Sopenharmony_ci		GUEST_HANDLE(uint32_t)              pdc;
4328c2ecf20Sopenharmony_ci	};
4338c2ecf20Sopenharmony_ci};
4348c2ecf20Sopenharmony_ciDEFINE_GUEST_HANDLE_STRUCT(xenpf_set_processor_pminfo);
4358c2ecf20Sopenharmony_ci
4368c2ecf20Sopenharmony_ci#define XENPF_get_cpuinfo 55
4378c2ecf20Sopenharmony_cistruct xenpf_pcpuinfo {
4388c2ecf20Sopenharmony_ci	/* IN */
4398c2ecf20Sopenharmony_ci	uint32_t xen_cpuid;
4408c2ecf20Sopenharmony_ci	/* OUT */
4418c2ecf20Sopenharmony_ci	/* The maxium cpu_id that is present */
4428c2ecf20Sopenharmony_ci	uint32_t max_present;
4438c2ecf20Sopenharmony_ci#define XEN_PCPU_FLAGS_ONLINE   1
4448c2ecf20Sopenharmony_ci	/* Correponding xen_cpuid is not present*/
4458c2ecf20Sopenharmony_ci#define XEN_PCPU_FLAGS_INVALID  2
4468c2ecf20Sopenharmony_ci	uint32_t flags;
4478c2ecf20Sopenharmony_ci	uint32_t apic_id;
4488c2ecf20Sopenharmony_ci	uint32_t acpi_id;
4498c2ecf20Sopenharmony_ci};
4508c2ecf20Sopenharmony_ciDEFINE_GUEST_HANDLE_STRUCT(xenpf_pcpuinfo);
4518c2ecf20Sopenharmony_ci
4528c2ecf20Sopenharmony_ci#define XENPF_cpu_online	56
4538c2ecf20Sopenharmony_ci#define XENPF_cpu_offline	57
4548c2ecf20Sopenharmony_cistruct xenpf_cpu_ol {
4558c2ecf20Sopenharmony_ci	uint32_t cpuid;
4568c2ecf20Sopenharmony_ci};
4578c2ecf20Sopenharmony_ciDEFINE_GUEST_HANDLE_STRUCT(xenpf_cpu_ol);
4588c2ecf20Sopenharmony_ci
4598c2ecf20Sopenharmony_ci#define XENPF_cpu_hotadd	58
4608c2ecf20Sopenharmony_cistruct xenpf_cpu_hotadd {
4618c2ecf20Sopenharmony_ci	uint32_t apic_id;
4628c2ecf20Sopenharmony_ci	uint32_t acpi_id;
4638c2ecf20Sopenharmony_ci	uint32_t pxm;
4648c2ecf20Sopenharmony_ci};
4658c2ecf20Sopenharmony_ci
4668c2ecf20Sopenharmony_ci#define XENPF_mem_hotadd	59
4678c2ecf20Sopenharmony_cistruct xenpf_mem_hotadd {
4688c2ecf20Sopenharmony_ci	uint64_t spfn;
4698c2ecf20Sopenharmony_ci	uint64_t epfn;
4708c2ecf20Sopenharmony_ci	uint32_t pxm;
4718c2ecf20Sopenharmony_ci	uint32_t flags;
4728c2ecf20Sopenharmony_ci};
4738c2ecf20Sopenharmony_ci
4748c2ecf20Sopenharmony_ci#define XENPF_core_parking     60
4758c2ecf20Sopenharmony_cistruct xenpf_core_parking {
4768c2ecf20Sopenharmony_ci	/* IN variables */
4778c2ecf20Sopenharmony_ci#define XEN_CORE_PARKING_SET   1
4788c2ecf20Sopenharmony_ci#define XEN_CORE_PARKING_GET   2
4798c2ecf20Sopenharmony_ci	uint32_t type;
4808c2ecf20Sopenharmony_ci	/* IN variables:  set cpu nums expected to be idled */
4818c2ecf20Sopenharmony_ci	/* OUT variables: get cpu nums actually be idled */
4828c2ecf20Sopenharmony_ci	uint32_t idle_nums;
4838c2ecf20Sopenharmony_ci};
4848c2ecf20Sopenharmony_ciDEFINE_GUEST_HANDLE_STRUCT(xenpf_core_parking);
4858c2ecf20Sopenharmony_ci
4868c2ecf20Sopenharmony_ci#define XENPF_get_symbol      63
4878c2ecf20Sopenharmony_cistruct xenpf_symdata {
4888c2ecf20Sopenharmony_ci	/* IN/OUT variables */
4898c2ecf20Sopenharmony_ci	uint32_t	namelen; /* size of 'name' buffer */
4908c2ecf20Sopenharmony_ci
4918c2ecf20Sopenharmony_ci	/* IN/OUT variables */
4928c2ecf20Sopenharmony_ci	uint32_t	symnum; /* IN:  Symbol to read                       */
4938c2ecf20Sopenharmony_ci				/* OUT: Next available symbol. If same as IN */
4948c2ecf20Sopenharmony_ci				/* then  we reached the end                  */
4958c2ecf20Sopenharmony_ci
4968c2ecf20Sopenharmony_ci	/* OUT variables */
4978c2ecf20Sopenharmony_ci	GUEST_HANDLE(char) name;
4988c2ecf20Sopenharmony_ci	uint64_t	address;
4998c2ecf20Sopenharmony_ci	char            type;
5008c2ecf20Sopenharmony_ci};
5018c2ecf20Sopenharmony_ciDEFINE_GUEST_HANDLE_STRUCT(xenpf_symdata);
5028c2ecf20Sopenharmony_ci
5038c2ecf20Sopenharmony_cistruct xen_platform_op {
5048c2ecf20Sopenharmony_ci	uint32_t cmd;
5058c2ecf20Sopenharmony_ci	uint32_t interface_version; /* XENPF_INTERFACE_VERSION */
5068c2ecf20Sopenharmony_ci	union {
5078c2ecf20Sopenharmony_ci		struct xenpf_settime32         settime32;
5088c2ecf20Sopenharmony_ci		struct xenpf_settime64         settime64;
5098c2ecf20Sopenharmony_ci		struct xenpf_add_memtype       add_memtype;
5108c2ecf20Sopenharmony_ci		struct xenpf_del_memtype       del_memtype;
5118c2ecf20Sopenharmony_ci		struct xenpf_read_memtype      read_memtype;
5128c2ecf20Sopenharmony_ci		struct xenpf_microcode_update  microcode;
5138c2ecf20Sopenharmony_ci		struct xenpf_platform_quirk    platform_quirk;
5148c2ecf20Sopenharmony_ci		struct xenpf_efi_runtime_call  efi_runtime_call;
5158c2ecf20Sopenharmony_ci		struct xenpf_firmware_info     firmware_info;
5168c2ecf20Sopenharmony_ci		struct xenpf_enter_acpi_sleep  enter_acpi_sleep;
5178c2ecf20Sopenharmony_ci		struct xenpf_change_freq       change_freq;
5188c2ecf20Sopenharmony_ci		struct xenpf_getidletime       getidletime;
5198c2ecf20Sopenharmony_ci		struct xenpf_set_processor_pminfo set_pminfo;
5208c2ecf20Sopenharmony_ci		struct xenpf_pcpuinfo          pcpu_info;
5218c2ecf20Sopenharmony_ci		struct xenpf_cpu_ol            cpu_ol;
5228c2ecf20Sopenharmony_ci		struct xenpf_cpu_hotadd        cpu_add;
5238c2ecf20Sopenharmony_ci		struct xenpf_mem_hotadd        mem_add;
5248c2ecf20Sopenharmony_ci		struct xenpf_core_parking      core_parking;
5258c2ecf20Sopenharmony_ci		struct xenpf_symdata           symdata;
5268c2ecf20Sopenharmony_ci		uint8_t                        pad[128];
5278c2ecf20Sopenharmony_ci	} u;
5288c2ecf20Sopenharmony_ci};
5298c2ecf20Sopenharmony_ciDEFINE_GUEST_HANDLE_STRUCT(xen_platform_op_t);
5308c2ecf20Sopenharmony_ci
5318c2ecf20Sopenharmony_ci#endif /* __XEN_PUBLIC_PLATFORM_H__ */
532