/* Map the ring buffer so that it can be accessed equally by both guest and hypervisor. */
EFI_STATUS EFIAPI VirtioRingMap(IN VIRTIO_DEVICE_PROTOCOL *VirtIo, IN VRING *Ring, OUT UINT64 *RingBaseShift, OUT VOID **Mapping)
/* Map the ring buffer so that it can be accessed equally by both guest and hypervisor. */
EFI_STATUS EFIAPI VirtioRingMap(IN VIRTIO_DEVICE_PROTOCOL *VirtIo, IN VRING *Ring, OUT UINT64 *RingBaseShift, OUT VOID **Mapping)
{
  EFI_STATUS            Status;
  EFI_PHYSICAL_ADDRESS  DeviceAddress;
  Status = VirtioMapAllBytesInSharedBuffer (
             VirtIo,
             VirtioOperationBusMasterCommonBuffer,
             Ring->Base,
             EFI_PAGES_TO_SIZE (Ring->NumPages),
             &DeviceAddress,
             Mapping
             );
  if (EFI_ERROR (Status)) {
    return Status;
  }
  *RingBaseShift = DeviceAddress - (UINT64)(UINTN)Ring->Base;
  return EFI_SUCCESS;
}