]> git.proxmox.com Git - mirror_edk2.git/blobdiff - MdeModulePkg/Library/DxeDebugPrintErrorLevelLib/DxeDebugPrintErrorLevelLib.c
MdeModulePkg/CapsuleLib: remove ImageIndex check.
[mirror_edk2.git] / MdeModulePkg / Library / DxeDebugPrintErrorLevelLib / DxeDebugPrintErrorLevelLib.c
index 1182e2eb5b49c7bcf3962777cdc7960f0b3c6205..0ba88d8eeb683324a87ad00801dcb294c8a140a3 100644 (file)
@@ -19,6 +19,7 @@
 \r
 #include <Library/DebugPrintErrorLevelLib.h>\r
 #include <Library/PcdLib.h>\r
+#include <Library/HobLib.h>\r
 \r
 #include <Guid/DebugMask.h>\r
 \r
@@ -89,10 +90,11 @@ BOOLEAN           mGlobalErrorLevelInitialized = FALSE;
 /// 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
@@ -122,13 +124,13 @@ DxeDebugPrintErrorLevelLibConstructor (
   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
@@ -142,7 +144,8 @@ DxeDebugPrintErrorLevelLibConstructor (
   //\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
@@ -194,6 +197,7 @@ GetDebugPrintErrorLevel (
   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
@@ -203,10 +207,10 @@ GetDebugPrintErrorLevel (
   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
@@ -242,6 +246,18 @@ GetDebugPrintErrorLevel (
           //\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