Skip to content
/ edk2 Public

Commit

Permalink
DasharoPayloadPkg: optionally enable update capsules
Browse files Browse the repository at this point in the history
New CAPSULE_ENABLE define in DasharoPayloadPkg.dsc adds required
libraries/DXEs/PCDs and enables building of CapsuleApp which is useful
for testing.

BlSupportPei now switches boot mode to BOOT_ON_FLASH_UPDATE if there are
any capsules.  It's not guarded by any PCD under the assumption that
coreboot won't pass capsules if EDK shouldn't be handling them.

EsrtDxe is enabled to manage and cache ESRT entries (caching is
supposedly necessary after a capsule is processed, although don't really
understand why).  ProcessCapsules() internally looks up
EsrtManagementProtocol and calls SyncEsrtFmp() to import data from
available FMP instances.

PlatformBootManagerLib was made to call ProcessCapsules() (twice).

Signed-off-by: Sergii Dmytruk <[email protected]>
  • Loading branch information
SergiiDmytruk committed Jun 30, 2024
1 parent af5902b commit e4bb5bf
Showing 5 changed files with 63 additions and 1 deletion.
5 changes: 5 additions & 0 deletions DasharoPayloadPkg/BlSupportPei/BlSupportPei.c
Original file line number Diff line number Diff line change
@@ -761,6 +761,11 @@ BlPeiEntryPoint (
return Status;
}

if (GetFirstHob (EFI_HOB_TYPE_UEFI_CAPSULE) != NULL) {
Status = PeiServicesSetBootMode (BOOT_ON_FLASH_UPDATE);
ASSERT_EFI_ERROR (Status);
}

//
// Mask off all legacy 8259 interrupt sources
//
25 changes: 24 additions & 1 deletion DasharoPayloadPkg/DasharoPayloadPkg.dsc
Original file line number Diff line number Diff line change
@@ -109,6 +109,7 @@
DEFINE PERFORMANCE_MEASUREMENT_ENABLE = FALSE
DEFINE RAM_DISK_ENABLE = FALSE
DEFINE APU_CONFIG_ENABLE = FALSE
DEFINE CAPSULE_ENABLE = FALSE

#
# Network definition
@@ -212,7 +213,12 @@
UefiUsbLib|MdePkg/Library/UefiUsbLib/UefiUsbLib.inf
UefiScsiLib|MdePkg/Library/UefiScsiLib/UefiScsiLib.inf
OemHookStatusCodeLib|MdeModulePkg/Library/OemHookStatusCodeLibNull/OemHookStatusCodeLibNull.inf
!if $(CAPSULE_ENABLE) == TRUE
CapsuleLib|MdeModulePkg/Library/DxeCapsuleLibFmp/DxeCapsuleLib.inf
DisplayUpdateProgressLib|MdeModulePkg/Library/DisplayUpdateProgressLibText/DisplayUpdateProgressLibText.inf
!else
CapsuleLib|MdeModulePkg/Library/DxeCapsuleLibNull/DxeCapsuleLibNull.inf
!endif
SecurityManagementLib|MdeModulePkg/Library/DxeSecurityManagementLib/DxeSecurityManagementLib.inf
UefiBootManagerLib|MdeModulePkg/Library/UefiBootManagerLib/UefiBootManagerLib.inf
BootLogoLib|MdeModulePkg/Library/BootLogoLib/BootLogoLib.inf
@@ -409,6 +415,9 @@
DebugLib|MdeModulePkg/Library/PeiDxeDebugLibReportStatusCode/PeiDxeDebugLibReportStatusCode.inf
PerformanceLib|MdeModulePkg/Library/DxePerformanceLib/DxePerformanceLib.inf
MbedTlsCrtLib|CryptoPkg/Library/MbedTlsCrtRuntimeLib/MbedTlsCrtRuntimeLib.inf
!if $(CAPSULE_ENABLE) == TRUE
CapsuleLib|MdeModulePkg/Library/DxeCapsuleLibFmp/DxeRuntimeCapsuleLib.inf
!endif

[LibraryClasses.common.UEFI_DRIVER,LibraryClasses.common.UEFI_APPLICATION]
PcdLib|MdePkg/Library/DxePcdLib/DxePcdLib.inf
@@ -432,6 +441,7 @@
gEfiMdeModulePkgTokenSpaceGuid.PcdFirmwarePerformanceDataTableS3Support|FALSE
gEfiMdeModulePkgTokenSpaceGuid.PcdInstallAcpiSdtProtocol|TRUE
gEfiMdeModulePkgTokenSpaceGuid.PcdPs2KbdExtendedVerification|TRUE
gEfiMdeModulePkgTokenSpaceGuid.PcdSupportUpdateCapsuleReset|$(CAPSULE_ENABLE)

[PcdsFixedAtBuild]
# UEFI spec: Minimal value is 0x8000!
@@ -453,6 +463,8 @@

