From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mga01.intel.com (mga01.intel.com [192.55.52.88]) by mx.groups.io with SMTP id smtpd.web11.11557.1582117311676851170 for ; Wed, 19 Feb 2020 05:01:51 -0800 Authentication-Results: mx.groups.io; dkim=missing; spf=pass (domain: intel.com, ip: 192.55.52.88, mailfrom: liming.gao@intel.com) X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga002.jf.intel.com ([10.7.209.21]) by fmsmga101.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 19 Feb 2020 05:01:51 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.70,459,1574150400"; d="scan'208";a="254090672" Received: from fmsmsx105.amr.corp.intel.com ([10.18.124.203]) by orsmga002.jf.intel.com with ESMTP; 19 Feb 2020 05:01:51 -0800 Received: from shsmsx603.ccr.corp.intel.com (10.109.6.143) by FMSMSX105.amr.corp.intel.com (10.18.124.203) with Microsoft SMTP Server (TLS) id 14.3.439.0; Wed, 19 Feb 2020 05:01:50 -0800 Received: from shsmsx606.ccr.corp.intel.com (10.109.6.216) by SHSMSX603.ccr.corp.intel.com (10.109.6.143) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.1713.5; Wed, 19 Feb 2020 21:01:48 +0800 Received: from shsmsx606.ccr.corp.intel.com ([10.109.6.216]) by SHSMSX606.ccr.corp.intel.com ([10.109.6.216]) with mapi id 15.01.1713.004; Wed, 19 Feb 2020 21:01:48 +0800 From: "Liming Gao" To: "Feng, YunhuaX" , "devel@edk2.groups.io" CC: "Feng, Bob C" Subject: Re: [PATCH] [edk2-staging/FceFmmt]BaseTools: Support no UI section FFS Thread-Topic: [PATCH] [edk2-staging/FceFmmt]BaseTools: Support no UI section FFS Thread-Index: AdXhbPXXPt0kAHFuQoujAM2mrLZ8QgFt8ZLw Date: Wed, 19 Feb 2020 13:01:48 +0000 Message-ID: <323f9c9661324c0c8c717b7aafdbe519@intel.com> References: <76e7103d62124617807608ab3643ca53@intel.com> In-Reply-To: <76e7103d62124617807608ab3643ca53@intel.com> Accept-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: dlp-version: 11.2.0.6 dlp-product: dlpe-windows dlp-reaction: no-action x-originating-ip: [10.239.127.36] MIME-Version: 1.0 Return-Path: liming.gao@intel.com Content-Language: en-US Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable Reviewed-by: Liming Gao > -----Original Message----- > From: Feng, YunhuaX > Sent: Wednesday, February 12, 2020 2:24 PM > To: devel@edk2.groups.io > Cc: Gao, Liming ; Feng, Bob C > Subject: [PATCH] [edk2-staging/FceFmmt]BaseTools: Support no UI section F= FS >=20 > REF: https://bugzilla.tianocore.org/show_bug.cgi?id=3D2521 >=20 > 1. If FFS file has no UI section, its FILE_GUID will be used as its name. > FMMT tool -d/-a/-r option can be updated to support such FFS file. > 2. -v option will print FILE_GUID if no UI section >=20 > Cc: Bob Feng > Cc: Liming Gao > Signed-off-by: Yunhua Feng > --- > BaseTools/Source/C/FMMT/FirmwareModuleManagement.c | 22 +++++++-- > BaseTools/Source/C/FMMT/FmmtLib.c | 56 ++++++++++++++++= ++++++ > 2 files changed, 73 insertions(+), 5 deletions(-) >=20 > diff --git a/BaseTools/Source/C/FMMT/FirmwareModuleManagement.c b/BaseToo= ls/Source/C/FMMT/FirmwareModuleManagement.c > index e4fbb5461f..a786113899 100644 > --- a/BaseTools/Source/C/FMMT/FirmwareModuleManagement.c > +++ b/BaseTools/Source/C/FMMT/FirmwareModuleManagement.c > @@ -79,11 +79,11 @@ Usage ( > Delete the entire FV in an FD binary\n"); >=20 > // > // Command Line for Delete file from FV > // > - fprintf (stdout, " -d [ ...] \n\ > + fprintf (stdout, " -d [ ...] \n\ > Delete a file (or files) from the firmware volume in an FD b= inary\n"); >=20 > // > // Command Line for Add > // > @@ -91,11 +91,11 @@ Usage ( > Add a file (or files) to the firmware volume in an FD binary= \n"); >=20 > // > // Command Line for Replace > // > - fprintf (stdout, " -r [ ...] file>\n\ > + fprintf (stdout, " -r [ > ...] \n\ > The replace command combines the functionality of remove and= add into a single operation.\n"); >=20 > fprintf (stdout, "\nNote:\n"); > fprintf (stdout, " is the sequence of the firmware volume inc= luded in the FD image, it both support the sequentially format like > FV0, FV1 and the FV's file guid value format.\n"); > return; > @@ -583,10 +583,11 @@ NeedNewPath(FV_INFORMATION *FvInFd, CHAR8 *FvId, UI= NT32 FileIndex, BOOLEAN IsAdd > static UINT32 FindFile(FV_INFORMATION *FvInFd, UINT8 FvLevel, CHAR8 *Fil= e, UINT32 *MatchIndex) { > UINT32 Index =3D 0; > CHAR16 *UIName; > CHAR16 *FfsUIName; > UINT32 FileNumber =3D 0; > + EFI_GUID Guid; >=20 > UIName =3D (CHAR16 *)malloc(_MAX_PATH); > if (NULL =3D=3D UIName) { > return 0; > } > @@ -612,11 +613,22 @@ static UINT32 FindFile(FV_INFORMATION *FvInFd, UINT= 8 FvLevel, CHAR8 *File, UINT3 > } >=20 > } > free(UIName); > free(FfsUIName); > - > + if (FileNumber =3D=3D 0) { > + StringToGuid(File, &Guid); > + for (Index =3D 0; Index <=3D FvInFd->FfsNumbers; Index++) { > + if (CompareGuid (&Guid, &FvInFd->FfsAttuibutes[Index].GuidName) = =3D=3D 0) { > + FileNumber +=3D 1; > + *MatchIndex =3D Index; > + if (FileNumber > 1) { > + break; > + } > + } > + } > + } > return FileNumber; > } >=20 > /** > Search the config file from the path list. > @@ -1089,11 +1101,11 @@ FmmtImageAdd( > goto FAILED; > } > HasUISection =3D FALSE; > HasUISection =3D ParseSection(InputFfs); > if (!HasUISection) { > - printf ("WARNING: The newly add file must have a user interf= ace (UI) section, otherwise it cannot be deleted or replaced. \n"); > + printf ("WARNING: The newly add file not have a user interfa= ce (UI) section. \n"); > } > if (NeedNewPath(FvInFd, FvId, 0, TRUE)) { > do { > NewFile =3D NewFileNode->FileName; > // > @@ -1845,11 +1857,11 @@ FmmtImageReplace ( > return EFI_ABORTED; > } > HasUISection =3D FALSE; > HasUISection =3D ParseSection(InputFfs); > if (!HasUISection) { > - printf ("WARNING: The newly replace file must have a user in= terface (UI) section, otherwise it cannot be deleted or replaced. \n"); > + printf ("WARNING: The newly replace file not have a user int= erface (UI) section. \n"); > } > if (FfsFoundFlag && NeedNewPath(FvInFd, FvId, Index, FALSE)) { > do { > OldFile =3D OldFileNode -> FileName; > NewFile =3D NewFileNode -> FileName; > diff --git a/BaseTools/Source/C/FMMT/FmmtLib.c b/BaseTools/Source/C/FMMT/= FmmtLib.c > index 78b6f3a21d..685ef634f2 100644 > --- a/BaseTools/Source/C/FMMT/FmmtLib.c > +++ b/BaseTools/Source/C/FMMT/FmmtLib.c > @@ -824,10 +824,11 @@ LibParseSection ( > UINT16 GuidAttr; > UINT16 DataOffset; > CHAR8 *UIFileName; > CHAR8 *ToolInputFileName; > CHAR8 *ToolOutputFileName; > + BOOLEAN HasUiSection; >=20 > DataOffset =3D 0; > GuidAttr =3D 0; > ParsedLength =3D 0; > ToolOutputLength =3D 0; > @@ -858,10 +859,11 @@ LibParseSection ( > ToolInputFileName =3D NULL; > ToolOutputFileFullName =3D NULL; > HasDepexSection =3D FALSE; > EncapDataNeedUpdata =3D TRUE; > LargeHeaderOffset =3D 0; > + HasUiSection =3D FALSE; >=20 >=20 > while (ParsedLength < BufferLength) { > Ptr =3D SectionBuffer + ParsedLength; >=20 > @@ -888,10 +890,11 @@ LibParseSection ( > switch (Type) { >=20 > case EFI_SECTION_FIRMWARE_VOLUME_IMAGE: >=20 > EncapDataNeedUpdata =3D TRUE; > + HasUiSection =3D TRUE; >=20 > Level ++; > NumberOfSections ++; >=20 > CurrentFv->FfsAttuibutes[*FfsCount].IsLeaf =3D FALSE; > @@ -988,10 +991,11 @@ LibParseSection ( > case EFI_SECTION_COMPRESSION: > Level ++; > NumberOfSections ++; >=20 > EncapDataNeedUpdata =3D TRUE; > + HasUiSection =3D TRUE; > // > // Put in encapsulate data information. > // > LocalEncapData =3D *CurrentFvEncapData; > if (LocalEncapData->NextNode !=3D NULL) { > @@ -1166,10 +1170,11 @@ LibParseSection ( > // a GUID defined FV section. > // > Level ++; > NumberOfSections++; > EncapDataNeedUpdata =3D TRUE; > + HasUiSection =3D TRUE; > // > // Put in encapsulate data information. > // > LocalEncapData =3D *CurrentFvEncapData; > if (LocalEncapData->NextNode !=3D NULL) { > @@ -1593,10 +1598,11 @@ LibParseSection ( > memcpy(CurrentFv->FfsAttuibutes[*FfsCount].Depex, Ptr, SectionLeng= th); > CurrentFv->FfsAttuibutes[*FfsCount].DepexLen =3D SectionLength; > break; >=20 > case EFI_SECTION_USER_INTERFACE: > + HasUiSection =3D TRUE; > NumberOfSections ++; > CurrentFv->FfsAttuibutes[*FfsCount].Level =3D Level; >=20 > UiSectionLength =3D GetLength (((EFI_USER_INTERFACE_SECTION *) Ptr= )->CommonHeader.Size); > if (UiSectionLength =3D=3D 0xffffff) { > @@ -1669,10 +1675,34 @@ LibParseSection ( > if (ParsedLength < BufferLength) { > Error ("FMMT", 0, 0003, "sections do not completely fill the section= ed buffer being parsed", NULL); > return EFI_SECTION_ERROR; > } >=20 > + if (ViewFlag && !HasUiSection) { > + // > + //print FILE FFS GUID name > + // > + BlankChar =3D LibConstructBlankChar( CurrentFv->FvLevel * 2); > + if (BlankChar =3D=3D NULL) { > + return EFI_OUT_OF_RESOURCES; > + } > + > + fprintf(stdout, "%sFile \"%08x-%04x-%04x-%02x%02x-%02x%02x%02x%02x%0= 2x%02x\"\n", BlankChar, > + CurrentFile->Name.Data1, > + CurrentFile->Name.Data2, > + CurrentFile->Name.Data3, > + CurrentFile->Name.Data4[0], > + CurrentFile->Name.Data4[1], > + CurrentFile->Name.Data4[2], > + CurrentFile->Name.Data4[3], > + CurrentFile->Name.Data4[4], > + CurrentFile->Name.Data4[5], > + CurrentFile->Name.Data4[6], > + CurrentFile->Name.Data4[7] > + ); > + free(BlankChar); > + } >=20 > return EFI_SUCCESS; > } >=20 > /** > @@ -1819,16 +1849,18 @@ LibGetFileInfo ( > UINT8 GuidBuffer[PRINTED_GUID_BUFFER_SIZE]; > ENCAP_INFO_DATA *LocalEncapData; > BOOLEAN EncapDataNeedUpdateFlag; > BOOLEAN IsGeneratedFfs; > UINT32 FfsFileHeaderSize; > + CHAR8 *BlankChar; >=20 > Status =3D EFI_SUCCESS; >=20 > LocalEncapData =3D NULL; > EncapDataNeedUpdateFlag =3D TRUE; > IsGeneratedFfs =3D FALSE; > + BlankChar =3D NULL; >=20 > FfsFileHeaderSize =3D GetFfsHeaderLength ((EFI_FFS_FILE_HEADER *) Cur= rentFile); > FileLength =3D GetFfsFileLength ((EFI_FFS_FILE_HEADER *) Curren= tFile); >=20 > // > @@ -1999,10 +2031,34 @@ LibGetFileInfo ( >=20 > if ( CurrentFile->Type =3D=3D EFI_FV_FILETYPE_RAW){ > CurrentFv->FfsAttuibutes[*FfsCount].Level =3D Level; > if (!ViewFlag){ > LibGenFfsFile(CurrentFile, CurrentFv, FvName, Level, FfsCount, E= rasePolarity); > + } else { > + // > + // print EFI_FV_FILETYPE_RAW GUID > + // > + BlankChar =3D LibConstructBlankChar( CurrentFv->FvLevel * 2); > + if (BlankChar =3D=3D NULL) { > + return EFI_OUT_OF_RESOURCES; > + } > + > + fprintf(stdout, "%sFile \"%08x-%04x-%04x-%02x%02x-%02x%02x%02x%0= 2x%02x%02x\"\n", BlankChar, > + CurrentFile->Name.Data1, > + CurrentFile->Name.Data2, > + CurrentFile->Name.Data3, > + CurrentFile->Name.Data4[0], > + CurrentFile->Name.Data4[1], > + CurrentFile->Name.Data4[2], > + CurrentFile->Name.Data4[3], > + CurrentFile->Name.Data4[4], > + CurrentFile->Name.Data4[5], > + CurrentFile->Name.Data4[6], > + CurrentFile->Name.Data4[7] > + ); > + free(BlankChar); > + > } > } else if( CurrentFile->Type =3D=3D EFI_FV_FILETYPE_FFS_PAD){ > //EFI_FV_FILETYPE_FFS_PAD > } else { > // > -- > 2.12.2.windows.2