public inbox for devel@edk2.groups.io
 help / color / mirror / Atom feed
From: "Laszlo Ersek" <lersek@redhat.com>
To: edk2-devel-groups-io <devel@edk2.groups.io>
Cc: Bob Feng <bob.c.feng@intel.com>,
	Liming Gao <gaoliming@byosoft.com.cn>,
	Rebecca Cran <rebecca@bsdio.com>,
	Yuwei Chen <yuwei.chen@intel.com>
Subject: [edk2-devel] [PATCH 03/11] BaseTools/AutoGen: declare ProcessLibraryConstructorList() for SEC modules
Date: Wed,  7 Feb 2024 02:04:29 +0100	[thread overview]
Message-ID: <20240207010437.105506-4-lersek@redhat.com> (raw)
In-Reply-To: <20240207010437.105506-1-lersek@redhat.com>

Most module types have standardized entry point function prototypes. They
are declared in headers like

- MdePkg/Include/Library/PeiCoreEntryPoint.h
- MdePkg/Include/Library/PeimEntryPoint.h
- MdePkg/Include/Library/DxeCoreEntryPoint.h
- MdePkg/Include/Library/UefiDriverEntryPoint.h
- MdePkg/Include/Library/UefiApplicationEntryPoint.h

These header files also declare matching ProcessLibraryConstructorList()
prototypes.

The SEC module type does not have a standardized entry point prototype
(aka parameter list), therefore no header file like the above ones exists
for SEC. Consequently, no header file *declares*
ProcessLibraryConstructorList() for SEC modules, even though AutoGen
always *defines* ProcessLibraryConstructorList() with the same, empty,
parameter list (i.e., just (VOID)).

The lack of a central declaration is a problem because in SEC code,
ProcessLibraryConstructorList() needs to be called manually, and those
calls need a prototype. Most SEC modules in edk2 get around this by
declaring ProcessLibraryConstructorList() manually, while some others use
an incorrect (PEIM) prototype.

Liming suggested in
<https://bugzilla.tianocore.org/show_bug.cgi?id=991#c2> that AutoGen
provide the declaration as well; implement that in this patch.

The patch produces the following difference in
"Build/OvmfX64/NOOPT_GCC5/X64/OvmfPkg/Sec/SecMain/DEBUG/AutoGen.h", for
example:

> --- AutoGen.h.orig      2024-02-06 23:10:23.469535345 +0100
> +++ AutoGen.h   2024-02-07 00:00:57.361294055 +0100
> @@ -220,6 +220,13 @@
>
>  // Definition of PCDs used in libraries is in AutoGen.c
>
> +// ProcessLibraryConstructorList() declared here because SEC has no standard entry point.
> +VOID
> +EFIAPI
> +ProcessLibraryConstructorList (
> +  VOID
> +  );
> +
>
>  #ifdef __cplusplus
>  }

Cc: Bob Feng <bob.c.feng@intel.com>
Cc: Liming Gao <gaoliming@byosoft.com.cn>
Cc: Rebecca Cran <rebecca@bsdio.com>
Cc: Yuwei Chen <yuwei.chen@intel.com>
Ref: https://bugzilla.tianocore.org/show_bug.cgi?id=991
Suggested-by: Liming Gao <gaoliming@byosoft.com.cn>
Signed-off-by: Laszlo Ersek <lersek@redhat.com>
---
 BaseTools/Source/Python/AutoGen/GenC.py | 8 ++++++++
 1 file changed, 8 insertions(+)

diff --git a/BaseTools/Source/Python/AutoGen/GenC.py b/BaseTools/Source/Python/AutoGen/GenC.py
index a2053d548521..ca4afb2e9501 100755
--- a/BaseTools/Source/Python/AutoGen/GenC.py
+++ b/BaseTools/Source/Python/AutoGen/GenC.py
@@ -1371,6 +1371,14 @@ def CreateLibraryConstructorCode(Info, AutoGenC, AutoGenH):
     else:
         if Info.ModuleType in [SUP_MODULE_BASE, SUP_MODULE_SEC, SUP_MODULE_USER_DEFINED, SUP_MODULE_HOST_APPLICATION]:
             AutoGenC.Append(gLibraryString[SUP_MODULE_BASE].Replace(Dict))
