summaryrefslogtreecommitdiff
path: root/MdeModulePkg/Universal/PcatSingleSegmentPciCfg2Pei/PciCfg2.c
diff options
context:
space:
mode:
Diffstat (limited to 'MdeModulePkg/Universal/PcatSingleSegmentPciCfg2Pei/PciCfg2.c')
-rw-r--r--MdeModulePkg/Universal/PcatSingleSegmentPciCfg2Pei/PciCfg2.c32
1 files changed, 23 insertions, 9 deletions
diff --git a/MdeModulePkg/Universal/PcatSingleSegmentPciCfg2Pei/PciCfg2.c b/MdeModulePkg/Universal/PcatSingleSegmentPciCfg2Pei/PciCfg2.c
index cab55126f8..3542bdd646 100644
--- a/MdeModulePkg/Universal/PcatSingleSegmentPciCfg2Pei/PciCfg2.c
+++ b/MdeModulePkg/Universal/PcatSingleSegmentPciCfg2Pei/PciCfg2.c
@@ -22,13 +22,27 @@
#include <IndustryStandard\Pci.h>
-#define COMMON_TO_PCILIB_ADDRESS(A) (UINTN)PCI_LIB_ADDRESS( \
- ((EFI_PEI_PCI_CFG_PPI_PCI_ADDRESS *) &A)->Bus, \
- ((EFI_PEI_PCI_CFG_PPI_PCI_ADDRESS *) &A)->Device, \
- ((EFI_PEI_PCI_CFG_PPI_PCI_ADDRESS *) &A)->Function, \
- ((EFI_PEI_PCI_CFG_PPI_PCI_ADDRESS *) &A)->Register \
- )
+/**
+ Convert EFI_PEI_PCI_CFG_PPI_PCI_ADDRESS to PCI_LIB_ADDRESS.
+ @param Address PCI address with
+ EFI_PEI_PCI_CFG_PPI_PCI_ADDRESS format.
+
+ @return The PCI address with PCI_LIB_ADDRESS format.
+
+**/
+STATIC
+UINTN
+PciCfgAddressConvert (
+ EFI_PEI_PCI_CFG_PPI_PCI_ADDRESS *Address
+ )
+{
+ if (Address->ExtendedRegister == 0) {
+ return PCI_LIB_ADDRESS (Address->Bus, Address->Device, Address->Function, Address->Register);
+ }
+
+ return PCI_LIB_ADDRESS (Address->Bus, Address->Device, Address->Function, Address->ExtendedRegister);
+}
/**
Reads from a given location in the PCI configuration space.
@@ -206,7 +220,7 @@ PciCfg2Read (
{
UINTN PciLibAddress;
- PciLibAddress = COMMON_TO_PCILIB_ADDRESS (Address);
+ PciLibAddress = PciCfgAddressConvert ((EFI_PEI_PCI_CFG_PPI_PCI_ADDRESS *) &Address);
if (Width == EfiPeiPciCfgWidthUint8) {
*((UINT8 *) Buffer) = PciRead8 (PciLibAddress);
@@ -257,7 +271,7 @@ PciCfg2Write (
{
UINTN PciLibAddress;
- PciLibAddress = COMMON_TO_PCILIB_ADDRESS (Address);
+ PciLibAddress = PciCfgAddressConvert ((EFI_PEI_PCI_CFG_PPI_PCI_ADDRESS *) &Address);
if (Width == EfiPeiPciCfgWidthUint8) {
PciWrite8 (PciLibAddress, *((UINT8 *) Buffer));
@@ -315,7 +329,7 @@ PciCfg2Modify (
{
UINTN PciLibAddress;
- PciLibAddress = COMMON_TO_PCILIB_ADDRESS (Address);
+ PciLibAddress = PciCfgAddressConvert ((EFI_PEI_PCI_CFG_PPI_PCI_ADDRESS *) &Address);
if (Width == EfiPeiPciCfgWidthUint8) {
PciAndThenOr8 (PciLibAddress, ~(*(UINT8 *)ClearBits), *((UINT8 *) SetBits));