@@ -23,7 +23,6 @@ [Defines]
MODULE_TYPE = BASE
VERSION_STRING = 1.0
LIBRARY_CLASS = PciExpressLib|DXE_DRIVER UEFI_DRIVER UEFI_APPLICATION
- CONSTRUCTOR = PciExpressLibInitialize
#
# VALID_ARCHITECTURES = ARM AARCH64
@@ -68,18 +68,7 @@ PciExpressRegisterForRuntimeAccess (
return RETURN_UNSUPPORTED;
}
-STATIC UINT64 mPciExpressBaseAddress;
-
-RETURN_STATUS
-EFIAPI
-PciExpressLibInitialize (
- VOID
- )
-{
- mPciExpressBaseAddress = PcdGet64 (PcdPciExpressBaseAddress);
- return RETURN_SUCCESS;
-}
-
+STATIC UINT64 mPciExpressBaseAddress = 0xFFFFFFFFFFFFFFFFULL;
/**
Gets the base address of PCI Express.
@@ -92,6 +81,9 @@ GetPciExpressBaseAddress (
VOID
)
{
+ if (mPciExpressBaseAddress == 0xFFFFFFFFFFFFFFFFULL) {
+ mPciExpressBaseAddress = PcdGet64 (PcdPciExpressBaseAddress);
+ }
return (VOID*)(UINTN) mPciExpressBaseAddress;
}
Instead of using a constructor, which may reference a dynamic PCD which is set by the DXE entry point of its user, defer the assignment of the global mPciExpressBaseAddress until the first the library is actually invoked. Contributed-under: TianoCore Contribution Agreement 1.0 Signed-off-by: Ard Biesheuvel <ard.biesheuvel@linaro.org> --- ArmVirtPkg/Library/BaseCachingPciExpressLib/BaseCachingPciExpressLib.inf | 1 - ArmVirtPkg/Library/BaseCachingPciExpressLib/PciExpressLib.c | 16 ++++------------ 2 files changed, 4 insertions(+), 13 deletions(-) -- 2.5.0 _______________________________________________ edk2-devel mailing list edk2-devel@lists.01.org https://lists.01.org/mailman/listinfo/edk2-devel