diff options
author | Ard Biesheuvel <ard.biesheuvel@linaro.org> | 2017-09-11 17:39:54 +0100 |
---|---|---|
committer | Ard Biesheuvel <ard.biesheuvel@linaro.org> | 2017-11-17 17:46:06 +0000 |
commit | c79ee74e8103d64a7f57d8b7038cfa6028c64c16 (patch) | |
tree | a586af8917383f96b1469e299b54a165a1ddd1a1 /Silicon/Socionext | |
parent | 6313ef2dd7c11bc0025c81190a867926e5f1d83d (diff) | |
download | edk2-platforms-c79ee74e8103d64a7f57d8b7038cfa6028c64c16.tar.xz |
SynQuacer/SynQuacerMemoryInitPeiLib: add capsule support
Add support for dealing with capsules left in memory by the OS before
reboot. This needs to be done early, before the memory is reused, which
is why the initial handling must reside here.
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Ard Biesheuvel <ard.biesheuvel@linaro.org>
Reviewed-by: Leif Lindholm <leif.lindholm@linaro.org>
Diffstat (limited to 'Silicon/Socionext')
2 files changed, 55 insertions, 1 deletions
diff --git a/Silicon/Socionext/SynQuacer/Library/SynQuacerMemoryInitPeiLib/SynQuacerMemoryInitPeiLib.c b/Silicon/Socionext/SynQuacer/Library/SynQuacerMemoryInitPeiLib/SynQuacerMemoryInitPeiLib.c index b682d631d0..b44c58d610 100644 --- a/Silicon/Socionext/SynQuacer/Library/SynQuacerMemoryInitPeiLib/SynQuacerMemoryInitPeiLib.c +++ b/Silicon/Socionext/SynQuacer/Library/SynQuacerMemoryInitPeiLib/SynQuacerMemoryInitPeiLib.c @@ -22,10 +22,12 @@ #include <Library/HobLib.h>
#include <Library/MemoryAllocationLib.h>
#include <Library/PeiServicesLib.h>
+#include <Library/PeiServicesTablePointerLib.h>
#include <Platform/MemoryMap.h>
#include <Platform/Pcie.h>
+#include <Ppi/Capsule.h>
#include <Ppi/DramInfo.h>
#define ARM_MEMORY_REGION(Base, Size) \
@@ -177,6 +179,11 @@ MemoryPeim ( {
EFI_STATUS Status;
ARM_MEMORY_REGION_DESCRIPTOR *VirtualMemoryTable;
+ EFI_PEI_SERVICES **PeiServices;
+ PEI_CAPSULE_PPI *Capsule;
+ VOID *CapsuleBuffer;
+ UINTN CapsuleBufferLength;
+ BOOLEAN HaveCapsule;
Status = DeclareDram (&VirtualMemoryTable);
ASSERT_EFI_ERROR (Status);
@@ -184,12 +191,57 @@ MemoryPeim ( return Status;
}
+ PeiServices = (EFI_PEI_SERVICES **) GetPeiServicesTablePointer ();
+ ASSERT (PeiServices != NULL);
+
+ Status = PeiServicesLocatePpi (&gPeiCapsulePpiGuid, 0, NULL,
+ (VOID **)&Capsule);
+ ASSERT_EFI_ERROR (Status);
+
+ //
+ // Check for persistent capsules
+ //
+ HaveCapsule = FALSE;
+ Status = Capsule->CheckCapsuleUpdate (PeiServices);
+ if (!EFI_ERROR (Status)) {
+
+ //
+ // Coalesce the capsule into unused memory. CreateState() below will copy
+ // it to a properly allocated buffer.
+ //
+ CapsuleBuffer = (VOID *)PcdGet64 (PcdSystemMemoryBase);
+ CapsuleBufferLength = UefiMemoryBase - PcdGet64 (PcdSystemMemoryBase);
+
+ PeiServicesSetBootMode (BOOT_ON_FLASH_UPDATE);
+
+ Status = Capsule->Coalesce (PeiServices, &CapsuleBuffer,
+ &CapsuleBufferLength);
+ if (!EFI_ERROR (Status)) {
+ DEBUG ((DEBUG_INFO, "%a: Coalesced capsule @ %p (0x%lx)\n",
+ __FUNCTION__, CapsuleBuffer, CapsuleBufferLength));
+ HaveCapsule = TRUE;
+ } else {
+ DEBUG ((DEBUG_WARN, "%a: failed to coalesce() capsule (Status == %r)\n",
+ __FUNCTION__, Status));
+ }
+ }
+
Status = ArmConfigureMmu (VirtualMemoryTable, NULL, NULL);
ASSERT_EFI_ERROR (Status);
if (EFI_ERROR (Status)) {
return Status;
}
+ if (HaveCapsule) {
+ Status = Capsule->CreateState (PeiServices, CapsuleBuffer,
+ CapsuleBufferLength);
+
+ if (EFI_ERROR (Status)) {
+ DEBUG ((DEBUG_WARN, "%a: Capsule->CreateState failed (Status == %r)\n",
+ __FUNCTION__, Status));
+ }
+ }
+
if (FeaturePcdGet (PcdPrePiProduceMemoryTypeInformationHob)) {
// Optional feature that helps prevent EFI memory map fragmentation.
BuildMemoryTypeInformationHob ();
diff --git a/Silicon/Socionext/SynQuacer/Library/SynQuacerMemoryInitPeiLib/SynQuacerMemoryInitPeiLib.inf b/Silicon/Socionext/SynQuacer/Library/SynQuacerMemoryInitPeiLib/SynQuacerMemoryInitPeiLib.inf index db3e3b3792..6c3420a525 100644 --- a/Silicon/Socionext/SynQuacer/Library/SynQuacerMemoryInitPeiLib/SynQuacerMemoryInitPeiLib.inf +++ b/Silicon/Socionext/SynQuacer/Library/SynQuacerMemoryInitPeiLib/SynQuacerMemoryInitPeiLib.inf @@ -39,6 +39,7 @@ DebugLib
MemoryAllocationLib
PeiServicesLib
+ PeiServicesTablePointerLib
[FeaturePcd]
gEmbeddedTokenSpaceGuid.PcdPrePiProduceMemoryTypeInformationHob
@@ -62,7 +63,8 @@ gArmTokenSpaceGuid.PcdSystemMemoryBase
[Ppis]
+ gPeiCapsulePpiGuid ## CONSUMES
gSynQuacerDramInfoPpiGuid ## CONSUMES
[Depex]
- gSynQuacerDramInfoPpiGuid
+ gPeiCapsulePpiGuid AND gSynQuacerDramInfoPpiGuid
|