From nobody Wed Dec 25 15:25:54 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=none (zoho.com: 198.145.21.10 is neither permitted nor denied by domain of lists.01.org) smtp.mailfrom=edk2-devel-bounces@lists.01.org Return-Path: Received: from ml01.01.org (ml01.01.org [198.145.21.10]) by mx.zohomail.com with SMTPS id 150944724788757.06102384046085; Tue, 31 Oct 2017 03:54:07 -0700 (PDT) Received: from [127.0.0.1] (localhost [IPv6:::1]) by ml01.01.org (Postfix) with ESMTP id 536A52035D0ED; Tue, 31 Oct 2017 03:49:28 -0700 (PDT) Received: from mail-wm0-x242.google.com (mail-wm0-x242.google.com [IPv6:2a00:1450:400c:c09::242]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by ml01.01.org (Postfix) with ESMTPS id 481FF2035D0EC for ; Tue, 31 Oct 2017 03:49:25 -0700 (PDT) Received: by mail-wm0-x242.google.com with SMTP id r68so22230678wmr.3 for ; Tue, 31 Oct 2017 03:53:16 -0700 (PDT) Received: from localhost.localdomain ([105.129.222.2]) by smtp.gmail.com with ESMTPSA id o14sm460985wra.54.2017.10.31.03.53.12 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 31 Oct 2017 03:53:14 -0700 (PDT) X-Original-To: edk2-devel@lists.01.org Received-SPF: none (zoho.com: 198.145.21.10 is neither permitted nor denied by domain of lists.01.org) client-ip=198.145.21.10; envelope-from=edk2-devel-bounces@lists.01.org; helo=ml01.01.org; Received-SPF: Pass (sender SPF authorized) identity=mailfrom; client-ip=2a00:1450:400c:c09::242; helo=mail-wm0-x242.google.com; envelope-from=ard.biesheuvel@linaro.org; receiver=edk2-devel@lists.01.org DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=W2b0UqcBMZPA2cR1/rHMrhSAaY0bVMqU1/OKdimufDg=; b=KG6vBEp4b3jReQqaszfgOVKH+O3zmOYCN/MmzbIJVzA9WOlYOFnzoThG5AKEfaAmGX C7ihjUcx0/UVPBQUWgMWBAt45ha3MdNAX0xqnGId8rSbOUd+zdeDFOsbeu2oAnwXqVLI UE7gOJrDDRwNVALaopkbAQjIIQi2gIwFWmPZQ= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=W2b0UqcBMZPA2cR1/rHMrhSAaY0bVMqU1/OKdimufDg=; b=b6teDcxR+wnWSiPO2h8MywHqzzGiyb95IqvMflHYn+zUksBMFvyRV2UwULAw+FL7sl DN9hacHz6AwxwUJ+PYIe0xF36k6ycxkSJh2u4LbBUF4jtzHsIStJzcPzbtXMSFKAf5dK F5CcI2F54AGeiAF6N/S8iQ1f5r8EODCoE9ATJkejMky3DkXmF0GKJh6fyWZyruf2DjCq ktZjES1OxP67yJPYvJv1lPFuXYVQuepo9waLZZdjB2Hcu1so6F9gh/OrKBADTjbAmwzn 12dVFngCJMSLDCJQT20UmR/f44sknBnCpIlJHSrzMd6lAHCPNCvRzUdKx10Xqyy4f83Z pTPw== X-Gm-Message-State: AMCzsaWQX9RKKafgsuIW6EQrtETPm9joKc1Q4I51znD6GzTqLW8zHj+U mok2EmsnIWf5PP/T3AqgPAndhu8Mm7M= X-Google-Smtp-Source: ABhQp+RRpoypNusdnE2zRXgD6wYKqIHTyN4kx/vPuqtQNHVdlp2NMR+uht5eJH3ZyqUvkr/mA1OCqg== X-Received: by 10.28.130.140 with SMTP id e134mr1687760wmd.159.1509447195395; Tue, 31 Oct 2017 03:53:15 -0700 (PDT) From: Ard Biesheuvel To: edk2-devel@lists.01.org, leif.lindholm@linaro.org Date: Tue, 31 Oct 2017 10:52:09 +0000 Message-Id: <20171031105218.30208-19-ard.biesheuvel@linaro.org> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20171031105218.30208-1-ard.biesheuvel@linaro.org> References: <20171031105218.30208-1-ard.biesheuvel@linaro.org> Subject: [edk2] [PATCH edk2-platforms v3 18/27] SynQuacer/SynQuacerMemoryInitPeiLib: add capsule support X-BeenThere: edk2-devel@lists.01.org X-Mailman-Version: 2.1.22 Precedence: list List-Id: EDK II Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: daniel.thompson@linaro.org, masami.hiramatsu@linaro.org, Ard Biesheuvel MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Errors-To: edk2-devel-bounces@lists.01.org Sender: "edk2-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZohoMail: RDKM_2 RSF_4 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" 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 Reviewed-by: Leif Lindholm --- Silicon/Socionext/SynQuacer/Library/SynQuacerMemoryInitPeiLib/SynQuacerMem= oryInitPeiLib.c | 52 ++++++++++++++++++++ Silicon/Socionext/SynQuacer/Library/SynQuacerMemoryInitPeiLib/SynQuacerMem= oryInitPeiLib.inf | 4 +- 2 files changed, 55 insertions(+), 1 deletion(-) diff --git a/Silicon/Socionext/SynQuacer/Library/SynQuacerMemoryInitPeiLib/= SynQuacerMemoryInitPeiLib.c b/Silicon/Socionext/SynQuacer/Library/SynQuacer= MemoryInitPeiLib/SynQuacerMemoryInitPeiLib.c index ed616c3bedee..69dd96bb5877 100644 --- a/Silicon/Socionext/SynQuacer/Library/SynQuacerMemoryInitPeiLib/SynQuac= erMemoryInitPeiLib.c +++ b/Silicon/Socionext/SynQuacer/Library/SynQuacerMemoryInitPeiLib/SynQuac= erMemoryInitPeiLib.c @@ -22,10 +22,12 @@ #include #include #include +#include =20 #include #include =20 +#include #include =20 #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; =20 Status =3D DeclareDram (&VirtualMemoryTable); ASSERT_EFI_ERROR (Status); @@ -184,12 +191,57 @@ MemoryPeim ( return Status; } =20 + PeiServices =3D (EFI_PEI_SERVICES **) GetPeiServicesTablePointer (); + ASSERT (PeiServices !=3D NULL); + + Status =3D PeiServicesLocatePpi (&gPeiCapsulePpiGuid, 0, NULL, + (VOID **)&Capsule); + ASSERT_EFI_ERROR (Status); + + // + // Check for persistent capsules + // + HaveCapsule =3D FALSE; + Status =3D Capsule->CheckCapsuleUpdate (PeiServices); + if (!EFI_ERROR (Status)) { + + // + // Coalesce the capsule into unused memory. CreateState() below will c= opy + // it to a properly allocated buffer. + // + CapsuleBuffer =3D (VOID *)PcdGet64 (PcdSystemMemoryBase); + CapsuleBufferLength =3D UefiMemoryBase - PcdGet64 (PcdSystemMemoryBase= ); + + PeiServicesSetBootMode (BOOT_ON_FLASH_UPDATE); + + Status =3D Capsule->Coalesce (PeiServices, &CapsuleBuffer, + &CapsuleBufferLength); + if (!EFI_ERROR (Status)) { + DEBUG ((DEBUG_INFO, "%a: Coalesced capsule @ %p (0x%lx)\n", + __FUNCTION__, CapsuleBuffer, CapsuleBufferLength)); + HaveCapsule =3D TRUE; + } else { + DEBUG ((DEBUG_WARN, "%a: failed to coalesce() capsule (Status =3D=3D= %r)\n", + __FUNCTION__, Status)); + } + } + Status =3D ArmConfigureMmu (VirtualMemoryTable, NULL, NULL); ASSERT_EFI_ERROR (Status); if (EFI_ERROR (Status)) { return Status; } =20 + if (HaveCapsule) { + Status =3D Capsule->CreateState (PeiServices, CapsuleBuffer, + CapsuleBufferLength); + + if (EFI_ERROR (Status)) { + DEBUG ((DEBUG_WARN, "%a: Capsule->CreateState failed (Status =3D=3D = %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/SynQuac= erMemoryInitPeiLib/SynQuacerMemoryInitPeiLib.inf index f433d9a57079..c6071557fd41 100644 --- a/Silicon/Socionext/SynQuacer/Library/SynQuacerMemoryInitPeiLib/SynQuac= erMemoryInitPeiLib.inf +++ b/Silicon/Socionext/SynQuacer/Library/SynQuacerMemoryInitPeiLib/SynQuac= erMemoryInitPeiLib.inf @@ -39,6 +39,7 @@ [LibraryClasses] DebugLib MemoryAllocationLib PeiServicesLib + PeiServicesTablePointerLib =20 [FeaturePcd] gEmbeddedTokenSpaceGuid.PcdPrePiProduceMemoryTypeInformationHob @@ -64,7 +65,8 @@ [Pcd] gArmTokenSpaceGuid.PcdSystemMemoryBase =20 [Ppis] + gPeiCapsulePpiGuid ## CONSUMES gSynQuacerDramInfoPpiGuid ## CONSUMES =20 [Depex] - gSynQuacerDramInfoPpiGuid + gPeiCapsulePpiGuid AND gSynQuacerDramInfoPpiGuid --=20 2.11.0 _______________________________________________ edk2-devel mailing list edk2-devel@lists.01.org https://lists.01.org/mailman/listinfo/edk2-devel