Home | History | Annotate | Line # | Download | only in public
      1  1.1  cherry /******************************************************************************
      2  1.1  cherry  * platform.h
      3  1.1  cherry  *
      4  1.1  cherry  * Hardware platform operations. Intended for use by domain-0 kernel.
      5  1.1  cherry  *
      6  1.1  cherry  * Permission is hereby granted, free of charge, to any person obtaining a copy
      7  1.1  cherry  * of this software and associated documentation files (the "Software"), to
      8  1.1  cherry  * deal in the Software without restriction, including without limitation the
      9  1.1  cherry  * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
     10  1.1  cherry  * sell copies of the Software, and to permit persons to whom the Software is
     11  1.1  cherry  * furnished to do so, subject to the following conditions:
     12  1.1  cherry  *
     13  1.1  cherry  * The above copyright notice and this permission notice shall be included in
     14  1.1  cherry  * all copies or substantial portions of the Software.
     15  1.1  cherry  *
     16  1.1  cherry  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
     17  1.1  cherry  * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
     18  1.1  cherry  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
     19  1.1  cherry  * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
     20  1.1  cherry  * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
     21  1.1  cherry  * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
     22  1.1  cherry  * DEALINGS IN THE SOFTWARE.
     23  1.1  cherry  *
     24  1.1  cherry  * Copyright (c) 2002-2006, K Fraser
     25  1.1  cherry  */
     26  1.1  cherry 
     27  1.1  cherry #ifndef __XEN_PUBLIC_PLATFORM_H__
     28  1.1  cherry #define __XEN_PUBLIC_PLATFORM_H__
     29  1.1  cherry 
     30  1.1  cherry #include "xen.h"
     31  1.1  cherry 
     32  1.1  cherry #define XENPF_INTERFACE_VERSION 0x03000001
     33  1.1  cherry 
     34  1.1  cherry /*
     35  1.1  cherry  * Set clock such that it would read <secs,nsecs> after 00:00:00 UTC,
     36  1.1  cherry  * 1 January, 1970 if the current system time was <system_time>.
     37  1.1  cherry  */
     38  1.1  cherry #define XENPF_settime32           17
     39  1.1  cherry struct xenpf_settime32 {
     40  1.1  cherry     /* IN variables. */
     41  1.1  cherry     uint32_t secs;
     42  1.1  cherry     uint32_t nsecs;
     43  1.1  cherry     uint64_t system_time;
     44  1.1  cherry };
     45  1.1  cherry #define XENPF_settime64           62
     46  1.1  cherry struct xenpf_settime64 {
     47  1.1  cherry     /* IN variables. */
     48  1.1  cherry     uint64_t secs;
     49  1.1  cherry     uint32_t nsecs;
     50  1.1  cherry     uint32_t mbz;
     51  1.1  cherry     uint64_t system_time;
     52  1.1  cherry };
     53  1.1  cherry #if __XEN_INTERFACE_VERSION__ < 0x00040600
     54  1.1  cherry #define XENPF_settime XENPF_settime32
     55  1.1  cherry #define xenpf_settime xenpf_settime32
     56  1.1  cherry #else
     57  1.1  cherry #define XENPF_settime XENPF_settime64
     58  1.1  cherry #define xenpf_settime xenpf_settime64
     59  1.1  cherry #endif
     60  1.1  cherry typedef struct xenpf_settime xenpf_settime_t;
     61  1.1  cherry DEFINE_XEN_GUEST_HANDLE(xenpf_settime_t);
     62  1.1  cherry 
     63  1.1  cherry /*
     64  1.1  cherry  * Request memory range (@mfn, @mfn+@nr_mfns-1) to have type @type.
     65  1.1  cherry  * On x86, @type is an architecture-defined MTRR memory type.
     66  1.1  cherry  * On success, returns the MTRR that was used (@reg) and a handle that can
     67  1.1  cherry  * be passed to XENPF_DEL_MEMTYPE to accurately tear down the new setting.
     68  1.1  cherry  * (x86-specific).
     69  1.1  cherry  */
     70  1.1  cherry #define XENPF_add_memtype         31
     71  1.1  cherry struct xenpf_add_memtype {
     72  1.1  cherry     /* IN variables. */
     73  1.1  cherry     xen_pfn_t mfn;
     74  1.1  cherry     uint64_t nr_mfns;
     75  1.1  cherry     uint32_t type;
     76  1.1  cherry     /* OUT variables. */
     77  1.1  cherry     uint32_t handle;
     78  1.1  cherry     uint32_t reg;
     79  1.1  cherry };
     80  1.1  cherry typedef struct xenpf_add_memtype xenpf_add_memtype_t;
     81  1.1  cherry DEFINE_XEN_GUEST_HANDLE(xenpf_add_memtype_t);
     82  1.1  cherry 
     83  1.1  cherry /*
     84  1.1  cherry  * Tear down an existing memory-range type. If @handle is remembered then it
     85  1.1  cherry  * should be passed in to accurately tear down the correct setting (in case
     86  1.1  cherry  * of overlapping memory regions with differing types). If it is not known
     87  1.1  cherry  * then @handle should be set to zero. In all cases @reg must be set.
     88  1.1  cherry  * (x86-specific).
     89  1.1  cherry  */
     90  1.1  cherry #define XENPF_del_memtype         32
     91  1.1  cherry struct xenpf_del_memtype {
     92  1.1  cherry     /* IN variables. */
     93  1.1  cherry     uint32_t handle;
     94  1.1  cherry     uint32_t reg;
     95  1.1  cherry };
     96  1.1  cherry typedef struct xenpf_del_memtype xenpf_del_memtype_t;
     97  1.1  cherry DEFINE_XEN_GUEST_HANDLE(xenpf_del_memtype_t);
     98  1.1  cherry 
     99  1.1  cherry /* Read current type of an MTRR (x86-specific). */
    100  1.1  cherry #define XENPF_read_memtype        33
    101  1.1  cherry struct xenpf_read_memtype {
    102  1.1  cherry     /* IN variables. */
    103  1.1  cherry     uint32_t reg;
    104  1.1  cherry     /* OUT variables. */
    105  1.1  cherry     xen_pfn_t mfn;
    106  1.1  cherry     uint64_t nr_mfns;
    107  1.1  cherry     uint32_t type;
    108  1.1  cherry };
    109  1.1  cherry typedef struct xenpf_read_memtype xenpf_read_memtype_t;
    110  1.1  cherry DEFINE_XEN_GUEST_HANDLE(xenpf_read_memtype_t);
    111  1.1  cherry 
    112  1.1  cherry #define XENPF_microcode_update    35
    113  1.1  cherry struct xenpf_microcode_update {
    114  1.1  cherry     /* IN variables. */
    115  1.1  cherry     XEN_GUEST_HANDLE(const_void) data;/* Pointer to microcode data */
    116  1.1  cherry     uint32_t length;                  /* Length of microcode data. */
    117  1.1  cherry };
    118  1.1  cherry typedef struct xenpf_microcode_update xenpf_microcode_update_t;
    119  1.1  cherry DEFINE_XEN_GUEST_HANDLE(xenpf_microcode_update_t);
    120  1.1  cherry 
    121  1.1  cherry #define XENPF_platform_quirk      39
    122  1.1  cherry #define QUIRK_NOIRQBALANCING      1 /* Do not restrict IO-APIC RTE targets */
    123  1.1  cherry #define QUIRK_IOAPIC_BAD_REGSEL   2 /* IO-APIC REGSEL forgets its value    */
    124  1.1  cherry #define QUIRK_IOAPIC_GOOD_REGSEL  3 /* IO-APIC REGSEL behaves properly     */
    125  1.1  cherry struct xenpf_platform_quirk {
    126  1.1  cherry     /* IN variables. */
    127  1.1  cherry     uint32_t quirk_id;
    128  1.1  cherry };
    129  1.1  cherry typedef struct xenpf_platform_quirk xenpf_platform_quirk_t;
    130  1.1  cherry DEFINE_XEN_GUEST_HANDLE(xenpf_platform_quirk_t);
    131  1.1  cherry 
    132  1.1  cherry #define XENPF_efi_runtime_call    49
    133  1.1  cherry #define XEN_EFI_get_time                      1
    134  1.1  cherry #define XEN_EFI_set_time                      2
    135  1.1  cherry #define XEN_EFI_get_wakeup_time               3
    136  1.1  cherry #define XEN_EFI_set_wakeup_time               4
    137  1.1  cherry #define XEN_EFI_get_next_high_monotonic_count 5
    138  1.1  cherry #define XEN_EFI_get_variable                  6
    139  1.1  cherry #define XEN_EFI_set_variable                  7
    140  1.1  cherry #define XEN_EFI_get_next_variable_name        8
    141  1.1  cherry #define XEN_EFI_query_variable_info           9
    142  1.1  cherry #define XEN_EFI_query_capsule_capabilities   10
    143  1.1  cherry #define XEN_EFI_update_capsule               11
    144  1.1  cherry 
    145  1.1  cherry struct xenpf_efi_time {
    146  1.1  cherry     uint16_t year;
    147  1.1  cherry     uint8_t month;
    148  1.1  cherry     uint8_t day;
    149  1.1  cherry     uint8_t hour;
    150  1.1  cherry     uint8_t min;
    151  1.1  cherry     uint8_t sec;
    152  1.1  cherry     uint32_t ns;
    153  1.1  cherry     int16_t tz;
    154  1.1  cherry     uint8_t daylight;
    155  1.1  cherry };
    156  1.1  cherry 
    157  1.1  cherry struct xenpf_efi_guid {
    158  1.1  cherry     uint32_t data1;
    159  1.1  cherry     uint16_t data2;
    160  1.1  cherry     uint16_t data3;
    161  1.1  cherry     uint8_t data4[8];
    162  1.1  cherry };
    163  1.1  cherry 
    164  1.1  cherry struct xenpf_efi_runtime_call {
    165  1.1  cherry     uint32_t function;
    166  1.1  cherry     /*
    167  1.1  cherry      * This field is generally used for per sub-function flags (defined
    168  1.1  cherry      * below), except for the XEN_EFI_get_next_high_monotonic_count case,
    169  1.1  cherry      * where it holds the single returned value.
    170  1.1  cherry      */
    171  1.1  cherry     uint32_t misc;
    172  1.1  cherry     xen_ulong_t status;
    173  1.1  cherry     union {
    174  1.1  cherry #define XEN_EFI_GET_TIME_SET_CLEARS_NS 0x00000001
    175  1.1  cherry         struct {
    176  1.1  cherry             struct xenpf_efi_time time;
    177  1.1  cherry             uint32_t resolution;
    178  1.1  cherry             uint32_t accuracy;
    179  1.1  cherry         } get_time;
    180  1.1  cherry 
    181  1.1  cherry         struct xenpf_efi_time set_time;
    182  1.1  cherry 
    183  1.1  cherry #define XEN_EFI_GET_WAKEUP_TIME_ENABLED 0x00000001
    184  1.1  cherry #define XEN_EFI_GET_WAKEUP_TIME_PENDING 0x00000002
    185  1.1  cherry         struct xenpf_efi_time get_wakeup_time;
    186  1.1  cherry 
    187  1.1  cherry #define XEN_EFI_SET_WAKEUP_TIME_ENABLE      0x00000001
    188  1.1  cherry #define XEN_EFI_SET_WAKEUP_TIME_ENABLE_ONLY 0x00000002
    189  1.1  cherry         struct xenpf_efi_time set_wakeup_time;
    190  1.1  cherry 
    191  1.1  cherry #define XEN_EFI_VARIABLE_NON_VOLATILE       0x00000001
    192  1.1  cherry #define XEN_EFI_VARIABLE_BOOTSERVICE_ACCESS 0x00000002
    193  1.1  cherry #define XEN_EFI_VARIABLE_RUNTIME_ACCESS     0x00000004
    194  1.1  cherry         struct {
    195  1.1  cherry             XEN_GUEST_HANDLE(void) name;  /* UCS-2/UTF-16 string */
    196  1.1  cherry             xen_ulong_t size;
    197  1.1  cherry             XEN_GUEST_HANDLE(void) data;
    198  1.1  cherry             struct xenpf_efi_guid vendor_guid;
    199  1.1  cherry         } get_variable, set_variable;
    200  1.1  cherry 
    201  1.1  cherry         struct {
    202  1.1  cherry             xen_ulong_t size;
    203  1.1  cherry             XEN_GUEST_HANDLE(void) name;  /* UCS-2/UTF-16 string */
    204  1.1  cherry             struct xenpf_efi_guid vendor_guid;
    205  1.1  cherry         } get_next_variable_name;
    206  1.1  cherry 
    207  1.1  cherry #define XEN_EFI_VARINFO_BOOT_SNAPSHOT       0x00000001
    208  1.1  cherry         struct {
    209  1.1  cherry             uint32_t attr;
    210  1.1  cherry             uint64_t max_store_size;
    211  1.1  cherry             uint64_t remain_store_size;
    212  1.1  cherry             uint64_t max_size;
    213  1.1  cherry         } query_variable_info;
    214  1.1  cherry 
    215  1.1  cherry         struct {
    216  1.1  cherry             XEN_GUEST_HANDLE(void) capsule_header_array;
    217  1.1  cherry             xen_ulong_t capsule_count;
    218  1.1  cherry             uint64_t max_capsule_size;
    219  1.1  cherry             uint32_t reset_type;
    220  1.1  cherry         } query_capsule_capabilities;
    221  1.1  cherry 
    222  1.1  cherry         struct {
    223  1.1  cherry             XEN_GUEST_HANDLE(void) capsule_header_array;
    224  1.1  cherry             xen_ulong_t capsule_count;
    225  1.1  cherry             uint64_t sg_list; /* machine address */
    226  1.1  cherry         } update_capsule;
    227  1.1  cherry     } u;
    228  1.1  cherry };
    229  1.1  cherry typedef struct xenpf_efi_runtime_call xenpf_efi_runtime_call_t;
    230  1.1  cherry DEFINE_XEN_GUEST_HANDLE(xenpf_efi_runtime_call_t);
    231  1.1  cherry 
    232  1.1  cherry #define XENPF_firmware_info       50
    233  1.1  cherry #define XEN_FW_DISK_INFO          1 /* from int 13 AH=08/41/48 */
    234  1.1  cherry #define XEN_FW_DISK_MBR_SIGNATURE 2 /* from MBR offset 0x1b8 */
    235  1.1  cherry #define XEN_FW_VBEDDC_INFO        3 /* from int 10 AX=4f15 */
    236  1.1  cherry #define XEN_FW_EFI_INFO           4 /* from EFI */
    237  1.1  cherry #define  XEN_FW_EFI_VERSION        0
    238  1.1  cherry #define  XEN_FW_EFI_CONFIG_TABLE   1
    239  1.1  cherry #define  XEN_FW_EFI_VENDOR         2
    240  1.1  cherry #define  XEN_FW_EFI_MEM_INFO       3
    241  1.1  cherry #define  XEN_FW_EFI_RT_VERSION     4
    242  1.1  cherry #define  XEN_FW_EFI_PCI_ROM        5
    243  1.1  cherry #define  XEN_FW_EFI_APPLE_PROPERTIES 6
    244  1.1  cherry #define XEN_FW_KBD_SHIFT_FLAGS    5
    245  1.1  cherry struct xenpf_firmware_info {
    246  1.1  cherry     /* IN variables. */
    247  1.1  cherry     uint32_t type;
    248  1.1  cherry     uint32_t index;
    249  1.1  cherry     /* OUT variables. */
    250  1.1  cherry     union {
    251  1.1  cherry         struct {
    252  1.1  cherry             /* Int13, Fn48: Check Extensions Present. */
    253  1.1  cherry             uint8_t device;                   /* %dl: bios device number */
    254  1.1  cherry             uint8_t version;                  /* %ah: major version      */
    255  1.1  cherry             uint16_t interface_support;       /* %cx: support bitmap     */
    256  1.1  cherry             /* Int13, Fn08: Legacy Get Device Parameters. */
    257  1.1  cherry             uint16_t legacy_max_cylinder;     /* %cl[7:6]:%ch: max cyl # */
    258  1.1  cherry             uint8_t legacy_max_head;          /* %dh: max head #         */
    259  1.1  cherry             uint8_t legacy_sectors_per_track; /* %cl[5:0]: max sector #  */
    260  1.1  cherry             /* Int13, Fn41: Get Device Parameters (as filled into %ds:%esi). */
    261  1.1  cherry             /* NB. First uint16_t of buffer must be set to buffer size.      */
    262  1.1  cherry             XEN_GUEST_HANDLE(void) edd_params;
    263  1.1  cherry         } disk_info; /* XEN_FW_DISK_INFO */
    264  1.1  cherry         struct {
    265  1.1  cherry             uint8_t device;                   /* bios device number  */
    266  1.1  cherry             uint32_t mbr_signature;           /* offset 0x1b8 in mbr */
    267  1.1  cherry         } disk_mbr_signature; /* XEN_FW_DISK_MBR_SIGNATURE */
    268  1.1  cherry         struct {
    269  1.1  cherry             /* Int10, AX=4F15: Get EDID info. */
    270  1.1  cherry             uint8_t capabilities;
    271  1.1  cherry             uint8_t edid_transfer_time;
    272  1.1  cherry             /* must refer to 128-byte buffer */
    273  1.1  cherry             XEN_GUEST_HANDLE(uint8) edid;
    274  1.1  cherry         } vbeddc_info; /* XEN_FW_VBEDDC_INFO */
    275  1.1  cherry         union xenpf_efi_info {
    276  1.1  cherry             uint32_t version;
    277  1.1  cherry             struct {
    278  1.1  cherry                 uint64_t addr;                /* EFI_CONFIGURATION_TABLE */
    279  1.1  cherry                 uint32_t nent;
    280  1.1  cherry             } cfg;
    281  1.1  cherry             struct {
    282  1.1  cherry                 uint32_t revision;
    283  1.1  cherry                 uint32_t bufsz;               /* input, in bytes */
    284  1.1  cherry                 XEN_GUEST_HANDLE(void) name;  /* UCS-2/UTF-16 string */
    285  1.1  cherry             } vendor;
    286  1.1  cherry             struct {
    287  1.1  cherry                 uint64_t addr;
    288  1.1  cherry                 uint64_t size;
    289  1.1  cherry                 uint64_t attr;
    290  1.1  cherry                 uint32_t type;
    291  1.1  cherry             } mem;
    292  1.1  cherry             struct {
    293  1.1  cherry                 /* IN variables */
    294  1.1  cherry                 uint16_t segment;
    295  1.1  cherry                 uint8_t bus;
    296  1.1  cherry                 uint8_t devfn;
    297  1.1  cherry                 uint16_t vendor;
    298  1.1  cherry                 uint16_t devid;
    299  1.1  cherry                 /* OUT variables */
    300  1.1  cherry                 uint64_t address;
    301  1.1  cherry                 xen_ulong_t size;
    302  1.1  cherry             } pci_rom;
    303  1.1  cherry             struct {
    304  1.1  cherry                 /* OUT variables */
    305  1.1  cherry                 uint64_t address;
    306  1.1  cherry                 xen_ulong_t size;
    307  1.1  cherry             } apple_properties;
    308  1.1  cherry         } efi_info; /* XEN_FW_EFI_INFO */
    309  1.1  cherry 
    310  1.1  cherry         /* Int16, Fn02: Get keyboard shift flags. */
    311  1.1  cherry         uint8_t kbd_shift_flags; /* XEN_FW_KBD_SHIFT_FLAGS */
    312  1.1  cherry     } u;
    313  1.1  cherry };
    314  1.1  cherry typedef struct xenpf_firmware_info xenpf_firmware_info_t;
    315  1.1  cherry DEFINE_XEN_GUEST_HANDLE(xenpf_firmware_info_t);
    316  1.1  cherry 
    317  1.1  cherry #define XENPF_enter_acpi_sleep    51
    318  1.1  cherry struct xenpf_enter_acpi_sleep {
    319  1.1  cherry     /* IN variables */
    320  1.1  cherry #if __XEN_INTERFACE_VERSION__ < 0x00040300
    321  1.1  cherry     uint16_t pm1a_cnt_val;      /* PM1a control value. */
    322  1.1  cherry     uint16_t pm1b_cnt_val;      /* PM1b control value. */
    323  1.1  cherry #else
    324  1.1  cherry     uint16_t val_a;             /* PM1a control / sleep type A. */
    325  1.1  cherry     uint16_t val_b;             /* PM1b control / sleep type B. */
    326  1.1  cherry #endif
    327  1.1  cherry     uint32_t sleep_state;       /* Which state to enter (Sn). */
    328  1.1  cherry #define XENPF_ACPI_SLEEP_EXTENDED 0x00000001
    329  1.1  cherry     uint32_t flags;             /* XENPF_ACPI_SLEEP_*. */
    330  1.1  cherry };
    331  1.1  cherry typedef struct xenpf_enter_acpi_sleep xenpf_enter_acpi_sleep_t;
    332  1.1  cherry DEFINE_XEN_GUEST_HANDLE(xenpf_enter_acpi_sleep_t);
    333  1.1  cherry 
    334  1.1  cherry #define XENPF_change_freq         52
    335  1.1  cherry struct xenpf_change_freq {
    336  1.1  cherry     /* IN variables */
    337  1.1  cherry     uint32_t flags; /* Must be zero. */
    338  1.1  cherry     uint32_t cpu;   /* Physical cpu. */
    339  1.1  cherry     uint64_t freq;  /* New frequency (Hz). */
    340  1.1  cherry };
    341  1.1  cherry typedef struct xenpf_change_freq xenpf_change_freq_t;
    342  1.1  cherry DEFINE_XEN_GUEST_HANDLE(xenpf_change_freq_t);
    343  1.1  cherry 
    344  1.1  cherry /*
    345  1.1  cherry  * Get idle times (nanoseconds since boot) for physical CPUs specified in the
    346  1.1  cherry  * @cpumap_bitmap with range [0..@cpumap_nr_cpus-1]. The @idletime array is
    347  1.1  cherry  * indexed by CPU number; only entries with the corresponding @cpumap_bitmap
    348  1.1  cherry  * bit set are written to. On return, @cpumap_bitmap is modified so that any
    349  1.1  cherry  * non-existent CPUs are cleared. Such CPUs have their @idletime array entry
    350  1.1  cherry  * cleared.
    351  1.1  cherry  */
    352  1.1  cherry #define XENPF_getidletime         53
    353  1.1  cherry struct xenpf_getidletime {
    354  1.1  cherry     /* IN/OUT variables */
    355  1.1  cherry     /* IN: CPUs to interrogate; OUT: subset of IN which are present */
    356  1.1  cherry     XEN_GUEST_HANDLE(uint8) cpumap_bitmap;
    357  1.1  cherry     /* IN variables */
    358  1.1  cherry     /* Size of cpumap bitmap. */
    359  1.1  cherry     uint32_t cpumap_nr_cpus;
    360  1.1  cherry     /* Must be indexable for every cpu in cpumap_bitmap. */
    361  1.1  cherry     XEN_GUEST_HANDLE(uint64) idletime;
    362  1.1  cherry     /* OUT variables */
    363  1.1  cherry     /* System time when the idletime snapshots were taken. */
    364  1.1  cherry     uint64_t now;
    365  1.1  cherry };
    366  1.1  cherry typedef struct xenpf_getidletime xenpf_getidletime_t;
    367  1.1  cherry DEFINE_XEN_GUEST_HANDLE(xenpf_getidletime_t);
    368  1.1  cherry 
    369  1.1  cherry #define XENPF_set_processor_pminfo      54
    370  1.1  cherry 
    371  1.1  cherry /* ability bits */
    372  1.1  cherry #define XEN_PROCESSOR_PM_CX	1
    373  1.1  cherry #define XEN_PROCESSOR_PM_PX	2
    374  1.1  cherry #define XEN_PROCESSOR_PM_TX	4
    375  1.1  cherry 
    376  1.1  cherry /* cmd type */
    377  1.1  cherry #define XEN_PM_CX   0
    378  1.1  cherry #define XEN_PM_PX   1
    379  1.1  cherry #define XEN_PM_TX   2
    380  1.1  cherry #define XEN_PM_PDC  3
    381  1.1  cherry 
    382  1.1  cherry /* Px sub info type */
    383  1.1  cherry #define XEN_PX_PCT   1
    384  1.1  cherry #define XEN_PX_PSS   2
    385  1.1  cherry #define XEN_PX_PPC   4
    386  1.1  cherry #define XEN_PX_PSD   8
    387  1.1  cherry 
    388  1.1  cherry struct xen_power_register {
    389  1.1  cherry     uint32_t     space_id;
    390  1.1  cherry     uint32_t     bit_width;
    391  1.1  cherry     uint32_t     bit_offset;
    392  1.1  cherry     uint32_t     access_size;
    393  1.1  cherry     uint64_t     address;
    394  1.1  cherry };
    395  1.1  cherry 
    396  1.1  cherry struct xen_processor_csd {
    397  1.1  cherry     uint32_t    domain;      /* domain number of one dependent group */
    398  1.1  cherry     uint32_t    coord_type;  /* coordination type */
    399  1.1  cherry     uint32_t    num;         /* number of processors in same domain */
    400  1.1  cherry };
    401  1.1  cherry typedef struct xen_processor_csd xen_processor_csd_t;
    402  1.1  cherry DEFINE_XEN_GUEST_HANDLE(xen_processor_csd_t);
    403  1.1  cherry 
    404  1.1  cherry struct xen_processor_cx {
    405  1.1  cherry     struct xen_power_register  reg; /* GAS for Cx trigger register */
    406  1.1  cherry     uint8_t     type;     /* cstate value, c0: 0, c1: 1, ... */
    407  1.1  cherry     uint32_t    latency;  /* worst latency (ms) to enter/exit this cstate */
    408  1.1  cherry     uint32_t    power;    /* average power consumption(mW) */
    409  1.1  cherry     uint32_t    dpcnt;    /* number of dependency entries */
    410  1.1  cherry     XEN_GUEST_HANDLE(xen_processor_csd_t) dp; /* NULL if no dependency */
    411  1.1  cherry };
    412  1.1  cherry typedef struct xen_processor_cx xen_processor_cx_t;
    413  1.1  cherry DEFINE_XEN_GUEST_HANDLE(xen_processor_cx_t);
    414  1.1  cherry 
    415  1.1  cherry struct xen_processor_flags {
    416  1.1  cherry     uint32_t bm_control:1;
    417  1.1  cherry     uint32_t bm_check:1;
    418  1.1  cherry     uint32_t has_cst:1;
    419  1.1  cherry     uint32_t power_setup_done:1;
    420  1.1  cherry     uint32_t bm_rld_set:1;
    421  1.1  cherry };
    422  1.1  cherry 
    423  1.1  cherry struct xen_processor_power {
    424  1.1  cherry     uint32_t count;  /* number of C state entries in array below */
    425  1.1  cherry     struct xen_processor_flags flags;  /* global flags of this processor */
    426  1.1  cherry     XEN_GUEST_HANDLE(xen_processor_cx_t) states; /* supported c states */
    427  1.1  cherry };
    428  1.1  cherry 
    429  1.1  cherry struct xen_pct_register {
    430  1.1  cherry     uint8_t  descriptor;
    431  1.1  cherry     uint16_t length;
    432  1.1  cherry     uint8_t  space_id;
    433  1.1  cherry     uint8_t  bit_width;
    434  1.1  cherry     uint8_t  bit_offset;
    435  1.1  cherry     uint8_t  reserved;
    436  1.1  cherry     uint64_t address;
    437  1.1  cherry };
    438  1.1  cherry 
    439  1.1  cherry struct xen_processor_px {
    440  1.1  cherry     uint64_t core_frequency; /* megahertz */
    441  1.1  cherry     uint64_t power;      /* milliWatts */
    442  1.1  cherry     uint64_t transition_latency; /* microseconds */
    443  1.1  cherry     uint64_t bus_master_latency; /* microseconds */
    444  1.1  cherry     uint64_t control;        /* control value */
    445  1.1  cherry     uint64_t status;     /* success indicator */
    446  1.1  cherry };
    447  1.1  cherry typedef struct xen_processor_px xen_processor_px_t;
    448  1.1  cherry DEFINE_XEN_GUEST_HANDLE(xen_processor_px_t);
    449  1.1  cherry 
    450  1.1  cherry struct xen_psd_package {
    451  1.1  cherry     uint64_t num_entries;
    452  1.1  cherry     uint64_t revision;
    453  1.1  cherry     uint64_t domain;
    454  1.1  cherry     uint64_t coord_type;
    455  1.1  cherry     uint64_t num_processors;
    456  1.1  cherry };
    457  1.1  cherry 
    458  1.1  cherry struct xen_processor_performance {
    459  1.1  cherry     uint32_t flags;     /* flag for Px sub info type */
    460  1.1  cherry     uint32_t platform_limit;  /* Platform limitation on freq usage */
    461  1.1  cherry     struct xen_pct_register control_register;
    462  1.1  cherry     struct xen_pct_register status_register;
    463  1.1  cherry     uint32_t state_count;     /* total available performance states */
    464  1.1  cherry     XEN_GUEST_HANDLE(xen_processor_px_t) states;
    465  1.1  cherry     struct xen_psd_package domain_info;
    466  1.1  cherry     uint32_t shared_type;     /* coordination type of this processor */
    467  1.1  cherry };
    468  1.1  cherry typedef struct xen_processor_performance xen_processor_performance_t;
    469  1.1  cherry DEFINE_XEN_GUEST_HANDLE(xen_processor_performance_t);
    470  1.1  cherry 
    471  1.1  cherry struct xenpf_set_processor_pminfo {
    472  1.1  cherry     /* IN variables */
    473  1.1  cherry     uint32_t id;    /* ACPI CPU ID */
    474  1.1  cherry     uint32_t type;  /* {XEN_PM_CX, XEN_PM_PX} */
    475  1.1  cherry     union {
    476  1.1  cherry         struct xen_processor_power          power;/* Cx: _CST/_CSD */
    477  1.1  cherry         struct xen_processor_performance    perf; /* Px: _PPC/_PCT/_PSS/_PSD */
    478  1.1  cherry         XEN_GUEST_HANDLE(uint32)            pdc;  /* _PDC */
    479  1.1  cherry     } u;
    480  1.1  cherry };
    481  1.1  cherry typedef struct xenpf_set_processor_pminfo xenpf_set_processor_pminfo_t;
    482  1.1  cherry DEFINE_XEN_GUEST_HANDLE(xenpf_set_processor_pminfo_t);
    483  1.1  cherry 
    484  1.1  cherry #define XENPF_get_cpuinfo 55
    485  1.1  cherry struct xenpf_pcpuinfo {
    486  1.1  cherry     /* IN */
    487  1.1  cherry     uint32_t xen_cpuid;
    488  1.1  cherry     /* OUT */
    489  1.1  cherry     /* The maxium cpu_id that is present */
    490  1.1  cherry     uint32_t max_present;
    491  1.1  cherry #define XEN_PCPU_FLAGS_ONLINE   1
    492  1.1  cherry     /* Correponding xen_cpuid is not present*/
    493  1.1  cherry #define XEN_PCPU_FLAGS_INVALID  2
    494  1.1  cherry     uint32_t flags;
    495  1.1  cherry     uint32_t apic_id;
    496  1.1  cherry     uint32_t acpi_id;
    497  1.1  cherry };
    498  1.1  cherry typedef struct xenpf_pcpuinfo xenpf_pcpuinfo_t;
    499  1.1  cherry DEFINE_XEN_GUEST_HANDLE(xenpf_pcpuinfo_t);
    500  1.1  cherry 
    501  1.1  cherry #define XENPF_get_cpu_version 48
    502  1.1  cherry struct xenpf_pcpu_version {
    503  1.1  cherry     /* IN */
    504  1.1  cherry     uint32_t xen_cpuid;
    505  1.1  cherry     /* OUT */
    506  1.1  cherry     /* The maxium cpu_id that is present */
    507  1.1  cherry     uint32_t max_present;
    508  1.1  cherry     char vendor_id[12];
    509  1.1  cherry     uint32_t family;
    510  1.1  cherry     uint32_t model;
    511  1.1  cherry     uint32_t stepping;
    512  1.1  cherry };
    513  1.1  cherry typedef struct xenpf_pcpu_version xenpf_pcpu_version_t;
    514  1.1  cherry DEFINE_XEN_GUEST_HANDLE(xenpf_pcpu_version_t);
    515  1.1  cherry 
    516  1.1  cherry #define XENPF_cpu_online    56
    517  1.1  cherry #define XENPF_cpu_offline   57
    518  1.1  cherry struct xenpf_cpu_ol
    519  1.1  cherry {
    520  1.1  cherry     uint32_t cpuid;
    521  1.1  cherry };
    522  1.1  cherry typedef struct xenpf_cpu_ol xenpf_cpu_ol_t;
    523  1.1  cherry DEFINE_XEN_GUEST_HANDLE(xenpf_cpu_ol_t);
    524  1.1  cherry 
    525  1.1  cherry #define XENPF_cpu_hotadd    58
    526  1.1  cherry struct xenpf_cpu_hotadd
    527  1.1  cherry {
    528  1.1  cherry 	uint32_t apic_id;
    529  1.1  cherry 	uint32_t acpi_id;
    530  1.1  cherry 	uint32_t pxm;
    531  1.1  cherry };
    532  1.1  cherry 
    533  1.1  cherry #define XENPF_mem_hotadd    59
    534  1.1  cherry struct xenpf_mem_hotadd
    535  1.1  cherry {
    536  1.1  cherry     uint64_t spfn;
    537  1.1  cherry     uint64_t epfn;
    538  1.1  cherry     uint32_t pxm;
    539  1.1  cherry     uint32_t flags;
    540  1.1  cherry };
    541  1.1  cherry 
    542  1.1  cherry #define XENPF_core_parking  60
    543  1.1  cherry 
    544  1.1  cherry #define XEN_CORE_PARKING_SET 1
    545  1.1  cherry #define XEN_CORE_PARKING_GET 2
    546  1.1  cherry struct xenpf_core_parking {
    547  1.1  cherry     /* IN variables */
    548  1.1  cherry     uint32_t type;
    549  1.1  cherry     /* IN variables:  set cpu nums expected to be idled */
    550  1.1  cherry     /* OUT variables: get cpu nums actually be idled */
    551  1.1  cherry     uint32_t idle_nums;
    552  1.1  cherry };
    553  1.1  cherry typedef struct xenpf_core_parking xenpf_core_parking_t;
    554  1.1  cherry DEFINE_XEN_GUEST_HANDLE(xenpf_core_parking_t);
    555  1.1  cherry 
    556  1.1  cherry /*
    557  1.1  cherry  * Access generic platform resources(e.g., accessing MSR, port I/O, etc)
    558  1.1  cherry  * in unified way. Batch resource operations in one call are supported and
    559  1.1  cherry  * they are always non-preemptible and executed in their original order.
    560  1.1  cherry  * The batch itself returns a negative integer for general errors, or a
    561  1.1  cherry  * non-negative integer for the number of successful operations. For the latter
    562  1.1  cherry  * case, the @ret in the failed entry (if any) indicates the exact error.
    563  1.1  cherry  */
    564  1.1  cherry #define XENPF_resource_op   61
    565  1.1  cherry 
    566  1.1  cherry #define XEN_RESOURCE_OP_MSR_READ  0
    567  1.1  cherry #define XEN_RESOURCE_OP_MSR_WRITE 1
    568  1.1  cherry 
    569  1.1  cherry /*
    570  1.1  cherry  * Specially handled MSRs:
    571  1.1  cherry  * - MSR_IA32_TSC
    572  1.1  cherry  * READ: Returns the scaled system time(ns) instead of raw timestamp. In
    573  1.1  cherry  *       multiple entry case, if other MSR read is followed by a MSR_IA32_TSC
    574  1.1  cherry  *       read, then both reads are guaranteed to be performed atomically (with
    575  1.1  cherry  *       IRQ disabled). The return time indicates the point of reading that MSR.
    576  1.1  cherry  * WRITE: Not supported.
    577  1.1  cherry  */
    578  1.1  cherry 
    579  1.1  cherry struct xenpf_resource_entry {
    580  1.1  cherry     union {
    581  1.1  cherry         uint32_t cmd;   /* IN: XEN_RESOURCE_OP_* */
    582  1.1  cherry         int32_t  ret;   /* OUT: return value for failed entry */
    583  1.1  cherry     } u;
    584  1.1  cherry     uint32_t rsvd;      /* IN: padding and must be zero */
    585  1.1  cherry     uint64_t idx;       /* IN: resource address to access */
    586  1.1  cherry     uint64_t val;       /* IN/OUT: resource value to set/get */
    587  1.1  cherry };
    588  1.1  cherry typedef struct xenpf_resource_entry xenpf_resource_entry_t;
    589  1.1  cherry DEFINE_XEN_GUEST_HANDLE(xenpf_resource_entry_t);
    590  1.1  cherry 
    591  1.1  cherry struct xenpf_resource_op {
    592  1.1  cherry     uint32_t nr_entries;    /* number of resource entry */
    593  1.1  cherry     uint32_t cpu;           /* which cpu to run */
    594  1.1  cherry     XEN_GUEST_HANDLE(xenpf_resource_entry_t) entries;
    595  1.1  cherry };
    596  1.1  cherry typedef struct xenpf_resource_op xenpf_resource_op_t;
    597  1.1  cherry DEFINE_XEN_GUEST_HANDLE(xenpf_resource_op_t);
    598  1.1  cherry 
    599  1.1  cherry #define XENPF_get_symbol   63
    600  1.1  cherry struct xenpf_symdata {
    601  1.1  cherry     /* IN/OUT variables */
    602  1.1  cherry     uint32_t namelen; /* IN:  size of name buffer                       */
    603  1.1  cherry                       /* OUT: strlen(name) of hypervisor symbol (may be */
    604  1.1  cherry                       /*      larger than what's been copied to guest)  */
    605  1.1  cherry     uint32_t symnum;  /* IN:  Symbol to read                            */
    606  1.1  cherry                       /* OUT: Next available symbol. If same as IN then */
    607  1.1  cherry                       /*      we reached the end                        */
    608  1.1  cherry 
    609  1.1  cherry     /* OUT variables */
    610  1.1  cherry     XEN_GUEST_HANDLE(char) name;
    611  1.1  cherry     uint64_t address;
    612  1.1  cherry     char type;
    613  1.1  cherry };
    614  1.1  cherry typedef struct xenpf_symdata xenpf_symdata_t;
    615  1.1  cherry DEFINE_XEN_GUEST_HANDLE(xenpf_symdata_t);
    616  1.1  cherry 
    617  1.1  cherry /*
    618  1.2  bouyer  * Fetch the video console information and mode setup by Xen.  A non-
    619  1.2  bouyer  * negative return value indicates the size of the (part of the) structure
    620  1.2  bouyer  * which was filled.
    621  1.2  bouyer  */
    622  1.2  bouyer #define XENPF_get_dom0_console 64
    623  1.2  bouyer typedef struct dom0_vga_console_info xenpf_dom0_console_t;
    624  1.2  bouyer DEFINE_XEN_GUEST_HANDLE(xenpf_dom0_console_t);
    625  1.2  bouyer 
    626  1.2  bouyer /*
    627  1.1  cherry  * ` enum neg_errnoval
    628  1.1  cherry  * ` HYPERVISOR_platform_op(const struct xen_platform_op*);
    629  1.1  cherry  */
    630  1.1  cherry struct xen_platform_op {
    631  1.1  cherry     uint32_t cmd;
    632  1.1  cherry     uint32_t interface_version; /* XENPF_INTERFACE_VERSION */
    633  1.1  cherry     union {
    634  1.1  cherry         struct xenpf_settime           settime;
    635  1.1  cherry         struct xenpf_settime32         settime32;
    636  1.1  cherry         struct xenpf_settime64         settime64;
    637  1.1  cherry         struct xenpf_add_memtype       add_memtype;
    638  1.1  cherry         struct xenpf_del_memtype       del_memtype;
    639  1.1  cherry         struct xenpf_read_memtype      read_memtype;
    640  1.1  cherry         struct xenpf_microcode_update  microcode;
    641  1.1  cherry         struct xenpf_platform_quirk    platform_quirk;
    642  1.1  cherry         struct xenpf_efi_runtime_call  efi_runtime_call;
    643  1.1  cherry         struct xenpf_firmware_info     firmware_info;
    644  1.1  cherry         struct xenpf_enter_acpi_sleep  enter_acpi_sleep;
    645  1.1  cherry         struct xenpf_change_freq       change_freq;
    646  1.1  cherry         struct xenpf_getidletime       getidletime;
    647  1.1  cherry         struct xenpf_set_processor_pminfo set_pminfo;
    648  1.1  cherry         struct xenpf_pcpuinfo          pcpu_info;
    649  1.1  cherry         struct xenpf_pcpu_version      pcpu_version;
    650  1.1  cherry         struct xenpf_cpu_ol            cpu_ol;
    651  1.1  cherry         struct xenpf_cpu_hotadd        cpu_add;
    652  1.1  cherry         struct xenpf_mem_hotadd        mem_add;
    653  1.1  cherry         struct xenpf_core_parking      core_parking;
    654  1.1  cherry         struct xenpf_resource_op       resource_op;
    655  1.1  cherry         struct xenpf_symdata           symdata;
    656  1.2  bouyer         xenpf_dom0_console_t           dom0_console;
    657  1.1  cherry         uint8_t                        pad[128];
    658  1.1  cherry     } u;
    659  1.1  cherry };
    660  1.1  cherry typedef struct xen_platform_op xen_platform_op_t;
    661  1.1  cherry DEFINE_XEN_GUEST_HANDLE(xen_platform_op_t);
    662  1.1  cherry 
    663  1.1  cherry #endif /* __XEN_PUBLIC_PLATFORM_H__ */
    664  1.1  cherry 
    665  1.1  cherry /*
    666  1.1  cherry  * Local variables:
    667  1.1  cherry  * mode: C
    668  1.1  cherry  * c-file-style: "BSD"
    669  1.1  cherry  * c-basic-offset: 4
    670  1.1  cherry  * tab-width: 4
    671  1.1  cherry  * indent-tabs-mode: nil
    672  1.1  cherry  * End:
    673  1.1  cherry  */
    674