]> git.proxmox.com Git - mirror_edk2.git/commitdiff
OvmfPkg/VirtioPciDeviceDxe: implement IOMMU-like member functions
authorBrijesh Singh <brijesh.singh@amd.com>
Wed, 23 Aug 2017 10:57:15 +0000 (06:57 -0400)
committerLaszlo Ersek <lersek@redhat.com>
Fri, 25 Aug 2017 08:42:18 +0000 (10:42 +0200)
The patch implements the newly added IOMMU-like member functions by
respectively delegating the job to:

- VIRTIO_DEVICE_PROTOCOL.AllocateSharedPages () ->
    MemoryAllocationLib.AllocatePages()

- VIRTIO_DEVICE_PROTOCOL.FreeSharedPages () ->
    MemoryAllocationLib.FreePages ()

- VIRTIO_DEVICE_PROTOCOL.MapSharedBuffer () -> no-op

- VIRTIO_DEVICE_PROTOCOL.UnmapSharedBuffer () -> no-op

Suggested-by: Laszlo Ersek <lersek@redhat.com>
Cc: Ard Biesheuvel <ard.biesheuvel@linaro.org>
Cc: Jordan Justen <jordan.l.justen@intel.com>
Cc: Tom Lendacky <thomas.lendacky@amd.com>
Cc: Laszlo Ersek <lersek@redhat.com>
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Brijesh Singh <brijesh.singh@amd.com>
Reviewed-by: Laszlo Ersek <lersek@redhat.com>
Regression-tested-by: Laszlo Ersek <lersek@redhat.com>
OvmfPkg/VirtioPciDeviceDxe/VirtioPciDevice.c
OvmfPkg/VirtioPciDeviceDxe/VirtioPciDevice.h
OvmfPkg/VirtioPciDeviceDxe/VirtioPciFunctions.c

index 8aae58e8b482e8c735c9020c7c14387bf226cf93..d4b4ec21c34d75d8b389538c3b97d417ae6b6eb9 100644 (file)
@@ -5,6 +5,7 @@
   Copyright (C) 2012, Red Hat, Inc.\r
   Copyright (c) 2012 - 2016, Intel Corporation. All rights reserved.<BR>\r
   Copyright (C) 2013, ARM Ltd.\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
@@ -40,7 +41,11 @@ STATIC VIRTIO_DEVICE_PROTOCOL mDeviceProtocolTemplate = {
   VirtioPciGetDeviceStatus,             // GetDeviceStatus\r
   VirtioPciSetDeviceStatus,             // SetDeviceStatus\r
   VirtioPciDeviceWrite,                 // WriteDevice\r
-  VirtioPciDeviceRead                   // ReadDevice\r
+  VirtioPciDeviceRead,                  // ReadDevice\r
+  VirtioPciAllocateSharedPages,         // AllocateSharedPages\r
+  VirtioPciFreeSharedPages,             // FreeSharedPages\r
+  VirtioPciMapSharedBuffer,             // MapSharedBuffer\r
+  VirtioPciUnmapSharedBuffer,           // UnmapSharedBuffer\r
 };\r
 \r
 /**\r
index 6f51f816ef0fec2bd395a1a6bcfd1e0a38413d31..41df5a98e560af12356bab0a9c1f914dba8f1a71 100644 (file)
@@ -3,6 +3,7 @@
   Internal definitions for the VirtIo PCI Device driver\r
 \r
   Copyright (C) 2013, ARM Ltd\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
@@ -156,4 +157,37 @@ VirtioPciSetDeviceStatus (
   IN  UINT8                          DeviceStatus\r
   );\r
 \r
+EFI_STATUS\r
+EFIAPI\r
+VirtioPciAllocateSharedPages (\r
+  IN  VIRTIO_DEVICE_PROTOCOL        *This,\r
+  IN  UINTN                         NumPages,\r
+  OUT VOID                          **HostAddress\r
+  );\r
+\r
+VOID\r
+EFIAPI\r
+VirtioPciFreeSharedPages (\r
+  IN  VIRTIO_DEVICE_PROTOCOL        *This,\r
+  IN  UINTN                         NumPages,\r
+  IN  VOID                          *HostAddress\r
+  );\r
+\r
+EFI_STATUS\r
+EFIAPI\r
+VirtioPciMapSharedBuffer (\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
+EFI_STATUS\r
+EFIAPI\r
+VirtioPciUnmapSharedBuffer (\r
+  IN  VIRTIO_DEVICE_PROTOCOL        *This,\r
+  IN  VOID                          *Mapping\r
+  );\r
 #endif // _VIRTIO_PCI_DEVICE_DXE_H_\r
index 5f86914265eadcffa9a6b2508e91eedcb0417284..bd912cca9b29d47855817a49c080dd4472b7bd4c 100644 (file)
@@ -5,6 +5,7 @@
   Copyright (C) 2012, Red Hat, Inc.\r
   Copyright (c) 2012, Intel Corporation. All rights reserved.<BR>\r
   Copyright (C) 2013, ARM Ltd.\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
@@ -271,3 +272,60 @@ VirtioPciSetDeviceStatus (
   return VirtioPciIoWrite (Dev, VIRTIO_PCI_OFFSET_QUEUE_DEVICE_STATUS,\r
       sizeof (UINT8), DeviceStatus);\r
 }\r
+\r
+EFI_STATUS\r
+EFIAPI\r
+VirtioPciAllocateSharedPages (\r
+  IN  VIRTIO_DEVICE_PROTOCOL  *This,\r
+  IN  UINTN                   NumPages,\r
+  OUT VOID                    **HostAddress\r
+  )\r
+{\r
+  VOID        *Buffer;\r
+\r
+  Buffer = AllocatePages (NumPages);\r
+  if (Buffer == NULL) {\r
+    return EFI_OUT_OF_RESOURCES;\r
+  }\r
+\r
+  *HostAddress = Buffer;\r
+  return EFI_SUCCESS;\r
+}\r
+\r
+VOID\r
+EFIAPI\r
+VirtioPciFreeSharedPages (\r
+  IN  VIRTIO_DEVICE_PROTOCOL  *This,\r
+  IN  UINTN                   NumPages,\r
+  IN  VOID                    *HostAddress\r
+  )\r
+{\r
+  FreePages (HostAddress, NumPages);\r
+}\r
+\r
+EFI_STATUS\r
+EFIAPI\r
+VirtioPciMapSharedBuffer (\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
+  *DeviceAddress = (EFI_PHYSICAL_ADDRESS) (UINTN) HostAddress;\r
+  *Mapping = NULL;\r
+\r
+  return EFI_SUCCESS;\r
+}\r
+\r
+EFI_STATUS\r
+EFIAPI\r
+VirtioPciUnmapSharedBuffer (\r
+  IN VIRTIO_DEVICE_PROTOCOL    *This,\r
+  IN VOID                      *Mapping\r
+  )\r
+{\r
+  return EFI_SUCCESS;\r
+}\r