OvmfPkg/VirtioMmioDeviceLib: implement IOMMU-like member functions

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>
This commit is contained in:
Brijesh Singh
2017-08-23 06:57:16 -04:00
committed by Laszlo Ersek
parent 4157b8416a
commit 084cfc1a35
3 changed files with 99 additions and 2 deletions

View File

@@ -293,3 +293,60 @@ VirtioMmioDeviceRead (
return EFI_SUCCESS;
}
EFI_STATUS
EFIAPI
VirtioMmioAllocateSharedPages (
IN VIRTIO_DEVICE_PROTOCOL *This,
IN UINTN NumPages,
OUT VOID **HostAddress
)
{
VOID *Buffer;
Buffer = AllocatePages (NumPages);
if (Buffer == NULL) {
return EFI_OUT_OF_RESOURCES;
}
*HostAddress = Buffer;
return EFI_SUCCESS;
}
VOID
EFIAPI
VirtioMmioFreeSharedPages (
IN VIRTIO_DEVICE_PROTOCOL *This,
IN UINTN NumPages,
IN VOID *HostAddress
)
{
FreePages (HostAddress, NumPages);
}
EFI_STATUS
EFIAPI
VirtioMmioMapSharedBuffer (
IN VIRTIO_DEVICE_PROTOCOL *This,
IN VIRTIO_MAP_OPERATION Operation,
IN VOID *HostAddress,
IN OUT UINTN *NumberOfBytes,
OUT EFI_PHYSICAL_ADDRESS *DeviceAddress,
OUT VOID **Mapping
)
{
*DeviceAddress = (EFI_PHYSICAL_ADDRESS) (UINTN) HostAddress;
*Mapping = NULL;
return EFI_SUCCESS;
}
EFI_STATUS
EFIAPI
VirtioMmioUnmapSharedBuffer (
IN VIRTIO_DEVICE_PROTOCOL *This,
IN VOID *Mapping
)
{
return EFI_SUCCESS;
}