]> git.proxmox.com Git - mirror_edk2.git/blobdiff - IntelFrameworkModulePkg/Universal/BdsDxe/BdsEntry.c
Remove IntelFrameworkModulePkg
[mirror_edk2.git] / IntelFrameworkModulePkg / Universal / BdsDxe / BdsEntry.c
diff --git a/IntelFrameworkModulePkg/Universal/BdsDxe/BdsEntry.c b/IntelFrameworkModulePkg/Universal/BdsDxe/BdsEntry.c
deleted file mode 100644 (file)
index 8c7c340..0000000
+++ /dev/null
@@ -1,675 +0,0 @@
-/** @file\r
-  This module produce main entry for BDS phase - BdsEntry.\r
-  When this module was dispatched by DxeCore, gEfiBdsArchProtocolGuid will be installed\r
-  which contains interface of BdsEntry.\r
-  After DxeCore finish DXE phase, gEfiBdsArchProtocolGuid->BdsEntry will be invoked\r
-  to enter BDS phase.\r
-\r
-Copyright (c) 2004 - 2018, Intel Corporation. All rights reserved.<BR>\r
-SPDX-License-Identifier: BSD-2-Clause-Patent\r
-\r
-**/\r
-\r
-#include "Bds.h"\r
-#include "Language.h"\r
-#include "FrontPage.h"\r
-#include "Hotkey.h"\r
-#include "HwErrRecSupport.h"\r
-\r
-///\r
-/// BDS arch protocol instance initial value.\r
-///\r
-/// Note: Current BDS not directly get the BootMode, DefaultBoot,\r
-/// TimeoutDefault, MemoryTestLevel value from the BDS arch protocol.\r
-/// Please refer to the library useage of BdsLibGetBootMode, BdsLibGetTimeout\r
-/// and PlatformBdsDiagnostics in BdsPlatform.c\r
-///\r
-EFI_HANDLE  gBdsHandle = NULL;\r
-\r
-EFI_BDS_ARCH_PROTOCOL  gBds = {\r
-  BdsEntry\r
-};\r
-\r
-UINT16                          *mBootNext = NULL;\r
-\r
-///\r
-/// The read-only variables defined in UEFI Spec.\r
-///\r
-CHAR16  *mReadOnlyVariables[] = {\r
-  L"PlatformLangCodes",\r
-  L"LangCodes",\r
-  L"BootOptionSupport",\r
-  L"HwErrRecSupport",\r
-  L"OsIndicationsSupported"\r
-  };\r
-\r
-/**\r
-\r
-  Install Boot Device Selection Protocol\r
-\r
-  @param ImageHandle     The image handle.\r
-  @param SystemTable     The system table.\r
-\r
-  @retval  EFI_SUCEESS  BDS has finished initializing.\r
-                        Return the dispatcher and recall BDS.Entry\r
-  @retval  Other        Return status from AllocatePool() or gBS->InstallProtocolInterface\r
-\r
-**/\r
-EFI_STATUS\r
-EFIAPI\r
-BdsInitialize (\r
-  IN EFI_HANDLE                            ImageHandle,\r
-  IN EFI_SYSTEM_TABLE                      *SystemTable\r
-  )\r
-{\r
-  EFI_STATUS  Status;\r
-\r
-  //\r
-  // Install protocol interface\r
-  //\r
-  Status = gBS->InstallMultipleProtocolInterfaces (\r
-                  &gBdsHandle,\r
-                  &gEfiBdsArchProtocolGuid, &gBds,\r
-                  NULL\r
-                  );\r
-  ASSERT_EFI_ERROR (Status);\r
-\r
-  return Status;\r
-}\r
-\r
-/**\r
-\r
-  This function attempts to boot for the boot order specified\r
-  by platform policy.\r
-\r
-**/\r
-VOID\r
-BdsBootDeviceSelect (\r
-  VOID\r
-  )\r
-{\r
-  EFI_STATUS        Status;\r
-  LIST_ENTRY        *Link;\r
-  BDS_COMMON_OPTION *BootOption;\r
-  UINTN             ExitDataSize;\r
-  CHAR16            *ExitData;\r
-  UINT16            Timeout;\r
-  LIST_ENTRY        BootLists;\r
-  CHAR16            Buffer[20];\r
-  BOOLEAN           BootNextExist;\r
-  LIST_ENTRY        *LinkBootNext;\r
-  EFI_EVENT         ConnectConInEvent;\r
-\r
-  //\r
-  // Got the latest boot option\r
-  //\r
-  BootNextExist = FALSE;\r
-  LinkBootNext  = NULL;\r
-  ConnectConInEvent = NULL;\r
-  InitializeListHead (&BootLists);\r
-\r
-  //\r
-  // First check the boot next option\r
-  //\r
-  ZeroMem (Buffer, sizeof (Buffer));\r
-\r
-  //\r
-  // Create Event to signal ConIn connection request\r
-  //\r
-  if (PcdGetBool (PcdConInConnectOnDemand)) {\r
-    Status = gBS->CreateEventEx (\r
-                    EVT_NOTIFY_SIGNAL,\r
-                    TPL_CALLBACK,\r
-                    EfiEventEmptyFunction,\r
-                    NULL,\r
-                    &gConnectConInEventGuid,\r
-                    &ConnectConInEvent\r
-                    );\r
-    if (EFI_ERROR(Status)) {\r
-      ConnectConInEvent = NULL;\r
-    }\r
-  }\r
-\r
-  if (mBootNext != NULL) {\r
-    //\r
-    // Indicate we have the boot next variable, so this time\r
-    // boot will always have this boot option\r
-    //\r
-    BootNextExist = TRUE;\r
-\r
-    //\r
-    // Clear the this variable so it's only exist in this time boot\r
-    //\r
-    Status = gRT->SetVariable (\r
-                    L"BootNext",\r
-                    &gEfiGlobalVariableGuid,\r
-                    EFI_VARIABLE_BOOTSERVICE_ACCESS | EFI_VARIABLE_RUNTIME_ACCESS | EFI_VARIABLE_NON_VOLATILE,\r
-                    0,\r
-                    NULL\r
-                    );\r
-    //\r
-    // Deleting variable with current variable implementation shouldn't fail.\r
-    //\r
-    ASSERT_EFI_ERROR (Status);\r
-\r
-    //\r
-    // Add the boot next boot option\r
-    //\r
-    UnicodeSPrint (Buffer, sizeof (Buffer), L"Boot%04x", *mBootNext);\r
-    BootOption = BdsLibVariableToOption (&BootLists, Buffer);\r
-\r
-    //\r
-    // If fail to get boot option from variable, just return and do nothing.\r
-    //\r
-    if (BootOption == NULL) {\r
-      return;\r
-    }\r
-\r
-    BootOption->BootCurrent = *mBootNext;\r
-  }\r
-  //\r
-  // Parse the boot order to get boot option\r
-  //\r
-  BdsLibBuildOptionFromVar (&BootLists, L"BootOrder");\r
-\r
-  //\r
-  // When we didn't have chance to build boot option variables in the first\r
-  // full configuration boot (e.g.: Reset in the first page or in Device Manager),\r
-  // we have no boot options in the following mini configuration boot.\r
-  // Give the last chance to enumerate the boot options.\r
-  //\r
-  if (IsListEmpty (&BootLists)) {\r
-    BdsLibEnumerateAllBootOption (&BootLists);\r
-  }\r
-\r
-  Link = BootLists.ForwardLink;\r
-\r
-  //\r
-  // Parameter check, make sure the loop will be valid\r
-  //\r
-  if (Link == NULL) {\r
-    return ;\r
-  }\r
-  //\r
-  // Here we make the boot in a loop, every boot success will\r
-  // return to the front page\r
-  //\r
-  for (;;) {\r
-    //\r
-    // Check the boot option list first\r
-    //\r
-    if (Link == &BootLists) {\r
-      //\r
-      // When LazyConIn enabled, signal connect ConIn event before enter UI\r
-      //\r
-      if (PcdGetBool (PcdConInConnectOnDemand) && ConnectConInEvent != NULL) {\r
-        gBS->SignalEvent (ConnectConInEvent);\r
-      }\r
-\r
-      //\r
-      // There are two ways to enter here:\r
-      // 1. There is no active boot option, give user chance to\r
-      //    add new boot option\r
-      // 2. All the active boot option processed, and there is no\r
-      //    one is success to boot, then we back here to allow user\r
-      //    add new active boot option\r
-      //\r
-      Timeout = 0xffff;\r
-      PlatformBdsEnterFrontPage (Timeout, FALSE);\r
-      InitializeListHead (&BootLists);\r
-      BdsLibBuildOptionFromVar (&BootLists, L"BootOrder");\r
-      Link = BootLists.ForwardLink;\r
-      continue;\r
-    }\r
-    //\r
-    // Get the boot option from the link list\r
-    //\r
-    BootOption = CR (Link, BDS_COMMON_OPTION, Link, BDS_LOAD_OPTION_SIGNATURE);\r
-\r
-    //\r
-    // According to EFI Specification, if a load option is not marked\r
-    // as LOAD_OPTION_ACTIVE, the boot manager will not automatically\r
-    // load the option.\r
-    //\r
-    if (!IS_LOAD_OPTION_TYPE (BootOption->Attribute, LOAD_OPTION_ACTIVE)) {\r
-      //\r
-      // skip the header of the link list, because it has no boot option\r
-      //\r
-      Link = Link->ForwardLink;\r
-      continue;\r
-    }\r
-    //\r
-    // Make sure the boot option device path connected,\r
-    // but ignore the BBS device path\r
-    //\r
-    if (DevicePathType (BootOption->DevicePath) != BBS_DEVICE_PATH) {\r
-      //\r
-      // Notes: the internal shell can not been connected with device path\r
-      // so we do not check the status here\r
-      //\r
-      BdsLibConnectDevicePath (BootOption->DevicePath);\r
-    }\r
-\r
-    //\r
-    // Restore to original mode before launching boot option.\r
-    //\r
-    BdsSetConsoleMode (FALSE);\r
-\r
-    //\r
-    // All the driver options should have been processed since\r
-    // now boot will be performed.\r
-    //\r
-    Status = BdsLibBootViaBootOption (BootOption, BootOption->DevicePath, &ExitDataSize, &ExitData);\r
-    if (Status != EFI_SUCCESS) {\r
-      //\r
-      // Call platform action to indicate the boot fail\r
-      //\r
-      BootOption->StatusString = GetStringById (STRING_TOKEN (STR_BOOT_FAILED));\r
-      PlatformBdsBootFail (BootOption, Status, ExitData, ExitDataSize);\r
-\r
-      //\r
-      // Check the next boot option\r
-      //\r
-      Link = Link->ForwardLink;\r
-\r
-    } else {\r
-      //\r
-      // Call platform action to indicate the boot success\r
-      //\r
-      BootOption->StatusString = GetStringById (STRING_TOKEN (STR_BOOT_SUCCEEDED));\r
-      PlatformBdsBootSuccess (BootOption);\r
-\r
-      //\r
-      // Boot success, then stop process the boot order, and\r
-      // present the boot manager menu, front page\r
-      //\r
-\r
-      //\r
-      // When LazyConIn enabled, signal connect ConIn Event before enter UI\r
-      //\r
-      if (PcdGetBool (PcdConInConnectOnDemand) && ConnectConInEvent != NULL) {\r
-        gBS->SignalEvent (ConnectConInEvent);\r
-      }\r
-\r
-      Timeout = 0xffff;\r
-      PlatformBdsEnterFrontPage (Timeout, FALSE);\r
-\r
-      //\r
-      // Rescan the boot option list, avoid potential risk of the boot\r
-      // option change in front page\r
-      //\r
-      if (BootNextExist) {\r
-        LinkBootNext = BootLists.ForwardLink;\r
-      }\r
-\r
-      InitializeListHead (&BootLists);\r
-      if (LinkBootNext != NULL) {\r
-        //\r
-        // Reserve the boot next option\r
-        //\r
-        InsertTailList (&BootLists, LinkBootNext);\r
-      }\r
-\r
-      BdsLibBuildOptionFromVar (&BootLists, L"BootOrder");\r
-      Link = BootLists.ForwardLink;\r
-    }\r
-  }\r
-\r
-}\r
-\r
-/**\r
-\r
-  Validate input console variable data.\r
-\r
-  If found the device path is not a valid device path, remove the variable.\r
-\r
-  @param VariableName             Input console variable name.\r
-\r
-**/\r
-VOID\r
-BdsFormalizeConsoleVariable (\r
-  IN  CHAR16          *VariableName\r
-  )\r
-{\r
-  EFI_DEVICE_PATH_PROTOCOL  *DevicePath;\r
-  UINTN                     VariableSize;\r
-  EFI_STATUS                Status;\r
-\r
-  DevicePath = BdsLibGetVariableAndSize (\r
-                      VariableName,\r
-                      &gEfiGlobalVariableGuid,\r
-                      &VariableSize\r
-                      );\r
-  if ((DevicePath != NULL) && !IsDevicePathValid (DevicePath, VariableSize)) {\r
-    Status = gRT->SetVariable (\r
-                    VariableName,\r
-                    &gEfiGlobalVariableGuid,\r
-                    EFI_VARIABLE_BOOTSERVICE_ACCESS | EFI_VARIABLE_RUNTIME_ACCESS | EFI_VARIABLE_NON_VOLATILE,\r
-                    0,\r
-                    NULL\r
-                    );\r
-    //\r
-    // Deleting variable with current variable implementation shouldn't fail.\r
-    //\r
-    ASSERT_EFI_ERROR (Status);\r
-  }\r
-}\r
-\r
-/**\r
-\r
-  Formalize Bds global variables.\r
-\r
- 1. For ConIn/ConOut/ConErr, if found the device path is not a valid device path, remove the variable.\r
- 2. For OsIndicationsSupported, Create a BS/RT/UINT64 variable to report caps\r
- 3. Delete OsIndications variable if it is not NV/BS/RT UINT64\r
- Item 3 is used to solve case when OS corrupts OsIndications. Here simply delete this NV variable.\r
-\r
-**/\r
-VOID\r
-BdsFormalizeEfiGlobalVariable (\r
-  VOID\r
-  )\r
-{\r
-  EFI_STATUS Status;\r
-  UINT64     OsIndicationSupport;\r
-  UINT64     OsIndication;\r
-  UINTN      DataSize;\r
-  UINT32     Attributes;\r
-\r
-  //\r
-  // Validate Console variable.\r
-  //\r
-  BdsFormalizeConsoleVariable (L"ConIn");\r
-  BdsFormalizeConsoleVariable (L"ConOut");\r
-  BdsFormalizeConsoleVariable (L"ErrOut");\r
-\r
-  //\r
-  // OS indicater support variable\r
-  //\r
-  OsIndicationSupport = EFI_OS_INDICATIONS_BOOT_TO_FW_UI \\r
-                      | EFI_OS_INDICATIONS_FMP_CAPSULE_SUPPORTED;\r
-\r
-  BdsDxeSetVariableAndReportStatusCodeOnError (\r
-    L"OsIndicationsSupported",\r
-    &gEfiGlobalVariableGuid,\r
-    EFI_VARIABLE_BOOTSERVICE_ACCESS | EFI_VARIABLE_RUNTIME_ACCESS,\r
-    sizeof(UINT64),\r
-    &OsIndicationSupport\r
-    );\r
-\r
-  //\r
-  // If OsIndications is invalid, remove it.\r
-  // Invalid case\r
-  //   1. Data size != UINT64\r
-  //   2. OsIndication value inconsistence\r
-  //   3. OsIndication attribute inconsistence\r
-  //\r
-  OsIndication = 0;\r
-  Attributes = 0;\r
-  DataSize = sizeof(UINT64);\r
-  Status = gRT->GetVariable (\r
-                  L"OsIndications",\r
-                  &gEfiGlobalVariableGuid,\r
-                  &Attributes,\r
-                  &DataSize,\r
-                  &OsIndication\r
-                  );\r
-\r
-  if (!EFI_ERROR(Status)) {\r
-    if (DataSize != sizeof(UINT64) ||\r
-        (OsIndication & ~OsIndicationSupport) != 0 ||\r
-        Attributes != (EFI_VARIABLE_BOOTSERVICE_ACCESS | EFI_VARIABLE_RUNTIME_ACCESS | EFI_VARIABLE_NON_VOLATILE)){\r
-\r
-      DEBUG ((EFI_D_ERROR, "Unformalized OsIndications variable exists. Delete it\n"));\r
-      Status = gRT->SetVariable (\r
-                      L"OsIndications",\r
-                      &gEfiGlobalVariableGuid,\r
-                      0,\r
-                      0,\r
-                      NULL\r
-                      );\r
-      //\r
-      // Deleting variable with current variable implementation shouldn't fail.\r
-      //\r
-      ASSERT_EFI_ERROR (Status);\r
-    }\r
-  }\r
-\r
-}\r
-\r
-/**\r
-\r
-  Service routine for BdsInstance->Entry(). Devices are connected, the\r
-  consoles are initialized, and the boot options are tried.\r
-\r
-  @param This             Protocol Instance structure.\r
-\r
-**/\r
-VOID\r
-EFIAPI\r
-BdsEntry (\r
-  IN EFI_BDS_ARCH_PROTOCOL  *This\r
-  )\r
-{\r
-  LIST_ENTRY                      DriverOptionList;\r
-  LIST_ENTRY                      BootOptionList;\r
-  UINTN                           BootNextSize;\r
-  CHAR16                          *FirmwareVendor;\r
-  EFI_STATUS                      Status;\r
-  UINT16                          BootTimeOut;\r
-  UINTN                           Index;\r
-  EDKII_VARIABLE_LOCK_PROTOCOL    *VariableLock;\r
-\r
-  //\r
-  // Insert the performance probe\r
-  //\r
-  PERF_END (NULL, "DXE", NULL, 0);\r
-  PERF_START (NULL, "BDS", NULL, 0);\r
-\r
-  //\r
-  // Initialize the global system boot option and driver option\r
-  //\r
-  InitializeListHead (&DriverOptionList);\r
-  InitializeListHead (&BootOptionList);\r
-\r
-  //\r
-  // Initialize hotkey service\r
-  //\r
-  InitializeHotkeyService ();\r
-\r
-  //\r
-  // Fill in FirmwareVendor and FirmwareRevision from PCDs\r
-  //\r
-  FirmwareVendor = (CHAR16 *)PcdGetPtr (PcdFirmwareVendor);\r
-  gST->FirmwareVendor = AllocateRuntimeCopyPool (StrSize (FirmwareVendor), FirmwareVendor);\r
-  ASSERT (gST->FirmwareVendor != NULL);\r
-  gST->FirmwareRevision = PcdGet32 (PcdFirmwareRevision);\r
-\r
-  //\r
-  // Fixup Tasble CRC after we updated Firmware Vendor and Revision\r
-  //\r
-  gST->Hdr.CRC32 = 0;\r
-  gBS->CalculateCrc32 ((VOID *)gST, sizeof(EFI_SYSTEM_TABLE), &gST->Hdr.CRC32);\r
-\r
-  //\r
-  // Validate Variable.\r
-  //\r
-  BdsFormalizeEfiGlobalVariable();\r
-\r
-  //\r
-  // Mark the read-only variables if the Variable Lock protocol exists\r
-  //\r
-  Status = gBS->LocateProtocol (&gEdkiiVariableLockProtocolGuid, NULL, (VOID **) &VariableLock);\r
-  DEBUG ((EFI_D_INFO, "[BdsDxe] Locate Variable Lock protocol - %r\n", Status));\r
-  if (!EFI_ERROR (Status)) {\r
-    for (Index = 0; Index < ARRAY_SIZE (mReadOnlyVariables); Index++) {\r
-      Status = VariableLock->RequestToLock (VariableLock, mReadOnlyVariables[Index], &gEfiGlobalVariableGuid);\r
-      ASSERT_EFI_ERROR (Status);\r
-    }\r
-  }\r
-\r
-  //\r
-  // Report Status Code to indicate connecting drivers will happen\r
-  //\r
-  REPORT_STATUS_CODE (\r
-    EFI_PROGRESS_CODE,\r
-    (EFI_SOFTWARE_DXE_BS_DRIVER | EFI_SW_DXE_BS_PC_BEGIN_CONNECTING_DRIVERS)\r
-    );\r
-\r
-  InitializeHwErrRecSupport();\r
-\r
-  //\r
-  // Initialize L"Timeout" EFI global variable.\r
-  //\r
-  BootTimeOut = PcdGet16 (PcdPlatformBootTimeOut);\r
-  if (BootTimeOut != 0xFFFF) {\r
-    //\r
-    // If time out value equal 0xFFFF, no need set to 0xFFFF to variable area because UEFI specification\r
-    // define same behavior between no value or 0xFFFF value for L"Timeout".\r
-    //\r
-    BdsDxeSetVariableAndReportStatusCodeOnError (\r
-                    L"Timeout",\r
-                    &gEfiGlobalVariableGuid,\r
-                    EFI_VARIABLE_BOOTSERVICE_ACCESS | EFI_VARIABLE_RUNTIME_ACCESS | EFI_VARIABLE_NON_VOLATILE,\r
-                    sizeof (UINT16),\r
-                    &BootTimeOut\r
-                    );\r
-  }\r
-\r
-  //\r
-  // bugbug: platform specific code\r
-  // Initialize the platform specific string and language\r
-  //\r
-  InitializeStringSupport ();\r
-  InitializeLanguage (TRUE);\r
-  InitializeFrontPage (TRUE);\r
-\r
-  //\r
-  // Do the platform init, can be customized by OEM/IBV\r
-  //\r
-  PERF_START (NULL, "PlatformBds", "BDS", 0);\r
-  PlatformBdsInit ();\r
-\r
-  //\r
-  // Set up the device list based on EFI 1.1 variables\r
-  // process Driver#### and Load the driver's in the\r
-  // driver option list\r
-  //\r
-  BdsLibBuildOptionFromVar (&DriverOptionList, L"DriverOrder");\r
-  if (!IsListEmpty (&DriverOptionList)) {\r
-    BdsLibLoadDrivers (&DriverOptionList);\r
-  }\r
-  //\r
-  // Check if we have the boot next option\r
-  //\r
-  mBootNext = BdsLibGetVariableAndSize (\r
-                L"BootNext",\r
-                &gEfiGlobalVariableGuid,\r
-                &BootNextSize\r
-                );\r
-\r
-  //\r
-  // Setup some platform policy here\r
-  //\r
-  PlatformBdsPolicyBehavior (&DriverOptionList, &BootOptionList, BdsProcessCapsules, BdsMemoryTest);\r
-  PERF_END (NULL, "PlatformBds", "BDS", 0);\r
-\r
-  //\r
-  // BDS select the boot device to load OS\r
-  //\r
-  BdsBootDeviceSelect ();\r
-\r
-  //\r
-  // Only assert here since this is the right behavior, we should never\r
-  // return back to DxeCore.\r
-  //\r
-  ASSERT (FALSE);\r
-\r
-  return ;\r
-}\r
-\r
-\r
-/**\r
-  Set the variable and report the error through status code upon failure.\r
-\r
-  @param  VariableName           A Null-terminated string that is the name of the vendor's variable.\r
-                                 Each VariableName is unique for each VendorGuid. VariableName must\r
-                                 contain 1 or more characters. If VariableName is an empty string,\r
-                                 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
-                                 EFI_VARIABLE_AUTHENTICATED_WRITE_ACCESS, or\r
-                                 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
-  @param  Data                   The contents for the variable.\r
-\r
-  @retval EFI_SUCCESS            The firmware has successfully stored the variable and its data as\r
-                                 defined by the Attributes.\r
-  @retval EFI_INVALID_PARAMETER  An invalid combination of attribute bits, name, and GUID was supplied, or the\r
-                                 DataSize exceeds the maximum allowed.\r
-  @retval EFI_INVALID_PARAMETER  VariableName is an empty string.\r
-  @retval EFI_OUT_OF_RESOURCES   Not enough storage is available to hold the variable and its data.\r
-  @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
-\r
-  @retval EFI_NOT_FOUND          The variable trying to be updated or deleted was not found.\r
-**/\r
-EFI_STATUS\r
-BdsDxeSetVariableAndReportStatusCodeOnError (\r
-  IN CHAR16     *VariableName,\r
-  IN EFI_GUID   *VendorGuid,\r
-  IN UINT32     Attributes,\r
-  IN UINTN      DataSize,\r
-  IN VOID       *Data\r
-  )\r
-{\r
-  EFI_STATUS                 Status;\r
-  EDKII_SET_VARIABLE_STATUS  *SetVariableStatus;\r
-  UINTN                      NameSize;\r
-\r
-  Status = gRT->SetVariable (\r
-                  VariableName,\r
-                  VendorGuid,\r
-                  Attributes,\r
-                  DataSize,\r
-                  Data\r
-                  );\r
-  if (EFI_ERROR (Status)) {\r
-    NameSize = StrSize (VariableName);\r
-    SetVariableStatus = AllocatePool (sizeof (EDKII_SET_VARIABLE_STATUS) + NameSize + DataSize);\r
-    if (SetVariableStatus != NULL) {\r
-      CopyGuid (&SetVariableStatus->Guid, VendorGuid);\r
-      SetVariableStatus->NameSize   = NameSize;\r
-      SetVariableStatus->DataSize   = DataSize;\r
-      SetVariableStatus->SetStatus  = Status;\r
-      SetVariableStatus->Attributes = Attributes;\r
-      CopyMem (SetVariableStatus + 1,                          VariableName, NameSize);\r
-      CopyMem (((UINT8 *) (SetVariableStatus + 1)) + NameSize, Data,         DataSize);\r
-\r
-      REPORT_STATUS_CODE_EX (\r
-        EFI_ERROR_CODE,\r
-        PcdGet32 (PcdErrorCodeSetVariable),\r
-        0,\r
-        NULL,\r
-        &gEdkiiStatusCodeDataTypeVariableGuid,\r
-        SetVariableStatus,\r
-        sizeof (EDKII_SET_VARIABLE_STATUS) + NameSize + DataSize\r
-        );\r
-\r
-      FreePool (SetVariableStatus);\r
-    }\r
-  }\r
-\r
-  return Status;\r
-}\r
-\r