\r
#include <Library/DebugPrintErrorLevelLib.h>\r
#include <Library/PcdLib.h>\r
+#include <Library/HobLib.h>\r
\r
#include <Guid/DebugMask.h>\r
\r
/// Global variable that contains the current debug error level mask for the\r
/// module that is using this library instance. This variable is initially\r
/// set to the PcdDebugPrintErrorLevel value. If the EFI Variable exists that\r
-/// contains the global debug print error level mask, then that override the\r
-/// PcdDebugPrintErrorLevel value. If the Debug Mask Protocol SetDebugMask()\r
-/// service is called, then that overrides bit the PcdDebugPrintErrorLevel and\r
-/// the EFI Variable setting.\r
+/// contains the global debug print error level mask, then that overrides the\r
+/// PcdDebugPrintErrorLevel value. The EFI Variable can optionally be \r
+/// discovered via a HOB so early DXE drivers can access the variable. If the\r
+/// Debug Mask Protocol SetDebugMask() service is called, then that overrides \r
+/// the PcdDebugPrintErrorLevel and the EFI Variable setting.\r
///\r
UINT32 mDebugPrintErrorLevel = 0;\r
\r
IN EFI_SYSTEM_TABLE *SystemTable\r
)\r
{\r
- EFI_STATUS Status;\r
-\r
+ EFI_STATUS Status;\r
+ \r
//\r
// Initialize the error level mask from PCD setting.\r
//\r
mDebugPrintErrorLevel = PcdGet32 (PcdDebugPrintErrorLevel);\r
- \r
+ \r
//\r
// Install Debug Mask Protocol onto ImageHandle\r
// \r
//\r
// Attempt to retrieve the global debug print error level mask from the EFI Variable\r
// If the EFI Variable can not be accessed when this module's library constructors are\r
- // executed, then the EFI Variable access will be reattempted on every DEBUG() print\r
+ // executed a HOB can be used to set the global debug print error level. If no value \r
+ // was found then the EFI Variable access will be reattempted on every DEBUG() print\r
// from this module until the EFI Variable services are available.\r
//\r
GetDebugPrintErrorLevel ();\r
EFI_TPL CurrentTpl;\r
UINTN Size;\r
UINTN GlobalErrorLevel;\r
+ VOID *Hob;\r
\r
//\r
// If the constructor has not been executed yet, then just return the PCD value.\r
if (mSystemTable == NULL) {\r
return PcdGet32 (PcdDebugPrintErrorLevel);\r
}\r
-\r
+ \r
//\r
- // Check to see if an attempt has been mde to retrieve the global debug print \r
- // error level mask. Since this libtrary instance stores the global debug print\r
+ // Check to see if an attempt has been made to retrieve the global debug print \r
+ // error level mask. Since this library instance stores the global debug print\r
// error level mask in an EFI Variable, the EFI Variable should only be accessed\r
// once to reduce the overhead of reading the EFI Variable on every debug print\r
// \r
//\r
mDebugPrintErrorLevel = (UINT32)GlobalErrorLevel;\r
}\r
+ } else {\r
+ //\r
+ // If variable services are not yet available optionally get the global\r
+ // debug print error level mask from a HOB.\r
+ //\r
+ Hob = GetFirstGuidHob (&gEfiGenericVariableGuid);\r
+ if (Hob != NULL) {\r
+ if (GET_GUID_HOB_DATA_SIZE (Hob) == sizeof (UINT32)) {\r
+ mDebugPrintErrorLevel = *(UINT32 *)GET_GUID_HOB_DATA (Hob);\r
+ mGlobalErrorLevelInitialized = TRUE;\r
+ }\r
+ }\r
}\r
}\r
}\r