summaryrefslogtreecommitdiffstats
path: root/OvmfPkg/Library/BasePciCapPciSegmentLib/BasePciCapPciSegmentLib.c
diff options
context:
space:
mode:
Diffstat (limited to 'OvmfPkg/Library/BasePciCapPciSegmentLib/BasePciCapPciSegmentLib.c')
-rw-r--r--OvmfPkg/Library/BasePciCapPciSegmentLib/BasePciCapPciSegmentLib.c78
1 files changed, 42 insertions, 36 deletions
diff --git a/OvmfPkg/Library/BasePciCapPciSegmentLib/BasePciCapPciSegmentLib.c b/OvmfPkg/Library/BasePciCapPciSegmentLib/BasePciCapPciSegmentLib.c
index 81f2a3eb06..8e7ea583fa 100644
--- a/OvmfPkg/Library/BasePciCapPciSegmentLib/BasePciCapPciSegmentLib.c
+++ b/OvmfPkg/Library/BasePciCapPciSegmentLib/BasePciCapPciSegmentLib.c
@@ -14,7 +14,6 @@
#include "BasePciCapPciSegmentLib.h"
-
/**
Read the config space of a given PCI device (both normal and extended).
@@ -44,17 +43,17 @@ STATIC
RETURN_STATUS
EFIAPI
SegmentDevReadConfig (
- IN PCI_CAP_DEV *PciDevice,
- IN UINT16 SourceOffset,
- OUT VOID *DestinationBuffer,
- IN UINT16 Size
+ IN PCI_CAP_DEV *PciDevice,
+ IN UINT16 SourceOffset,
+ OUT VOID *DestinationBuffer,
+ IN UINT16 Size
)
{
- SEGMENT_DEV *SegmentDev;
- UINT16 ConfigSpaceSize;
- UINT64 SourceAddress;
+ SEGMENT_DEV *SegmentDev;
+ UINT16 ConfigSpaceSize;
+ UINT64 SourceAddress;
- SegmentDev = SEGMENT_DEV_FROM_PCI_CAP_DEV (PciDevice);
+ SegmentDev = SEGMENT_DEV_FROM_PCI_CAP_DEV (PciDevice);
ConfigSpaceSize = (SegmentDev->MaxDomain == PciCapNormal ?
PCI_MAX_CONFIG_OFFSET : PCI_EXP_MAX_CONFIG_OFFSET);
//
@@ -64,14 +63,18 @@ SegmentDevReadConfig (
if (SourceOffset + Size > ConfigSpaceSize) {
return RETURN_UNSUPPORTED;
}
- SourceAddress = PCI_SEGMENT_LIB_ADDRESS (SegmentDev->SegmentNr,
- SegmentDev->BusNr, SegmentDev->DeviceNr,
- SegmentDev->FunctionNr, SourceOffset);
+
+ SourceAddress = PCI_SEGMENT_LIB_ADDRESS (
+ SegmentDev->SegmentNr,
+ SegmentDev->BusNr,
+ SegmentDev->DeviceNr,
+ SegmentDev->FunctionNr,
+ SourceOffset
+ );
PciSegmentReadBuffer (SourceAddress, Size, DestinationBuffer);
return RETURN_SUCCESS;
}
-
/**
Write the config space of a given PCI device (both normal and extended).
@@ -101,17 +104,17 @@ STATIC
RETURN_STATUS
EFIAPI
SegmentDevWriteConfig (
- IN PCI_CAP_DEV *PciDevice,
- IN UINT16 DestinationOffset,
- IN VOID *SourceBuffer,
- IN UINT16 Size
+ IN PCI_CAP_DEV *PciDevice,
+ IN UINT16 DestinationOffset,
+ IN VOID *SourceBuffer,
+ IN UINT16 Size
)
{
- SEGMENT_DEV *SegmentDev;
- UINT16 ConfigSpaceSize;
- UINT64 DestinationAddress;
+ SEGMENT_DEV *SegmentDev;
+ UINT16 ConfigSpaceSize;
+ UINT64 DestinationAddress;
- SegmentDev = SEGMENT_DEV_FROM_PCI_CAP_DEV (PciDevice);
+ SegmentDev = SEGMENT_DEV_FROM_PCI_CAP_DEV (PciDevice);
ConfigSpaceSize = (SegmentDev->MaxDomain == PciCapNormal ?
PCI_MAX_CONFIG_OFFSET : PCI_EXP_MAX_CONFIG_OFFSET);
//
@@ -121,14 +124,18 @@ SegmentDevWriteConfig (
if (DestinationOffset + Size > ConfigSpaceSize) {
return RETURN_UNSUPPORTED;
}
- DestinationAddress = PCI_SEGMENT_LIB_ADDRESS (SegmentDev->SegmentNr,
- SegmentDev->BusNr, SegmentDev->DeviceNr,
- SegmentDev->FunctionNr, DestinationOffset);
+
+ DestinationAddress = PCI_SEGMENT_LIB_ADDRESS (
+ SegmentDev->SegmentNr,
+ SegmentDev->BusNr,
+ SegmentDev->DeviceNr,
+ SegmentDev->FunctionNr,
+ DestinationOffset
+ );
PciSegmentWriteBuffer (DestinationAddress, Size, SourceBuffer);
return RETURN_SUCCESS;
}
-
/**
Create a PCI_CAP_DEV object from the PCI Segment:Bus:Device.Function
quadruplet. The config space accessors are based upon PciSegmentLib.
@@ -168,17 +175,17 @@ SegmentDevWriteConfig (
RETURN_STATUS
EFIAPI
PciCapPciSegmentDeviceInit (
- IN PCI_CAP_DOMAIN MaxDomain,
- IN UINT16 Segment,
- IN UINT8 Bus,
- IN UINT8 Device,
- IN UINT8 Function,
- OUT PCI_CAP_DEV **PciDevice
+ IN PCI_CAP_DOMAIN MaxDomain,
+ IN UINT16 Segment,
+ IN UINT8 Bus,
+ IN UINT8 Device,
+ IN UINT8 Function,
+ OUT PCI_CAP_DEV **PciDevice
)
{
- SEGMENT_DEV *SegmentDev;
+ SEGMENT_DEV *SegmentDev;
- if (Device > PCI_MAX_DEVICE || Function > PCI_MAX_FUNC) {
+ if ((Device > PCI_MAX_DEVICE) || (Function > PCI_MAX_FUNC)) {
return RETURN_INVALID_PARAMETER;
}
@@ -200,7 +207,6 @@ PciCapPciSegmentDeviceInit (
return RETURN_SUCCESS;
}
-
/**
Free the resources used by PciDevice.
@@ -210,10 +216,10 @@ PciCapPciSegmentDeviceInit (
VOID
EFIAPI
PciCapPciSegmentDeviceUninit (
- IN PCI_CAP_DEV *PciDevice
+ IN PCI_CAP_DEV *PciDevice
)
{
- SEGMENT_DEV *SegmentDev;
+ SEGMENT_DEV *SegmentDev;
SegmentDev = SEGMENT_DEV_FROM_PCI_CAP_DEV (PciDevice);
FreePool (SegmentDev);