Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

No UEFI Shell #208

Open
wants to merge 3 commits into
base: dasharo
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 3 additions & 4 deletions DasharoPayloadPkg/DasharoPayloadPkg.dsc
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,7 @@
DEFINE NETWORK_IP4_ENABLE = TRUE
DEFINE NETWORK_LAN_ROM = FALSE

!if $(NETWORK_ENABLE) == TRUE
!if $(NETWORK_PXE_BOOT) == TRUE
DEFINE NETWORK_SNP_ENABLE = TRUE
DEFINE NETWORK_HTTP_BOOT_ENABLE = FALSE
Expand All @@ -135,7 +136,7 @@
DEFINE NETWORK_ALLOW_HTTP_CONNECTIONS = TRUE
DEFINE NETWORK_ISCSI_ENABLE = TRUE
!endif

!endif

!include NetworkPkg/NetworkDefines.dsc.inc
#
Expand Down Expand Up @@ -204,6 +205,7 @@
UefiHiiServicesLib|MdeModulePkg/Library/UefiHiiServicesLib/UefiHiiServicesLib.inf
HiiLib|MdeModulePkg/Library/UefiHiiLib/UefiHiiLib.inf
DevicePathLib|MdePkg/Library/UefiDevicePathLib/UefiDevicePathLib.inf
FileHandleLib|MdePkg/Library/UefiFileHandleLib/UefiFileHandleLib.inf
UefiDecompressLib|MdePkg/Library/BaseUefiDecompressLib/BaseUefiDecompressLib.inf
PeiServicesTablePointerLib|MdePkg/Library/PeiServicesTablePointerLibIdt/PeiServicesTablePointerLibIdt.inf
PeiServicesLib|MdePkg/Library/PeiServicesLib/PeiServicesLib.inf
Expand Down Expand Up @@ -990,8 +992,6 @@
#
[LibraryClasses]
BcfgCommandLib|ShellPkg/Library/UefiShellBcfgCommandLib/UefiShellBcfgCommandLib.inf
DevicePathLib|MdePkg/Library/UefiDevicePathLib/UefiDevicePathLib.inf
FileHandleLib|MdePkg/Library/UefiFileHandleLib/UefiFileHandleLib.inf
ShellLib|ShellPkg/Library/UefiShellLib/UefiShellLib.inf

[Components.X64]
Expand Down Expand Up @@ -1039,7 +1039,6 @@

<LibraryClasses>
DebugLib|MdePkg/Library/UefiDebugLibConOut/UefiDebugLibConOut.inf
DevicePathLib|MdePkg/Library/UefiDevicePathLib/UefiDevicePathLib.inf
HandleParsingLib|ShellPkg/Library/UefiHandleParsingLib/UefiHandleParsingLib.inf
OrderedCollectionLib|MdePkg/Library/BaseOrderedCollectionRedBlackTreeLib/BaseOrderedCollectionRedBlackTreeLib.inf
PcdLib|MdePkg/Library/DxePcdLib/DxePcdLib.inf
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,8 @@ PlatformRegisterFvBootOption (
MEDIA_FW_VOL_FILEPATH_DEVICE_PATH FileNode;
EFI_LOADED_IMAGE_PROTOCOL *LoadedImage;
EFI_DEVICE_PATH_PROTOCOL *DevicePath;
EFI_DEVICE_PATH_PROTOCOL *FileDevicePath;
BOOLEAN FileExists;

Status = gBS->HandleProtocol (
gImageHandle,
Expand All @@ -128,6 +130,16 @@ PlatformRegisterFvBootOption (
);
ASSERT (DevicePath != NULL);

// Search if given file exists anywhere
Status = GetFileDevicePathFromAnyFv (
FileGuid,
EFI_SECTION_ALL,
0,
&FileDevicePath
);

FileExists = !EFI_ERROR (Status);

Status = EfiBootManagerInitializeLoadOption (
&NewOption,
LoadOptionNumberUnassigned,
Expand All @@ -141,6 +153,8 @@ PlatformRegisterFvBootOption (
ASSERT_EFI_ERROR (Status);
FreePool (DevicePath);

// No need to guard here, because an error would be displayed on the screen
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No need to guard here in front of an if is confusing without knowing context of this commit. Would be clearer to mention file existence explicitly.

// if file is not found.
if (BootNow)
EfiBootManagerBoot (&NewOption);

Expand All @@ -152,9 +166,14 @@ PlatformRegisterFvBootOption (
&NewOption, BootOptions, BootOptionCount
);

if (OptionIndex == -1) {
if (OptionIndex == -1 && FileExists) {
Status = EfiBootManagerAddLoadOptionVariable (&NewOption, MAX_UINTN);
ASSERT_EFI_ERROR (Status);
} else if (OptionIndex != -1 && !FileExists) {
// Option exists but no longer in the image. Remove it from boot option list.
Status = EfiBootManagerDeleteLoadOptionVariable (BootOptions[OptionIndex].OptionNumber,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This makes function for adding an option to remove an already existing one.

I don't really have a better way of implementing it (need some place which can drop all outdated entries and there might be none), but an update to a comment on PlatformRegisterFvBootOption() to warn about this unexpected behaviour seems warranted.

BootOptions[OptionIndex].OptionType);
ASSERT_EFI_ERROR (Status);
}

EfiBootManagerFreeLoadOption (&NewOption);
Expand Down