]> git.proxmox.com Git - mirror_ubuntu-bionic-kernel.git/blob - drivers/staging/hv/Hv.h
Staging: hv: osd.h: remove GUID typedef
[mirror_ubuntu-bionic-kernel.git] / drivers / staging / hv / Hv.h
1 /*
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
28 #include "include/HvTypes.h"
29 #include "include/HvStatus.h"
30 #include "include/HvHalApi.h"
31 #include "include/HvVpApi.h"
32 #include "include/HvSynicApi.h"
33 #include "include/HvHcApi.h"
34 #include "include/HvPtApi.h"
35
36 enum {
37 VMBUS_MESSAGE_CONNECTION_ID = 1,
38 VMBUS_MESSAGE_PORT_ID = 1,
39 VMBUS_EVENT_CONNECTION_ID = 2,
40 VMBUS_EVENT_PORT_ID = 2,
41 VMBUS_MONITOR_CONNECTION_ID = 3,
42 VMBUS_MONITOR_PORT_ID = 3,
43 VMBUS_MESSAGE_SINT = 2,
44 };
45
46 /* #defines */
47
48 #define HV_PRESENT_BIT 0x80000000
49
50 #define HV_XENLINUX_GUEST_ID_LO 0x00000000
51 #define HV_XENLINUX_GUEST_ID_HI 0x0B00B135
52 #define HV_XENLINUX_GUEST_ID (((u64)HV_XENLINUX_GUEST_ID_HI << 32) \
53 | HV_XENLINUX_GUEST_ID_LO)
54
55 #define HV_LINUX_GUEST_ID_LO 0x00000000
56 #define HV_LINUX_GUEST_ID_HI 0xB16B00B5
57 #define HV_LINUX_GUEST_ID (((u64)HV_LINUX_GUEST_ID_HI << 32) | \
58 HV_LINUX_GUEST_ID_LO)
59
60 #define HV_CPU_POWER_MANAGEMENT (1 << 0)
61 #define HV_RECOMMENDATIONS_MAX 4
62
63 #define HV_X64_MAX 5
64 #define HV_CAPS_MAX 8
65
66
67 #define HV_HYPERCALL_PARAM_ALIGN sizeof(u64)
68
69
70 /* Service definitions */
71
72 #define HV_SERVICE_PARENT_PORT (0)
73 #define HV_SERVICE_PARENT_CONNECTION (0)
74
75 #define HV_SERVICE_CONNECT_RESPONSE_SUCCESS (0)
76 #define HV_SERVICE_CONNECT_RESPONSE_INVALID_PARAMETER (1)
77 #define HV_SERVICE_CONNECT_RESPONSE_UNKNOWN_SERVICE (2)
78 #define HV_SERVICE_CONNECT_RESPONSE_CONNECTION_REJECTED (3)
79
80 #define HV_SERVICE_CONNECT_REQUEST_MESSAGE_ID (1)
81 #define HV_SERVICE_CONNECT_RESPONSE_MESSAGE_ID (2)
82 #define HV_SERVICE_DISCONNECT_REQUEST_MESSAGE_ID (3)
83 #define HV_SERVICE_DISCONNECT_RESPONSE_MESSAGE_ID (4)
84 #define HV_SERVICE_MAX_MESSAGE_ID (4)
85
86 #define HV_SERVICE_PROTOCOL_VERSION (0x0010)
87 #define HV_CONNECT_PAYLOAD_BYTE_COUNT 64
88
89 /* #define VMBUS_REVISION_NUMBER 6 */
90
91 /* Our local vmbus's port and connection id. Anything >0 is fine */
92 /* #define VMBUS_PORT_ID 11 */
93
94 /* 628180B8-308D-4c5e-B7DB-1BEB62E62EF4 */
95 static const struct hv_guid VMBUS_SERVICE_ID = {
96 .data = {
97 0xb8, 0x80, 0x81, 0x62, 0x8d, 0x30, 0x5e, 0x4c,
98 0xb7, 0xdb, 0x1b, 0xeb, 0x62, 0xe6, 0x2e, 0xf4
99 },
100 };
101
102 #define MAX_NUM_CPUS 1
103
104
105 struct hv_input_signal_event_buffer {
106 u64 Align8;
107 HV_INPUT_SIGNAL_EVENT Event;
108 };
109
110 struct hv_context {
111 /* XenLinux or native Linux. If XenLinux, the hypercall and synic pages
112 * has already been initialized */
113 u64 GuestId;
114
115 void *HypercallPage;
116
117 bool SynICInitialized;
118
119 /*
120 * This is used as an input param to HvCallSignalEvent hypercall. The
121 * input param is immutable in our usage and must be dynamic mem (vs
122 * stack or global). */
123 struct hv_input_signal_event_buffer *SignalEventBuffer;
124 /* 8-bytes aligned of the buffer above */
125 HV_INPUT_SIGNAL_EVENT *SignalEventParam;
126
127 void *synICMessagePage[MAX_NUM_CPUS];
128 void *synICEventPage[MAX_NUM_CPUS];
129 };
130
131 extern struct hv_context gHvContext;
132
133
134 /* Hv Interface */
135
136 extern int HvInit(void);
137
138 extern void HvCleanup(void);
139
140 extern HV_STATUS HvPostMessage(HV_CONNECTION_ID connectionId,
141 HV_MESSAGE_TYPE messageType,
142 void *payload,
143 size_t payloadSize);
144
145 extern HV_STATUS HvSignalEvent(void);
146
147 extern int HvSynicInit(u32 irqVector);
148
149 extern void HvSynicCleanup(void);
150
151 #endif /* __HV_H__ */