From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by mx.groups.io with SMTP id smtpd.web11.20277.1655733374756399727 for ; Mon, 20 Jun 2022 06:56:15 -0700 Authentication-Results: mx.groups.io; dkim=missing; spf=pass (domain: arm.com, ip: 217.140.110.172, mailfrom: rohit.mathew@arm.com) Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 9D649113E; Mon, 20 Jun 2022 06:56:14 -0700 (PDT) Received: from usa.arm.com (unknown [10.57.70.6]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPA id B21953F534; Mon, 20 Jun 2022 06:56:13 -0700 (PDT) From: "Rohit Mathew" To: devel@edk2.groups.io Cc: Ard Biesheuvel , Sami Mujawar , Rebecca Cran Subject: [edk2][PATCH V2 1/1] ArmPlatformPkg/PrePeiCore: Explicitly invoke constructor for SEC phase Date: Mon, 20 Jun 2022 14:56:10 +0100 Message-Id: <20220620135610.12578-1-rohit.mathew@arm.com> X-Mailer: git-send-email 2.25.1 MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable PrePeiCore's CEntry function calls DebugLib library's print API before the library is initialized. So, invoke the constructor in the SEC phase to call into initialization functions associated with libraries linked with this particular module. This change is essential to initialize uart for SEC. Signed-off-by: Rohit Mathew --- ArmPlatformPkg/PrePeiCore/PrePeiCore.h | 11 ++++++++++- ArmPlatformPkg/PrePeiCore/PrePeiCore.c | 5 ++++- 2 files changed, 14 insertions(+), 2 deletions(-) Changes since V1: - Rebased on top of latest master branch. - Addressed comments from Ard. Link to github branch with the patches in this series - https://github.com/rohit-arm/edk2/tree/sec_constructor_issue diff --git a/ArmPlatformPkg/PrePeiCore/PrePeiCore.h b/ArmPlatformPkg/PreP= eiCore/PrePeiCore.h index 0345dd7bdd2a..d2491aa586ee 100644 --- a/ArmPlatformPkg/PrePeiCore/PrePeiCore.h +++ b/ArmPlatformPkg/PrePeiCore/PrePeiCore.h @@ -1,7 +1,7 @@ /** @file Main file supporting the transition to PEI Core in Normal World for Ve= rsatile Express =20 - Copyright (c) 2011, ARM Limited. All rights reserved. + Copyright (c) 2011-2022, ARM Limited. All rights reserved. =20 SPDX-License-Identifier: BSD-2-Clause-Patent =20 @@ -73,4 +73,13 @@ PeiCommonExceptionEntry ( IN UINTN LR ); =20 +/* + * Constructor for SEC phase + */ +VOID +EFIAPI +ProcessLibraryConstructorList ( + VOID + ); + #endif diff --git a/ArmPlatformPkg/PrePeiCore/PrePeiCore.c b/ArmPlatformPkg/PreP= eiCore/PrePeiCore.c index 6dd9bcdea24f..72c5f2f193b6 100644 --- a/ArmPlatformPkg/PrePeiCore/PrePeiCore.c +++ b/ArmPlatformPkg/PrePeiCore/PrePeiCore.c @@ -1,7 +1,7 @@ /** @file Main file supporting the transition to PEI Core in Normal World for Ve= rsatile Express =20 - Copyright (c) 2011-2014, ARM Limited. All rights reserved. + Copyright (c) 2011-2022, ARM Limited. All rights reserved. =20 SPDX-License-Identifier: BSD-2-Clause-Patent =20 @@ -86,6 +86,9 @@ CEntryPoint ( ArmEnableVFP (); } =20 + // Explicitly invoke the library constructor to resolve any library de= pendency + ProcessLibraryConstructorList(); + // Note: The MMU will be enabled by MemoryPeim. Only the primary core = will have the MMU on. =20 // If not primary Jump to Secondary Main --=20 2.25.1