summaryrefslogtreecommitdiffstats
path: root/ArmPkg/Library/PlatformBootManagerLib/PlatformBm.c
diff options
context:
space:
mode:
Diffstat (limited to 'ArmPkg/Library/PlatformBootManagerLib/PlatformBm.c')
-rw-r--r--ArmPkg/Library/PlatformBootManagerLib/PlatformBm.c72
1 files changed, 71 insertions, 1 deletions
diff --git a/ArmPkg/Library/PlatformBootManagerLib/PlatformBm.c b/ArmPkg/Library/PlatformBootManagerLib/PlatformBm.c
index 08998ffe4d..ea093bb725 100644
--- a/ArmPkg/Library/PlatformBootManagerLib/PlatformBm.c
+++ b/ArmPkg/Library/PlatformBootManagerLib/PlatformBm.c
@@ -2,7 +2,7 @@
Implementation for PlatformBootManagerLib library class interfaces.
Copyright (C) 2015-2016, Red Hat, Inc.
- Copyright (c) 2014 - 2021, ARM Ltd. All rights reserved.<BR>
+ Copyright (c) 2014 - 2023, Arm Ltd. All rights reserved.<BR>
Copyright (c) 2004 - 2018, Intel Corporation. All rights reserved.<BR>
Copyright (c) 2016, Linaro Ltd. All rights reserved.<BR>
Copyright (c) 2021, Semihalf All rights reserved.<BR>
@@ -470,6 +470,64 @@ PlatformRegisterFvBootOption (
EfiBootManagerFreeLoadOptions (BootOptions, BootOptionCount);
}
+/** Boot a Fv Boot Option.
+
+ This function is useful for booting the UEFI Shell as it is loaded
+ as a non active boot option.
+
+ @param[in] FileGuid The File GUID.
+ @param[in] Description String describing the Boot Option.
+
+**/
+STATIC
+VOID
+PlatformBootFvBootOption (
+ IN CONST EFI_GUID *FileGuid,
+ IN CHAR16 *Description
+ )
+{
+ EFI_STATUS Status;
+ EFI_BOOT_MANAGER_LOAD_OPTION NewOption;
+ MEDIA_FW_VOL_FILEPATH_DEVICE_PATH FileNode;
+ EFI_LOADED_IMAGE_PROTOCOL *LoadedImage;
+ EFI_DEVICE_PATH_PROTOCOL *DevicePath;
+
+ Status = gBS->HandleProtocol (
+ gImageHandle,
+ &gEfiLoadedImageProtocolGuid,
+ (VOID **)&LoadedImage
+ );
+ ASSERT_EFI_ERROR (Status);
+
+ //
+ // The UEFI Shell was registered in PlatformRegisterFvBootOption ()
+ // previously, thus it must still be available in this FV.
+ //
+ EfiInitializeFwVolDevicepathNode (&FileNode, FileGuid);
+ DevicePath = DevicePathFromHandle (LoadedImage->DeviceHandle);
+ ASSERT (DevicePath != NULL);
+ DevicePath = AppendDevicePathNode (
+ DevicePath,
+ (EFI_DEVICE_PATH_PROTOCOL *)&FileNode
+ );
+ ASSERT (DevicePath != NULL);
+
+ Status = EfiBootManagerInitializeLoadOption (
+ &NewOption,
+ LoadOptionNumberUnassigned,
+ LoadOptionTypeBoot,
+ LOAD_OPTION_ACTIVE,
+ Description,
+ DevicePath,
+ NULL,
+ 0
+ );
+ ASSERT_EFI_ERROR (Status);
+ FreePool (DevicePath);
+
+ EfiBootManagerBoot (&NewOption);
+}
+
STATIC
VOID
GetPlatformOptions (
@@ -1076,6 +1134,18 @@ PlatformBootManagerUnableToBoot (
EfiBootManagerRefreshAllBootOption ();
//
+ // Boot the 'UEFI Shell'. If the Pcd is not set, the UEFI Shell is not
+ // an active boot option and must be manually selected through UiApp
+ // (at least during the fist boot).
+ //
+ if (FixedPcdGetBool (PcdUefiShellDefaultBootEnable)) {
+ PlatformBootFvBootOption (
+ &gUefiShellFileGuid,
+ L"UEFI Shell (default)"
+ );
+ }
+
+ //
// Record the updated number of boot configured boot options
//
BootOptions = EfiBootManagerGetLoadOptions (