summaryrefslogtreecommitdiffstats
path: root/OvmfPkg/VirtioPciDeviceDxe/VirtioPciFunctions.c
diff options
context:
space:
mode:
Diffstat (limited to 'OvmfPkg/VirtioPciDeviceDxe/VirtioPciFunctions.c')
-rw-r--r--OvmfPkg/VirtioPciDeviceDxe/VirtioPciFunctions.c165
1 files changed, 105 insertions, 60 deletions
diff --git a/OvmfPkg/VirtioPciDeviceDxe/VirtioPciFunctions.c b/OvmfPkg/VirtioPciDeviceDxe/VirtioPciFunctions.c
index 46a9354be0..92165de226 100644
--- a/OvmfPkg/VirtioPciDeviceDxe/VirtioPciFunctions.c
+++ b/OvmfPkg/VirtioPciDeviceDxe/VirtioPciFunctions.c
@@ -42,20 +42,24 @@
EFI_STATUS
EFIAPI
VirtioPciDeviceRead (
- IN VIRTIO_DEVICE_PROTOCOL *This,
- IN UINTN FieldOffset,
- IN UINTN FieldSize,
- IN UINTN BufferSize,
- OUT VOID *Buffer
+ IN VIRTIO_DEVICE_PROTOCOL *This,
+ IN UINTN FieldOffset,
+ IN UINTN FieldSize,
+ IN UINTN BufferSize,
+ OUT VOID *Buffer
)
{
- VIRTIO_PCI_DEVICE *Dev;
+ VIRTIO_PCI_DEVICE *Dev;
Dev = VIRTIO_PCI_DEVICE_FROM_VIRTIO_DEVICE (This);
- return VirtioPciIoRead (Dev,
- Dev->DeviceSpecificConfigurationOffset + FieldOffset,
- FieldSize, BufferSize, Buffer);
+ return VirtioPciIoRead (
+ Dev,
+ Dev->DeviceSpecificConfigurationOffset + FieldOffset,
+ FieldSize,
+ BufferSize,
+ Buffer
+ );
}
/**
@@ -78,30 +82,34 @@ VirtioPciDeviceRead (
EFI_STATUS
EFIAPI
VirtioPciDeviceWrite (
- IN VIRTIO_DEVICE_PROTOCOL *This,
- IN UINTN FieldOffset,
- IN UINTN FieldSize,
- IN UINT64 Value
+ IN VIRTIO_DEVICE_PROTOCOL *This,
+ IN UINTN FieldOffset,
+ IN UINTN FieldSize,
+ IN UINT64 Value
)
{
- VIRTIO_PCI_DEVICE *Dev;
+ VIRTIO_PCI_DEVICE *Dev;
Dev = VIRTIO_PCI_DEVICE_FROM_VIRTIO_DEVICE (This);
- return VirtioPciIoWrite (Dev,
- Dev->DeviceSpecificConfigurationOffset + FieldOffset, FieldSize, Value);
+ return VirtioPciIoWrite (
+ Dev,
+ Dev->DeviceSpecificConfigurationOffset + FieldOffset,
+ FieldSize,
+ Value
+ );
}
EFI_STATUS
EFIAPI
VirtioPciGetDeviceFeatures (
- IN VIRTIO_DEVICE_PROTOCOL *This,
- OUT UINT64 *DeviceFeatures
+ IN VIRTIO_DEVICE_PROTOCOL *This,
+ OUT UINT64 *DeviceFeatures
)
{
- VIRTIO_PCI_DEVICE *Dev;
- EFI_STATUS Status;
- UINT32 Features32;
+ VIRTIO_PCI_DEVICE *Dev;
+ EFI_STATUS Status;
+ UINT32 Features32;
if (DeviceFeatures == NULL) {
return EFI_INVALID_PARAMETER;
@@ -109,11 +117,17 @@ VirtioPciGetDeviceFeatures (
Dev = VIRTIO_PCI_DEVICE_FROM_VIRTIO_DEVICE (This);
- Status = VirtioPciIoRead (Dev, VIRTIO_PCI_OFFSET_DEVICE_FEATURES,
- sizeof (UINT32), sizeof (UINT32), &Features32);
+ Status = VirtioPciIoRead (
+ Dev,
+ VIRTIO_PCI_OFFSET_DEVICE_FEATURES,
+ sizeof (UINT32),
+ sizeof (UINT32),
+ &Features32
+ );
if (!EFI_ERROR (Status)) {
*DeviceFeatures = Features32;
}
+
return Status;
}
@@ -124,7 +138,7 @@ VirtioPciGetQueueSize (
OUT UINT16 *QueueNumMax
)
{
- VIRTIO_PCI_DEVICE *Dev;
+ VIRTIO_PCI_DEVICE *Dev;
if (QueueNumMax == NULL) {
return EFI_INVALID_PARAMETER;
@@ -132,8 +146,13 @@ VirtioPciGetQueueSize (
Dev = VIRTIO_PCI_DEVICE_FROM_VIRTIO_DEVICE (This);
- return VirtioPciIoRead (Dev, VIRTIO_PCI_OFFSET_QUEUE_SIZE, sizeof (UINT16),
- sizeof (UINT16), QueueNumMax);
+ return VirtioPciIoRead (
+ Dev,
+ VIRTIO_PCI_OFFSET_QUEUE_SIZE,
+ sizeof (UINT16),
+ sizeof (UINT16),
+ QueueNumMax
+ );
}
EFI_STATUS
@@ -143,7 +162,7 @@ VirtioPciGetDeviceStatus (
OUT UINT8 *DeviceStatus
)
{
- VIRTIO_PCI_DEVICE *Dev;
+ VIRTIO_PCI_DEVICE *Dev;
if (DeviceStatus == NULL) {
return EFI_INVALID_PARAMETER;
@@ -151,26 +170,36 @@ VirtioPciGetDeviceStatus (
Dev = VIRTIO_PCI_DEVICE_FROM_VIRTIO_DEVICE (This);
- return VirtioPciIoRead (Dev, VIRTIO_PCI_OFFSET_QUEUE_DEVICE_STATUS,
- sizeof (UINT8), sizeof (UINT8), DeviceStatus);
+ return VirtioPciIoRead (
+ Dev,
+ VIRTIO_PCI_OFFSET_QUEUE_DEVICE_STATUS,
+ sizeof (UINT8),
+ sizeof (UINT8),
+ DeviceStatus
+ );
}
EFI_STATUS
EFIAPI
VirtioPciSetGuestFeatures (
IN VIRTIO_DEVICE_PROTOCOL *This,
- IN UINT64 Features
+ IN UINT64 Features
)
{
- VIRTIO_PCI_DEVICE *Dev;
+ VIRTIO_PCI_DEVICE *Dev;
Dev = VIRTIO_PCI_DEVICE_FROM_VIRTIO_DEVICE (This);
if (Features > MAX_UINT32) {
return EFI_UNSUPPORTED;
}
- return VirtioPciIoWrite (Dev, VIRTIO_PCI_OFFSET_GUEST_FEATURES,
- sizeof (UINT32), Features);
+
+ return VirtioPciIoWrite (
+ Dev,
+ VIRTIO_PCI_OFFSET_GUEST_FEATURES,
+ sizeof (UINT32),
+ Features
+ );
}
EFI_STATUS
@@ -181,35 +210,43 @@ VirtioPciSetQueueAddress (
IN UINT64 RingBaseShift
)
{
- VIRTIO_PCI_DEVICE *Dev;
+ VIRTIO_PCI_DEVICE *Dev;
ASSERT (RingBaseShift == 0);
Dev = VIRTIO_PCI_DEVICE_FROM_VIRTIO_DEVICE (This);
- return VirtioPciIoWrite (Dev, VIRTIO_PCI_OFFSET_QUEUE_ADDRESS, sizeof (UINT32),
- (UINT32)((UINTN)Ring->Base >> EFI_PAGE_SHIFT));
+ return VirtioPciIoWrite (
+ Dev,
+ VIRTIO_PCI_OFFSET_QUEUE_ADDRESS,
+ sizeof (UINT32),
+ (UINT32)((UINTN)Ring->Base >> EFI_PAGE_SHIFT)
+ );
}
EFI_STATUS
EFIAPI
VirtioPciSetQueueSel (
- IN VIRTIO_DEVICE_PROTOCOL *This,
- IN UINT16 Sel
+ IN VIRTIO_DEVICE_PROTOCOL *This,
+ IN UINT16 Sel
)
{
- VIRTIO_PCI_DEVICE *Dev;
+ VIRTIO_PCI_DEVICE *Dev;
Dev = VIRTIO_PCI_DEVICE_FROM_VIRTIO_DEVICE (This);
- return VirtioPciIoWrite (Dev, VIRTIO_PCI_OFFSET_QUEUE_SELECT, sizeof (UINT16),
- Sel);
+ return VirtioPciIoWrite (
+ Dev,
+ VIRTIO_PCI_OFFSET_QUEUE_SELECT,
+ sizeof (UINT16),
+ Sel
+ );
}
EFI_STATUS
EFIAPI
VirtioPciSetQueueAlignment (
- IN VIRTIO_DEVICE_PROTOCOL *This,
+ IN VIRTIO_DEVICE_PROTOCOL *This,
IN UINT32 Alignment
)
{
@@ -219,7 +256,7 @@ VirtioPciSetQueueAlignment (
EFI_STATUS
EFIAPI
VirtioPciSetPageSize (
- IN VIRTIO_DEVICE_PROTOCOL *This,
+ IN VIRTIO_DEVICE_PROTOCOL *This,
IN UINT32 PageSize
)
{
@@ -229,23 +266,27 @@ VirtioPciSetPageSize (
EFI_STATUS
EFIAPI
VirtioPciSetQueueNotify (
- IN VIRTIO_DEVICE_PROTOCOL *This,
- IN UINT16 Index
+ IN VIRTIO_DEVICE_PROTOCOL *This,
+ IN UINT16 Index
)
{
- VIRTIO_PCI_DEVICE *Dev;
+ VIRTIO_PCI_DEVICE *Dev;
Dev = VIRTIO_PCI_DEVICE_FROM_VIRTIO_DEVICE (This);
- return VirtioPciIoWrite (Dev, VIRTIO_PCI_OFFSET_QUEUE_NOTIFY, sizeof (UINT16),
- Index);
+ return VirtioPciIoWrite (
+ Dev,
+ VIRTIO_PCI_OFFSET_QUEUE_NOTIFY,
+ sizeof (UINT16),
+ Index
+ );
}
EFI_STATUS
EFIAPI
VirtioPciSetQueueSize (
- IN VIRTIO_DEVICE_PROTOCOL *This,
- IN UINT16 Size
+ IN VIRTIO_DEVICE_PROTOCOL *This,
+ IN UINT16 Size
)
{
//
@@ -258,16 +299,20 @@ VirtioPciSetQueueSize (
EFI_STATUS
EFIAPI
VirtioPciSetDeviceStatus (
- IN VIRTIO_DEVICE_PROTOCOL *This,
- IN UINT8 DeviceStatus
+ IN VIRTIO_DEVICE_PROTOCOL *This,
+ IN UINT8 DeviceStatus
)
{
- VIRTIO_PCI_DEVICE *Dev;
+ VIRTIO_PCI_DEVICE *Dev;
Dev = VIRTIO_PCI_DEVICE_FROM_VIRTIO_DEVICE (This);
- return VirtioPciIoWrite (Dev, VIRTIO_PCI_OFFSET_QUEUE_DEVICE_STATUS,
- sizeof (UINT8), DeviceStatus);
+ return VirtioPciIoWrite (
+ Dev,
+ VIRTIO_PCI_OFFSET_QUEUE_DEVICE_STATUS,
+ sizeof (UINT8),
+ DeviceStatus
+ );
}
EFI_STATUS
@@ -278,7 +323,7 @@ VirtioPciAllocateSharedPages (
OUT VOID **HostAddress
)
{
- VOID *Buffer;
+ VOID *Buffer;
Buffer = AllocatePages (NumPages);
if (Buffer == NULL) {
@@ -311,8 +356,8 @@ VirtioPciMapSharedBuffer (
OUT VOID **Mapping
)
{
- *DeviceAddress = (EFI_PHYSICAL_ADDRESS) (UINTN) HostAddress;
- *Mapping = NULL;
+ *DeviceAddress = (EFI_PHYSICAL_ADDRESS)(UINTN)HostAddress;
+ *Mapping = NULL;
return EFI_SUCCESS;
}
@@ -320,8 +365,8 @@ VirtioPciMapSharedBuffer (
EFI_STATUS
EFIAPI
VirtioPciUnmapSharedBuffer (
- IN VIRTIO_DEVICE_PROTOCOL *This,
- IN VOID *Mapping
+ IN VIRTIO_DEVICE_PROTOCOL *This,
+ IN VOID *Mapping
)
{
return EFI_SUCCESS;