OvmfPkg/FdtPciHostBridgeLib: Use MapMmioLib for MMIO mapping

Replace the local GCD MMIO mapping helper with MapMmioMemory() when
mapping the PCI ECAM region and the translated I/O MMIO window.

This keeps the FDT PCI host bridge code aligned with the common MMIO
mapping helper and avoids duplicating AddMemorySpace() and
SetMemorySpaceAttributes() handling.

Signed-off-by: Sami Mujawar <sami.mujawar@arm.com>
This commit is contained in:
Sami Mujawar 2026-07-01 18:56:25 +01:00 committed by mergify[bot]
parent 9dcf9d317a
commit d46e38c5ea
5 changed files with 8 additions and 44 deletions

View file

@ -2,6 +2,7 @@
PCI Host Bridge Library instance for pci-ecam-generic DT nodes
Copyright (c) 2016, Linaro Ltd. All rights reserved.<BR>
Copyright (c) 2026, Arm Ltd. All rights reserved.<BR>
SPDX-License-Identifier: BSD-2-Clause-Patent
@ -10,7 +11,7 @@
#include <Library/BaseMemoryLib.h>
#include <Library/DebugLib.h>
#include <Library/DevicePathLib.h>
#include <Library/DxeServicesTableLib.h>
#include <Library/MapMmioLib.h>
#include <Library/MemoryAllocationLib.h>
#include <Library/PcdLib.h>
#include <Library/PciHostBridgeLib.h>
@ -42,46 +43,6 @@ typedef struct {
#define DTB_PCI_HOST_RANGE_IO BIT24
#define DTB_PCI_HOST_RANGE_TYPEMASK (BIT31 | BIT30 | BIT29 | BIT25 | BIT24)
STATIC
EFI_STATUS
MapGcdMmioSpace (
IN UINT64 Base,
IN UINT64 Size
)
{
EFI_STATUS Status;
Status = gDS->AddMemorySpace (
EfiGcdMemoryTypeMemoryMappedIo,
Base,
Size,
EFI_MEMORY_UC
);
if (EFI_ERROR (Status)) {
DEBUG ((
DEBUG_ERROR,
"%a: failed to add GCD memory space for region [0x%Lx+0x%Lx)\n",
__func__,
Base,
Size
));
return Status;
}
Status = gDS->SetMemorySpaceAttributes (Base, Size, EFI_MEMORY_UC);
if (EFI_ERROR (Status)) {
DEBUG ((
DEBUG_ERROR,
"%a: failed to set memory space attributes for region [0x%Lx+0x%Lx)\n",
__func__,
Base,
Size
));
}
return Status;
}
STATIC
EFI_STATUS
ProcessPciHost (
@ -322,7 +283,7 @@ ProcessPciHost (
));
// Map the ECAM space in the GCD memory map
Status = MapGcdMmioSpace (ConfigBase, ConfigSize);
Status = MapMmioMemory (ConfigBase, ConfigSize, EFI_MEMORY_UC);
ASSERT_EFI_ERROR (Status);
if (EFI_ERROR (Status)) {
return Status;
@ -334,7 +295,7 @@ ProcessPciHost (
// is not aware of this translation and so it will only map the I/O view
// in the GCD I/O map.
//
Status = MapGcdMmioSpace (*IoBase + IoTranslation, *IoSize);
Status = MapMmioMemory (*IoBase + IoTranslation, *IoSize, EFI_MEMORY_UC);
ASSERT_EFI_ERROR (Status);
}

View file

@ -29,7 +29,7 @@
BaseMemoryLib
DebugLib
DevicePathLib
DxeServicesTableLib
MapMmioLib
MemoryAllocationLib
PciHostBridgeUtilityLib
PciPcdProducerLib

View file

@ -332,6 +332,7 @@
QemuFwCfgLib | OvmfPkg/Library/QemuFwCfgLib/QemuFwCfgMmioDxeLib.inf
PciPcdProducerLib | OvmfPkg/Fdt/FdtPciPcdProducerLib/FdtPciPcdProducerLib.inf
AcpiPlatformLib | OvmfPkg/Library/AcpiPlatformLib/DxeAcpiPlatformLib.inf
MapMmioLib | OvmfPkg/Library/MapMmioLib/MapMmioLib.inf
MpInitLib | UefiCpuPkg/Library/MpInitLib/DxeMpInitLib.inf
!if $(TPM2_ENABLE) == TRUE
Tpm2DeviceLib|SecurityPkg/Library/Tpm2DeviceLibTcg2/Tpm2DeviceLibTcg2.inf

View file

@ -397,6 +397,7 @@
PcdLib|MdePkg/Library/DxePcdLib/DxePcdLib.inf
ResetSystemLib|OvmfPkg/Library/ResetSystemLib/DxeResetSystemLibMicrovm.inf
HobLib|MdePkg/Library/DxeHobLib/DxeHobLib.inf
MapMmioLib|OvmfPkg/Library/MapMmioLib/MapMmioLib.inf
MemoryAllocationLib|MdePkg/Library/UefiMemoryAllocationLib/UefiMemoryAllocationLib.inf
ReportStatusCodeLib|MdeModulePkg/Library/DxeReportStatusCodeLib/DxeReportStatusCodeLib.inf
UefiScsiLib|MdePkg/Library/UefiScsiLib/UefiScsiLib.inf

View file

@ -186,6 +186,7 @@
[LibraryClasses.common.DXE_DRIVER]
SecurityManagementLib|MdeModulePkg/Library/DxeSecurityManagementLib/DxeSecurityManagementLib.inf
MapMmioLib|OvmfPkg/Library/MapMmioLib/MapMmioLib.inf
MemoryAllocationLib|MdePkg/Library/UefiMemoryAllocationLib/UefiMemoryAllocationLib.inf
CpuExceptionHandlerLib|UefiCpuPkg/Library/CpuExceptionHandlerLib/DxeCpuExceptionHandlerLib.inf