]> git.proxmox.com Git - mirror_edk2.git/blobdiff - ArmVirtPkg/Library/PlatformBootManagerLib/PlatformBm.c
ArmVirtPkg: Change complex DEBUG_CODE() to DEBUG_CODE_BEGIN/END()
[mirror_edk2.git] / ArmVirtPkg / Library / PlatformBootManagerLib / PlatformBm.c
index 5f6cfe64daca131d31fabe5249c78cf768ee0509..02d6c87050602fd8288cee4f07409392d3bd60a2 100644 (file)
@@ -16,6 +16,7 @@
 #include <Library/PcdLib.h>\r
 #include <Library/PlatformBmPrintScLib.h>\r
 #include <Library/QemuBootOrderLib.h>\r
+#include <Library/TpmPlatformHierarchyLib.h>\r
 #include <Library/UefiBootManagerLib.h>\r
 #include <Protocol/DevicePath.h>\r
 #include <Protocol/FirmwareVolume2.h>\r
@@ -25,6 +26,7 @@
 #include <Protocol/PciRootBridgeIo.h>\r
 #include <Protocol/VirtioDevice.h>\r
 #include <Guid/EventGroup.h>\r
+#include <Guid/GlobalVariable.h>\r
 #include <Guid/RootBridgesConnectedEventGroup.h>\r
 #include <Guid/SerialPortLibVendor.h>\r
 \r
