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>
27 /* #ifndef PAGE_SIZE */
28 /* #if defined(_IA64_) */
29 /* #error This does not work for IA64 */
31 /* #define PAGE_SIZE 0x1000 */
35 /* allow nameless unions */
36 /* #pragma warning(disable : 4201) */
44 volatile u32 In
; /* Offset in bytes from the ring base */
45 volatile u32 Out
; /* Offset in bytes from the ring base */
47 volatile long long InOut
;
51 /* If the receiving endpoint sets this to some non-zero value, the sending */
52 /* endpoint should not send any interrupts. */
55 volatile u32 InterruptMask
;
68 u8 Reserved
[PAGE_SIZE
];
72 /* Beginning of the ring data. Note: It must be guaranteed that */
73 /* this data does not share a page with the control structure. */
87 } VMPACKET_DESCRIPTOR
, *PVMPACKET_DESCRIPTOR
;
89 typedef u32 PREVIOUS_PACKET_OFFSET
, *PPREVIOUS_PACKET_OFFSET
;
93 PREVIOUS_PACKET_OFFSET PreviousPacketStartOffset
;
94 VMPACKET_DESCRIPTOR Descriptor
;
95 } VMPACKET_HEADER
, *PVMPACKET_HEADER
;
101 } VMTRANSFER_PAGE_RANGE
, *PVMTRANSFER_PAGE_RANGE
;
105 typedef struct _VMTRANSFER_PAGE_PACKET_HEADER
: VMPACKET_DESCRIPTOR
{
109 typedef struct VMTRANSFER_PAGE_PACKET_HEADER
{
111 VMPACKET_DESCRIPTOR d
;
115 u16 TransferPageSetId
;
119 VMTRANSFER_PAGE_RANGE Ranges
[1];
121 } VMTRANSFER_PAGE_PACKET_HEADER
, *PVMTRANSFER_PAGE_PACKET_HEADER
;
126 typedef struct _VMGPADL_PACKET_HEADER
: VMPACKET_DESCRIPTOR
{
130 typedef struct _VMGPADL_PACKET_HEADER
{
132 VMPACKET_DESCRIPTOR d
;
140 } VMGPADL_PACKET_HEADER
, *PVMGPADL_PACKET_HEADER
;
144 typedef struct _VMADD_REMOVE_TRANSFER_PAGE_SET
: VMPACKET_DESCRIPTOR
{
148 typedef struct _VMADD_REMOVE_TRANSFER_PAGE_SET
{
150 VMPACKET_DESCRIPTOR d
;
155 u16 TransferPageSetId
;
158 } VMADD_REMOVE_TRANSFER_PAGE_SET
, *PVMADD_REMOVE_TRANSFER_PAGE_SET
;
163 /* This structure defines a range in guest physical space that can be made */
164 /* to look virtually contiguous. */
167 typedef struct _GPA_RANGE
{
173 } GPA_RANGE
, *PGPA_RANGE
;
177 #pragma pack(push, 1)
180 /* This is the format for an Establish Gpadl packet, which contains a handle */
181 /* by which this GPADL will be known and a set of GPA ranges associated with */
182 /* it. This can be converted to a MDL by the guest OS. If there are multiple */
183 /* GPA ranges, then the resulting MDL will be "chained," representing multiple */
189 typedef struct _VMESTABLISH_GPADL
: VMPACKET_DESCRIPTOR
{
193 typedef struct _VMESTABLISH_GPADL
{
195 VMPACKET_DESCRIPTOR d
;
203 } VMESTABLISH_GPADL
, *PVMESTABLISH_GPADL
;
207 /* This is the format for a Teardown Gpadl packet, which indicates that the */
208 /* GPADL handle in the Establish Gpadl packet will never be referenced again. */
213 typedef struct _VMTEARDOWN_GPADL
: VMPACKET_DESCRIPTOR
{
217 typedef struct _VMTEARDOWN_GPADL
{
219 VMPACKET_DESCRIPTOR d
;
224 u32 Reserved
; /* for alignment to a 8-byte boundary */
225 } VMTEARDOWN_GPADL
, *PVMTEARDOWN_GPADL
;
229 /* This is the format for a GPA-Direct packet, which contains a set of GPA */
230 /* ranges, in addition to commands and/or data. */
235 typedef struct _VMDATA_GPA_DIRECT
: VMPACKET_DESCRIPTOR
{
239 typedef struct _VMDATA_GPA_DIRECT
{
241 VMPACKET_DESCRIPTOR d
;
249 } VMDATA_GPA_DIRECT
, *PVMDATA_GPA_DIRECT
;
254 /* This is the format for a Additional Data Packet. */
259 typedef struct _VMADDITIONAL_DATA
: VMPACKET_DESCRIPTOR
{
263 typedef struct _VMADDITIONAL_DATA
{
265 VMPACKET_DESCRIPTOR d
;
272 unsigned char Data
[1];
274 } VMADDITIONAL_DATA
, *PVMADDITIONAL_DATA
;
280 VMPACKET_DESCRIPTOR SimpleHeader
;
281 VMTRANSFER_PAGE_PACKET_HEADER TransferPageHeader
;
282 VMGPADL_PACKET_HEADER GpadlHeader
;
283 VMADD_REMOVE_TRANSFER_PAGE_SET AddRemoveTransferPageHeader
;
284 VMESTABLISH_GPADL EstablishGpadlHeader
;
285 VMTEARDOWN_GPADL TeardownGpadlHeader
;
286 VMDATA_GPA_DIRECT DataGpaDirectHeader
;
287 } VMPACKET_LARGEST_POSSIBLE_HEADER
, *PVMPACKET_LARGEST_POSSIBLE_HEADER
;
289 #define VMPACKET_DATA_START_ADDRESS(__packet) \
290 (void *)(((unsigned char *)__packet) + ((PVMPACKET_DESCRIPTOR)__packet)->DataOffset8 * 8)
292 #define VMPACKET_DATA_LENGTH(__packet) \
293 ((((PVMPACKET_DESCRIPTOR)__packet)->Length8 - ((PVMPACKET_DESCRIPTOR)__packet)->DataOffset8) * 8)
295 #define VMPACKET_TRANSFER_MODE(__packet) ((PVMPACKET_DESCRIPTOR)__packet)->Type
298 VmbusServerEndpoint
= 0,
301 } ENDPOINT_TYPE
, *PENDPOINT_TYPE
;
304 VmbusPacketTypeInvalid
= 0x0,
305 VmbusPacketTypeSynch
= 0x1,
306 VmbusPacketTypeAddTransferPageSet
= 0x2,
307 VmbusPacketTypeRemoveTransferPageSet
= 0x3,
308 VmbusPacketTypeEstablishGpadl
= 0x4,
309 VmbusPacketTypeTearDownGpadl
= 0x5,
310 VmbusPacketTypeDataInBand
= 0x6,
311 VmbusPacketTypeDataUsingTransferPages
= 0x7,
312 VmbusPacketTypeDataUsingGpadl
= 0x8,
313 VmbusPacketTypeDataUsingGpaDirect
= 0x9,
314 VmbusPacketTypeCancelRequest
= 0xa,
315 VmbusPacketTypeCompletion
= 0xb,
316 VmbusPacketTypeDataUsingAdditionalPackets
= 0xc,
317 VmbusPacketTypeAdditionalData
= 0xd
318 } VMBUS_PACKET_TYPE
, *PVMBUS_PACKET_TYPE
;
320 #define VMBUS_DATA_PACKET_FLAG_COMPLETION_REQUESTED 1