gDasharoPayloadPkgTokenSpaceGuid.PcdSerialOnSuperIo|$(UART_ON_SUPERIO)

gEfiMdeModulePkgTokenSpaceGuid.PcdCapsuleFmpSupport|$(CAPSULE_ENABLE)

!if $(SECURE_BOOT_DEFAULT_ENABLE) == TRUE
gEfiSecurityPkgTokenSpaceGuid.PcdSecureBootDefaultEnable|1
!else
@@ -682,7 +694,14 @@

UefiCpuPkg/CpuDxe/CpuDxe.inf
MdeModulePkg/Universal/DriverHealthManagerDxe/DriverHealthManagerDxe.inf
MdeModulePkg/Universal/BdsDxe/BdsDxe.inf
MdeModulePkg/Universal/BdsDxe/BdsDxe.inf {
<LibraryClasses>
!if $(CAPSULE_ENABLE) == TRUE
FmpAuthenticationLib|SecurityPkg/Library/FmpAuthenticationLibPkcs7/FmpAuthenticationLibPkcs7.inf
!else
FmpAuthenticationLib|MdeModulePkg/Library/FmpAuthenticationLibNull/FmpAuthenticationLibNull.inf
!endif
}
MdeModulePkg/Logo/LogoDxe.inf
MdeModulePkg/Application/UiApp/UiApp.inf {
<LibraryClasses>
@@ -697,6 +716,10 @@
gDasharoSystemFeaturesTokenSpaceGuid.PcdShowPs2Option|$(PS2_KEYBOARD_ENABLE)
}
MdeModulePkg/Application/BootManagerMenuApp/BootManagerMenuApp.inf
!if $(CAPSULE_ENABLE) == TRUE
MdeModulePkg/Application/CapsuleApp/CapsuleApp.inf
MdeModulePkg/Universal/EsrtDxe/EsrtDxe.inf
!endif
!if $(RAM_DISK_ENABLE) == TRUE
MdeModulePkg/Universal/Disk/RamDiskDxe/RamDiskDxe.inf
!endif
4 changes: 4 additions & 0 deletions DasharoPayloadPkg/DasharoPayloadPkg.fdf
Original file line number Diff line number Diff line change
@@ -374,6 +374,10 @@ INF RuleOverride = BINARY USE = X64 ShellBinPkg/UefiShell/UefiShell.inf

INF CrScreenshotDxe/CrScreenshotDxe.inf

!if $(CAPSULE_ENABLE) == TRUE
INF MdeModulePkg/Universal/EsrtDxe/EsrtDxe.inf
!endif

################################################################################
#
# Rules are use with the [FV] section's module INF type to define
Original file line number Diff line number Diff line change
@@ -14,6 +14,8 @@ SPDX-License-Identifier: BSD-2-Clause-Patent
#include <Guid/GlobalVariable.h>
#include <Library/CustomizedDisplayLib.h>
#include <Library/BlParseLib.h>
#include <Library/CapsuleLib.h>
#include <Library/HobLib.h>
#include <Coreboot.h>
#include <DasharoOptions.h>

@@ -672,6 +674,19 @@ PlatformBootManagerBeforeConsole (
UnregisterBootManagerMenuAppBootOption ();
}

//
// Process system firmware update capsules and possibly device update
// capsules that don't contain embedded drivers if those devices are already
// available.
//
if (GetBootModeHob() == BOOT_ON_FLASH_UPDATE) {
// TODO: when enabling capsule support for laptops, add a battery check here
Status = ProcessCapsules ();
if (EFI_ERROR (Status)) {
DEBUG((DEBUG_ERROR, "%a(): ProcessCapsule() failed with: %r\n", __FUNCTION__, Status));
}
}

//
// Install ready to lock.
// This needs to be done before option rom dispatched.
@@ -1567,6 +1582,19 @@ PlatformBootManagerAfterConsole (
EfiBootManagerConnectAll ();
EfiBootManagerRefreshAllBootOption ();

//
// Process device update capsules there weren't processed along with system
// firmware capsules on first call to ProcessCapsules() in
// PlatformBootManagerBeforeConsole().
//
if (GetBootModeHob() == BOOT_ON_FLASH_UPDATE) {
// TODO: when enabling capsule support for laptops, add a battery check here
Status = ProcessCapsules ();
if (EFI_ERROR (Status)) {
DEBUG((DEBUG_ERROR, "%a(): ProcessCapsule() failed with: %r\n", __FUNCTION__, Status));
}
}

//
// Process TPM PPI request
//
Original file line number Diff line number Diff line change
@@ -54,6 +54,8 @@
Tcg2PhysicalPresenceLib
CustomizedDisplayLib
LaptopBatteryLib
CapsuleLib
HobLib

[Guids]
gEfiEndOfDxeEventGroupGuid

0 comments on commit e4bb5bf

Please sign in to comment.