diff options
author | Ard Biesheuvel <ard.biesheuvel@linaro.org> | 2017-11-01 12:48:49 +0000 |
---|---|---|
committer | Ard Biesheuvel <ard.biesheuvel@linaro.org> | 2017-11-17 18:48:12 +0000 |
commit | 4499be3aa0e44a291268f88cd5ea23666a5c5158 (patch) | |
tree | ca12143e217ea7eeb737cd4832b8bc14644b3780 | |
parent | db376cd398e2132ac9cbfac5daf599e181c6d7ac (diff) | |
download | edk2-platforms-4499be3aa0e44a291268f88cd5ea23666a5c5158.tar.xz |
Silicon/SynQuacerMemoryInitPeiLib: ignore capsules when clearing NVRAM
In preparation of adding support for setting a DIP switch to clear the
EFI variable store, update the early capsule handling logic to take the
boot mode into account.
This is necessary for two reasons:
- we override the boot mode when a capsule is detected,
- the capsule detection itself involves reading a EFI variable, which we
shouldn't be doing if the varstore may be in a bad state.
So factor out the initial capsule check (to keep the code understandable)
and only perform it if we are not booting in 'clear NVRAM' mode.
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Ard Biesheuvel <ard.biesheuvel@linaro.org>
Reviewed-by: Leif Lindholm <leif.lindholm@linaro.org>
-rw-r--r-- | Silicon/Socionext/SynQuacer/Library/SynQuacerMemoryInitPeiLib/SynQuacerMemoryInitPeiLib.c | 71 |
1 files changed, 47 insertions, 24 deletions
diff --git a/Silicon/Socionext/SynQuacer/Library/SynQuacerMemoryInitPeiLib/SynQuacerMemoryInitPeiLib.c b/Silicon/Socionext/SynQuacer/Library/SynQuacerMemoryInitPeiLib/SynQuacerMemoryInitPeiLib.c index b44c58d610..0c5df14482 100644 --- a/Silicon/Socionext/SynQuacer/Library/SynQuacerMemoryInitPeiLib/SynQuacerMemoryInitPeiLib.c +++ b/Silicon/Socionext/SynQuacer/Library/SynQuacerMemoryInitPeiLib/SynQuacerMemoryInitPeiLib.c @@ -170,6 +170,44 @@ DeclareDram ( return EFI_SUCCESS;
}
+STATIC
+BOOLEAN
+CheckCapsule (
+ IN EFI_PEI_SERVICES **PeiServices,
+ IN PEI_CAPSULE_PPI *Capsule,
+ IN EFI_PHYSICAL_ADDRESS UefiMemoryBase,
+ OUT VOID **CapsuleBuffer,
+ OUT UINTN *CapsuleBufferLength
+ )
+{
+ EFI_STATUS Status;
+
+ 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));
+ return TRUE;
+ } else {
+ DEBUG ((DEBUG_WARN, "%a: failed to coalesce() capsule (Status == %r)\n",
+ __FUNCTION__, Status));
+ }
+ }
+ return FALSE;
+}
+
EFI_STATUS
EFIAPI
MemoryPeim (
@@ -184,6 +222,7 @@ MemoryPeim ( VOID *CapsuleBuffer;
UINTN CapsuleBufferLength;
BOOLEAN HaveCapsule;
+ EFI_BOOT_MODE BootMode;
Status = DeclareDram (&VirtualMemoryTable);
ASSERT_EFI_ERROR (Status);
@@ -199,31 +238,15 @@ MemoryPeim ( ASSERT_EFI_ERROR (Status);
//
- // Check for persistent capsules
+ // Check for persistent capsules, unless we are booting with default
+ // settings.
//
- 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 = PeiServicesGetBootMode (&BootMode);
+ if (!EFI_ERROR (Status) && BootMode != BOOT_WITH_DEFAULT_SETTINGS) {
+ HaveCapsule = CheckCapsule (PeiServices, Capsule, UefiMemoryBase,
+ &CapsuleBuffer, &CapsuleBufferLength);
+ } else {
+ HaveCapsule = FALSE;
}
Status = ArmConfigureMmu (VirtualMemoryTable, NULL, NULL);
|