2 Debug Print Error Level library instance that retrieves
3 the DebugPrintErrorLevel from bootloader.
5 Copyright (c) 2022, Intel Corporation. All rights reserved.<BR>
6 SPDX-License-Identifier: BSD-2-Clause-Patent
13 #include <Library/PcdLib.h>
14 #include <Library/HobLib.h>
15 #include <Guid/DebugPrintErrorLevel.h>
16 #include <Library/DebugPrintErrorLevelLib.h>
17 #include <UniversalPayload/UniversalPayload.h>
19 STATIC UINT32 gDebugPrintErrorLevel
;
20 STATIC BOOLEAN gDebugPrintErrorLevelInitialized
= FALSE
;
23 Returns the debug print error level mask for the current module.
25 @return Debug print error level mask for the current module.
30 GetDebugPrintErrorLevel (
35 UNIVERSAL_PAYLOAD_GENERIC_HEADER
*GenericHeader
;
36 UEFI_PAYLOAD_DEBUG_PRINT_ERROR_LEVEL
*DebugPrintErrorLevel
;
38 if (!gDebugPrintErrorLevelInitialized
) {
39 gDebugPrintErrorLevelInitialized
= TRUE
;
40 gDebugPrintErrorLevel
= PcdGet32 (PcdDebugPrintErrorLevel
);
41 GuidHob
= GetFirstGuidHob (&gEdkiiDebugPrintErrorLevelGuid
);
42 if (GuidHob
!= NULL
) {
43 GenericHeader
= (UNIVERSAL_PAYLOAD_GENERIC_HEADER
*)GET_GUID_HOB_DATA (GuidHob
);
44 if ((sizeof (UNIVERSAL_PAYLOAD_GENERIC_HEADER
) < GET_GUID_HOB_DATA_SIZE (GuidHob
)) &&
45 (GenericHeader
->Length
<= GET_GUID_HOB_DATA_SIZE (GuidHob
)))
47 if (GenericHeader
->Revision
== UEFI_PAYLOAD_DEBUG_PRINT_ERROR_LEVEL_REVISION
) {
48 DebugPrintErrorLevel
= (UEFI_PAYLOAD_DEBUG_PRINT_ERROR_LEVEL
*)GET_GUID_HOB_DATA (GuidHob
);
49 if (DebugPrintErrorLevel
->Header
.Length
>= UNIVERSAL_PAYLOAD_SIZEOF_THROUGH_FIELD (UEFI_PAYLOAD_DEBUG_PRINT_ERROR_LEVEL
, ErrorLevel
)) {
50 gDebugPrintErrorLevel
= DebugPrintErrorLevel
->ErrorLevel
;
57 return gDebugPrintErrorLevel
;
61 Sets the global debug print error level mask fpr the entire platform.
63 @param ErrorLevel Global debug print error level.
65 @retval TRUE The debug print error level mask was sucessfully set.
66 @retval FALSE The debug print error level mask could not be set.
71 SetDebugPrintErrorLevel (
76 // This library uinstance does not support setting the global debug print error