BaseTools: Clean up source files
1. Do not use tab characters 2. No trailing white space in one line 3. All files must end with CRLF Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Liming Gao <liming.gao@intel.com> Cc: Yonghong Zhu <yonghong.zhu@intel.com> Reviewed-by: Yonghong Zhu <yonghong.zhu@intel.com>
This commit is contained in:
@@ -1,14 +1,14 @@
|
||||
/** @file
|
||||
This file contains functions required to generate a Firmware File System file.
|
||||
|
||||
Copyright (c) 2004 - 2017, Intel Corporation. All rights reserved.<BR>
|
||||
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 IMPLIED.
|
||||
Copyright (c) 2004 - 2018, Intel Corporation. All rights reserved.<BR>
|
||||
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 IMPLIED.
|
||||
|
||||
**/
|
||||
|
||||
@@ -76,7 +76,7 @@ STATIC EFI_GUID mZeroGuid = {0};
|
||||
STATIC EFI_GUID mEfiFfsSectionAlignmentPaddingGuid = EFI_FFS_SECTION_ALIGNMENT_PADDING_GUID;
|
||||
|
||||
STATIC
|
||||
VOID
|
||||
VOID
|
||||
Version (
|
||||
VOID
|
||||
)
|
||||
@@ -89,12 +89,12 @@ Routine Description:
|
||||
Arguments:
|
||||
|
||||
None
|
||||
|
||||
|
||||
Returns:
|
||||
|
||||
None
|
||||
|
||||
--*/
|
||||
|
||||
--*/
|
||||
{
|
||||
fprintf (stdout, "%s Version %d.%d %s \n", UTILITY_NAME, UTILITY_MAJOR_VERSION, UTILITY_MINOR_VERSION, __BUILD_VERSION);
|
||||
}
|
||||
@@ -124,11 +124,11 @@ Returns:
|
||||
// Summary usage
|
||||
//
|
||||
fprintf (stdout, "\nUsage: %s [options]\n\n", UTILITY_NAME);
|
||||
|
||||
|
||||
//
|
||||
// Copyright declaration
|
||||
//
|
||||
fprintf (stdout, "Copyright (c) 2007 - 2017, Intel Corporation. All rights reserved.\n\n");
|
||||
//
|
||||
fprintf (stdout, "Copyright (c) 2007 - 2018, Intel Corporation. All rights reserved.\n\n");
|
||||
|
||||
//
|
||||
// Details Option
|
||||
@@ -236,7 +236,7 @@ Returns:
|
||||
--*/
|
||||
{
|
||||
UINT8 Index = 0;
|
||||
|
||||
|
||||
if (String == NULL) {
|
||||
return EFI_FV_FILETYPE_ALL;
|
||||
}
|
||||
@@ -262,31 +262,31 @@ GetSectionContents (
|
||||
OUT UINT8 *PESectionNum
|
||||
)
|
||||
/*++
|
||||
|
||||
|
||||
Routine Description:
|
||||
|
||||
|
||||
Get the contents of all section files specified in InputFileName
|
||||
into FileBuffer.
|
||||
|
||||
|
||||
Arguments:
|
||||
|
||||
|
||||
InputFileName - Name of the input file.
|
||||
|
||||
|
||||
InputFileAlign - Alignment required by the input file data.
|
||||
|
||||
InputFileNum - Number of input files. Should be at least 1.
|
||||
|
||||
FileBuffer - Output buffer to contain data
|
||||
|
||||
BufferLength - On input, this is size of the FileBuffer.
|
||||
BufferLength - On input, this is size of the FileBuffer.
|
||||
On output, this is the actual length of the data.
|
||||
|
||||
MaxAlignment - The max alignment required by all the input file datas.
|
||||
|
||||
|
||||
PeSectionNum - Calculate the number of Pe/Te Section in this FFS file.
|
||||
|
||||
Returns:
|
||||
|
||||
|
||||
EFI_SUCCESS on successful return
|
||||
EFI_INVALID_PARAMETER if InputFileNum is less than 1 or BufferLength point is NULL.
|
||||
EFI_ABORTED if unable to open input file.
|
||||
@@ -323,8 +323,8 @@ Returns:
|
||||
while ((Size & 0x03) != 0) {
|
||||
Size++;
|
||||
}
|
||||
|
||||
//
|
||||
|
||||
//
|
||||
// Open file and read contents
|
||||
//
|
||||
InFile = fopen (LongFilePath (InputFileName[Index]), "rb");
|
||||
@@ -336,8 +336,8 @@ Returns:
|
||||
fseek (InFile, 0, SEEK_END);
|
||||
FileSize = ftell (InFile);
|
||||
fseek (InFile, 0, SEEK_SET);
|
||||
DebugMsg (NULL, 0, 9, "Input section files",
|
||||
"the input section name is %s and the size is %u bytes", InputFileName[Index], (unsigned) FileSize);
|
||||
DebugMsg (NULL, 0, 9, "Input section files",
|
||||
"the input section name is %s and the size is %u bytes", InputFileName[Index], (unsigned) FileSize);
|
||||
|
||||
//
|
||||
// Check this section is Te/Pe section, and Calculate the numbers of Te/Pe section.
|
||||
@@ -371,10 +371,10 @@ Returns:
|
||||
}
|
||||
}
|
||||
(*PESectionNum) ++;
|
||||
} else if (TempSectHeader.Type == EFI_SECTION_COMPRESSION ||
|
||||
} else if (TempSectHeader.Type == EFI_SECTION_COMPRESSION ||
|
||||
TempSectHeader.Type == EFI_SECTION_FIRMWARE_VOLUME_IMAGE) {
|
||||
//
|
||||
// for the encapsulated section, assume it contains Pe/Te section
|
||||
// for the encapsulated section, assume it contains Pe/Te section
|
||||
//
|
||||
(*PESectionNum) ++;
|
||||
}
|
||||
@@ -398,7 +398,7 @@ Returns:
|
||||
if ((InputFileAlign [Index] != 0) && (((Size + HeaderSize + TeOffset) % InputFileAlign [Index]) != 0)) {
|
||||
Offset = (Size + sizeof (EFI_COMMON_SECTION_HEADER) + HeaderSize + TeOffset + InputFileAlign [Index] - 1) & ~(InputFileAlign [Index] - 1);
|
||||
Offset = Offset - Size - HeaderSize - TeOffset;
|
||||
|
||||
|
||||
if (FileBuffer != NULL && ((Size + Offset) < *BufferLength)) {
|
||||
//
|
||||
// The maximal alignment is 64K, the raw section size must be less than 0xffffff
|
||||
@@ -425,7 +425,7 @@ Returns:
|
||||
SectHeader->CommonHeader.Type = EFI_SECTION_RAW;
|
||||
}
|
||||
}
|
||||
DebugMsg (NULL, 0, 9, "Pad raw section for section data alignment",
|
||||
DebugMsg (NULL, 0, 9, "Pad raw section for section data alignment",
|
||||
"Pad Raw section size is %u", (unsigned) Offset);
|
||||
|
||||
Size = Size + Offset;
|
||||
@@ -612,13 +612,13 @@ Returns:
|
||||
// unsigned 32-bit integer plus the size unit character.
|
||||
//
|
||||
CHAR8 AlignmentBuffer[16];
|
||||
|
||||
|
||||
//
|
||||
// Init local variables
|
||||
//
|
||||
LogLevel = 0;
|
||||
Index = 0;
|
||||
FfsAttrib = 0;
|
||||
FfsAttrib = 0;
|
||||
FfsAlign = 0;
|
||||
FfsFiletype = EFI_FV_FILETYPE_ALL;
|
||||
OutputFileName = NULL;
|
||||
@@ -649,12 +649,12 @@ Returns:
|
||||
if ((stricmp (argv[0], "-h") == 0) || (stricmp (argv[0], "--help") == 0)) {
|
||||
Version ();
|
||||
Usage ();
|
||||
return STATUS_SUCCESS;
|
||||
return STATUS_SUCCESS;
|
||||
}
|
||||
|
||||
if (stricmp (argv[0], "--version") == 0) {
|
||||
Version ();
|
||||
return STATUS_SUCCESS;
|
||||
return STATUS_SUCCESS;
|
||||
}
|
||||
|
||||
while (argc > 0) {
|
||||
@@ -670,7 +670,7 @@ Returns:
|
||||
}
|
||||
argc -= 2;
|
||||
argv += 2;
|
||||
continue;
|
||||
continue;
|
||||
}
|
||||
|
||||
if ((stricmp (argv[0], "-o") == 0) || (stricmp (argv[0], "--outputfile") == 0)) {
|
||||
@@ -681,7 +681,7 @@ Returns:
|
||||
OutputFileName = argv[1];
|
||||
argc -= 2;
|
||||
argv += 2;
|
||||
continue;
|
||||
continue;
|
||||
}
|
||||
|
||||
if ((stricmp (argv[0], "-g") == 0) || (stricmp (argv[0], "--fileguid") == 0)) {
|
||||
@@ -755,7 +755,7 @@ Returns:
|
||||
return STATUS_ERROR;
|
||||
}
|
||||
memset (InputFileName, 0, (MAXIMUM_INPUT_FILE_NUM * sizeof (CHAR8 *)));
|
||||
|
||||
|
||||
InputFileAlign = (UINT32 *) malloc (MAXIMUM_INPUT_FILE_NUM * sizeof (UINT32));
|
||||
if (InputFileAlign == NULL) {
|
||||
Error (NULL, 0, 4001, "Resource", "memory cannot be allocated!");
|
||||
@@ -771,7 +771,7 @@ Returns:
|
||||
InputFileName,
|
||||
(InputFileNum + MAXIMUM_INPUT_FILE_NUM) * sizeof (CHAR8 *)
|
||||
);
|
||||
|
||||
|
||||
if (InputFileName == NULL) {
|
||||
Error (NULL, 0, 4001, "Resource", "memory cannot be allocated!");
|
||||
free (InputFileAlign);
|
||||
@@ -783,7 +783,7 @@ Returns:
|
||||
InputFileAlign,
|
||||
(InputFileNum + MAXIMUM_INPUT_FILE_NUM) * sizeof (UINT32)
|
||||
);
|
||||
|
||||
|
||||
if (InputFileAlign == NULL) {
|
||||
Error (NULL, 0, 4001, "Resource", "memory cannot be allocated!");
|
||||
free (InputFileName);
|
||||
@@ -791,16 +791,16 @@ Returns:
|
||||
}
|
||||
memset (&(InputFileAlign[InputFileNum]), 0, (MAXIMUM_INPUT_FILE_NUM * sizeof (UINT32)));
|
||||
}
|
||||
|
||||
|
||||
InputFileName[InputFileNum] = argv[1];
|
||||
argc -= 2;
|
||||
argv += 2;
|
||||
|
||||
if (argc <= 0) {
|
||||
InputFileNum ++;
|
||||
InputFileNum ++;
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
//
|
||||
// Section File alignment requirement
|
||||
//
|
||||
@@ -834,7 +834,7 @@ Returns:
|
||||
argv += 2;
|
||||
}
|
||||
InputFileNum ++;
|
||||
continue;
|
||||
continue;
|
||||
}
|
||||
|
||||
if ((stricmp (argv[0], "-n") == 0) || (stricmp (argv[0], "--sectionalign") == 0)) {
|
||||
@@ -886,25 +886,25 @@ Returns:
|
||||
//
|
||||
if (FfsFiletype == EFI_FV_FILETYPE_ALL) {
|
||||
Error (NULL, 0, 1001, "Missing option", "filetype");
|
||||
goto Finish;
|
||||
goto Finish;
|
||||
}
|
||||
|
||||
if (CompareGuid (&FileGuid, &mZeroGuid) == 0) {
|
||||
Error (NULL, 0, 1001, "Missing option", "fileguid");
|
||||
goto Finish;
|
||||
goto Finish;
|
||||
}
|
||||
|
||||
if (InputFileNum == 0) {
|
||||
Error (NULL, 0, 1001, "Missing option", "Input files");
|
||||
goto Finish;
|
||||
}
|
||||
|
||||
|
||||
//
|
||||
// Output input parameter information
|
||||
//
|
||||
VerboseMsg ("Fv File type is %s", mFfsFileType [FfsFiletype]);
|
||||
VerboseMsg ("Output file name is %s", OutputFileName);
|
||||
VerboseMsg ("FFS File Guid is %08X-%04X-%04X-%02X%02X-%02X%02X%02X%02X%02X%02X",
|
||||
VerboseMsg ("FFS File Guid is %08X-%04X-%04X-%02X%02X-%02X%02X%02X%02X%02X%02X",
|
||||
(unsigned) FileGuid.Data1,
|
||||
FileGuid.Data2,
|
||||
FileGuid.Data3,
|
||||
@@ -932,10 +932,10 @@ Returns:
|
||||
}
|
||||
VerboseMsg ("the %dth input section name is %s and section alignment is %u", Index, InputFileName[Index], (unsigned) InputFileAlign[Index]);
|
||||
}
|
||||
|
||||
|
||||
//
|
||||
// Calculate the size of all input section files.
|
||||
//
|
||||
//
|
||||
Status = GetSectionContents (
|
||||
InputFileName,
|
||||
InputFileAlign,
|
||||
@@ -946,20 +946,20 @@ Returns:
|
||||
&MaxAlignment,
|
||||
&PeSectionNum
|
||||
);
|
||||
|
||||
if ((FfsFiletype == EFI_FV_FILETYPE_SECURITY_CORE ||
|
||||
|
||||
if ((FfsFiletype == EFI_FV_FILETYPE_SECURITY_CORE ||
|
||||
FfsFiletype == EFI_FV_FILETYPE_PEI_CORE ||
|
||||
FfsFiletype == EFI_FV_FILETYPE_DXE_CORE) && (PeSectionNum != 1)) {
|
||||
Error (NULL, 0, 2000, "Invalid parameter", "Fv File type %s must have one and only one Pe or Te section, but %u Pe/Te section are input", mFfsFileType [FfsFiletype], PeSectionNum);
|
||||
goto Finish;
|
||||
}
|
||||
|
||||
|
||||
if ((FfsFiletype == EFI_FV_FILETYPE_PEIM ||
|
||||
FfsFiletype == EFI_FV_FILETYPE_DRIVER ||
|
||||
FfsFiletype == EFI_FV_FILETYPE_COMBINED_PEIM_DRIVER ||
|
||||
FfsFiletype == EFI_FV_FILETYPE_APPLICATION) && (PeSectionNum < 1)) {
|
||||
Error (NULL, 0, 2000, "Invalid parameter", "Fv File type %s must have at least one Pe or Te section, but no Pe/Te section is input", mFfsFileType [FfsFiletype]);
|
||||
goto Finish;
|
||||
goto Finish;
|
||||
}
|
||||
|
||||
if (Status == EFI_BUFFER_TOO_SMALL) {
|
||||
@@ -969,7 +969,7 @@ Returns:
|
||||
goto Finish;
|
||||
}
|
||||
memset (FileBuffer, 0, FileSize);
|
||||
|
||||
|
||||
//
|
||||
// read all input file contents into a buffer
|
||||
//
|
||||
@@ -993,7 +993,7 @@ Returns:
|
||||
Error (NULL, 0, 4001, "Resource", "memory cannot be allocated!");
|
||||
goto Finish;
|
||||
}
|
||||
|
||||
|
||||
//
|
||||
// Create Ffs file header.
|
||||
//
|
||||
@@ -1001,9 +1001,9 @@ Returns:
|
||||
memcpy (&FfsFileHeader.Name, &FileGuid, sizeof (EFI_GUID));
|
||||
FfsFileHeader.Type = FfsFiletype;
|
||||
//
|
||||
// Update FFS Alignment based on the max alignment required by input section files
|
||||
// Update FFS Alignment based on the max alignment required by input section files
|
||||
//
|
||||
VerboseMsg ("the max alignment of all input sections is %u", (unsigned) MaxAlignment);
|
||||
VerboseMsg ("the max alignment of all input sections is %u", (unsigned) MaxAlignment);
|
||||
for (Index = 0; Index < sizeof (mFfsValidAlign) / sizeof (UINT32) - 1; Index ++) {
|
||||
if ((MaxAlignment > mFfsValidAlign [Index]) && (MaxAlignment <= mFfsValidAlign [Index + 1])) {
|
||||
break;
|
||||
@@ -1012,8 +1012,8 @@ Returns:
|
||||
if (FfsAlign < Index) {
|
||||
FfsAlign = Index;
|
||||
}
|
||||
VerboseMsg ("the alignment of the generated FFS file is %u", (unsigned) mFfsValidAlign [FfsAlign + 1]);
|
||||
|
||||
VerboseMsg ("the alignment of the generated FFS file is %u", (unsigned) mFfsValidAlign [FfsAlign + 1]);
|
||||
|
||||
//
|
||||
// Now FileSize includes the EFI_FFS_FILE_HEADER
|
||||
//
|
||||
@@ -1056,15 +1056,15 @@ Returns:
|
||||
// Ffs header checksum = zero, so only need to calculate ffs body.
|
||||
//
|
||||
FfsFileHeader.IntegrityCheck.Checksum.File = CalculateChecksum8 (
|
||||
FileBuffer,
|
||||
FileBuffer,
|
||||
FileSize - HeaderSize
|
||||
);
|
||||
);
|
||||
} else {
|
||||
FfsFileHeader.IntegrityCheck.Checksum.File = FFS_FIXED_CHECKSUM;
|
||||
}
|
||||
|
||||
FfsFileHeader.State = EFI_FILE_HEADER_CONSTRUCTION | EFI_FILE_HEADER_VALID | EFI_FILE_DATA_VALID;
|
||||
|
||||
|
||||
//
|
||||
// Open output file to write ffs data.
|
||||
//
|
||||
|
Reference in New Issue
Block a user