summaryrefslogtreecommitdiff
path: root/OvmfPkg/Library/VirtioLib/VirtioLib.c
diff options
context:
space:
mode:
authorSteven Kinney <steven.kinney@linaro.org>2013-11-22 08:15:09 -0600
committerSteven Kinney <steven.kinney@linaro.org>2013-11-22 08:15:09 -0600
commitaec0833cc55918a9111af736171ba8ceb976824e (patch)
tree3b188d6e0c1075a5df74f724bb302486454e25e8 /OvmfPkg/Library/VirtioLib/VirtioLib.c
parente08b4a7ea684e3358f0281da5e23ae03b1b14116 (diff)
parent0caeca1501ec2edee346a3108f45e556e7905204 (diff)
Merging uefi-next/linaro-release into masterlinaro-uefi-2013.11
Signed-off-by: Steven Kinney <steven.kinney@linaro.org>
Diffstat (limited to 'OvmfPkg/Library/VirtioLib/VirtioLib.c')
-rw-r--r--OvmfPkg/Library/VirtioLib/VirtioLib.c158
1 files changed, 8 insertions, 150 deletions
diff --git a/OvmfPkg/Library/VirtioLib/VirtioLib.c b/OvmfPkg/Library/VirtioLib/VirtioLib.c
index 959bc5da8..1550318d8 100644
--- a/OvmfPkg/Library/VirtioLib/VirtioLib.c
+++ b/OvmfPkg/Library/VirtioLib/VirtioLib.c
@@ -3,6 +3,7 @@
Utility functions used by virtio device drivers.
Copyright (C) 2012, Red Hat, Inc.
+ Portion of Copyright (C) 2013, ARM Ltd.
This program and the accompanying materials are licensed and made available
under the terms and conditions of the BSD License which accompanies this
@@ -14,7 +15,6 @@
**/
-#include <IndustryStandard/Pci22.h>
#include <Library/BaseLib.h>
#include <Library/BaseMemoryLib.h>
#include <Library/DebugLib.h>
@@ -26,143 +26,6 @@
/**
- Write a word into Region 0 of the device specified by PciIo.
-
- Region 0 must be an iomem region. This is an internal function for the
- driver-specific VIRTIO_CFG_WRITE() macros.
-
- @param[in] PciIo Target PCI device.
-
- @param[in] FieldOffset Destination offset.
-
- @param[in] FieldSize Destination field size, must be in { 1, 2, 4, 8 }.
-
- @param[in] Value Little endian value to write, converted to UINT64.
- The least significant FieldSize bytes will be used.
-
-
- @return Status code returned by PciIo->Io.Write().
-
-**/
-EFI_STATUS
-EFIAPI
-VirtioWrite (
- IN EFI_PCI_IO_PROTOCOL *PciIo,
- IN UINTN FieldOffset,
- IN UINTN FieldSize,
- IN UINT64 Value
- )
-{
- UINTN Count;
- EFI_PCI_IO_PROTOCOL_WIDTH Width;
-
- Count = 1;
- switch (FieldSize) {
- case 1:
- Width = EfiPciIoWidthUint8;
- break;
-
- case 2:
- Width = EfiPciIoWidthUint16;
- break;
-
- case 8:
- Count = 2;
- // fall through
-
- case 4:
- Width = EfiPciIoWidthUint32;
- break;
-
- default:
- ASSERT (FALSE);
- return EFI_INVALID_PARAMETER;
- }
-
- return PciIo->Io.Write (
- PciIo,
- Width,
- PCI_BAR_IDX0,
- FieldOffset,
- Count,
- &Value
- );
-}
-
-
-/**
-
- Read a word from Region 0 of the device specified by PciIo.
-
- Region 0 must be an iomem region. This is an internal function for the
- driver-specific VIRTIO_CFG_READ() macros.
-
- @param[in] PciIo Source PCI device.
-
- @param[in] FieldOffset Source offset.
-
- @param[in] FieldSize Source field size, must be in { 1, 2, 4, 8 }.
-
- @param[in] BufferSize Number of bytes available in the target buffer. Must
- equal FieldSize.
-
- @param[out] Buffer Target buffer.
-
-
- @return Status code returned by PciIo->Io.Read().
-
-**/
-EFI_STATUS
-EFIAPI
-VirtioRead (
- IN EFI_PCI_IO_PROTOCOL *PciIo,
- IN UINTN FieldOffset,
- IN UINTN FieldSize,
- IN UINTN BufferSize,
- OUT VOID *Buffer
- )
-{
- UINTN Count;
- EFI_PCI_IO_PROTOCOL_WIDTH Width;
-
- ASSERT (FieldSize == BufferSize);
-
- Count = 1;
- switch (FieldSize) {
- case 1:
- Width = EfiPciIoWidthUint8;
- break;
-
- case 2:
- Width = EfiPciIoWidthUint16;
- break;
-
- case 8:
- Count = 2;
- // fall through
-
- case 4:
- Width = EfiPciIoWidthUint32;
- break;
-
- default:
- ASSERT (FALSE);
- return EFI_INVALID_PARAMETER;
- }
-
- return PciIo->Io.Read (
- PciIo,
- Width,
- PCI_BAR_IDX0,
- FieldOffset,
- Count,
- Buffer
- );
-}
-
-
-/**
-
Configure a virtio ring.
This function sets up internal storage (the guest-host communication area)
@@ -376,7 +239,7 @@ VirtioAppendDesc (
Notify the host about the descriptor chain just built, and wait until the
host processes it.
- @param[in] PciIo The target virtio PCI device to notify.
+ @param[in] VirtIo The target virtio device to notify.
@param[in] VirtQueueId Identifies the queue for the target device.
@@ -387,7 +250,7 @@ VirtioAppendDesc (
of the descriptor chain.
- @return Error code from VirtioWrite() if it fails.
+ @return Error code from VirtioWriteDevice() if it fails.
@retval EFI_SUCCESS Otherwise, the host processed all descriptors.
@@ -395,10 +258,10 @@ VirtioAppendDesc (
EFI_STATUS
EFIAPI
VirtioFlush (
- IN EFI_PCI_IO_PROTOCOL *PciIo,
- IN UINT16 VirtQueueId,
- IN OUT VRING *Ring,
- IN DESC_INDICES *Indices
+ IN VIRTIO_DEVICE_PROTOCOL *VirtIo,
+ IN UINT16 VirtQueueId,
+ IN OUT VRING *Ring,
+ IN DESC_INDICES *Indices
)
{
UINT16 NextAvailIdx;
@@ -427,12 +290,7 @@ VirtioFlush (
// OK.
//
MemoryFence();
- Status = VirtioWrite (
- PciIo,
- OFFSET_OF (VIRTIO_HDR, VhdrQueueNotify),
- sizeof (UINT16),
- VirtQueueId
- );
+ Status = VirtIo->SetQueueNotify (VirtIo, VirtQueueId);
if (EFI_ERROR (Status)) {
return Status;
}