and should not be used outside of the EDK II tree.\r
\r
Copyright (c) 2013, ARM Ltd. All rights reserved.<BR>\r
+ Copyright (c) 2017, AMD Inc, All rights reserved.<BR>\r
\r
This program and the accompanying materials are licensed and made available\r
under the terms and conditions of the BSD License which accompanies this\r
\r
typedef struct _VIRTIO_DEVICE_PROTOCOL VIRTIO_DEVICE_PROTOCOL;\r
\r
+//\r
+// VIRTIO Operation for VIRTIO_MAP_SHARED\r
+//\r
+typedef enum {\r
+ //\r
+ // A read operation from system memory by a bus master\r
+ //\r
+ VirtioOperationBusMasterRead,\r
+ //\r
+ // A write operation to system memory by a bus master\r
+ //\r
+ VirtioOperationBusMasterWrite,\r
+ //\r
+ // Provides both read and write access to system memory by both the\r
+ // processor and a bus master\r
+ //\r
+ VirtioOperationBusMasterCommonBuffer,\r
+} VIRTIO_MAP_OPERATION;\r
+\r
/**\r
\r
Read a word from the device-specific I/O region of the Virtio Header.\r
IN UINT8 DeviceStatus\r
);\r
\r
+/**\r
+\r
+ Allocates pages that are suitable for an VirtioOperationBusMasterCommonBuffer\r
+ mapping. This means that the buffer allocated by this function supports\r
+ simultaneous access by both the processor and the bus master. The device\r
+ address that the bus master uses to access the buffer must be retrieved with\r
+ a call to VIRTIO_MAP_SHARED.\r
+\r
+ @param[in] This The protocol instance pointer.\r
+\r
+ @param[in] Pages The number of pages to allocate.\r
+\r
+ @param[in,out] HostAddress A pointer to store the system memory base\r
+ address of the allocated range.\r
+\r
+ @retval EFI_SUCCESS The requested memory pages were allocated.\r
+ @retval EFI_OUT_OF_RESOURCES The memory pages could not be allocated.\r
+\r
+**/\r
+typedef\r
+EFI_STATUS\r
+(EFIAPI *VIRTIO_ALLOCATE_SHARED)(\r
+ IN VIRTIO_DEVICE_PROTOCOL *This,\r
+ IN UINTN Pages,\r
+ IN OUT VOID **HostAddress\r
+ );\r
+\r
+/**\r
+ Frees memory that was allocated with VIRTIO_ALLOCATE_SHARED.\r
+\r
+ @param[in] This The protocol instance pointer.\r
+\r
+ @param[in] Pages The number of pages to free.\r
+\r
+ @param[in] HostAddress The system memory base address of the allocated\r
+ range.\r
+\r
+**/\r
+typedef\r
+VOID\r
+(EFIAPI *VIRTIO_FREE_SHARED)(\r
+ IN VIRTIO_DEVICE_PROTOCOL *This,\r
+ IN UINTN Pages,\r
+ IN VOID *HostAddress\r
+ );\r
+\r
+/**\r
+ Provides the virtio device address required to access system memory from a\r
+ DMA bus master.\r
+\r
+ The interface follows the same usage pattern as defined in UEFI spec 2.6\r
+ (Section 13.2 PCI Root Bridge I/O Protocol)\r
+\r
+ @param[in] This The protocol instance pointer.\r
+\r
+ @param[in] Operation Indicates if the bus master is going to\r
+ read or write to system memory.\r
+\r
+ @param[in] HostAddress The system memory address to map to shared\r
+ buffer address.\r
+\r
+ @param[in,out] NumberOfBytes On input the number of bytes to map.\r
+ On output the number of bytes that were\r
+ mapped.\r
+\r
+ @param[out] DeviceAddress The resulting shared map address for the\r
+ bus master to access the hosts HostAddress.\r
+\r
+ @param[out] Mapping A resulting token to pass to\r
+ VIRTIO_UNMAP_SHARED.\r
+\r
+ @retval EFI_SUCCESS The range was mapped for the returned\r
+ NumberOfBytes.\r
+ @retval EFI_UNSUPPORTED The HostAddress cannot be mapped as a\r
+ common buffer.\r
+ @retval EFI_INVALID_PARAMETER One or more parameters are invalid.\r
+ @retval EFI_OUT_OF_RESOURCES The request could not be completed due to\r
+ a lack of resources.\r
+ @retval EFI_DEVICE_ERROR The system hardware could not map the\r
+ requested address.\r
+**/\r
+\r
+typedef\r
+EFI_STATUS\r
+(EFIAPI *VIRTIO_MAP_SHARED) (\r
+ IN VIRTIO_DEVICE_PROTOCOL *This,\r
+ IN VIRTIO_MAP_OPERATION Operation,\r
+ IN VOID *HostAddress,\r
+ IN OUT UINTN *NumberOfBytes,\r
+ OUT EFI_PHYSICAL_ADDRESS *DeviceAddress,\r
+ OUT VOID **Mapping\r
+ );\r
+\r
+/**\r
+ Completes the VIRTIO_MAP_SHARED operation and releases any corresponding\r
+ resources.\r
+\r
+ @param[in] This The protocol instance pointer.\r
+\r
+ @param[in] Mapping The mapping token returned from\r
+ VIRTIO_MAP_SHARED.\r
+\r
+ @retval EFI_SUCCESS The range was unmapped.\r
+ @retval EFI_INVALID_PARAMETER Mapping is not a value that was returned by\r
+ VIRTIO_MAP_SHARED. Passing an invalid Mapping\r
+ token can cause undefined behavior.\r
+ @retval EFI_DEVICE_ERROR The data was not committed to the target\r
+ system memory.\r
+**/\r
+typedef\r
+EFI_STATUS\r
+(EFIAPI *VIRTIO_UNMAP_SHARED)(\r
+ IN VIRTIO_DEVICE_PROTOCOL *This,\r
+ IN VOID *Mapping\r
+ );\r
\r
///\r
/// This protocol provides an abstraction over the VirtIo transport layer\r
//\r
VIRTIO_DEVICE_WRITE WriteDevice;\r
VIRTIO_DEVICE_READ ReadDevice;\r
+\r
+ //\r
+ // Functions to allocate, free, map and unmap shared buffer\r
+ //\r
+ VIRTIO_ALLOCATE_SHARED AllocateSharedPages;\r
+ VIRTIO_FREE_SHARED FreeSharedPages;\r
+ VIRTIO_MAP_SHARED MapSharedBuffer;\r
+ VIRTIO_UNMAP_SHARED UnmapSharedBuffer;\r
};\r
\r
extern EFI_GUID gVirtioDeviceProtocolGuid;\r