From: "Wu, Hao A" <hao.a.wu@intel.com>
To: "Xu, Wei6" <wei6.xu@intel.com>,
"devel@edk2.groups.io" <devel@edk2.groups.io>
Cc: "Wang, Jian J" <jian.j.wang@intel.com>,
"Zhang, Chao B" <chao.b.zhang@intel.com>
Subject: Re: [edk2-devel][Patch] MdeModulePkg/CapsuleApp: Enhance Capsule-On-Disk related functions.
Date: Tue, 28 May 2019 00:53:02 +0000 [thread overview]
Message-ID: <B80AF82E9BFB8E4FBD8C89DA810C6A093C8D6C9C@SHSMSX104.ccr.corp.intel.com> (raw)
In-Reply-To: <20190524090207.19728-1-wei6.xu@intel.com>
> -----Original Message-----
> From: Xu, Wei6
> Sent: Friday, May 24, 2019 5:02 PM
> To: devel@edk2.groups.io
> Cc: Wang, Jian J; Wu, Hao A; Zhang, Chao B; Xu, Wei6
> Subject: [edk2-devel][Patch] MdeModulePkg/CapsuleApp: Enhance
> Capsule-On-Disk related functions.
>
> BZ: https://bugzilla.tianocore.org/show_bug.cgi?id=1840
>
> 1. Add missing '\n' in usage.
> 2. Fix the dead loop of CapsuleApp -L.
> 3. Fix the bug that CapsuleApp -OD cannot perform capsules in sub-
> folder.
> 4. Optimize the handling for option -NR and -OD to support both
> 'CapsuleApp <Capsule> -OD -NR' and 'CapsuleApp <Capsule> -NR -OD'.
> 5. Check if Capsule-On-Disk is supported by "OsIndicationsSupported"
> variable firstly before processing capsules. If not supported, prompt
> an error message and quit the process.
I think this one belongs to a bug fix.
Acked-by: Hao A Wu <hao.a.wu@intel.com>
Best Regards,
Hao Wu
>
> Cc: Jian J Wang <jian.j.wang@intel.com>
> Cc: Hao A Wu <hao.a.wu@intel.com>
> Cc: Chao B Zhang <chao.b.zhang@intel.com>
> Signed-off-by: Wei6 Xu <wei6.xu@intel.com>
> ---
> MdeModulePkg/Application/CapsuleApp/CapsuleApp.c | 41 ++++++++-----
> ---
> MdeModulePkg/Application/CapsuleApp/CapsuleDump.c | 4 +-
> .../Application/CapsuleApp/CapsuleOnDisk.c | 56
> +++++++++++++++++++++-
> 3 files changed, 77 insertions(+), 24 deletions(-)
>
> diff --git a/MdeModulePkg/Application/CapsuleApp/CapsuleApp.c
> b/MdeModulePkg/Application/CapsuleApp/CapsuleApp.c
> index e3c591dbf3..0b5f7c8684 100644
> --- a/MdeModulePkg/Application/CapsuleApp/CapsuleApp.c
> +++ b/MdeModulePkg/Application/CapsuleApp/CapsuleApp.c
> @@ -847,11 +847,11 @@ PrintUsage (
> Print(L" CapsuleApp -D <Capsule>\n");
> Print(L" CapsuleApp -P GET <ImageTypeId> <Index> -O <FileName>\n");
> Print(L"Parameter:\n");
> Print(L" -NR: No reset will be triggered for the capsule\n");
> Print(L" with CAPSULE_FLAGS_PERSIST_ACROSS_RESET and without
> CAPSULE_FLAGS_INITIATE_RESET.\n");
> - Print(L" -OD: Delivery of Capsules via file on Mass Storage device.");
> + Print(L" -OD: Delivery of Capsules via file on Mass Storage device.\n");
> Print(L" -S: Dump capsule report variable
> (EFI_CAPSULE_REPORT_GUID),\n");
> Print(L" which is defined in UEFI specification.\n");
> Print(L" -C: Clear capsule report variable
> (EFI_CAPSULE_REPORT_GUID),\n");
> Print(L" which is defined in UEFI specification.\n");
> Print(L" -P: Dump UEFI FMP protocol info, or get image with specified\n");
> @@ -1018,44 +1018,43 @@ UefiMain (
> ParaNrIndex = Index;
> NoReset = TRUE;
> }
> }
>
> - if (ParaOdIndex != 0) {
> - if (ParaOdIndex == Argc - 1) {
> + if (ParaOdIndex > ParaNrIndex) {
> + if (ParaNrIndex != 0) {
> + CapsuleLastIndex = ParaNrIndex - 1;
> + } else {
> + CapsuleLastIndex = ParaOdIndex - 1;
> + }
> +
> + if (ParaOdIndex == Argc -1) {
> MapFsStr = NULL;
> } else if (ParaOdIndex == Argc - 2) {
> MapFsStr = Argv[Argc-1];
> } else {
> - Print (L"CapsuleApp: Invalid Position for -OD Options\n");
> + Print (L"CapsuleApp: Cannot specify more than one FS mapping!\n");
> Status = EFI_INVALID_PARAMETER;
> goto Done;
> }
> -
> - if (ParaNrIndex != 0) {
> - if (ParaNrIndex + 1 == ParaOdIndex) {
> - CapsuleLastIndex = ParaNrIndex - 1;
> - } else {
> - Print (L"CapsuleApp: Invalid Position for -NR Options\n");
> - Status = EFI_INVALID_PARAMETER;
> - goto Done;
> - }
> - } else {
> + } else if (ParaOdIndex < ParaNrIndex) {
> + if (ParaOdIndex != 0) {
> CapsuleLastIndex = ParaOdIndex - 1;
> - }
> - } else {
> - if (ParaNrIndex != 0) {
> - if (ParaNrIndex == Argc -1) {
> - CapsuleLastIndex = ParaNrIndex - 1;
> + if (ParaOdIndex == ParaNrIndex - 1) {
> + MapFsStr = NULL;
> + } else if (ParaOdIndex == ParaNrIndex - 2) {
> + MapFsStr = Argv[ParaOdIndex + 1];
> } else {
> - Print (L"CapsuleApp: Invalid Position for -NR Options\n");
> + Print (L"CapsuleApp: Cannot specify more than one FS mapping!\n");
> Status = EFI_INVALID_PARAMETER;
> goto Done;
> }
> } else {
> - CapsuleLastIndex = Argc - 1;
> + CapsuleLastIndex = ParaNrIndex - 1;
> }
> + } else {
> + CapsuleLastIndex = Argc - 1;
> }
>
> CapsuleNum = CapsuleLastIndex - CapsuleFirstIndex + 1;
>
> if (CapsuleFirstIndex > CapsuleLastIndex) {
> diff --git a/MdeModulePkg/Application/CapsuleApp/CapsuleDump.c
> b/MdeModulePkg/Application/CapsuleApp/CapsuleDump.c
> index b81c5b7b3a..0e0c566702 100644
> --- a/MdeModulePkg/Application/CapsuleApp/CapsuleDump.c
> +++ b/MdeModulePkg/Application/CapsuleApp/CapsuleDump.c
> @@ -810,12 +810,12 @@ DumpCapsuleFromDisk (
> }
>
> //
> // Get file count first
> //
> + Status = FileHandleFindFirstFile (DirHandle, &FileInfo);
> do {
> - Status = FileHandleFindFirstFile (DirHandle, &FileInfo);
> if (EFI_ERROR (Status) || FileInfo == NULL) {
> Print (L"Get File Info Fail. Status = %r\n", Status);
> goto Done;
> }
>
> @@ -844,12 +844,12 @@ DumpCapsuleFromDisk (
> NoFile = FALSE;
>
> //
> // Get all file info
> //
> + Status = FileHandleFindFirstFile (DirHandle, &FileInfo);
> do {
> - Status = FileHandleFindFirstFile (DirHandle, &FileInfo);
> if (EFI_ERROR (Status) || FileInfo == NULL) {
> Print (L"Get File Info Fail. Status = %r\n", Status);
> goto Done;
> }
>
> diff --git a/MdeModulePkg/Application/CapsuleApp/CapsuleOnDisk.c
> b/MdeModulePkg/Application/CapsuleApp/CapsuleOnDisk.c
> index a11683d66c..df43a436f2 100644
> --- a/MdeModulePkg/Application/CapsuleApp/CapsuleOnDisk.c
> +++ b/MdeModulePkg/Application/CapsuleApp/CapsuleOnDisk.c
> @@ -21,10 +21,12 @@
> #include <Protocol/Shell.h>
> #include <Guid/FileInfo.h>
> #include <Guid/GlobalVariable.h>
> #include <Guid/Gpt.h>
>
> +#define MAX_CAPSULE_NUM 10
> +
> EFI_GUID mCapsuleOnDiskBootOptionGuid = { 0x4CC29BB7, 0x2413, 0x40A2,
> { 0xB0, 0x6D, 0x25, 0x3E, 0x37, 0x10, 0xF5, 0x32 } };
>
> /**
> Get shell protocol.
>
> @@ -742,10 +744,45 @@ SetCapsuleStatusVariable (
> );
>
> return Status;
> }
>
> +/**
> + Check if Capsule On Disk is supported.
> +
> + @retval TRUE Capsule On Disk is supported.
> + @retval FALSE Capsule On Disk is not supported.
> +
> +**/
> +BOOLEAN
> +IsCapsuleOnDiskSupported (
> + VOID
> + )
> +{
> + EFI_STATUS Status;
> + UINT64 OsIndicationsSupported;
> + UINTN DataSize;
> +
> + DataSize = sizeof(UINT64);
> + Status = gRT->GetVariable (
> + L"OsIndicationsSupported",
> + &gEfiGlobalVariableGuid,
> + NULL,
> + &DataSize,
> + &OsIndicationsSupported
> + );
> + if (EFI_ERROR (Status)) {
> + return FALSE;
> + }
> +
> + if (OsIndicationsSupported &
> EFI_OS_INDICATIONS_FILE_CAPSULE_DELIVERY_SUPPORTED) {
> + return TRUE;
> + }
> +
> + return FALSE;
> +}
> +
> /**
> Process Capsule On Disk.
>
> @param[in] CapsuleBuffer An array of pointer to capsule images
> @param[in] CapsuleBufferSize An array of UINTN to capsule images size
> @@ -768,10 +805,20 @@ ProcessCapsuleOnDisk (
> {
> EFI_STATUS Status;
> UINT16 BootNext;
> EFI_SIMPLE_FILE_SYSTEM_PROTOCOL *Fs;
> BOOLEAN UpdateBootNext;
> + CHAR16 *FileName[MAX_CAPSULE_NUM];
> + UINTN Index;
> +
> + //
> + // Check if Capsule On Disk is supported
> + //
> + if (!IsCapsuleOnDiskSupported ()) {
> + Print (L"CapsuleApp: Capsule On Disk is not supported.\n");
> + return EFI_UNSUPPORTED;
> + }
>
> //
> // Get a valid file system from boot path
> //
> Fs = NULL;
> @@ -780,14 +827,21 @@ ProcessCapsuleOnDisk (
> if (EFI_ERROR (Status)) {
> Print (L"CapsuleApp: cannot find a valid file system on boot devies. Status
> = %r\n", Status);
> return Status;
> }
>
> + //
> + // Get file name from file path
> + //
> + for (Index = 0; Index < CapsuleNum; Index ++) {
> + FileName[Index] = GetFileNameFromPath (FilePath[Index]);
> + }
> +
> //
> // Copy capsule image to '\efi\UpdateCapsule\'
> //
> - Status = WriteUpdateFile (CapsuleBuffer, CapsuleBufferSize, FilePath,
> CapsuleNum, Fs);
> + Status = WriteUpdateFile (CapsuleBuffer, CapsuleBufferSize, FileName,
> CapsuleNum, Fs);
> if (EFI_ERROR (Status)) {
> Print (L"CapsuleApp: capsule image could not be copied for update.\n");
> return Status;
> }
>
> --
> 2.16.2.windows.1
next prev parent reply other threads:[~2019-05-28 0:53 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-05-24 9:02 [edk2-devel][Patch] MdeModulePkg/CapsuleApp: Enhance Capsule-On-Disk related functions Xu, Wei6
2019-05-28 0:34 ` Zhang, Chao B
2019-05-28 0:53 ` Wu, Hao A [this message]
-- strict thread matches above, loose matches on Subject: below --
2019-06-25 6:51 Xu, Wei6
2019-06-26 1:45 ` Wu, Hao A
2019-06-26 2:06 ` Zhang, Chao B
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-list from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=B80AF82E9BFB8E4FBD8C89DA810C6A093C8D6C9C@SHSMSX104.ccr.corp.intel.com \
--to=devel@edk2.groups.io \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox