From patchwork Tue Oct 31 10:52:09 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ard Biesheuvel X-Patchwork-Id: 117552 Delivered-To: patch@linaro.org Received: by 10.80.245.45 with SMTP id t42csp3794591edm; Tue, 31 Oct 2017 03:54:06 -0700 (PDT) X-Google-Smtp-Source: ABhQp+SIq/GVlEwZux86dI6MRl1l92WJ1JqJSbYZ+XHixuE3nX/zRBZ9N5K35Y7QXIIJbQKqfJkE X-Received: by 10.98.247.4 with SMTP id h4mr1660437pfi.16.1509447246579; Tue, 31 Oct 2017 03:54:06 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1509447246; cv=none; d=google.com; s=arc-20160816; b=EYb0bNlOoeu1UzvMCp0ibWgynDnoY9B48BepBQbvGNnXpzw3FE/HJcBBhfKK96FNtb JsjRMm3hq3eItQd3Szza9Jv9gkaA1zeYkWnhVmCbuSK0Kpelov2bavf1WV7qDYFfzHR/ DKAqSgnXXxkBQLBpEblxYSJ1aOsmoKe8idToeIf2bsKjIPsQYO2QoUuHVhdsM6iU6l48 ZeLsKybmRR0hxSIpJMxafELLlaTyWtLAOYsXHdNL5dleIRI9GiS7DfPdwTlkmxZbXuko IiQN+GQ5ZUpCMq2N6QAJLZLfkhC+zUy5ts0q1PNHznIaOJaSc2vUT2SoBjCaNA/y3Zvm 5n7A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:content-transfer-encoding:mime-version:cc :list-subscribe:list-help:list-post:list-archive:list-unsubscribe :list-id:precedence:subject:references:in-reply-to:message-id:date :to:from:dkim-signature:delivered-to:arc-authentication-results; bh=0fFuaNEAmCUC4i/p1S1NoqbQJHRKUZvKO9DxSaTMgvQ=; b=vXG5ukTZxP+GbUgNpyAgy8Hj229oSWinNv0Xz1CxgjCcQGLQolHpVC0mcxnu9nZZe2 6GT607XpCM266j7DL9BWKV3ZSt4iXbgwuw+vjFVHoCwTf9Z7GCcj9H0mS2uiPTo0nAwk Wp03+OsZdsByyCJNZt5CLEO0O48j0CWvn3J//Cw+wdmXr887dXb6+czHfiYTjB8fx1+M uWR9djMKPz6z5lRWyGbHNg1TExJTd/eYN0h2rWaEU2sR+36K6w/6uZsEnVbBXiuQjnWJ loO9KD2YWm5I/rZaaudIhXWIIKCge0Huf/r3349vM32qn1TZ5bp55irvd710B+zCwXyd FCTw== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org header.s=google header.b=KG6vBEp4; spf=pass (google.com: best guess record for domain of edk2-devel-bounces@lists.01.org designates 198.145.21.10 as permitted sender) smtp.mailfrom=edk2-devel-bounces@lists.01.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from ml01.01.org (ml01.01.org. [198.145.21.10]) by mx.google.com with ESMTPS id m10si1327429pgs.21.2017.10.31.03.54.06 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 31 Oct 2017 03:54:06 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of edk2-devel-bounces@lists.01.org designates 198.145.21.10 as permitted sender) client-ip=198.145.21.10; Authentication-Results: mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org header.s=google header.b=KG6vBEp4; spf=pass (google.com: best guess record for domain of edk2-devel-bounces@lists.01.org designates 198.145.21.10 as permitted sender) smtp.mailfrom=edk2-devel-bounces@lists.01.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org 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) X-Original-To: edk2-devel@lists.01.org Delivered-To: edk2-devel@lists.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 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) 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-Received: by 10.28.130.140 with SMTP id e134mr1687760wmd.159.1509447195395; Tue, 31 Oct 2017 03:53:15 -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) 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 Errors-To: edk2-devel-bounces@lists.01.org Sender: "edk2-devel" 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/SynQuacerMemoryInitPeiLib.c | 52 ++++++++++++++++++++ Silicon/Socionext/SynQuacer/Library/SynQuacerMemoryInitPeiLib/SynQuacerMemoryInitPeiLib.inf | 4 +- 2 files changed, 55 insertions(+), 1 deletion(-) -- 2.11.0 _______________________________________________ edk2-devel mailing list edk2-devel@lists.01.org https://lists.01.org/mailman/listinfo/edk2-devel diff --git a/Silicon/Socionext/SynQuacer/Library/SynQuacerMemoryInitPeiLib/SynQuacerMemoryInitPeiLib.c b/Silicon/Socionext/SynQuacer/Library/SynQuacerMemoryInitPeiLib/SynQuacerMemoryInitPeiLib.c index ed616c3bedee..69dd96bb5877 100644 --- a/Silicon/Socionext/SynQuacer/Library/SynQuacerMemoryInitPeiLib/SynQuacerMemoryInitPeiLib.c +++ b/Silicon/Socionext/SynQuacer/Library/SynQuacerMemoryInitPeiLib/SynQuacerMemoryInitPeiLib.c @@ -22,10 +22,12 @@ #include #include #include +#include #include #include +#include #include #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 f433d9a57079..c6071557fd41 100644 --- a/Silicon/Socionext/SynQuacer/Library/SynQuacerMemoryInitPeiLib/SynQuacerMemoryInitPeiLib.inf +++ b/Silicon/Socionext/SynQuacer/Library/SynQuacerMemoryInitPeiLib/SynQuacerMemoryInitPeiLib.inf @@ -39,6 +39,7 @@ [LibraryClasses] DebugLib MemoryAllocationLib PeiServicesLib + PeiServicesTablePointerLib [FeaturePcd] gEmbeddedTokenSpaceGuid.PcdPrePiProduceMemoryTypeInformationHob @@ -64,7 +65,8 @@ [Pcd] gArmTokenSpaceGuid.PcdSystemMemoryBase [Ppis] + gPeiCapsulePpiGuid ## CONSUMES gSynQuacerDramInfoPpiGuid ## CONSUMES [Depex] - gSynQuacerDramInfoPpiGuid + gPeiCapsulePpiGuid AND gSynQuacerDramInfoPpiGuid