From patchwork Tue Jun 12 11:23:28 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ard Biesheuvel X-Patchwork-Id: 138321 Delivered-To: patch@linaro.org Received: by 2002:a2e:970d:0:0:0:0:0 with SMTP id r13-v6csp5218736lji; Tue, 12 Jun 2018 04:23:45 -0700 (PDT) X-Google-Smtp-Source: ADUXVKJn6gRRVbZEHg4dChP9M4VUUiEtNgiqYFS/attaFIn1WcMY05/wUflTkaV8vy+D/eAvfI+k X-Received: by 2002:a63:6dce:: with SMTP id i197-v6mr2906723pgc.215.1528802625171; Tue, 12 Jun 2018 04:23:45 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1528802625; cv=none; d=google.com; s=arc-20160816; b=pfp+8shedAyM2QqFlRyJLnqsW8rHsdd2vNnyTAyI5CZ4EqgOyLLqwojt7h4+NChjfo oMxnBWL6ZKdSD60UBNMepp9n9XylTOE1kr7O3msW+kZ+HieDO/hs54UXt40USNHhSNd2 Sp4JxenAAkzK/59J5IqzF1ABPFub5zN71MY8fGaudXhK9n8De1le5qxNBxq2fxdnLmEW JKmFutnme/jKrd3Tom8BLH9TwxarwxyjRlZhLpJv9ZgCR+1SeG5mtorveR6YOHBsMCdr 2C/+IDLLFHIs7EExg5CWHpT7pympnIJbI2fQx48hXjc4Xj5klWVLEz6UyuIkS5lhbAm2 hdtA== 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=PZ/qnhcbUDWxRlJvr4b3aG6l3ZMzj3pSUZsv1vuFAWM=; b=DVUaSByfx1G95EYcI5X09BV2LEIMEii0af/DtgFUX1leV46WdN6Pn/SuzLC1NX/3ns /TIddsgfEu10bRYcgEHO5Q7vtUq/QDf4xiqw0m8NaNns8GGmGff9nEz5G6H2u9AfHNbn rcXtJXb3f9NRM6NFNDdOur9weV0s3g1cfzITMidkwkPgNAHI5uq0drXT4VWk7T8/0/Ph uQN5u2wwFHwG0dYFaSjUtS06K9YAdmeOgypTRRqF17WiiAsiZPVXCewEX73F55wvm0p+ 82NabmXYvZVRHL5eaGaMaFoG/f3BiLrnh0Aoh0Fm9gQz2FL0FUQ8xgY7+knRtERqM66R zqFw== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org header.s=google header.b=g6mrRudr; 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 e1-v6si550978pgr.318.2018.06.12.04.23.44 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 12 Jun 2018 04:23:45 -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=g6mrRudr; 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 748852121797A; Tue, 12 Jun 2018 04:23:42 -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:c0c::22f; helo=mail-wr0-x22f.google.com; envelope-from=ard.biesheuvel@linaro.org; receiver=edk2-devel@lists.01.org Received: from mail-wr0-x22f.google.com (mail-wr0-x22f.google.com [IPv6:2a00:1450:400c:c0c::22f]) (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 F328821217979 for ; Tue, 12 Jun 2018 04:23:39 -0700 (PDT) Received: by mail-wr0-x22f.google.com with SMTP id a12-v6so23682890wro.1 for ; Tue, 12 Jun 2018 04:23:39 -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=SEto7WiKDYJFLF6OMrLPa2ANAWW1maQD4Qayn3WBfuo=; b=g6mrRudrB2et9KLnR7bg1T1C5hjquyCbtSO4g2hI8YP9GanhPuY20ih4UCtGkp+htW 7sAC2Jal2kJZwvGjouFDUcOX6KN+rBg/gbUv5aJhEb7+RUtECvZIELLJCfFKBC8hwBuW Exuz9K3TDSikq8MhRRirqd/EUYBoYHidDqlBk= 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=SEto7WiKDYJFLF6OMrLPa2ANAWW1maQD4Qayn3WBfuo=; b=rTaQL5sPZLfVttEx+W+InfJkKGk93faor7ioxyZCghYHbvwaVv+swAG+bPA7USrlMN 7jvkZHsipGTOn7fWfoDetwt4XnQ0HpLbqUn1lNOF4QFgBA/WJ7C2jC9xHOWmqHt9Bt5p lv+ovm91RZnSZ459FwgZzRTfSGze5VKjC5rRg+6q84jStUfwbd1N5JPnaoiUop+lNtfJ anpxYj+TiKl70AXjQwRezWb2R01Z3K+9CLXSPV/vTlRAKHPjh1CEp1y/PflbyH5H0i4+ 1Yeu6LJEeDx9bBuXxFY0NxX60fN1Lat+FNv8tGnK36qz5C1dWmrkdCuR2cSpTsHHco93 AV/A== X-Gm-Message-State: APt69E0CNxZYGs7RigrGMABOH5nqpSkjeK+SGze2LRbGcDeSsRjCOArw nagfrgDLgr563FjZ/NL9qpiyfEO4lPo= X-Received: by 2002:adf:a6ca:: with SMTP id t68-v6mr2251795wrc.215.1528802617687; Tue, 12 Jun 2018 04:23:37 -0700 (PDT) Received: from dogfood.home ([2a01:cb1d:112:6f00:3c84:18ae:27f2:d03]) by smtp.gmail.com with ESMTPSA id o16-v6sm1177202wrp.8.2018.06.12.04.23.36 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 12 Jun 2018 04:23:36 -0700 (PDT) From: Ard Biesheuvel To: edk2-devel@lists.01.org Date: Tue, 12 Jun 2018 13:23:28 +0200 Message-Id: <20180612112329.664-4-ard.biesheuvel@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20180612112329.664-1-ard.biesheuvel@linaro.org> References: <20180612112329.664-1-ard.biesheuvel@linaro.org> Subject: [edk2] [PATCH v3 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 --- ArmPkg/Library/PlatformBootManagerLib/PlatformBm.c | 87 ++++++++++++++------ ArmPkg/Library/PlatformBootManagerLib/PlatformBootManagerLib.inf | 1 + 2 files changed, 61 insertions(+), 27 deletions(-) -- 2.17.1 _______________________________________________ edk2-devel mailing list edk2-devel@lists.01.org https://lists.01.org/mailman/listinfo/edk2-devel Reviewed-by: Leif Lindholm diff --git a/ArmPkg/Library/PlatformBootManagerLib/PlatformBm.c b/ArmPkg/Library/PlatformBootManagerLib/PlatformBm.c index 3456a71fbb9c..7c21cce5960b 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,57 @@ 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; + } + if ((CapsuleHeader->Flags & CAPSULE_FLAGS_INITIATE_RESET) != 0) { + 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 +674,6 @@ PlatformBootManagerAfterConsole ( VOID ) { - ESRT_MANAGEMENT_PROTOCOL *EsrtManagement; EFI_STATUS Status; EFI_GRAPHICS_OUTPUT_PROTOCOL *GraphicsOutput; UINTN FirmwareVerLength; @@ -675,17 +711,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