+            if Info.ModuleType == SUP_MODULE_SEC:
+                AutoGenH.Append(("\n"
+                                 "// ProcessLibraryConstructorList() declared here because SEC has no standard entry point.\n"
+                                 "VOID\n"
+                                 "EFIAPI\n"
+                                 "ProcessLibraryConstructorList (\n"
+                                 "  VOID\n"
+                                 "  );\n"))
         elif Info.ModuleType in SUP_MODULE_SET_PEI:
             AutoGenC.Append(gLibraryString['PEI'].Replace(Dict))
         elif Info.ModuleType in [SUP_MODULE_DXE_CORE, SUP_MODULE_DXE_DRIVER, SUP_MODULE_DXE_SMM_DRIVER, SUP_MODULE_DXE_RUNTIME_DRIVER,



-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#115200): https://edk2.groups.io/g/devel/message/115200
Mute This Topic: https://groups.io/mt/104210777/7686176
Group Owner: devel+owner@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub [rebecca@openfw.io]
-=-=-=-=-=-=-=-=-=-=-=-



  parent reply	other threads:[~2024-02-07  1:04 UTC|newest]

Thread overview: 36+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-02-07  0:50 [edk2-devel] BaseTools/AutoGen: declare ProcessLibraryConstructorList() for SEC modules Laszlo Ersek
2024-02-07  1:04 ` [edk2-devel] [PATCH 00/11] " Laszlo Ersek
2024-02-07  1:04   ` [edk2-devel] [PATCH 01/11] OvmfPkg/Sec: Use correct prototype of ProcessLibraryConstructorList() Laszlo Ersek
2024-02-14 14:27     ` Ard Biesheuvel
2024-02-07  1:04   ` [edk2-devel] [PATCH 02/11] OvmfPkg/RiscVVirt/Sec: don't #include <Library/PeimEntryPoint.h> Laszlo Ersek
2024-02-07  1:04   ` Laszlo Ersek [this message]
2024-02-07  1:04   ` [edk2-devel] [PATCH 04/11] ArmPlatformPkg: remove SEC ProcessLibraryConstructorList() declarations Laszlo Ersek
2024-02-07  1:04   ` [edk2-devel] [PATCH 05/11] ArmVirtPkg: remove SEC ProcessLibraryConstructorList() declaration Laszlo Ersek
2024-02-07  1:04   ` [edk2-devel] [PATCH 06/11] EmulatorPkg: " Laszlo Ersek
2024-02-07  1:04   ` [edk2-devel] [PATCH 07/11] IntelFsp2Pkg: " Laszlo Ersek
2024-02-07  1:04   ` [edk2-devel] [PATCH 08/11] OvmfPkg/RiscVVirt: " Laszlo Ersek
2024-02-07  1:04   ` [edk2-devel] [PATCH 09/11] OvmfPkg: " Laszlo Ersek
2024-02-07  1:04   ` [edk2-devel] [PATCH 10/11] UefiCpuPkg: " Laszlo Ersek
2024-02-07  1:04   ` [edk2-devel] [PATCH 11/11] UefiPayloadPkg: " Laszlo Ersek
2024-02-07  1:09 ` [edk2-devel] [edk2-platforms PATCH 0/6] clean up SEC ProcessLibraryConstructorList() declarations Laszlo Ersek
2024-02-07  1:09   ` [edk2-devel] [edk2-platforms PATCH 1/6] ChachaniBoardPkg: remove SEC ProcessLibraryConstructorList() declaration Laszlo Ersek
2024-02-07  1:09   ` [edk2-devel] [edk2-platforms PATCH 2/6] BeagleBoardPkg: " Laszlo Ersek
2024-02-07  1:09   ` [edk2-devel] [edk2-platforms PATCH 3/6] QuarkPlatformPkg: " Laszlo Ersek
2024-02-07  1:09   ` [edk2-devel] [edk2-platforms PATCH 4/6] SimicsOpenBoardPkg: fix SEC ProcessLibraryConstructorList() prototype Laszlo Ersek
2024-02-09  0:07     ` Nate DeSimone
2024-02-09  9:24       ` Laszlo Ersek
2024-02-09 22:53         ` Nate DeSimone
2024-02-07  1:09   ` [edk2-devel] [edk2-platforms PATCH 5/6] LoongArchQemuPkg: " Laszlo Ersek
2024-02-19  2:21     ` Chao Li
2024-02-19 20:08       ` Laszlo Ersek
2024-02-07  1:09   ` [edk2-devel] [edk2-platforms PATCH 6/6] SG2042Pkg: clean up SEC ProcessLibraryConstructorList() declaration Laszlo Ersek
2024-02-14 14:25   ` [edk2-devel] [edk2-platforms PATCH 0/6] clean up SEC ProcessLibraryConstructorList() declarations Ard Biesheuvel
2024-02-07  1:16 ` [edk2-devel] BaseTools/AutoGen: declare ProcessLibraryConstructorList() for SEC modules Michael D Kinney
2024-02-07 15:40   ` Laszlo Ersek
2024-02-08 16:40     ` Michael D Kinney
2024-02-15  7:57       ` Laszlo Ersek
2024-02-15 17:29         ` Michael D Kinney
2024-02-16 14:16           ` Laszlo Ersek
2024-02-16 17:21             ` Michael D Kinney
2024-02-24 18:02           ` Laszlo Ersek
2024-02-24 18:37           ` Laszlo Ersek

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-list from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20240207010437.105506-4-lersek@redhat.com \
    --to=devel@edk2.groups.io \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox