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
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.
19 * Haiyang Zhang <haiyangz@microsoft.com>
20 * Hank Janssen <hjanssen@microsoft.com>
28 #include "include/HvStatus.h"
32 VMBUS_MESSAGE_CONNECTION_ID
= 1,
33 VMBUS_MESSAGE_PORT_ID
= 1,
34 VMBUS_EVENT_CONNECTION_ID
= 2,
35 VMBUS_EVENT_PORT_ID
= 2,
36 VMBUS_MONITOR_CONNECTION_ID
= 3,
37 VMBUS_MONITOR_PORT_ID
= 3,
38 VMBUS_MESSAGE_SINT
= 2,
43 #define HV_PRESENT_BIT 0x80000000
45 #define HV_XENLINUX_GUEST_ID_LO 0x00000000
46 #define HV_XENLINUX_GUEST_ID_HI 0x0B00B135
47 #define HV_XENLINUX_GUEST_ID (((u64)HV_XENLINUX_GUEST_ID_HI << 32) \
48 | HV_XENLINUX_GUEST_ID_LO)
50 #define HV_LINUX_GUEST_ID_LO 0x00000000
51 #define HV_LINUX_GUEST_ID_HI 0xB16B00B5
52 #define HV_LINUX_GUEST_ID (((u64)HV_LINUX_GUEST_ID_HI << 32) | \
55 #define HV_CPU_POWER_MANAGEMENT (1 << 0)
56 #define HV_RECOMMENDATIONS_MAX 4
62 #define HV_HYPERCALL_PARAM_ALIGN sizeof(u64)
65 /* Service definitions */
67 #define HV_SERVICE_PARENT_PORT (0)
68 #define HV_SERVICE_PARENT_CONNECTION (0)
70 #define HV_SERVICE_CONNECT_RESPONSE_SUCCESS (0)
71 #define HV_SERVICE_CONNECT_RESPONSE_INVALID_PARAMETER (1)
72 #define HV_SERVICE_CONNECT_RESPONSE_UNKNOWN_SERVICE (2)
73 #define HV_SERVICE_CONNECT_RESPONSE_CONNECTION_REJECTED (3)
75 #define HV_SERVICE_CONNECT_REQUEST_MESSAGE_ID (1)
76 #define HV_SERVICE_CONNECT_RESPONSE_MESSAGE_ID (2)
77 #define HV_SERVICE_DISCONNECT_REQUEST_MESSAGE_ID (3)
78 #define HV_SERVICE_DISCONNECT_RESPONSE_MESSAGE_ID (4)
79 #define HV_SERVICE_MAX_MESSAGE_ID (4)
81 #define HV_SERVICE_PROTOCOL_VERSION (0x0010)
82 #define HV_CONNECT_PAYLOAD_BYTE_COUNT 64
84 /* #define VMBUS_REVISION_NUMBER 6 */
86 /* Our local vmbus's port and connection id. Anything >0 is fine */
87 /* #define VMBUS_PORT_ID 11 */
89 /* 628180B8-308D-4c5e-B7DB-1BEB62E62EF4 */
90 static const struct hv_guid VMBUS_SERVICE_ID
= {
92 0xb8, 0x80, 0x81, 0x62, 0x8d, 0x30, 0x5e, 0x4c,
93 0xb7, 0xdb, 0x1b, 0xeb, 0x62, 0xe6, 0x2e, 0xf4
97 #define MAX_NUM_CPUS 1
100 struct hv_input_signal_event_buffer
{
102 struct hv_input_signal_event Event
;
106 /* XenLinux or native Linux. If XenLinux, the hypercall and synic pages
107 * has already been initialized */
112 bool SynICInitialized
;
115 * This is used as an input param to HvCallSignalEvent hypercall. The
116 * input param is immutable in our usage and must be dynamic mem (vs
117 * stack or global). */
118 struct hv_input_signal_event_buffer
*SignalEventBuffer
;
119 /* 8-bytes aligned of the buffer above */
120 struct hv_input_signal_event
*SignalEventParam
;
122 void *synICMessagePage
[MAX_NUM_CPUS
];
123 void *synICEventPage
[MAX_NUM_CPUS
];
126 extern struct hv_context gHvContext
;
131 extern int HvInit(void);
133 extern void HvCleanup(void);
135 extern HV_STATUS
HvPostMessage(union hv_connection_id connectionId
,
136 enum hv_message_type messageType
,
140 extern HV_STATUS
HvSignalEvent(void);
142 extern int HvSynicInit(u32 irqVector
);
144 extern void HvSynicCleanup(void);
146 #endif /* __HV_H__ */