From: Leif Lindholm <leif.lindholm@linaro.org>
To: Ard Biesheuvel <ard.biesheuvel@linaro.org>
Cc: edk2-devel@lists.01.org, daniel.thompson@linaro.org,
masami.hiramatsu@linaro.org
Subject: Re: [PATCH edk2-platforms v2 16/23] SynQuacer/SynQuacerMemoryInitPeiLib: add capsule support
Date: Thu, 26 Oct 2017 22:27:52 +0100 [thread overview]
Message-ID: <20171026212752.2ujj4l4w6oft7gx5@bivouac.eciton.net> (raw)
In-Reply-To: <20171025175947.22798-17-ard.biesheuvel@linaro.org>
On Wed, Oct 25, 2017 at 06:59:40PM +0100, Ard Biesheuvel wrote:
> 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>
> ---
> Silicon/Socionext/SynQuacer/Library/SynQuacerMemoryInitPeiLib/SynQuacerMemoryInitPeiLib.c | 59 +++++++++++++++++++-
> Silicon/Socionext/SynQuacer/Library/SynQuacerMemoryInitPeiLib/SynQuacerMemoryInitPeiLib.inf | 12 ++++
> 2 files changed, 70 insertions(+), 1 deletion(-)
>
> diff --git a/Silicon/Socionext/SynQuacer/Library/SynQuacerMemoryInitPeiLib/SynQuacerMemoryInitPeiLib.c b/Silicon/Socionext/SynQuacer/Library/SynQuacerMemoryInitPeiLib/SynQuacerMemoryInitPeiLib.c
> index 9359f7c320b7..a249210a3192 100644
> --- a/Silicon/Socionext/SynQuacer/Library/SynQuacerMemoryInitPeiLib/SynQuacerMemoryInitPeiLib.c
> +++ b/Silicon/Socionext/SynQuacer/Library/SynQuacerMemoryInitPeiLib/SynQuacerMemoryInitPeiLib.c
> @@ -17,12 +17,17 @@
>
> #include <Library/ArmLib.h>
> #include <Library/ArmMmuLib.h>
> +#include <Library/CacheMaintenanceLib.h>
> #include <Library/DebugLib.h>
> #include <Library/HobLib.h>
> +#include <Library/PeiServicesLib.h>
> +#include <Library/PeiServicesTablePointerLib.h>
>
> #include <Platform/MemoryMap.h>
> #include <Platform/Pcie.h>
>
> +#include <Ppi/Capsule.h>
> +
> #define ARM_MEMORY_REGION(Base, Size) \
> { (Base), (Base), (Size), ARM_MEMORY_REGION_ATTRIBUTE_WRITE_BACK }
>
> @@ -39,7 +44,8 @@ BuildMemoryTypeInformationHob (
>
> STATIC ARM_MEMORY_REGION_DESCRIPTOR mVirtualMemoryTable[] = {
> // Memory mapped SPI NOR flash
> - ARM_UNCACHED_REGION (SYNQUACER_SPI_NOR_BASE, SYNQUACER_SPI_NOR_BASE),
> + ARM_UNCACHED_REGION (FixedPcdGet64 (PcdFdBaseAddress),
> + FixedPcdGet32 (PcdFdSize)),
>
> // DDR - 2 GB
> ARM_MEMORY_REGION (SYNQUACER_SYSTEM_MEMORY_1_BASE,
> @@ -113,6 +119,12 @@ MemoryPeim (
> {
> EFI_RESOURCE_ATTRIBUTE_TYPE ResourceAttributes;
> RETURN_STATUS Status;
> + EFI_PEI_SERVICES **PeiServices;
> + PEI_CAPSULE_PPI *Capsule;
> + VOID *CapsuleBuffer;
> + UINTN CapsuleBufferLength;
> + EFI_STATUS EfiStatus;
> + BOOLEAN HaveCapsule;
>
> ResourceAttributes =
> EFI_RESOURCE_ATTRIBUTE_PRESENT |
> @@ -140,12 +152,57 @@ MemoryPeim (
> // SYNQUACER_SYSTEM_MEMORY_3_BASE,
> // SYNQUACER_SYSTEM_MEMORY_3_SZ);
>
> + PeiServices = (EFI_PEI_SERVICES **) GetPeiServicesTablePointer ();
> + ASSERT (PeiServices != NULL);
> +
> + EfiStatus = PeiServicesLocatePpi (&gPeiCapsulePpiGuid, 0, NULL,
> + (VOID **)&Capsule);
> + ASSERT_EFI_ERROR (EfiStatus);
> +
> + //
> + // Check for persistent capsules
> + //
> + HaveCapsule = FALSE;
> + EfiStatus = Capsule->CheckCapsuleUpdate (PeiServices);
> + if (!EFI_ERROR (EfiStatus)) {
> +
> + //
> + // Coalesce the capsule into unused memory. CreateState() below will copy
> + // it to a properly allocated buffer.
> + //
> + CapsuleBuffer = (VOID *)FixedPcdGet64 (PcdSystemMemoryBase);
> + CapsuleBufferLength = UefiMemoryBase - FixedPcdGet64 (PcdSystemMemoryBase);
> +
> + PeiServicesSetBootMode (BOOT_ON_FLASH_UPDATE);
> +
> + EfiStatus = Capsule->Coalesce (PeiServices, &CapsuleBuffer,
> + &CapsuleBufferLength);
> + if (!EFI_ERROR (EfiStatus)) {
> + 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__, EfiStatus));
> + }
> + }
> +
> Status = ArmConfigureMmu (mVirtualMemoryTable, NULL, NULL);
> ASSERT_EFI_ERROR (Status);
> if (EFI_ERROR (Status)) {
> return Status;
> }
>
> + if (HaveCapsule) {
> + EfiStatus = Capsule->CreateState (PeiServices, CapsuleBuffer,
> + CapsuleBufferLength);
> +
> + if (EFI_ERROR (EfiStatus)) {
> + DEBUG ((DEBUG_WARN, "%a: Capsule->CreateState failed (Status == %r)\n",
> + __FUNCTION__, EfiStatus));
> + }
> + }
> +
> 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 1ddaee8a9d45..d294c943d7f9 100644
> --- a/Silicon/Socionext/SynQuacer/Library/SynQuacerMemoryInitPeiLib/SynQuacerMemoryInitPeiLib.inf
> +++ b/Silicon/Socionext/SynQuacer/Library/SynQuacerMemoryInitPeiLib/SynQuacerMemoryInitPeiLib.inf
> @@ -36,14 +36,20 @@ [Packages]
> [LibraryClasses]
> ArmLib
> ArmMmuLib
> + CacheMaintenanceLib
> DebugLib
> + PeiServicesLib
> + PeiServicesTablePointerLib
>
> [FeaturePcd]
> gEmbeddedTokenSpaceGuid.PcdPrePiProduceMemoryTypeInformationHob
>
> [FixedPcd]
> + gArmTokenSpaceGuid.PcdFdBaseAddress
> + gArmTokenSpaceGuid.PcdFdSize
> gArmTokenSpaceGuid.PcdGicDistributorBase
> gArmTokenSpaceGuid.PcdGicRedistributorsBase
> + gArmTokenSpaceGuid.PcdSystemMemoryBase
> gEfiMdeModulePkgTokenSpaceGuid.PcdFlashNvStorageVariableBase
> gEfiMdeModulePkgTokenSpaceGuid.PcdFlashNvStorageVariableSize
> gEfiMdeModulePkgTokenSpaceGuid.PcdFlashNvStorageFtwWorkingBase
> @@ -53,3 +59,9 @@ [FixedPcd]
> gNetsecDxeTokenSpaceGuid.PcdEepRomBase
> gFip006DxeTokenSpaceGuid.PcdFip006DxeRegBaseAddress
> gFip006DxeTokenSpaceGuid.PcdFip006DxeMemBaseAddress
> +
> +[Ppis]
> + gPeiCapsulePpiGuid
> +
> +[Depex]
> + gPeiCapsulePpiGuid
> --
> 2.11.0
>
next prev parent reply other threads:[~2017-10-26 21:24 UTC|newest]
Thread overview: 54+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-10-25 17:59 [PATCH edk2-platforms v2 00/23] add support for Socionext Synquacer Ard Biesheuvel
2017-10-25 17:59 ` [PATCH edk2-platforms v2 01/23] Silicon/SynQuacer: add package with platform headers Ard Biesheuvel
2017-10-26 14:39 ` Leif Lindholm
2017-10-25 17:59 ` [PATCH edk2-platforms v2 02/23] Silicon/Socionext: add driver for NETSEC network controller Ard Biesheuvel
2017-10-26 14:49 ` Leif Lindholm
2017-10-25 17:59 ` [PATCH edk2-platforms v2 03/23] Silicon/SynQuacer: add MemoryInitPeiLib implementation Ard Biesheuvel
2017-10-26 14:56 ` Leif Lindholm
2017-10-26 14:57 ` Ard Biesheuvel
2017-10-26 15:05 ` Leif Lindholm
2017-10-25 17:59 ` [PATCH edk2-platforms v2 04/23] Platform: add support for Socionext SynQuacer eval board Ard Biesheuvel
2017-10-26 15:02 ` Leif Lindholm
2017-10-26 15:14 ` Ard Biesheuvel
2017-10-25 17:59 ` [PATCH edk2-platforms v2 05/23] Silicon/SynQuacer: implement PciSegmentLib to support dual RCs Ard Biesheuvel
2017-10-26 15:06 ` Leif Lindholm
2017-10-25 17:59 ` [PATCH edk2-platforms v2 06/23] Silicon/SynQuacer: implement PciHostBridgeLib support Ard Biesheuvel
2017-10-26 15:10 ` Leif Lindholm
2017-10-26 15:12 ` Ard Biesheuvel
2017-10-25 17:59 ` [PATCH edk2-platforms v2 07/23] Silicon/SynQuacer: implement EFI_CPU_IO2_PROTOCOL Ard Biesheuvel
2017-10-26 15:13 ` Leif Lindholm
2017-10-25 17:59 ` [PATCH edk2-platforms v2 08/23] Platform/SynQuacerEvalBoard: add PCI support Ard Biesheuvel
2017-10-26 15:38 ` Leif Lindholm
2017-10-26 15:41 ` Ard Biesheuvel
2017-10-26 21:49 ` Leif Lindholm
2017-10-25 17:59 ` [PATCH edk2-platforms v2 09/23] Platform/SynQuacerEvalBoard: add NETSEC driver Ard Biesheuvel
2017-10-26 15:39 ` Leif Lindholm
2017-10-25 17:59 ` [PATCH edk2-platforms v2 10/23] Silicon/SynQuacer: add ACPI support Ard Biesheuvel
2017-10-26 17:13 ` Leif Lindholm
2017-10-25 17:59 ` [PATCH edk2-platforms v2 11/23] Silicon/SynQuacer: add device tree support for eval board Ard Biesheuvel
2017-10-26 17:15 ` Leif Lindholm
2017-10-25 17:59 ` [PATCH edk2-platforms v2 12/23] Silicon/SynQuacer: add NorFlashPlatformLib implementation Ard Biesheuvel
2017-10-25 17:59 ` [PATCH edk2-platforms v2 13/23] Silicon/Socionext: add driver for SPI NOR flash Ard Biesheuvel
2017-10-26 21:19 ` Leif Lindholm
2017-10-28 14:16 ` Ard Biesheuvel
2017-10-28 21:31 ` Leif Lindholm
2017-10-25 17:59 ` [PATCH edk2-platforms v2 14/23] Platform/SynQuacer: incorporate NOR flash and variable drivers Ard Biesheuvel
2017-10-25 17:59 ` [PATCH edk2-platforms v2 15/23] Silicon/SynQuacer: implement PlatformFlashAccessLib Ard Biesheuvel
2017-10-26 21:22 ` Leif Lindholm
2017-10-25 17:59 ` [PATCH edk2-platforms v2 16/23] SynQuacer/SynQuacerMemoryInitPeiLib: add capsule support Ard Biesheuvel
2017-10-26 21:27 ` Leif Lindholm [this message]
2017-10-25 17:59 ` [PATCH edk2-platforms v2 17/23] Socionext/SynQuacerEvalBoard: wire up basic " Ard Biesheuvel
2017-10-26 21:28 ` Leif Lindholm
2017-10-25 17:59 ` [PATCH edk2-platforms v2 18/23] Socionext/SynQuacerEvalBoard: switch to execute in place Ard Biesheuvel
2017-10-26 21:30 ` Leif Lindholm
2017-10-25 17:59 ` [PATCH edk2-platforms v2 19/23] Platform/SynQuacerEvalBoard: add signed capsule update support Ard Biesheuvel
2017-10-26 21:33 ` Leif Lindholm
2017-10-28 13:48 ` Ard Biesheuvel
2017-10-25 17:59 ` [PATCH edk2-platforms v2 20/23] Silicon/SynQuacer/AcpiTables: hide PCI domain #0 Ard Biesheuvel
2017-10-26 21:34 ` Leif Lindholm
2017-10-25 17:59 ` [PATCH edk2-platforms v2 21/23] Silicon/SynQuacerPciHostBridgeLib: add workaround to support 32-bit only cards Ard Biesheuvel
2017-10-26 21:35 ` Leif Lindholm
2017-10-25 17:59 ` [PATCH edk2-platforms v2 22/23] Platform/Socionext: add support for Socionext Developer Box rev 0.1 Ard Biesheuvel
2017-10-26 21:46 ` Leif Lindholm
2017-10-25 17:59 ` [PATCH edk2-platforms v2 23/23] Platform/DeveloperBox: add ConsolePrefDxe driver Ard Biesheuvel
2017-10-26 21:46 ` Leif Lindholm
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-list from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20171026212752.2ujj4l4w6oft7gx5@bivouac.eciton.net \
--to=devel@edk2.groups.io \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox