From 12dc8d420bc98ceb3dbeb7be433b7dfc465a24b8 Mon Sep 17 00:00:00 2001 From: Ard Biesheuvel Date: Tue, 30 Jul 2024 19:52:21 +0200 Subject: [PATCH] ArmPkg/ArmArchTimerLib: Drop pointless constructor Drop the pointless constructor in ArmArchTimerLib, which does nothing useful, especially because AArch64 mandates the presence of the generic timer, and 32-bit ARM is mostly obsolete these days. To preserve the existing behavior in DEBUG builds when actually using the timer, move the ASSERT () on a non-zero frequency to the associated accessor helper function. Signed-off-by: Ard Biesheuvel --- .../Library/ArmArchTimerLib/ArmArchTimerLib.c | 26 ++----------------- .../ArmArchTimerLib/ArmArchTimerLib.inf | 1 - 2 files changed, 2 insertions(+), 25 deletions(-) diff --git a/ArmPkg/Library/ArmArchTimerLib/ArmArchTimerLib.c b/ArmPkg/Library/ArmArchTimerLib/ArmArchTimerLib.c index ccb4f6474b..76f94c9161 100644 --- a/ArmPkg/Library/ArmArchTimerLib/ArmArchTimerLib.c +++ b/ArmPkg/Library/ArmArchTimerLib/ArmArchTimerLib.c @@ -24,30 +24,6 @@ #define MULT_U64_X_N MultU64x64 #endif -RETURN_STATUS -EFIAPI -TimerConstructor ( - VOID - ) -{ - // - // Check if the ARM Generic Timer Extension is implemented. - // - if (ArmIsArchTimerImplemented ()) { - // - // Architectural Timer Frequency must be set in Secure privileged - // mode (if secure extension is supported). - // If the reset value (0) is returned, just ASSERT. - // - ASSERT (ArmGenericTimerGetTimerFreq () != 0); - } else { - DEBUG ((DEBUG_ERROR, "ARM Architectural Timer is not available in the CPU, hence this library cannot be used.\n")); - ASSERT (0); - } - - return RETURN_SUCCESS; -} - /** A local utility function that returns the PCD value, if specified. Otherwise it defaults to ArmGenericTimerGetTimerFreq. @@ -65,6 +41,8 @@ GetPlatformTimerFreq ( TimerFreq = ArmGenericTimerGetTimerFreq (); + ASSERT (TimerFreq != 0); + return TimerFreq; } diff --git a/ArmPkg/Library/ArmArchTimerLib/ArmArchTimerLib.inf b/ArmPkg/Library/ArmArchTimerLib/ArmArchTimerLib.inf index 273b1e9555..76bad81531 100644 --- a/ArmPkg/Library/ArmArchTimerLib/ArmArchTimerLib.inf +++ b/ArmPkg/Library/ArmArchTimerLib/ArmArchTimerLib.inf @@ -12,7 +12,6 @@ MODULE_TYPE = BASE VERSION_STRING = 1.0 LIBRARY_CLASS = TimerLib - CONSTRUCTOR = TimerConstructor [Sources.common] ArmArchTimerLib.c