Skip to content

Commit

Permalink
Add PcdShellFvGuid to allow platforms to provide FV GUID to search sh…
Browse files Browse the repository at this point in the history
…ell image in (#116)

## Description

Add PcdShellFvGuid to allow platforms to provide FV GUID to search shell
image in

- [x] Impacts functionality?
- [ ] Impacts security?
- [ ] Breaking change?
- [ ] Includes tests?
- [ ] Includes documentation?

## How This Was Tested

When a FV GUID is provided, a default boot option for shell with the FV
device path is created. as long as the device path exists, system is
able to boot to internal UEFI shell.

If the PCD is not updated by platform and is at default value (zero
guid), then all FV's are searched and shell is located to create a boot
option device path.

## Integration Instructions

N/A
  • Loading branch information
srisrid authored and kenlautner committed May 14, 2023
1 parent e707676 commit 50512de
Show file tree
Hide file tree
Showing 3 changed files with 52 additions and 5 deletions.
52 changes: 47 additions & 5 deletions PcBdsPkg/Library/MsBootOptionsLib/MsBootOptionsLib.c
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,33 @@ SPDX-License-Identifier: BSD-2-Clause-Patent
#define MS_PXE_BOOT L"PXE Network"
#define MS_PXE_BOOT_PARM "PXE"

typedef struct {
MEDIA_FW_VOL_DEVICE_PATH FvDevPath;
EFI_DEVICE_PATH_PROTOCOL EndDevPath;
} FV_PIWG_DEVICE_PATH;

FV_PIWG_DEVICE_PATH mFvPIWGDevicePathTemplate = {
{
{
MEDIA_DEVICE_PATH,
MEDIA_PIWG_FW_VOL_DP,
{
(UINT8)(sizeof (MEDIA_FW_VOL_DEVICE_PATH)),
(UINT8)(sizeof (MEDIA_FW_VOL_DEVICE_PATH) >> 8)
}
},
{ 0 }
},
{
END_DEVICE_PATH_TYPE,
END_ENTIRE_DEVICE_PATH_SUBTYPE,
{
END_DEVICE_PATH_LENGTH,
0
}
}
};

/**
* Constructor
*
Expand Down Expand Up @@ -303,13 +330,24 @@ CreateFvBootOption (
(EFI_DEVICE_PATH_PROTOCOL *)&FileNode
);
} else {
DevicePath = CreateShellDevicePath ();
if (DevicePath == NULL) {
return EFI_NOT_FOUND;
if (IsZeroGuid (PcdGetPtr (PcdShellFvGuid))) {
// Search all FV's for Shell.
DevicePath = CreateShellDevicePath ();
if (DevicePath == NULL) {
return EFI_NOT_FOUND;
}
} else {
// Create FV devicepath from template
DevicePath = (EFI_DEVICE_PATH_PROTOCOL *)AllocateCopyPool (sizeof (FV_PIWG_DEVICE_PATH), &mFvPIWGDevicePathTemplate);
// Update FvName to the Shell GUID from PCD if it is not ZeroGuid
CopyGuid (
&((FV_PIWG_DEVICE_PATH *)DevicePath)->FvDevPath.FvName,
PcdGetPtr (PcdShellFvGuid)
);
}

DevicePath = AppendDevicePathNode (
DevicePath,
(EFI_DEVICE_PATH_PROTOCOL *)DevicePath,
(EFI_DEVICE_PATH_PROTOCOL *)&FileNode
);
}
Expand All @@ -324,7 +362,11 @@ CreateFvBootOption (
OptionalData,
OptionalDataSize
);
FreePool (DevicePath);

if (DevicePath != NULL) {
FreePool (DevicePath);
}

return Status;
}

Expand Down
1 change: 1 addition & 0 deletions PcBdsPkg/Library/MsBootOptionsLib/MsBootOptionsLib.inf
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@
[Pcd]
gEfiMdeModulePkgTokenSpaceGuid.PcdBootManagerMenuFile
gPcBdsPkgTokenSpaceGuid.PcdShellFile
gPcBdsPkgTokenSpaceGuid.PcdShellFvGuid

[Depex]
TRUE
4 changes: 4 additions & 0 deletions PcBdsPkg/PcBdsPkg.dec
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,10 @@
# @Prompt FFS Name of Shell Application
gPcBdsPkgTokenSpaceGuid.PcdShellFile|{ 0xB7, 0xD6, 0x7A, 0xC5, 0x15, 0x05, 0xA8, 0x40, 0x9D, 0x21, 0x55, 0x16, 0x52, 0x85, 0x4E, 0x37 }|VOID*|0x40000129

## GUID of the FV to locate the shell in.
# If left at default zero guid value, all FV's will be searched to find Shell image.
gPcBdsPkgTokenSpaceGuid.PcdShellFvGuid|{ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }|VOID*|0x40000130

## This fixed at build flag tells MsBootPolicyLib that it is part of BDS
gPcBdsPkgTokenSpaceGuid.PcdBdsBootPolicy|FALSE|BOOLEAN|0x40000141

Expand Down

0 comments on commit 50512de

Please sign in to comment.