Re: [PATCH v5 07/15] MdeModulePkg: Fix constructor invocation ordering


Wu, Hao A
 

Acked-by: Hao A Wu <hao.a.wu@...>

Best Regards,
Hao Wu

-----Original Message-----
From: Sami Mujawar <sami.mujawar@...>
Sent: Saturday, October 3, 2020 5:14 AM
To: devel@edk2.groups.io
Cc: Sami Mujawar <sami.mujawar@...>; ard.biesheuvel@...;
leif@...; lersek@...; Wang, Jian J <jian.j.wang@...>;
Wu, Hao A <hao.a.wu@...>; Alexandru.Elisei@...;
Andre.Przywara@...; Matteo.Carlini@...; Ben.Adderson@...;
nd@...
Subject: [PATCH v5 07/15] MdeModulePkg: Fix constructor invocation ordering

The BaseSerialPortLib16550 library does not implement a constructor. This
prevents the correct constructor invocation order for dependent libraries.
e.g. A PlatformHookLib (for the Serial Port) may have a dependency on
retrieving data from a Hob. A Hob library implementation may configure its
initial state in the HobLib constructor. Since BaseSerialPortLib16550 does not
implement a constructor, the Basetools do not resolve the correct order for
constructor invocation.

To fix this, add an empty constructor to the serial port library
BaseSerialPortLib16550.

Signed-off-by: Sami Mujawar <sami.mujawar@...>
Acked-by: Ard Biesheuvel <Ard.Biesheuvel@...>
---

Notes:
v5:
- Fix function documentation to match doxygen style. [Sami]
Ref: https://edk2.groups.io/g/devel/message/62148

v4:
- No code change, resending patch with v4 series. [Sami]
Ref: https://edk2.groups.io/g/devel/topic/75081484

MdeModulePkg/Library/BaseSerialPortLib16550/BaseSerialPortLib16550.c |
17 +++++++++++++++++
MdeModulePkg/Library/BaseSerialPortLib16550/BaseSerialPortLib16550.inf | 3
+++
2 files changed, 20 insertions(+)

diff --git
a/MdeModulePkg/Library/BaseSerialPortLib16550/BaseSerialPortLib16550.c
b/MdeModulePkg/Library/BaseSerialPortLib16550/BaseSerialPortLib16550.c
index
9cb50dd80d5634ab2aa6d68bf5ca7fb891463eef..f10b5894663a979873427cffa8
4a37b3064c623e 100644
--- a/MdeModulePkg/Library/BaseSerialPortLib16550/BaseSerialPortLib16550.c
+++ b/MdeModulePkg/Library/BaseSerialPortLib16550/BaseSerialPortLib16550
+++ .c
@@ -4,6 +4,7 @@
(C) Copyright 2014 Hewlett-Packard Development Company, L.P.<BR>
Copyright (c) 2006 - 2019, Intel Corporation. All rights reserved.<BR>
Copyright (c) 2018, AMD Incorporated. All rights reserved.<BR>
+ Copyright (c) 2020, ARM Limited. All rights reserved.

SPDX-License-Identifier: BSD-2-Clause-Patent

@@ -1102,3 +1103,19 @@ SerialPortSetAttributes (
return RETURN_SUCCESS;
}

+/** Base Serial Port 16550 Library Constructor
+
+ @retval RETURN_SUCCESS Success.
+**/
+EFI_STATUS
+EFIAPI
+BaseSerialPortLib16550 (
+ VOID
+ )
+{
+ // Nothing to do here. This constructor is added to
+ // enable the chain of constructor invocation for
+ // dependent libraries.
+ return RETURN_SUCCESS;
+}
+
diff --git
a/MdeModulePkg/Library/BaseSerialPortLib16550/BaseSerialPortLib16550.inf
b/MdeModulePkg/Library/BaseSerialPortLib16550/BaseSerialPortLib16550.inf
index
8b4ae3f1d4ee1e2e9a8b81eab4c900541ce8cfb6..92b7a8b7896a305d2ce22589f
8a9593618d37bb7 100644
---
a/MdeModulePkg/Library/BaseSerialPortLib16550/BaseSerialPortLib16550.inf
+++ b/MdeModulePkg/Library/BaseSerialPortLib16550/BaseSerialPortLib16550
+++ .inf
@@ -2,6 +2,8 @@
# SerialPortLib instance for 16550 UART.
#
# Copyright (c) 2006 - 2019, Intel Corporation. All rights reserved.<BR>
+# Copyright (c) 2020, ARM Limited. All rights reserved.
+#
# SPDX-License-Identifier: BSD-2-Clause-Patent # ## @@ -14,6 +16,7 @@
[Defines]
MODULE_TYPE = BASE
VERSION_STRING = 1.1
LIBRARY_CLASS = SerialPortLib
+ CONSTRUCTOR = BaseSerialPortLib16550

[Packages]
MdePkg/MdePkg.dec
--
'Guid(CE165669-3EF3-493F-B85D-6190EE5B9759)'

Join devel@edk2.groups.io to automatically receive all group messages.