From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: mx.groups.io; dkim=missing; spf=pass (domain: intel.com, ip: 134.134.136.20, mailfrom: hao.a.wu@intel.com) Received: from mga02.intel.com (mga02.intel.com [134.134.136.20]) by groups.io with SMTP; Tue, 25 Jun 2019 18:46:00 -0700 X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga006.jf.intel.com ([10.7.209.51]) by orsmga101.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 25 Jun 2019 18:45:59 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.63,418,1557212400"; d="scan'208";a="166873800" Received: from fmsmsx105.amr.corp.intel.com ([10.18.124.203]) by orsmga006.jf.intel.com with ESMTP; 25 Jun 2019 18:45:59 -0700 Received: from fmsmsx154.amr.corp.intel.com (10.18.116.70) by FMSMSX105.amr.corp.intel.com (10.18.124.203) with Microsoft SMTP Server (TLS) id 14.3.439.0; Tue, 25 Jun 2019 18:45:58 -0700 Received: from shsmsx102.ccr.corp.intel.com (10.239.4.154) by FMSMSX154.amr.corp.intel.com (10.18.116.70) with Microsoft SMTP Server (TLS) id 14.3.439.0; Tue, 25 Jun 2019 18:45:58 -0700 Received: from shsmsx104.ccr.corp.intel.com ([169.254.5.185]) by shsmsx102.ccr.corp.intel.com ([169.254.2.33]) with mapi id 14.03.0439.000; Wed, 26 Jun 2019 09:45:54 +0800 From: "Wu, Hao A" To: "Zhang, Chao B" , "Xu, Wei6" , "devel@edk2.groups.io" CC: "Wang, Jian J" Subject: Re: [edk2-devel][Patch] MdeModulePkg/CapsuleApp: Enhance Capsule-On-Disk related functions. Thread-Topic: [edk2-devel][Patch] MdeModulePkg/CapsuleApp: Enhance Capsule-On-Disk related functions. Thread-Index: AQHVKyJ3LgbsnZP0C0uhRo9jpd1yxaatKyGA Date: Wed, 26 Jun 2019 01:45:54 +0000 Message-ID: References: <20190625065113.12488-1-wei6.xu@intel.com> In-Reply-To: <20190625065113.12488-1-wei6.xu@intel.com> Accept-Language: zh-CN, en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-originating-ip: [10.239.127.40] MIME-Version: 1.0 Return-Path: hao.a.wu@intel.com Content-Language: en-US Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable > -----Original Message----- > From: Xu, Wei6 > Sent: Tuesday, June 25, 2019 2:51 PM > To: devel@edk2.groups.io > Cc: Wang, Jian J; Wu, Hao A; Zhang, Chao B > Subject: [edk2-devel][Patch] MdeModulePkg/CapsuleApp: Enhance > Capsule-On-Disk related functions. >=20 > BZ: https://bugzilla.tianocore.org/show_bug.cgi?id=3D1840 >=20 > 1. Introduce an internal header file to put definitions in it. > 2. Add missing '\n' in usage. > 3. Fix the dead loop of CapsuleApp -L. > 4. Fix the bug that CapsuleApp -OD cannot perform capsules in sub- > folder. > 5. Optimize the handling for option -NR and -OD to support both > 'CapsuleApp -OD -NR' and 'CapsuleApp -NR -OD'. > 6. 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. Acked-by: Hao A Wu Hello Chao, could you help to review this patch? Thanks in advance. Best Regards, Hao Wu >=20 > Cc: Jian J Wang > Cc: Hao A Wu > Cc: Chao B Zhang > Signed-off-by: Wei6 Xu > --- > MdeModulePkg/Application/CapsuleApp/AppSupport.c | 13 +- > MdeModulePkg/Application/CapsuleApp/CapsuleApp.c | 215 ++------------- > --- > MdeModulePkg/Application/CapsuleApp/CapsuleApp.h | 240 > +++++++++++++++++++++ > MdeModulePkg/Application/CapsuleApp/CapsuleApp.inf | 3 +- > MdeModulePkg/Application/CapsuleApp/CapsuleDump.c | 98 +-------- > .../Application/CapsuleApp/CapsuleOnDisk.c | 86 +++++--- > 6 files changed, 323 insertions(+), 332 deletions(-) > create mode 100644 > MdeModulePkg/Application/CapsuleApp/CapsuleApp.h >=20 > diff --git a/MdeModulePkg/Application/CapsuleApp/AppSupport.c > b/MdeModulePkg/Application/CapsuleApp/AppSupport.c > index d9ce1b4843..8fe70dc3b6 100644 > --- a/MdeModulePkg/Application/CapsuleApp/AppSupport.c > +++ b/MdeModulePkg/Application/CapsuleApp/AppSupport.c > @@ -1,23 +1,14 @@ > /** @file > A shell application that triggers capsule update process. >=20 > - Copyright (c) 2016 - 2017, Intel Corporation. All rights reserved.
> + Copyright (c) 2016 - 2019, Intel Corporation. All rights reserved.
> SPDX-License-Identifier: BSD-2-Clause-Patent >=20 > **/ >=20 > -#include > -#include > -#include > -#include > -#include > -#include > -#include > -#include > -#include > -#include > +#include "CapsuleApp.h" >=20 > UINTN Argc; > CHAR16 **Argv; > EFI_SHELL_PROTOCOL *mShellProtocol =3D NULL; >=20 > diff --git a/MdeModulePkg/Application/CapsuleApp/CapsuleApp.c > b/MdeModulePkg/Application/CapsuleApp/CapsuleApp.c > index e3c591dbf3..3439ce5feb 100644 > --- a/MdeModulePkg/Application/CapsuleApp/CapsuleApp.c > +++ b/MdeModulePkg/Application/CapsuleApp/CapsuleApp.c > @@ -4,191 +4,19 @@ > Copyright (c) 2016 - 2019, Intel Corporation. All rights reserved.
> SPDX-License-Identifier: BSD-2-Clause-Patent >=20 > **/ >=20 > -#include > -#include > -#include > -#include > -#include > -#include > -#include > -#include > -#include > -#include > -#include > -#include > -#include > -#include > -#include > -#include > - > -#define CAPSULE_HEADER_SIZE 0x20 > - > -#define NESTED_CAPSULE_HEADER_SIZE SIZE_4KB > -#define SYSTEM_FIRMWARE_FLAG 0x50000 > -#define DEVICE_FIRMWARE_FLAG 0x78010 > - > -#define MAJOR_VERSION 1 > -#define MINOR_VERSION 0 > - > -#define MAX_CAPSULE_NUM 10 > - > -extern UINTN Argc; > -extern CHAR16 **Argv; > +#include "CapsuleApp.h" >=20 > // > // Define how many block descriptors we want to test with. > // > UINTN NumberOfDescriptors =3D 1; > UINTN CapsuleFirstIndex; > UINTN CapsuleLastIndex; >=20 > -/** > - Dump capsule information > - > - @param[in] CapsuleName The name of the capsule image. > - > - @retval EFI_SUCCESS The capsule information is dumped. > - @retval EFI_UNSUPPORTED Input parameter is not valid. > -**/ > -EFI_STATUS > -DumpCapsule ( > - IN CHAR16 *CapsuleName > - ); > - > -/** > - Dump capsule status variable. > - > - @retval EFI_SUCCESS The capsule status variable is dumped. > - @retval EFI_UNSUPPORTED Input parameter is not valid. > -**/ > -EFI_STATUS > -DumpCapsuleStatusVariable ( > - VOID > - ); > - > -/** > - Dump FMP protocol info. > -**/ > -VOID > -DumpFmpData ( > - VOID > - ); > - > -/** > - Dump FMP image data. > - > - @param[in] ImageTypeId The ImageTypeId of the FMP image. > - It is used to identify the FMP protocol. > - @param[in] ImageIndex The ImageIndex of the FMP image. > - It is the input parameter for FMP->GetImage(= ). > - @param[in] ImageName The file name to hold the output FMP image. > -**/ > -VOID > -DumpFmpImage ( > - IN EFI_GUID *ImageTypeId, > - IN UINTN ImageIndex, > - IN CHAR16 *ImageName > - ); > - > -/** > - Dump ESRT info. > -**/ > -VOID > -DumpEsrtData ( > - VOID > - ); > - > -/** > - Dump Provisioned Capsule. > - > - @param[in] DumpCapsuleInfo The flag to indicate whether to dump the > capsule inforomation. > -**/ > -VOID > -DumpProvisionedCapsule ( > - IN BOOLEAN DumpCapsuleInfo > - ); > - > -/** > - Dump all EFI System Partition. > -**/ > -VOID > -DumpAllEfiSysPartition ( > - VOID > - ); > - > -/** > - Process Capsule On Disk. > - > - @param[in] CapsuleBuffer An array of pointer to capsule images > - @param[in] CapsuleBufferSize An array of UINTN to capsule images si= ze > - @param[in] FilePath An array of capsule images file path > - @param[in] Map File system mapping string > - @param[in] CapsuleNum The count of capsule images > - > - @retval EFI_SUCCESS Capsule on disk success. > - @retval others Capsule on disk fail. > - > -**/ > -EFI_STATUS > -ProcessCapsuleOnDisk ( > - IN VOID **CapsuleBuffer, > - IN UINTN *CapsuleBufferSize, > - IN CHAR16 **FilePath, > - IN CHAR16 *Map, > - IN UINTN CapsuleNum > - ); > - > -/** > - Read a file. > - > - @param[in] FileName The file to be read. > - @param[out] BufferSize The file buffer size > - @param[out] Buffer The file buffer > - > - @retval EFI_SUCCESS Read file successfully > - @retval EFI_NOT_FOUND Shell protocol or file not found > - @retval others Read file failed > -**/ > -EFI_STATUS > -ReadFileToBuffer ( > - IN CHAR16 *FileName, > - OUT UINTN *BufferSize, > - OUT VOID **Buffer > - ); > - > -/** > - Write a file. > - > - @param[in] FileName The file to be written. > - @param[in] BufferSize The file buffer size > - @param[in] Buffer The file buffer > - > - @retval EFI_SUCCESS Write file successfully > - @retval EFI_NOT_FOUND Shell protocol not found > - @retval others Write file failed > -**/ > -EFI_STATUS > -WriteFileFromBuffer ( > - IN CHAR16 *FileName, > - IN UINTN BufferSize, > - IN VOID *Buffer > - ); > - > -/** > - > - This function parse application ARG. > - > - @return Status > -**/ > -EFI_STATUS > -GetArg ( > - VOID > - ); > - > /** > Create UX capsule. >=20 > @retval EFI_SUCCESS The capsule header is appended. > @retval EFI_UNSUPPORTED Input parameter is not valid. > @@ -847,11 +675,11 @@ PrintUsage ( > Print(L" CapsuleApp -D \n"); > Print(L" CapsuleApp -P GET -O \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 specifie= d\n"); > @@ -1018,44 +846,43 @@ UefiMain ( > ParaNrIndex =3D Index; > NoReset =3D TRUE; > } > } >=20 > - if (ParaOdIndex !=3D 0) { > - if (ParaOdIndex =3D=3D Argc - 1) { > + if (ParaOdIndex > ParaNrIndex) { > + if (ParaNrIndex !=3D 0) { > + CapsuleLastIndex =3D ParaNrIndex - 1; > + } else { > + CapsuleLastIndex =3D ParaOdIndex - 1; > + } > + > + if (ParaOdIndex =3D=3D Argc -1) { > MapFsStr =3D NULL; > } else if (ParaOdIndex =3D=3D Argc - 2) { > MapFsStr =3D 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 =3D EFI_INVALID_PARAMETER; > goto Done; > } > - > - if (ParaNrIndex !=3D 0) { > - if (ParaNrIndex + 1 =3D=3D ParaOdIndex) { > - CapsuleLastIndex =3D ParaNrIndex - 1; > - } else { > - Print (L"CapsuleApp: Invalid Position for -NR Options\n"); > - Status =3D EFI_INVALID_PARAMETER; > - goto Done; > - } > - } else { > + } else if (ParaOdIndex < ParaNrIndex) { > + if (ParaOdIndex !=3D 0) { > CapsuleLastIndex =3D ParaOdIndex - 1; > - } > - } else { > - if (ParaNrIndex !=3D 0) { > - if (ParaNrIndex =3D=3D Argc -1) { > - CapsuleLastIndex =3D ParaNrIndex - 1; > + if (ParaOdIndex =3D=3D ParaNrIndex - 1) { > + MapFsStr =3D NULL; > + } else if (ParaOdIndex =3D=3D ParaNrIndex - 2) { > + MapFsStr =3D 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 =3D EFI_INVALID_PARAMETER; > goto Done; > } > } else { > - CapsuleLastIndex =3D Argc - 1; > + CapsuleLastIndex =3D ParaNrIndex - 1; > } > + } else { > + CapsuleLastIndex =3D Argc - 1; > } >=20 > CapsuleNum =3D CapsuleLastIndex - CapsuleFirstIndex + 1; >=20 > if (CapsuleFirstIndex > CapsuleLastIndex) { > diff --git a/MdeModulePkg/Application/CapsuleApp/CapsuleApp.h > b/MdeModulePkg/Application/CapsuleApp/CapsuleApp.h > new file mode 100644 > index 0000000000..270d2359a3 > --- /dev/null > +++ b/MdeModulePkg/Application/CapsuleApp/CapsuleApp.h > @@ -0,0 +1,240 @@ > +/** @file > + A shell application that triggers capsule update process. > + > + Copyright (c) 2019, Intel Corporation. All rights reserved.
> + SPDX-License-Identifier: BSD-2-Clause-Patent > + > +**/ > + > + > +#ifndef _CAPSULE_APP_H_ > +#define _CAPSULE_APP_H_ > + > +#include > +#include > +#include > +#include > +#include > +#include > +#include > +#include > +#include > +#include > +#include > +#include > +#include > +#include > +#include > +#include > +#include > +#include > +#include > +#include > +#include > +#include > +#include > +#include > +#include > +#include > +#include > +#include > + > +#define CAPSULE_HEADER_SIZE 0x20 > + > +#define NESTED_CAPSULE_HEADER_SIZE SIZE_4KB > +#define SYSTEM_FIRMWARE_FLAG 0x50000 > +#define DEVICE_FIRMWARE_FLAG 0x78010 > + > +#define MAJOR_VERSION 1 > +#define MINOR_VERSION 0 > + > +#define MAX_CAPSULE_NUM 10 > + > +// > +// (20 * (6+5+2))+1) unicode characters from EFI FAT spec (doubled for > bytes) > +// > +#define MAX_FILE_NAME_SIZE 522 > +#define MAX_FILE_NAME_LEN (MAX_FILE_NAME_SIZE / sizeof(CHAR16)) > + > +extern UINTN Argc; > +extern CHAR16 **Argv; > + > +/** > + > + This function parse application ARG. > + > + @return Status > +**/ > +EFI_STATUS > +GetArg ( > + VOID > + ); > + > +/** > + Get shell protocol. > + > + @return Pointer to shell protocol. > + > +**/ > +EFI_SHELL_PROTOCOL * > +GetShellProtocol ( > + VOID > + ); > + > + > +/** > + Read a file. > + > + @param[in] FileName The file to be read. > + @param[out] BufferSize The file buffer size > + @param[out] Buffer The file buffer > + > + @retval EFI_SUCCESS Read file successfully > + @retval EFI_NOT_FOUND Shell protocol or file not found > + @retval others Read file failed > +**/ > +EFI_STATUS > +ReadFileToBuffer ( > + IN CHAR16 *FileName, > + OUT UINTN *BufferSize, > + OUT VOID **Buffer > + ); > + > +/** > + Write a file. > + > + @param[in] FileName The file to be written. > + @param[in] BufferSize The file buffer size > + @param[in] Buffer The file buffer > + > + @retval EFI_SUCCESS Write file successfully > + @retval EFI_NOT_FOUND Shell protocol not found > + @retval others Write file failed > +**/ > +EFI_STATUS > +WriteFileFromBuffer ( > + IN CHAR16 *FileName, > + IN UINTN BufferSize, > + IN VOID *Buffer > + ); > + > + > +/** > + Dump capsule information > + > + @param[in] CapsuleName The name of the capsule image. > + > + @retval EFI_SUCCESS The capsule information is dumped. > + @retval EFI_UNSUPPORTED Input parameter is not valid. > +**/ > +EFI_STATUS > +DumpCapsule ( > + IN CHAR16 *CapsuleName > + ); > + > +/** > + Dump capsule status variable. > + > + @retval EFI_SUCCESS The capsule status variable is dumped. > + @retval EFI_UNSUPPORTED Input parameter is not valid. > +**/ > +EFI_STATUS > +DumpCapsuleStatusVariable ( > + VOID > + ); > + > +/** > + Dump FMP protocol info. > +**/ > +VOID > +DumpFmpData ( > + VOID > + ); > + > +/** > + Dump FMP image data. > + > + @param[in] ImageTypeId The ImageTypeId of the FMP image. > + It is used to identify the FMP protocol. > + @param[in] ImageIndex The ImageIndex of the FMP image. > + It is the input parameter for FMP->GetImage(= ). > + @param[in] ImageName The file name to hold the output FMP image. > +**/ > +VOID > +DumpFmpImage ( > + IN EFI_GUID *ImageTypeId, > + IN UINTN ImageIndex, > + IN CHAR16 *ImageName > + ); > + > +/** > + Dump ESRT info. > +**/ > +VOID > +DumpEsrtData ( > + VOID > + ); > + > +/** > + Dump Provisioned Capsule. > + > + @param[in] DumpCapsuleInfo The flag to indicate whether to dump the > capsule inforomation. > +**/ > +VOID > +DumpProvisionedCapsule ( > + IN BOOLEAN DumpCapsuleInfo > + ); > + > +/** > + Dump all EFI System Partition. > +**/ > +VOID > +DumpAllEfiSysPartition ( > + VOID > + ); > + > + > +/** > + Get SimpleFileSystem from boot option file path. > + > + @param[in] DevicePath The file path of boot option > + @param[out] FullPath The full device path of boot device > + @param[out] Fs The file system within EfiSysPartition > + > + @retval EFI_SUCCESS Get file system successfully > + @retval EFI_NOT_FOUND No valid file system found > + @retval others Get file system failed > + > +**/ > +EFI_STATUS > +GetEfiSysPartitionFromBootOptionFilePath ( > + IN EFI_DEVICE_PATH_PROTOCOL *DevicePath, > + OUT EFI_DEVICE_PATH_PROTOCOL **FullPath, > + OUT EFI_SIMPLE_FILE_SYSTEM_PROTOCOL **Fs > + ); > + > + > +/** > + Process Capsule On Disk. > + > + @param[in] CapsuleBuffer An array of pointer to capsule images > + @param[in] CapsuleBufferSize An array of UINTN to capsule images si= ze > + @param[in] FilePath An array of capsule images file path > + @param[in] Map File system mapping string > + @param[in] CapsuleNum The count of capsule images > + > + @retval EFI_SUCCESS Capsule on disk success. > + @retval others Capsule on disk fail. > + > +**/ > +EFI_STATUS > +ProcessCapsuleOnDisk ( > + IN VOID **CapsuleBuffer, > + IN UINTN *CapsuleBufferSize, > + IN CHAR16 **FilePath, > + IN CHAR16 *Map, > + IN UINTN CapsuleNum > + ); > + > +#endif > + > diff --git a/MdeModulePkg/Application/CapsuleApp/CapsuleApp.inf > b/MdeModulePkg/Application/CapsuleApp/CapsuleApp.inf > index 8ca5e04104..6ed0659835 100644 > --- a/MdeModulePkg/Application/CapsuleApp/CapsuleApp.inf > +++ b/MdeModulePkg/Application/CapsuleApp/CapsuleApp.inf > @@ -2,11 +2,11 @@ > # A shell application that triggers capsule update process. > # > # This application can trigger capsule update process. It can also > # generate capsule image, or dump capsule variable information. > # > -# Copyright (c) 2016 - 2018, Intel Corporation. All rights reserved. > +# Copyright (c) 2016 - 2019, Intel Corporation. All rights reserved. > # SPDX-License-Identifier: BSD-2-Clause-Patent > # > ## >=20 > [Defines] > @@ -24,10 +24,11 @@ > # VALID_ARCHITECTURES =3D IA32 X64 > # >=20 > [Sources] > CapsuleApp.c > + CapsuleApp.h > CapsuleDump.c > CapsuleOnDisk.c > AppSupport.c >=20 > [Packages] > diff --git a/MdeModulePkg/Application/CapsuleApp/CapsuleDump.c > b/MdeModulePkg/Application/CapsuleApp/CapsuleDump.c > index b81c5b7b3a..58a93568d0 100644 > --- a/MdeModulePkg/Application/CapsuleApp/CapsuleDump.c > +++ b/MdeModulePkg/Application/CapsuleApp/CapsuleDump.c > @@ -4,102 +4,11 @@ > Copyright (c) 2016 - 2019, Intel Corporation. All rights reserved.
> SPDX-License-Identifier: BSD-2-Clause-Patent >=20 > **/ >=20 > -#include > -#include > -#include > -#include > -#include > -#include > -#include > -#include > -#include > -#include > -#include > -#include > -#include > -#include > -#include > -#include > -#include > -#include > -#include > -#include > -#include > -#include > - > -// > -// (20 * (6+5+2))+1) unicode characters from EFI FAT spec (doubled for > bytes) > -// > -#define MAX_FILE_NAME_SIZE 522 > -#define MAX_FILE_NAME_LEN (MAX_FILE_NAME_SIZE / sizeof(CHAR16)) > - > -/** > - Read a file. > - > - @param[in] FileName The file to be read. > - @param[out] BufferSize The file buffer size > - @param[out] Buffer The file buffer > - > - @retval EFI_SUCCESS Read file successfully > - @retval EFI_NOT_FOUND File not found > -**/ > -EFI_STATUS > -ReadFileToBuffer ( > - IN CHAR16 *FileName, > - OUT UINTN *BufferSize, > - OUT VOID **Buffer > - ); > - > -/** > - Write a file. > - > - @param[in] FileName The file to be written. > - @param[in] BufferSize The file buffer size > - @param[in] Buffer The file buffer > - > - @retval EFI_SUCCESS Write file successfully > -**/ > -EFI_STATUS > -WriteFileFromBuffer ( > - IN CHAR16 *FileName, > - IN UINTN BufferSize, > - IN VOID *Buffer > - ); > - > -/** > - Get shell protocol. > - > - @return Pointer to shell protocol. > - > -**/ > -EFI_SHELL_PROTOCOL * > -GetShellProtocol ( > - VOID > - ); > - > -/** > - Get SimpleFileSystem from boot option file path. > - > - @param[in] DevicePath The file path of boot option > - @param[out] FullPath The full device path of boot device > - @param[out] Fs The file system within EfiSysPartition > - > - @retval EFI_SUCCESS Get file system successfully > - @retval EFI_NOT_FOUND No valid file system found > - @retval others Get file system failed > - > -**/ > -EFI_STATUS > -EFIAPI > -GetEfiSysPartitionFromBootOptionFilePath ( > - IN EFI_DEVICE_PATH_PROTOCOL *DevicePath, > - OUT EFI_DEVICE_PATH_PROTOCOL **FullPath, > - OUT EFI_SIMPLE_FILE_SYSTEM_PROTOCOL **Fs > - ); > +#include "CapsuleApp.h" >=20 > /** > Validate if it is valid capsule header >=20 > This function assumes the caller provided correct CapsuleHeader pointe= r > @@ -707,11 +616,10 @@ SplitFileNameExtension ( > @return <0 Buffer1 is less than Buffer2. > @return >0 Buffer1 is greater than Buffer2. >=20 > **/ > INTN > -EFIAPI > CompareFileNameInAlphabet ( > IN VOID *Left, > IN VOID *Right > ) > { > @@ -810,12 +718,12 @@ DumpCapsuleFromDisk ( > } >=20 > // > // Get file count first > // > + Status =3D FileHandleFindFirstFile (DirHandle, &FileInfo); > do { > - Status =3D FileHandleFindFirstFile (DirHandle, &FileInfo); > if (EFI_ERROR (Status) || FileInfo =3D=3D NULL) { > Print (L"Get File Info Fail. Status =3D %r\n", Status); > goto Done; > } >=20 > @@ -844,12 +752,12 @@ DumpCapsuleFromDisk ( > NoFile =3D FALSE; >=20 > // > // Get all file info > // > + Status =3D FileHandleFindFirstFile (DirHandle, &FileInfo); > do { > - Status =3D FileHandleFindFirstFile (DirHandle, &FileInfo); > if (EFI_ERROR (Status) || FileInfo =3D=3D NULL) { > Print (L"Get File Info Fail. Status =3D %r\n", Status); > goto Done; > } >=20 > diff --git a/MdeModulePkg/Application/CapsuleApp/CapsuleOnDisk.c > b/MdeModulePkg/Application/CapsuleApp/CapsuleOnDisk.c > index a11683d66c..382efa9aa0 100644 > --- a/MdeModulePkg/Application/CapsuleApp/CapsuleOnDisk.c > +++ b/MdeModulePkg/Application/CapsuleApp/CapsuleOnDisk.c > @@ -3,40 +3,14 @@ >=20 > Copyright (c) 2019, Intel Corporation. All rights reserved.
> SPDX-License-Identifier: BSD-2-Clause-Patent >=20 > **/ > -#include > -#include > -#include > -#include > -#include > -#include > -#include > -#include > -#include > -#include > -#include > -#include > -#include > -#include > -#include > -#include > -#include >=20 > -EFI_GUID mCapsuleOnDiskBootOptionGuid =3D { 0x4CC29BB7, 0x2413, 0x40A2, > { 0xB0, 0x6D, 0x25, 0x3E, 0x37, 0x10, 0xF5, 0x32 } }; > - > -/** > - Get shell protocol. > +#include "CapsuleApp.h" >=20 > - @return Pointer to shell protocol. > - > -**/ > -EFI_SHELL_PROTOCOL * > -GetShellProtocol ( > - VOID > - ); > +EFI_GUID mCapsuleOnDiskBootOptionGuid =3D { 0x4CC29BB7, 0x2413, 0x40A2, > { 0xB0, 0x6D, 0x25, 0x3E, 0x37, 0x10, 0xF5, 0x32 } }; >=20 > /** > Get file name from file path. >=20 > @param FilePath File path. > @@ -328,11 +302,10 @@ GetEfiSysPartitionFromDevPath ( > @retval EFI_NOT_FOUND No valid file system found > @retval others Get file system failed >=20 > **/ > EFI_STATUS > -EFIAPI > GetEfiSysPartitionFromBootOptionFilePath ( > IN EFI_DEVICE_PATH_PROTOCOL *DevicePath, > OUT EFI_DEVICE_PATH_PROTOCOL **FullPath, > OUT EFI_SIMPLE_FILE_SYSTEM_PROTOCOL **Fs > ) > @@ -396,11 +369,10 @@ GetEfiSysPartitionFromBootOptionFilePath ( > @retval EFI_NOT_FOUND No valid FS found > @retval others Get FS failed >=20 > **/ > EFI_STATUS > -EFIAPI > GetUpdateFileSystem ( > IN CHAR16 *Map, > OUT UINT16 *BootNext, > OUT EFI_SIMPLE_FILE_SYSTEM_PROTOCOL **Fs, > OUT BOOLEAN *UpdateBootNext > @@ -742,10 +714,45 @@ SetCapsuleStatusVariable ( > ); >=20 > return Status; > } >=20 > +/** > + 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 =3D sizeof(UINT64); > + Status =3D 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. >=20 > @param[in] CapsuleBuffer An array of pointer to capsule images > @param[in] CapsuleBufferSize An array of UINTN to capsule images si= ze > @@ -768,10 +775,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; > + } >=20 > // > // Get a valid file system from boot path > // > Fs =3D NULL; > @@ -780,14 +797,21 @@ ProcessCapsuleOnDisk ( > if (EFI_ERROR (Status)) { > Print (L"CapsuleApp: cannot find a valid file system on boot devies.= Status > =3D %r\n", Status); > return Status; > } >=20 > + // > + // Get file name from file path > + // > + for (Index =3D 0; Index < CapsuleNum; Index ++) { > + FileName[Index] =3D GetFileNameFromPath (FilePath[Index]); > + } > + > // > // Copy capsule image to '\efi\UpdateCapsule\' > // > - Status =3D WriteUpdateFile (CapsuleBuffer, CapsuleBufferSize, FilePath= , > CapsuleNum, Fs); > + Status =3D WriteUpdateFile (CapsuleBuffer, CapsuleBufferSize, FileName= , > CapsuleNum, Fs); > if (EFI_ERROR (Status)) { > Print (L"CapsuleApp: capsule image could not be copied for update.\n= "); > return Status; > } >=20 > -- > 2.16.2.windows.1