platform.h revision 183375
1239310Sdim/******************************************************************************
2239310Sdim * platform.h
3239310Sdim *
4239310Sdim * Hardware platform operations. Intended for use by domain-0 kernel.
5239310Sdim *
6239310Sdim * Permission is hereby granted, free of charge, to any person obtaining a copy
7239310Sdim * of this software and associated documentation files (the "Software"), to
8239310Sdim * deal in the Software without restriction, including without limitation the
9239310Sdim * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
10239310Sdim * sell copies of the Software, and to permit persons to whom the Software is
11239310Sdim * furnished to do so, subject to the following conditions:
12239310Sdim *
13239310Sdim * The above copyright notice and this permission notice shall be included in
14239310Sdim * all copies or substantial portions of the Software.
15239310Sdim *
16239310Sdim * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17239310Sdim * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18243830Sdim * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19239310Sdim * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20239310Sdim * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
21249423Sdim * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
22249423Sdim * DEALINGS IN THE SOFTWARE.
23239310Sdim *
24239310Sdim * Copyright (c) 2002-2006, K Fraser
25239310Sdim */
26239310Sdim
27243830Sdim#ifndef __XEN_PUBLIC_PLATFORM_H__
28243830Sdim#define __XEN_PUBLIC_PLATFORM_H__
29239310Sdim
30243830Sdim#include "xen.h"
31243830Sdim
32243830Sdim#define XENPF_INTERFACE_VERSION 0x03000001
33243830Sdim
34243830Sdim/*
35243830Sdim * Set clock such that it would read <secs,nsecs> after 00:00:00 UTC,
36243830Sdim * 1 January, 1970 if the current system time was <system_time>.
37243830Sdim */
38243830Sdim#define XENPF_settime             17
39243830Sdimstruct xenpf_settime {
40243830Sdim    /* IN variables. */
41243830Sdim    uint32_t secs;
42243830Sdim    uint32_t nsecs;
43243830Sdim    uint64_t system_time;
44243830Sdim};
45243830Sdimtypedef struct xenpf_settime xenpf_settime_t;
46243830SdimDEFINE_XEN_GUEST_HANDLE(xenpf_settime_t);
47243830Sdim
48243830Sdim/*
49243830Sdim * Request memory range (@mfn, @mfn+@nr_mfns-1) to have type @type.
50243830Sdim * On x86, @type is an architecture-defined MTRR memory type.
51243830Sdim * On success, returns the MTRR that was used (@reg) and a handle that can
52243830Sdim * be passed to XENPF_DEL_MEMTYPE to accurately tear down the new setting.
53243830Sdim * (x86-specific).
54243830Sdim */
55243830Sdim#define XENPF_add_memtype         31
56243830Sdimstruct xenpf_add_memtype {
57243830Sdim    /* IN variables. */
58249423Sdim    xen_pfn_t mfn;
59249423Sdim    uint64_t nr_mfns;
60249423Sdim    uint32_t type;
61249423Sdim    /* OUT variables. */
62249423Sdim    uint32_t handle;
63243830Sdim    uint32_t reg;
64243830Sdim};
65243830Sdimtypedef struct xenpf_add_memtype xenpf_add_memtype_t;
66243830SdimDEFINE_XEN_GUEST_HANDLE(xenpf_add_memtype_t);
67243830Sdim
68243830Sdim/*
69243830Sdim * Tear down an existing memory-range type. If @handle is remembered then it
70243830Sdim * should be passed in to accurately tear down the correct setting (in case
71243830Sdim * of overlapping memory regions with differing types). If it is not known
72243830Sdim * then @handle should be set to zero. In all cases @reg must be set.
73243830Sdim * (x86-specific).
74243830Sdim */
75243830Sdim#define XENPF_del_memtype         32
76249423Sdimstruct xenpf_del_memtype {
77249423Sdim    /* IN variables. */
78249423Sdim    uint32_t handle;
79243830Sdim    uint32_t reg;
80243830Sdim};
81243830Sdimtypedef struct xenpf_del_memtype xenpf_del_memtype_t;
82243830SdimDEFINE_XEN_GUEST_HANDLE(xenpf_del_memtype_t);
83243830Sdim
84243830Sdim/* Read current type of an MTRR (x86-specific). */
85243830Sdim#define XENPF_read_memtype        33
86243830Sdimstruct xenpf_read_memtype {
87243830Sdim    /* IN variables. */
88243830Sdim    uint32_t reg;
89243830Sdim    /* OUT variables. */
90243830Sdim    xen_pfn_t mfn;
91243830Sdim    uint64_t nr_mfns;
92243830Sdim    uint32_t type;
93243830Sdim};
94243830Sdimtypedef struct xenpf_read_memtype xenpf_read_memtype_t;
95243830SdimDEFINE_XEN_GUEST_HANDLE(xenpf_read_memtype_t);
96243830Sdim
97243830Sdim#define XENPF_microcode_update    35
98243830Sdimstruct xenpf_microcode_update {
99243830Sdim    /* IN variables. */
100243830Sdim    XEN_GUEST_HANDLE(const_void) data;/* Pointer to microcode data */
101243830Sdim    uint32_t length;                  /* Length of microcode data. */
102243830Sdim};
103243830Sdimtypedef struct xenpf_microcode_update xenpf_microcode_update_t;
104243830SdimDEFINE_XEN_GUEST_HANDLE(xenpf_microcode_update_t);
105243830Sdim
106243830Sdim#define XENPF_platform_quirk      39
107243830Sdim#define QUIRK_NOIRQBALANCING      1 /* Do not restrict IO-APIC RTE targets */
108243830Sdim#define QUIRK_IOAPIC_BAD_REGSEL   2 /* IO-APIC REGSEL forgets its value    */
109243830Sdim#define QUIRK_IOAPIC_GOOD_REGSEL  3 /* IO-APIC REGSEL behaves properly     */
110243830Sdimstruct xenpf_platform_quirk {
111243830Sdim    /* IN variables. */
112243830Sdim    uint32_t quirk_id;
113243830Sdim};
114243830Sdimtypedef struct xenpf_platform_quirk xenpf_platform_quirk_t;
115243830SdimDEFINE_XEN_GUEST_HANDLE(xenpf_platform_quirk_t);
116243830Sdim
117243830Sdim#define XENPF_firmware_info       50
118243830Sdim#define XEN_FW_DISK_INFO          1 /* from int 13 AH=08/41/48 */
119243830Sdim#define XEN_FW_DISK_MBR_SIGNATURE 2 /* from MBR offset 0x1b8 */
120243830Sdim#define XEN_FW_VBEDDC_INFO        3 /* from int 10 AX=4f15 */
121243830Sdimstruct xenpf_firmware_info {
122243830Sdim    /* IN variables. */
123243830Sdim    uint32_t type;
124243830Sdim    uint32_t index;
125243830Sdim    /* OUT variables. */
126243830Sdim    union {
127239310Sdim        struct {
128249423Sdim            /* Int13, Fn48: Check Extensions Present. */
129239310Sdim            uint8_t device;                   /* %dl: bios device number */
130239310Sdim            uint8_t version;                  /* %ah: major version      */
131239310Sdim            uint16_t interface_support;       /* %cx: support bitmap     */
132243830Sdim            /* Int13, Fn08: Legacy Get Device Parameters. */
133243830Sdim            uint16_t legacy_max_cylinder;     /* %cl[7:6]:%ch: max cyl # */
134243830Sdim            uint8_t legacy_max_head;          /* %dh: max head #         */
135243830Sdim            uint8_t legacy_sectors_per_track; /* %cl[5:0]: max sector #  */
136243830Sdim            /* Int13, Fn41: Get Device Parameters (as filled into %ds:%esi). */
137243830Sdim            /* NB. First uint16_t of buffer must be set to buffer size.      */
138243830Sdim            XEN_GUEST_HANDLE(void) edd_params;
139243830Sdim        } disk_info; /* XEN_FW_DISK_INFO */
140243830Sdim        struct {
141243830Sdim            uint8_t device;                   /* bios device number  */
142243830Sdim            uint32_t mbr_signature;           /* offset 0x1b8 in mbr */
143243830Sdim        } disk_mbr_signature; /* XEN_FW_DISK_MBR_SIGNATURE */
144243830Sdim        struct {
145249423Sdim            /* Int10, AX=4F15: Get EDID info. */
146249423Sdim            uint8_t capabilities;
147249423Sdim            uint8_t edid_transfer_time;
148249423Sdim            /* must refer to 128-byte buffer */
149239310Sdim            XEN_GUEST_HANDLE(uint8) edid;
150243830Sdim        } vbeddc_info; /* XEN_FW_VBEDDC_INFO */
151249423Sdim    } u;
152249423Sdim};
153249423Sdimtypedef struct xenpf_firmware_info xenpf_firmware_info_t;
154249423SdimDEFINE_XEN_GUEST_HANDLE(xenpf_firmware_info_t);
155243830Sdim
156243830Sdim#define XENPF_enter_acpi_sleep    51
157243830Sdimstruct xenpf_enter_acpi_sleep {
158239310Sdim    /* IN variables */
159239310Sdim    uint16_t pm1a_cnt_val;      /* PM1a control value. */
160239310Sdim    uint16_t pm1b_cnt_val;      /* PM1b control value. */
161239310Sdim    uint32_t sleep_state;       /* Which state to enter (Sn). */
162239310Sdim    uint32_t flags;             /* Must be zero. */
163239310Sdim};
164239310Sdimtypedef struct xenpf_enter_acpi_sleep xenpf_enter_acpi_sleep_t;
165239310SdimDEFINE_XEN_GUEST_HANDLE(xenpf_enter_acpi_sleep_t);
166239310Sdim
167239310Sdim#define XENPF_change_freq         52
168239310Sdimstruct xenpf_change_freq {
169239310Sdim    /* IN variables */
170239310Sdim    uint32_t flags; /* Must be zero. */
171239310Sdim    uint32_t cpu;   /* Physical cpu. */
172239310Sdim    uint64_t freq;  /* New frequency (Hz). */
173239310Sdim};
174239310Sdimtypedef struct xenpf_change_freq xenpf_change_freq_t;
175243830SdimDEFINE_XEN_GUEST_HANDLE(xenpf_change_freq_t);
176239310Sdim
177239310Sdim/*
178239310Sdim * Get idle times (nanoseconds since boot) for physical CPUs specified in the
179239310Sdim * @cpumap_bitmap with range [0..@cpumap_nr_cpus-1]. The @idletime array is
180243830Sdim * indexed by CPU number; only entries with the corresponding @cpumap_bitmap
181239310Sdim * bit set are written to. On return, @cpumap_bitmap is modified so that any
182243830Sdim * non-existent CPUs are cleared. Such CPUs have their @idletime array entry
183243830Sdim * cleared.
184243830Sdim */
185243830Sdim#define XENPF_getidletime         53
186243830Sdimstruct xenpf_getidletime {
187243830Sdim    /* IN/OUT variables */
188243830Sdim    /* IN: CPUs to interrogate; OUT: subset of IN which are present */
189243830Sdim    XEN_GUEST_HANDLE(uint8) cpumap_bitmap;
190243830Sdim    /* IN variables */
191243830Sdim    /* Size of cpumap bitmap. */
192243830Sdim    uint32_t cpumap_nr_cpus;
193243830Sdim    /* Must be indexable for every cpu in cpumap_bitmap. */
194243830Sdim    XEN_GUEST_HANDLE(uint64) idletime;
195243830Sdim    /* OUT variables */
196243830Sdim    /* System time when the idletime snapshots were taken. */
197249423Sdim    uint64_t now;
198243830Sdim};
199243830Sdimtypedef struct xenpf_getidletime xenpf_getidletime_t;
200243830SdimDEFINE_XEN_GUEST_HANDLE(xenpf_getidletime_t);
201243830Sdim
202243830Sdim#define XENPF_set_processor_pminfo      54
203249423Sdim
204249423Sdim/* ability bits */
205249423Sdim#define XEN_PROCESSOR_PM_CX	1
206249423Sdim#define XEN_PROCESSOR_PM_PX	2
207243830Sdim#define XEN_PROCESSOR_PM_TX	4
208243830Sdim
209243830Sdim/* cmd type */
210243830Sdim#define XEN_PM_CX   0
211243830Sdim#define XEN_PM_PX   1
212243830Sdim#define XEN_PM_TX   2
213243830Sdim
214243830Sdim/* Px sub info type */
215243830Sdim#define XEN_PX_PCT   1
216239310Sdim#define XEN_PX_PSS   2
217239310Sdim#define XEN_PX_PPC   4
218243830Sdim#define XEN_PX_PSD   8
219239310Sdim
220239310Sdimstruct xen_power_register {
221239310Sdim    uint32_t     space_id;
222239310Sdim    uint32_t     bit_width;
223243830Sdim    uint32_t     bit_offset;
224243830Sdim    uint32_t     access_size;
225243830Sdim    uint64_t     address;
226243830Sdim};
227243830Sdim
228243830Sdimstruct xen_processor_csd {
229243830Sdim    uint32_t    domain;      /* domain number of one dependent group */
230243830Sdim    uint32_t    coord_type;  /* coordination type */
231243830Sdim    uint32_t    num;         /* number of processors in same domain */
232243830Sdim};
233243830Sdimtypedef struct xen_processor_csd xen_processor_csd_t;
234243830SdimDEFINE_XEN_GUEST_HANDLE(xen_processor_csd_t);
235243830Sdim
236243830Sdimstruct xen_processor_cx {
237239310Sdim    struct xen_power_register  reg; /* GAS for Cx trigger register */
238239310Sdim    uint8_t     type;     /* cstate value, c0: 0, c1: 1, ... */
239239310Sdim    uint32_t    latency;  /* worst latency (ms) to enter/exit this cstate */
240243830Sdim    uint32_t    power;    /* average power consumption(mW) */
241243830Sdim    uint32_t    dpcnt;    /* number of dependency entries */
242239310Sdim    XEN_GUEST_HANDLE(xen_processor_csd_t) dp; /* NULL if no dependency */
243249423Sdim};
244249423Sdimtypedef struct xen_processor_cx xen_processor_cx_t;
245243830SdimDEFINE_XEN_GUEST_HANDLE(xen_processor_cx_t);
246243830Sdim
247239310Sdimstruct xen_processor_flags {
248239310Sdim    uint32_t bm_control:1;
249239310Sdim    uint32_t bm_check:1;
250239310Sdim    uint32_t has_cst:1;
251243830Sdim    uint32_t power_setup_done:1;
252243830Sdim    uint32_t bm_rld_set:1;
253243830Sdim};
254243830Sdim
255243830Sdimstruct xen_processor_power {
256243830Sdim    uint32_t count;  /* number of C state entries in array below */
257243830Sdim    struct xen_processor_flags flags;  /* global flags of this processor */
258243830Sdim    XEN_GUEST_HANDLE(xen_processor_cx_t) states; /* supported c states */
259243830Sdim};
260243830Sdim
261243830Sdimstruct xen_pct_register {
262243830Sdim    uint8_t  descriptor;
263243830Sdim    uint16_t length;
264243830Sdim    uint8_t  space_id;
265243830Sdim    uint8_t  bit_width;
266243830Sdim    uint8_t  bit_offset;
267243830Sdim    uint8_t  reserved;
268243830Sdim    uint64_t address;
269243830Sdim};
270243830Sdim
271243830Sdimstruct xen_processor_px {
272243830Sdim    uint64_t core_frequency; /* megahertz */
273243830Sdim    uint64_t power;      /* milliWatts */
274243830Sdim    uint64_t transition_latency; /* microseconds */
275243830Sdim    uint64_t bus_master_latency; /* microseconds */
276243830Sdim    uint64_t control;        /* control value */
277243830Sdim    uint64_t status;     /* success indicator */
278243830Sdim};
279243830Sdimtypedef struct xen_processor_px xen_processor_px_t;
280249423SdimDEFINE_XEN_GUEST_HANDLE(xen_processor_px_t);
281249423Sdim
282249423Sdimstruct xen_psd_package {
283243830Sdim    uint64_t num_entries;
284243830Sdim    uint64_t revision;
285243830Sdim    uint64_t domain;
286243830Sdim    uint64_t coord_type;
287243830Sdim    uint64_t num_processors;
288243830Sdim};
289243830Sdim
290243830Sdimstruct xen_processor_performance {
291243830Sdim    uint32_t flags;     /* flag for Px sub info type */
292243830Sdim    uint32_t platform_limit;  /* Platform limitation on freq usage */
293243830Sdim    struct xen_pct_register control_register;
294243830Sdim    struct xen_pct_register status_register;
295243830Sdim    uint32_t state_count;     /* total available performance states */
296243830Sdim    XEN_GUEST_HANDLE(xen_processor_px_t) states;
297243830Sdim    struct xen_psd_package domain_info;
298243830Sdim    uint32_t shared_type;     /* coordination type of this processor */
299243830Sdim};
300243830Sdimtypedef struct xen_processor_performance xen_processor_performance_t;
301243830SdimDEFINE_XEN_GUEST_HANDLE(xen_processor_performance_t);
302243830Sdim
303243830Sdimstruct xenpf_set_processor_pminfo {
304243830Sdim    /* IN variables */
305243830Sdim    uint32_t id;    /* ACPI CPU ID */
306243830Sdim    uint32_t type;  /* {XEN_PM_CX, XEN_PM_PX} */
307243830Sdim    union {
308243830Sdim        struct xen_processor_power          power;/* Cx: _CST/_CSD */
309243830Sdim        struct xen_processor_performance    perf; /* Px: _PPC/_PCT/_PSS/_PSD */
310243830Sdim    } u;
311243830Sdim};
312243830Sdimtypedef struct xenpf_set_processor_pminfo xenpf_set_processor_pminfo_t;
313243830SdimDEFINE_XEN_GUEST_HANDLE(xenpf_set_processor_pminfo_t);
314239310Sdim
315243830Sdimstruct xen_platform_op {
316239310Sdim    uint32_t cmd;
317239310Sdim    uint32_t interface_version; /* XENPF_INTERFACE_VERSION */
318239310Sdim    union {
319243830Sdim        struct xenpf_settime           settime;
320243830Sdim        struct xenpf_add_memtype       add_memtype;
321243830Sdim        struct xenpf_del_memtype       del_memtype;
322239310Sdim        struct xenpf_read_memtype      read_memtype;
323239310Sdim        struct xenpf_microcode_update  microcode;
324243830Sdim        struct xenpf_platform_quirk    platform_quirk;
325243830Sdim        struct xenpf_firmware_info     firmware_info;
326243830Sdim        struct xenpf_enter_acpi_sleep  enter_acpi_sleep;
327243830Sdim        struct xenpf_change_freq       change_freq;
328239310Sdim        struct xenpf_getidletime       getidletime;
329243830Sdim        struct xenpf_set_processor_pminfo set_pminfo;
330243830Sdim        uint8_t                        pad[128];
331243830Sdim    } u;
332239310Sdim};
333249423Sdimtypedef struct xen_platform_op xen_platform_op_t;
334249423SdimDEFINE_XEN_GUEST_HANDLE(xen_platform_op_t);
335243830Sdim
336243830Sdim#endif /* __XEN_PUBLIC_PLATFORM_H__ */
337243830Sdim
338243830Sdim/*
339243830Sdim * Local variables:
340243830Sdim * mode: C
341249423Sdim * c-set-style: "BSD"
342249423Sdim * c-basic-offset: 4
343243830Sdim * tab-width: 4
344243830Sdim * indent-tabs-mode: nil
345243830Sdim * End:
346249423Sdim */
347249423Sdim