Skip to content

Commit

Permalink
MdeModulePkg: Modify Capsule to support non-RAM persistence across reset
Browse files Browse the repository at this point in the history
Modifications to capsule infrastructure to allow persistence in media other than "warm reset doesn't destroy ram".
Related work items: #17706456
  • Loading branch information
joschock authored and VivianNK committed Jul 16, 2024
1 parent 86b5ee6 commit 8ceb14a
Show file tree
Hide file tree
Showing 4 changed files with 73 additions and 0 deletions.
21 changes: 21 additions & 0 deletions MdeModulePkg/Include/Library/CapsuleLib.h
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,27 @@ ProcessCapsuleImage (
IN EFI_CAPSULE_HEADER *CapsuleHeader
);

// MU_CHANGE - Add a routine to allow firmware-specific handling for capsules
// that need to persist across reset.

/**
The firmware-specific implementation that stages the capsule image
for processing after reset if it recognized the format of this capsule
image.
Caution: This function may receive untrusted input.
@param[in] CapsuleHeader Pointer to the UEFI capsule image to be processed.
@retval EFI_SUCESS Capsule Image processed successfully.
@retval EFI_UNSUPPORTED Capsule image is not supported by the firmware.
**/
EFI_STATUS
EFIAPI
StageCapsuleImage (
IN EFI_CAPSULE_HEADER *CapsuleHeader
);

/**
This routine is called to process capsules.
Expand Down
20 changes: 20 additions & 0 deletions MdeModulePkg/Library/DxeCapsuleLibFmp/DxeCapsuleLib.c
Original file line number Diff line number Diff line change
Expand Up @@ -1615,6 +1615,26 @@ ProcessCapsuleImage (
return ProcessThisCapsuleImage (CapsuleHeader, NULL, NULL);
}

/** MU_CHANGE - START
The firmware implements to process the capsule image.
@param CapsuleHeader Points to a capsule header.
@retval EFI_SUCESS Process Capsule Image successfully.
@retval EFI_UNSUPPORTED Capsule image is not supported by the firmware.
@retval EFI_DEVICE_ERROR Something went wrong staging the capsule
**/
EFI_STATUS
EFIAPI
StageCapsuleImage (
IN EFI_CAPSULE_HEADER *CapsuleHeader
)
{
return EFI_SUCCESS;
}

// MU_CHANGE - END

/**
Callback function executed when the EndOfDxe event group is signaled.
Expand Down
23 changes: 23 additions & 0 deletions MdeModulePkg/Library/DxeCapsuleLibNull/DxeCapsuleLibNull.c
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
Null Dxe Capsule Library instance does nothing and returns unsupport status.
Copyright (c) 2007 - 2019, Intel Corporation. All rights reserved.<BR>
Copyright (c) Microsoft Corporation.
SPDX-License-Identifier: BSD-2-Clause-Patent
**/
Expand Down Expand Up @@ -167,3 +168,25 @@ CoDRemoveTempFile (
{
return EFI_UNSUPPORTED;
}

// MU_CHANGE [BEGIN] - Provide simpler interface without assumptions of staging medium.

/**
The firmware implements to process the capsule image.
@param CapsuleHeader Points to a capsule header.
@retval EFI_SUCESS Process Capsule Image successfully.
@retval EFI_UNSUPPORTED Capsule image is not supported by the firmware.
@retval EFI_DEVICE_ERROR Something went wrong staging the capsule
**/
EFI_STATUS
EFIAPI
StageCapsuleImage (
IN EFI_CAPSULE_HEADER *CapsuleHeader
)
{
return EFI_UNSUPPORTED;
}

// MU_CHANGE [END] - Provide simpler interface without assumptions of staging medium.
9 changes: 9 additions & 0 deletions MdeModulePkg/Universal/CapsuleRuntimeDxe/CapsuleService.c
Original file line number Diff line number Diff line change
Expand Up @@ -178,6 +178,15 @@ UpdateCapsule (
if ((CapsuleHeader->Flags & CAPSULE_FLAGS_INITIATE_RESET) != 0) {
InitiateReset = TRUE;
}

// MU_CHANGE - Stage Runtime Capsules (in case special handling is needed)
// To persist across reset.
Status = StageCapsuleImage (CapsuleHeader);
if (EFI_ERROR (Status)) {
return Status;
}

// MU_CHANGE - End
}
}

Expand Down

0 comments on commit 8ceb14a

Please sign in to comment.