]> git.proxmox.com Git - mirror_edk2.git/blobdiff - MdeModulePkg/Universal/BdsDxe/BdsEntry.c
MdeModulePkg/BdsDxe: Revert "fall back to UI loop before hanging"
[mirror_edk2.git] / MdeModulePkg / Universal / BdsDxe / BdsEntry.c
index 2b24755ac368696f7fd57c7917dcd64614d225ac..39b643c77a6352243247b6527572ac43ecf09f7f 100644 (file)
@@ -5,7 +5,7 @@
   After DxeCore finish DXE phase, gEfiBdsArchProtocolGuid->BdsEntry will be invoked\r
   to enter BDS phase.\r
 \r
-Copyright (c) 2004 - 2017, Intel Corporation. All rights reserved.<BR>\r
+Copyright (c) 2004 - 2018, Intel Corporation. All rights reserved.<BR>\r
 (C) Copyright 2016 Hewlett Packard Enterprise Development LP<BR>\r
 (C) Copyright 2015 Hewlett-Packard Development Company, L.P.<BR>\r
 This program and the accompanying materials\r
@@ -293,9 +293,9 @@ BdsReadKeys (
   }\r
 \r
   while (gST->ConIn != NULL) {\r
-    \r
+\r
     Status = gST->ConIn->ReadKeyStroke (gST->ConIn, &Key);\r
-    \r
+\r
     if (EFI_ERROR (Status)) {\r
       //\r
       // No more keys.\r
@@ -488,10 +488,10 @@ ProcessLoadOptions (
 \r
 /**\r
 \r
-  Validate input console variable data. \r
+  Validate input console variable data.\r
 \r
   If found the device path is not a valid device path, remove the variable.\r
-  \r
+\r
   @param VariableName             Input console variable name.\r
 \r
 **/\r
@@ -505,7 +505,7 @@ BdsFormalizeConsoleVariable (
   EFI_STATUS                Status;\r
 \r
   GetEfiGlobalVariable2 (VariableName, (VOID **) &DevicePath, &VariableSize);\r
-  if ((DevicePath != NULL) && !IsDevicePathValid (DevicePath, VariableSize)) { \r
+  if ((DevicePath != NULL) && !IsDevicePathValid (DevicePath, VariableSize)) {\r
     Status = gRT->SetVariable (\r
                     VariableName,\r
                     &gEfiGlobalVariableGuid,\r
@@ -525,17 +525,17 @@ BdsFormalizeConsoleVariable (
 }\r
 \r
 /**\r
-  Formalize OsIndication related variables. \r
-  \r
-  For OsIndicationsSupported, Create a BS/RT/UINT64 variable to report caps \r
+  Formalize OsIndication related variables.\r
+\r
+  For OsIndicationsSupported, Create a BS/RT/UINT64 variable to report caps\r
   Delete OsIndications variable if it is not NV/BS/RT UINT64.\r
-  \r
+\r
   Item 3 is used to solve case when OS corrupts OsIndications. Here simply delete this NV variable.\r
 \r
   Create a boot option for BootManagerMenu if it hasn't been created yet\r
 \r
 **/\r
-VOID \r
+VOID\r
 BdsFormalizeOSIndicationVariable (\r
   VOID\r
   )\r
@@ -613,10 +613,10 @@ BdsFormalizeOSIndicationVariable (
 \r
 /**\r
 \r
-  Validate variables. \r
+  Validate variables.\r
 \r
 **/\r
-VOID \r
+VOID\r
 BdsFormalizeEfiGlobalVariable (\r
   VOID\r
   )\r
@@ -634,106 +634,6 @@ BdsFormalizeEfiGlobalVariable (
   BdsFormalizeOSIndicationVariable ();\r
 }\r
 \r
-/**\r
-\r
-  Allocate a block of memory that will contain performance data to OS.\r
-\r
-**/\r
-VOID\r
-BdsAllocateMemoryForPerformanceData (\r
-  VOID\r
-  )\r
-{\r
-  EFI_STATUS                    Status;\r
-  EFI_PHYSICAL_ADDRESS          AcpiLowMemoryBase;\r
-  EDKII_VARIABLE_LOCK_PROTOCOL  *VariableLock;\r
-\r
-  AcpiLowMemoryBase = 0x0FFFFFFFFULL;\r
-\r
-  //\r
-  // Allocate a block of memory that will contain performance data to OS.\r
-  //\r
-  Status = gBS->AllocatePages (\r
-                  AllocateMaxAddress,\r
-                  EfiReservedMemoryType,\r
-                  EFI_SIZE_TO_PAGES (PERF_DATA_MAX_LENGTH),\r
-                  &AcpiLowMemoryBase\r
-                  );\r
-  if (!EFI_ERROR (Status)) {\r
-    //\r
-    // Save the pointer to variable for use in S3 resume.\r
-    //\r
-    Status = BdsDxeSetVariableAndReportStatusCodeOnError (\r
-               L"PerfDataMemAddr",\r
-               &gPerformanceProtocolGuid,\r
-               EFI_VARIABLE_NON_VOLATILE | EFI_VARIABLE_BOOTSERVICE_ACCESS | EFI_VARIABLE_RUNTIME_ACCESS,\r
-               sizeof (EFI_PHYSICAL_ADDRESS),\r
-               &AcpiLowMemoryBase\r
-               );\r
-    if (EFI_ERROR (Status)) {\r
-      DEBUG ((EFI_D_ERROR, "[Bds] PerfDataMemAddr (%08x) cannot be saved to NV storage.\n", AcpiLowMemoryBase));\r
-    }\r
-    //\r
-    // Mark L"PerfDataMemAddr" variable to read-only if the Variable Lock protocol exists\r
-    // Still lock it even the variable cannot be saved to prevent it's set by 3rd party code.\r
-    //\r
-    Status = gBS->LocateProtocol (&gEdkiiVariableLockProtocolGuid, NULL, (VOID **) &VariableLock);\r
-    if (!EFI_ERROR (Status)) {\r
-      Status = VariableLock->RequestToLock (VariableLock, L"PerfDataMemAddr", &gPerformanceProtocolGuid);\r
-      ASSERT_EFI_ERROR (Status);\r
-    }\r
-  }\r
-}\r
-\r
-/**\r
-  Enter an infinite loop of calling the Boot Manager Menu.\r
-\r
-  This is a last resort alternative to BdsEntry() giving up for good. This\r
-  function never returns.\r
-\r
-  @param[in] BootManagerMenu  The EFI_BOOT_MANAGER_LOAD_OPTION located and/or\r
-                              created by the EfiBootManagerGetBootManagerMenu()\r
-                              call in BdsEntry().\r
-**/\r
-VOID\r
-BdsBootManagerMenuLoop (\r
-  IN EFI_BOOT_MANAGER_LOAD_OPTION *BootManagerMenu\r
-  )\r
-{\r
-  EFI_INPUT_KEY Key;\r
-\r
-  //\r
-  // Normally BdsDxe does not print anything to the system console, but this is\r
-  // a last resort -- the end-user will likely not see any DEBUG messages\r
-  // logged in this situation.\r
-  //\r
-  // AsciiPrint() will NULL-check gST->ConOut internally. We check gST->ConIn\r
-  // here to see if it makes sense to request and wait for a keypress.\r
-  //\r
-  if (gST->ConIn != NULL) {\r
-    AsciiPrint (\r
-      "%a: No bootable option or device was found.\n"\r
-      "%a: Press any key to enter the Boot Manager Menu.\n",\r
-      gEfiCallerBaseName,\r
-      gEfiCallerBaseName\r
-      );\r
-    BdsWaitForSingleEvent (gST->ConIn->WaitForKey, 0);\r
-\r
-    //\r
-    // Drain any queued keys.\r
-    //\r
-    while (!EFI_ERROR (gST->ConIn->ReadKeyStroke (gST->ConIn, &Key))) {\r
-      //\r
-      // just throw away Key\r
-      //\r
-    }\r
-  }\r
-\r
-  for (;;) {\r
-    EfiBootManagerBoot (BootManagerMenu);\r
-  }\r
-}\r
-\r
 /**\r
 \r
   Service routine for BdsInstance->Entry(). Devices are connected, the\r
@@ -776,14 +676,10 @@ BdsEntry (
   //\r
   // Insert the performance probe\r
   //\r
-  PERF_END (NULL, "DXE", NULL, 0);\r
-  PERF_START (NULL, "BDS", NULL, 0);\r
+  PERF_CROSSMODULE_END("DXE");\r
+  PERF_CROSSMODULE_BEGIN("BDS");\r
   DEBUG ((EFI_D_INFO, "[Bds] Entry...\n"));\r
 \r
-  PERF_CODE (\r
-    BdsAllocateMemoryForPerformanceData ();\r
-  );\r
-\r
   //\r
   // Fill in FirmwareVendor and FirmwareRevision from PCDs\r
   //\r
@@ -939,13 +835,13 @@ BdsEntry (
   // Possible things that can be done in PlatformBootManagerBeforeConsole:\r
   // > Update console variable: 1. include hot-plug devices; 2. Clear ConIn and add SOL for AMT\r
   // > Register new Driver#### or Boot####\r
-  // > Register new Key####: e.g.: F12 \r
+  // > Register new Key####: e.g.: F12\r
   // > Signal ReadyToLock event\r
   // > Authentication action: 1. connect Auth devices; 2. Identify auto logon user.\r
   //\r
-  PERF_START (NULL, "PlatformBootManagerBeforeConsole", "BDS", 0);\r
+  PERF_INMODULE_BEGIN("PlatformBootManagerBeforeConsole");\r
   PlatformBootManagerBeforeConsole ();\r
-  PERF_END   (NULL, "PlatformBootManagerBeforeConsole", "BDS", 0);\r
+  PERF_INMODULE_END("PlatformBootManagerBeforeConsole");\r
 \r
   //\r
   // Initialize hotkey service\r
@@ -962,7 +858,7 @@ BdsEntry (
   //\r
   // Connect consoles\r
   //\r
-  PERF_START (NULL, "EfiBootManagerConnectAllDefaultConsoles", "BDS", 0);\r
+  PERF_INMODULE_BEGIN("EfiBootManagerConnectAllDefaultConsoles");\r
   if (PcdGetBool (PcdConInConnectOnDemand)) {\r
     EfiBootManagerConnectConsoleVariable (ConOut);\r
     EfiBootManagerConnectConsoleVariable (ErrOut);\r
@@ -972,7 +868,7 @@ BdsEntry (
   } else {\r
     EfiBootManagerConnectAllDefaultConsoles ();\r
   }\r
-  PERF_END   (NULL, "EfiBootManagerConnectAllDefaultConsoles", "BDS", 0);\r
+  PERF_INMODULE_END("EfiBootManagerConnectAllDefaultConsoles");\r
 \r
   //\r
   // Do the platform specific action after the console is ready\r
@@ -984,10 +880,10 @@ BdsEntry (
   // > Connect certain devices\r
   // > Dispatch aditional option roms\r
   // > Special boot: e.g.: USB boot, enter UI\r
-  // \r
-  PERF_START (NULL, "PlatformBootManagerAfterConsole", "BDS", 0);\r
+  //\r
+  PERF_INMODULE_BEGIN("PlatformBootManagerAfterConsole");\r
   PlatformBootManagerAfterConsole ();\r
-  PERF_END   (NULL, "PlatformBootManagerAfterConsole", "BDS", 0);\r
+  PERF_INMODULE_END("PlatformBootManagerAfterConsole");\r
   //\r
   // Boot to Boot Manager Menu when EFI_OS_INDICATIONS_BOOT_TO_FW_UI is set. Skip HotkeyBoot\r
   //\r
@@ -1036,7 +932,7 @@ BdsEntry (
   PlatformRecovery = (BOOLEAN) ((OsIndication & EFI_OS_INDICATIONS_START_PLATFORM_RECOVERY) != 0);\r
   //\r
   // Clear EFI_OS_INDICATIONS_BOOT_TO_FW_UI to acknowledge OS\r
-  // \r
+  //\r
   if (BootFwUi || PlatformRecovery) {\r
     OsIndication &= ~((UINT64) (EFI_OS_INDICATIONS_BOOT_TO_FW_UI | EFI_OS_INDICATIONS_START_PLATFORM_RECOVERY));\r
     Status = gRT->SetVariable (\r
@@ -1080,10 +976,9 @@ BdsEntry (
     //\r
     // Execute Key####\r
     //\r
-    PERF_START (NULL, "BdsWait", "BDS", 0);\r
+    PERF_INMODULE_BEGIN ("BdsWait");\r
     BdsWait (HotkeyTriggered);\r
-    PERF_END   (NULL, "BdsWait", "BDS", 0);\r
-\r
+    PERF_INMODULE_END ("BdsWait");\r
     //\r
     // BdsReadKeys() can be removed after all keyboard drivers invoke callback in timer callback.\r
     //\r
@@ -1115,7 +1010,7 @@ BdsEntry (
       if (!EFI_ERROR (Status)) {\r
         EfiBootManagerBoot (&LoadOption);\r
         EfiBootManagerFreeLoadOption (&LoadOption);\r
-        if ((LoadOption.Status == EFI_SUCCESS) && \r
+        if ((LoadOption.Status == EFI_SUCCESS) &&\r
             (BootManagerMenuStatus != EFI_NOT_FOUND) &&\r
             (LoadOption.OptionNumber != BootManagerMenu.OptionNumber)) {\r
           //\r
@@ -1137,19 +1032,16 @@ BdsEntry (
     } while (BootSuccess);\r
   }\r
 \r
+  if (BootManagerMenuStatus != EFI_NOT_FOUND) {\r
+    EfiBootManagerFreeLoadOption (&BootManagerMenu);\r
+  }\r
+\r
   if (!BootSuccess) {\r
     LoadOptions = EfiBootManagerGetLoadOptions (&LoadOptionCount, LoadOptionTypePlatformRecovery);\r
     ProcessLoadOptions (LoadOptions, LoadOptionCount);\r
     EfiBootManagerFreeLoadOptions (LoadOptions, LoadOptionCount);\r
   }\r
 \r
-  //\r
-  // If BootManagerMenu is available, fall back to it indefinitely.\r
-  //\r
-  if (BootManagerMenuStatus != EFI_NOT_FOUND) {\r
-    BdsBootManagerMenuLoop (&BootManagerMenu);\r
-  }\r
-\r
   DEBUG ((EFI_D_ERROR, "[Bds] Unable to boot!\n"));\r
   CpuDeadLoop ();\r
 }\r
@@ -1163,14 +1055,14 @@ BdsEntry (
                                  then EFI_INVALID_PARAMETER is returned.\r
   @param  VendorGuid             A unique identifier for the vendor.\r
   @param  Attributes             Attributes bitmask to set for the variable.\r
-  @param  DataSize               The size in bytes of the Data buffer. Unless the EFI_VARIABLE_APPEND_WRITE, \r
+  @param  DataSize               The size in bytes of the Data buffer. Unless the EFI_VARIABLE_APPEND_WRITE,\r
                                  or EFI_VARIABLE_TIME_BASED_AUTHENTICATED_WRITE_ACCESS attribute is set, a size of zero\r
-                                 causes the variable to be deleted. When the EFI_VARIABLE_APPEND_WRITE attribute is \r
-                                 set, then a SetVariable() call with a DataSize of zero will not cause any change to \r
-                                 the variable value (the timestamp associated with the variable may be updated however \r
-                                 even if no new data value is provided,see the description of the \r
-                                 EFI_VARIABLE_AUTHENTICATION_2 descriptor below. In this case the DataSize will not \r
-                                 be zero since the EFI_VARIABLE_AUTHENTICATION_2 descriptor will be populated). \r
+                                 causes the variable to be deleted. When the EFI_VARIABLE_APPEND_WRITE attribute is\r
+                                 set, then a SetVariable() call with a DataSize of zero will not cause any change to\r
+                                 the variable value (the timestamp associated with the variable may be updated however\r
+                                 even if no new data value is provided,see the description of the\r
+                                 EFI_VARIABLE_AUTHENTICATION_2 descriptor below. In this case the DataSize will not\r
+                                 be zero since the EFI_VARIABLE_AUTHENTICATION_2 descriptor will be populated).\r
   @param  Data                   The contents for the variable.\r
 \r
   @retval EFI_SUCCESS            The firmware has successfully stored the variable and its data as\r