From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received-SPF: Pass (sender SPF authorized) identity=mailfrom; client-ip=134.134.136.20; helo=mga02.intel.com; envelope-from=liming.gao@intel.com; receiver=edk2-devel@lists.01.org Received: from mga02.intel.com (mga02.intel.com [134.134.136.20]) (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 AF5602118DC21 for ; Fri, 23 Nov 2018 07:10:25 -0800 (PST) X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga007.jf.intel.com ([10.7.209.58]) by orsmga101.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 23 Nov 2018 07:10:25 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.56,270,1539673200"; d="scan'208";a="91584832" Received: from fmsmsx104.amr.corp.intel.com ([10.18.124.202]) by orsmga007.jf.intel.com with ESMTP; 23 Nov 2018 07:10:24 -0800 Received: from fmsmsx123.amr.corp.intel.com (10.18.125.38) by fmsmsx104.amr.corp.intel.com (10.18.124.202) with Microsoft SMTP Server (TLS) id 14.3.408.0; Fri, 23 Nov 2018 07:10:24 -0800 Received: from shsmsx102.ccr.corp.intel.com (10.239.4.154) by fmsmsx123.amr.corp.intel.com (10.18.125.38) with Microsoft SMTP Server (TLS) id 14.3.408.0; Fri, 23 Nov 2018 07:10:23 -0800 Received: from shsmsx104.ccr.corp.intel.com ([169.254.5.117]) by shsmsx102.ccr.corp.intel.com ([169.254.2.84]) with mapi id 14.03.0415.000; Fri, 23 Nov 2018 23:10:21 +0800 From: "Gao, Liming" To: "Zhang, Shenglei" , "edk2-devel@lists.01.org" Thread-Topic: [PATCH] BaseTools: Remove GenVtf Thread-Index: AQHUgvAXhCN7E5AUtEySp6kDZLYof6VddyUQ Date: Fri, 23 Nov 2018 15:10:20 +0000 Message-ID: <4A89E2EF3DFEDB4C8BFDE51014F606A14E3717AC@SHSMSX104.ccr.corp.intel.com> References: <20181123054751.6224-1-shenglei.zhang@intel.com> In-Reply-To: <20181123054751.6224-1-shenglei.zhang@intel.com> Accept-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-ctpclassification: CTP_NT x-titus-metadata-40: eyJDYXRlZ29yeUxhYmVscyI6IiIsIk1ldGFkYXRhIjp7Im5zIjoiaHR0cDpcL1wvd3d3LnRpdHVzLmNvbVwvbnNcL0ludGVsMyIsImlkIjoiNmVmNWZmMDctMjcyZC00NjE5LTljNGEtMWNjMTdiMGI3YTAwIiwicHJvcHMiOlt7Im4iOiJDVFBDbGFzc2lmaWNhdGlvbiIsInZhbHMiOlt7InZhbHVlIjoiQ1RQX05UIn1dfV19LCJTdWJqZWN0TGFiZWxzIjpbXSwiVE1DVmVyc2lvbiI6IjE3LjEwLjE4MDQuNDkiLCJUcnVzdGVkTGFiZWxIYXNoIjoiSHNMQXJtZHpoeXB4UXRIUVhnS0ZoKzlHS2hrS3NWWEZyN2FTUjVHYXpZMktsb0NYbzZ0ZElHMXZDSytPWHBKOCJ9 dlp-product: dlpe-windows dlp-version: 11.0.400.15 dlp-reaction: no-action x-originating-ip: [10.239.127.40] MIME-Version: 1.0 Subject: Re: [PATCH] BaseTools: Remove GenVtf 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, 23 Nov 2018 15:10:26 -0000 Content-Language: en-US Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable Please update edk2\BaseTools\Source\C\Makefile and edk2\BaseTools\Source\C\= GNUmakefile to remove this tool. It is not required to be compiled after it= is removed.=20 > -----Original Message----- > From: Zhang, Shenglei > Sent: Friday, November 23, 2018 1:48 PM > To: edk2-devel@lists.01.org > Cc: Zhu, Yonghong ; Gao, Liming > Subject: [PATCH] BaseTools: Remove GenVtf >=20 > GenVtf C tool is IPF specific. IPF support has been removed > from edk2 trunk. This tool can be removed. > https://bugzilla.tianocore.org/show_bug.cgi?id=3D1349 >=20 > Cc: Yonghong Zhu > Cc: Liming Gao > Contributed-under: TianoCore Contribution Agreement 1.1 > Signed-off-by: Shenglei Zhang > --- > BaseTools/Source/BinaryFiles.txt | 1 - > BaseTools/Source/C/GenVtf/GNUmakefile | 21 - > BaseTools/Source/C/GenVtf/GenVtf.c | 2811 ------------------------- > BaseTools/Source/C/GenVtf/GenVtf.h | 326 --- > BaseTools/Source/C/GenVtf/Makefile | 22 - > BaseTools/toolsetup.bat | 1 - > 6 files changed, 3182 deletions(-) > delete mode 100644 BaseTools/Source/C/GenVtf/GNUmakefile > delete mode 100644 BaseTools/Source/C/GenVtf/GenVtf.c > delete mode 100644 BaseTools/Source/C/GenVtf/GenVtf.h > delete mode 100644 BaseTools/Source/C/GenVtf/Makefile >=20 > diff --git a/BaseTools/Source/BinaryFiles.txt b/BaseTools/Source/BinaryFi= les.txt > index aad138ebd5..d707df9dda 100644 > --- a/BaseTools/Source/BinaryFiles.txt > +++ b/BaseTools/Source/BinaryFiles.txt > @@ -44,7 +44,6 @@ GenFw.exe > GenPage.exe > GenPatchPcdTable.exe > GenSec.exe > -GenVtf.exe > ImportTool.bat > LzmaCompress.exe > LzmaF86Compress.bat > diff --git a/BaseTools/Source/C/GenVtf/GNUmakefile b/BaseTools/Source/C/G= enVtf/GNUmakefile > deleted file mode 100644 > index 54160c64d4..0000000000 > --- a/BaseTools/Source/C/GenVtf/GNUmakefile > +++ /dev/null > @@ -1,21 +0,0 @@ > -## @file > -# GNU/Linux makefile for 'GenVtf' module build. > -# > -# Copyright (c) 2007 - 2018, Intel Corporation. All rights reserved.
> -# This program and the accompanying materials > -# are licensed and made available under the terms and conditions of the = BSD License > -# which accompanies this distribution. The full text of the license may= be found at > -# http://opensource.org/licenses/bsd-license.php > -# > -# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, > -# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR I= MPLIED. > -# > -MAKEROOT ?=3D .. > - > -APPNAME =3D GenVtf > - > -LIBS =3D -lCommon > - > -OBJECTS =3D GenVtf.o > - > -include $(MAKEROOT)/Makefiles/app.makefile > diff --git a/BaseTools/Source/C/GenVtf/GenVtf.c b/BaseTools/Source/C/GenV= tf/GenVtf.c > deleted file mode 100644 > index 3a7ac06156..0000000000 > --- a/BaseTools/Source/C/GenVtf/GenVtf.c > +++ /dev/null > @@ -1,2811 +0,0 @@ > -/** @file > -This file contains functions required to generate a boot strap file (BSF= ) also > -known as the Volume Top File (VTF) > - > -Copyright (c) 1999 - 2018, Intel Corporation. All rights reserved.
> -This program and the accompanying materials are licensed and made availa= ble > -under the terms and conditions of the BSD License which accompanies this > -distribution. The full text of the license may be found at > -http://opensource.org/licenses/bsd-license.php > - > -THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, > -WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMP= LIED. > - > -**/ > - > -// > -// > -// > -#include > -#include > -#include "GenVtf.h" > -#include > -#include "CommonLib.h" > -#include "EfiUtilityMsgs.h" > - > -// > -// Global variables > -// > -UINTN SectionOptionFlag =3D 0; > -UINTN SectionCompFlag =3D 0; > - > -UINT64 DebugLevel; > -BOOLEAN DebugMode; > - > -BOOLEAN QuietMode =3D FALSE; > - > -BOOLEAN VTF_OUTPUT =3D FALSE; > -CHAR8 *OutFileName1; > -CHAR8 *OutFileName2; > -CHAR8 *SymFileName; > - > -CHAR8 **TokenStr; > -CHAR8 **OrgStrTokPtr; > - > -PARSED_VTF_INFO *FileListPtr; > -PARSED_VTF_INFO *FileListHeadPtr; > - > -VOID *Vtf1Buffer; > -VOID *Vtf1EndBuffer; > -VOID *Vtf2Buffer; > -VOID *Vtf2EndBuffer; > - > -UINTN ValidLineNum =3D 0; > -UINTN ValidFFDFileListNum =3D 0; > - > -// > -// Section Description and their number of occurences in *.INF file > -// > -UINTN NumFvFiles =3D 0; > -UINTN SectionOptionNum =3D 0; > - > -// > -// Global flag which will check for VTF Present, if yes then will be use= d > -// to decide about adding FFS header to pad data > -// > -BOOLEAN VTFPresent =3D FALSE; > -BOOLEAN SecondVTF =3D FALSE; > - > -// > -// Address related information > -// > -UINT64 Fv1BaseAddress =3D 0; > -UINT64 Fv2BaseAddress =3D 0; > -UINT64 Fv1EndAddress =3D 0; > -UINT64 Fv2EndAddress =3D 0; > -UINT32 Vtf1TotalSize =3D SIZE_TO_OFFSET_PAL_A_END; > -UINT64 Vtf1LastStartAddress =3D 0; > -UINT32 Vtf2TotalSize =3D 0; > -UINT64 Vtf2LastStartAddress =3D 0; > - > -UINT32 BufferToTop =3D 0; > - > -// > -// IA32 Reset Vector Bin name > -// > -CHAR8 IA32BinFile[FILE_NAME_SIZE]; > - > -// > -// Function Implementations > -// > -EFI_STATUS > -ConvertVersionInfo ( > - IN CHAR8 *Str, > - IN OUT UINT8 *MajorVer, > - IN OUT UINT8 *MinorVer > - ) > -/*++ > -Routine Description: > - > - This function split version to major version and minor version > - > -Arguments: > - > - Str - String representing in form XX.XX > - MajorVer - The major version > - MinorVer - The minor version > - > -Returns: > - > - EFI_SUCCESS - The function completed successfully. > - > ---*/ > -{ > - CHAR8 TemStr[5] =3D "0000"; > - int Major; > - int Minor; > - UINTN Length; > - > - Major =3D 0; > - Minor =3D 0; > - > - if (strstr (Str, ".") !=3D NULL) { > - sscanf ( > - Str, > - "%02x.%02x", > - &Major, > - &Minor > - ); > - } else { > - Length =3D strlen(Str); > - if (Length < 4) { > - memcpy (TemStr + 4 - Length, Str, Length); > - } else { > - memcpy (TemStr, Str + Length - 4, 4); > - } > - > - sscanf ( > - TemStr, > - "%02x%02x", > - &Major, > - &Minor > - ); > - } > - > - *MajorVer =3D (UINT8) Major; > - *MinorVer =3D (UINT8) Minor; > - return EFI_SUCCESS; > -} > - > -VOID > -TrimLine ( > - IN CHAR8 *Line > - ) > -/*++ > -Routine Description: > - > - This function cleans up the line by removing all whitespace and > - comments > - > -Arguments: > - > - Line - The pointer of the string > - > -Returns: > - > - None > - > ---*/ > -{ > - CHAR8 TmpLine[FILE_NAME_SIZE]; > - CHAR8 Char; > - CHAR8 *Ptr0; > - UINTN Index; > - UINTN Index2; > - > - // > - // Change '#' to '//' for Comment style > - // > - if (((Ptr0 =3D strchr (Line, '#')) !=3D NULL) || ((Ptr0 =3D strstr (Li= ne, "//")) !=3D NULL)) { > - Line[Ptr0 - Line] =3D 0; > - } > - > - // > - // Initialize counters > - // > - Index =3D 0; > - Index2 =3D 0; > - > - while ((Char =3D Line[Index]) !=3D 0) { > - if ((Char !=3D ' ') && (Char !=3D '\t') && (Char !=3D '\n') && (Char= !=3D '\r')) { > - TmpLine[Index2++] =3D Char; > - } > - Index++; > - } > - > - TmpLine[Index2] =3D 0; > - strcpy (Line, TmpLine); > -} > - > -VOID > -ValidLineCount ( > - IN FILE *Fp > - ) > -/*++ > - > -Routine Description: > - > - This function calculated number of valid lines in a input file. > - > -Arguments: > - > - Fp - Pointer to a file handle which has been opened. > - > -Returns: > - > - None > - > ---*/ > -{ > - CHAR8 Buff[FILE_NAME_SIZE]; > - while (fgets(Buff, sizeof (Buff), Fp)) { > - TrimLine (Buff); > - if (Buff[0] =3D=3D 0) { > - continue; > - } > - ValidLineNum++; > - } > -} > - > -EFI_STATUS > -ParseInputFile ( > - IN FILE *Fp > - ) > -/*++ > - > -Routine Description: > - > - This function parses the input file and tokenize the string > - > -Arguments: > - > - Fp - Pointer to a file handle which has been opened. > - > -Returns: > - > - None > - > ---*/ > -{ > - CHAR8 *Token; > - CHAR8 Buff[FILE_NAME_SIZE + 1]; > - CHAR8 Delimit[] =3D "=3D"; > - > - Buff [FILE_NAME_SIZE] =3D '\0'; > - Token =3D NULL; > - > - while (fgets (Buff, FILE_NAME_SIZE, Fp) !=3D NULL) { > - TrimLine (Buff); > - if (Buff[0] =3D=3D 0) { > - continue; > - } > - Token =3D strtok (Buff, Delimit); > - while (Token !=3D NULL) { > - strcpy (*TokenStr, Token); > - TokenStr ++; > - Token =3D strtok (NULL, Delimit); > - } > - } > - return EFI_SUCCESS; > -} > - > -EFI_STATUS > -InitializeComps ( > - VOID > - ) > -/*++ > - > -Routine Description: > - > - This function initializes the relevant global variable which is being > - used to store the information retrieved from INF file. This also init= ializes > - the VTF symbol file. > - > -Arguments: > - > - None > - > -Returns: > - > - EFI_SUCCESS - The function completed successfully > - EFI_OUT_OF_RESOURCES - Malloc failed. > - > ---*/ > -{ > - > - FileListPtr =3D malloc (sizeof (PARSED_VTF_INFO)); > - > - if (FileListPtr =3D=3D NULL) { > - return EFI_OUT_OF_RESOURCES; > - } > - > - FileListHeadPtr =3D FileListPtr; > - memset (FileListPtr, 0, sizeof (PARSED_VTF_INFO)); > - FileListPtr->NextVtfInfo =3D NULL; > - > - remove (SymFileName); > - return EFI_SUCCESS; > -} > - > -VOID > -ParseAndUpdateComponents ( > - IN PARSED_VTF_INFO *VtfInfo > - ) > -/*++ > - > -Routine Description: > - > - This function initializes the relevant global variable which is being > - used to store the information retrieved from INF file. > - > -Arguments: > - > - VtfInfo - A pointer to the VTF Info Structure > - > - > -Returns: > - > - None > - > ---*/ > -{ > - UINT64 StringValue; > - > - while (*TokenStr !=3D NULL && (strnicmp (*TokenStr, "COMP_NAME", 9) != =3D 0)) { > - > - if (strnicmp (*TokenStr, "COMP_LOC", 8) =3D=3D 0) { > - TokenStr++; > - if (strnicmp (*TokenStr, "F", 1) =3D=3D 0) { > - VtfInfo->LocationType =3D FIRST_VTF; > - } else if (strnicmp (*TokenStr, "S", 1) =3D=3D 0) { > - VtfInfo->LocationType =3D SECOND_VTF; > - } else { > - VtfInfo->LocationType =3D NONE; > - } > - } else if (strnicmp (*TokenStr, "COMP_TYPE", 9) =3D=3D 0) { > - TokenStr++; > - if (AsciiStringToUint64 (*TokenStr, FALSE, &StringValue) !=3D EFI_= SUCCESS) { > - Error (NULL, 0, 5001, "Cannot get: \"0x%s\".", *TokenStr); > - return ; > - } > - > - VtfInfo->CompType =3D (UINT8) StringValue; > - } else if (strnicmp (*TokenStr, "COMP_VER", 8) =3D=3D 0) { > - TokenStr++; > - if (strnicmp (*TokenStr, "-", 1) =3D=3D 0) { > - VtfInfo->VersionPresent =3D FALSE; > - VtfInfo->MajorVer =3D 0; > - VtfInfo->MinorVer =3D 0; > - } else { > - VtfInfo->VersionPresent =3D TRUE; > - ConvertVersionInfo (*TokenStr, &VtfInfo->MajorVer, &VtfInfo->Min= orVer); > - } > - } else if (strnicmp (*TokenStr, "COMP_BIN", 8) =3D=3D 0) { > - TokenStr++; > - if (strlen (*TokenStr) >=3D FILE_NAME_SIZE) { > - Error (NULL, 0, 3000, "Invalid", "The 'COMP_BIN' name is too lon= g."); > - return ; > - } > - strncpy (VtfInfo->CompBinName, *TokenStr, FILE_NAME_SIZE - 1); > - VtfInfo->CompBinName[FILE_NAME_SIZE - 1] =3D 0; > - } else if (strnicmp (*TokenStr, "COMP_SYM", 8) =3D=3D 0) { > - TokenStr++; > - if (strlen (*TokenStr) >=3D FILE_NAME_SIZE) { > - Error (NULL, 0, 3000, "Invalid", "The 'COMP_SYM' name is too lon= g."); > - return ; > - } > - strncpy (VtfInfo->CompSymName, *TokenStr, FILE_NAME_SIZE - 1); > - VtfInfo->CompSymName[FILE_NAME_SIZE - 1] =3D 0; > - } else if (strnicmp (*TokenStr, "COMP_SIZE", 9) =3D=3D 0) { > - TokenStr++; > - if (strnicmp (*TokenStr, "-", 1) =3D=3D 0) { > - VtfInfo->PreferredSize =3D FALSE; > - VtfInfo->CompSize =3D 0; > - } else { > - VtfInfo->PreferredSize =3D TRUE; > - if (AsciiStringToUint64 (*TokenStr, FALSE, &StringValue) !=3D EF= I_SUCCESS) { > - Error (NULL, 0, 5001, "Parse error", "Cannot get: %s.", TokenS= tr); > - return ; > - } > - > - VtfInfo->CompSize =3D (UINTN) StringValue; > - } > - > - } else if (strnicmp (*TokenStr, "COMP_CS", 7) =3D=3D 0) { > - TokenStr++; > - if (strnicmp (*TokenStr, "1", 1) =3D=3D 0) { > - VtfInfo->CheckSumRequired =3D 1; > - } else if (strnicmp (*TokenStr, "0", 1) =3D=3D 0) { > - VtfInfo->CheckSumRequired =3D 0; > - } else { > - Error (NULL, 0, 3000, "Invaild", "Bad value in INF file required= field: Checksum, the value must be '0' or '1'."); > - } > - } > - > - TokenStr++; > - if (*TokenStr =3D=3D NULL) { > - break; > - } > - } > -} > - > -VOID > -InitializeInFileInfo ( > - VOID > - ) > -/*++ > - > -Routine Description: > - > - This function intializes the relevant global variable which is being > - used to store the information retrieved from INF file. > - > -Arguments: > - > - NONE > - > -Returns: > - > - NONE > - > ---*/ > -{ > - > - SectionOptionFlag =3D 0; > - SectionCompFlag =3D 0; > - TokenStr =3D OrgStrTokPtr; > - > - while (*TokenStr !=3D NULL) { > - if (strnicmp (*TokenStr, "[OPTIONS]", 9) =3D=3D 0) { > - SectionOptionFlag =3D 1; > - SectionCompFlag =3D 0; > - } > - > - if (strnicmp (*TokenStr, "[COMPONENTS]", 12) =3D=3D 0) { > - if (FileListPtr =3D=3D NULL) { > - FileListPtr =3D FileListHeadPtr; > - } > - > - SectionCompFlag =3D 1; > - SectionOptionFlag =3D 0; > - TokenStr++; > - } > - > - if (SectionOptionFlag) { > - if (stricmp (*TokenStr, "IA32_RST_BIN") =3D=3D 0) { > - TokenStr++; > - if (strlen (*TokenStr) >=3D FILE_NAME_SIZE) { > - Error (NULL, 0, 3000, "Invalid", "The 'IA32_RST_BIN' name is t= oo long."); > - break; > - } > - strncpy (IA32BinFile, *TokenStr, FILE_NAME_SIZE - 1); > - IA32BinFile[FILE_NAME_SIZE - 1] =3D 0; > - } > - } > - > - if (SectionCompFlag) { > - if (stricmp (*TokenStr, "COMP_NAME") =3D=3D 0) { > - TokenStr++; > - if (strlen (*TokenStr) >=3D COMPONENT_NAME_SIZE) { > - Error (NULL, 0, 3000, "Invalid", "The 'COMP_NAME' name is too = long."); > - break; > - } > - strncpy (FileListPtr->CompName, *TokenStr, COMPONENT_NAME_SIZE -= 1); > - FileListPtr->CompName[COMPONENT_NAME_SIZE - 1] =3D 0; > - TokenStr++; > - ParseAndUpdateComponents (FileListPtr); > - } > - > - if (*TokenStr !=3D NULL) { > - FileListPtr->NextVtfInfo =3D malloc (sizeof (PARSED_VTF_INFO)); > - if (FileListPtr->NextVtfInfo =3D=3D NULL) { > - Error (NULL, 0, 4003, "Resource", "Out of memory resources.", = NULL); > - break; > - } > - FileListPtr =3D FileListPtr->NextVtfInfo; > - memset (FileListPtr, 0, sizeof (PARSED_VTF_INFO)); > - FileListPtr->NextVtfInfo =3D NULL; > - continue; > - } else { > - break; > - } > - } > - > - TokenStr++; > - } > -} > - > -EFI_STATUS > -GetVtfRelatedInfoFromInfFile ( > - IN FILE *FilePointer > - ) > -/*++ > - > -Routine Description: > - > - This function reads the input file, parse it and create a list of toke= ns > - which is parsed and used, to intialize the data related to VTF > - > -Arguments: > - > - FileName - FileName which needed to be read to parse data > - > -Returns: > - > - EFI_ABORTED - Error in opening file > - EFI_INVALID_PARAMETER - File doesn't contain any valid information > - EFI_OUT_OF_RESOURCES - Malloc Failed > - EFI_SUCCESS - The function completed successfully > - > ---*/ > -{ > - FILE *Fp; > - UINTN Index; > - UINTN Index1; > - EFI_STATUS Status; > - > - Status =3D EFI_SUCCESS; > - Fp =3D FilePointer; > - if (Fp =3D=3D NULL) { > - Error (NULL, 0, 2000, "Invalid parameter", "BSF INF file is invalid!= "); > - return EFI_ABORTED; > - } > - > - ValidLineCount (Fp); > - > - if (ValidLineNum =3D=3D 0) { > - Error (NULL, 0, 2000, "Invalid parameter", "File does not contain an= y valid information!"); > - return EFI_INVALID_PARAMETER; > - } > - > - TokenStr =3D (CHAR8 **) malloc (sizeof (UINTN) * (2 * ValidLineNum + 1= )); > - > - if (TokenStr =3D=3D NULL) { > - return EFI_OUT_OF_RESOURCES; > - } > - > - memset (TokenStr, 0, (sizeof (UINTN) * (2 * ValidLineNum + 1))); > - OrgStrTokPtr =3D TokenStr; > - > - for (Index =3D 0; Index < (2 * ValidLineNum); Index++) { > - *TokenStr =3D (CHAR8*)malloc (sizeof (CHAR8) * FILE_NAME_SIZE); > - > - if (*TokenStr =3D=3D NULL) { > - Status =3D EFI_OUT_OF_RESOURCES; > - goto ParseFileError; > - } > - > - memset (*TokenStr, 0, FILE_NAME_SIZE); > - TokenStr++; > - } > - > - TokenStr =3D OrgStrTokPtr; > - fseek (Fp, 0L, SEEK_SET); > - > - Status =3D InitializeComps (); > - > - if (Status !=3D EFI_SUCCESS) { > - goto ParseFileError; > - } > - > - Status =3D ParseInputFile (Fp); > - if (Status !=3D EFI_SUCCESS) { > - goto ParseFileError; > - } > - > - InitializeInFileInfo (); > - > -ParseFileError: > - > - for (Index1 =3D 0; Index1 < Index; Index1 ++) { > - free (OrgStrTokPtr[Index1]); > - } > - > - free (OrgStrTokPtr); > - > - return Status; > -} > - > -VOID > -GetRelativeAddressInVtfBuffer ( > - IN UINT64 Address, > - IN OUT UINTN *RelativeAddress, > - IN LOC_TYPE LocType > - ) > -/*++ > - > -Routine Description: > - > - This function checks for the address alignmnet for specified data boun= dary. In > - case the address is not aligned, it returns FALSE and the amount of da= ta in > - terms of byte needed to adjust to get the boundary alignmnet. If data = is > - aligned, TRUE will be returned. > - > -Arguments: > - > - Address - The address of the flash map space > - RelativeAddress - The relative address of the Buffer > - LocType - The type of the VTF > - > - > -Returns: > - > - > ---*/ > -{ > - UINT64 TempAddress; > - UINT8 *LocalBuff; > - > - if (LocType =3D=3D FIRST_VTF) { > - LocalBuff =3D (UINT8 *) Vtf1EndBuffer; > - TempAddress =3D Fv1EndAddress - Address; > - *RelativeAddress =3D (UINTN) LocalBuff - (UINTN) TempAddress; > - } else { > - LocalBuff =3D (UINT8 *) Vtf2EndBuffer; > - TempAddress =3D Fv2EndAddress - Address; > - *RelativeAddress =3D (UINTN) LocalBuff - (UINTN) TempAddress; > - } > -} > - > -EFI_STATUS > -GetComponentVersionInfo ( > - IN OUT PARSED_VTF_INFO *VtfInfo, > - IN UINT8 *Buffer > - ) > -/*++ > -Routine Description: > - > - This function will extract the version information from File > - > -Arguments: > - > - VtfInfo - A Pointer to the VTF Info Structure > - Buffer - A Pointer to type UINT8 > - > -Returns: > - > - EFI_SUCCESS - The function completed successfully > - EFI_INVALID_PARAMETER - The parameter is invalid > - > ---*/ > -{ > - UINT16 VersionInfo; > - EFI_STATUS Status; > - > - switch (VtfInfo->CompType) { > - > - case COMP_TYPE_FIT_PAL_A: > - case COMP_TYPE_FIT_PAL_B: > - memcpy (&VersionInfo, (Buffer + 8), sizeof (UINT16)); > - VtfInfo->MajorVer =3D (UINT8) ((VersionInfo & 0xFF00) >> 8); > - VtfInfo->MinorVer =3D (UINT8) (VersionInfo & 0x00FF); > - Status =3D EFI_SUCCESS; > - break; > - > - default: > - Status =3D EFI_INVALID_PARAMETER; > - break; > - } > - > - return Status; > -} > - > -BOOLEAN > -CheckAddressAlignment ( > - IN UINT64 Address, > - IN UINT64 AlignmentData, > - IN OUT UINT64 *AlignAdjustByte > - ) > -/*++ > - > -Routine Description: > - > - This function checks for the address alignmnet for specified data boun= dary. In > - case the address is not aligned, it returns FALSE and the amount of da= ta in > - terms of byte needed to adjust to get the boundary alignmnet. If data = is > - aligned, TRUE will be returned. > - > -Arguments: > - > - Address - Pointer to buffer containing byte data of compo= nent. > - AlignmentData - DataSize for which address needed to be aligned > - AlignAdjustByte - Number of bytes needed to adjust alignment. > - > -Returns: > - > - TRUE - Address is aligned to specific data size bounda= ry > - FALSE - Address in not aligned to specified data size b= oundary > - - Add/Subtract AlignAdjustByte to aling the addre= ss. > - > ---*/ > -{ > - // > - // Check if the assigned address is on address boundary. If not, it wi= ll > - // return the remaining byte required to adjust the address for specif= ied > - // address boundary > - // > - *AlignAdjustByte =3D (Address % AlignmentData); > - > - if (*AlignAdjustByte =3D=3D 0) { > - return TRUE; > - } else { > - return FALSE; > - } > -} > - > -EFI_STATUS > -GetFitTableStartAddress ( > - IN OUT FIT_TABLE **FitTable > - ) > -/*++ > - > -Routine Description: > - > - Get the FIT table start address in VTF Buffer > - > -Arguments: > - > - FitTable - Pointer to available fit table where new component can b= e added > - > -Returns: > - > - EFI_SUCCESS - The function completed successfully > - > ---*/ > -{ > - UINT64 FitTableAdd; > - UINT64 FitTableAddOffset; > - UINTN RelativeAddress; > - > - // > - // Read the Fit Table address from Itanium-based address map. > - // > - FitTableAddOffset =3D Fv1EndAddress - (SIZE_IA32_RESET_VECT + SIZE_SAL= E_ENTRY_POINT + SIZE_FIT_TABLE_ADD); > - > - // > - // Translate this Itanium-based address in terms of local buffer addre= ss which > - // contains the image for Boot Strapped File. The relative address wil= l be > - // the address of fit table VTF buffer. > - // > - GetRelativeAddressInVtfBuffer (FitTableAddOffset, &RelativeAddress, FI= RST_VTF); > - FitTableAdd =3D *(UINTN *) RelativeAddress; > - > - // > - // The FitTableAdd is the extracted Itanium based address pointing to = FIT > - // table. The relative address will return its actual location in VTF > - // Buffer. > - // > - GetRelativeAddressInVtfBuffer (FitTableAdd, &RelativeAddress, FIRST_VT= F); > - > - *FitTable =3D (FIT_TABLE *) RelativeAddress; > - > - return EFI_SUCCESS; > -} > - > -EFI_STATUS > -GetNextAvailableFitPtr ( > - IN FIT_TABLE **FitPtr > - ) > -/*++ > - > -Routine Description: > - > - Get the FIT table address and locate the free space in fit where we ca= n add > - new component. In this process, this function locates the fit table us= ing > - Fit pointer in Itanium-based address map (as per Intel?Itanium(TM) SAL= spec) > - and locate the available location in FIT table to be used by new compo= nents. > - If there are any Fit table which areg not being used contains Componen= tType > - field as 0x7F. If needed we can change this and spec this out. > - > -Arguments: > - > - FitPtr - Pointer to available fit table where new component can be = added > - > -Returns: > - > - EFI_SUCCESS - The function completed successfully > - > ---*/ > -{ > - FIT_TABLE *TmpFitPtr; > - UINT64 FitTableAdd; > - UINT64 FitTableAddOffset; > - UINTN Index; > - UINTN NumFitComponents; > - UINTN RelativeAddress; > - > - // > - // Read the Fit Table address from Itanium-based address map. > - // > - FitTableAddOffset =3D Fv1EndAddress - (SIZE_IA32_RESET_VECT + SIZE_SAL= E_ENTRY_POINT + SIZE_FIT_TABLE_ADD); > - > - // > - // Translate this Itanium-based address in terms of local buffer addre= ss which > - // contains the image for Boot Strapped File. The relative address wil= l be > - // the address of fit table VTF buffer. > - // > - GetRelativeAddressInVtfBuffer (FitTableAddOffset, &RelativeAddress, FI= RST_VTF); > - FitTableAdd =3D *(UINTN *) RelativeAddress; > - > - // > - // The FitTableAdd is the extracted Itanium based address pointing to = FIT > - // table. The relative address will return its actual location in VTF > - // Buffer. > - // > - GetRelativeAddressInVtfBuffer (FitTableAdd, &RelativeAddress, FIRST_VT= F); > - > - TmpFitPtr =3D (FIT_TABLE *) RelativeAddress; > - NumFitComponents =3D TmpFitPtr->CompSize; > - *FitPtr =3D NULL; > - > - for (Index =3D 0; Index < NumFitComponents; Index++) { > - if ((TmpFitPtr->CvAndType & FIT_TYPE_MASK) =3D=3D COMP_TYPE_FIT_UNUS= ED) { > - *FitPtr =3D TmpFitPtr; > - break; > - } > - > - TmpFitPtr++; > - } > - > - return EFI_SUCCESS; > -} > - > -int > -CompareItems ( > - IN const VOID *Arg1, > - IN const VOID *Arg2 > - ) > -/*++ > - > -Routine Description: > - > - This function is used by qsort to sort the FIT table based upon Comp= onent > - Type in their incresing order. > - > -Arguments: > - > - Arg1 - Pointer to Arg1 > - Arg2 - Pointer to Arg2 > - > -Returns: > - > - None > - > ---*/ > -{ > - if ((((FIT_TABLE *) Arg1)->CvAndType & FIT_TYPE_MASK) > (((FIT_TABLE *= ) Arg2)->CvAndType & FIT_TYPE_MASK)) { > - return 1; > - } else if ((((FIT_TABLE *) Arg1)->CvAndType & FIT_TYPE_MASK) < (((FIT_= TABLE *) Arg2)->CvAndType & FIT_TYPE_MASK)) { > - return -1; > - } else { > - return 0; > - } > -} > - > -VOID > -SortFitTable ( > - IN VOID > - ) > -/*++ > - > -Routine Description: > - > - This function is used by qsort to sort the FIT table based upon Comp= onent > - Type in their incresing order. > - > -Arguments: > - > - VOID > - > -Returns: > - > - None > - > ---*/ > -{ > - FIT_TABLE *FitTable; > - FIT_TABLE *TmpFitPtr; > - UINTN NumFitComponents; > - UINTN Index; > - > - GetFitTableStartAddress (&FitTable); > - TmpFitPtr =3D FitTable; > - NumFitComponents =3D 0; > - for (Index =3D 0; Index < FitTable->CompSize; Index++) { > - if ((TmpFitPtr->CvAndType & FIT_TYPE_MASK) !=3D COMP_TYPE_FIT_UNUSED= ) { > - NumFitComponents +=3D 1; > - } > - TmpFitPtr++; > - } > - qsort ((VOID *) FitTable, NumFitComponents, sizeof (FIT_TABLE), Compar= eItems); > -} > - > -VOID > -UpdateFitEntryForFwVolume ( > - IN UINT64 Size > - ) > -/*++ > - > -Routine Description: > - > - This function updates the information about Firmware Volume in FIT TA= BLE. > - This FIT table has to be immediately below the PAL_A Start and it cont= ains > - component type and address information. Other information can't be > - created this time so we would need to fix it up.. > - > - > -Arguments: > - > - Size - Firmware Volume Size > - > -Returns: > - > - VOID > - > ---*/ > -{ > - FIT_TABLE *CompFitPtr; > - UINTN RelativeAddress; > - > - // > - // FV Fit table will be located at PAL_A Startaddress - 16 byte locati= on > - // > - Vtf1LastStartAddress -=3D 0x10; > - Vtf1TotalSize +=3D 0x10; > - > - GetRelativeAddressInVtfBuffer (Vtf1LastStartAddress, &RelativeAddress,= FIRST_VTF); > - > - CompFitPtr =3D (FIT_TABLE *) RelativeAddress; > - CompFitPtr->CompAddress =3D Fv1BaseAddress; > - > - // > - // Since we don't have any information about its location in Firmware = Volume, > - // initialize address to 0. This will be updated once Firmware Volume = is > - // being build and its current address will be fixed in FIT table. Cur= rently > - // we haven't implemented it so far and working on architectural clara= fication > - // > - // > - // Firmware Volume Size in 16 byte block > - // > - CompFitPtr->CompSize =3D ((UINT32) Size) / 16; > - > - // > - // Since Firmware Volume does not exist by the time we create this FIT= info > - // this should be fixedup from Firmware Volume creation tool. We haven= 't > - // worked out a method so far. > - // > - CompFitPtr->CompVersion =3D MAKE_VERSION (0, 0); > - > - // > - // Since we don't have any info about this file, we are making sure th= at > - // checksum is not needed. > - // > - CompFitPtr->CvAndType =3D CV_N_TYPE (0, COMP_TYPE_FIT_FV_BOOT); > - > - // > - // Since non VTF component will reside outside the VTF, we will not ha= ve its > - // binary image while creating VTF, hence we will not perform checksum= at > - // this time. Once Firmware Volume is being created which will contain= this > - // VTF, it will fix the FIT table for all the non VTF component and he= nce > - // checksum > - // > - CompFitPtr->CheckSum =3D 0; > -} > - > -EFI_STATUS > -UpdateFitEntryForNonVTFComp ( > - IN PARSED_VTF_INFO *VtfInfo > - ) > -/*++ > - > -Routine Description: > - > - This function updates the information about non VTF component in FIT T= ABLE. > - Since non VTF componets binaries are not part of VTF binary, we would = still > - be required to update its location information in Firmware Volume, ins= ide > - FIT table. > - > -Arguments: > - > - VtfInfo - Pointer to VTF Info Structure > - > -Returns: > - > - EFI_ABORTED - The function fails to update the component in FIT > - EFI_SUCCESS - The function completed successfully > - > ---*/ > -{ > - FIT_TABLE *CompFitPtr; > - > - // > - // Scan the FIT table for available space > - // > - GetNextAvailableFitPtr (&CompFitPtr); > - if (CompFitPtr =3D=3D NULL) { > - Error (NULL, 0, 5003, "Invalid", "Can't update this component in FIT= "); > - return EFI_ABORTED; > - } > - > - // > - // Since we don't have any information about its location in Firmware = Volume, > - // initialize address to 0. This will be updated once Firmware Volume = is > - // being build and its current address will be fixed in FIT table > - // > - CompFitPtr->CompAddress =3D 0; > - CompFitPtr->CompSize =3D VtfInfo->CompSize; > - CompFitPtr->CompVersion =3D MAKE_VERSION (VtfInfo->MajorVer, VtfInfo->= MinorVer); > - CompFitPtr->CvAndType =3D CV_N_TYPE (VtfInfo->CheckSumRequired, VtfI= nfo->CompType); > - > - // > - // Since non VTF component will reside outside the VTF, we will not ha= ve its > - // binary image while creating VTF, hence we will not perform checksum= at > - // this time. Once Firmware Volume is being created which will contain= this > - // VTF, it will fix the FIT table for all the non VTF component and he= nce > - // checksum > - // > - CompFitPtr->CheckSum =3D 0; > - > - // > - // Fit Type is FV_BOOT which means Firmware Volume, we initialize this= to base > - // address of Firmware Volume in which this VTF will be attached. > - // > - if ((CompFitPtr->CvAndType & 0x7F) =3D=3D COMP_TYPE_FIT_FV_BOOT) { > - CompFitPtr->CompAddress =3D Fv1BaseAddress; > - } > - > - return EFI_SUCCESS; > -} > - > -// > -// !!!WARNING > -// This function is updating the SALE_ENTRY in Itanium address space as = per SAL > -// spec. SALE_ENTRY is being read from SYM file of PEICORE. Once the PEI > -// CORE moves in Firmware Volume, we would need to modify this function = to be > -// used with a API which will detect PEICORE component while building Fi= rmware > -// Volume and update its entry in FIT table as well as in Itanium addres= s space > -// as per Intel?Itanium(TM) SAL address space > -// > -EFI_STATUS > -UpdateEntryPoint ( > - IN PARSED_VTF_INFO *VtfInfo, > - IN UINT64 *CompStartAddress > - ) > -/*++ > - > -Routine Description: > - > - This function updated the architectural entry point in IPF, SALE_ENTRY= . > - > -Arguments: > - > - VtfInfo - Pointer to VTF Info Structure > - CompStartAddress - Pointer to Component Start Address > - > -Returns: > - > - EFI_INVALID_PARAMETER - The parameter is invalid > - EFI_SUCCESS - The function completed successfully > - > ---*/ > -{ > - UINTN RelativeAddress; > - UINT64 SalEntryAdd; > - FILE *Fp; > - UINTN Offset; > - > - CHAR8 Buff[FILE_NAME_SIZE]; > - CHAR8 Buff1[10]; > - CHAR8 Buff2[10]; > - CHAR8 OffsetStr[30]; > - CHAR8 Buff3[10]; > - CHAR8 Buff4[10]; > - CHAR8 Buff5[10]; > - CHAR8 Token[50]; > - CHAR8 FormatString[MAX_LINE_LEN]; > - > - Fp =3D fopen (LongFilePath (VtfInfo->CompSymName), "rb"); > - > - if (Fp =3D=3D NULL) { > - Error (NULL, 0, 0001, "Error opening file", VtfInfo->CompSymName); > - return EFI_INVALID_PARAMETER; > - } > - > - // > - // Generate the format string for fscanf > - // > - sprintf ( > - FormatString, > - "%%%us %%%us %%%us %%%us %%%us %%%us %%%us", > - (unsigned) sizeof (Buff1) - 1, > - (unsigned) sizeof (Buff2) - 1, > - (unsigned) sizeof (OffsetStr) - 1, > - (unsigned) sizeof (Buff3) - 1, > - (unsigned) sizeof (Buff4) - 1, > - (unsigned) sizeof (Buff5) - 1, > - (unsigned) sizeof (Token) - 1 > - ); > - > - while (fgets (Buff, sizeof (Buff), Fp) !=3D NULL) { > - fscanf ( > - Fp, > - FormatString, > - Buff1, > - Buff2, > - OffsetStr, > - Buff3, > - Buff4, > - Buff5, > - Token > - ); > - if (strnicmp (Token, "SALE_ENTRY", 10) =3D=3D 0) { > - break; > - } > - } > - > - Offset =3D strtoul (OffsetStr, NULL, 16); > - > - *CompStartAddress +=3D Offset; > - SalEntryAdd =3D Fv1EndAddress - (SIZE_IA32_RESET_VECT + SIZE_SALE_ENTR= Y_POINT); > - > - GetRelativeAddressInVtfBuffer (SalEntryAdd, &RelativeAddress, FIRST_VT= F); > - > - memcpy ((VOID *) RelativeAddress, (VOID *) CompStartAddress, sizeof (U= INT64)); > - > - if (Fp !=3D NULL) { > - fclose (Fp); > - } > - > - return EFI_SUCCESS; > -} > - > -EFI_STATUS > -CreateAndUpdateComponent ( > - IN PARSED_VTF_INFO *VtfInfo > - ) > -/*++ > - > -Routine Description: > - > - This function reads the binary file for each components and update the= m > - in VTF Buffer as well as in FIT table. If the component is located in = non > - VTF area, only the FIT table address will be updated > - > -Arguments: > - > - VtfInfo - Pointer to Parsed Info > - > -Returns: > - > - EFI_SUCCESS - The function completed successful > - EFI_ABORTED - Aborted due to one of the many reasons like: > - (a) Component Size greater than the specified size= . > - (b) Error opening files. > - (c) Fail to get the FIT table address. > - > - EFI_INVALID_PARAMETER Value returned from call to UpdateEntryPoint= () > - EFI_OUT_OF_RESOURCES Memory allocation failure. > - > ---*/ > -{ > - EFI_STATUS Status; > - UINT64 CompStartAddress; > - UINT64 FileSize; > - UINT64 NumAdjustByte; > - UINT8 *Buffer; > - FILE *Fp; > - FIT_TABLE *CompFitPtr; > - BOOLEAN Aligncheck; > - > - if (VtfInfo->LocationType =3D=3D NONE) { > - UpdateFitEntryForNonVTFComp (VtfInfo); > - return EFI_SUCCESS; > - } > - > - Fp =3D fopen (LongFilePath (VtfInfo->CompBinName), "rb"); > - > - if (Fp =3D=3D NULL) { > - Error (NULL, 0, 0001, "Error opening file", VtfInfo->CompBinName); > - return EFI_ABORTED; > - } > - > - FileSize =3D _filelength (fileno (Fp)); > - if ((VtfInfo->CompType =3D=3D COMP_TYPE_FIT_PAL_B) || (VtfInfo->CompTy= pe =3D=3D COMP_TYPE_FIT_PAL_A_SPECIFIC)) { > - > - // > - // BUGBUG: Satish to correct > - // > - FileSize -=3D SIZE_OF_PAL_HEADER; > - } > - > - if (VtfInfo->PreferredSize) { > - if (FileSize > VtfInfo->CompSize) { > - fclose (Fp); > - Error (NULL, 0, 2000, "Invalid parameter", "The component size is = more than specified size."); > - return EFI_ABORTED; > - } > - > - FileSize =3D VtfInfo->CompSize; > - } > - > - Buffer =3D malloc ((UINTN) FileSize); > - if (Buffer =3D=3D NULL) { > - fclose (Fp); > - return EFI_OUT_OF_RESOURCES; > - } > - memset (Buffer, 0, (UINTN) FileSize); > - > - if ((VtfInfo->CompType =3D=3D COMP_TYPE_FIT_PAL_B) || (VtfInfo->CompTy= pe =3D=3D COMP_TYPE_FIT_PAL_A_SPECIFIC)) { > - > - // > - // Read first 64 bytes of PAL header and use it to find version info > - // > - fread (Buffer, sizeof (UINT8), SIZE_OF_PAL_HEADER, Fp); > - > - // > - // PAL header contains the version info. Currently, we will use the = header > - // to read version info and then discard. > - // > - if (!VtfInfo->VersionPresent) { > - GetComponentVersionInfo (VtfInfo, Buffer); > - } > - } > - > - fread (Buffer, sizeof (UINT8), (UINTN) FileSize, Fp); > - fclose (Fp); > - > - // > - // If it is non PAL_B component, pass the entire buffer to get the ver= sion > - // info and implement any specific case inside GetComponentVersionInfo= . > - // > - if (VtfInfo->CompType !=3D COMP_TYPE_FIT_PAL_B) { > - if (!VtfInfo->VersionPresent) { > - GetComponentVersionInfo (VtfInfo, Buffer); > - } > - } > - > - if (VtfInfo->LocationType =3D=3D SECOND_VTF) { > - > - CompStartAddress =3D (Vtf2LastStartAddress - FileSize); > - } else { > - CompStartAddress =3D (Vtf1LastStartAddress - FileSize); > - } > - > - if (VtfInfo->CompType =3D=3D COMP_TYPE_FIT_PAL_B) { > - Aligncheck =3D CheckAddressAlignment (CompStartAddress, 32 * 1024, &= NumAdjustByte); > - } else { > - Aligncheck =3D CheckAddressAlignment (CompStartAddress, 8, &NumAdjus= tByte); > - } > - > - if (!Aligncheck) { > - CompStartAddress -=3D NumAdjustByte; > - } > - > - if (VtfInfo->LocationType =3D=3D SECOND_VTF && SecondVTF =3D=3D TRUE) = { > - Vtf2LastStartAddress =3D CompStartAddress; > - Vtf2TotalSize +=3D (UINT32) (FileSize + NumAdjustByte); > - Status =3D UpdateVtfBuffer (CompStartAddress, Buffer, FileSize, SECO= ND_VTF); > - } else if (VtfInfo->LocationType =3D=3D FIRST_VTF) { > - Vtf1LastStartAddress =3D CompStartAddress; > - Vtf1TotalSize +=3D (UINT32) (FileSize + NumAdjustByte); > - Status =3D UpdateVtfBuffer (CompStartAddress, Buffer, FileSize, FIRS= T_VTF); > - } else { > - free (Buffer); > - Error (NULL, 0, 2000,"Invalid Parameter", "There's component in seco= nd VTF so second BaseAddress and Size must be specified!"); > - return EFI_INVALID_PARAMETER; > - } > - > - if (EFI_ERROR (Status)) { > - free (Buffer); > - return EFI_ABORTED; > - } > - > - GetNextAvailableFitPtr (&CompFitPtr); > - if (CompFitPtr =3D=3D NULL) { > - free (Buffer); > - return EFI_ABORTED; > - } > - > - CompFitPtr->CompAddress =3D CompStartAddress | IPF_CACHE_BIT; > - if ((FileSize % 16) !=3D 0) { > - free (Buffer); > - Error (NULL, 0, 2000, "Invalid parameter", "Binary FileSize must be = a multiple of 16."); > - return EFI_INVALID_PARAMETER; > - } > - //assert ((FileSize % 16) =3D=3D 0); > - CompFitPtr->CompSize =3D (UINT32) (FileSize / 16); > - CompFitPtr->CompVersion =3D MAKE_VERSION (VtfInfo->MajorVer, VtfInfo->= MinorVer); > - CompFitPtr->CvAndType =3D CV_N_TYPE (VtfInfo->CheckSumRequired, VtfI= nfo->CompType); > - if (VtfInfo->CheckSumRequired) { > - CompFitPtr->CheckSum =3D 0; > - CompFitPtr->CheckSum =3D CalculateChecksum8 (Buffer, (UINTN) FileSi= ze); > - } > - > - // > - // Free the buffer > - // > - if (Buffer) { > - free (Buffer); > - } > - > - // > - // Update the SYM file for this component based on it's start address. > - // > - Status =3D UpdateSymFile (CompStartAddress, SymFileName, VtfInfo->Comp= SymName, FileSize); > - if (EFI_ERROR (Status)) { > - > - // > - // At this time, SYM files are not required, so continue on error. > - // > - } > - > - // !!!!!!!!!!!!!!!!!!!!! > - // BUGBUG: > - // This part of the code is a temporary line since PEICORE is going to= be inside > - // VTF till we work out how to determine the SALE_ENTRY through it. We= will need > - // to clarify so many related questions > - // !!!!!!!!!!!!!!!!!!!!!!! > - > - if (VtfInfo->CompType =3D=3D COMP_TYPE_FIT_PEICORE) { > - Status =3D UpdateEntryPoint (VtfInfo, &CompStartAddress); > - } > - > - return Status; > -} > - > -EFI_STATUS > -CreateAndUpdatePAL_A ( > - IN PARSED_VTF_INFO *VtfInfo > - ) > -/*++ > - > -Routine Description: > - > - This function reads the binary file for each components and update the= m > - in VTF Buffer as well as FIT table > - > -Arguments: > - > - VtfInfo - Pointer to Parsed Info > - > -Returns: > - > - EFI_ABORTED - Due to one of the following reasons: > - (a)Error Opening File > - (b)The PAL_A Size is more than specified size= status > - One of the values mentioned below returned= from > - call to UpdateSymFile > - EFI_SUCCESS - The function completed successfully. > - EFI_INVALID_PARAMETER - One of the input parameters was invalid. > - EFI_ABORTED - An error occurred.UpdateSymFile > - EFI_OUT_OF_RESOURCES - Memory allocation failed. > - > ---*/ > -{ > - EFI_STATUS Status; > - UINT64 PalStartAddress; > - UINT64 AbsAddress; > - UINTN RelativeAddress; > - UINT64 FileSize; > - UINT8 *Buffer; > - FILE *Fp; > - FIT_TABLE *PalFitPtr; > - > - Fp =3D fopen (LongFilePath (VtfInfo->CompBinName), "rb"); > - > - if (Fp =3D=3D NULL) { > - Error (NULL, 0, 0001, "Error opening file", VtfInfo->CompBinName); > - return EFI_ABORTED; > - } > - > - FileSize =3D _filelength (fileno (Fp)); > - if (FileSize < 64) { > - fclose (Fp); > - Error (NULL, 0, 2000, "Invalid parameter", "PAL_A bin header is 64 b= ytes, so the Bin size must be larger than 64 bytes!"); > - return EFI_INVALID_PARAMETER; > - } > - FileSize -=3D SIZE_OF_PAL_HEADER; > - > - > - if (VtfInfo->PreferredSize) { > - if (FileSize > VtfInfo->CompSize) { > - fclose (Fp); > - Error (NULL, 0, 2000, "Invalid parameter", "The PAL_A Size is more= than the specified size."); > - return EFI_ABORTED; > - } > - > - FileSize =3D VtfInfo->CompSize; > - } > - > - Buffer =3D malloc ((UINTN) FileSize); > - if (Buffer =3D=3D NULL) { > - fclose (Fp); > - return EFI_OUT_OF_RESOURCES; > - } > - memset (Buffer, 0, (UINTN) FileSize); > - > - // > - // Read, Get version Info and discard the PAL header. > - // > - fread (Buffer, sizeof (UINT8), SIZE_OF_PAL_HEADER, Fp); > - > - // > - // Extract the version info from header of PAL_A. Once done, discrad t= his buffer > - // > - if (!VtfInfo->VersionPresent) { > - GetComponentVersionInfo (VtfInfo, Buffer); > - } > - > - // > - // Read PAL_A file in a buffer > - // > - fread (Buffer, sizeof (UINT8), (UINTN) FileSize, Fp); > - fclose (Fp); > - > - PalStartAddress =3D Fv1EndAddress - (SIZE_TO_OFFSET_PAL_A_END + = FileSize); > - Vtf1LastStartAddress =3D PalStartAddress; > - Vtf1TotalSize +=3D (UINT32) FileSize; > - Status =3D UpdateVtfBuffer (PalStartAddress, Buffer, FileSize, FI= RST_VTF); > - > - AbsAddress =3D Fv1EndAddress - SIZE_TO_PAL_A_FIT; > - GetRelativeAddressInVtfBuffer (AbsAddress, &RelativeAddress, FIRST_VTF= ); > - PalFitPtr =3D (FIT_TABLE *) RelativeAddress; > - PalFitPtr->CompAddress =3D PalStartAddress | IPF_CACHE_BIT; > - //assert ((FileSize % 16) =3D=3D 0); > - if ((FileSize % 16) !=3D 0) { > - free (Buffer); > - Error (NULL, 0, 2000, "Invalid parameter", "Binary FileSize must be = a multiple of 16."); > - return EFI_INVALID_PARAMETER; > - } > - > - PalFitPtr->CompSize =3D (UINT32) (FileSize / 16); > - PalFitPtr->CompVersion =3D MAKE_VERSION (VtfInfo->MajorVer, VtfInfo->= MinorVer); > - PalFitPtr->CvAndType =3D CV_N_TYPE (VtfInfo->CheckSumRequired, VtfI= nfo->CompType); > - if (VtfInfo->CheckSumRequired) { > - PalFitPtr->CheckSum =3D 0; > - PalFitPtr->CheckSum =3D CalculateChecksum8 (Buffer, (UINTN) FileSize= ); > - } > - > - if (Buffer) { > - free (Buffer); > - } > - > - // > - // Update the SYM file for this component based on it's start address. > - // > - Status =3D UpdateSymFile (PalStartAddress, SymFileName, VtfInfo->CompS= ymName, FileSize); > - if (EFI_ERROR (Status)) { > - > - // > - // At this time, SYM files are not required, so continue on error. > - // > - } > - > - return Status; > -} > - > -EFI_STATUS > -CreateFitTableAndInitialize ( > - IN PARSED_VTF_INFO *VtfInfo > - ) > -/*++ > - > -Routine Description: > - > - This function creates and intializes FIT table which would be used to > - add component info inside this > - > -Arguments: > - > - VtfInfo - Pointer to Parsed Info > - > -Returns: > - > - EFI_ABORTED - Aborted due to no size information > - EFI_SUCCESS - The function completed successfully > - > ---*/ > -{ > - UINT64 PalFitTableAdd; > - UINT64 FitTableAdd; > - UINT64 FitTableAddressOffset; > - FIT_TABLE *PalFitPtr; > - FIT_TABLE *FitStartPtr; > - UINTN NumFitComp; > - UINTN RelativeAddress; > - UINTN Index; > - > - if (!VtfInfo->PreferredSize) { > - Error (NULL, 0, 2000, "Invalid parameter", "FIT could not be allocat= ed because there is no size information."); > - return EFI_ABORTED; > - } > - > - if ((VtfInfo->CompSize % 16) !=3D 0) { > - Error (NULL, 0, 2000, "Invalid parameter", "Invalid FIT Table Size, = it is not a multiple of 16 bytes. Please correct the size."); > - } > - > - PalFitTableAdd =3D Fv1EndAddress - SIZE_TO_PAL_A_FIT; > - GetRelativeAddressInVtfBuffer (PalFitTableAdd, &RelativeAddress, FIRST= _VTF); > - PalFitPtr =3D (FIT_TABLE *) RelativeAddress; > - PalFitTableAdd =3D (PalFitPtr->CompAddress - VtfInfo->CompSize)= ; > - > - FitTableAdd =3D (PalFitPtr->CompAddress - 0x10) - VtfInfo->C= ompSize; > - FitTableAddressOffset =3D Fv1EndAddress - (SIZE_IA32_RESET_VECT + SIZE= _SALE_ENTRY_POINT + SIZE_FIT_TABLE_ADD); > - GetRelativeAddressInVtfBuffer (FitTableAddressOffset, &RelativeAddress= , FIRST_VTF); > - *(UINT64 *) RelativeAddress =3D FitTableAdd; > - > - GetRelativeAddressInVtfBuffer (FitTableAdd, &RelativeAddress, FIRST_VT= F); > - > - // > - // Update Fit Table with FIT Signature and FIT info in first 16 bytes. > - // > - FitStartPtr =3D (FIT_TABLE *) RelativeAddress; > - > - strncpy ((CHAR8 *) &FitStartPtr->CompAddress, FIT_SIGNATURE, 8); // "= _FIT_ " > - assert (((VtfInfo->CompSize & 0x00FFFFFF) % 16) =3D=3D 0); > - FitStartPtr->CompSize =3D (VtfInfo->CompSize & 0x00FFFFFF) / 16; > - FitStartPtr->CompVersion =3D MAKE_VERSION (VtfInfo->MajorVer, VtfInfo= ->MinorVer); > - > - // > - // BUGBUG: If a checksum is required, add code to checksum the FIT tab= le. Also > - // determine what to do for things like the FV component that aren't e= asily checksummed. > - // The checksum will be done once we are done with all the componet up= date in the FIT > - // table > - // > - FitStartPtr->CvAndType =3D CV_N_TYPE (VtfInfo->CheckSumRequired, VtfI= nfo->CompType); > - > - NumFitComp =3D FitStartPtr->CompSize; > - > - FitStartPtr++; > - > - // > - // Intialize remaining FIT table space to UNUSED fit component type > - // so that when we need to create a FIT entry for a component, we can > - // locate a free one and use it. > - // > - for (Index =3D 0; Index < (NumFitComp - 1); Index++) { > - FitStartPtr->CvAndType =3D 0x7F; // Initialize all with UNUSED > - FitStartPtr++; > - } > - > - Vtf1TotalSize +=3D VtfInfo->CompSize; > - Vtf1LastStartAddress -=3D VtfInfo->CompSize; > - > - return EFI_SUCCESS; > -} > - > -EFI_STATUS > -WriteVtfBinary ( > - IN CHAR8 *FileName, > - IN UINT32 VtfSize, > - IN LOC_TYPE LocType > - ) > -/*++ > - > -Routine Description: > - > - Write Firmware Volume from memory to a file. > - > -Arguments: > - > - FileName - Output File Name which needed to be created/ > - VtfSize - FileSize > - LocType - The type of the VTF > - > -Returns: > - > - EFI_ABORTED - Returned due to one of the following resons: > - (a) Error Opening File > - (b) Failing to copy buffers > - EFI_SUCCESS - The fuction completes successfully > - > ---*/ > -{ > - FILE *Fp; > - UINTN NumByte; > - VOID *VtfBuffer; > - UINTN RelativeAddress; > - > - if (LocType =3D=3D FIRST_VTF) { > - GetRelativeAddressInVtfBuffer (Vtf1LastStartAddress, &RelativeAddres= s, FIRST_VTF); > - VtfBuffer =3D (VOID *) RelativeAddress; > - } else { > - GetRelativeAddressInVtfBuffer (Vtf2LastStartAddress, &RelativeAddres= s, SECOND_VTF); > - VtfBuffer =3D (VOID *) RelativeAddress; > - } > - > - Fp =3D fopen (LongFilePath (FileName), "wb"); > - if (Fp =3D=3D NULL) { > - Error (NULL, 0, 0001, "Error opening file", FileName); > - return EFI_ABORTED; > - } > - > - NumByte =3D fwrite (VtfBuffer, sizeof (UINT8), (UINTN) VtfSize, Fp); > - > - if (Fp) { > - fclose (Fp); > - } > - > - if (NumByte !=3D (sizeof (UINT8) * VtfSize)) { > - Error (NULL, 0, 0002, "Error writing file", FileName); > - return EFI_ABORTED; > - } > - > - return EFI_SUCCESS; > -} > - > -EFI_STATUS > -UpdateVtfBuffer ( > - IN UINT64 StartAddress, > - IN UINT8 *Buffer, > - IN UINT64 DataSize, > - IN LOC_TYPE LocType > - ) > -/*++ > - > -Routine Description: > - > - Update the Firmware Volume Buffer with requested buffer data > - > -Arguments: > - > - StartAddress - StartAddress in buffer. This number will automaticall= y > - point to right address in buffer where data needed > - to be updated. > - Buffer - Buffer pointer from data will be copied to memory map= ped buffer. > - DataSize - Size of the data needed to be copied. > - LocType - The type of the VTF: First or Second > - > -Returns: > - > - EFI_ABORTED - The input parameter is error > - EFI_SUCCESS - The function completed successfully > - > ---*/ > -{ > - UINT8 *LocalBufferPtrToWrite; > - > - if (LocType =3D=3D FIRST_VTF) { > - if ((StartAddress | IPF_CACHE_BIT) < (Vtf1LastStartAddress | IPF_CAC= HE_BIT)) { > - Error (NULL, 0, 2000, "Invalid parameter", "Start Address is less = than the VTF start address."); > - return EFI_ABORTED; > - } > - > - LocalBufferPtrToWrite =3D (UINT8 *) Vtf1EndBuffer; > - > - LocalBufferPtrToWrite -=3D (Fv1EndAddress - StartAddress); > - > - } else { > - > - if ((StartAddress | IPF_CACHE_BIT) < (Vtf2LastStartAddress | IPF_CAC= HE_BIT)) { > - Error (NULL, 0, 2000, "Invalid parameter", "Error StartAddress"); > - return EFI_ABORTED; > - } > - LocalBufferPtrToWrite =3D (UINT8 *) Vtf2EndBuffer; > - LocalBufferPtrToWrite -=3D (Fv2EndAddress - StartAddress); > - } > - > - memcpy (LocalBufferPtrToWrite, Buffer, (UINTN) DataSize); > - > - return EFI_SUCCESS; > -} > - > -EFI_STATUS > -UpdateFfsHeader ( > - IN UINT32 TotalVtfSize, > - IN LOC_TYPE LocType > - ) > -/*++ > - > -Routine Description: > - > - Update the Firmware Volume Buffer with requested buffer data > - > -Arguments: > - > - TotalVtfSize - Size of the VTF > - Fileoffset - The start of the file relative to the start of the = FV. > - LocType - The type of the VTF > - > -Returns: > - > - EFI_SUCCESS - The function completed successfully > - EFI_INVALID_PARAMETER - The Ffs File Header Pointer is NULL > - > ---*/ > -{ > - EFI_FFS_FILE_HEADER *FileHeader; > - UINTN RelativeAddress; > - EFI_GUID EfiFirmwareVolumeTopFileGuid =3D EFI_FFS_VOLUME_TO= P_FILE_GUID; > - > - // > - // Find the VTF file header location > - // > - if (LocType =3D=3D FIRST_VTF) { > - GetRelativeAddressInVtfBuffer (Vtf1LastStartAddress, &RelativeAddres= s, FIRST_VTF); > - FileHeader =3D (EFI_FFS_FILE_HEADER *) RelativeAddress; > - } else { > - GetRelativeAddressInVtfBuffer (Vtf2LastStartAddress, &RelativeAddres= s, SECOND_VTF); > - FileHeader =3D (EFI_FFS_FILE_HEADER *) RelativeAddress; > - } > - > - if (FileHeader =3D=3D NULL) { > - return EFI_INVALID_PARAMETER; > - } > - > - // > - // write header > - // > - memset (FileHeader, 0, sizeof (EFI_FFS_FILE_HEADER)); > - memcpy (&FileHeader->Name, &EfiFirmwareVolumeTopFileGuid, sizeof (EFI_= GUID)); > - FileHeader->Type =3D EFI_FV_FILETYPE_RAW; > - FileHeader->Attributes =3D FFS_ATTRIB_CHECKSUM; > - > - // > - // Now FileSize includes the EFI_FFS_FILE_HEADER > - // > - FileHeader->Size[0] =3D (UINT8) (TotalVtfSize & 0x000000FF); > - FileHeader->Size[1] =3D (UINT8) ((TotalVtfSize & 0x0000FF00) >> 8); > - FileHeader->Size[2] =3D (UINT8) ((TotalVtfSize & 0x00FF0000) >> 16); > - > - // > - // Fill in checksums and state, all three must be zero for the checksu= ms. > - // > - FileHeader->IntegrityCheck.Checksum.Header =3D 0; > - FileHeader->IntegrityCheck.Checksum.File =3D 0; > - FileHeader->State =3D 0; > - FileHeader->IntegrityCheck.Checksum.Header =3D CalculateChecksum8 ((U= INT8 *) FileHeader, sizeof (EFI_FFS_FILE_HEADER)); > - FileHeader->IntegrityCheck.Checksum.File =3D CalculateChecksum8 ((U= INT8 *) (FileHeader + 1), TotalVtfSize - sizeof > (EFI_FFS_FILE_HEADER)); > - FileHeader->State =3D EFI_FILE_HEADER_CONSTR= UCTION | EFI_FILE_HEADER_VALID | > EFI_FILE_DATA_VALID; > - > - return EFI_SUCCESS; > -} > - > -EFI_STATUS > -ValidateAddressAndSize ( > - IN UINT64 BaseAddress, > - IN UINT64 FwVolSize > - ) > -/*++ > - > -Routine Description: > - > - Update the Firmware Volume Buffer with requested buffer data > - > -Arguments: > - > - BaseAddress - Base address for the Fw Volume. > - > - FwVolSize - Total Size of the FwVolume to which VTF will be attac= hed.. > - > -Returns: > - > - EFI_SUCCESS - The function completed successfully > - EFI_UNSUPPORTED - The input parameter is error > - > ---*/ > -{ > - if ((FwVolSize > 0x40) && ((BaseAddress + FwVolSize) % 8 =3D=3D 0)) { > - return EFI_SUCCESS; > - } > - > - return EFI_UNSUPPORTED; > -} > - > -EFI_STATUS > -UpdateIA32ResetVector ( > - IN CHAR8 *FileName, > - IN UINT64 FirstFwVSize > - ) > -/*++ > - > -Routine Description: > - > - Update the 16 byte IA32 Reset vector to maintain the compatibility > - > -Arguments: > - > - FileName - Binary file name which contains the IA32 Reset vector i= nfo.. > - FirstFwVSize - Total Size of the FwVolume to which VTF will be attache= d.. > - > -Returns: > - > - EFI_SUCCESS - The function completed successfully > - EFI_ABORTED - Invalid File Size > - EFI_INVALID_PARAMETER - Bad File Name > - EFI_OUT_OF_RESOURCES - Memory allocation failed. > - > ---*/ > -{ > - UINT8 *Buffer; > - UINT8 *LocalVtfBuffer; > - UINTN FileSize; > - FILE *Fp; > - > - if (!strcmp (FileName, "")) { > - return EFI_INVALID_PARAMETER; > - } > - > - Fp =3D fopen (LongFilePath (FileName), "rb"); > - > - if (Fp =3D=3D NULL) { > - Error (NULL, 0, 0001, "Error opening file", FileName); > - return EFI_ABORTED; > - } > - > - FileSize =3D _filelength (fileno (Fp)); > - > - if (FileSize > 16) { > - fclose (Fp); > - return EFI_ABORTED; > - } > - > - Buffer =3D malloc (FileSize); > - if (Buffer =3D=3D NULL) { > - fclose (Fp); > - return EFI_OUT_OF_RESOURCES; > - } > - > - fread (Buffer, sizeof (UINT8), FileSize, Fp); > - > - LocalVtfBuffer =3D (UINT8 *) Vtf1EndBuffer - SIZE_IA32_RESET_VECT; > - memcpy (LocalVtfBuffer, Buffer, FileSize); > - > - if (Buffer) { > - free (Buffer); > - } > - > - if (Fp !=3D NULL) { > - fclose (Fp); > - } > - return EFI_SUCCESS; > -} > - > -VOID > -CleanUpMemory ( > - VOID > - ) > -/*++ > - > -Routine Description: > - > - This function cleans up any allocated buffer > - > -Arguments: > - > - NONE > - > -Returns: > - > - NONE > - > ---*/ > -{ > - PARSED_VTF_INFO *TempFileListPtr; > - > - if (Vtf1Buffer) { > - free (Vtf1Buffer); > - } > - > - if (Vtf2Buffer) { > - free (Vtf2Buffer); > - } > - > - // > - // Cleanup the buffer which was allocated to read the file names from = FV.INF > - // > - FileListPtr =3D FileListHeadPtr; > - while (FileListPtr !=3D NULL) { > - TempFileListPtr =3D FileListPtr->NextVtfInfo; > - free (FileListPtr); > - FileListPtr =3D TempFileListPtr; > - } > -} > - > -EFI_STATUS > -ProcessAndCreateVtf ( > - IN UINT64 Size > - ) > -/*++ > - > -Routine Description: > - > - This function process the link list created during INF file parsing > - and create component in VTF and updates its info in FIT table > - > -Arguments: > - > - Size - Size of the Firmware Volume of which, this VTF belongs to. > - > -Returns: > - > - EFI_UNSUPPORTED - Unknown FIT type > - EFI_SUCCESS - The function completed successfully > - > ---*/ > -{ > - EFI_STATUS Status; > - PARSED_VTF_INFO *ParsedInfoPtr; > - > - Status =3D EFI_SUCCESS; > - > - ParsedInfoPtr =3D FileListHeadPtr; > - > - while (ParsedInfoPtr !=3D NULL) { > - > - switch (ParsedInfoPtr->CompType) { > - // > - // COMP_TYPE_FIT_HEADER is a special case, hence handle it here > - // > - case COMP_TYPE_FIT_HEADER: > - //COMP_TYPE_FIT_HEADER 0x00 > - Status =3D CreateFitTableAndInitialize (ParsedInfoPtr); > - break; > - > - // > - // COMP_TYPE_FIT_PAL_A is a special case, hence handle it here > - // > - case COMP_TYPE_FIT_PAL_A: > - //COMP_TYPE_FIT_PAL_A 0x0F > - Status =3D CreateAndUpdatePAL_A (ParsedInfoPtr); > - > - // > - // Based on VTF specification, once the PAL_A component has been w= ritten, > - // update the Firmware Volume info as FIT table. This will be util= ized > - // to extract the Firmware Volume Start address where this VTF wil= l be > - // of part. > - // > - if (Status =3D=3D EFI_SUCCESS) { > - UpdateFitEntryForFwVolume (Size); > - } > - break; > - > - case COMP_TYPE_FIT_FV_BOOT: > - //COMP_TYPE_FIT_FV_BOOT 0x7E > - // > - // Since FIT entry for Firmware Volume has been created and it is > - // located at (PAL_A start - 16 byte). So we will not process any > - // Firmware Volume related entry from INF file > - // > - Status =3D EFI_SUCCESS; > - break; > - > - default: > - // > - // Any other component type should be handled here. This will crea= te the > - // image in specified VTF and create appropriate entry about this > - // component in FIT Entry. > - // > - Status =3D CreateAndUpdateComponent (ParsedInfoPtr); > - if (EFI_ERROR (Status)) { > - Error (NULL, 0, 0002, "Error updating component", ParsedInfoPtr-= >CompName); > - return EFI_ABORTED; > - } else { > - break;} > - } > - > - ParsedInfoPtr =3D ParsedInfoPtr->NextVtfInfo; > - } > - return Status; > -} > - > -EFI_STATUS > -GenerateVtfImage ( > - IN UINT64 StartAddress1, > - IN UINT64 Size1, > - IN UINT64 StartAddress2, > - IN UINT64 Size2, > - IN FILE *fp > - ) > -/*++ > - > -Routine Description: > - > - This is the main function which will be called from application. > - > -Arguments: > - > - StartAddress1 - The start address of the first VTF > - Size1 - The size of the first VTF > - StartAddress2 - The start address of the second VTF > - Size2 - The size of the second VTF > - fp - The pointer to BSF inf file > - > -Returns: > - > - EFI_OUT_OF_RESOURCES - Can not allocate memory > - The return value can be any of the values > - returned by the calls to following functions: > - GetVtfRelatedInfoFromInfFile > - ProcessAndCreateVtf > - UpdateIA32ResetVector > - UpdateFfsHeader > - WriteVtfBinary > - > ---*/ > -{ > - EFI_STATUS Status; > - FILE *VtfFP; > - > - Status =3D EFI_UNSUPPORTED; > - VtfFP =3D fp; > - > - if (StartAddress2 =3D=3D 0) { > - SecondVTF =3D FALSE; > - } else { > - SecondVTF =3D TRUE; > - } > - > - Fv1BaseAddress =3D StartAddress1; > - Fv1EndAddress =3D Fv1BaseAddress + Size1; > - if (Fv1EndAddress !=3D 0x100000000ULL || Size1 < 0x100000) { > - Error (NULL, 0, 2000, "Invalid parameter", "Error BaseAddress and Si= ze parameters!"); > - if (Size1 < 0x100000) { > - Error (NULL, 0, 2000, "Invalid parameter", "The FwVolumeSize must = be larger than 1M!"); > - } else if (SecondVTF !=3D TRUE) { > - Error (NULL, 0, 2000, "Invalid parameter", "BaseAddress + FwVolume= Size must equal 0x100000000!"); > - } > - Usage(); > - return EFI_INVALID_PARAMETER; > - } > - > - // > - // The image buffer for the First VTF > - // > - Vtf1Buffer =3D malloc ((UINTN) Size1); > - if (Vtf1Buffer =3D=3D NULL) { > - Error (NULL, 0, 4001, "Resource", "Not enough resources available to= create memory mapped file for the Boot Strap File!"); > - return EFI_OUT_OF_RESOURCES; > - } > - memset (Vtf1Buffer, 0x00, (UINTN) Size1); > - Vtf1EndBuffer =3D (UINT8 *) Vtf1Buffer + Size1; > - Vtf1LastStartAddress =3D Fv1EndAddress | IPF_CACHE_BIT; > - > - if (SecondVTF) { > - Fv2BaseAddress =3D StartAddress2; > - Fv2EndAddress =3D Fv2BaseAddress + Size2; > - if (Fv2EndAddress !=3D StartAddress1) { > - Error (NULL, 0, 2000, "Invalid parameter", "Error BaseAddress and = Size parameters!"); > - if (SecondVTF =3D=3D TRUE) { > - Error (NULL, 0, 2000, "Invalid parameter", "FirstBaseAddress + F= irstFwVolumeSize must equal 0x100000000!"); > - Error (NULL, 0, 2000, "Invalid parameter", "SecondBaseAddress + = SecondFwVolumeSize must equal FirstBaseAddress!"); > - } > - Usage(); > - return EFI_INVALID_PARAMETER; > - } > - > - // > - // The image buffer for the second VTF > - // > - Vtf2Buffer =3D malloc ((UINTN) Size2); > - if (Vtf2Buffer =3D=3D NULL) { > - Error (NULL, 0, 4001, "Resource", "Not enough resources available = to create memory mapped file for the Boot Strap File!"); > - return EFI_OUT_OF_RESOURCES; > - } > - memset (Vtf2Buffer, 0x00, (UINTN) Size2); > - Vtf2EndBuffer =3D (UINT8 *) Vtf2Buffer + Size2; > - Vtf2LastStartAddress =3D Fv2EndAddress | IPF_CACHE_BIT; > - } > - > - Status =3D GetVtfRelatedInfoFromInfFile (VtfFP); > - > - if (Status !=3D EFI_SUCCESS) { > - Error (NULL, 0, 0003, "Error parsing file", "the input file."); > - CleanUpMemory (); > - return Status; > - } > - > - Status =3D ProcessAndCreateVtf (Size1); > - if (Status !=3D EFI_SUCCESS) { > - CleanUpMemory (); > - return Status; > - } > - > - if (SectionOptionFlag) { > - Status =3D UpdateIA32ResetVector (IA32BinFile, Vtf1TotalSize); > - if (Status !=3D EFI_SUCCESS) { > - CleanUpMemory (); > - return Status; > - } > - } > - > - // > - // Re arrange the FIT Table for Ascending order of their FIT Type.. > - // > - SortFitTable (); > - > - // > - // All components have been updated in FIT table. Now perform the FIT = table > - // checksum. The following function will check if Checksum is required= , > - // if yes, then it will perform the checksum otherwise not. > - // > - CalculateFitTableChecksum (); > - > - // > - // Write the FFS header > - // > - Vtf1TotalSize +=3D sizeof (EFI_FFS_FILE_HEADER); > - Vtf1LastStartAddress -=3D sizeof (EFI_FFS_FILE_HEADER); > - > - Status =3D UpdateFfsHeader (Vtf1TotalSize, FIRST_VTF); > - if (Status !=3D EFI_SUCCESS) { > - CleanUpMemory (); > - return Status; > - } > - // > - // Update the VTF buffer into specified VTF binary file > - // > - Status =3D WriteVtfBinary (OutFileName1, Vtf1TotalSize, FIRST_VTF); > - > - if (SecondVTF) { > - Vtf2TotalSize +=3D sizeof (EFI_FFS_FILE_HEADER); > - Vtf2LastStartAddress -=3D sizeof (EFI_FFS_FILE_HEADER); > - Status =3D UpdateFfsHeader (Vtf2TotalSize, SECOND_VTF); > - if (Status !=3D EFI_SUCCESS) { > - CleanUpMemory (); > - return Status; > - } > - > - // > - // Update the VTF buffer into specified VTF binary file > - // > - Status =3D WriteVtfBinary (OutFileName2, Vtf2TotalSize, SECOND_VTF)= ; > - } > - > - CleanUpMemory (); > - > - return Status; > -} > - > -EFI_STATUS > -PeimFixupInFitTable ( > - IN UINT64 StartAddress > - ) > -/*++ > - > -Routine Description: > - > - This function is an entry point to fixup SAL-E entry point. > - > -Arguments: > - > - StartAddress - StartAddress for PEIM..... > - > -Returns: > - > - EFI_SUCCESS - The function completed successfully > - EFI_ABORTED - Error Opening File > - EFI_OUT_OF_RESOURCES - System out of resources for memory allocation. > - > ---*/ > -{ > - EFI_STATUS Status; > - FILE *Fp; > - UINT64 *StartAddressPtr; > - UINTN FirstFwVSize; > - > - StartAddressPtr =3D malloc (sizeof (UINT64)); > - if (StartAddressPtr =3D=3D NULL) { > - return EFI_OUT_OF_RESOURCES; > - } > - *StartAddressPtr =3D StartAddress; > - > - Fp =3D fopen (LongFilePath (OutFileName1), "rb"); > - > - if (Fp =3D=3D NULL) { > - Error (NULL, 0, 0001, "Error opening file", OutFileName1); > - if (StartAddressPtr) { > - free (StartAddressPtr); > - } > - return EFI_ABORTED; > - } > - > - FirstFwVSize =3D _filelength (fileno (Fp)); > - fseek (Fp, (long) (FirstFwVSize - (UINTN) (SIZE_IA32_RESET_VECT + SIZE= _SALE_ENTRY_POINT)), SEEK_SET); > - fwrite ((VOID *) StartAddressPtr, sizeof (UINT64), 1, Fp); > - > - if (Fp) { > - fclose (Fp); > - } > - > - if (StartAddressPtr) { > - free (StartAddressPtr); > - } > - > - Status =3D EFI_SUCCESS; > - return Status; > -} > - > -EFI_STATUS > -UpdateSymFile ( > - IN UINT64 BaseAddress, > - IN CHAR8 *DestFileName, > - IN CHAR8 *SourceFileName, > - IN UINT64 FileSize > - > - ) > -/*++ > - > -Routine Description: > - > - This function adds the SYM tokens in the source file to the destinatio= n file. > - The SYM tokens are updated to reflect the base address. > - > -Arguments: > - > - BaseAddress - The base address for the new SYM tokens. > - DestFileName - The destination file. > - SourceFileName - The source file. > - FileSize - Size of bin file. > - > -Returns: > - > - EFI_SUCCESS - The function completed successfully. > - EFI_INVALID_PARAMETER - One of the input parameters was invalid. > - EFI_ABORTED - An error occurred. > - > ---*/ > -{ > - FILE *SourceFile; > - FILE *DestFile; > - CHAR8 Buffer[MAX_LONG_FILE_PATH]; > - CHAR8 Type[MAX_LONG_FILE_PATH]; > - CHAR8 Address[MAX_LONG_FILE_PATH]; > - CHAR8 Section[MAX_LONG_FILE_PATH]; > - CHAR8 Token[MAX_LONG_FILE_PATH]; > - CHAR8 BaseToken[MAX_LONG_FILE_PATH]; > - CHAR8 FormatString[MAX_LINE_LEN]; > - UINT64 TokenAddress; > - long StartLocation; > - > - // > - // Verify input parameters. > - // > - if (BaseAddress =3D=3D 0 || DestFileName =3D=3D NULL || SourceFileName= =3D=3D NULL) { > - return EFI_INVALID_PARAMETER; > - } > - > - // > - // Open the source file > - // > - SourceFile =3D fopen (LongFilePath (SourceFileName), "r"); > - if (SourceFile =3D=3D NULL) { > - > - // > - // SYM files are not required. > - // > - return EFI_SUCCESS; > - } > - > - // > - // Use the file name minus extension as the base for tokens > - // > - if (strlen (SourceFileName) >=3D MAX_LONG_FILE_PATH) { > - fclose (SourceFile); > - Error (NULL, 0, 2000, "Invalid parameter", "The source file name is = too long."); > - return EFI_ABORTED; > - } > - strncpy (BaseToken, SourceFileName, MAX_LONG_FILE_PATH - 1); > - BaseToken[MAX_LONG_FILE_PATH - 1] =3D 0; > - strtok (BaseToken, ". \t\n"); > - if (strlen (BaseToken) + strlen ("__") >=3D MAX_LONG_FILE_PATH) { > - fclose (SourceFile); > - Error (NULL, 0, 2000, "Invalid parameter", "The source file name is = too long."); > - return EFI_ABORTED; > - } > - strncat (BaseToken, "__", MAX_LONG_FILE_PATH - strlen (BaseToken) - 1)= ; > - > - // > - // Open the destination file > - // > - DestFile =3D fopen (LongFilePath (DestFileName), "a+"); > - if (DestFile =3D=3D NULL) { > - fclose (SourceFile); > - Error (NULL, 0, 0001, "Error opening file", DestFileName); > - return EFI_ABORTED; > - } > - > - // > - // If this is the beginning of the output file, write the symbol forma= t info. > - // > - if (fseek (DestFile, 0, SEEK_END) !=3D 0) { > - fclose (SourceFile); > - fclose (DestFile); > - Error (NULL, 0, 2000, "Invalid parameter", "not at the beginning of = the output file."); > - return EFI_ABORTED; > - } > - > - StartLocation =3D ftell (DestFile); > - > - if (StartLocation =3D=3D 0) { > - fprintf (DestFile, "TEXTSYM format | V1.0\n"); > - } else if (StartLocation =3D=3D -1) { > - fclose (SourceFile); > - fclose (DestFile); > - Error (NULL, 0, 2000, "Invalid parameter", "StartLocation error"); > - return EFI_ABORTED; > - } > - > - // > - // Read the first line > - // > - if (fgets (Buffer, MAX_LONG_FILE_PATH, SourceFile) =3D=3D NULL) { > - Buffer[0] =3D 0; > - } > - > - // > - // Make sure it matches the expected sym format > - // > - if (strcmp (Buffer, "TEXTSYM format | V1.0\n")) { > - fclose (SourceFile); > - fclose (DestFile); > - Error (NULL, 0, 2000, "Invalid parameter", "The symbol file does not= match the expected TEXTSYM format (V1.0.)"); > - return EFI_ABORTED; > - } > - > - // > - // Generate the format string for fscanf > - // > - sprintf ( > - FormatString, > - "%%%us | %%%us | %%%us | %%%us\n", > - (unsigned) sizeof (Type) - 1, > - (unsigned) sizeof (Address) - 1, > - (unsigned) sizeof (Section) - 1, > - (unsigned) sizeof (Token) - 1 > - ); > - > - // > - // Read in the file > - // > - while (feof (SourceFile) =3D=3D 0) { > - > - // > - // Read a line > - // > - if (fscanf (SourceFile, FormatString, Type, Address, Section, Token)= =3D=3D 4) { > - > - // > - // Get the token address > - // > - AsciiStringToUint64 (Address, TRUE, &TokenAddress); > - if (TokenAddress > FileSize) { > - // > - // Symbol offset larger than FileSize. This Symbol can't be in B= in file. Don't print them. > - // > - break; > - } > - > - // > - // Add the base address, the size of the FFS file header and the s= ize of the peim header. > - // > - TokenAddress +=3D BaseAddress &~IPF_CACHE_BIT; > - > - fprintf (DestFile, "%s | %016llX | ", Type, (unsigned long long) T= okenAddress); > - fprintf (DestFile, "%s | %s\n %s\n", Section, Token, BaseToken)= ; > - } > - } > - > - fclose (SourceFile); > - fclose (DestFile); > - return EFI_SUCCESS; > -} > - > -EFI_STATUS > -CalculateFitTableChecksum ( > - VOID > - ) > -/*++ > - > -Routine Description: > - > - This function will perform byte checksum on the FIT table, if the the = checksum required > - field is set to CheckSum required. If the checksum is not required the= n checksum byte > - will have value as 0;. > - > -Arguments: > - > - NONE > - > -Returns: > - > - Status - Value returned by call to CalculateChecksum8 () > - EFI_SUCCESS - The function completed successfully > - > ---*/ > -{ > - FIT_TABLE *TmpFitPtr; > - UINT64 FitTableAdd; > - UINT64 FitTableAddOffset; > - UINTN RelativeAddress; > - UINTN Size; > - > - // > - // Read the Fit Table address from Itanium-based address map. > - // > - FitTableAddOffset =3D Fv1EndAddress - (SIZE_IA32_RESET_VECT + SIZE_SAL= E_ENTRY_POINT + SIZE_FIT_TABLE_ADD); > - > - // > - // Translate this Itanium-based address in terms of local buffer addre= ss which > - // contains the image for Boot Strapped File > - // > - GetRelativeAddressInVtfBuffer (FitTableAddOffset, &RelativeAddress, FI= RST_VTF); > - FitTableAdd =3D *(UINTN *) RelativeAddress; > - > - GetRelativeAddressInVtfBuffer (FitTableAdd, &RelativeAddress, FIRST_VT= F); > - > - TmpFitPtr =3D (FIT_TABLE *) RelativeAddress; > - > - Size =3D TmpFitPtr->CompSize * 16; > - > - if ((TmpFitPtr->CvAndType & CHECKSUM_BIT_MASK) >> 7) { > - TmpFitPtr->CheckSum =3D 0; > - TmpFitPtr->CheckSum =3D CalculateChecksum8 ((UINT8 *) TmpFitPtr, Siz= e); > - } else { > - TmpFitPtr->CheckSum =3D 0; > - } > - > - return EFI_SUCCESS; > -} > - > -VOID > -Version ( > - VOID > - ) > -/*++ > - > -Routine Description: > - > - Displays the standard utility information to SDTOUT > - > -Arguments: > - > - None > - > -Returns: > - > - None > - > ---*/ > -{ > - fprintf (stdout, "%s Version %d.%d %s \n", UTILITY_NAME, UTILITY_MAJOR= _VERSION, UTILITY_MINOR_VERSION, > __BUILD_VERSION); > -} > - > -VOID > -Usage ( > - VOID > - ) > -/*++ > - > -Routine Description: > - > - Displays the utility usage syntax to STDOUT > - > -Arguments: > - > - None > - > -Returns: > - > - None > - > ---*/ > -{ > - // > - // Summary usage > - // > - fprintf (stdout, "Usage: %s [options] <-f input_file> <-r BaseAddress>= <-s FwVolumeSize>\n\n", UTILITY_NAME); > - > - // > - // Copyright declaration > - // > - fprintf (stdout, "Copyright (c) 2007 - 2018, Intel Corporation. All ri= ghts reserved.\n\n"); > - // > - // Details Option > - // > - fprintf (stdout, "Options:\n"); > - fprintf (stdout, " -f Input_file, --filename Input_file\n\ > - Input_file is name of the BS Image INF file\n"); > - fprintf (stdout, " -r BaseAddress, --baseaddr BaseAddress\n\ > - BaseAddress is the starting address of Firmware = Volume\n\ > - where Boot Strapped Image will reside.\n"); > - fprintf (stdout, " -s FwVolumeSize, --size FwVolumeSize\n\ > - FwVolumeSize is the size of Firmware Volume.\n")= ; > - fprintf (stdout, " -o FileName, --output FileName\n\ > - File will be created to store the ouput content.= \n"); > - fprintf (stdout, " -v, --verbose Turn on verbose output with = informational messages.\n"); > - fprintf (stdout, " --version Show program's version numbe= r and exit.\n"); > - fprintf (stdout, " -h, --help Show this help message and e= xit.\n"); > - fprintf (stdout, " -q, --quiet Disable all messages except = FATAL ERRORS.\n"); > - fprintf (stdout, " -d, --debug [#, 0-9] Enable debug messages at lev= el #.\n"); > -} > - > -int > -main ( > - IN int argc, > - IN char **argv > - ) > -/*++ > - > -Routine Description: > - > - This utility uses GenVtf.dll to build a Boot Strap File Image which wi= ll be > - part of firmware volume image. > - > -Arguments: > - > - argc - The count of the parameters > - argv - The parameters > - > - > -Returns: > - > - 0 - No error conditions detected. > - 1 - One or more of the input parameters is invalid. > - 2 - A resource required by the utility was unavailable. > - - Most commonly this will be memory allocation or file creation. > - 3 - GenFvImage.dll could not be loaded. > - 4 - Error executing the GenFvImage dll. > - 5 - Now this tool does not support the IA32 platform > - > ---*/ > -{ > - UINT8 Index; > - UINT64 StartAddress1; > - UINT64 StartAddress2; > - UINT64 FwVolSize1; > - UINT64 FwVolSize2; > - BOOLEAN FirstRoundO; > - BOOLEAN FirstRoundB; > - BOOLEAN FirstRoundS; > - EFI_STATUS Status; > - FILE *VtfFP; > - CHAR8 *VtfFileName; > - > - SetUtilityName (UTILITY_NAME); > - > - // > - // Initialize variables > - // > - StartAddress1 =3D 0; > - StartAddress2 =3D 0; > - FwVolSize1 =3D 0; > - FwVolSize2 =3D 0; > - FirstRoundB =3D TRUE; > - FirstRoundS =3D TRUE; > - FirstRoundO =3D TRUE; > - DebugMode =3D FALSE; > - OutFileName1 =3D NULL; > - OutFileName2 =3D NULL; > - VtfFP =3D NULL; > - DebugLevel =3D 0; > - > - // > - // Verify the correct number of arguments > - // > - if (argc =3D=3D 1) { > - Usage(); > - return 0; > - } > - > - if ((strcmp(argv[1], "-h") =3D=3D 0) || (strcmp(argv[1], "--help") =3D= =3D 0)) { > - Usage(); > - return 0; > - } > - > - if ((strcmp(argv[1], "--version") =3D=3D 0)) { > - Version(); > - return 0; > - } > - > - // > - // Parse the command line arguments > - // > - for (Index =3D 1; Index < argc; Index +=3D 2) { > - if ((stricmp (argv[Index], "-o") =3D=3D 0) || (stricmp (argv[Index],= "--output") =3D=3D 0)) { > - if (argv[Index + 1] =3D=3D NULL || argv[Index + 1][0] =3D=3D '-') = { > - Error (NULL, 0, 1003, "Invalid option value", "Output file is mi= ssing for -o option"); > - goto ERROR; > - } > - // > - // Get the output file name > - // > - VTF_OUTPUT =3D TRUE; > - if (FirstRoundO) { > - // > - // It's the first output file name > - // > - OutFileName1 =3D (CHAR8 *)argv[Index+1]; > - FirstRoundO =3D FALSE; > - } else { > - // > - //It's the second output file name > - // > - OutFileName2 =3D (CHAR8 *)argv[Index+1]; > - } > - continue; > - } > - > - if ((stricmp (argv[Index], "-f") =3D=3D 0) || (stricmp (argv[Index],= "--filename") =3D=3D 0)) { > - if (argv[Index + 1] =3D=3D NULL || argv[Index + 1][0] =3D=3D '-') = { > - Error (NULL, 0, 1003, "Invalid option value", "BS Image INF file= is missing for -f option"); > - goto ERROR; > - } > - // > - // Get the input VTF file name > - // > - VtfFileName =3D argv[Index+1]; > - if (VtfFP !=3D NULL) { > - // > - // VTF file name has been given previously, override with the ne= w value > - // > - fclose (VtfFP); > - } > - VtfFP =3D fopen (LongFilePath (VtfFileName), "rb"); > - if (VtfFP =3D=3D NULL) { > - Error (NULL, 0, 0001, "Error opening file", VtfFileName); > - goto ERROR; > - } > - continue; > - } > - > - if ((stricmp (argv[Index], "-r") =3D=3D 0) || (stricmp (argv[Index],= "--baseaddr") =3D=3D 0)) { > - if (FirstRoundB) { > - Status =3D AsciiStringToUint64 (argv[Index + 1], FALSE, &St= artAddress1); > - FirstRoundB =3D FALSE; > - } else { > - Status =3D AsciiStringToUint64 (argv[Index + 1], FALSE, &StartAd= dress2); > - } > - if (Status !=3D EFI_SUCCESS) { > - Error (NULL, 0, 2000, "Invalid option value", "%s is Bad FV star= t address.", argv[Index + 1]); > - goto ERROR; > - } > - continue; > - } > - > - if ((stricmp (argv[Index], "-s") =3D=3D 0) || (stricmp (argv[Index],= "--size") =3D=3D 0)) { > - if (FirstRoundS) { > - Status =3D AsciiStringToUint64 (argv[Index + 1], FALSE, &Fw= VolSize1); > - FirstRoundS =3D FALSE; > - } else { > - Status =3D AsciiStringToUint64 (argv[Index + 1], FALSE, &FwVolSi= ze2); > - SecondVTF =3D TRUE; > - } > - > - if (Status !=3D EFI_SUCCESS) { > - Error (NULL, 0, 2000, "Invalid option value", "%s is Bad FV size= .", argv[Index + 1]); > - goto ERROR; > - } > - continue; > - } > - > - if ((stricmp (argv[Index], "-v") =3D=3D 0) || (stricmp (argv[Index],= "--verbose") =3D=3D 0)) { > - VerboseMode =3D TRUE; > - Index--; > - continue; > - } > - > - if ((stricmp (argv[Index], "-q") =3D=3D 0) || (stricmp (argv[Index],= "--quiet") =3D=3D 0)) { > - QuietMode =3D TRUE; > - Index--; > - continue; > - } > - > - if ((stricmp (argv[Index], "-d") =3D=3D 0) || (stricmp (argv[Index],= "--debug") =3D=3D 0)) { > - // > - // debug level specified > - // > - Status =3D AsciiStringToUint64(argv[Index + 1], FALSE, &DebugLevel= ); > - if (EFI_ERROR (Status)) { > - Error (NULL, 0, 1003, "Invalid option value", "%s =3D %s", argv[= Index], argv[Index + 1]); > - goto ERROR; > - } > - if (DebugLevel > 9) { > - Error (NULL, 0, 2000, "Invalid option value", "Unrecognized argu= ment %s.", argv[Index + 1]); > - goto ERROR; > - } > - if((DebugLevel <=3D 9) &&(DebugLevel >=3D 5)) { > - DebugMode =3D TRUE; > - } else { > - DebugMode =3D FALSE; > - } > - continue; > - } > - > - Error (NULL, 0, 2000, "Invalid parameter", "Unrecognized argument %s= .", argv[Index]); > - goto ERROR; > - } > - > - if (VtfFP =3D=3D NULL) { > - Error (NULL, 0, 2000, "Invalid parameter", "No BS Image INF file is = specified"); > - goto ERROR; > - } > - > - if (FirstRoundB) { > - Error (NULL, 0, 2000, "Invalid parameter", "No FV base address is sp= ecified"); > - goto ERROR; > - } > - > - if (FirstRoundS) { > - Error (NULL, 0, 2000, "Invalid parameter", "No FV Size is specified"= ); > - goto ERROR; > - } > - // > - // All Parameters has been parsed, now set the message print level > - // > - if (QuietMode) { > - SetPrintLevel(40); > - } else if (VerboseMode) { > - SetPrintLevel(15); > - } else if (DebugMode) { > - SetPrintLevel(DebugLevel); > - } > - > - if (VerboseMode) { > - VerboseMsg("%s tool start.\n", UTILITY_NAME); > - } > - > - if (VTF_OUTPUT =3D=3D FALSE) { > - if (SecondVTF =3D=3D TRUE) { > - OutFileName1 =3D VTF_OUTPUT_FILE1; > - OutFileName2 =3D VTF_OUTPUT_FILE2; > - } else { > - OutFileName1 =3D VTF_OUTPUT_FILE1; > - } > - SymFileName =3D VTF_SYM_FILE; > - } else { > - INTN OutFileNameLen; > - INTN NewIndex; > - > - assert (OutFileName1); > - OutFileNameLen =3D strlen(OutFileName1); > - > - for (NewIndex =3D OutFileNameLen; NewIndex > 0; --NewIndex) { > - if (OutFileName1[NewIndex] =3D=3D '/' || OutFileName1[NewIndex] = =3D=3D '\\') { > - break; > - } > - } > - if (NewIndex =3D=3D 0) { > - SymFileName =3D VTF_SYM_FILE; > - } else { > - INTN SymFileNameLen =3D NewIndex + 1 + strlen(VTF_SYM_FILE); > - SymFileName =3D malloc(SymFileNameLen + 1); > - if (SymFileName =3D=3D NULL) { > - Error (NULL, 0, 4001, "Resource", "memory cannot be allocated!")= ; > - goto ERROR; > - } > - memcpy(SymFileName, OutFileName1, NewIndex + 1); > - memcpy(SymFileName + NewIndex + 1, VTF_SYM_FILE, strlen(VTF_SYM_FI= LE)); > - SymFileName[SymFileNameLen] =3D '\0'; > - } > - if (DebugMode) { > - DebugMsg(UTILITY_NAME, 0, DebugLevel, SymFileName, NULL); > - } > - } > - > - // > - // Call the GenVtfImage > - // > - if (DebugMode) { > - DebugMsg(UTILITY_NAME, 0, DebugLevel, "Start to generate the VTF ima= ge\n", NULL); > - } > - Status =3D GenerateVtfImage (StartAddress1, FwVolSize1, StartAddress2,= FwVolSize2, VtfFP); > - > - if (EFI_ERROR (Status)) { > - switch (Status) { > - > - case EFI_INVALID_PARAMETER: > - Error (NULL, 0, 2000, "Invalid parameter", "Invalid parameter pass= ed to GenVtf function."); > - break; > - > - case EFI_ABORTED: > - Error (NULL, 0, 3000, "Invalid", "Error detected while creating th= e file image."); > - break; > - > - case EFI_OUT_OF_RESOURCES: > - Error (NULL, 0, 4002, "Resource", "GenVtfImage function could not = allocate required resources."); > - break; > - > - case EFI_VOLUME_CORRUPTED: > - Error (NULL, 0, 3000, "Invalid", "No base address was specified.")= ; > - break; > - > - default: > - Error (NULL, 0, 3000, "Invalid", "GenVtfImage function returned un= known status %x.", (int) Status ); > - break; > - } > - } > -ERROR: > - if (VtfFP !=3D NULL) { > - fclose (VtfFP); > - } > - > - if (DebugMode) { > - DebugMsg(UTILITY_NAME, 0, DebugLevel, "VTF image generated successfu= l\n", NULL); > - } > - > - if (VerboseMode) { > - VerboseMsg("%s tool done with return code is 0x%x.\n", UTILITY_NAME,= GetUtilityStatus ()); > - } > - return GetUtilityStatus(); > -} > diff --git a/BaseTools/Source/C/GenVtf/GenVtf.h b/BaseTools/Source/C/GenV= tf/GenVtf.h > deleted file mode 100644 > index 62c61aa84e..0000000000 > --- a/BaseTools/Source/C/GenVtf/GenVtf.h > +++ /dev/null > @@ -1,326 +0,0 @@ > -/** @file > -This file contains the relevant declarations required to generate Boot S= trap File > - > -Copyright (c) 1999 - 2018, Intel Corporation. All rights reserved.
> -This program and the accompanying materials are licensed and made availa= ble > -under the terms and conditions of the BSD License which accompanies this > -distribution. The full text of the license may be found at > -http://opensource.org/licenses/bsd-license.php > - > -THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, > -WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMP= LIED. > - > -**/ > - > -// > -// Module Coded to EFI 2.0 Coding Conventions > -// > -#ifndef __GEN_VTF_H__ > -#define __GEN_VTF_H__ > - > -// > -// External Files Referenced > -// > -#include > -#include > -#include > -#ifndef __GNUC__ > -#include > -#endif > -#include "assert.h" > -#include > -#include "ParseInf.h" > - > -// > -// Internal Constants > -// > -#define CV_N_TYPE(a,b) (UINT8)(((UINT8)a << 7) + (UINT8)b) /= / Keeps the CV and Type in same byte field > -#define MAKE_VERSION(a,b) (UINT16)(((UINT16)a << 8) + (UINT16)b) > - > -#define FILE_NAME_SIZE 256 > -#define COMPONENT_NAME_SIZE 128 > -#define VTF_INPUT_FILE "VTF.INF" > -#define VTF_OUTPUT_FILE1 "VTF1.RAW" > -#define VTF_OUTPUT_FILE2 "VTF2.RAW" > -#define VTF_SYM_FILE "Vtf.SYM" > -#define FIT_SIGNATURE "_FIT_ " > - > -// > -//Fit Type Definition > -// > -#define COMP_TYPE_FIT_HEADER 0x00 > -#define COMP_TYPE_FIT_PAL_B 0x01 > - > -// > -// This is generic PAL_A > -// > -#define COMP_TYPE_FIT_PAL_A 0x0F > -#define COMP_TYPE_FIT_PEICORE 0x10 > -#define COMP_TYPE_FIT_AUTOSCAN 0x30 > -#define COMP_TYPE_FIT_FV_BOOT 0x7E > - > -// > -//This is processor Specific PAL_A > -// > -#define COMP_TYPE_FIT_PAL_A_SPECIFIC 0x0E > -#define COMP_TYPE_FIT_UNUSED 0x7F > - > -#define FIT_TYPE_MASK 0x7F > -#define CHECKSUM_BIT_MASK 0x80 > - > -// > -// IPF processor address is cached bit > -// > -#define IPF_CACHE_BIT 0x8000000000000000ULL > - > -// > -// Size definition to calculate the location from top of address for > -// each component > -// > -#define SIZE_IA32_RESET_VECT 0x10 // 16 Bytes > -#define SIZE_SALE_ENTRY_POINT 0x08 // 8 Byte > -#define SIZE_FIT_TABLE_ADD 0x08 // 8 Byte > -#define SIZE_FIT_TABLE_PAL_A 0x10 > -#define SIZE_RESERVED 0x10 > - > - > -#define SIZE_TO_OFFSET_PAL_A_END (SIZE_IA32_RESET_VECT + SIZE_SALE_ENTR= Y_POINT + \ > - SIZE_FIT_TABLE_ADD + SIZE_FIT_TABLE_PA= L_A + \ > - SIZE_RESERVED) > -#define SIZE_TO_PAL_A_FIT (SIZE_IA32_RESET_VECT + SIZE_SALE_ENTR= Y_POINT + \ > - SIZE_FIT_TABLE_ADD + SIZE_FIT_TABLE_PA= L_A) > - > -#define SIZE_OF_PAL_HEADER 0x40 //PAL has 64 byte header > - > -// > -// Utility Name > -// > -#define UTILITY_NAME "GenVtf" > - > -// > -// Utility version information > -// > -#define UTILITY_MAJOR_VERSION 0 > -#define UTILITY_MINOR_VERSION 1 > -#define UTILITY_DATE __DATE__ > - > -// > -// The maximum number of arguments accepted from the command line. > -// > -#define ONE_VTF_ARGS 10 > -#define TWO_VTF_ARGS 12 > -#define THREE_VTF_ARGS 16 > - > -static BOOLEAN VerboseMode =3D FALSE; > - > -// > -// Internal Data Structure > -// > -typedef enum _LOC_TYPE > -{ > - NONE, // In case there is - INF file > - FIRST_VTF, // First VTF > - SECOND_VTF, // Outside VTF > -} LOC_TYPE; > - > -typedef struct _PARSED_VTF_INFO { > - CHAR8 CompName[COMPONENT_NAME_SIZE]; > - LOC_TYPE LocationType; > - UINT8 CompType; > - UINT8 MajorVer; > - UINT8 MinorVer; > - UINT8 CheckSumRequired; > - BOOLEAN VersionPresent; // If it is TRUE, then, Ver= sion is in INF file > - BOOLEAN PreferredSize; > - BOOLEAN PreferredAddress; > - CHAR8 CompBinName[FILE_NAME_SIZE]; > - CHAR8 CompSymName[FILE_NAME_SIZE]; > - UINTN CompSize; > - UINT64 CompPreferredAddress; > - UINT32 Align; > - > - // > - // Fixed - warning C4133: '=3D' : incompatible types - from 'struct _= ParsedVtfInfo *' to 'struct _PARSED_VTF_INFO *' > - // Fixed - warning C4133: '=3D' : incompatible types - from 'struct _= ParsedVtfInfo *' to 'struct _PARSED_VTF_INFO *' > - // Fixed - warning C4133: '=3D' : incompatible types - from 'struct _= ParsedVtfInfo *' to 'struct _PARSED_VTF_INFO *' > - // Fixed - warning C4133: '=3D' : incompatible types - from 'struct _= ParsedVtfInfo *' to 'struct _PARSED_VTF_INFO *' > - // > - struct _PARSED_VTF_INFO *NextVtfInfo; > -} PARSED_VTF_INFO; > - > -#pragma pack (1) > -typedef struct { > - UINT64 CompAddress; > - UINT32 CompSize; > - UINT16 CompVersion; > - UINT8 CvAndType; > - UINT8 CheckSum; > -} FIT_TABLE; > -#pragma pack () > - > -// > -// Function Prototype Declarations > -// > - > -EFI_STATUS > -UpdateVtfBuffer( > - IN UINT64 StartAddress, > - IN UINT8 *Buffer, > - IN UINT64 DataSize, > - IN LOC_TYPE LocType > - ) > -/*++ > - > -Routine Description: > - > - Update the Firmware Volume Buffer with requested buffer data > - > -Arguments: > - > - StartAddress - StartAddress in buffer. This number will automaticall= y > - point to right address in buffer where data needed > - to be updated. > - Buffer - Buffer pointer from data will be copied to memory map= ped buffer. > - DataSize - Size of the data needed to be copied. > - LocType - The type of the VTF > - > -Returns: > - > - EFI_ABORTED - The input parameter is error > - EFI_SUCCESS - The function completed successfully > - > ---*/ > -; > - > -EFI_STATUS > -UpdateSymFile ( > - IN UINT64 BaseAddress, > - IN CHAR8 *DestFileName, > - IN CHAR8 *SourceFileName, > - IN UINT64 FileSize > - ) > -/*++ > - > -Routine Description: > - > - This function adds the SYM tokens in the source file to the destinatio= n file. > - The SYM tokens are updated to reflect the base address. > - > -Arguments: > - > - BaseAddress - The base address for the new SYM tokens. > - DestFileName - The destination file. > - SourceFileName - The source file. > - FileSize - Size of bin file. > - > -Returns: > - > - EFI_SUCCESS - The function completed successfully. > - EFI_INVALID_PARAMETER - One of the input parameters was invalid. > - EFI_ABORTED - An error occurred. > - > ---*/ > -; > - > -EFI_STATUS > -CalculateFitTableChecksum ( > - VOID > - ) > -/*++ > - > -Routine Description: > - > - This function will perform byte checksum on the FIT table, if the the = checksum required > - field is set to CheckSum required. If the checksum is not required the= n checksum byte > - will have value as 0;. > - > -Arguments: > - > - NONE > - > -Returns: > - > - Status - Value returned by call to CalculateChecksum8 () > - EFI_SUCCESS - The function completed successfully > - > ---*/ > -; > - > -EFI_STATUS > -GenerateVtfImage ( > - IN UINT64 StartAddress1, > - IN UINT64 Size1, > - IN UINT64 StartAddress2, > - IN UINT64 Size2, > - IN FILE *fp > - ) > -/*++ > - > -Routine Description: > - > - This is the main function which will be called from application. > - > -Arguments: > - > - StartAddress1 - The start address of the first VTF > - Size1 - The size of the first VTF > - StartAddress2 - The start address of the second VTF > - Size2 - The size of the second VTF > - > -Returns: > - > - EFI_OUT_OF_RESOURCES - Can not allocate memory > - The return value can be any of the values > - returned by the calls to following functions: > - GetVtfRelatedInfoFromInfFile > - ProcessAndCreateVtf > - UpdateIA32ResetVector > - UpdateFfsHeader > - WriteVtfBinary > - > ---*/ > -; > - > -EFI_STATUS > -PeimFixupInFitTable ( > - IN UINT64 StartAddress > - ) > -/*++ > - > -Routine Description: > - > - This function is an entry point to fixup SAL-E entry point. > - > -Arguments: > - > - StartAddress - StartAddress for PEIM..... > - > -Returns: > - > - EFI_SUCCESS - The function completed successfully > - EFI_ABORTED - Error Opening File > - > ---*/ > -; > - > -VOID > -Usage ( > - VOID > - ) > -/*++ > - > -Routine Description: > - > - Displays the utility usage syntax to STDOUT > - > -Arguments: > - > - None > - > -Returns: > - > - None > - > ---*/ > -; > -#endif > diff --git a/BaseTools/Source/C/GenVtf/Makefile b/BaseTools/Source/C/GenV= tf/Makefile > deleted file mode 100644 > index 957f25bd16..0000000000 > --- a/BaseTools/Source/C/GenVtf/Makefile > +++ /dev/null > @@ -1,22 +0,0 @@ > -## @file > -# Windows makefile for 'GenVtf' module build. > -# > -# Copyright (c) 2007 - 2010, Intel Corporation. All rights reserved.
> -# This program and the accompanying materials > -# are licensed and made available under the terms and conditions of the = BSD License > -# which accompanies this distribution. The full text of the license may= be found at > -# http://opensource.org/licenses/bsd-license.php > -# > -# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, > -# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR I= MPLIED. > -# > -!INCLUDE ..\Makefiles\ms.common > - > -APPNAME =3D GenVtf > - > -LIBS =3D $(LIB_PATH)\Common.lib > - > -OBJECTS =3D GenVtf.obj > - > -!INCLUDE ..\Makefiles\ms.app > - > diff --git a/BaseTools/toolsetup.bat b/BaseTools/toolsetup.bat > index 67454ad74b..06a877ee6b 100755 > --- a/BaseTools/toolsetup.bat > +++ b/BaseTools/toolsetup.bat > @@ -265,7 +265,6 @@ IF NOT EXIST "%EDK_TOOLS_BIN%\GenFv.exe" goto check_c= _tools > IF NOT EXIST "%EDK_TOOLS_BIN%\GenFw.exe" goto check_c_tools > IF NOT EXIST "%EDK_TOOLS_BIN%\GenPage.exe" goto check_c_tools > IF NOT EXIST "%EDK_TOOLS_BIN%\GenSec.exe" goto check_c_tools > -IF NOT EXIST "%EDK_TOOLS_BIN%\GenVtf.exe" goto check_c_tools > IF NOT EXIST "%EDK_TOOLS_BIN%\Split.exe" goto check_c_tools > IF NOT EXIST "%EDK_TOOLS_BIN%\TianoCompress.exe" goto check_c_tools > IF NOT EXIST "%EDK_TOOLS_BIN%\VfrCompile.exe" goto check_c_tools > -- > 2.18.0.windows.1