Staging: hv: coding style cleanups for HvStatus.h
[linux-2.6/linux-acpi-2.6/ibm-acpi-2.6.git] / drivers / staging / hv / hv_api.h
blob99129b5823a0ecbc01e63295713910ef01f5edff
1 /*
3 * Copyright (c) 2009, Microsoft Corporation.
5 * This program is free software; you can redistribute it and/or modify it
6 * under the terms and conditions of the GNU General Public License,
7 * version 2, as published by the Free Software Foundation.
9 * This program is distributed in the hope it will be useful, but WITHOUT
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
12 * more details.
14 * You should have received a copy of the GNU General Public License along with
15 * this program; if not, write to the Free Software Foundation, Inc., 59 Temple
16 * Place - Suite 330, Boston, MA 02111-1307 USA.
18 * Authors:
19 * Haiyang Zhang <haiyangz@microsoft.com>
20 * Hank Janssen <hjanssen@microsoft.com>
23 #ifndef __HV_API_H
24 #define __HV_API_H
27 * The below CPUID leaves are present if VersionAndFeatures.HypervisorPresent
28 * is set by CPUID(HvCpuIdFunctionVersionAndFeatures).
30 enum hv_cpuid_function {
31 HvCpuIdFunctionVersionAndFeatures = 0x00000001,
32 HvCpuIdFunctionHvVendorAndMaxFunction = 0x40000000,
33 HvCpuIdFunctionHvInterface = 0x40000001,
36 * The remaining functions depend on the value of
37 * HvCpuIdFunctionInterface
39 HvCpuIdFunctionMsHvVersion = 0x40000002,
40 HvCpuIdFunctionMsHvFeatures = 0x40000003,
41 HvCpuIdFunctionMsHvEnlightenmentInformation = 0x40000004,
42 HvCpuIdFunctionMsHvImplementationLimits = 0x40000005,
45 /* Define the virtual APIC registers */
46 #define HV_X64_MSR_EOI (0x40000070)
47 #define HV_X64_MSR_ICR (0x40000071)
48 #define HV_X64_MSR_TPR (0x40000072)
49 #define HV_X64_MSR_APIC_ASSIST_PAGE (0x40000073)
51 /* Define version of the synthetic interrupt controller. */
52 #define HV_SYNIC_VERSION (1)
54 /* Define synthetic interrupt controller model specific registers. */
55 #define HV_X64_MSR_SCONTROL (0x40000080)
56 #define HV_X64_MSR_SVERSION (0x40000081)
57 #define HV_X64_MSR_SIEFP (0x40000082)
58 #define HV_X64_MSR_SIMP (0x40000083)
59 #define HV_X64_MSR_EOM (0x40000084)
60 #define HV_X64_MSR_SINT0 (0x40000090)
61 #define HV_X64_MSR_SINT1 (0x40000091)
62 #define HV_X64_MSR_SINT2 (0x40000092)
63 #define HV_X64_MSR_SINT3 (0x40000093)
64 #define HV_X64_MSR_SINT4 (0x40000094)
65 #define HV_X64_MSR_SINT5 (0x40000095)
66 #define HV_X64_MSR_SINT6 (0x40000096)
67 #define HV_X64_MSR_SINT7 (0x40000097)
68 #define HV_X64_MSR_SINT8 (0x40000098)
69 #define HV_X64_MSR_SINT9 (0x40000099)
70 #define HV_X64_MSR_SINT10 (0x4000009A)
71 #define HV_X64_MSR_SINT11 (0x4000009B)
72 #define HV_X64_MSR_SINT12 (0x4000009C)
73 #define HV_X64_MSR_SINT13 (0x4000009D)
74 #define HV_X64_MSR_SINT14 (0x4000009E)
75 #define HV_X64_MSR_SINT15 (0x4000009F)
77 /* Define the expected SynIC version. */
78 #define HV_SYNIC_VERSION_1 (0x1)
80 /* Define synthetic interrupt controller message constants. */
81 #define HV_MESSAGE_SIZE (256)
82 #define HV_MESSAGE_PAYLOAD_BYTE_COUNT (240)
83 #define HV_MESSAGE_PAYLOAD_QWORD_COUNT (30)
84 #define HV_ANY_VP (0xFFFFFFFF)
86 /* Define synthetic interrupt controller flag constants. */
87 #define HV_EVENT_FLAGS_COUNT (256 * 8)
88 #define HV_EVENT_FLAGS_BYTE_COUNT (256)
89 #define HV_EVENT_FLAGS_DWORD_COUNT (256 / sizeof(u32))
91 /* Define hypervisor message types. */
92 enum hv_message_type {
93 HvMessageTypeNone = 0x00000000,
95 /* Memory access messages. */
96 HvMessageTypeUnmappedGpa = 0x80000000,
97 HvMessageTypeGpaIntercept = 0x80000001,
99 /* Timer notification messages. */
100 HvMessageTimerExpired = 0x80000010,
102 /* Error messages. */
103 HvMessageTypeInvalidVpRegisterValue = 0x80000020,
104 HvMessageTypeUnrecoverableException = 0x80000021,
105 HvMessageTypeUnsupportedFeature = 0x80000022,
107 /* Trace buffer complete messages. */
108 HvMessageTypeEventLogBufferComplete = 0x80000040,
110 /* Platform-specific processor intercept messages. */
111 HvMessageTypeX64IoPortIntercept = 0x80010000,
112 HvMessageTypeX64MsrIntercept = 0x80010001,
113 HvMessageTypeX64CpuidIntercept = 0x80010002,
114 HvMessageTypeX64ExceptionIntercept = 0x80010003,
115 HvMessageTypeX64ApicEoi = 0x80010004,
116 HvMessageTypeX64LegacyFpError = 0x80010005
119 /* Define the number of synthetic interrupt sources. */
120 #define HV_SYNIC_SINT_COUNT (16)
121 #define HV_SYNIC_STIMER_COUNT (4)
123 /* Define invalid partition identifier. */
124 #define HV_PARTITION_ID_INVALID ((u64)0x0)
126 /* Define connection identifier type. */
127 union hv_connection_id {
128 u32 Asu32;
129 struct {
130 u32 Id:24;
131 u32 Reserved:8;
132 } u;
135 /* Define port identifier type. */
136 union hv_port_id {
137 u32 Asu32;
138 struct {
139 u32 Id:24;
140 u32 Reserved:8;
141 } u ;
144 /* Define port type. */
145 enum hv_port_type {
146 HvPortTypeMessage = 1,
147 HvPortTypeEvent = 2,
148 HvPortTypeMonitor = 3
151 /* Define port information structure. */
152 struct hv_port_info {
153 enum hv_port_type PortType;
154 u32 Padding;
155 union {
156 struct {
157 u32 TargetSint;
158 u32 TargetVp;
159 u64 RsvdZ;
160 } MessagePortInfo;
161 struct {
162 u32 TargetSint;
163 u32 TargetVp;
164 u16 BaseFlagNumber;
165 u16 FlagCount;
166 u32 RsvdZ;
167 } EventPortInfo;
168 struct {
169 u64 MonitorAddress;
170 u64 RsvdZ;
171 } MonitorPortInfo;
175 struct hv_connection_info {
176 enum hv_port_type PortType;
177 u32 Padding;
178 union {
179 struct {
180 u64 RsvdZ;
181 } MessageConnectionInfo;
182 struct {
183 u64 RsvdZ;
184 } EventConnectionInfo;
185 struct {
186 u64 MonitorAddress;
187 } MonitorConnectionInfo;
191 /* Define synthetic interrupt controller message flags. */
192 union hv_message_flags {
193 u8 Asu8;
194 struct {
195 u8 MessagePending:1;
196 u8 Reserved:7;
200 /* Define synthetic interrupt controller message header. */
201 struct hv_message_header {
202 enum hv_message_type MessageType;
203 u8 PayloadSize;
204 union hv_message_flags MessageFlags;
205 u8 Reserved[2];
206 union {
207 u64 Sender;
208 union hv_port_id Port;
212 /* Define timer message payload structure. */
213 struct hv_timer_message_payload {
214 u32 TimerIndex;
215 u32 Reserved;
216 u64 ExpirationTime; /* When the timer expired */
217 u64 DeliveryTime; /* When the message was delivered */
220 /* Define synthetic interrupt controller message format. */
221 struct hv_message {
222 struct hv_message_header Header;
223 union {
224 u64 Payload[HV_MESSAGE_PAYLOAD_QWORD_COUNT];
225 } u ;
228 /* Define the number of message buffers associated with each port. */
229 #define HV_PORT_MESSAGE_BUFFER_COUNT (16)
231 /* Define the synthetic interrupt message page layout. */
232 struct hv_message_page {
233 struct hv_message SintMessage[HV_SYNIC_SINT_COUNT];
236 /* Define the synthetic interrupt controller event flags format. */
237 union hv_synic_event_flags {
238 u8 Flags8[HV_EVENT_FLAGS_BYTE_COUNT];
239 u32 Flags32[HV_EVENT_FLAGS_DWORD_COUNT];
242 /* Define the synthetic interrupt flags page layout. */
243 struct hv_synic_event_flags_page {
244 union hv_synic_event_flags SintEventFlags[HV_SYNIC_SINT_COUNT];
247 /* Define SynIC control register. */
248 union hv_synic_scontrol {
249 u64 AsUINT64;
250 struct {
251 u64 Enable:1;
252 u64 Reserved:63;
256 /* Define synthetic interrupt source. */
257 union hv_synic_sint {
258 u64 AsUINT64;
259 struct {
260 u64 Vector:8;
261 u64 Reserved1:8;
262 u64 Masked:1;
263 u64 AutoEoi:1;
264 u64 Reserved2:46;
268 /* Define the format of the SIMP register */
269 union hv_synic_simp {
270 u64 AsUINT64;
271 struct {
272 u64 SimpEnabled:1;
273 u64 Preserved:11;
274 u64 BaseSimpGpa:52;
278 /* Define the format of the SIEFP register */
279 union hv_synic_siefp {
280 u64 AsUINT64;
281 struct {
282 u64 SiefpEnabled:1;
283 u64 Preserved:11;
284 u64 BaseSiefpGpa:52;
288 /* Definitions for the monitored notification facility */
289 union hv_monitor_trigger_group {
290 u64 AsUINT64;
291 struct {
292 u32 Pending;
293 u32 Armed;
297 struct hv_monitor_parameter {
298 union hv_connection_id ConnectionId;
299 u16 FlagNumber;
300 u16 RsvdZ;
303 union hv_monitor_trigger_state {
304 u32 Asu32;
306 struct {
307 u32 GroupEnable:4;
308 u32 RsvdZ:28;
312 /* struct hv_monitor_page Layout */
313 /* ------------------------------------------------------ */
314 /* | 0 | TriggerState (4 bytes) | Rsvd1 (4 bytes) | */
315 /* | 8 | TriggerGroup[0] | */
316 /* | 10 | TriggerGroup[1] | */
317 /* | 18 | TriggerGroup[2] | */
318 /* | 20 | TriggerGroup[3] | */
319 /* | 28 | Rsvd2[0] | */
320 /* | 30 | Rsvd2[1] | */
321 /* | 38 | Rsvd2[2] | */
322 /* | 40 | NextCheckTime[0][0] | NextCheckTime[0][1] | */
323 /* | ... | */
324 /* | 240 | Latency[0][0..3] | */
325 /* | 340 | Rsvz3[0] | */
326 /* | 440 | Parameter[0][0] | */
327 /* | 448 | Parameter[0][1] | */
328 /* | ... | */
329 /* | 840 | Rsvd4[0] | */
330 /* ------------------------------------------------------ */
331 struct hv_monitor_page {
332 union hv_monitor_trigger_state TriggerState;
333 u32 RsvdZ1;
335 union hv_monitor_trigger_group TriggerGroup[4];
336 u64 RsvdZ2[3];
338 s32 NextCheckTime[4][32];
340 u16 Latency[4][32];
341 u64 RsvdZ3[32];
343 struct hv_monitor_parameter Parameter[4][32];
345 u8 RsvdZ4[1984];
348 /* Declare the various hypercall operations. */
349 enum hv_call_code {
350 HvCallPostMessage = 0x005c,
351 HvCallSignalEvent = 0x005d,
354 /* Definition of the HvPostMessage hypercall input structure. */
355 struct hv_input_post_message {
356 union hv_connection_id ConnectionId;
357 u32 Reserved;
358 enum hv_message_type MessageType;
359 u32 PayloadSize;
360 u64 Payload[HV_MESSAGE_PAYLOAD_QWORD_COUNT];
363 /* Definition of the HvSignalEvent hypercall input structure. */
364 struct hv_input_signal_event {
365 union hv_connection_id ConnectionId;
366 u16 FlagNumber;
367 u16 RsvdZ;
371 * Versioning definitions used for guests reporting themselves to the
372 * hypervisor, and visa versa.
375 /* Version info reported by guest OS's */
376 enum hv_guest_os_vendor {
377 HvGuestOsVendorMicrosoft = 0x0001
380 enum hv_guest_os_microsoft_ids {
381 HvGuestOsMicrosoftUndefined = 0x00,
382 HvGuestOsMicrosoftMSDOS = 0x01,
383 HvGuestOsMicrosoftWindows3x = 0x02,
384 HvGuestOsMicrosoftWindows9x = 0x03,
385 HvGuestOsMicrosoftWindowsNT = 0x04,
386 HvGuestOsMicrosoftWindowsCE = 0x05
390 * Declare the MSR used to identify the guest OS.
392 #define HV_X64_MSR_GUEST_OS_ID 0x40000000
394 union hv_x64_msr_guest_os_id_contents {
395 u64 AsUINT64;
396 struct {
397 u64 BuildNumber:16;
398 u64 ServiceVersion:8; /* Service Pack, etc. */
399 u64 MinorVersion:8;
400 u64 MajorVersion:8;
401 u64 OsId:8; /* enum hv_guest_os_microsoft_ids (if Vendor=MS) */
402 u64 VendorId:16; /* enum hv_guest_os_vendor */
407 * Declare the MSR used to setup pages used to communicate with the hypervisor.
409 #define HV_X64_MSR_HYPERCALL 0x40000001
411 union hv_x64_msr_hypercall_contents {
412 u64 AsUINT64;
413 struct {
414 u64 Enable:1;
415 u64 Reserved:11;
416 u64 GuestPhysicalAddress:52;
420 #endif