Commit 565e7dc8 authored by Hank Janssen's avatar Hank Janssen Committed by Greg Kroah-Hartman

Staging: hv: add the Hyper-V api header files

These are the header files for the API to talk to the Hyper-V
core.
Signed-off-by: default avatarHank Janssen <hjanssen@microsoft.com>
Signed-off-by: default avatarHaiyang Zhang <haiyangz@microsoft.com>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@suse.de>
parent 578f2938
This diff is collapsed.
/*
*
* Copyright (c) 2009, Microsoft Corporation.
*
* This program is free software; you can redistribute it and/or modify it
* under the terms and conditions of the GNU General Public License,
* version 2, as published by the Free Software Foundation.
*
* This program is distributed in the hope it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
* more details.
*
* You should have received a copy of the GNU General Public License along with
* this program; if not, write to the Free Software Foundation, Inc., 59 Temple
* Place - Suite 330, Boston, MA 02111-1307 USA.
*
* Authors:
* Haiyang Zhang <haiyangz@microsoft.com>
* Hank Janssen <hjanssen@microsoft.com>
*
*/
#pragma once
//
// Time in the hypervisor is measured in 100 nanosecond units
//
typedef UINT64 HV_NANO100_TIME, *PHV_NANO100_TIME;
typedef UINT64 HV_NANO100_DURATION, *PHV_NANO100_DURATION;
/*
*
* Copyright (c) 2009, Microsoft Corporation.
*
* This program is free software; you can redistribute it and/or modify it
* under the terms and conditions of the GNU General Public License,
* version 2, as published by the Free Software Foundation.
*
* This program is distributed in the hope it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
* more details.
*
* You should have received a copy of the GNU General Public License along with
* this program; if not, write to the Free Software Foundation, Inc., 59 Temple
* Place - Suite 330, Boston, MA 02111-1307 USA.
*
* Authors:
* Haiyang Zhang <haiyangz@microsoft.com>
* Hank Janssen <hjanssen@microsoft.com>
*
*/
#pragma once
//
// Declare the various hypercall operations.
//
typedef enum _HV_CALL_CODE
{
HvCallPostMessage = 0x005c,
HvCallSignalEvent = 0x005d,
} HV_CALL_CODE, *PHV_CALL_CODE;
//
// Definition of the HvPostMessage hypercall input structure.
//
typedef struct _HV_INPUT_POST_MESSAGE
{
HV_CONNECTION_ID ConnectionId;
UINT32 Reserved;
HV_MESSAGE_TYPE MessageType;
UINT32 PayloadSize;
UINT64 Payload[HV_MESSAGE_PAYLOAD_QWORD_COUNT];
} HV_INPUT_POST_MESSAGE, *PHV_INPUT_POST_MESSAGE;
//
// Definition of the HvSignalEvent hypercall input structure.
//
typedef struct _HV_INPUT_SIGNAL_EVENT
{
HV_CONNECTION_ID ConnectionId;
UINT16 FlagNumber;
UINT16 RsvdZ;
} HV_INPUT_SIGNAL_EVENT, *PHV_INPUT_SIGNAL_EVENT;
/*
*
* Copyright (c) 2009, Microsoft Corporation.
*
* This program is free software; you can redistribute it and/or modify it
* under the terms and conditions of the GNU General Public License,
* version 2, as published by the Free Software Foundation.
*
* This program is distributed in the hope it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
* more details.
*
* You should have received a copy of the GNU General Public License along with
* this program; if not, write to the Free Software Foundation, Inc., 59 Temple
* Place - Suite 330, Boston, MA 02111-1307 USA.
*
* Authors:
* Haiyang Zhang <haiyangz@microsoft.com>
* Hank Janssen <hjanssen@microsoft.com>
*
*/
#pragma once
//
// Versioning definitions used for guests reporting themselves to the
// hypervisor, and visa versa.
// ==================================================================
//
//
// Version info reported by guest OS's
//
typedef enum _HV_GUEST_OS_VENDOR
{
HvGuestOsVendorMicrosoft = 0x0001
} HV_GUEST_OS_VENDOR, *PHV_GUEST_OS_VENDOR;
typedef enum _HV_GUEST_OS_MICROSOFT_IDS
{
HvGuestOsMicrosoftUndefined = 0x00,
HvGuestOsMicrosoftMSDOS = 0x01,
HvGuestOsMicrosoftWindows3x = 0x02,
HvGuestOsMicrosoftWindows9x = 0x03,
HvGuestOsMicrosoftWindowsNT = 0x04,
HvGuestOsMicrosoftWindowsCE = 0x05
} HV_GUEST_OS_MICROSOFT_IDS, *PHV_GUEST_OS_MICROSOFT_IDS;
//
// Declare the MSR used to identify the guest OS.
//
#define HV_X64_MSR_GUEST_OS_ID 0x40000000
typedef union _HV_X64_MSR_GUEST_OS_ID_CONTENTS
{
UINT64 AsUINT64;
struct
{
UINT64 BuildNumber : 16;
UINT64 ServiceVersion : 8; // Service Pack, etc.
UINT64 MinorVersion : 8;
UINT64 MajorVersion : 8;
UINT64 OsId : 8; // HV_GUEST_OS_MICROSOFT_IDS (If Vendor=MS)
UINT64 VendorId : 16; // HV_GUEST_OS_VENDOR
};
} HV_X64_MSR_GUEST_OS_ID_CONTENTS, *PHV_X64_MSR_GUEST_OS_ID_CONTENTS;
//
// Declare the MSR used to setup pages used to communicate with the hypervisor.
//
#define HV_X64_MSR_HYPERCALL 0x40000001
typedef union _HV_X64_MSR_HYPERCALL_CONTENTS
{
UINT64 AsUINT64;
struct
{
UINT64 Enable : 1;
UINT64 Reserved : 11;
UINT64 GuestPhysicalAddress : 52;
};
} HV_X64_MSR_HYPERCALL_CONTENTS, *PHV_X64_MSR_HYPERCALL_CONTENTS;
This diff is collapsed.
This diff is collapsed.
/*
*
* Copyright (c) 2009, Microsoft Corporation.
*
* This program is free software; you can redistribute it and/or modify it
* under the terms and conditions of the GNU General Public License,
* version 2, as published by the Free Software Foundation.
*
* This program is distributed in the hope it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
* more details.
*
* You should have received a copy of the GNU General Public License along with
* this program; if not, write to the Free Software Foundation, Inc., 59 Temple
* Place - Suite 330, Boston, MA 02111-1307 USA.
*
* Authors:
* Haiyang Zhang <haiyangz@microsoft.com>
* Hank Janssen <hjanssen@microsoft.com>
*
*/
#pragma once
typedef UINT64 HV_GPA, *PHV_GPA;
#define HV_X64_PAGE_SIZE (4096)
#define HV_PAGE_SIZE HV_X64_PAGE_SIZE
/*
*
* Copyright (c) 2009, Microsoft Corporation.
*
* This program is free software; you can redistribute it and/or modify it
* under the terms and conditions of the GNU General Public License,
* version 2, as published by the Free Software Foundation.
*
* This program is distributed in the hope it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
* more details.
*
* You should have received a copy of the GNU General Public License along with
* this program; if not, write to the Free Software Foundation, Inc., 59 Temple
* Place - Suite 330, Boston, MA 02111-1307 USA.
*
* Authors:
* Haiyang Zhang <haiyangz@microsoft.com>
* Hank Janssen <hjanssen@microsoft.com>
*
*/
#pragma once
//
// Virtual Processor Indices
//
typedef UINT32 HV_VP_INDEX, *PHV_VP_INDEX;
//
// The below CPUID leaves are present if VersionAndFeatures.HypervisorPresent
// is set by CPUID(HvCpuIdFunctionVersionAndFeatures).
// ==========================================================================
//
typedef enum _HV_CPUID_FUNCTION
{
HvCpuIdFunctionVersionAndFeatures = 0x00000001,
HvCpuIdFunctionHvVendorAndMaxFunction = 0x40000000,
HvCpuIdFunctionHvInterface = 0x40000001,
//
// The remaining functions depend on the value of HvCpuIdFunctionInterface
//
HvCpuIdFunctionMsHvVersion = 0x40000002,
HvCpuIdFunctionMsHvFeatures = 0x40000003,
HvCpuIdFunctionMsHvEnlightenmentInformation = 0x40000004,
HvCpuIdFunctionMsHvImplementationLimits = 0x40000005
} HV_CPUID_FUNCTION, *PHV_CPUID_FUNCTION;
/*
*
* Copyright (c) 2009, Microsoft Corporation.
*
* This program is free software; you can redistribute it and/or modify it
* under the terms and conditions of the GNU General Public License,
* version 2, as published by the Free Software Foundation.
*
* This program is distributed in the hope it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
* more details.
*
* You should have received a copy of the GNU General Public License along with
* this program; if not, write to the Free Software Foundation, Inc., 59 Temple
* Place - Suite 330, Boston, MA 02111-1307 USA.
*
* Authors:
* Haiyang Zhang <haiyangz@microsoft.com>
* Hank Janssen <hjanssen@microsoft.com>
*
*/
#ifndef _LIST_H_
#define _LIST_H_
#include "osd.h"
/*
*
* Doubly-linked list manipulation routines. Implemented as macros
* but logically these are procedures.
*
*/
typedef DLIST_ENTRY LIST_ENTRY;
typedef DLIST_ENTRY *PLIST_ENTRY;
//typedef struct LIST_ENTRY {
// struct LIST_ENTRY * volatile Flink;
// struct LIST_ENTRY * volatile Blink;
//} LIST_ENTRY, *PLIST_ENTRY;
/*
* VOID
* InitializeListHead(
* PLIST_ENTRY ListHead
* );
*/
#define INITIALIZE_LIST_HEAD InitializeListHead
#define InitializeListHead(ListHead) (\
(ListHead)->Flink = (ListHead)->Blink = (ListHead))
/*
* BOOLEAN
* IsListEmpty(
* PLIST_ENTRY ListHead
* );
*/
#define IS_LIST_EMPTY IsListEmpty
#define IsListEmpty(ListHead) \
((ListHead)->Flink == (ListHead))
/*
* PLIST_ENTRY
* NextListEntry(
* PLIST_ENTRY Entry
* );
*/
#define NEXT_LIST_ENTRY NextListEntry
#define NextListEntry(Entry) \
(Entry)->Flink
/*
* PLIST_ENTRY
* PrevListEntry(
* PLIST_ENTRY Entry
* );
*/
#define PREV_LIST_ENTRY PrevListEntry
#define PrevListEntry(Entry) \
(Entry)->Blink
/*
* PLIST_ENTRY
* TopListEntry(
* PLIST_ENTRY ListHead
* );
*/
#define TOP_LIST_ENTRY TopListEntry
#define TopListEntry(ListHead) \
(ListHead)->Flink
/*
* PLIST_ENTRY
* RemoveHeadList(
* PLIST_ENTRY ListHead
* );
*/
#define REMOVE_HEAD_LIST RemoveHeadList
#define RemoveHeadList(ListHead) \
(ListHead)->Flink;\
{RemoveEntryList((ListHead)->Flink)}
/*
* PLIST_ENTRY
* RemoveTailList(
* PLIST_ENTRY ListHead
* );
*/
#define REMOVE_TAIL_LIST RemoveTailList
#define RemoveTailList(ListHead) \
(ListHead)->Blink;\
{RemoveEntryList((ListHead)->Blink)}
/*
* VOID
* RemoveEntryList(
* PLIST_ENTRY Entry
* );
*/
#define REMOVE_ENTRY_LIST RemoveEntryList
#define RemoveEntryList(Entry) {\
PLIST_ENTRY _EX_Flink = (Entry)->Flink;\
PLIST_ENTRY _EX_Blink = (Entry)->Blink;\
_EX_Blink->Flink = _EX_Flink;\
_EX_Flink->Blink = _EX_Blink;\
}
/*
* VOID
* AttachList(
* PLIST_ENTRY ListHead,
* PLIST_ENTRY ListEntry
* );
*/
#define ATTACH_LIST AttachList
#define AttachList(ListHead,ListEntry) {\
PLIST_ENTRY _EX_ListHead = (ListHead);\
PLIST_ENTRY _EX_Blink = (ListHead)->Blink;\
(ListEntry)->Blink->Flink = _EX_ListHead;\
_EX_Blink->Flink = (ListEntry);\
_EX_ListHead->Blink = (ListEntry)->Blink;\
(ListEntry)->Blink = _EX_Blink;\
}
/*
* VOID
* InsertTailList(
* PLIST_ENTRY ListHead,
* PLIST_ENTRY Entry
* );
*/
#define INSERT_TAIL_LIST InsertTailList
#define InsertTailList(ListHead,Entry) {\
PLIST_ENTRY _EX_ListHead = (ListHead);\
PLIST_ENTRY _EX_Blink = (ListHead)->Blink;\
(Entry)->Flink = _EX_ListHead;\
(Entry)->Blink = _EX_Blink;\
_EX_Blink->Flink = (Entry);\
_EX_ListHead->Blink = (Entry);\
}
/*
* VOID
* InsertHeadList(
* PLIST_ENTRY ListHead,
* PLIST_ENTRY Entry
* );
*/
#define INSERT_HEAD_LIST InsertHeadList
#define InsertHeadList(ListHead,Entry) {\
PLIST_ENTRY _EX_ListHead = (ListHead);\
PLIST_ENTRY _EX_Flink = (ListHead)->Flink;\
(Entry)->Flink = _EX_Flink;\
(Entry)->Blink = _EX_ListHead;\
_EX_Flink->Blink = (Entry);\
_EX_ListHead->Flink = (Entry);\
}
/*
* VOID
* IterateListEntries(
* PLIST_ENTRY anchor,
* PLIST_ENTRY index,
* PLIST_ENTRY listp
* );
*/
#define ITERATE_LIST_ENTRIES IterateListEntries
#define IterateListEntries(anchor, index, listp) \
(anchor) = (LIST_ENTRY *)(listp); \
for((index) = (anchor)->Flink; (index) != (anchor); (index) = (index)->Flink)
/*
* PSINGLE_LIST_ENTRY
* PopEntryList(
* PSINGLE_LIST_ENTRY ListHead
* );
*/
#define POP_ENTRY_LIST PopEntryList
#define PopEntryList(ListHead) \
(ListHead)->Next;\
{\
PSINGLE_LIST_ENTRY FirstEntry;\
FirstEntry = (ListHead)->Next;\
if (FirstEntry != NULL) { \
(ListHead)->Next = FirstEntry->Next;\
} \
}
/*
* VOID
* PushEntryList(
* PSINGLE_LIST_ENTRY ListHead,
* PSINGLE_LIST_ENTRY Entry
* );
*/
#define PUSH_ENTRY_LIST PushEntryList
#define PushEntryList(ListHead,Entry) \
(Entry)->Next = (ListHead)->Next; \
(ListHead)->Next = (Entry)
#ifndef CONTAINING_RECORD
#define CONTAINING_RECORD(address, type, field) ((type *)( \
(PCHAR)(address) - \
(PCHAR)(&((type *)0)->field)))
#endif /* CONTAINING_RECORD */
#endif /* _LIST_H_ */
/* EOF */
/*
*
* Copyright (c) 2009, Microsoft Corporation.
*
* This program is free software; you can redistribute it and/or modify it
* under the terms and conditions of the GNU General Public License,
* version 2, as published by the Free Software Foundation.
*
* This program is distributed in the hope it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
* more details.
*
* You should have received a copy of the GNU General Public License along with
* this program; if not, write to the Free Software Foundation, Inc., 59 Temple
* Place - Suite 330, Boston, MA 02111-1307 USA.
*
* Authors:
* Haiyang Zhang <haiyangz@microsoft.com>
* Hank Janssen <hjanssen@microsoft.com>
*
*/
#pragma once
// allow nameless unions
//#pragma warning(disable : 4201)
//
// A revision number of vmbus that is used for ensuring both ends on a
// partition are using compatible versions.
//
#define VMBUS_REVISION_NUMBER 13
//
// Make maximum size of pipe payload of 16K
//
#define MAX_PIPE_DATA_PAYLOAD (sizeof(BYTE) * 16384)
//
// Define PipeMode values.
//
#define VMBUS_PIPE_TYPE_BYTE 0x00000000
#define VMBUS_PIPE_TYPE_MESSAGE 0x00000004
//
// The size of the user defined data buffer for non-pipe offers.
//
#define MAX_USER_DEFINED_BYTES 120
//
// The size of the user defined data buffer for pipe offers.
//
#define MAX_PIPE_USER_DEFINED_BYTES 116
//
// At the center of the Channel Management library is
// the Channel Offer. This struct contains the
// fundamental information about an offer.
//
#pragma pack(push,1)
typedef struct
{
GUID InterfaceType;
GUID InterfaceInstance;
UINT64 InterruptLatencyIn100nsUnits;
UINT32 InterfaceRevision;
UINT32 ServerContextAreaSize; // in bytes
UINT16 ChannelFlags;
UINT16 MmioMegabytes; // in bytes * 1024 * 1024
union
{
//
// Non-pipes: The user has MAX_USER_DEFINED_BYTES bytes.
//
struct
{
UCHAR UserDefined[MAX_USER_DEFINED_BYTES];
} Standard;
//
// Pipes: The following sructure is an integrated pipe protocol, which
// is implemented on top of standard user-defined data. Pipe clients
// have MAX_PIPE_USER_DEFINED_BYTES left for their own use.
//
struct
{
UINT32 PipeMode;
UCHAR UserDefined[MAX_PIPE_USER_DEFINED_BYTES];
} Pipe;
} u;
UINT32 Padding;
} VMBUS_CHANNEL_OFFER, *PVMBUS_CHANNEL_OFFER;
#pragma pack(pop)
//
// Verify the MAX_PIPE_USER_DEFINED_BYTES value.
//
//C_ASSERT(MAX_PIPE_USER_DEFINED_BYTES ==
// MAX_USER_DEFINED_BYTES -
// (FIELD_OFFSET(VMBUS_CHANNEL_OFFER, u.Pipe.UserDefined) -
// FIELD_OFFSET(VMBUS_CHANNEL_OFFER, u.Standard.UserDefined)));
//
typedef UINT32 GPADL_HANDLE;
//
// Server Flags
//
#define VMBUS_CHANNEL_ENUMERATE_DEVICE_INTERFACE 1
#define VMBUS_CHANNEL_SERVER_SUPPORTS_TRANSFER_PAGES 2
#define VMBUS_CHANNEL_SERVER_SUPPORTS_GPADLS 4
#define VMBUS_CHANNEL_NAMED_PIPE_MODE 0x10
#define VMBUS_CHANNEL_LOOPBACK_OFFER 0x100
#define VMBUS_CHANNEL_PARENT_OFFER 0x200
#define VMBUS_CHANNEL_REQUEST_MONITORED_NOTIFICATION 0x400
//
// TEMPTEMP -- move this next define to devioctl.h some day
//
#ifndef FILE_DEVICE_VMBUS
#define FILE_DEVICE_VMBUS 0x0000003E
#endif
/*
*
* Copyright (c) 2009, Microsoft Corporation.
*
* This program is free software; you can redistribute it and/or modify it
* under the terms and conditions of the GNU General Public License,
* version 2, as published by the Free Software Foundation.
*
* This program is distributed in the hope it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
* more details.
*
* You should have received a copy of the GNU General Public License along with
* this program; if not, write to the Free Software Foundation, Inc., 59 Temple
* Place - Suite 330, Boston, MA 02111-1307 USA.
*
* Authors:
* Haiyang Zhang <haiyangz@microsoft.com>
* Hank Janssen <hjanssen@microsoft.com>
*
*/
#pragma once
//#ifndef PAGE_SIZE
//#if defined(_IA64_)
//#error This does not work for IA64
//#else
//#define PAGE_SIZE 0x1000
//#endif
//#endif
// allow nameless unions
//#pragma warning(disable : 4201)
typedef struct
{
union
{
struct
{
volatile UINT32 In; // Offset in bytes from the ring base
volatile UINT32 Out; // Offset in bytes from the ring base
};
volatile LONGLONG InOut;
};
//
// If the receiving endpoint sets this to some non-zero value, the sending
// endpoint should not send any interrupts.
//
volatile UINT32 InterruptMask;
} VMRCB, *PVMRCB;
typedef struct
{
union
{
struct
{
VMRCB Control;
};
UINT8 Reserved[PAGE_SIZE];
};
//
// Beginning of the ring data. Note: It must be guaranteed that
// this data does not share a page with the control structure.
//
UINT8 Data[1];
} VMRING, *PVMRING;
#pragma pack(push, 1)
typedef struct
{
UINT16 Type;
UINT16 DataOffset8;
UINT16 Length8;
UINT16 Flags;
UINT64 TransactionId;
} VMPACKET_DESCRIPTOR, *PVMPACKET_DESCRIPTOR;
typedef UINT32 PREVIOUS_PACKET_OFFSET, *PPREVIOUS_PACKET_OFFSET;
typedef struct
{
PREVIOUS_PACKET_OFFSET PreviousPacketStartOffset;
VMPACKET_DESCRIPTOR Descriptor;
} VMPACKET_HEADER, *PVMPACKET_HEADER;
typedef struct
{
UINT32 ByteCount;
UINT32 ByteOffset;
} VMTRANSFER_PAGE_RANGE, *PVMTRANSFER_PAGE_RANGE;
#ifdef __cplusplus
typedef struct _VMTRANSFER_PAGE_PACKET_HEADER : VMPACKET_DESCRIPTOR {
#else
typedef struct VMTRANSFER_PAGE_PACKET_HEADER {
VMPACKET_DESCRIPTOR d;
#endif
UINT16 TransferPageSetId;
BOOLEAN SenderOwnsSet;
UINT8 Reserved;
UINT32 RangeCount;
VMTRANSFER_PAGE_RANGE Ranges[1];
} VMTRANSFER_PAGE_PACKET_HEADER, *PVMTRANSFER_PAGE_PACKET_HEADER;
#ifdef __cplusplus
typedef struct _VMGPADL_PACKET_HEADER : VMPACKET_DESCRIPTOR {
#else
typedef struct _VMGPADL_PACKET_HEADER {
VMPACKET_DESCRIPTOR d;
#endif
UINT32 Gpadl;
UINT32 Reserved;
} VMGPADL_PACKET_HEADER, *PVMGPADL_PACKET_HEADER;
#ifdef __cplusplus
typedef struct _VMADD_REMOVE_TRANSFER_PAGE_SET : VMPACKET_DESCRIPTOR {
#else
typedef struct _VMADD_REMOVE_TRANSFER_PAGE_SET {
VMPACKET_DESCRIPTOR d;
#endif
UINT32 Gpadl;
UINT16 TransferPageSetId;
UINT16 Reserved;
} VMADD_REMOVE_TRANSFER_PAGE_SET, *PVMADD_REMOVE_TRANSFER_PAGE_SET;
#pragma pack(pop)
//
// This structure defines a range in guest physical space that can be made
// to look virtually contiguous.
//
typedef struct _GPA_RANGE {
UINT32 ByteCount;
UINT32 ByteOffset;
UINT64 PfnArray[0];
} GPA_RANGE, *PGPA_RANGE;
#pragma pack(push, 1)
//
// This is the format for an Establish Gpadl packet, which contains a handle
// by which this GPADL will be known and a set of GPA ranges associated with
// it. This can be converted to a MDL by the guest OS. If there are multiple
// GPA ranges, then the resulting MDL will be "chained," representing multiple
// VA ranges.
//
#ifdef __cplusplus
typedef struct _VMESTABLISH_GPADL : VMPACKET_DESCRIPTOR {
#else
typedef struct _VMESTABLISH_GPADL {
VMPACKET_DESCRIPTOR d;
#endif
UINT32 Gpadl;
UINT32 RangeCount;
GPA_RANGE Range[1];
} VMESTABLISH_GPADL, *PVMESTABLISH_GPADL;
//
// This is the format for a Teardown Gpadl packet, which indicates that the
// GPADL handle in the Establish Gpadl packet will never be referenced again.
//
#ifdef __cplusplus
typedef struct _VMTEARDOWN_GPADL : VMPACKET_DESCRIPTOR {
#else
typedef struct _VMTEARDOWN_GPADL {
VMPACKET_DESCRIPTOR d;
#endif
UINT32 Gpadl;
UINT32 Reserved; // for alignment to a 8-byte boundary
} VMTEARDOWN_GPADL, *PVMTEARDOWN_GPADL;
//
// This is the format for a GPA-Direct packet, which contains a set of GPA
// ranges, in addition to commands and/or data.
//
#ifdef __cplusplus
typedef struct _VMDATA_GPA_DIRECT : VMPACKET_DESCRIPTOR {
#else
typedef struct _VMDATA_GPA_DIRECT {
VMPACKET_DESCRIPTOR d;
#endif
UINT32 Reserved;
UINT32 RangeCount;
GPA_RANGE Range[1];
} VMDATA_GPA_DIRECT, *PVMDATA_GPA_DIRECT;
//
// This is the format for a Additional Data Packet.
//
#ifdef __cplusplus
typedef struct _VMADDITIONAL_DATA : VMPACKET_DESCRIPTOR {
#else
typedef struct _VMADDITIONAL_DATA {
VMPACKET_DESCRIPTOR d;
#endif
UINT64 TotalBytes;
UINT32 ByteOffset;
UINT32 ByteCount;
UCHAR Data[1];
} VMADDITIONAL_DATA, *PVMADDITIONAL_DATA;
#pragma pack(pop)
typedef union {
VMPACKET_DESCRIPTOR SimpleHeader;
VMTRANSFER_PAGE_PACKET_HEADER TransferPageHeader;
VMGPADL_PACKET_HEADER GpadlHeader;
VMADD_REMOVE_TRANSFER_PAGE_SET AddRemoveTransferPageHeader;
VMESTABLISH_GPADL EstablishGpadlHeader;
VMTEARDOWN_GPADL TeardownGpadlHeader;
VMDATA_GPA_DIRECT DataGpaDirectHeader;
} VMPACKET_LARGEST_POSSIBLE_HEADER, *PVMPACKET_LARGEST_POSSIBLE_HEADER;
#define VMPACKET_DATA_START_ADDRESS(__packet) \
(PVOID)(((PUCHAR)__packet) + ((PVMPACKET_DESCRIPTOR)__packet)->DataOffset8 * 8)
#define VMPACKET_DATA_LENGTH(__packet) \
((((PVMPACKET_DESCRIPTOR)__packet)->Length8 - ((PVMPACKET_DESCRIPTOR)__packet)->DataOffset8) * 8)
#define VMPACKET_TRANSFER_MODE(__packet) ((PVMPACKET_DESCRIPTOR)__packet)->Type
typedef enum {
VmbusServerEndpoint = 0,
VmbusClientEndpoint,
VmbusEndpointMaximum
} ENDPOINT_TYPE, *PENDPOINT_TYPE;
typedef enum {
VmbusPacketTypeInvalid = 0x0,
VmbusPacketTypeSynch = 0x1,
VmbusPacketTypeAddTransferPageSet = 0x2,
VmbusPacketTypeRemoveTransferPageSet = 0x3,
VmbusPacketTypeEstablishGpadl = 0x4,
VmbusPacketTypeTearDownGpadl = 0x5,
VmbusPacketTypeDataInBand = 0x6,
VmbusPacketTypeDataUsingTransferPages = 0x7,
VmbusPacketTypeDataUsingGpadl = 0x8,
VmbusPacketTypeDataUsingGpaDirect = 0x9,
VmbusPacketTypeCancelRequest = 0xa,
VmbusPacketTypeCompletion = 0xb,
VmbusPacketTypeDataUsingAdditionalPackets = 0xc,
VmbusPacketTypeAdditionalData = 0xd
} VMBUS_PACKET_TYPE, *PVMBUS_PACKET_TYPE;
#define VMBUS_DATA_PACKET_FLAG_COMPLETION_REQUESTED 1
This diff is collapsed.
This diff is collapsed.
/*
*
* Copyright (c) 2009, Microsoft Corporation.
*
* This program is free software; you can redistribute it and/or modify it
* under the terms and conditions of the GNU General Public License,
* version 2, as published by the Free Software Foundation.
*
* This program is distributed in the hope it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
* more details.
*
* You should have received a copy of the GNU General Public License along with
* this program; if not, write to the Free Software Foundation, Inc., 59 Temple
* Place - Suite 330, Boston, MA 02111-1307 USA.
*
* Authors:
* Haiyang Zhang <haiyangz@microsoft.com>
* Hank Janssen <hjanssen@microsoft.com>
*
*/
#pragma once
//#include <vmbuspacketformat.h>
//#include <ntddscsi.h>
#define C_ASSERT(x)
//
// public interface to the server
//
//
// Storvsp device interface guid
//
//
// Protocol versions.
//
//
// vstorage.w revision number. This is used in the case of a version match,
// to alert the user that structure sizes may be mismatched even though the
// protocol versions match.
//
#define REVISION_STRING(REVISION_) #REVISION_
#define FILL_VMSTOR_REVISION(RESULT_LVALUE_) \
{ \
char *revisionString = REVISION_STRING($Revision: 6 $) + 11; \
RESULT_LVALUE_ = 0; \
while (*revisionString >= '0' && *revisionString <= '9') \
{ \
RESULT_LVALUE_ *= 10; \
RESULT_LVALUE_ += *revisionString - '0'; \
revisionString++; \
} \
}
//
// Major/minor macros. Minor version is in LSB, meaning that earlier flat
// version numbers will be interpreted as "0.x" (i.e., 1 becomes 0.1).
//
#define VMSTOR_PROTOCOL_MAJOR(VERSION_) (((VERSION_) >> 8) & 0xff)
#define VMSTOR_PROTOCOL_MINOR(VERSION_) (((VERSION_) ) & 0xff)
#define VMSTOR_PROTOCOL_VERSION(MAJOR_, MINOR_) ((((MAJOR_) & 0xff) << 8) | \
(((MINOR_) & 0xff) ))
//
// Invalid version.
//
#define VMSTOR_INVALID_PROTOCOL_VERSION -1
//
// Version history:
// V1 Beta 0.1
// V1 RC < 2008/1/31 1.0
// V1 RC > 2008/1/31 2.0
//
#define VMSTOR_PROTOCOL_VERSION_CURRENT VMSTOR_PROTOCOL_VERSION(2, 0)
//
// This will get replaced with the max transfer length that is possible on
// the host adapter.
// The max transfer length will be published when we offer a vmbus channel.
//
#define MAX_TRANSFER_LENGTH 0x40000
#define DEFAULT_PACKET_SIZE (sizeof(VMDATA_GPA_DIRECT) + \
sizeof(VSTOR_PACKET) + \
(sizeof(UINT64) * (MAX_TRANSFER_LENGTH / PAGE_SIZE)))
//
// Packet structure describing virtual storage requests.
//
typedef enum
{
VStorOperationCompleteIo = 1,
VStorOperationRemoveDevice = 2,
VStorOperationExecuteSRB = 3,
VStorOperationResetLun = 4,
VStorOperationResetAdapter = 5,
VStorOperationResetBus = 6,
VStorOperationBeginInitialization = 7,
VStorOperationEndInitialization = 8,
VStorOperationQueryProtocolVersion = 9,
VStorOperationQueryProperties = 10,
VStorOperationMaximum = 10
} VSTOR_PACKET_OPERATION;
//
// Platform neutral description of a scsi request -
// this remains the same across the write regardless of 32/64 bit
// note: it's patterned off the SCSI_PASS_THROUGH structure
//
#pragma pack(push,1)
#define CDB16GENERIC_LENGTH 0x10
#ifndef SENSE_BUFFER_SIZE
#define SENSE_BUFFER_SIZE 0x12
#endif
C_ASSERT(SENSE_BUFFER_SIZE == 0x12);
#define MAX_DATA_BUFFER_LENGTH_WITH_PADDING 0x14
typedef struct
{
USHORT Length;
UCHAR SrbStatus;
UCHAR ScsiStatus;
UCHAR PortNumber;
UCHAR PathId;
UCHAR TargetId;
UCHAR Lun;
UCHAR CdbLength;
UCHAR SenseInfoLength;
UCHAR DataIn;
UCHAR Reserved;
ULONG DataTransferLength;
union
{
UCHAR Cdb[CDB16GENERIC_LENGTH];
UCHAR SenseData[SENSE_BUFFER_SIZE];
UCHAR ReservedArray[MAX_DATA_BUFFER_LENGTH_WITH_PADDING];
};
} VMSCSI_REQUEST, *PVMSCSI_REQUEST;
C_ASSERT((sizeof(VMSCSI_REQUEST) % 4) == 0);
//
// This structure is sent during the intialization phase to get the different
// properties of the channel.
//
typedef struct
{
USHORT ProtocolVersion;
UCHAR PathId;
UCHAR TargetId;
//
// Note: port number is only really known on the client side
//
ULONG PortNumber;
ULONG Flags;
ULONG MaxTransferBytes;
//
// This id is unique for each channel and will correspond with
// vendor specific data in the inquirydata
//
ULONGLONG UniqueId;
} VMSTORAGE_CHANNEL_PROPERTIES, *PVMSTORAGE_CHANNEL_PROPERTIES;
C_ASSERT((sizeof(VMSTORAGE_CHANNEL_PROPERTIES) % 4) == 0);
//
// This structure is sent during the storage protocol negotiations.
//
typedef struct
{
//
// Major (MSW) and minor (LSW) version numbers.
//
USHORT MajorMinor;
//
// Revision number is auto-incremented whenever this file is changed
// (See FILL_VMSTOR_REVISION macro above). Mismatch does not definitely
// indicate incompatibility--but it does indicate mismatched builds.
//
USHORT Revision;
} VMSTORAGE_PROTOCOL_VERSION, *PVMSTORAGE_PROTOCOL_VERSION;
C_ASSERT((sizeof(VMSTORAGE_PROTOCOL_VERSION) % 4) == 0);
//
// Channel Property Flags
//
#define STORAGE_CHANNEL_REMOVABLE_FLAG 0x1
#define STORAGE_CHANNEL_EMULATED_IDE_FLAG 0x2
typedef struct _VSTOR_PACKET
{
//
// Requested operation type
//
VSTOR_PACKET_OPERATION Operation;
//
// Flags - see below for values
//
ULONG Flags;
//
// Status of the request returned from the server side.
//
ULONG Status;
//
// Data payload area
//
union
{
//
// Structure used to forward SCSI commands from the client to the server.
//
VMSCSI_REQUEST VmSrb;
//
// Structure used to query channel properties.
//
VMSTORAGE_CHANNEL_PROPERTIES StorageChannelProperties;
//
// Used during version negotiations.
//
VMSTORAGE_PROTOCOL_VERSION Version;
};
} VSTOR_PACKET, *PVSTOR_PACKET;
C_ASSERT((sizeof(VSTOR_PACKET) % 4) == 0);
//
// Packet flags
//
//
// This flag indicates that the server should send back a completion for this
// packet.
//
#define REQUEST_COMPLETION_FLAG 0x1
//
// This is the set of flags that the vsc can set in any packets it sends
//
#define VSC_LEGAL_FLAGS (REQUEST_COMPLETION_FLAG)
#pragma pack(pop)
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment