From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received-SPF: Pass (sender SPF authorized) identity=mailfrom; client-ip=192.55.52.115; helo=mga14.intel.com; envelope-from=jaben.carsey@intel.com; receiver=edk2-devel@lists.01.org Received: from mga14.intel.com (mga14.intel.com [192.55.52.115]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ml01.01.org (Postfix) with ESMTPS id D2D16211B85F0 for ; Fri, 25 Jan 2019 07:36:28 -0800 (PST) X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga002.fm.intel.com ([10.253.24.26]) by fmsmga103.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 25 Jan 2019 07:36:28 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.56,521,1539673200"; d="scan'208";a="137772741" Received: from fmsmsx103.amr.corp.intel.com ([10.18.124.201]) by fmsmga002.fm.intel.com with ESMTP; 25 Jan 2019 07:36:28 -0800 Received: from fmsmsx121.amr.corp.intel.com (10.18.125.36) by FMSMSX103.amr.corp.intel.com (10.18.124.201) with Microsoft SMTP Server (TLS) id 14.3.408.0; Fri, 25 Jan 2019 07:36:27 -0800 Received: from fmsmsx103.amr.corp.intel.com ([169.254.2.205]) by fmsmsx121.amr.corp.intel.com ([169.254.6.18]) with mapi id 14.03.0415.000; Fri, 25 Jan 2019 07:36:27 -0800 From: "Carsey, Jaben" To: "Gao, Liming" , "Zhang, Chao B" , "Yao, Jiewen" , "edk2-devel@lists.01.org" CC: "Wu, Hao A" , "Gao, Liming" Thread-Topic: [edk2] [PATCH 1/3] MdeModulePkg/CapsuleApp: Refine code logic of parsing parameter. Thread-Index: AQHUtHU57HK+wtbqPUSP7Q47JnGi1qXACnmAgAAQi4CAACHNAP//4ZMA Date: Fri, 25 Jan 2019 15:36:27 +0000 Message-ID: References: <20190125061341.8964-1-chen.a.chen@intel.com> <74D8A39837DF1E4DA445A8C0B3885C503F4C6564@shsmsx102.ccr.corp.intel.com> <4A89E2EF3DFEDB4C8BFDE51014F606A14E3D0750@SHSMSX104.ccr.corp.intel.com> In-Reply-To: <4A89E2EF3DFEDB4C8BFDE51014F606A14E3D0750@SHSMSX104.ccr.corp.intel.com> Accept-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-titus-metadata-40: eyJDYXRlZ29yeUxhYmVscyI6IiIsIk1ldGFkYXRhIjp7Im5zIjoiaHR0cDpcL1wvd3d3LnRpdHVzLmNvbVwvbnNcL0ludGVsMyIsImlkIjoiNzU4ZjdjYjUtYjY5MS00YWM3LTk4OTctOGJhYWE0NTQwYmVjIiwicHJvcHMiOlt7Im4iOiJDVFBDbGFzc2lmaWNhdGlvbiIsInZhbHMiOlt7InZhbHVlIjoiQ1RQX05UIn1dfV19LCJTdWJqZWN0TGFiZWxzIjpbXSwiVE1DVmVyc2lvbiI6IjE3LjEwLjE4MDQuNDkiLCJUcnVzdGVkTGFiZWxIYXNoIjoiRjlEOEFud0FZeTVib2xXaldyM2phemcyOGNIMXU3SitmY3YzbXUyU3FBN1Y1aGZHcEpcL2wwNWNRVWFyeUVSK0QifQ== x-ctpclassification: CTP_NT dlp-product: dlpe-windows dlp-version: 11.0.400.15 dlp-reaction: no-action x-originating-ip: [10.1.200.108] MIME-Version: 1.0 Subject: Re: [PATCH 1/3] MdeModulePkg/CapsuleApp: Refine code logic of parsing parameter. X-BeenThere: edk2-devel@lists.01.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: EDK II Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 25 Jan 2019 15:36:29 -0000 Content-Language: en-US Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable I think that if the application wants to depend on the libs, then we should= discuss moving the application to the ShellPkg. -Jaben > -----Original Message----- > From: edk2-devel [mailto:edk2-devel-bounces@lists.01.org] On Behalf Of > Gao, Liming > Sent: Friday, January 25, 2019 1:25 AM > To: Zhang, Chao B ; Yao, Jiewen > ; edk2-devel@lists.01.org > Cc: Wu, Hao A ; Gao, Liming > Subject: Re: [edk2] [PATCH 1/3] MdeModulePkg/CapsuleApp: Refine code > logic of parsing parameter. > Importance: High >=20 > Chao: > CapsuleApp can base on gEfiShellProtocolGuid and > gEfiShellParametersProtocolGuid to do it. Current CapsuleApp bases on > these two protocols to parse the parameters. >=20 > Thanks > Liming > From: Zhang, Chao B > Sent: Friday, January 25, 2019 3:24 PM > To: Yao, Jiewen ; edk2-devel@lists.01.org; Gao, > Liming > Cc: Wu, Hao A ; Chen, Chen A > > Subject: RE: [edk2] [PATCH 1/3] MdeModulePkg/CapsuleApp: Refine code > logic of parsing parameter. >=20 > Jiewen & Liming: > It is a problem. Unlike UiApp. CapsuleApp is supposed to run in Shell. > ShellLib provides standard parameter parsing support. > Any suggestion on this? >=20 > From: Yao, Jiewen > Sent: Friday, January 25, 2019 2:25 PM > To: Chen, Chen A > >; edk2- > devel@lists.01.org > Cc: Wu, Hao A >; Zhang, > Chao B > > Subject: RE: [edk2] [PATCH 1/3] MdeModulePkg/CapsuleApp: Refine code > logic of parsing parameter. >=20 > Hey > I don't think MdeModulePkg can depend on ShellPkg. >=20 > That is why we do not use ShellLib in the first version. >=20 > Do we change the package dependency rule? >=20 > Thank you > Yao Jiewen >=20 > > -----Original Message----- > > From: edk2-devel [mailto:edk2-devel-bounces@lists.01.org] On Behalf Of > > Chen A Chen > > Sent: Friday, January 25, 2019 2:14 PM > > To: edk2-devel@lists.01.org > > Cc: Wu, Hao A >; > Zhang, Chao B > > > > > Subject: [edk2] [PATCH 1/3] MdeModulePkg/CapsuleApp: Refine code > logic > > of parsing parameter. > > > > BZ:https://bugzilla.tianocore.org/show_bug.cgi?id=3D1482 > > > > No change functionality, use ShellLib to parsing command line. > > > > Cc: Jian J Wang > > > Cc: Hao Wu > > > Cc: Zhang Chao B > > > > Contributed-under: TianoCore Contribution Agreement 1.1 > > Signed-off-by: Chen A Chen > > > > --- > > MdeModulePkg/Application/CapsuleApp/CapsuleApp.c | 433 > > +++++++++++---------- > > MdeModulePkg/Application/CapsuleApp/CapsuleApp.inf | 2 + > > 2 files changed, 236 insertions(+), 199 deletions(-) > > > > diff --git a/MdeModulePkg/Application/CapsuleApp/CapsuleApp.c > > b/MdeModulePkg/Application/CapsuleApp/CapsuleApp.c > > index 4d907242f3..acae0fe261 100644 > > --- a/MdeModulePkg/Application/CapsuleApp/CapsuleApp.c > > +++ b/MdeModulePkg/Application/CapsuleApp/CapsuleApp.c > > @@ -27,6 +27,7 @@ > > #include > > #include > > #include > > +#include > > > > #define CAPSULE_HEADER_SIZE 0x20 > > > > @@ -39,15 +40,27 @@ > > > > #define MAX_CAPSULE_NUM 10 > > > > -extern UINTN Argc; > > -extern CHAR16 **Argv; > > - > > // > > // Define how many block descriptors we want to test with. > > // > > UINTN NumberOfDescriptors =3D 1; > > -UINTN CapsuleFirstIndex; > > -UINTN CapsuleLastIndex; > > + > > +STATIC CONST SHELL_PARAM_ITEM ParamList[] =3D { > > + {L"-C", TypeFlag}, > > + {L"-E", TypeFlag}, > > + {L"-S", TypeFlag}, > > + > > + {L"-NR", TypeFlag}, > > + > > + {L"-G", TypeValue}, > > + {L"-O", TypeValue}, > > + {L"-N", TypeValue}, > > + {L"-D", TypeValue}, > > + {L"-P", TypeValue}, > > + {L"-I", TypeValue}, > > + > > + {NULL, TypeMax} > > + }; > > > > /** > > Dump capsule information > > @@ -161,13 +174,12 @@ GetArg ( > > **/ > > EFI_STATUS > > CreateBmpFmp ( > > - VOID > > + IN CHAR16 *BmpName, > > + IN CHAR16 > > *OutputCapsuleName > > ) > > { > > - CHAR16 > > *OutputCapsuleName; > > VOID *BmpBuffer; > > UINTN FileSize; > > - CHAR16 *BmpName; > > UINT8 > > *FullCapsuleBuffer; > > UINTN > > FullCapsuleBufferSize; > > EFI_DISPLAY_CAPSULE *DisplayCapsule; > > @@ -191,22 +203,10 @@ CreateBmpFmp ( > > // HorizontalResolution >=3D BMP_IMAGE_HEADER.PixelWidth > > // VerticalResolution >=3D BMP_IMAGE_HEADER.PixelHeight > > > > - if (Argc !=3D 5) { > > - Print(L"CapsuleApp: Incorrect parameter count.\n"); > > - return EFI_UNSUPPORTED; > > - } > > - > > - if (StrCmp(Argv[3], L"-O") !=3D 0) { > > - Print(L"CapsuleApp: NO output capsule name.\n"); > > - return EFI_UNSUPPORTED; > > - } > > - OutputCapsuleName =3D Argv[4]; > > - > > BmpBuffer =3D NULL; > > FileSize =3D 0; > > FullCapsuleBuffer =3D NULL; > > > > - BmpName =3D Argv[2]; > > Status =3D ReadFileToBuffer(BmpName, &FileSize, &BmpBuffer); > > if (EFI_ERROR(Status)) { > > Print(L"CapsuleApp: BMP image (%s) is not found.\n", BmpName); > > @@ -425,13 +425,12 @@ IsFmpCapsuleGuid ( > > **/ > > EFI_STATUS > > CreateNestedFmp ( > > - VOID > > + IN CHAR16 *CapsuleName, > > + IN CHAR16 > > *OutputCapsuleName > > ) > > { > > - CHAR16 > > *OutputCapsuleName; > > VOID *CapsuleBuffer; > > UINTN FileSize; > > - CHAR16 *CapsuleName; > > UINT8 > > *FullCapsuleBuffer; > > UINTN > > FullCapsuleBufferSize; > > EFI_CAPSULE_HEADER > > *NestedCapsuleHeader; > > @@ -439,22 +438,10 @@ CreateNestedFmp ( > > UINT32 FwType; > > EFI_STATUS Status; > > > > - if (Argc !=3D 5) { > > - Print(L"CapsuleApp: Incorrect parameter count.\n"); > > - return EFI_UNSUPPORTED; > > - } > > - > > - if (StrCmp(Argv[3], L"-O") !=3D 0) { > > - Print(L"CapsuleApp: NO output capsule name.\n"); > > - return EFI_UNSUPPORTED; > > - } > > - OutputCapsuleName =3D Argv[4]; > > - > > CapsuleBuffer =3D NULL; > > FileSize =3D 0; > > FullCapsuleBuffer =3D NULL; > > > > - CapsuleName =3D Argv[2]; > > Status =3D ReadFileToBuffer(CapsuleName, &FileSize, &CapsuleBuffer); > > if (EFI_ERROR(Status)) { > > Print(L"CapsuleApp: Capsule image (%s) is not found.\n", > > CapsuleName); > > @@ -807,7 +794,7 @@ PrintUsage ( > > Print(L" CapsuleApp -G -O \n"); > > Print(L" CapsuleApp -N -O \n"); > > Print(L" CapsuleApp -D \n"); > > - Print(L" CapsuleApp -P GET -O \n"); > > + Print(L" CapsuleApp -P -I -O \n"); > > Print(L"Parameter:\n"); > > Print(L" -NR: No reset will be triggered for the capsule with\n"); > > Print(L" CAPSULE_FLAGS_PERSIST_ACROSS_RESET and > > without\n"); > > @@ -817,8 +804,7 @@ PrintUsage ( > > 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"); > > - Print(L" ImageTypeId and Index (decimal format) to a file if > > 'GET'\n"); > > - Print(L" option is used.\n"); > > + Print(L" ImageTypeId and Index (decimal format) to a file\n"); > > Print(L" -E: Dump UEFI ESRT table info.\n"); > > Print(L" -G: Convert a BMP file to be an UX capsule,\n"); > > Print(L" according to Windows Firmware Update document\n"); > > @@ -851,206 +837,255 @@ UefiMain ( > > { > > EFI_STATUS Status; > > RETURN_STATUS RStatus; > > - UINTN FileSize[MAX_CAPSULE_NUM]; > > VOID > > *CapsuleBuffer[MAX_CAPSULE_NUM]; > > - EFI_CAPSULE_BLOCK_DESCRIPTOR *BlockDescriptors; > > EFI_CAPSULE_HEADER > > *CapsuleHeaderArray[MAX_CAPSULE_NUM + 1]; > > - UINT64 MaxCapsuleSize; > > + EFI_CAPSULE_BLOCK_DESCRIPTOR *BlockDescriptors; > > EFI_RESET_TYPE ResetType; > > + UINT64 MaxCapsuleSize; > > + LIST_ENTRY *Package; > > + CHAR16 *ProblemParam; > > + CHAR16 *BmpFileName; > > + CHAR16 *CapsuleFileName; > > + CHAR16 *OutputFileName; > > + CHAR16 *GuidStr; > > + CHAR16 *IndexStr; > > + EFI_GUID ImageTypeGuid; > > + BOOLEAN NoResetFlag; > > BOOLEAN NeedReset; > > - BOOLEAN NoReset; > > - CHAR16 *CapsuleName; > > + UINTN > > CapsuleBufferSize[MAX_CAPSULE_NUM]; > > UINTN CapsuleNum; > > - UINTN Index; > > - EFI_GUID ImageTypeId; > > UINTN ImageIndex; > > + UINTN FlagCount; > > + UINTN Index; > > > > - Status =3D GetArg(); > > - if (EFI_ERROR(Status)) { > > - Print(L"Please use UEFI SHELL to run this application!\n", Status)= ; > > - return Status; > > - } > > - if (Argc < 2) { > > - PrintUsage(); > > - return EFI_UNSUPPORTED; > > + Status =3D EFI_SUCCESS; > > + NoResetFlag =3D FALSE; > > + FlagCount =3D 0; > > + > > + ZeroMem (&CapsuleBuffer, sizeof (CapsuleBuffer)); > > + ZeroMem (&CapsuleBufferSize, sizeof (CapsuleBufferSize)); > > + > > + Status =3D ShellCommandLineParse (ParamList, &Package, > &ProblemParam, > > TRUE); > > + if (EFI_ERROR (Status)) { > > + PrintUsage (); > > + Status =3D EFI_UNSUPPORTED; > > + goto Done; > > } > > - if (StrCmp(Argv[1], L"-D") =3D=3D 0) { > > - if (Argc !=3D 3) { > > - Print(L"CapsuleApp: Incorrect parameter count.\n"); > > - return EFI_UNSUPPORTED; > > + > > + for (Index =3D 0; ParamList[Index].Type !=3D TypeMax; Index++) { > > + if (ShellCommandLineGetFlag (Package, ParamList[Index].Name)) { > > + FlagCount++; > > } > > - Status =3D DumpCapsule(Argv[2]); > > - return Status; > > - } > > - if (StrCmp(Argv[1], L"-G") =3D=3D 0) { > > - Status =3D CreateBmpFmp(); > > - return Status; > > - } > > - if (StrCmp(Argv[1], L"-N") =3D=3D 0) { > > - Status =3D CreateNestedFmp(); > > - return Status; > > } > > - if (StrCmp(Argv[1], L"-S") =3D=3D 0) { > > - Status =3D DumpCapsuleStatusVariable(); > > - return EFI_SUCCESS; > > - } > > - if (StrCmp(Argv[1], L"-C") =3D=3D 0) { > > - Status =3D ClearCapsuleStatusVariable(); > > - return Status; > > - } > > - if (StrCmp(Argv[1], L"-P") =3D=3D 0) { > > - if (Argc =3D=3D 2) { > > - DumpFmpData(); > > - } > > - if (Argc >=3D 3) { > > - if (StrCmp(Argv[2], L"GET") !=3D 0) { > > - Print(L"CapsuleApp: Unrecognized option(%s).\n", Argv[2]); > > - return EFI_UNSUPPORTED; > > - } else { > > - if (Argc !=3D 7) { > > - Print(L"CapsuleApp: Incorrect parameter count.\n"); > > - return EFI_UNSUPPORTED; > > - } > > > > - // > > - // FMP->GetImage() > > - // > > - RStatus =3D StrToGuid (Argv[3], &ImageTypeId); > > - if (RETURN_ERROR (RStatus) || > > (Argv[3][GUID_STRING_LENGTH] !=3D L'\0')) { > > - Print (L"Invalid ImageTypeId - %s\n", Argv[3]); > > - return EFI_INVALID_PARAMETER; > > - } > > - ImageIndex =3D StrDecimalToUintn(Argv[4]); > > - if (StrCmp(Argv[5], L"-O") !=3D 0) { > > - Print(L"CapsuleApp: NO output file name.\n"); > > - return EFI_UNSUPPORTED; > > + CapsuleNum =3D ShellCommandLineGetCount (Package) - 1; > > + > > + if (CapsuleNum =3D=3D 0) { > > + if (FlagCount =3D=3D 1) { > > + // > > + // CapsuleApp -C > > + // > > + if (ShellCommandLineGetFlag (Package, L"-C")) { > > + Status =3D ClearCapsuleStatusVariable(); > > + } > > + > > + // > > + // CapsuleApp -D > > + // > > + if (ShellCommandLineGetFlag (Package, L"-D")) { > > + CapsuleFileName =3D (CHAR16 *)ShellCommandLineGetValue > > (Package, L"-D"); > > + if (CapsuleFileName !=3D NULL) { > > + Status =3D DumpCapsule (CapsuleFileName); > > + } else { > > + Print (L"CapsuleApp: Incorrect Parameter Count.\n"); > > + Status =3D EFI_UNSUPPORTED; > > } > > - DumpFmpImage(&ImageTypeId, ImageIndex, Argv[6]); > > } > > - } > > - return EFI_SUCCESS; > > - } > > > > - if (StrCmp(Argv[1], L"-E") =3D=3D 0) { > > - DumpEsrtData(); > > - return EFI_SUCCESS; > > - } > > + // > > + // CapsuleApp -E > > + // > > + if (ShellCommandLineGetFlag (Package, L"-E")) { > > + DumpEsrtData (); > > + } > > > > - if (Argv[1][0] =3D=3D L'-') { > > - Print(L"CapsuleApp: Unrecognized option(%s).\n", Argv[1]); > > - return EFI_UNSUPPORTED; > > - } > > + // > > + // CapsuleApp -P > > + // > > + if (ShellCommandLineGetFlag (Package, L"-P")) { > > + DumpFmpData (); > > + } > > > > - CapsuleFirstIndex =3D 1; > > - NoReset =3D FALSE; > > - if ((Argc > 1) && (StrCmp(Argv[Argc - 1], L"-NR") =3D=3D 0)) { > > - NoReset =3D TRUE; > > - CapsuleLastIndex =3D Argc - 2; > > - } else { > > - CapsuleLastIndex =3D Argc - 1; > > - } > > - CapsuleNum =3D CapsuleLastIndex - CapsuleFirstIndex + 1; > > + // > > + // CapsuleApp -S > > + // > > + if (ShellCommandLineGetFlag (Package, L"-S")) { > > + Status =3D DumpCapsuleStatusVariable (); > > + } > > + } > > > > - if (CapsuleFirstIndex > CapsuleLastIndex) { > > - Print(L"CapsuleApp: NO capsule image.\n"); > > - return EFI_UNSUPPORTED; > > - } > > - if (CapsuleNum > MAX_CAPSULE_NUM) { > > - Print(L"CapsuleApp: Too many capsule images.\n"); > > - return EFI_UNSUPPORTED; > > - } > > + if (FlagCount =3D=3D 2) { > > + // > > + // CapsuleApp -G -O > > + // > > + if (ShellCommandLineGetFlag (Package, L"-G") && > > ShellCommandLineGetFlag (Package, L"-O")) { > > + BmpFileName =3D (CHAR16 *)ShellCommandLineGetValue > > (Package, L"-G"); > > + OutputFileName =3D (CHAR16 *)ShellCommandLineGetValue > > (Package, L"-O"); > > + if (BmpFileName !=3D NULL && OutputFileName !=3D NULL) { > > + Status =3D CreateBmpFmp (BmpFileName, OutputFileName); > > + } else { > > + Print (L"CapsuleApp: Incorrect Parameter Count.\n"); > > + Status =3D EFI_UNSUPPORTED; > > + } > > + } > > > > - ZeroMem(&CapsuleBuffer, sizeof(CapsuleBuffer)); > > - ZeroMem(&FileSize, sizeof(FileSize)); > > - BlockDescriptors =3D NULL; > > + // > > + // CapsuleApp -N -O > > + // > > + if (ShellCommandLineGetFlag (Package, L"-N") && > > ShellCommandLineGetFlag (Package ,L"-O")) { > > + CapsuleFileName =3D (CHAR16 *)ShellCommandLineGetValue > > (Package, L"-N"); > > + OutputFileName =3D (CHAR16 *)ShellCommandLineGetValue > > (Package, L"-O"); > > + if (CapsuleFileName !=3D NULL && OutputFileName !=3D NULL) { > > + Status =3D CreateNestedFmp (CapsuleFileName, > > OutputFileName); > > + } else { > > + Print (L"CapsuleApp: Incorrect Parameter Count.\n"); > > + Status =3D EFI_UNSUPPORTED; > > + } > > + } > > + } > > > > - for (Index =3D 0; Index < CapsuleNum; Index++) { > > - CapsuleName =3D Argv[CapsuleFirstIndex + Index]; > > - Status =3D ReadFileToBuffer(CapsuleName, &FileSize[Index], > > &CapsuleBuffer[Index]); > > - if (EFI_ERROR(Status)) { > > - Print(L"CapsuleApp: capsule image (%s) is not found.\n", > > CapsuleName); > > + if (FlagCount =3D=3D 3) { > > + // > > + // CapsuleApp -P -I -O > > > > + // > > + if ( ShellCommandLineGetFlag (Package, L"-P") && > > + ShellCommandLineGetFlag (Package, L"-I") && > > + ShellCommandLineGetFlag (Package, L"-O") > > + ) { > > + GuidStr =3D (CHAR16 *)ShellCommandLineGetValue > > (Package, L"-P"); > > + IndexStr =3D (CHAR16 *)ShellCommandLineGetValue > > (Package, L"-I"); > > + OutputFileName =3D (CHAR16 *)ShellCommandLineGetValue > > (Package, L"-O"); > > + if (GuidStr !=3D NULL && IndexStr !=3D NULL && OutputFileName = !=3D > > NULL) { > > + RStatus =3D StrToGuid (GuidStr, &ImageTypeGuid); > > + if (EFI_ERROR (RStatus) || GuidStr[GUID_STRING_LENGTH] !=3D > > L'\0') { > > + Print (L"Invalid ImageTypeId - %s\n", GuidStr); > > + Status =3D EFI_INVALID_PARAMETER; > > + goto Done; > > + } > > + ImageIndex =3D StrDecimalToUintn (IndexStr); > > + DumpFmpImage (&ImageTypeGuid, ImageIndex, > > OutputFileName); > > + } else { > > + Print (L"CapsuleApp: Incorrect Parameter Count.\n"); > > + Status =3D EFI_UNSUPPORTED; > > + } > > + } > > + } > > + } else { > > + if (CapsuleNum > MAX_CAPSULE_NUM) { > > + Print(L"CapsuleApp: Too many capsule images.\n"); > > + Status =3D EFI_UNSUPPORTED; > > goto Done; > > } > > - if (!IsValidCapsuleHeader (CapsuleBuffer[Index], FileSize[Index]))= { > > - Print(L"CapsuleApp: Capsule image (%s) is not a valid capsule.\n= ", > > CapsuleName); > > - return EFI_INVALID_PARAMETER; > > + > > + if (ShellCommandLineGetFlag (Package, L"-NR")) { > > + NoResetFlag =3D TRUE; > > } > > - } > > > > - // > > - // Every capsule use 2 descriptor 1 for data 1 for end > > - // > > - Status =3D BuildGatherList(CapsuleBuffer, FileSize, CapsuleNum, > > &BlockDescriptors); > > - if (EFI_ERROR(Status)) { > > - goto Done; > > - } > > + for (Index =3D 0; Index < CapsuleNum; Index++) { > > + CapsuleFileName =3D (CHAR16 *)ShellCommandLineGetRawValue > > (Package, Index + 1); > > + Status =3D ReadFileToBuffer (CapsuleFileName, > > &CapsuleBufferSize[Index], &CapsuleBuffer[Index]); > > + if (EFI_ERROR (Status)) { > > + Print (L"CapsuleApp: capsule image (%s) is not found.\n", > > CapsuleFileName); > > + goto Done; > > + } > > + if (!IsValidCapsuleHeader (CapsuleBuffer[Index], > > CapsuleBufferSize[Index])) { > > + Print (L"CapsuleApp: Capsule image (%s) is not a valid capsule= .\n", > > CapsuleFileName); > > + Status =3D EFI_INVALID_PARAMETER; > > + goto Done; > > + } > > + } > > > > - // > > - // Call the runtime service capsule. > > - // > > - NeedReset =3D FALSE; > > - for (Index =3D 0; Index < CapsuleNum; Index++) { > > - CapsuleHeaderArray[Index] =3D (EFI_CAPSULE_HEADER *) > > CapsuleBuffer[Index]; > > - if ((CapsuleHeaderArray[Index]->Flags & > > CAPSULE_FLAGS_PERSIST_ACROSS_RESET) !=3D 0) { > > - NeedReset =3D TRUE; > > + // > > + // Every capsule use 2 descriptor 1 for data 1 for end > > + // > > + BlockDescriptors =3D NULL; > > + Status =3D BuildGatherList (CapsuleBuffer, CapsuleBufferSize, > > CapsuleNum, &BlockDescriptors); > > + if (EFI_ERROR (Status)) { > > + Print (L"Build Gather List Fail, %r\n", Status); > > + goto Done; > > } > > - } > > - CapsuleHeaderArray[CapsuleNum] =3D NULL; > > > > - // > > - // Inquire platform capability of UpdateCapsule. > > - // > > - Status =3D gRT->QueryCapsuleCapabilities (CapsuleHeaderArray, > > CapsuleNum, &MaxCapsuleSize, &ResetType); > > - if (EFI_ERROR(Status)) { > > - Print (L"CapsuleApp: failed to query capsule capability - %r\n", S= tatus); > > - goto Done; > > - } > > + // > > + // Call the runtime service capsule. > > + // > > + NeedReset =3D FALSE; > > + for (Index =3D 0; Index < CapsuleNum; Index++) { > > + CapsuleHeaderArray[Index] =3D (EFI_CAPSULE_HEADER *) > > CapsuleBuffer[Index]; > > + if ((CapsuleHeaderArray[Index]->Flags & > > CAPSULE_FLAGS_PERSIST_ACROSS_RESET) !=3D 0) { > > + NeedReset =3D TRUE; > > + } > > + } > > + CapsuleHeaderArray[CapsuleNum] =3D NULL; > > > > - for (Index =3D 0; Index < CapsuleNum; Index++) { > > - if (FileSize[Index] > MaxCapsuleSize) { > > - Print (L"CapsuleApp: capsule is too large to update, %ld is > > allowed\n", MaxCapsuleSize); > > - Status =3D EFI_UNSUPPORTED; > > + // > > + // Inquire platform capability of UpdateCapsule. > > + // > > + Status =3D gRT->QueryCapsuleCapabilities (CapsuleHeaderArray, > > CapsuleNum, &MaxCapsuleSize, &ResetType); > > + if (EFI_ERROR (Status)) { > > + Print (L"CapsuleApp: failed to query capsule capability - %r\n", > > Status); > > goto Done; > > } > > - } > > > > - // > > - // Check whether the input capsule image has the flag of persist acr= oss > > system reset. > > - // > > - if (NeedReset) { > > - Status =3D > > gRT->UpdateCapsule(CapsuleHeaderArray,CapsuleNum,(UINTN) > > BlockDescriptors); > > - if (Status !=3D EFI_SUCCESS) { > > - Print (L"CapsuleApp: failed to update capsule - %r\n", Status); > > - goto Done; > > + for (Index =3D 0; Index < CapsuleNum; Index++) { > > + if (CapsuleBufferSize[Index] > MaxCapsuleSize) { > > + Print (L"CapsuleApp: capsule is too large to update, %ld is > > allowed\n", MaxCapsuleSize); > > + Status =3D EFI_UNSUPPORTED; > > + goto Done; > > + } > > } > > + > > // > > - // For capsule with CAPSULE_FLAGS_PERSIST_ACROSS_RESET + > > CAPSULE_FLAGS_INITIATE_RESET, > > - // a system reset should have been triggered by gRT->UpdateCapsule= () > > calling above. > > - // > > - // For capsule with CAPSULE_FLAGS_PERSIST_ACROSS_RESET and > > without CAPSULE_FLAGS_INITIATE_RESET, > > - // check if -NR (no-reset) has been specified or not. > > + // Check whether the input capsule image has the flag of persist a= cross > > system reset. > > // > > - if (!NoReset) { > > + if (NeedReset) { > > + Status =3D gRT->UpdateCapsule > > (CapsuleHeaderArray,CapsuleNum,(UINTN) BlockDescriptors); > > + if (Status !=3D EFI_SUCCESS) { > > + Print (L"CapsuleApp: failed to update capsule - %r\n", Status)= ; > > + goto Done; > > + } > > // > > - // For capsule who has reset flag and no -NR (no-reset) has been > > specified, after calling UpdateCapsule service, > > - // trigger a system reset to process capsule persist across a sy= stem > > reset. > > + // For capsule with CAPSULE_FLAGS_PERSIST_ACROSS_RESET + > > CAPSULE_FLAGS_INITIATE_RESET, > > + // a system reset should have been triggered by > > gRT->UpdateCapsule() calling above. > > // > > - gRT->ResetSystem (ResetType, EFI_SUCCESS, 0, NULL); > > - } > > - } else { > > - // > > - // For capsule who has no reset flag, only call UpdateCapsule Serv= ice > > without a > > - // system reset. The service will process the capsule immediately. > > - // > > - Status =3D gRT->UpdateCapsule > > (CapsuleHeaderArray,CapsuleNum,(UINTN) BlockDescriptors); > > - if (Status !=3D EFI_SUCCESS) { > > - Print (L"CapsuleApp: failed to update capsule - %r\n", Status); > > + // For capsule with CAPSULE_FLAGS_PERSIST_ACROSS_RESET and > > without CAPSULE_FLAGS_INITIATE_RESET, > > + // check if -NR (no-reset) has been specified or not. > > + // > > + if (!NoResetFlag) { > > + // > > + // For capsule who has reset flag and no -NR (no-reset) has be= en > > specified, after calling UpdateCapsule service, > > + // trigger a system reset to process capsule persist across a > > system reset. > > + // > > + gRT->ResetSystem (ResetType, EFI_SUCCESS, 0, NULL); > > + } > > + } else { > > + // > > + // For capsule who has no reset flag, only call UpdateCapsule > > Service without a > > + // system reset. The service will process the capsule immediatel= y. > > + // > > + Status =3D gRT->UpdateCapsule > > (CapsuleHeaderArray,CapsuleNum,(UINTN) BlockDescriptors); > > + if (Status !=3D EFI_SUCCESS) { > > + Print (L"CapsuleApp: failed to update capsule - %r\n", Status)= ; > > + } > > } > > - } > > > > - Status =3D EFI_SUCCESS; > > + Status =3D EFI_SUCCESS; > > + } > > > > Done: > > + if (Package !=3D NULL) { > > + ShellCommandLineFreeVarList (Package); > > + } > > + > > for (Index =3D 0; Index < CapsuleNum; Index++) { > > if (CapsuleBuffer[Index] !=3D NULL) { > > FreePool (CapsuleBuffer[Index]); > > diff --git a/MdeModulePkg/Application/CapsuleApp/CapsuleApp.inf > > b/MdeModulePkg/Application/CapsuleApp/CapsuleApp.inf > > index 8a21875286..d4edc539cc 100644 > > --- a/MdeModulePkg/Application/CapsuleApp/CapsuleApp.inf > > +++ b/MdeModulePkg/Application/CapsuleApp/CapsuleApp.inf > > @@ -38,6 +38,7 @@ > > [Packages] > > MdePkg/MdePkg.dec > > MdeModulePkg/MdeModulePkg.dec > > + ShellPkg/ShellPkg.dec > > > > [Guids] > > gEfiCapsuleReportGuid ## CONSUMES ## GUID > > @@ -61,6 +62,7 @@ > > UefiLib > > PrintLib > > BmpSupportLib > > + ShellLib > > > > [UserExtensions.TianoCore."ExtraFiles"] > > CapsuleAppExtra.uni > > -- > > 2.16.2.windows.1 > > > > _______________________________________________ > > edk2-devel mailing list > > edk2-devel@lists.01.org > > https://lists.01.org/mailman/listinfo/edk2-devel > _______________________________________________ > edk2-devel mailing list > edk2-devel@lists.01.org > https://lists.01.org/mailman/listinfo/edk2-devel