From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received-SPF: Pass (sender SPF authorized) identity=mailfrom; client-ip=2607:f8b0:4001:c06::229; helo=mail-io0-x229.google.com; envelope-from=ard.biesheuvel@linaro.org; receiver=edk2-devel@lists.01.org Received: from mail-io0-x229.google.com (mail-io0-x229.google.com [IPv6:2607:f8b0:4001:c06::229]) (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 6FE1621148ED4 for ; Wed, 6 Jun 2018 10:35:27 -0700 (PDT) Received: by mail-io0-x229.google.com with SMTP id l19-v6so8563340ioj.5 for ; Wed, 06 Jun 2018 10:35:27 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :cc; bh=VC6ELecSHj5a8eeMD6gw/c7wC82en/EcsQ5dQNVwbyU=; b=RynvfFznxe772VuUS5fpMw3nH9Eo8Ny40QXJ6hCo9BIPD1oT18Z701iUVutbhEpUBD nsWmNH+kkXGlmWhIQiU8jPL+Gj4wwiNT642vECJYdfJDCI9odntSPD6ifLktGt0knv3F u9COh8HkOXPtXrlnpUl0/L7JXU9nqWECPiTZE= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:in-reply-to:references:from:date :message-id:subject:to:cc; bh=VC6ELecSHj5a8eeMD6gw/c7wC82en/EcsQ5dQNVwbyU=; b=kFHYp4dx/Xs3EWHmPQpzZbqfb/jMj0DOeyDFjJw2hQXf+9vwP7MXk8POwivrLLxUEr umCua0eRzonb5+HGMsqUX9BRVlpQH8Dfyie/7wNbq1EGm+UFton/Oa7JJQZqAemHd48R pmhK+SU7fRn70X5Q73gy4vTFU3+z3uWLwZbBRZ9hFlyhhTszGHkN4t8RCSlTEnBQuM8P HE8/6NBDm/zzVHvn9MHFugimWDvW09609CmBCo10L2/IXquhZJeGSf7+n23pN2eF+3b1 vuL2CE33hiWeg/gRFnEd1SmwkIgzMyG37fKVtPcpZVVKoDHzvO9SjT0Vh4/lJuPNGFlE w44g== X-Gm-Message-State: APt69E2Hw9myeWRFb5OeCMZXKm9aMg+SRcyupL1+/q6T8yFITcbA/XPj C+iP+F1zrG8AUFQ2kkGZisoLlDNMQA5djJTkbm/Dlg== X-Google-Smtp-Source: ADUXVKImjnwN+/3D3Ibc8c6UT9xXDWUHaeMFf13mUj1b84yGdRId6LIDbUZnk2g+A5ny8s+/vAmLMVuFlJYB2spNEIU= X-Received: by 2002:a6b:dd0b:: with SMTP id f11-v6mr3802975ioc.173.1528306526731; Wed, 06 Jun 2018 10:35:26 -0700 (PDT) MIME-Version: 1.0 Received: by 2002:a6b:bb86:0:0:0:0:0 with HTTP; Wed, 6 Jun 2018 10:35:26 -0700 (PDT) In-Reply-To: <20180529161755.9424-3-michael.d.kinney@intel.com> References: <20180529161755.9424-1-michael.d.kinney@intel.com> <20180529161755.9424-3-michael.d.kinney@intel.com> From: Ard Biesheuvel Date: Wed, 6 Jun 2018 19:35:26 +0200 Message-ID: To: Michael D Kinney Cc: "edk2-devel@lists.01.org" , Jiewen Yao Subject: Re: [Patch v3 2/2] SignedCapsulePkg/SystemFirmwareUpdateDxe: Use progress API 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: , X-List-Received-Date: Wed, 06 Jun 2018 17:35:27 -0000 Content-Type: text/plain; charset="UTF-8" On 29 May 2018 at 18:17, Michael D Kinney wrote: > From: "Kinney, Michael D" > > https://bugzilla.tianocore.org/show_bug.cgi?id=801 > > Use PlatformFlashWriteWithProgress() instead of PlatformFLashWrite() > so the user can be informed of the progress as a capsule is used > to update a firmware image in a firmware device. > > Cc: Jiewen Yao > Signed-off-by: Michael D Kinney > Contributed-under: TianoCore Contribution Agreement 1.1 Tested-by: Ard Biesheuvel Reviewed-by: Ard Biesheuvel > --- > .../SystemFirmwareUpdate/SystemFirmwareUpdateDxe.c | 90 ++++++++++++++++------ > 1 file changed, 67 insertions(+), 23 deletions(-) > > diff --git a/SignedCapsulePkg/Universal/SystemFirmwareUpdate/SystemFirmwareUpdateDxe.c b/SignedCapsulePkg/Universal/SystemFirmwareUpdate/SystemFirmwareUpdateDxe.c > index ce6892d6a9..8e66aedf62 100644 > --- a/SignedCapsulePkg/Universal/SystemFirmwareUpdate/SystemFirmwareUpdateDxe.c > +++ b/SignedCapsulePkg/Universal/SystemFirmwareUpdate/SystemFirmwareUpdateDxe.c > @@ -65,11 +65,14 @@ ParseUpdateDataFile ( > **/ > EFI_STATUS > PerformUpdate ( > - IN VOID *SystemFirmwareImage, > - IN UINTN SystemFirmwareImageSize, > - IN UPDATE_CONFIG_DATA *ConfigData, > - OUT UINT32 *LastAttemptVersion, > - OUT UINT32 *LastAttemptStatus > + IN VOID *SystemFirmwareImage, > + IN UINTN SystemFirmwareImageSize, > + IN UPDATE_CONFIG_DATA *ConfigData, > + OUT UINT32 *LastAttemptVersion, > + OUT UINT32 *LastAttemptStatus, > + IN EFI_FIRMWARE_MANAGEMENT_UPDATE_IMAGE_PROGRESS Progress, > + IN UINTN StartPercentage, > + IN UINTN EndPercentage > ) > { > EFI_STATUS Status; > @@ -78,13 +81,22 @@ PerformUpdate ( > DEBUG((DEBUG_INFO, " BaseAddress - 0x%lx,", ConfigData->BaseAddress)); > DEBUG((DEBUG_INFO, " ImageOffset - 0x%x,", ConfigData->ImageOffset)); > DEBUG((DEBUG_INFO, " Legnth - 0x%x\n", ConfigData->Length)); > - Status = PerformFlashWrite ( > + if (Progress != NULL) { > + Progress (StartPercentage); > + } > + Status = PerformFlashWriteWithProgress ( > ConfigData->FirmwareType, > ConfigData->BaseAddress, > ConfigData->AddressType, > (VOID *)((UINTN)SystemFirmwareImage + (UINTN)ConfigData->ImageOffset), > - ConfigData->Length > + ConfigData->Length, > + Progress, > + StartPercentage, > + EndPercentage > ); > + if (Progress != NULL) { > + Progress (EndPercentage); > + } > if (!EFI_ERROR(Status)) { > *LastAttemptStatus = LAST_ATTEMPT_STATUS_SUCCESS; > if (ConfigData->FirmwareType == PlatformFirmwareTypeNvRam) { > @@ -111,12 +123,13 @@ PerformUpdate ( > **/ > EFI_STATUS > UpdateImage ( > - IN VOID *SystemFirmwareImage, > - IN UINTN SystemFirmwareImageSize, > - IN VOID *ConfigImage, > - IN UINTN ConfigImageSize, > - OUT UINT32 *LastAttemptVersion, > - OUT UINT32 *LastAttemptStatus > + IN VOID *SystemFirmwareImage, > + IN UINTN SystemFirmwareImageSize, > + IN VOID *ConfigImage, > + IN UINTN ConfigImageSize, > + OUT UINT32 *LastAttemptVersion, > + OUT UINT32 *LastAttemptStatus, > + IN EFI_FIRMWARE_MANAGEMENT_UPDATE_IMAGE_PROGRESS Progress > ) > { > EFI_STATUS Status; > @@ -124,19 +137,34 @@ UpdateImage ( > UPDATE_CONFIG_DATA *UpdateConfigData; > CONFIG_HEADER ConfigHeader; > UINTN Index; > + UINTN TotalSize; > + UINTN BytesWritten; > + UINTN StartPercentage; > + UINTN EndPercentage; > > if (ConfigImage == NULL) { > DEBUG((DEBUG_INFO, "PlatformUpdate (NoConfig):")); > DEBUG((DEBUG_INFO, " BaseAddress - 0x%x,", 0)); > DEBUG((DEBUG_INFO, " Length - 0x%x\n", SystemFirmwareImageSize)); > // ASSUME the whole System Firmware include NVRAM region. > - Status = PerformFlashWrite ( > + StartPercentage = 0; > + EndPercentage = 100; > + if (Progress != NULL) { > + Progress (StartPercentage); > + } > + Status = PerformFlashWriteWithProgress ( > PlatformFirmwareTypeNvRam, > 0, > FlashAddressTypeRelativeAddress, > SystemFirmwareImage, > - SystemFirmwareImageSize > + SystemFirmwareImageSize, > + Progress, > + StartPercentage, > + EndPercentage > ); > + if (Progress != NULL) { > + Progress (EndPercentage); > + } > if (!EFI_ERROR(Status)) { > *LastAttemptStatus = LAST_ATTEMPT_STATUS_SUCCESS; > mNvRamUpdated = TRUE; > @@ -163,17 +191,30 @@ UpdateImage ( > DEBUG((DEBUG_INFO, "ConfigHeader.NumOfUpdates - 0x%x\n", ConfigHeader.NumOfUpdates)); > DEBUG((DEBUG_INFO, "PcdEdkiiSystemFirmwareFileGuid - %g\n", PcdGetPtr(PcdEdkiiSystemFirmwareFileGuid))); > > + TotalSize = 0; > + for (Index = 0; Index < ConfigHeader.NumOfUpdates; Index++) { > + if (CompareGuid(&ConfigData[Index].FileGuid, PcdGetPtr(PcdEdkiiSystemFirmwareFileGuid))) { > + TotalSize = TotalSize + ConfigData[Index].Length; > + } > + } > + > + BytesWritten = 0; > Index = 0; > UpdateConfigData = ConfigData; > while (Index < ConfigHeader.NumOfUpdates) { > if (CompareGuid(&UpdateConfigData->FileGuid, PcdGetPtr(PcdEdkiiSystemFirmwareFileGuid))) { > DEBUG((DEBUG_INFO, "FileGuid - %g (processing)\n", &UpdateConfigData->FileGuid)); > + StartPercentage = (BytesWritten * 100) / TotalSize; > + EndPercentage = ((BytesWritten + UpdateConfigData->Length) * 100) / TotalSize; > Status = PerformUpdate ( > SystemFirmwareImage, > SystemFirmwareImageSize, > UpdateConfigData, > LastAttemptVersion, > - LastAttemptStatus > + LastAttemptStatus, > + Progress, > + StartPercentage, > + EndPercentage > ); > // > // Shall updates be serialized so that if an update is not successfully completed, > @@ -186,6 +227,8 @@ UpdateImage ( > DEBUG((DEBUG_INFO, "FileGuid - %g (ignored)\n", &UpdateConfigData->FileGuid)); > } > > + BytesWritten += UpdateConfigData->Length; > + > Index++; > UpdateConfigData++; > } > @@ -209,10 +252,11 @@ UpdateImage ( > **/ > EFI_STATUS > SystemFirmwareAuthenticatedUpdate ( > - IN VOID *Image, > - IN UINTN ImageSize, > - OUT UINT32 *LastAttemptVersion, > - OUT UINT32 *LastAttemptStatus > + IN VOID *Image, > + IN UINTN ImageSize, > + OUT UINT32 *LastAttemptVersion, > + OUT UINT32 *LastAttemptStatus, > + IN EFI_FIRMWARE_MANAGEMENT_UPDATE_IMAGE_PROGRESS Progress > ) > { > EFI_STATUS Status; > @@ -240,7 +284,7 @@ SystemFirmwareAuthenticatedUpdate ( > ExtractConfigImage(AuthenticatedImage, AuthenticatedImageSize, &ConfigImage, &ConfigImageSize); > > DEBUG((DEBUG_INFO, "UpdateImage ...\n")); > - Status = UpdateImage(SystemFirmwareImage, SystemFirmwareImageSize, ConfigImage, ConfigImageSize, LastAttemptVersion, LastAttemptStatus); > + Status = UpdateImage(SystemFirmwareImage, SystemFirmwareImageSize, ConfigImage, ConfigImageSize, LastAttemptVersion, LastAttemptStatus, Progress); > if (EFI_ERROR(Status)) { > DEBUG((DEBUG_INFO, "UpdateImage - %r\n", Status)); > return Status; > @@ -442,8 +486,8 @@ FmpSetImage ( > return EFI_INVALID_PARAMETER; > } > > - Status = SystemFirmwareAuthenticatedUpdate((VOID *)Image, ImageSize, &SystemFmpPrivate->LastAttempt.LastAttemptVersion, &SystemFmpPrivate->LastAttempt.LastAttemptStatus); > - DEBUG((DEBUG_INFO, "SetImage - LastAttemp Version - 0x%x, State - 0x%x\n", SystemFmpPrivate->LastAttempt.LastAttemptVersion, SystemFmpPrivate->LastAttempt.LastAttemptStatus)); > + Status = SystemFirmwareAuthenticatedUpdate((VOID *)Image, ImageSize, &SystemFmpPrivate->LastAttempt.LastAttemptVersion, &SystemFmpPrivate->LastAttempt.LastAttemptStatus, Progress); > + DEBUG((DEBUG_INFO, "SetImage - LastAttempt Version - 0x%x, State - 0x%x\n", SystemFmpPrivate->LastAttempt.LastAttemptVersion, SystemFmpPrivate->LastAttempt.LastAttemptStatus)); > > // > // If NVRAM is updated, we should no longer touch variable services, because > -- > 2.14.2.windows.3 > > _______________________________________________ > edk2-devel mailing list > edk2-devel@lists.01.org > https://lists.01.org/mailman/listinfo/edk2-devel