blob: 41f5ebb86e17579de40dc50d7bc35b1b72b1ce74 [file] [log] [blame]
Hank Janssen3e7ee492009-07-13 16:02:34 -07001/*
2 *
3 * Copyright (c) 2009, Microsoft Corporation.
4 *
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.
8 *
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.
13 *
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.
17 *
18 * Authors:
19 * Haiyang Zhang <haiyangz@microsoft.com>
20 * Hank Janssen <hjanssen@microsoft.com>
21 *
22 */
23
24
25#ifndef __HV_H__
26#define __HV_H__
27
Greg Kroah-Hartman6658be62009-08-20 12:13:27 -070028#include "hv_api.h"
Hank Janssen3e7ee492009-07-13 16:02:34 -070029
Greg Kroah-Hartman98d9fac2009-08-17 17:20:55 -070030enum {
31 VMBUS_MESSAGE_CONNECTION_ID = 1,
32 VMBUS_MESSAGE_PORT_ID = 1,
33 VMBUS_EVENT_CONNECTION_ID = 2,
34 VMBUS_EVENT_PORT_ID = 2,
35 VMBUS_MONITOR_CONNECTION_ID = 3,
36 VMBUS_MONITOR_PORT_ID = 3,
37 VMBUS_MESSAGE_SINT = 2,
Hank Janssen3e7ee492009-07-13 16:02:34 -070038};
Bill Pemberton454f18a2009-07-27 16:47:24 -040039
40/* #defines */
41
Greg Kroah-Hartman98d9fac2009-08-17 17:20:55 -070042#define HV_PRESENT_BIT 0x80000000
Hank Janssen3e7ee492009-07-13 16:02:34 -070043
Hank Janssen3e7ee492009-07-13 16:02:34 -070044#define HV_LINUX_GUEST_ID_LO 0x00000000
45#define HV_LINUX_GUEST_ID_HI 0xB16B00B5
Greg Kroah-Hartman98d9fac2009-08-17 17:20:55 -070046#define HV_LINUX_GUEST_ID (((u64)HV_LINUX_GUEST_ID_HI << 32) | \
47 HV_LINUX_GUEST_ID_LO)
Hank Janssen3e7ee492009-07-13 16:02:34 -070048
Greg Kroah-Hartman98d9fac2009-08-17 17:20:55 -070049#define HV_CPU_POWER_MANAGEMENT (1 << 0)
50#define HV_RECOMMENDATIONS_MAX 4
Hank Janssen3e7ee492009-07-13 16:02:34 -070051
Greg Kroah-Hartman98d9fac2009-08-17 17:20:55 -070052#define HV_X64_MAX 5
53#define HV_CAPS_MAX 8
Hank Janssen3e7ee492009-07-13 16:02:34 -070054
55
Greg Kroah-Hartman59471432009-07-14 15:10:26 -070056#define HV_HYPERCALL_PARAM_ALIGN sizeof(u64)
Hank Janssen3e7ee492009-07-13 16:02:34 -070057
Bill Pemberton454f18a2009-07-27 16:47:24 -040058
59/* Service definitions */
60
Greg Kroah-Hartman98d9fac2009-08-17 17:20:55 -070061#define HV_SERVICE_PARENT_PORT (0)
62#define HV_SERVICE_PARENT_CONNECTION (0)
Hank Janssen3e7ee492009-07-13 16:02:34 -070063
Greg Kroah-Hartman98d9fac2009-08-17 17:20:55 -070064#define HV_SERVICE_CONNECT_RESPONSE_SUCCESS (0)
65#define HV_SERVICE_CONNECT_RESPONSE_INVALID_PARAMETER (1)
66#define HV_SERVICE_CONNECT_RESPONSE_UNKNOWN_SERVICE (2)
67#define HV_SERVICE_CONNECT_RESPONSE_CONNECTION_REJECTED (3)
Hank Janssen3e7ee492009-07-13 16:02:34 -070068
69#define HV_SERVICE_CONNECT_REQUEST_MESSAGE_ID (1)
70#define HV_SERVICE_CONNECT_RESPONSE_MESSAGE_ID (2)
71#define HV_SERVICE_DISCONNECT_REQUEST_MESSAGE_ID (3)
72#define HV_SERVICE_DISCONNECT_RESPONSE_MESSAGE_ID (4)
Greg Kroah-Hartman98d9fac2009-08-17 17:20:55 -070073#define HV_SERVICE_MAX_MESSAGE_ID (4)
Hank Janssen3e7ee492009-07-13 16:02:34 -070074
75#define HV_SERVICE_PROTOCOL_VERSION (0x0010)
76#define HV_CONNECT_PAYLOAD_BYTE_COUNT 64
77
Bill Pemberton454f18a2009-07-27 16:47:24 -040078/* #define VMBUS_REVISION_NUMBER 6 */
Greg Kroah-Hartman98d9fac2009-08-17 17:20:55 -070079
80/* Our local vmbus's port and connection id. Anything >0 is fine */
81/* #define VMBUS_PORT_ID 11 */
Hank Janssen3e7ee492009-07-13 16:02:34 -070082
Bill Pemberton454f18a2009-07-27 16:47:24 -040083/* 628180B8-308D-4c5e-B7DB-1BEB62E62EF4 */
Greg Kroah-Hartmancaf26a32009-08-19 16:17:03 -070084static const struct hv_guid VMBUS_SERVICE_ID = {
85 .data = {
Greg Kroah-Hartman98d9fac2009-08-17 17:20:55 -070086 0xb8, 0x80, 0x81, 0x62, 0x8d, 0x30, 0x5e, 0x4c,
87 0xb7, 0xdb, 0x1b, 0xeb, 0x62, 0xe6, 0x2e, 0xf4
88 },
89};
Hank Janssen3e7ee492009-07-13 16:02:34 -070090
Greg Kroah-Hartman7692fd42010-01-08 09:06:40 -080091#define MAX_NUM_CPUS 32
Hank Janssen3e7ee492009-07-13 16:02:34 -070092
93
Greg Kroah-Hartmanaf248e12009-08-18 15:20:34 -070094struct hv_input_signal_event_buffer {
Greg Kroah-Hartman98d9fac2009-08-17 17:20:55 -070095 u64 Align8;
Greg Kroah-Hartmancba4dec2009-08-19 16:21:28 -070096 struct hv_input_signal_event Event;
Greg Kroah-Hartmanaf248e12009-08-18 15:20:34 -070097};
Hank Janssen3e7ee492009-07-13 16:02:34 -070098
Greg Kroah-Hartmanaf248e12009-08-18 15:20:34 -070099struct hv_context {
Hank Janssena73e6b72010-01-22 19:17:50 +0000100 /* We only support running on top of Hyper-V
101 * So at this point this really can only contain the Hyper-V ID
102 */
Greg Kroah-Hartman98d9fac2009-08-17 17:20:55 -0700103 u64 GuestId;
Hank Janssen3e7ee492009-07-13 16:02:34 -0700104
Greg Kroah-Hartman98d9fac2009-08-17 17:20:55 -0700105 void *HypercallPage;
106
107 bool SynICInitialized;
108
109 /*
110 * This is used as an input param to HvCallSignalEvent hypercall. The
111 * input param is immutable in our usage and must be dynamic mem (vs
112 * stack or global). */
Greg Kroah-Hartmanaf248e12009-08-18 15:20:34 -0700113 struct hv_input_signal_event_buffer *SignalEventBuffer;
Greg Kroah-Hartman98d9fac2009-08-17 17:20:55 -0700114 /* 8-bytes aligned of the buffer above */
Greg Kroah-Hartmancba4dec2009-08-19 16:21:28 -0700115 struct hv_input_signal_event *SignalEventParam;
Hank Janssen3e7ee492009-07-13 16:02:34 -0700116
Bill Pemberton44f357f2009-07-28 13:46:26 -0400117 void *synICMessagePage[MAX_NUM_CPUS];
118 void *synICEventPage[MAX_NUM_CPUS];
Greg Kroah-Hartmanaf248e12009-08-18 15:20:34 -0700119};
Hank Janssen3e7ee492009-07-13 16:02:34 -0700120
Greg Kroah-Hartmanaf248e12009-08-18 15:20:34 -0700121extern struct hv_context gHvContext;
Hank Janssen3e7ee492009-07-13 16:02:34 -0700122
123
Bill Pemberton454f18a2009-07-27 16:47:24 -0400124/* Hv Interface */
125
Greg Kroah-Hartman98d9fac2009-08-17 17:20:55 -0700126extern int HvInit(void);
Hank Janssen3e7ee492009-07-13 16:02:34 -0700127
Greg Kroah-Hartman98d9fac2009-08-17 17:20:55 -0700128extern void HvCleanup(void);
Hank Janssen3e7ee492009-07-13 16:02:34 -0700129
Greg Kroah-Hartman034469e2009-08-20 12:14:11 -0700130extern u16 HvPostMessage(union hv_connection_id connectionId,
131 enum hv_message_type messageType,
132 void *payload, size_t payloadSize);
Hank Janssen3e7ee492009-07-13 16:02:34 -0700133
Greg Kroah-Hartman034469e2009-08-20 12:14:11 -0700134extern u16 HvSignalEvent(void);
Hank Janssen3e7ee492009-07-13 16:02:34 -0700135
Greg Kroah-Hartman7692fd42010-01-08 09:06:40 -0800136extern void HvSynicInit(void *irqarg);
Hank Janssen3e7ee492009-07-13 16:02:34 -0700137
Greg Kroah-Hartman7692fd42010-01-08 09:06:40 -0800138extern void HvSynicCleanup(void *arg);
Hank Janssen3e7ee492009-07-13 16:02:34 -0700139
Bill Pemberton454f18a2009-07-27 16:47:24 -0400140#endif /* __HV_H__ */