diff options
Diffstat (limited to 'drivers/staging/hv/VmbusPrivate.h')
-rw-r--r-- | drivers/staging/hv/VmbusPrivate.h | 170 |
1 files changed, 170 insertions, 0 deletions
diff --git a/drivers/staging/hv/VmbusPrivate.h b/drivers/staging/hv/VmbusPrivate.h new file mode 100644 index 00000000000..5e86165dea2 --- /dev/null +++ b/drivers/staging/hv/VmbusPrivate.h | |||
@@ -0,0 +1,170 @@ | |||
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 _VMBUS_PRIVATE_H_ | ||
26 | #define _VMBUS_PRIVATE_H_ | ||
27 | |||
28 | #ifndef INTERNAL | ||
29 | #define INTERNAL static | ||
30 | #endif | ||
31 | |||
32 | #include "Hv.h" | ||
33 | #include "VmbusApi.h" | ||
34 | #include "Channel.h" | ||
35 | #include "ChannelMgmt.h" | ||
36 | #include "ChannelInterface.h" | ||
37 | //#include "ChannelMessages.h" | ||
38 | #include "RingBuffer.h" | ||
39 | //#include "Packet.h" | ||
40 | #include "List.h" | ||
41 | |||
42 | // | ||
43 | // Defines | ||
44 | // | ||
45 | |||
46 | // Maximum channels is determined by the size of the interrupt page which is PAGE_SIZE. 1/2 of PAGE_SIZE is for | ||
47 | // send endpoint interrupt and the other is receive endpoint interrupt | ||
48 | #define MAX_NUM_CHANNELS (PAGE_SIZE >> 1) << 3 // 16348 channels | ||
49 | |||
50 | // The value here must be in multiple of 32 | ||
51 | // TODO: Need to make this configurable | ||
52 | #define MAX_NUM_CHANNELS_SUPPORTED 256 | ||
53 | |||
54 | // | ||
55 | // Data types | ||
56 | // | ||
57 | |||
58 | typedef enum { | ||
59 | Disconnected, | ||
60 | Connecting, | ||
61 | Connected, | ||
62 | Disconnecting | ||
63 | } VMBUS_CONNECT_STATE; | ||
64 | |||
65 | #define MAX_SIZE_CHANNEL_MESSAGE HV_MESSAGE_PAYLOAD_BYTE_COUNT | ||
66 | |||
67 | typedef struct _VMBUS_CONNECTION { | ||
68 | |||
69 | VMBUS_CONNECT_STATE ConnectState; | ||
70 | |||
71 | UINT32 NextGpadlHandle; | ||
72 | |||
73 | // Represents channel interrupts. Each bit position | ||
74 | // represents a channel. | ||
75 | // When a channel sends an interrupt via VMBUS, it | ||
76 | // finds its bit in the sendInterruptPage, set it and | ||
77 | // calls Hv to generate a port event. The other end | ||
78 | // receives the port event and parse the recvInterruptPage | ||
79 | // to see which bit is set | ||
80 | VOID* InterruptPage; | ||
81 | VOID* SendInterruptPage; | ||
82 | VOID* RecvInterruptPage; | ||
83 | |||
84 | // 2 pages - 1st page for parent->child notification and 2nd is child->parent notification | ||
85 | VOID* MonitorPages; | ||
86 | LIST_ENTRY ChannelMsgList; | ||
87 | HANDLE ChannelMsgLock; | ||
88 | |||
89 | // List of channels | ||
90 | LIST_ENTRY ChannelList; | ||
91 | HANDLE ChannelLock; | ||
92 | |||
93 | HANDLE WorkQueue; | ||
94 | } VMBUS_CONNECTION; | ||
95 | |||
96 | |||
97 | typedef struct _VMBUS_MSGINFO { | ||
98 | // Bookkeeping stuff | ||
99 | LIST_ENTRY MsgListEntry; | ||
100 | |||
101 | // Synchronize the request/response if needed | ||
102 | HANDLE WaitEvent; | ||
103 | |||
104 | // The message itself | ||
105 | unsigned char Msg[0]; | ||
106 | } VMBUS_MSGINFO; | ||
107 | |||
108 | |||
109 | // | ||
110 | // Externs | ||
111 | // | ||
112 | extern VMBUS_CONNECTION gVmbusConnection; | ||
113 | |||
114 | // | ||
115 | // General vmbus interface | ||
116 | // | ||
117 | INTERNAL DEVICE_OBJECT* | ||
118 | VmbusChildDeviceCreate( | ||
119 | GUID deviceType, | ||
120 | GUID deviceInstance, | ||
121 | void *context); | ||
122 | |||
123 | INTERNAL int | ||
124 | VmbusChildDeviceAdd( | ||
125 | DEVICE_OBJECT* Device); | ||
126 | |||
127 | INTERNAL void | ||
128 | VmbusChildDeviceRemove( | ||
129 | DEVICE_OBJECT* Device); | ||
130 | |||
131 | //INTERNAL void | ||
132 | //VmbusChildDeviceDestroy( | ||
133 | // DEVICE_OBJECT*); | ||
134 | |||
135 | INTERNAL VMBUS_CHANNEL* | ||
136 | GetChannelFromRelId( | ||
137 | UINT32 relId | ||
138 | ); | ||
139 | |||
140 | // | ||
141 | // Connection interface | ||
142 | // | ||
143 | INTERNAL int | ||
144 | VmbusConnect( | ||
145 | VOID | ||
146 | ); | ||
147 | |||
148 | INTERNAL int | ||
149 | VmbusDisconnect( | ||
150 | VOID | ||
151 | ); | ||
152 | |||
153 | INTERNAL int | ||
154 | VmbusPostMessage( | ||
155 | PVOID buffer, | ||
156 | SIZE_T bufSize | ||
157 | ); | ||
158 | |||
159 | INTERNAL int | ||
160 | VmbusSetEvent( | ||
161 | UINT32 childRelId | ||
162 | ); | ||
163 | |||
164 | INTERNAL VOID | ||
165 | VmbusOnEvents( | ||
166 | VOID | ||
167 | ); | ||
168 | |||
169 | |||
170 | #endif // _VMBUS_PRIVATE_H_ | ||