]> git.proxmox.com Git - mirror_edk2.git/blobdiff - MdeModulePkg/Universal/BdsDxe/BdsEntry.c
MdeModulePkg: Deprecate EFI_VARIABLE_AUTHENTICATED_WRITE_ACCESS
[mirror_edk2.git] / MdeModulePkg / Universal / BdsDxe / BdsEntry.c
index 98b393109389d74a1fe824562afe845acc6535a0..dccc4909021967cf1bf2cbf4409aaf4cfbc6a3b0 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 - 2016, Intel Corporation. All rights reserved.<BR>\r
+Copyright (c) 2004 - 2017, 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
@@ -369,6 +369,11 @@ BootBootOptions (
 {\r
   UINTN                              Index;\r
 \r
+  //\r
+  // Report Status Code to indicate BDS starts attempting booting from the UEFI BootOrder list.\r
+  //\r
+  REPORT_STATUS_CODE (EFI_PROGRESS_CODE, (EFI_SOFTWARE_DXE_BS_DRIVER | EFI_SW_DXE_BS_PC_ATTEMPT_BOOT_ORDER_EVENT));\r
+\r
   //\r
   // Attempt boot each boot option\r
   //\r
@@ -803,7 +808,8 @@ BdsEntry (
   ASSERT_EFI_ERROR (Status);\r
 \r
   //\r
-  // Cache and remove the "BootNext" NV variable.\r
+  // Cache the "BootNext" NV variable before calling any PlatformBootManagerLib APIs\r
+  // This could avoid the "BootNext" set by PlatformBootManagerLib be consumed in this boot.\r
   //\r
   GetEfiGlobalVariable2 (EFI_BOOT_NEXT_VARIABLE_NAME, (VOID **) &BootNext, &DataSize);\r
   if (DataSize != sizeof (UINT16)) {\r
@@ -812,17 +818,6 @@ BdsEntry (
     }\r
     BootNext = NULL;\r
   }\r
-  Status = gRT->SetVariable (\r
-                  EFI_BOOT_NEXT_VARIABLE_NAME,\r
-                  &gEfiGlobalVariableGuid,\r
-                  0,\r
-                  0,\r
-                  NULL\r
-                  );\r
-  //\r
-  // Deleting NV variable shouldn't fail unless it doesn't exist.\r
-  //\r
-  ASSERT (Status == EFI_SUCCESS || Status == EFI_NOT_FOUND);\r
 \r
   //\r
   // Initialize the platform language variables\r
@@ -873,6 +868,23 @@ BdsEntry (
     (EFI_SOFTWARE_DXE_BS_DRIVER | EFI_SW_DXE_BS_PC_BEGIN_CONNECTING_DRIVERS)\r
     );\r
 \r
+  //\r
+  // Initialize ConnectConIn event before calling platform code.\r
+  //\r
+  if (PcdGetBool (PcdConInConnectOnDemand)) {\r
+    Status = gBS->CreateEventEx (\r
+                    EVT_NOTIFY_SIGNAL,\r
+                    TPL_CALLBACK,\r
+                    BdsDxeOnConnectConInCallBack,\r
+                    NULL,\r
+                    &gConnectConInEventGuid,\r
+                    &gConnectConInEvent\r
+                    );\r
+    if (EFI_ERROR (Status)) {\r
+      gConnectConInEvent = NULL;\r
+    }\r
+  }\r
+\r
   //\r
   // Do the platform init, can be customized by OEM/IBV\r
   // Possible things that can be done in PlatformBootManagerBeforeConsole:\r
@@ -905,21 +917,9 @@ BdsEntry (
   if (PcdGetBool (PcdConInConnectOnDemand)) {\r
     EfiBootManagerConnectConsoleVariable (ConOut);\r
     EfiBootManagerConnectConsoleVariable (ErrOut);\r
-\r
     //\r
-    // Initialize ConnectConIn event\r
+    // Do not connect ConIn devices when lazy ConIn feature is ON.\r
     //\r
-    Status = gBS->CreateEventEx (\r
-                    EVT_NOTIFY_SIGNAL,\r
-                    TPL_CALLBACK,\r
-                    BdsDxeOnConnectConInCallBack,\r
-                    NULL,\r
-                    &gConnectConInEventGuid,\r
-                    &gConnectConInEvent\r
-                    );\r
-    if (EFI_ERROR (Status)) {\r
-      gConnectConInEvent = NULL;\r
-    }\r
   } else {\r
     EfiBootManagerConnectAllDefaultConsoles ();\r
   }\r
@@ -1042,10 +1042,25 @@ BdsEntry (
 \r
     EfiBootManagerHotkeyBoot ();\r
 \r
-    //\r
-    // Boot to "BootNext"\r
-    //\r
     if (BootNext != NULL) {\r
+      //\r
+      // Delete "BootNext" NV variable before transferring control to it to prevent loops.\r
+      //\r
+      Status = gRT->SetVariable (\r
+                      EFI_BOOT_NEXT_VARIABLE_NAME,\r
+                      &gEfiGlobalVariableGuid,\r
+                      0,\r
+                      0,\r
+                      NULL\r
+                      );\r
+      //\r
+      // Deleting NV variable shouldn't fail unless it doesn't exist.\r
+      //\r
+      ASSERT (Status == EFI_SUCCESS || Status == EFI_NOT_FOUND);\r
+\r
+      //\r
+      // Boot to "BootNext"\r
+      //\r
       UnicodeSPrint (BootNextVariableName, sizeof (BootNextVariableName), L"Boot%04x", *BootNext);\r
       Status = EfiBootManagerVariableToLoadOption (BootNextVariableName, &LoadOption);\r
       if (!EFI_ERROR (Status)) {\r
@@ -1097,8 +1112,7 @@ BdsEntry (
   @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
-                                 EFI_VARIABLE_AUTHENTICATED_WRITE_ACCESS, or \r
-                                 EFI_VARIABLE_TIME_BASED_AUTHENTICATED_WRITE_ACCESS attribute is set, a size of zero \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
@@ -1116,9 +1130,8 @@ BdsEntry (
   @retval EFI_DEVICE_ERROR       The variable could not be retrieved due to a hardware error.\r
   @retval EFI_WRITE_PROTECTED    The variable in question is read-only.\r
   @retval EFI_WRITE_PROTECTED    The variable in question cannot be deleted.\r
-  @retval EFI_SECURITY_VIOLATION The variable could not be written due to EFI_VARIABLE_AUTHENTICATED_WRITE_ACCESS \r
-                                 or EFI_VARIABLE_TIME_BASED_AUTHENTICATED_WRITE_ACESS being set, but the AuthInfo \r
-                                 does NOT pass the validation check carried out by the firmware.\r
+  @retval EFI_SECURITY_VIOLATION The variable could not be written due to EFI_VARIABLE_TIME_BASED_AUTHENTICATED_WRITE_ACESS\r
+                                 being set, but the AuthInfo does NOT pass the validation check carried out by the firmware.\r
 \r
   @retval EFI_NOT_FOUND          The variable trying to be updated or deleted was not found.\r
 **/\r