[ipxe-devel] [RFC PATCH 6/8] efi: import HypervVmbusDevice header from edk2

Roman Kagan rkagan at virtuozzo.com
Mon Jun 11 17:28:21 UTC 2018


Signed-off-by: Roman Kagan <rkagan at virtuozzo.com>
---
 .../ipxe/efi/Protocol/HypervVmbusDevice.h     | 168 ++++++++++++++++++
 1 file changed, 168 insertions(+)
 create mode 100644 src/include/ipxe/efi/Protocol/HypervVmbusDevice.h

diff --git a/src/include/ipxe/efi/Protocol/HypervVmbusDevice.h b/src/include/ipxe/efi/Protocol/HypervVmbusDevice.h
new file mode 100644
index 00000000..ef4f9df6
--- /dev/null
+++ b/src/include/ipxe/efi/Protocol/HypervVmbusDevice.h
@@ -0,0 +1,168 @@
+/**@file
+
+  VMBus device protocol definition
+  Copyright (c) 2018 Virtuozzo International GmbH.
+
+  This program and the accompanying materials
+  are licensed and made available under the terms and conditions of the BSD License
+  which accompanies this distribution.  The full text of the license may be found at
+  http://opensource.org/licenses/bsd-license.php
+
+  THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+  WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+**/
+
+#ifndef __HYPERV_VMBUS_DEVICE_PROTOCOL_H__
+#define __HYPERV_VMBUS_DEVICE_PROTOCOL_H__
+
+typedef struct _HYPERV_VMBUS_DEVICE_PROTOCOL HYPERV_VMBUS_DEVICE_PROTOCOL;
+
+typedef
+EFI_STATUS
+(EFIAPI *HV_VMBUS_ESTABLISH_GPADL)(
+  IN HYPERV_VMBUS_DEVICE_PROTOCOL *Self,
+  IN VOID *Buffer,
+  IN UINT32 Size,
+  OUT UINT32 *Gpadl
+  );
+
+typedef
+EFI_STATUS
+(EFIAPI *HV_VMBUS_TEARDOWN_GPADL)(
+  IN HYPERV_VMBUS_DEVICE_PROTOCOL *Self,
+  IN UINT32 Gpadl
+  );
+
+/**
+  Open device channel
+  Vmbus devices use channels as means of communication between host and guest
+
+  @param Self                   Vmbus device protocol instance
+
+  @param RingbufferSizePages    Requested channel ring buffer size in pages
+                                Two ringbuffers are created for each channel:
+                                inbound and outbound. Both will have this size,
+                                so memory consumption is doubled.
+
+  @retval EFI_INVALID_PARAMETER Self is NULL or RingbufferSizePages is 0
+  @retval EFI_OUT_OF_RESOURCES  No memory for channel ringbuffers
+  @retval EFI_DEVICE_ERROR      Hypervisor host error
+  @retval EFI_SUCCESS           Channel successfully opened and is ready for IO
+**/
+typedef
+EFI_STATUS
+(EFIAPI *HV_VMBUS_OPEN_CHANNEL)(
+  IN HYPERV_VMBUS_DEVICE_PROTOCOL *Self,
+  IN UINT32                       RbOutPages,
+  IN UINT32                       RbInPages
+  );
+
+/**
+  Close device channel
+
+  @param Self                   Vmbus device protocol instance
+
+  #retval EFI_INVALID_PARAMETER Self is NULL
+  @retval EFI_DEVICE_ERROR      Hypervisor host error
+  @retval EFI_SUCCESS           Channel successfully closed
+**/
+typedef
+EFI_STATUS
+(EFIAPI *HV_VMBUS_CLOSE_CHANNEL)(
+  IN HYPERV_VMBUS_DEVICE_PROTOCOL *Self
+  );
+
+/**
+  Read next message from channel
+  This call will block until new message is available
+
+  @param Self                   Vmbus device protocol instance
+  @param Buffer                 Data buffer
+  @param Size                   Data buffer size in bytes
+  @param Msglen                 Size of actual message that was read from channel.
+                                In case buffer size is insufficient, size of
+                                required buffer
+
+  @retval EFI_INVALID_PARAMETER Self or Buffer is NULL
+  @retval EFI_BUFFER_TOO_SMALL  Supplied buffer size is insufficient to hold message data
+                                Required size is returned in Msglen if it is not NULL
+  @retval EFI_DEVICE_ERROR      Hypervisor host error
+  @retval EFI_SUCCESS           Message successfully read, check size in Msglen
+**/
+typedef struct _HV_VMBUS_BUF_RANGE {
+  UINT32 Length;
+  UINT32 Offset;
+} HV_VMBUS_BUF_RANGE;
+
+typedef
+EFI_STATUS
+(EFIAPI *HV_VMBUS_READ_CHANNEL)(
+  IN HYPERV_VMBUS_DEVICE_PROTOCOL *Self,
+  OUT UINT16 *Type OPTIONAL,
+  OUT UINT64 *TransactionId OPTIONAL,
+  OUT VOID *Message OPTIONAL,
+  OUT UINT32 *MessageSize OPTIONAL,
+  OUT UINT16 *BufferId OPTIONAL,
+  OUT HV_VMBUS_BUF_RANGE *Ranges OPTIONAL,
+  OUT UINT32 *NumRanges OPTIONAL
+  );
+
+/**
+  Write message to channel
+
+  @param Self                   Vmbus device protocol instance
+  @param Type                   Vmbus packet type
+  @param TransactionId          Transaction ID
+  @param Message                Packet message
+  @param MessageSize            Packet message size
+  @param Data                   Packet data (out-of-band)
+  @param DataSize               Packet data size
+
+  @retval EFI_INVALID_PARAMETER Self or Buffer is NULL
+  @retval EFI_BUFFER_TOO_SMALL  There is not enough space in channel ringbuffer for new message
+  @retval EFI_DEVICE_ERROR      Hypervisor host error
+  @retval EFI_SUCCESS           Message successfully written
+**/
+typedef
+EFI_STATUS
+(EFIAPI *HV_VMBUS_WRITE_CHANNEL)(
+  IN HYPERV_VMBUS_DEVICE_PROTOCOL   *Self,
+  IN UINT16 Type,
+  IN UINT64 TransactionId,
+  IN CONST VOID *Message,
+  IN UINT32 MessageSize,
+  IN VOID *Data,
+  IN UINT32 DataSize
+  );
+
+/**
+  VMBus device protocol
+
+  VMbus DXE driver will enumerate paravirtualized device bus and produce
+  a handle with this protocol and device path protocol installed for
+  each device offered by host hypervisor
+
+  Specific device driver can use this protocol as generic vmbus device
+  communication channel
+**/
+struct _HYPERV_VMBUS_DEVICE_PROTOCOL {
+  EFI_GUID                    TypeGUID;
+  EFI_GUID                    InstanceGUID;
+  UINT32                      Channel;
+
+  HV_VMBUS_ESTABLISH_GPADL       EstablishGpadl;
+  HV_VMBUS_TEARDOWN_GPADL        TeardownGpadl;
+  HV_VMBUS_OPEN_CHANNEL          OpenChannel;
+  HV_VMBUS_CLOSE_CHANNEL         CloseChannel;
+  HV_VMBUS_READ_CHANNEL          ReadChannel;
+  HV_VMBUS_WRITE_CHANNEL         WriteChannel;
+};
+
+
+#define EFI_HYPERV_VMBUS_DEVICE_PROTOCOL_GUID \
+{0x37c2cad1, 0x5e84, 0x488e, {0xaa, 0x24, 0x0b, 0xcd, 0x09, 0x47, 0x65, 0x13}}
+
+extern EFI_GUID gHypervVmbusDeviceProtocolGuid;
+
+#endif
-- 
2.17.1




More information about the ipxe-devel mailing list