Skip to content

Commit

Permalink
OvmfPkg: register ipxe.efi file as boot option
Browse files Browse the repository at this point in the history
* Add ipxe.efi to the firmware volume.
* Based on NetBootEnable UEFI variable register or unregister iPXE as boot
option.

Signed-off-by: Piotr Król <[email protected]>
  • Loading branch information
pietrushnic committed Oct 23, 2023
1 parent f203b1c commit 689d3fc
Show file tree
Hide file tree
Showing 4 changed files with 52 additions and 2 deletions.
42 changes: 41 additions & 1 deletion OvmfPkg/Library/PlatformBootManagerLib/BdsPlatform.c
Original file line number Diff line number Diff line change
Expand Up @@ -1699,6 +1699,9 @@ PlatformBootManagerAfterConsole (
)
{
EFI_BOOT_MODE BootMode;
BOOLEAN NetBootEnabled;
UINTN VarSize;
EFI_STATUS Status;

DEBUG ((EFI_D_INFO, "PlatformBootManagerAfterConsole\n"));

Expand Down Expand Up @@ -1758,11 +1761,48 @@ PlatformBootManagerAfterConsole (

EfiBootManagerRefreshAllBootOption ();

VarSize = sizeof (NetBootEnabled);
Status = gRT->GetVariable (
L"NetworkBoot",
&gDasharoSystemFeaturesGuid,
NULL,
&VarSize,
&NetBootEnabled
);

//
// Register iPXE
//
if ((Status != EFI_NOT_FOUND) && (VarSize == sizeof(NetBootEnabled))) {
if (NetBootEnabled) {
DEBUG((DEBUG_INFO, "Registering iPXE boot option by variable\n"));
PlatformRegisterFvBootOption (PcdGetPtr (PcdiPXEFile),
(CHAR16 *) PcdGetPtr(PcdiPXEOptionName),
LOAD_OPTION_ACTIVE,
FALSE);
} else {
DEBUG((DEBUG_INFO, "Unregistering iPXE boot option by variable\n"));
PlatformUnregisterFvBootOption (PcdGetPtr (PcdiPXEFile),
(CHAR16 *) PcdGetPtr(PcdiPXEOptionName),
LOAD_OPTION_ACTIVE);
}
} else if ((Status == EFI_NOT_FOUND) && FixedPcdGetBool(PcdDefaultNetworkBootEnable)) {
DEBUG((DEBUG_INFO, "Registering iPXE boot option by policy\n"));
PlatformRegisterFvBootOption (PcdGetPtr (PcdiPXEFile),
(CHAR16 *) PcdGetPtr(PcdiPXEOptionName),
LOAD_OPTION_ACTIVE,
FALSE);
} else {
DEBUG((DEBUG_INFO, "Unregistering iPXE boot option\n"));
PlatformUnregisterFvBootOption (PcdGetPtr (PcdiPXEFile),
(CHAR16 *) PcdGetPtr(PcdiPXEOptionName),
LOAD_OPTION_ACTIVE);
}
//
// Register UEFI Shell
//
PlatformRegisterFvBootOption (
&gUefiShellFileGuid, L"UEFI Shell", LOAD_OPTION_ACTIVE
&gUefiShellFileGuid, L"UEFI Shell", LOAD_OPTION_ACTIVE, FALSE
);

RemoveStaleFvFileOptions ();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,8 @@
OvmfPkg/OvmfPkg.dec
SecurityPkg/SecurityPkg.dec
ShellPkg/ShellPkg.dec
UefiPayloadPkg/UefiPayloadPkg.dec
DasharoModulePkg/DasharoModulePkg.dec

[LibraryClasses]
BaseLib
Expand Down Expand Up @@ -61,6 +63,9 @@
gUefiOvmfPkgTokenSpaceGuid.PcdEmuVariableEvent
gUefiOvmfPkgTokenSpaceGuid.PcdOvmfFlashVariablesEnable
gUefiOvmfPkgTokenSpaceGuid.PcdOvmfHostBridgePciDevId
gUefiPayloadPkgTokenSpaceGuid.PcdiPXEFile
gUefiPayloadPkgTokenSpaceGuid.PcdiPXEOptionName
gDasharoSystemFeaturesTokenSpaceGuid.PcdDefaultNetworkBootEnable
gEfiMdePkgTokenSpaceGuid.PcdPlatformBootTimeOut
gEfiMdePkgTokenSpaceGuid.PcdUartDefaultBaudRate ## CONSUMES
gEfiMdePkgTokenSpaceGuid.PcdUartDefaultDataBits ## CONSUMES
Expand All @@ -84,3 +89,4 @@
gRootBridgesConnectedEventGroupGuid
gUefiShellFileGuid
gEfiTtyTermGuid
gDasharoSystemFeaturesGuid
4 changes: 4 additions & 0 deletions OvmfPkg/OvmfPkg.dec
Original file line number Diff line number Diff line change
Expand Up @@ -256,6 +256,10 @@
## Number of page frames to use for storing grant table entries.
gUefiOvmfPkgTokenSpaceGuid.PcdXenGrantFrames|4|UINT32|0x33

## FFS filename to find the ipxe application.
gUefiPayloadPkgTokenSpaceGuid.PcdiPXEFile|{ 0xC7, 0x53, 0x86, 0xb6, 0xA1, 0xEE, 0x35, 0x44, 0xA1, 0x99, 0xA4, 0x4F, 0x59, 0xE4, 0x47, 0x6C }|VOID*|0x10000006
gUefiPayloadPkgTokenSpaceGuid.PcdiPXEOptionName|L"iPXE"|VOID*|0x10000007

[PcdsDynamic, PcdsDynamicEx]
gUefiOvmfPkgTokenSpaceGuid.PcdEmuVariableEvent|0|UINT64|2
gUefiOvmfPkgTokenSpaceGuid.PcdOvmfFlashVariablesEnable|FALSE|BOOLEAN|0x10
Expand Down
2 changes: 1 addition & 1 deletion OvmfPkg/OvmfPkgX64.fdf
Original file line number Diff line number Diff line change
Expand Up @@ -327,7 +327,7 @@ INF MdeModulePkg/Logo/LogoDxe.inf
# build system or user should put the ipxe.efi file here before EDK2 build
#
FILE FREEFORM = B68653C7-EEA1-4435-A199-A44F59E4476C {
SECTION PE32 = UefiPayloadPkg/NetworkDrivers/ipxe.efi
SECTION PE32 = ipxe.efi
}
!endif

Expand Down

0 comments on commit 689d3fc

Please sign in to comment.