X-Git-Url: https://git.proxmox.com/?a=blobdiff_plain;f=OvmfPkg%2FInclude%2FLibrary%2FVirtioLib.h;h=e714ec7aee500b3828e257afcf5321cdc9b7e124;hb=9854561c085df43139625aa275dd67144c75e432;hp=660ea2767781b940126f8ad022deb0200d13f040;hpb=0a78d754edc82ed0dae07c3d505b88fce8b5bd09;p=mirror_edk2.git diff --git a/OvmfPkg/Include/Library/VirtioLib.h b/OvmfPkg/Include/Library/VirtioLib.h index 660ea27677..e714ec7aee 100644 --- a/OvmfPkg/Include/Library/VirtioLib.h +++ b/OvmfPkg/Include/Library/VirtioLib.h @@ -5,13 +5,7 @@ Copyright (C) 2012-2016, Red Hat, Inc. Copyright (C) 2017, AMD Inc, All rights reserved.
- 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. + SPDX-License-Identifier: BSD-2-Clause-Patent **/ @@ -35,14 +29,15 @@ - 1.1 Virtqueues, - 2.3 Virtqueue Configuration. + @param[in] VirtIo The virtio device which will use the ring. + @param[in] The number of descriptors to allocate for the virtio ring, as requested by the host. @param[out] Ring The virtio ring to set up. - @retval EFI_OUT_OF_RESOURCES AllocatePages() failed to allocate contiguous - pages for the requested QueueSize. Fields of - Ring have indeterminate value. + @return Status codes propagated from + VirtIo->AllocateSharedPages(). @retval EFI_SUCCESS Allocation and setup successful. Ring->Base (and nothing else) is responsible for @@ -52,11 +47,38 @@ EFI_STATUS EFIAPI VirtioRingInit ( - IN UINT16 QueueSize, - OUT VRING *Ring + IN VIRTIO_DEVICE_PROTOCOL *VirtIo, + IN UINT16 QueueSize, + OUT VRING *Ring ); +/** + + Map the ring buffer so that it can be accessed equally by both guest + and hypervisor. + + @param[in] VirtIo The virtio device instance. + + @param[in] Ring The virtio ring to map. + + @param[out] RingBaseShift A resulting translation offset, to be + passed to VirtIo->SetQueueAddress(). + + @param[out] Mapping A resulting token to pass to + VirtIo->UnmapSharedBuffer(). + + @return Status code from VirtIo->MapSharedBuffer() +**/ +EFI_STATUS +EFIAPI +VirtioRingMap ( + IN VIRTIO_DEVICE_PROTOCOL *VirtIo, + IN VRING *Ring, + OUT UINT64 *RingBaseShift, + OUT VOID **Mapping + ); + /** Tear down the internal resources of a configured virtio ring. @@ -65,13 +87,16 @@ VirtioRingInit ( invoking this function: the VSTAT_DRIVER_OK bit must be clear in VhdrDeviceStatus. - @param[out] Ring The virtio ring to clean up. + @param[in] VirtIo The virtio device which was using the ring. + + @param[out] Ring The virtio ring to clean up. **/ VOID EFIAPI VirtioRingUninit ( - IN OUT VRING *Ring + IN VIRTIO_DEVICE_PROTOCOL *VirtIo, + IN OUT VRING *Ring ); @@ -120,33 +145,34 @@ VirtioPrepare ( The caller is responsible for initializing *Indices with VirtioPrepare() first. - @param[in,out] Ring The virtio ring to append the buffer to, as a - descriptor. + @param[in,out] Ring The virtio ring to append the buffer to, + as a descriptor. - @param[in] BufferPhysAddr (Guest pseudo-physical) start address of the - transmit / receive buffer. + @param[in] BufferDeviceAddress (Bus master device) start address of the + transmit / receive buffer. - @param[in] BufferSize Number of bytes to transmit or receive. + @param[in] BufferSize Number of bytes to transmit or receive. - @param[in] Flags A bitmask of VRING_DESC_F_* flags. The caller - computes this mask dependent on further buffers to - append and transfer direction. - VRING_DESC_F_INDIRECT is unsupported. The - VRING_DESC.Next field is always set, but the host - only interprets it dependent on VRING_DESC_F_NEXT. + @param[in] Flags A bitmask of VRING_DESC_F_* flags. The + caller computes this mask dependent on + further buffers to append and transfer + direction. VRING_DESC_F_INDIRECT is + unsupported. The VRING_DESC.Next field is + always set, but the host only interprets + it dependent on VRING_DESC_F_NEXT. - @param[in,out] Indices Indices->HeadDescIdx is not accessed. - On input, Indices->NextDescIdx identifies the next - descriptor to carry the buffer. On output, - Indices->NextDescIdx is incremented by one, modulo - 2^16. + @param[in,out] Indices Indices->HeadDescIdx is not accessed. + On input, Indices->NextDescIdx identifies + the next descriptor to carry the buffer. + On output, Indices->NextDescIdx is + incremented by one, modulo 2^16. **/ VOID EFIAPI VirtioAppendDesc ( IN OUT VRING *Ring, - IN UINTN BufferPhysAddr, + IN UINT64 BufferDeviceAddress, IN UINT32 BufferSize, IN UINT16 Flags, IN OUT DESC_INDICES *Indices @@ -266,7 +292,7 @@ Virtio10WriteFeatures ( VIRTIO_UNMAP_SHARED. - @retval EFI_SUCCESS The NumberOfBytes is succesfully mapped. + @retval EFI_SUCCESS The NumberOfBytes is successfully mapped. @retval EFI_UNSUPPORTED The HostAddress cannot be mapped as a common buffer. @retval EFI_INVALID_PARAMETER One or more parameters are invalid.