From patchwork Wed Jun 13 08:09:00 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ard Biesheuvel X-Patchwork-Id: 138426 Delivered-To: patch@linaro.org Received: by 2002:a2e:970d:0:0:0:0:0 with SMTP id r13-v6csp401637lji; Wed, 13 Jun 2018 01:09:14 -0700 (PDT) X-Google-Smtp-Source: ADUXVKIIAyhfnT1vjOh/Fky2j0kQwcgiK0aHPE1m0ZoiBgwVScvduHYTWbbN8X3G8pQ8qS+QFLSb X-Received: by 2002:a62:9385:: with SMTP id r5-v6mr3850891pfk.59.1528877354246; Wed, 13 Jun 2018 01:09:14 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1528877354; cv=none; d=google.com; s=arc-20160816; b=f08PNRxMNbJaLQ+F01j76UYD1KIOW3juB4USqYqrjGc7qBR+9sryi8aGn+sKnwV1L2 N5cow5ctUxhbzwjPNyuxdLrkoej1hUJ0w1WdlaaYIqmPlrJwq2IRhEIiyeUJdDkx9ecY Vgs2WgcCRhm0IjrHL3oNaFZW/Ru5Dy0aZ0vQ+EmgNu1kKvmLP6MgMa+f6rgBlzx4YtJJ Uc7p7MVmnwNjl0PJoTrXZG+umcV3ugOWYpP6+PR1WQNbuJC3p9r1ja851jaRbMZkqYju ze2AvzzOe9twjdeaNtDooBVo/pBSo6j/xd9rMt2nJfuzfnsgtDwz9FrXL7/yEZlZZJnC eFSA== 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=f5Q8px9BfMeFPurGCwdCKI2lRplK0Anzvx42Z/p/UR8=; b=b8MRfckoNw+JnK6BcVFDeI9qUVwU0vKdveYQBlwBcrOw/cnfUrCs+LFygCsgDEZUxB sqYylojyw4LoNsjHFrjTmYuOELKlm7DFXZWLFy8kIYgXhRvr7c25u9Z8uYn//sLIPAm9 CIexXwjt5NTu8nUK0TkzchyGU9avf4V3hArYbVpIMM/uwMjvJWeoRuDWeosRtzp9P9yu cGZI4C1MyBWGWvRjPHBvsNOUpuCuogJsdD994yfw0ccSSIhkN72C49Cl6eu4ersl6AWk xL48UqXj8EZyT1jSM6MSs6smLNkfRsjfSLQ1zdu/CsXBNRHt+VdXV9SDXQ28fi4R5+wW S0Sw== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org header.s=google header.b="R1/4kLtC"; spf=pass (google.com: best guess record for domain of edk2-devel-bounces@lists.01.org designates 2001:19d0:306:5::1 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. [2001:19d0:306:5::1]) by mx.google.com with ESMTPS id e9-v6si2556315pli.337.2018.06.13.01.09.13 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 13 Jun 2018 01:09:14 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of edk2-devel-bounces@lists.01.org designates 2001:19d0:306:5::1 as permitted sender) client-ip=2001:19d0:306:5::1; Authentication-Results: mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org header.s=google header.b="R1/4kLtC"; spf=pass (google.com: best guess record for domain of edk2-devel-bounces@lists.01.org designates 2001:19d0:306:5::1 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 11B9E211E00E2; Wed, 13 Jun 2018 01:09:12 -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::22a; helo=mail-wm0-x22a.google.com; envelope-from=ard.biesheuvel@linaro.org; receiver=edk2-devel@lists.01.org Received: from mail-wm0-x22a.google.com (mail-wm0-x22a.google.com [IPv6:2a00:1450:400c:c09::22a]) (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 1D48A212B2044 for ; Wed, 13 Jun 2018 01:09:10 -0700 (PDT) Received: by mail-wm0-x22a.google.com with SMTP id 69-v6so3508309wmf.3 for ; Wed, 13 Jun 2018 01:09:09 -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=JT63QFPgYtr0j5Y8WsamKwRIbdFZ0yqVXiPg+8FlRH0=; b=R1/4kLtCWmblbe4UozrBv1LZJ7aueJvaAnQZdoPEiypdKC3HgxLnfISpckks/H9Tuz dmdZW5371cnsCDNUfGEArTHOA8/A+o2vMF7NxuWdc0H3mCteMHzvW8qNYoBMZOgxv7wE cMgC8MhgkSnNqM8HNPEcnvUobJookpig6rqtA= 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=JT63QFPgYtr0j5Y8WsamKwRIbdFZ0yqVXiPg+8FlRH0=; b=L+BDslTOQEB5F8U4hSWYBn9REAlcypQ8M1KmlqdKg6SJRCMUNaNOKhb22iJlJwf1so LuSKq0yAmc/Q9K8vS16I0N4koDOSL+5WNnmuVjjwoHegal1EXdPEi1XoylVPZIRkWWCU ABD+1+3nM1eX8Ay+RAmtVR5uAQ2xTLGR5uA+PMrOBL75ah6eR14gRVUGR/mjUNYg09re q9/PSFiTIw1Hkb5G2EQjCuWuL0bJL9cswmJxe7ylbZk/dQq3OOv/DX4Z1v2QbVLadLbl +8N2keF8/NoxerOAReERR6uoFw9UEn6ilo+DJ/8chO6IaIX0A5zJZYgWdmx+rOk76Ia4 71kA== X-Gm-Message-State: APt69E0xoNfF/IYCzRQFHCeNym95lXxf9RtOWUgfYo82WP1bEn9w/UcR Yx554/Xwb+TwCn4WvL5lYgMpgHop8OY= X-Received: by 2002:a1c:954d:: with SMTP id x74-v6mr2848646wmd.57.1528877348406; Wed, 13 Jun 2018 01:09:08 -0700 (PDT) Received: from dogfood.home ([2a01:cb1d:112:6f00:6dfc:b76c:4240:35ff]) by smtp.gmail.com with ESMTPSA id v31-v6sm4974772wrc.80.2018.06.13.01.09.07 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 13 Jun 2018 01:09:07 -0700 (PDT) From: Ard Biesheuvel To: edk2-devel@lists.01.org Date: Wed, 13 Jun 2018 10:09:00 +0200 Message-Id: <20180613080901.7156-4-ard.biesheuvel@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20180613080901.7156-1-ard.biesheuvel@linaro.org> References: <20180613080901.7156-1-ard.biesheuvel@linaro.org> Subject: [edk2] [PATCH v4 3/4] ArmPkg/PlatformBootManagerLib: call ProcessCapsules() only once X-BeenThere: edk2-devel@lists.01.org X-Mailman-Version: 2.1.26 Precedence: list List-Id: EDK II Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: michael.d.kinney@intel.com, jiewen.yao@intel.com, star.zeng@intel.com, leif.lindholm@linaro.org, Ard Biesheuvel MIME-Version: 1.0 Errors-To: edk2-devel-bounces@lists.01.org Sender: "edk2-devel" ARM platforms have no restriction on when a system firmware update capsule can be applied, and so it is not necessary to call ProcessCapsules() twice. So let's drop the first invocation that occurs before EndOfDxe, and rewrite the second call so that all capsule updates will be applied when the console is up and able to provide progress feedback. Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Ard Biesheuvel Reviewed-by: Leif Lindholm --- ArmPkg/Library/PlatformBootManagerLib/PlatformBm.c | 86 ++++++++++++++------ ArmPkg/Library/PlatformBootManagerLib/PlatformBootManagerLib.inf | 1 + 2 files changed, 60 insertions(+), 27 deletions(-) -- 2.17.1 _______________________________________________ edk2-devel mailing list edk2-devel@lists.01.org https://lists.01.org/mailman/listinfo/edk2-devel diff --git a/ArmPkg/Library/PlatformBootManagerLib/PlatformBm.c b/ArmPkg/Library/PlatformBootManagerLib/PlatformBm.c index 3456a71fbb9c..079f1552d5ea 100644 --- a/ArmPkg/Library/PlatformBootManagerLib/PlatformBm.c +++ b/ArmPkg/Library/PlatformBootManagerLib/PlatformBm.c @@ -24,6 +24,7 @@ #include #include #include +#include #include #include #include @@ -553,21 +554,6 @@ PlatformBootManagerBeforeConsole ( VOID ) { - EFI_STATUS Status; - ESRT_MANAGEMENT_PROTOCOL *EsrtManagement; - - if (GetBootModeHob() == BOOT_ON_FLASH_UPDATE) { - DEBUG ((DEBUG_INFO, "ProcessCapsules Before EndOfDxe ......\n")); - Status = ProcessCapsules (); - DEBUG ((DEBUG_INFO, "ProcessCapsules returned %r\n", Status)); - } else { - Status = gBS->LocateProtocol (&gEsrtManagementProtocolGuid, NULL, - (VOID **)&EsrtManagement); - if (!EFI_ERROR (Status)) { - EsrtManagement->SyncEsrtFmp (); - } - } - // // Signal EndOfDxe PI Event // @@ -618,6 +604,56 @@ PlatformBootManagerBeforeConsole ( PlatformRegisterOptionsAndKeys (); } +STATIC +VOID +HandleCapsules ( + VOID + ) +{ + ESRT_MANAGEMENT_PROTOCOL *EsrtManagement; + EFI_PEI_HOB_POINTERS HobPointer; + EFI_CAPSULE_HEADER *CapsuleHeader; + BOOLEAN NeedReset; + EFI_STATUS Status; + + DEBUG ((DEBUG_INFO, "%a: processing capsules ...\n", __FUNCTION__)); + + Status = gBS->LocateProtocol (&gEsrtManagementProtocolGuid, NULL, + (VOID **)&EsrtManagement); + if (!EFI_ERROR (Status)) { + EsrtManagement->SyncEsrtFmp (); + } + + // + // Find all capsule images from hob + // + HobPointer.Raw = GetHobList (); + NeedReset = FALSE; + while ((HobPointer.Raw = GetNextHob (EFI_HOB_TYPE_UEFI_CAPSULE, + HobPointer.Raw)) != NULL) { + CapsuleHeader = (VOID *)(UINTN)HobPointer.Capsule->BaseAddress; + + Status = ProcessCapsuleImage (CapsuleHeader); + if (EFI_ERROR (Status)) { + DEBUG ((DEBUG_ERROR, "%a: failed to process capsule %p - %r\n", + __FUNCTION__, CapsuleHeader, Status)); + return; + } + + NeedReset = TRUE; + HobPointer.Raw = GET_NEXT_HOB (HobPointer); + } + + if (NeedReset) { + DEBUG ((DEBUG_WARN, "%a: capsule update successful, resetting ...\n", + __FUNCTION__)); + + gRT->ResetSystem (EfiResetCold, EFI_SUCCESS, 0, NULL); + CpuDeadLoop(); + } +} + + #define VERSION_STRING_PREFIX L"Tianocore/EDK2 firmware version " /** @@ -637,7 +673,6 @@ PlatformBootManagerAfterConsole ( VOID ) { - ESRT_MANAGEMENT_PROTOCOL *EsrtManagement; EFI_STATUS Status; EFI_GRAPHICS_OUTPUT_PROTOCOL *GraphicsOutput; UINTN FirmwareVerLength; @@ -675,17 +710,14 @@ PlatformBootManagerAfterConsole ( // EfiBootManagerConnectAll (); - Status = gBS->LocateProtocol (&gEsrtManagementProtocolGuid, NULL, - (VOID **)&EsrtManagement); - if (!EFI_ERROR (Status)) { - EsrtManagement->SyncEsrtFmp (); - } - - if (GetBootModeHob() == BOOT_ON_FLASH_UPDATE) { - DEBUG((DEBUG_INFO, "ProcessCapsules After EndOfDxe ......\n")); - Status = ProcessCapsules (); - DEBUG((DEBUG_INFO, "ProcessCapsules returned %r\n", Status)); - } + // + // On ARM, there is currently no reason to use the phased capsule + // update approach where some capsules are dispatched before EndOfDxe + // and some are dispatched after. So just handle all capsules here, + // when the console is up and we can actually give the user some + // feedback about what is going on. + // + HandleCapsules (); // // Enumerate all possible boot options. diff --git a/ArmPkg/Library/PlatformBootManagerLib/PlatformBootManagerLib.inf b/ArmPkg/Library/PlatformBootManagerLib/PlatformBootManagerLib.inf index e8cbb10dabdd..28d606d5c329 100644 --- a/ArmPkg/Library/PlatformBootManagerLib/PlatformBootManagerLib.inf +++ b/ArmPkg/Library/PlatformBootManagerLib/PlatformBootManagerLib.inf @@ -55,6 +55,7 @@ [LibraryClasses] UefiBootManagerLib UefiBootServicesTableLib UefiLib + UefiRuntimeServicesTableLib [FeaturePcd] gEfiMdePkgTokenSpaceGuid.PcdUgaConsumeSupport