From nobody Wed Dec 25 14:35:26 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 1510323796483183.3105070681155; Fri, 10 Nov 2017 06:23:16 -0800 (PST) Received: from [127.0.0.1] (localhost [IPv6:::1]) by ml01.01.org (Postfix) with ESMTP id 3E1F920355229; Fri, 10 Nov 2017 06:18:34 -0800 (PST) Received: from mail-wm0-x244.google.com (mail-wm0-x244.google.com [IPv6:2a00:1450:400c:c09::244]) (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 6902320355206 for ; Fri, 10 Nov 2017 06:18:31 -0800 (PST) Received: by mail-wm0-x244.google.com with SMTP id p75so3073553wmg.3 for ; Fri, 10 Nov 2017 06:22:34 -0800 (PST) Received: from localhost.localdomain ([160.167.170.128]) by smtp.gmail.com with ESMTPSA id e131sm1036477wmg.15.2017.11.10.06.22.30 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 10 Nov 2017 06:22:32 -0800 (PST) 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::244; helo=mail-wm0-x244.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=Y5UDfaBTsgJADu7C8mSV3x8sjiF3kUBLpPWCg6uNqFI=; b=RBYBWJotL7cL0n6E8dMboQFOnTr7eCFT9n2m+sWV/c2Cszq6w/pTtU1Csta4NuvKys cN6y94ZgNexrDHbb9GupiBj9qs+VURGsYABKCQJ7Mwg8TuX6epUKx203/Tzv9vCcG8D6 SGt2vSR1sxPPefXs6ksCX5HRtISMmgDtwSbNU= 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=Y5UDfaBTsgJADu7C8mSV3x8sjiF3kUBLpPWCg6uNqFI=; b=V4KrkePhqLkmKEOTwCzIggz6HNssibkGc0NwhIdn6Nmn7kEnwSddQnimFa90+Vs6Hp iAnjNNNgaS249u/R2L2w210u6YUuj2kG1HNrJAIPJjywLCfPESngEYye4WKW8EWB/dfN sK866MCVIGdjFcTIrCAYn3p25Aps0O8b4+y1dVA+4d5l4VCS45YffIQryDws4xurde+9 D3Ri5T4PSZcc545ooR27ulOeGI18fajzyGra608dXssVE5AYSLNu177TYFX9/jQHuSwq 2haMwmbpKKUEL5rNy+vxzq+azlMbpYp12TQcxqztA77ReFcy2kptl5OgBd+ae65uaAxo cWRQ== X-Gm-Message-State: AJaThX6rsPK2gTmX5yUdZhBYQvjSVo0/fB+6gQMuqcfalCjP15i1q2EL awN16JEGpuU5fETf7UnaM83+wqJ/LD0= X-Google-Smtp-Source: AGs4zMY8VYYi8GfgZm8PxUxJgfbjjxV2PQpsiUhhNiuHJtVqChl9AjIyQkBxmvYxA1aGabTZyFy/XQ== X-Received: by 10.28.61.213 with SMTP id k204mr355921wma.110.1510323752865; Fri, 10 Nov 2017 06:22:32 -0800 (PST) From: Ard Biesheuvel To: edk2-devel@lists.01.org, leif.lindholm@linaro.org, daniel.thompson@linaro.org Date: Fri, 10 Nov 2017 14:21:10 +0000 Message-Id: <20171110142127.12018-18-ard.biesheuvel@linaro.org> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20171110142127.12018-1-ard.biesheuvel@linaro.org> References: <20171110142127.12018-1-ard.biesheuvel@linaro.org> Subject: [edk2] [PATCH edk2-platforms v4 17/34] 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: masahisa.kojima@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 b682d631d0c2..b44c58d61062 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 db3e3b3792e4..6c3420a525d6 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 @@ -62,7 +63,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