+++ 
b/UefiPayloadPkg/Library/DebugPrintErrorLevelLibCmos/DebugPrintErrorLevelLibCmos.c

1. Please change the folder and file names to 
"DebugPrintErrorLevelLibHob/DebugPrintErrorLevelLibHob.c".
    Please change the INF file name accordingly.

+#include <Pi/PiHob.h>

2. PiHob.h is included by PiDxe.h. So you can remove the above include.

+#include <Library/DxeHobListLib.h>
3. Can you try to remove the above line? Can build still pass?

+#include <Library/UefiLib.h>
+#include <Library/DebugLib.h>

+#include <Library/DxeHobListLib.h>
4. Similar comment.


+#include <Guid/DebugPrintErrorLevel.h>
+#include <Library/DebugPrintErrorLevelLib.h>
+#include <UniversalPayload/UniversalPayload.h>
+
+/**
+  Returns the debug print error level mask for the current module.
+
+  @return  Debug print error level mask for the current module.
+
+**/
+UINT32
+EFIAPI
+GetDebugPrintErrorLevel (
+  VOID
+  )
+{
+  VOID                                       *GuidHob;
+  UNIVERSAL_PAYLOAD_GENERIC_HEADER           *GenericHeader;
+  UNIVERSAL_PAYLOAD_DEBUG_PRINT_ERROR_LEVEL  *DebugPrintErrorLevel;
+

5. can you please use a global variable to cache the error level so that no 
need to query from HOB always?

e.g.:
define two below variables in the beginning of the file.
UINT32  gDebugPrintErrorLevel;
BOOLEAN gDebugPrintErrorLevelInitialized = FALSE;

then in this function:
if (!gDebugPrintErrorLevelInitialized) {
  // re-use the below logic to get the value from HOB or PCD if HOB doesn't 
exist
  // store the value in gDebugPrintErrorLevel
}
return gDebugPrintErrorLevel;


+  GuidHob = GetFirstGuidHob (&gEdkiiDebugPrintErrorLevelGuid);
+
+  if (GuidHob == NULL) {
+    //
+    // If the HOB is not create, the default value of PcdDebugPrintErrorLevel 
will be used.
+    //
+    return PcdGet32(PcdDebugPrintErrorLevel);
+  }
+
+  GenericHeader = (UNIVERSAL_PAYLOAD_GENERIC_HEADER *)GET_GUID_HOB_DATA 
(GuidHob);
+  if ((sizeof (UNIVERSAL_PAYLOAD_GENERIC_HEADER) > GET_GUID_HOB_DATA_SIZE 
(GuidHob)) || 
+  (GenericHeader->Length > GET_GUID_HOB_DATA_SIZE (GuidHob))) {
+    return PcdGet32(PcdDebugPrintErrorLevel);
+  }
+
+  if (GenericHeader->Revision == 
UNIVERSAL_PAYLOAD_DEBUG_PRINT_ERROR_LEVEL_REVISION) {
+    DebugPrintErrorLevel = GET_GUID_HOB_DATA (GuidHob);
+    return DebugPrintErrorLevel->ErrorLevel;
+  } else {
+    return PcdGet32(PcdDebugPrintErrorLevel);
+  }
+
+}
+

+[Defines]
+  INF_VERSION                    = 0x00010005
+  BASE_NAME                      = DebugPrintErrorLevelLib

6. Please change the BASE_NAME to DebugPrintErrorLevelLibHob.







-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#87993): https://edk2.groups.io/g/devel/message/87993
Mute This Topic: https://groups.io/mt/89972118/21656
Group Owner: devel+ow...@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub [arch...@mail-archive.com]
-=-=-=-=-=-=-=-=-=-=-=-


Reply via email to