@@ -184,7 +186,7 @@ FilterAndProcess (
     //\r
     // This is not an error, just an informative condition.\r
     //\r
-    DEBUG ((EFI_D_VERBOSE, "%a: %g: %r\n", __FUNCTION__, ProtocolGuid,\r
+    DEBUG ((DEBUG_VERBOSE, "%a: %g: %r\n", __FUNCTION__, ProtocolGuid,\r
       Status));\r
     return;\r
   }\r
@@ -245,7 +247,7 @@ IsPciDisplay (
   Status = PciIo->Pci.Read (PciIo, EfiPciIoWidthUint32, 0 /* Offset */,\r
                         sizeof Pci / sizeof (UINT32), &Pci);\r
   if (EFI_ERROR (Status)) {\r
-    DEBUG ((EFI_D_ERROR, "%a: %s: %r\n", __FUNCTION__, ReportText, Status));\r
+    DEBUG ((DEBUG_ERROR, "%a: %s: %r\n", __FUNCTION__, ReportText, Status));\r
     return FALSE;\r
   }\r
 \r
@@ -388,7 +390,7 @@ Connect (
                   NULL,   // RemainingDevicePath -- produce all children\r
                   FALSE   // Recursive\r
                   );\r
-  DEBUG ((EFI_ERROR (Status) ? EFI_D_ERROR : EFI_D_VERBOSE, "%a: %s: %r\n",\r
+  DEBUG ((EFI_ERROR (Status) ? DEBUG_ERROR : DEBUG_VERBOSE, "%a: %s: %r\n",\r
     __FUNCTION__, ReportText, Status));\r
 }\r
 \r
@@ -410,26 +412,26 @@ AddOutput (
 \r
   DevicePath = DevicePathFromHandle (Handle);\r
   if (DevicePath == NULL) {\r
-    DEBUG ((EFI_D_ERROR, "%a: %s: handle %p: device path not found\n",\r
+    DEBUG ((DEBUG_ERROR, "%a: %s: handle %p: device path not found\n",\r
       __FUNCTION__, ReportText, Handle));\r
     return;\r
   }\r
 \r
   Status = EfiBootManagerUpdateConsoleVariable (ConOut, DevicePath, NULL);\r
   if (EFI_ERROR (Status)) {\r
-    DEBUG ((EFI_D_ERROR, "%a: %s: adding to ConOut: %r\n", __FUNCTION__,\r
+    DEBUG ((DEBUG_ERROR, "%a: %s: adding to ConOut: %r\n", __FUNCTION__,\r
       ReportText, Status));\r
     return;\r
   }\r
 \r
   Status = EfiBootManagerUpdateConsoleVariable (ErrOut, DevicePath, NULL);\r
   if (EFI_ERROR (Status)) {\r
-    DEBUG ((EFI_D_ERROR, "%a: %s: adding to ErrOut: %r\n", __FUNCTION__,\r
+    DEBUG ((DEBUG_ERROR, "%a: %s: adding to ErrOut: %r\n", __FUNCTION__,\r
       ReportText, Status));\r
     return;\r
   }\r
 \r
-  DEBUG ((EFI_D_VERBOSE, "%a: %s: added to ConOut and ErrOut\n", __FUNCTION__,\r
+  DEBUG ((DEBUG_VERBOSE, "%a: %s: added to ConOut and ErrOut\n", __FUNCTION__,\r
     ReportText));\r
 }\r
 \r
@@ -603,13 +605,13 @@ RemoveStaleFvFileOptions (
     //\r
     Status = EfiBootManagerDeleteLoadOptionVariable (\r
                BootOptions[Index].OptionNumber, LoadOptionTypeBoot);\r
-    DEBUG_CODE (\r
+    DEBUG_CODE_BEGIN ();\r
       CHAR16 *DevicePathString;\r
 \r
       DevicePathString = ConvertDevicePathToText(BootOptions[Index].FilePath,\r
                            FALSE, FALSE);\r
       DEBUG ((\r
-        EFI_ERROR (Status) ? EFI_D_WARN : EFI_D_VERBOSE,\r
+        EFI_ERROR (Status) ? DEBUG_WARN : DEBUG_VERBOSE,\r
         "%a: removing stale Boot#%04x %s: %r\n",\r
         __FUNCTION__,\r
         (UINT32)BootOptions[Index].OptionNumber,\r
@@ -619,7 +621,7 @@ RemoveStaleFvFileOptions (
       if (DevicePathString != NULL) {\r
         FreePool (DevicePathString);\r
       }\r
-      );\r
+    DEBUG_CODE_END ();\r
   }\r
 \r
   EfiBootManagerFreeLoadOptions (BootOptions, BootOptionCount);\r
@@ -686,13 +688,20 @@ PlatformBootManagerBeforeConsole (
   VOID\r
   )\r
 {\r
+  UINT16        FrontPageTimeout;\r
   RETURN_STATUS PcdStatus;\r
+  EFI_STATUS    Status;\r
 \r
   //\r
   // Signal EndOfDxe PI Event\r
   //\r
   EfiEventGroupSignal (&gEfiEndOfDxeEventGroupGuid);\r
 \r
+  //\r
+  // Disable the TPM 2 platform hierarchy\r
+  //\r
+  ConfigureTpmPlatformHierarchy ();\r
+\r
   //\r
   // Dispatch deferred images after EndOfDxe event.\r
   //\r
@@ -744,9 +753,29 @@ PlatformBootManagerBeforeConsole (
   //\r
   // Set the front page timeout from the QEMU configuration.\r
   //\r
-  PcdStatus = PcdSet16S (PcdPlatformBootTimeOut,\r
-                GetFrontPageTimeoutFromQemu ());\r
+  FrontPageTimeout = GetFrontPageTimeoutFromQemu ();\r
+  PcdStatus = PcdSet16S (PcdPlatformBootTimeOut, FrontPageTimeout);\r
   ASSERT_RETURN_ERROR (PcdStatus);\r
+  //\r
+  // Reflect the PCD in the standard Timeout variable.\r
+  //\r
+  Status = gRT->SetVariable (\r
+                  EFI_TIME_OUT_VARIABLE_NAME,\r
+                  &gEfiGlobalVariableGuid,\r
+                  (EFI_VARIABLE_NON_VOLATILE |\r
+                   EFI_VARIABLE_BOOTSERVICE_ACCESS |\r
+                   EFI_VARIABLE_RUNTIME_ACCESS),\r
+                  sizeof FrontPageTimeout,\r
+                  &FrontPageTimeout\r
+                  );\r
+  DEBUG ((\r
+    EFI_ERROR (Status) ? DEBUG_ERROR : DEBUG_VERBOSE,\r
+    "%a: SetVariable(%s, %u): %r\n",\r
+    __FUNCTION__,\r
+    EFI_TIME_OUT_VARIABLE_NAME,\r
+    FrontPageTimeout,\r
+    Status\r
+    ));\r
 \r
   //\r
   // Register platform-specific boot options and keyboard shortcuts.\r