Merge branches 'amd-iommu/fixes' and 'dma-debug/fixes' into iommu/fixes
[linux-2.6-block.git] / drivers / staging / hv / Hv.h
CommitLineData
3e7ee490
HJ
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
6658be6a 28#include "hv_api.h"
3e7ee490 29
98d9fac4
GKH
30enum {
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,
3e7ee490 38};
454f18a9
BP
39
40/* #defines */
41
98d9fac4 42#define HV_PRESENT_BIT 0x80000000
3e7ee490 43
98d9fac4 44#define HV_XENLINUX_GUEST_ID_LO 0x00000000
3e7ee490 45#define HV_XENLINUX_GUEST_ID_HI 0x0B00B135
98d9fac4
GKH
46#define HV_XENLINUX_GUEST_ID (((u64)HV_XENLINUX_GUEST_ID_HI << 32) \
47 | HV_XENLINUX_GUEST_ID_LO)
3e7ee490
HJ
48
49#define HV_LINUX_GUEST_ID_LO 0x00000000
50#define HV_LINUX_GUEST_ID_HI 0xB16B00B5
98d9fac4
GKH
51#define HV_LINUX_GUEST_ID (((u64)HV_LINUX_GUEST_ID_HI << 32) | \
52 HV_LINUX_GUEST_ID_LO)
3e7ee490 53
98d9fac4
GKH
54#define HV_CPU_POWER_MANAGEMENT (1 << 0)
55#define HV_RECOMMENDATIONS_MAX 4
3e7ee490 56
98d9fac4
GKH
57#define HV_X64_MAX 5
58#define HV_CAPS_MAX 8
3e7ee490
HJ
59
60
59471438 61#define HV_HYPERCALL_PARAM_ALIGN sizeof(u64)
3e7ee490 62
454f18a9
BP
63
64/* Service definitions */
65
98d9fac4
GKH
66#define HV_SERVICE_PARENT_PORT (0)
67#define HV_SERVICE_PARENT_CONNECTION (0)
3e7ee490 68
98d9fac4
GKH
69#define HV_SERVICE_CONNECT_RESPONSE_SUCCESS (0)
70#define HV_SERVICE_CONNECT_RESPONSE_INVALID_PARAMETER (1)
71#define HV_SERVICE_CONNECT_RESPONSE_UNKNOWN_SERVICE (2)
72#define HV_SERVICE_CONNECT_RESPONSE_CONNECTION_REJECTED (3)
3e7ee490
HJ
73
74#define HV_SERVICE_CONNECT_REQUEST_MESSAGE_ID (1)
75#define HV_SERVICE_CONNECT_RESPONSE_MESSAGE_ID (2)
76#define HV_SERVICE_DISCONNECT_REQUEST_MESSAGE_ID (3)
77#define HV_SERVICE_DISCONNECT_RESPONSE_MESSAGE_ID (4)
98d9fac4 78#define HV_SERVICE_MAX_MESSAGE_ID (4)
3e7ee490
HJ
79
80#define HV_SERVICE_PROTOCOL_VERSION (0x0010)
81#define HV_CONNECT_PAYLOAD_BYTE_COUNT 64
82
454f18a9 83/* #define VMBUS_REVISION_NUMBER 6 */
98d9fac4
GKH
84
85/* Our local vmbus's port and connection id. Anything >0 is fine */
86/* #define VMBUS_PORT_ID 11 */
3e7ee490 87
454f18a9 88/* 628180B8-308D-4c5e-B7DB-1BEB62E62EF4 */
caf26a31
GKH
89static const struct hv_guid VMBUS_SERVICE_ID = {
90 .data = {
98d9fac4
GKH
91 0xb8, 0x80, 0x81, 0x62, 0x8d, 0x30, 0x5e, 0x4c,
92 0xb7, 0xdb, 0x1b, 0xeb, 0x62, 0xe6, 0x2e, 0xf4
93 },
94};
3e7ee490 95
7692fd4d 96#define MAX_NUM_CPUS 32
3e7ee490
HJ
97
98
af248e1f 99struct hv_input_signal_event_buffer {
98d9fac4 100 u64 Align8;
cba4decd 101 struct hv_input_signal_event Event;
af248e1f 102};
3e7ee490 103
af248e1f 104struct hv_context {
98d9fac4
GKH
105 /* XenLinux or native Linux. If XenLinux, the hypercall and synic pages
106 * has already been initialized */
107 u64 GuestId;
108
109 void *HypercallPage;
3e7ee490 110
98d9fac4
GKH
111 bool SynICInitialized;
112
113 /*
114 * This is used as an input param to HvCallSignalEvent hypercall. The
115 * input param is immutable in our usage and must be dynamic mem (vs
116 * stack or global). */
af248e1f 117 struct hv_input_signal_event_buffer *SignalEventBuffer;
98d9fac4 118 /* 8-bytes aligned of the buffer above */
cba4decd 119 struct hv_input_signal_event *SignalEventParam;
3e7ee490 120
44f357f8
BP
121 void *synICMessagePage[MAX_NUM_CPUS];
122 void *synICEventPage[MAX_NUM_CPUS];
af248e1f 123};
3e7ee490 124
af248e1f 125extern struct hv_context gHvContext;
3e7ee490
HJ
126
127
454f18a9
BP
128/* Hv Interface */
129
98d9fac4
GKH
130extern int HvInit(void);
131
132extern void HvCleanup(void);
133
034469e6
GKH
134extern u16 HvPostMessage(union hv_connection_id connectionId,
135 enum hv_message_type messageType,
136 void *payload, size_t payloadSize);
98d9fac4 137
034469e6 138extern u16 HvSignalEvent(void);
98d9fac4 139
7692fd4d 140extern void HvSynicInit(void *irqarg);
98d9fac4 141
7692fd4d 142extern void HvSynicCleanup(void *arg);
3e7ee490 143
454f18a9 144#endif /* __HV_H__ */