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.93; helo=mga11.intel.com; envelope-from=yonghong.zhu@intel.com; receiver=edk2-devel@lists.01.org Received: from mga11.intel.com (mga11.intel.com [192.55.52.93]) (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 9ED02211648BB for ; Fri, 12 Oct 2018 19:03:28 -0700 (PDT) X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga008.jf.intel.com ([10.7.209.65]) by fmsmga102.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 12 Oct 2018 19:03:28 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.54,374,1534834800"; d="scan'208";a="81090753" Received: from fmsmsx103.amr.corp.intel.com ([10.18.124.201]) by orsmga008.jf.intel.com with ESMTP; 12 Oct 2018 19:03:27 -0700 Received: from fmsmsx158.amr.corp.intel.com (10.18.116.75) by FMSMSX103.amr.corp.intel.com (10.18.124.201) with Microsoft SMTP Server (TLS) id 14.3.319.2; Fri, 12 Oct 2018 19:03:27 -0700 Received: from shsmsx104.ccr.corp.intel.com (10.239.4.70) by fmsmsx158.amr.corp.intel.com (10.18.116.75) with Microsoft SMTP Server (TLS) id 14.3.319.2; Fri, 12 Oct 2018 19:03:27 -0700 Received: from shsmsx103.ccr.corp.intel.com ([169.254.4.111]) by SHSMSX104.ccr.corp.intel.com ([169.254.5.183]) with mapi id 14.03.0319.002; Sat, 13 Oct 2018 10:03:25 +0800 From: "Zhu, Yonghong" To: "Zhu, Yonghong" , "edk2-devel@lists.01.org" CC: "Gao, Liming" , "Zhu, Yonghong" Thread-Topic: [edk2] [PATCH] BaseTools: Add --uefi option to enable UefiCompress method Thread-Index: AQHUYeYGfm1Nd+hMAUKRVgo2ZbL60aUcbdGw Date: Sat, 13 Oct 2018 02:03:24 +0000 Message-ID: References: <1539319318-1888-1-git-send-email-yonghong.zhu@intel.com> In-Reply-To: <1539319318-1888-1-git-send-email-yonghong.zhu@intel.com> Accept-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-originating-ip: [10.239.127.40] MIME-Version: 1.0 Subject: Re: [PATCH] BaseTools: Add --uefi option to enable UefiCompress method 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: Sat, 13 Oct 2018 02:03:28 -0000 Content-Language: en-US Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable Reviewed-by: Yonghong Zhu =20 Best Regards, Zhu Yonghong -----Original Message----- From: edk2-devel [mailto:edk2-devel-bounces@lists.01.org] On Behalf Of Yong= hong Zhu Sent: Friday, October 12, 2018 12:42 PM To: edk2-devel@lists.01.org Cc: Gao, Liming Subject: [edk2] [PATCH] BaseTools: Add --uefi option to enable UefiCompress= method From: Yunhua Feng Add one new option --uefi to enable UefiCompress. Cc: Liming Gao Cc: Yonghong Zhu Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Yunhua Feng --- BaseTools/Source/C/TianoCompress/TianoCompress.c | 81 +++++++++++++++++---= ---- BaseTools/Source/C/TianoCompress/TianoCompress.h | 2 +- 2 files changed, 58 insertions(+), 25 deletions(-) diff --git a/BaseTools/Source/C/TianoCompress/TianoCompress.c b/BaseTools/S= ource/C/TianoCompress/TianoCompress.c index 9a548fae1e..b88d7da2ed 100644 --- a/BaseTools/Source/C/TianoCompress/TianoCompress.c +++ b/BaseTools/Source/C/TianoCompress/TianoCompress.c @@ -15,10 +15,11 @@ THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN = "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER E= XPRESS OR IMPLIED. =20 **/ =20 #include "Compress.h" +#include "Decompress.h" #include "TianoCompress.h" #include "EfiUtilityMsgs.h" #include "ParseInf.h" #include #include "assert.h" @@ -63,10 +64,11 @@ static BOOLEAN QuietMode =3D FALSE; // // Global Var= iables // STATIC BOOLEAN ENCODE =3D FALSE; STATIC BOOLEAN DECODE =3D FAL= SE; +STATIC BOOLEAN UEFIMODE =3D FALSE; STATIC UINT8 *mSrc, *mDst, *mSrcUpperLimit, *mDstUpperLimit; STATIC UINT= 8 *mLevel, *mText, *mChildCount, *mBuf, mCLen[NC], mPTLen[NPT], *mLen; ST= ATIC INT16 mHeap[NC + 1]; STATIC INT32 mRemainder, mMatchLen, mBitCount,= mHeapSize, mN; STATIC UINT32 mBufSiz =3D 0, mOutputPos, mOutputMask, mSub= BitBuf, mCrc; @@ -1701,10 +1703,12 @@ Returns: =20 // // Details Option // fprintf (stdout, "Options:\n"); + fprintf (stdout, " --uefi\n\ + Enable UefiCompress, use TianoCompress when without this=20 + option\n"); fprintf (stdout, " -o FileName, --output FileName\n\ File will be created to store the ouput content.\n"); fprintf (stdout, " -v, --verbose\n\ Turn on verbose output with informational messages.\n"); fprintf (stdout, " -q, --quiet\n\ @@ -1820,10 +1824,17 @@ Returns: argc--; argv++; continue; } =20 + if (stricmp(argv[0], "--uefi") =3D=3D 0) { + UEFIMODE =3D TRUE; + argc--; + argv++; + continue; + } + if (stricmp (argv[0], "--debug") =3D=3D 0) { argc-=3D2; argv++; Status =3D AsciiStringToUint64(argv[0], FALSE, &DebugLevel); if (DebugLevel > 9) { @@ -1937,21 +1948,29 @@ Returns: // First call TianoCompress to get DstSize // if (DebugMode) { DebugMsg(UTILITY_NAME, 0, DebugLevel, "Encoding", NULL); } - Status =3D TianoCompress ((UINT8 *)FileBuffer, InputLength, OutBuffer, &= DstSize); + if (UEFIMODE) { + Status =3D EfiCompress ((UINT8 *)FileBuffer, InputLength, OutBuffer,=20 + &DstSize); } else { + Status =3D TianoCompress ((UINT8 *)FileBuffer, InputLength,=20 + OutBuffer, &DstSize); } =20 if (Status =3D=3D EFI_BUFFER_TOO_SMALL) { OutBuffer =3D (UINT8 *) malloc (DstSize); if (OutBuffer =3D=3D NULL) { Error (NULL, 0, 4001, "Resource:", "Memory cannot be allocated!"); goto ERROR; } } =20 - Status =3D TianoCompress ((UINT8 *)FileBuffer, InputLength, OutBuffer, &= DstSize); + if (UEFIMODE) { + Status =3D EfiCompress ((UINT8 *)FileBuffer, InputLength, OutBuffer,=20 + &DstSize); } else { + Status =3D TianoCompress ((UINT8 *)FileBuffer, InputLength,=20 + OutBuffer, &DstSize); } if (Status !=3D EFI_SUCCESS) { Error (NULL, 0, 0007, "Error compressing file", NULL); goto ERROR; } =20 @@ -1977,36 +1996,50 @@ Returns: } else if (DECODE) { if (DebugMode) { DebugMsg(UTILITY_NAME, 0, DebugLevel, "Decoding\n", NULL); } - // - // Get Compressed file original size - // - Src =3D (UINT8 *)FileBuffer; - OrigSize =3D Src[4] + (Src[5] << 8) + (Src[6] << 16) + (Src[7] << 24); =20 - // - // Allocate OutputBuffer - // - OutBuffer =3D (UINT8 *)malloc(OrigSize); - if (OutBuffer =3D=3D NULL) { - Error (NULL, 0, 4001, "Resource:", "Memory cannot be allocated!"); - goto ERROR; - } + if (UEFIMODE) { + Status =3D Extract((VOID *)FileBuffer, InputLength, (VOID *)&OutBuffer= , &DstSize, 1); + if (Status !=3D EFI_SUCCESS) { + goto ERROR; + } + fwrite(OutBuffer, (size_t)(DstSize), 1, OutputFile); } else { + // + // Get Compressed file original size + // + Src =3D (UINT8 *)FileBuffer; + OrigSize =3D Src[4] + (Src[5] << 8) + (Src[6] << 16) + (Src[7] <<=20 + 24); =20 - Status =3D Decompress((VOID *)FileBuffer, (VOID *)OutBuffer, (VOID *)Scr= atch, 2); - if (Status !=3D EFI_SUCCESS) { - goto ERROR; - } + // + // Allocate OutputBuffer + // + OutBuffer =3D (UINT8 *)malloc(OrigSize); + if (OutBuffer =3D=3D NULL) { + Error (NULL, 0, 4001, "Resource:", "Memory cannot be allocated!"); + goto ERROR; + } =20 - fwrite(OutBuffer, (size_t)(Scratch->mOrigSize), 1, OutputFile); + Status =3D TDecompress((VOID *)FileBuffer, (VOID *)OutBuffer, (VOID *)= Scratch, 2); + if (Status !=3D EFI_SUCCESS) { + goto ERROR; + } + fwrite(OutBuffer, (size_t)(Scratch->mOrigSize), 1, OutputFile); } fclose(OutputFile); fclose(InputFile); - free(Scratch); - free(FileBuffer); - free(OutBuffer); + if (Scratch !=3D NULL) { + free(Scratch); + } + if (FileBuffer !=3D NULL) { + free(FileBuffer); + } + if (OutBuffer !=3D NULL) { + free(OutBuffer); + } =20 if (DebugMode) { DebugMsg(UTILITY_NAME, 0, DebugLevel, "Encoding successful!\n", NULL); } =20 @@ -2632,11 +2665,11 @@ Done: return ; } =20 RETURN_STATUS EFIAPI -Decompress ( +TDecompress ( IN VOID *Source, IN OUT VOID *Destination, IN OUT VOID *Scratch, IN UINT32 Version ) diff --git a/BaseTools/Source/C/TianoCompress/TianoCompress.h b/BaseTools/S= ource/C/TianoCompress/TianoCompress.h index d75c00d26f..1297982e27 100644 --- a/BaseTools/Source/C/TianoCompress/TianoCompress.h +++ b/BaseTools/Source/C/TianoCompress/TianoCompress.h @@ -425,11 +425,11 @@ Decode ( SCRATCH_DATA *Sd ); =20 RETURN_STATUS EFIAPI -Decompress ( +TDecompress ( IN VOID *Source, IN OUT VOID *Destination, IN OUT VOID *Scratch, IN UINT32 Version ); -- 2.12.2.windows.2 _______________________________________________ edk2-devel mailing list edk2-devel@lists.01.org https://lists.01.org/mailman/listinfo/edk2-devel