TianoCore EDK2 master
Loading...
Searching...
No Matches
DebugPrintErrorLevelLibHob.c
Go to the documentation of this file.
1
10#include <Base.h>
11#include <Uefi.h>
12#include <PiDxe.h>
13#include <Library/PcdLib.h>
14#include <Library/HobLib.h>
18
19STATIC UINT32 gDebugPrintErrorLevel;
20STATIC BOOLEAN gDebugPrintErrorLevelInitialized = FALSE;
21
28UINT32
29EFIAPI
31 VOID
32 )
33{
34 VOID *GuidHob;
36 UEFI_PAYLOAD_DEBUG_PRINT_ERROR_LEVEL *DebugPrintErrorLevel;
37
38 if (GetHobList () == NULL) {
39 return PcdGet32 (PcdDebugPrintErrorLevel);
40 }
41
42 if (!gDebugPrintErrorLevelInitialized) {
43 gDebugPrintErrorLevelInitialized = TRUE;
44 gDebugPrintErrorLevel = PcdGet32 (PcdDebugPrintErrorLevel);
45 GuidHob = GetFirstGuidHob (&gEdkiiDebugPrintErrorLevelGuid);
46 if (GuidHob != NULL) {
47 GenericHeader = (UNIVERSAL_PAYLOAD_GENERIC_HEADER *)GET_GUID_HOB_DATA (GuidHob);
48 if ((sizeof (UNIVERSAL_PAYLOAD_GENERIC_HEADER) < GET_GUID_HOB_DATA_SIZE (GuidHob)) &&
49 (GenericHeader->Length <= GET_GUID_HOB_DATA_SIZE (GuidHob)))
50 {
51 if (GenericHeader->Revision == UEFI_PAYLOAD_DEBUG_PRINT_ERROR_LEVEL_REVISION) {
52 DebugPrintErrorLevel = (UEFI_PAYLOAD_DEBUG_PRINT_ERROR_LEVEL *)GET_GUID_HOB_DATA (GuidHob);
53 if (DebugPrintErrorLevel->Header.Length >= UNIVERSAL_PAYLOAD_SIZEOF_THROUGH_FIELD (UEFI_PAYLOAD_DEBUG_PRINT_ERROR_LEVEL, ErrorLevel)) {
54 gDebugPrintErrorLevel = DebugPrintErrorLevel->ErrorLevel;
55 }
56 }
57 }
58 }
59 }
60
61 return gDebugPrintErrorLevel;
62}
63
73BOOLEAN
74EFIAPI
76 UINT32 ErrorLevel
77 )
78{
79 //
80 // This library uinstance does not support setting the global debug print error
81 // level mask.
82 //
83 return FALSE;
84}
VOID *EFIAPI GetFirstGuidHob(IN CONST EFI_GUID *Guid)
Definition: HobLib.c:215
VOID *EFIAPI GetHobList(VOID)
Definition: HobLib.c:76
BOOLEAN EFIAPI SetDebugPrintErrorLevel(UINT32 ErrorLevel)
UINT32 EFIAPI GetDebugPrintErrorLevel(VOID)
#define NULL
Definition: Base.h:319
#define STATIC
Definition: Base.h:264
#define TRUE
Definition: Base.h:301
#define FALSE
Definition: Base.h:307
#define PcdGet32(TokenName)
Definition: PcdLib.h:362
#define UNIVERSAL_PAYLOAD_SIZEOF_THROUGH_FIELD(TYPE, Field)