Sync all bug fixes between EDK1.04 and EDK1.06 into EdkCompatibilityPkg.
git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@11094 6f19259b-4bc3-4df7-8a09-765794883524
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
/*++
|
||||
|
||||
Copyright (c) 2004 - 2007, Intel Corporation. All rights reserved.<BR>
|
||||
Copyright (c) 2004 - 2010, 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
|
||||
@@ -707,8 +707,13 @@ Returns:
|
||||
//
|
||||
FileLength = GetLength (FfsHeader->Size);
|
||||
OccupiedFileLength = (FileLength + 0x07) & (-1 << 3);
|
||||
#if (PI_SPECIFICATION_VERSION < 0x00010000)
|
||||
Checksum = CalculateSum8 ((UINT8 *) FfsHeader, FileLength - TailSize);
|
||||
Checksum = (UINT8) (Checksum - FfsHeader->State);
|
||||
#else
|
||||
Checksum = CalculateSum8 ((UINT8 *) ((UINTN)FfsHeader + sizeof (EFI_FFS_FILE_HEADER)), FileLength - TailSize - sizeof (EFI_FFS_FILE_HEADER));
|
||||
Checksum = Checksum + (UINT8)FfsHeader->IntegrityCheck.Checksum.File;
|
||||
#endif
|
||||
if (Checksum != 0) {
|
||||
Error (NULL, 0, 0, FileGuidString, "invalid FFS file checksum");
|
||||
return EFI_ABORTED;
|
||||
@@ -716,10 +721,10 @@ Returns:
|
||||
} else {
|
||||
//
|
||||
// File does not have a checksum
|
||||
// Verify contents are 0x5A as spec'd
|
||||
// Verify contents are 0x5A(Framework) and 0xAA(PI 1.0) as spec'd
|
||||
//
|
||||
if (FfsHeader->IntegrityCheck.Checksum.File != FFS_FIXED_CHECKSUM) {
|
||||
Error (NULL, 0, 0, FileGuidString, "invalid fixed FFS file header checksum");
|
||||
Error (NULL, 0, 0, FileGuidString, "invalid fixed file checksum");
|
||||
return EFI_ABORTED;
|
||||
}
|
||||
}
|
||||
|
@@ -1,6 +1,6 @@
|
||||
/*++
|
||||
|
||||
Copyright (c) 2004, Intel Corporation. All rights reserved.<BR>
|
||||
Copyright (c) 2004 - 2010, 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
|
||||
@@ -343,6 +343,152 @@ Returns:
|
||||
return EFI_NOT_FOUND;
|
||||
}
|
||||
|
||||
EFI_STATUS
|
||||
FindTokenInstanceInSection (
|
||||
IN MEMORY_FILE *InputFile,
|
||||
IN CHAR8 *Section,
|
||||
IN UINTN Instance,
|
||||
OUT CHAR8 *Token,
|
||||
OUT CHAR8 *Value
|
||||
)
|
||||
/*++
|
||||
|
||||
Routine Description:
|
||||
|
||||
Finds the Instance-th token in a section.
|
||||
|
||||
Arguments:
|
||||
|
||||
InputFile Memory file image.
|
||||
Section The section to search for, a string within [].
|
||||
Instance Specify the Instance-th token to search for, starting from zero
|
||||
Token The token name to return. Caller should allocate the buffer.
|
||||
Must be _MAX_PATH in size.
|
||||
Value The token value to return. Caller should allocate the buffer.
|
||||
Must be _MAX_PATH in size.
|
||||
|
||||
Returns:
|
||||
|
||||
EFI_SUCCESS Token and Value found.
|
||||
EFI_ABORTED Format error detected in INF file.
|
||||
EFI_INVALID_PARAMETER Input argument was null.
|
||||
EFI_LOAD_ERROR Error reading from the file.
|
||||
EFI_NOT_FOUND Section/Token/Value not found.
|
||||
|
||||
--*/
|
||||
{
|
||||
CHAR8 InputBuffer[_MAX_PATH];
|
||||
CHAR8 *CurrentToken;
|
||||
CHAR8 *CurrentValue;
|
||||
BOOLEAN ParseError;
|
||||
BOOLEAN ReadError;
|
||||
UINTN InstanceIndex;
|
||||
|
||||
//
|
||||
// Check input parameters
|
||||
//
|
||||
if (InputFile->FileImage == NULL ||
|
||||
InputFile->Eof == NULL ||
|
||||
InputFile->CurrentFilePointer == NULL ||
|
||||
Section == NULL ||
|
||||
strlen (Section) == 0 ||
|
||||
Value == NULL
|
||||
) {
|
||||
return EFI_INVALID_PARAMETER;
|
||||
}
|
||||
//
|
||||
// Initialize error codes
|
||||
//
|
||||
ParseError = FALSE;
|
||||
ReadError = FALSE;
|
||||
|
||||
//
|
||||
// Initialize our instance counter for the search token
|
||||
//
|
||||
InstanceIndex = 0;
|
||||
|
||||
if (FindSection (InputFile, Section)) {
|
||||
//
|
||||
// Found the desired section, find and read the desired token
|
||||
//
|
||||
do {
|
||||
//
|
||||
// Read a line from the file
|
||||
//
|
||||
if (ReadLine (InputFile, InputBuffer, _MAX_PATH) == NULL) {
|
||||
//
|
||||
// Error reading from input file
|
||||
//
|
||||
ReadError = TRUE;
|
||||
break;
|
||||
}
|
||||
//
|
||||
// Get the first non-whitespace string
|
||||
//
|
||||
CurrentToken = strtok (InputBuffer, " \t\n");
|
||||
if (CurrentToken == NULL) {
|
||||
//
|
||||
// Whitespace line found (or comment) so continue
|
||||
//
|
||||
CurrentToken = InputBuffer;
|
||||
continue;
|
||||
}
|
||||
//
|
||||
// Make sure we have not reached the end of the current section
|
||||
//
|
||||
if (CurrentToken[0] == '[') {
|
||||
break;
|
||||
}
|
||||
//
|
||||
// Check if it is the correct instance
|
||||
//
|
||||
if (Instance == InstanceIndex) {
|
||||
//
|
||||
// Copy the contents following the =
|
||||
//
|
||||
CurrentValue = strtok (NULL, "= \t\n");
|
||||
if (CurrentValue == NULL) {
|
||||
//
|
||||
// Nothing found, parsing error
|
||||
//
|
||||
ParseError = TRUE;
|
||||
} else {
|
||||
//
|
||||
// Copy the current token to the output value
|
||||
//
|
||||
strcpy (Token, CurrentToken);
|
||||
strcpy (Value, CurrentValue);
|
||||
return EFI_SUCCESS;
|
||||
}
|
||||
} else {
|
||||
//
|
||||
// Increment the occurrance found
|
||||
//
|
||||
InstanceIndex++;
|
||||
}
|
||||
} while (
|
||||
!ParseError &&
|
||||
!ReadError &&
|
||||
InputFile->CurrentFilePointer < InputFile->Eof &&
|
||||
CurrentToken[0] != '[' &&
|
||||
InstanceIndex <= Instance
|
||||
);
|
||||
}
|
||||
//
|
||||
// Distinguish between read errors and INF file format errors.
|
||||
//
|
||||
if (ReadError) {
|
||||
return EFI_LOAD_ERROR;
|
||||
}
|
||||
|
||||
if (ParseError) {
|
||||
return EFI_ABORTED;
|
||||
}
|
||||
|
||||
return EFI_NOT_FOUND;
|
||||
}
|
||||
|
||||
|
||||
EFI_STATUS
|
||||
StringToGuid (
|
||||
IN CHAR8 *AsciiGuidBuffer,
|
||||
|
@@ -1,6 +1,6 @@
|
||||
/*++
|
||||
|
||||
Copyright (c) 2004, Intel Corporation. All rights reserved.<BR>
|
||||
Copyright (c) 2004 - 2010, 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
|
||||
@@ -124,6 +124,42 @@ Returns:
|
||||
EFI_NOT_FOUND Section/Token/Value not found.
|
||||
|
||||
--*/
|
||||
|
||||
EFI_STATUS
|
||||
FindTokenInstanceInSection (
|
||||
IN MEMORY_FILE *InputFile,
|
||||
IN CHAR8 *Section,
|
||||
IN UINTN Instance,
|
||||
OUT CHAR8 *Token,
|
||||
OUT CHAR8 *Value
|
||||
)
|
||||
;
|
||||
/*++
|
||||
|
||||
Routine Description:
|
||||
|
||||
Finds the Instance-th token in a section.
|
||||
|
||||
Arguments:
|
||||
|
||||
InputFile Memory file image.
|
||||
Section The section to search for, a string within [].
|
||||
Instance Specify the Instance-th token to search for, starting from zero
|
||||
Token The token name to return. Caller should allocate the buffer.
|
||||
Must be _MAX_PATH in size.
|
||||
Value The token value to return. Caller should allocate the buffer.
|
||||
Must be _MAX_PATH in size.
|
||||
|
||||
Returns:
|
||||
|
||||
EFI_SUCCESS Token and Value found.
|
||||
EFI_ABORTED Format error detected in INF file.
|
||||
EFI_INVALID_PARAMETER Input argument was null.
|
||||
EFI_LOAD_ERROR Error reading from the file.
|
||||
EFI_NOT_FOUND Section/Token/Value not found.
|
||||
|
||||
--*/
|
||||
|
||||
EFI_STATUS
|
||||
StringToGuid (
|
||||
IN CHAR8 *AsciiGuidBuffer,
|
||||
|
@@ -1,6 +1,6 @@
|
||||
/*++
|
||||
|
||||
Copyright (c) 2006 - 2007, Intel Corporation. All rights reserved.<BR>
|
||||
Copyright (c) 2006 - 2010, 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
|
||||
@@ -25,6 +25,9 @@ Abstract:
|
||||
#include "TianoCommon.h"
|
||||
#include "Compress.h"
|
||||
|
||||
#define UTILITY_VERSION "v1.0"
|
||||
#define UTILITY_NAME "EfiCompress"
|
||||
|
||||
typedef enum {
|
||||
EFI_COMPRESS = 1,
|
||||
TIANO_COMPRESS = 2
|
||||
@@ -365,22 +368,32 @@ Usage (
|
||||
CHAR8 *ExeName
|
||||
)
|
||||
{
|
||||
fprintf (
|
||||
stdout,
|
||||
"\n"
|
||||
"Usage: %s [-tCompressType] InFileName OutFileName\n"
|
||||
" %*c [[-tCompressType] InFileName OutFileName ...]\n"
|
||||
"\n"
|
||||
"where:\n"
|
||||
" CompressType - optional compress algorithm (EFI | Tiano), case insensitive.\n"
|
||||
" If ommitted, compress type specified ahead is used, \n"
|
||||
" default is EFI\n"
|
||||
" e.g.: EfiCompress a.in a.out -tTiano b.in b.out \\ \n"
|
||||
" c.in c.out -tEFI d.in d.out\n"
|
||||
" a.in and d.in are compressed using EFI compress algorithm\n"
|
||||
" b.in and c.in are compressed using Tiano compress algorithm\n"
|
||||
" InFileName - input file path\n"
|
||||
" OutFileName - output file path\n",
|
||||
ExeName, strlen(ExeName), ' '
|
||||
);
|
||||
int Index;
|
||||
const char *Str[] = {
|
||||
UTILITY_NAME" "UTILITY_VERSION" - Intel EFI Compress Utility",
|
||||
" Copyright (C), 2006 - 2008 Intel Corporation",
|
||||
|
||||
#if ( defined(UTILITY_BUILD) && defined(UTILITY_VENDOR) )
|
||||
" Built from "UTILITY_BUILD", project of "UTILITY_VENDOR,
|
||||
#endif
|
||||
"",
|
||||
"Usage:",
|
||||
" "UTILITY_NAME" [OPTION] SOURCE DEST ...",
|
||||
"Description:",
|
||||
" Compress a list of SOURCE(s) to accordingly DEST(s) using the specified",
|
||||
" compress algorithm.",
|
||||
"Options:",
|
||||
" -tCompressAlgo Optional compress algorithm (EFI | Tiano), case insensitive.",
|
||||
" If ommitted, compress type specified ahead is used,",
|
||||
" default is EFI\n"
|
||||
" e.g.: EfiCompress a.in a.out -tTiano b.in b.out \\",
|
||||
" c.in c.out -tEFI d.in d.out",
|
||||
" a.in and d.in are compressed using EFI compress algorithm",
|
||||
" b.in and c.in are compressed using Tiano compress algorithm",
|
||||
NULL
|
||||
};
|
||||
for (Index = 0; Str[Index] != NULL; Index++) {
|
||||
fprintf (stdout, "%s\n", Str[Index]);
|
||||
}
|
||||
|
||||
}
|
||||
|
@@ -1,6 +1,6 @@
|
||||
/*++
|
||||
|
||||
Copyright (c) 2007, Intel Corporation. All rights reserved.<BR>
|
||||
Copyright (c) 2007 - 2010, 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
|
||||
@@ -45,7 +45,8 @@ Abstract:
|
||||
//
|
||||
// Version of this utility
|
||||
//
|
||||
#define UTILITY_VERSION "v2.6"
|
||||
#define UTILITY_NAME "EfiRom"
|
||||
#define UTILITY_VERSION "v2.7"
|
||||
|
||||
//
|
||||
// Define some status return values
|
||||
@@ -1311,39 +1312,42 @@ Returns:
|
||||
|
||||
--*/
|
||||
{
|
||||
int Index;
|
||||
static const char *Msg[] = {
|
||||
"EfiRom "UTILITY_VERSION" - Intel EFI Make Option ROM utility",
|
||||
" Copyright (C), 1999 - 2002 Intel Coproration\n",
|
||||
int Index;
|
||||
const char *Str[] = {
|
||||
UTILITY_NAME" "UTILITY_VERSION" - Intel EFI Make Option ROM Utility",
|
||||
" Copyright (C), 1999 - 2008 Intel Coproration",
|
||||
|
||||
#if ( defined(UTILITY_BUILD) && defined(UTILITY_VENDOR) )
|
||||
" Built from "UTILITY_BUILD", project of "UTILITY_VENDOR,
|
||||
#endif
|
||||
|
||||
"",
|
||||
"Usage:",
|
||||
" "UTILITY_NAME" [OPTION]... SOURCE ...",
|
||||
"Description:",
|
||||
" Create an option ROM image from a list of input files",
|
||||
" Usage: efirom {-p} [-v VendorId] [-d DeviceId] {-o OutFileName} ",
|
||||
" [-e|-b] [FileName(s)]",
|
||||
" where:",
|
||||
" VendorId - required hex PCI Vendor ID for the device",
|
||||
" DeviceId - required hex PCI Device ID for the device",
|
||||
" OutFileName - optional output file name. Default is the first input",
|
||||
" file name with a "DEFAULT_OUTPUT_EXTENSION" file extension",
|
||||
" FileNames - input PE32 or binary file name(s)",
|
||||
" BinFileName - input binary file name(s)",
|
||||
" -p - for verbose output",
|
||||
" -l - to not automatically set the LAST bit on the last file",
|
||||
" -b - following FileNames are binary files",
|
||||
" -e - following FileNames are EFI PE32 image files",
|
||||
" -ec - following FileNames are EFI PE32 image files, and should",
|
||||
" be compressed by this utility",
|
||||
" -cc ClassCode - to use hex ClassCode in the PCI data structure header for",
|
||||
" the following FileName",
|
||||
" -rev Revision - to use hex Revision in the PCI data structure header for",
|
||||
" the following FileName",
|
||||
" -dump - to dump the headers of an existing option ROM image",
|
||||
"",
|
||||
"Example usage: EfiRom -v 0xABCD -d 0x1234 -b File1.bin File2.bin -e File1.efi File2.efi",
|
||||
"",
|
||||
"Options:",
|
||||
" -v VendorId - required hex PCI Vendor ID for the device",
|
||||
" -d DeviceId - required hex PCI Device ID for the device",
|
||||
" -o OutFileName - optional output file name. Default is the first input",
|
||||
" file name with a "DEFAULT_OUTPUT_EXTENSION" file extension",
|
||||
" -e SOURCE ... - input are EFI PE32 image file(s)",
|
||||
" -b SOURCE ... - input are Legacy binary file(s)",
|
||||
" -ec SOURCE ... - input are EFI PE32 image file(s) and should be compressed",
|
||||
" -p - for verbose output",
|
||||
" -l - to not automatically set the LAST bit on the last file",
|
||||
" -cc ClassCode - to use hex ClassCode in the PCI data structure header for",
|
||||
" the following SOURCE(s)",
|
||||
" -rev Revision - to use hex Revision in the PCI data structure header for",
|
||||
" the following one SOURCE",
|
||||
" -dump - to dump the headers of an existing option ROM image",
|
||||
"Example Usage:",
|
||||
" EfiRom -v 0xABCD -d 0x1234 -b File1.bin File2.bin -e File1.efi File2.efi",
|
||||
NULL
|
||||
};
|
||||
|
||||
for (Index = 0; Msg[Index] != NULL; Index++) {
|
||||
fprintf (stdout, "%s\n", Msg[Index]);
|
||||
for (Index = 0; Str[Index] != NULL; Index++) {
|
||||
fprintf (stdout, "%s\n", Str[Index]);
|
||||
}
|
||||
}
|
||||
|
||||
|
@@ -1,6 +1,6 @@
|
||||
/*++
|
||||
|
||||
Copyright (c) 2004 - 2006, Intel Corporation. All rights reserved.<BR>
|
||||
Copyright (c) 2004 - 2010, 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
|
||||
@@ -29,7 +29,8 @@ Abstract:
|
||||
#include "EfiImage.h"
|
||||
#include "EfiUtilityMsgs.c"
|
||||
|
||||
#define UTILITY_NAME "FwImage"
|
||||
#define UTILITY_NAME "FwImage"
|
||||
#define UTILITY_VERSION "v1.0"
|
||||
|
||||
typedef union {
|
||||
IMAGE_NT_HEADERS32 PeHeader32;
|
||||
@@ -41,10 +42,33 @@ Usage (
|
||||
VOID
|
||||
)
|
||||
{
|
||||
printf ("Usage: " UTILITY_NAME " {-t time-date} {-e} {-r} [APPLICATION|BS_DRIVER|RT_DRIVER|SAL_RT_DRIVER|COMBINED_PEIM_DRIVER|SECURITY_CORE|PEI_CORE|PE32_PEIM|RELOCATABLE_PEIM] peimage [outimage]\n");
|
||||
printf (" -t: Add Time Stamp for output image\n");
|
||||
printf (" -e: Not clear ExceptionTable for output image\n");
|
||||
printf (" -r: Not strip zero pending of .reloc for output image\n");
|
||||
int Index;
|
||||
const char *Str[] = {
|
||||
UTILITY_NAME" "UTILITY_VERSION" - Intel Firmware Image Utility",
|
||||
" Copyright (C), 2004 - 2008 Intel Corporation",
|
||||
|
||||
#if ( defined(UTILITY_BUILD) && defined(UTILITY_VENDOR) )
|
||||
" Built from "UTILITY_BUILD", project of "UTILITY_VENDOR,
|
||||
#endif
|
||||
|
||||
"",
|
||||
"Usage:",
|
||||
" "UTILITY_NAME" [OPTION]... FWTYPE SOURCE [DEST]",
|
||||
"Description:",
|
||||
" Converts a pe32/pe32+ SOURCE to DEST with FWTYPE image type.",
|
||||
"Options:",
|
||||
" FWTYPE Can be one of APPLICATION, BS_DRIVER, RT_DRIVER, SAL_RT_DRIVER,",
|
||||
" COMBINED_PEIM_DRIVER, SECURITY_CORE, PEI_CORE, PE32_PEIM and",
|
||||
" RELOCATABLE_PEIM",
|
||||
" -t time-date Add Time Stamp for output image",
|
||||
" -e Not clear ExceptionTable for output image",
|
||||
" -r Not strip zero pending of .reloc for output image",
|
||||
NULL
|
||||
};
|
||||
|
||||
for (Index = 0; Str[Index] != NULL; Index++) {
|
||||
fprintf (stdout, "%s\n", Str[Index]);
|
||||
}
|
||||
}
|
||||
|
||||
static
|
||||
|
@@ -1,6 +1,6 @@
|
||||
/*++
|
||||
|
||||
Copyright (c) 2006, Intel Corporation. All rights reserved.<BR>
|
||||
Copyright (c) 2006 - 2010, 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
|
||||
@@ -39,7 +39,8 @@ Abstract:
|
||||
// #define STATUS_WARNING 1
|
||||
// #define STATUS_ERROR 2
|
||||
//
|
||||
#define UTILITY_NAME "GenAprioriFile"
|
||||
#define UTILITY_NAME "GenAprioriFile"
|
||||
#define UTILITY_VERSION "v1.0"
|
||||
//
|
||||
// Here's all our globals.
|
||||
//
|
||||
@@ -447,18 +448,26 @@ Returns:
|
||||
|
||||
--*/
|
||||
{
|
||||
int Index;
|
||||
static const char *Str[] = {
|
||||
UTILITY_NAME " -- create an Apriori file consumable by the DXE dispatcher",
|
||||
" Usage: "UTILITY_NAME " [Options]",
|
||||
" Options include:",
|
||||
" -h or -? for this help information",
|
||||
" -f AprioriFile parse the GUID'ed files in AprioriFile (required)",
|
||||
" -o OutputFile write output to OutputFile (required)",
|
||||
" -i for intelligent re-creation of OutputFile",
|
||||
" -null to terminate the output file with a NULL GUID",
|
||||
" -v verbose option",
|
||||
int Index;
|
||||
const char *Str[] = {
|
||||
UTILITY_NAME" "UTILITY_VERSION" - Intel Generate Apriori File Utility",
|
||||
" Copyright (C), 2006 - 2008 Intel Corporation",
|
||||
|
||||
#if ( defined(UTILITY_BUILD) && defined(UTILITY_VENDOR) )
|
||||
" Built from "UTILITY_BUILD", project of "UTILITY_VENDOR,
|
||||
#endif
|
||||
"",
|
||||
"Usage:",
|
||||
" "UTILITY_NAME" [OPTION]...",
|
||||
"Description:",
|
||||
" Generate an Apriori file consumable by the DXE or PEI dispatcher.",
|
||||
"Options:",
|
||||
" -h or -? for this help information",
|
||||
" -f AprioriFile parse the GUID'ed files in AprioriFile (required)",
|
||||
" -o OutputFile write output to OutputFile (required)",
|
||||
" -i for intelligent re-creation of OutputFile",
|
||||
" -null to terminate the output file with a NULL GUID",
|
||||
" -v verbose option",
|
||||
NULL
|
||||
};
|
||||
for (Index = 0; Str[Index] != NULL; Index++) {
|
||||
|
@@ -1,6 +1,6 @@
|
||||
/*++
|
||||
|
||||
Copyright (c) 2004 - 2006, Intel Corporation. All rights reserved.<BR>
|
||||
Copyright (c) 2004 - 2010, 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
|
||||
@@ -35,9 +35,9 @@ Abstract:
|
||||
|
||||
#include EFI_PROTOCOL_DEFINITION (GuidedSectionExtraction)
|
||||
|
||||
#define TOOLVERSION "0.2"
|
||||
#define UTILITY_VERSION "v1.0"
|
||||
|
||||
#define UTILITY_NAME "GenCrc32Section"
|
||||
#define UTILITY_NAME "GenCrc32Section"
|
||||
|
||||
EFI_GUID gEfiCrc32SectionGuid = EFI_CRC32_GUIDED_SECTION_EXTRACTION_PROTOCOL_GUID;
|
||||
|
||||
@@ -134,12 +134,26 @@ PrintUsage (
|
||||
VOID
|
||||
)
|
||||
{
|
||||
printf ("Usage:\n");
|
||||
printf (UTILITY_NAME " -i \"inputfile1\" \"inputfile2\" -o \"outputfile\" \n");
|
||||
printf (" -i \"inputfile\":\n ");
|
||||
printf (" specifies the input files that would be signed to CRC32 Guided section.\n");
|
||||
printf (" -o \"outputfile\":\n");
|
||||
printf (" specifies the output file that is a CRC32 Guided section.\n");
|
||||
int Index;
|
||||
const char *Str[] = {
|
||||
UTILITY_NAME" "UTILITY_VERSION" - Intel Generate CRC32 Section Utility",
|
||||
" Copyright (C), 2004 - 2008 Intel Corporation",
|
||||
|
||||
#if ( defined(UTILITY_BUILD) && defined(UTILITY_VENDOR) )
|
||||
" Built from "UTILITY_BUILD", project of "UTILITY_VENDOR,
|
||||
#endif
|
||||
"",
|
||||
"Usage:",
|
||||
" "UTILITY_NAME" [OPTION]",
|
||||
"Options:",
|
||||
" -i Input1 ... specifies the input file(s) that would be signed to CRC32",
|
||||
" Guided section.",
|
||||
" -o Output specifies the output file that is a CRC32 Guided section",
|
||||
NULL
|
||||
};
|
||||
for (Index = 0; Str[Index] != NULL; Index++) {
|
||||
fprintf (stdout, "%s\n", Str[Index]);
|
||||
}
|
||||
}
|
||||
|
||||
INT32
|
||||
|
@@ -1,6 +1,6 @@
|
||||
/*++
|
||||
|
||||
Copyright (c) 2004 - 2006, Intel Corporation. All rights reserved.<BR>
|
||||
Copyright (c) 2004 - 2010, 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
|
||||
@@ -77,7 +77,15 @@ Abstract:
|
||||
|
||||
#include "GenDepex.h"
|
||||
|
||||
#define TOOL_NAME "GenDepex"
|
||||
//
|
||||
// Utility Name
|
||||
//
|
||||
#define UTILITY_NAME "GenDepex"
|
||||
|
||||
//
|
||||
// Utility version information
|
||||
//
|
||||
#define UTILITY_VERSION "v1.0"
|
||||
|
||||
extern
|
||||
BOOLEAN
|
||||
@@ -106,13 +114,19 @@ Returns:
|
||||
|
||||
--*/
|
||||
{
|
||||
printf (
|
||||
"%s, Tiano Dependency Expression Generation Utility. Version %d.%d.\n",
|
||||
UTILITY_NAME,
|
||||
UTILITY_MAJOR_VERSION,
|
||||
UTILITY_MINOR_VERSION
|
||||
);
|
||||
printf ("Copyright (C) 1996-2002 Intel Corporation. All rights reserved.\n\n");
|
||||
int Index;
|
||||
const char *Str[] = {
|
||||
UTILITY_NAME" "UTILITY_VERSION" - Intel Generate Dependency Expression Utility",
|
||||
" Copyright (C), 1996 - 2008 Intel Corporation",
|
||||
|
||||
#if ( defined(UTILITY_BUILD) && defined(UTILITY_VENDOR) )
|
||||
" Built from "UTILITY_BUILD", project of "UTILITY_VENDOR,
|
||||
#endif
|
||||
NULL
|
||||
};
|
||||
for (Index = 0; Str[Index] != NULL; Index++) {
|
||||
fprintf (stdout, "%s\n", Str[Index]);
|
||||
}
|
||||
}
|
||||
|
||||
VOID
|
||||
@@ -135,15 +149,22 @@ Returns:
|
||||
|
||||
--*/
|
||||
{
|
||||
printf (
|
||||
"Usage: %s -I <INFILE> -O <OUTFILE> [-P <Optional Boundary for padding up>] \n",
|
||||
UTILITY_NAME
|
||||
);
|
||||
printf (" Where:\n");
|
||||
printf (" <INFILE> is the input pre-processed dependency text files name.\n");
|
||||
printf (" <OUTFILE> is the output binary dependency files name.\n");
|
||||
printf (" <Optional Boundary for padding up> is the padding integer value.\n");
|
||||
printf (" This is the boundary to align the output file size to.\n");
|
||||
int Index;
|
||||
const char *Str[] = {
|
||||
"",
|
||||
"Usage:",
|
||||
" "UTILITY_NAME" [OPTION]...",
|
||||
"Options:",
|
||||
" -I INFILE The input pre-processed dependency text files name",
|
||||
" -O OUTFILE The output binary dependency files name",
|
||||
" -P BOUNDARY The padding integer value to align the output file size",
|
||||
NULL
|
||||
};
|
||||
|
||||
PrintGenDepexUtilityInfo ();
|
||||
for (Index = 0; Str[Index] != NULL; Index++) {
|
||||
fprintf (stdout, "%s\n", Str[Index]);
|
||||
}
|
||||
}
|
||||
|
||||
DEPENDENCY_OPCODE
|
||||
@@ -742,7 +763,7 @@ Returns:
|
||||
// print an error message.
|
||||
//
|
||||
*(Ptrx + 20) = 0;
|
||||
printf (TOOL_NAME " ERROR: Unrecognized input at: \"%s\"...\n", Ptrx);
|
||||
printf (UTILITY_NAME" ERROR: Unrecognized input at: \"%s\"...\n", Ptrx);
|
||||
return EFI_INVALID_PARAMETER;
|
||||
}
|
||||
}
|
||||
|
@@ -1,5 +1,5 @@
|
||||
/*++
|
||||
Copyright (c) 2004, Intel Corporation. All rights reserved.<BR>
|
||||
Copyright (c) 2004 - 2010, 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
|
||||
@@ -53,15 +53,5 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
|
||||
#define EVAL_STACK_SIZE 0x1024
|
||||
#define BUFFER_SIZE 0x100
|
||||
|
||||
//
|
||||
// Utility Name
|
||||
//
|
||||
#define UTILITY_NAME "GenDepex"
|
||||
|
||||
//
|
||||
// Utility version information
|
||||
//
|
||||
#define UTILITY_MAJOR_VERSION 0
|
||||
#define UTILITY_MINOR_VERSION 4
|
||||
|
||||
#endif
|
||||
|
@@ -1,6 +1,6 @@
|
||||
/*++
|
||||
|
||||
Copyright (c) 2004 - 2007, Intel Corporation. All rights reserved.<BR>
|
||||
Copyright (c) 2004 - 2010, 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
|
||||
@@ -43,7 +43,7 @@ Abstract:
|
||||
#include "SimpleFileParsing.h"
|
||||
|
||||
#define UTILITY_NAME "GenFfsFile"
|
||||
#define TOOLVERSION "0.32"
|
||||
#define UTILITY_VERSION "v1.1"
|
||||
#define MAX_ARRAY_SIZE 100
|
||||
|
||||
static
|
||||
@@ -123,6 +123,7 @@ static struct {
|
||||
UINT8 BuildDirectory[_MAX_PATH];
|
||||
UINT8 PrimaryPackagePath[_MAX_PATH];
|
||||
UINT8 OverridePackagePath[_MAX_PATH];
|
||||
UINT8 OutputFilePath[_MAX_PATH];
|
||||
BOOLEAN Verbose;
|
||||
MACRO *MacroList;
|
||||
} mGlobals;
|
||||
@@ -187,22 +188,33 @@ Returns:
|
||||
|
||||
--*/
|
||||
{
|
||||
printf ("Usage:\n");
|
||||
printf (UTILITY_NAME " -b \"build directory\" -p1 \"package1.inf\" -p2 \"package2.inf\"\n");
|
||||
printf (" -d \"name=value\" -v\n");
|
||||
printf (" -b \"build directory\":\n");
|
||||
printf (" specifies the full path to the component build directory.\n");
|
||||
printf (" -p1 \"P1_path\":\n");
|
||||
printf (" specifies fully qualified file name to the primary package file.\n");
|
||||
printf (" This file will normally exist in the same directory as the makefile\n");
|
||||
printf (" for the component. Required.\n");
|
||||
printf (" -p2 \"P2_path\":\n");
|
||||
printf (" specifies fully qualified file name to the override package file.\n");
|
||||
printf (" This file will normally exist in the build tip. Optional.\n");
|
||||
printf (" -d \"name=value\":\n");
|
||||
printf (" add a macro definition for package file. Optional.\n");
|
||||
printf (" -v :\n");
|
||||
printf (" verbose. Optional.\n");
|
||||
int Index;
|
||||
const char *Str[] = {
|
||||
UTILITY_NAME" "UTILITY_VERSION" - Intel Generate FFS File Utility",
|
||||
" Copyright (C), 2004 - 2009 Intel Corporation",
|
||||
|
||||
#if ( defined(UTILITY_BUILD) && defined(UTILITY_VENDOR) )
|
||||
" Built from "UTILITY_BUILD", project of "UTILITY_VENDOR,
|
||||
#endif
|
||||
"",
|
||||
"Usage:",
|
||||
" "UTILITY_NAME" [OPTION]...",
|
||||
"Options:",
|
||||
" -b BuildDirectory Specifies the full path to the component build directory",
|
||||
" -p1 P1Path Specifies fully qualified file name to the primary package",
|
||||
" file. This file will normally exist in the same directory",
|
||||
" as the makefile for the component. Required.",
|
||||
" -p2 P2Path Specifies fully qualified file name to the override",
|
||||
" package. This file will normally exist in the build tip.",
|
||||
" Optional.",
|
||||
" -d Name=Value Add a macro definition for the package file. Optional.",
|
||||
" -o OutputFile Specifies the file name of output file. Optional.",
|
||||
" -v Verbose. Optional.",
|
||||
NULL
|
||||
};
|
||||
for (Index = 0; Str[Index] != NULL; Index++) {
|
||||
fprintf (stdout, "%s\n", Str[Index]);
|
||||
}
|
||||
}
|
||||
|
||||
static
|
||||
@@ -2160,54 +2172,64 @@ here:
|
||||
StripQuotes (BaseName);
|
||||
}
|
||||
|
||||
if (BaseName[0] != 0) {
|
||||
sprintf (InputString, "%s-%s", GuidString, BaseName);
|
||||
if (mGlobals.OutputFilePath[0]) {
|
||||
//
|
||||
// Use user specified output file name
|
||||
//
|
||||
strcpy (InputString, mGlobals.OutputFilePath);
|
||||
} else {
|
||||
strcpy (InputString, GuidString);
|
||||
}
|
||||
//
|
||||
// Construct the output file name according to FileType
|
||||
//
|
||||
if (BaseName[0] != 0) {
|
||||
sprintf (InputString, "%s-%s", GuidString, BaseName);
|
||||
} else {
|
||||
strcpy (InputString, GuidString);
|
||||
}
|
||||
|
||||
switch (StringToType (FileType)) {
|
||||
switch (StringToType (FileType)) {
|
||||
|
||||
case EFI_FV_FILETYPE_SECURITY_CORE:
|
||||
strcat (InputString, ".SEC");
|
||||
break;
|
||||
case EFI_FV_FILETYPE_SECURITY_CORE:
|
||||
strcat (InputString, ".SEC");
|
||||
break;
|
||||
|
||||
case EFI_FV_FILETYPE_PEIM:
|
||||
case EFI_FV_FILETYPE_PEI_CORE:
|
||||
case EFI_FV_FILETYPE_COMBINED_PEIM_DRIVER:
|
||||
strcat (InputString, ".PEI");
|
||||
break;
|
||||
case EFI_FV_FILETYPE_PEIM:
|
||||
case EFI_FV_FILETYPE_PEI_CORE:
|
||||
case EFI_FV_FILETYPE_COMBINED_PEIM_DRIVER:
|
||||
strcat (InputString, ".PEI");
|
||||
break;
|
||||
|
||||
case EFI_FV_FILETYPE_DRIVER:
|
||||
case EFI_FV_FILETYPE_DXE_CORE:
|
||||
strcat (InputString, ".DXE");
|
||||
break;
|
||||
case EFI_FV_FILETYPE_DRIVER:
|
||||
case EFI_FV_FILETYPE_DXE_CORE:
|
||||
strcat (InputString, ".DXE");
|
||||
break;
|
||||
|
||||
case EFI_FV_FILETYPE_APPLICATION:
|
||||
strcat (InputString, ".APP");
|
||||
break;
|
||||
case EFI_FV_FILETYPE_APPLICATION:
|
||||
strcat (InputString, ".APP");
|
||||
break;
|
||||
|
||||
case EFI_FV_FILETYPE_FIRMWARE_VOLUME_IMAGE:
|
||||
strcat (InputString, ".FVI");
|
||||
break;
|
||||
case EFI_FV_FILETYPE_FIRMWARE_VOLUME_IMAGE:
|
||||
strcat (InputString, ".FVI");
|
||||
break;
|
||||
|
||||
case EFI_FV_FILETYPE_RAW:
|
||||
strcat (InputString, ".RAW");
|
||||
break;
|
||||
case EFI_FV_FILETYPE_RAW:
|
||||
strcat (InputString, ".RAW");
|
||||
break;
|
||||
|
||||
case EFI_FV_FILETYPE_ALL:
|
||||
Error (mGlobals.OverridePackagePath, 1, 0, "invalid FFS file type for this utility", NULL);
|
||||
goto Done;
|
||||
case EFI_FV_FILETYPE_ALL:
|
||||
Error (mGlobals.OverridePackagePath, 1, 0, "invalid FFS file type for this utility", NULL);
|
||||
goto Done;
|
||||
|
||||
default:
|
||||
strcat (InputString, ".FFS");
|
||||
break;
|
||||
default:
|
||||
strcat (InputString, ".FFS");
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (ForceUncompress) {
|
||||
strcat (InputString, ".ORG");
|
||||
}
|
||||
|
||||
|
||||
Out = fopen (InputString, "wb");
|
||||
if (Out == NULL) {
|
||||
Error (NULL, 0, 0, InputString, "could not open output file for writing");
|
||||
@@ -2242,7 +2264,11 @@ here:
|
||||
sizeof (EFI_FFS_FILE_HEADER)
|
||||
);
|
||||
if (FileHeader.Attributes & FFS_ATTRIB_CHECKSUM) {
|
||||
#if (PI_SPECIFICATION_VERSION < 0x00010000)
|
||||
FileHeader.IntegrityCheck.Checksum.File = CalculateChecksum8 ((UINT8 *) &FileHeader, FileSize);
|
||||
#else
|
||||
FileHeader.IntegrityCheck.Checksum.File = CalculateChecksum8 ((UINT8 *) ((UINTN)&FileHeader + sizeof (EFI_FFS_FILE_HEADER)), FileSize - sizeof (EFI_FFS_FILE_HEADER));
|
||||
#endif
|
||||
} else {
|
||||
FileHeader.IntegrityCheck.Checksum.File = FFS_FIXED_CHECKSUM;
|
||||
}
|
||||
@@ -2307,48 +2333,58 @@ here:
|
||||
StripQuotes (BaseName);
|
||||
}
|
||||
|
||||
if (BaseName[0] != 0) {
|
||||
sprintf (InputString, "%s-%s", GuidString, BaseName);
|
||||
if (mGlobals.OutputFilePath[0]) {
|
||||
//
|
||||
// Use user specified output file name
|
||||
//
|
||||
strcpy (InputString, mGlobals.OutputFilePath);
|
||||
} else {
|
||||
strcpy (InputString, GuidString);
|
||||
}
|
||||
//
|
||||
// Construct the output file name according to FileType
|
||||
//
|
||||
if (BaseName[0] != 0) {
|
||||
sprintf (InputString, "%s-%s", GuidString, BaseName);
|
||||
} else {
|
||||
strcpy (InputString, GuidString);
|
||||
}
|
||||
|
||||
switch (StringToType (FileType)) {
|
||||
switch (StringToType (FileType)) {
|
||||
|
||||
case EFI_FV_FILETYPE_SECURITY_CORE:
|
||||
strcat (InputString, ".SEC");
|
||||
break;
|
||||
case EFI_FV_FILETYPE_SECURITY_CORE:
|
||||
strcat (InputString, ".SEC");
|
||||
break;
|
||||
|
||||
case EFI_FV_FILETYPE_PEIM:
|
||||
case EFI_FV_FILETYPE_PEI_CORE:
|
||||
case EFI_FV_FILETYPE_COMBINED_PEIM_DRIVER:
|
||||
strcat (InputString, ".PEI");
|
||||
break;
|
||||
case EFI_FV_FILETYPE_PEIM:
|
||||
case EFI_FV_FILETYPE_PEI_CORE:
|
||||
case EFI_FV_FILETYPE_COMBINED_PEIM_DRIVER:
|
||||
strcat (InputString, ".PEI");
|
||||
break;
|
||||
|
||||
case EFI_FV_FILETYPE_DRIVER:
|
||||
case EFI_FV_FILETYPE_DXE_CORE:
|
||||
strcat (InputString, ".DXE");
|
||||
break;
|
||||
case EFI_FV_FILETYPE_DRIVER:
|
||||
case EFI_FV_FILETYPE_DXE_CORE:
|
||||
strcat (InputString, ".DXE");
|
||||
break;
|
||||
|
||||
case EFI_FV_FILETYPE_APPLICATION:
|
||||
strcat (InputString, ".APP");
|
||||
break;
|
||||
case EFI_FV_FILETYPE_APPLICATION:
|
||||
strcat (InputString, ".APP");
|
||||
break;
|
||||
|
||||
case EFI_FV_FILETYPE_FIRMWARE_VOLUME_IMAGE:
|
||||
strcat (InputString, ".FVI");
|
||||
break;
|
||||
case EFI_FV_FILETYPE_FIRMWARE_VOLUME_IMAGE:
|
||||
strcat (InputString, ".FVI");
|
||||
break;
|
||||
|
||||
case EFI_FV_FILETYPE_RAW:
|
||||
strcat (InputString, ".RAW");
|
||||
break;
|
||||
case EFI_FV_FILETYPE_RAW:
|
||||
strcat (InputString, ".RAW");
|
||||
break;
|
||||
|
||||
case EFI_FV_FILETYPE_ALL:
|
||||
Error (mGlobals.PrimaryPackagePath, 1, 0, "invalid FFS file type for this utility", NULL);
|
||||
goto Done;
|
||||
case EFI_FV_FILETYPE_ALL:
|
||||
Error (mGlobals.PrimaryPackagePath, 1, 0, "invalid FFS file type for this utility", NULL);
|
||||
goto Done;
|
||||
|
||||
default:
|
||||
strcat (InputString, ".FFS");
|
||||
break;
|
||||
default:
|
||||
strcat (InputString, ".FFS");
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (ForceUncompress) {
|
||||
@@ -2624,6 +2660,23 @@ Returns:
|
||||
OriginalOverridePackagePath = Argv[1];
|
||||
Argc--;
|
||||
Argv++;
|
||||
} else if (_strcmpi (Argv[0], "-o") == 0) {
|
||||
//
|
||||
// OPTION: -o OutputFilePath
|
||||
// Make sure there is another argument, then save it to out globals.
|
||||
//
|
||||
if (Argc < 2) {
|
||||
Error (NULL, 0, 0, Argv[0], "option requires the output file name");
|
||||
return STATUS_ERROR;
|
||||
}
|
||||
if (mGlobals.OutputFilePath[0]) {
|
||||
Error (NULL, 0, 0, Argv[0], "option can only be specified once");
|
||||
return STATUS_ERROR;
|
||||
}
|
||||
|
||||
strcpy (mGlobals.OutputFilePath, Argv[1]);
|
||||
Argc--;
|
||||
Argv++;
|
||||
} else if (_strcmpi (Argv[0], "-v") == 0) {
|
||||
//
|
||||
// OPTION: -v verbose
|
||||
|
@@ -1,6 +1,6 @@
|
||||
/*++
|
||||
|
||||
Copyright (c) 2004, Intel Corporation. All rights reserved.<BR>
|
||||
Copyright (c) 2004 - 2010, 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
|
||||
@@ -49,12 +49,19 @@ Returns:
|
||||
|
||||
--*/
|
||||
{
|
||||
printf (
|
||||
"%s - Tiano Firmware Volume Generation Utility."" Version %i.%i\n\n",
|
||||
UTILITY_NAME,
|
||||
UTILITY_MAJOR_VERSION,
|
||||
UTILITY_MINOR_VERSION
|
||||
);
|
||||
int Index;
|
||||
const char *Str[] = {
|
||||
UTILITY_NAME" "UTILITY_VERSION" - Intel Generate Firmware Volume Utility",
|
||||
" Copyright (C), 2004 - 2009 Intel Corporation",
|
||||
|
||||
#if ( defined(UTILITY_BUILD) && defined(UTILITY_VENDOR) )
|
||||
" Built from "UTILITY_BUILD", project of "UTILITY_VENDOR,
|
||||
#endif
|
||||
NULL
|
||||
};
|
||||
for (Index = 0; Str[Index] != NULL; Index++) {
|
||||
fprintf (stdout, "%s\n", Str[Index]);
|
||||
}
|
||||
}
|
||||
|
||||
VOID
|
||||
@@ -77,9 +84,19 @@ Returns:
|
||||
|
||||
--*/
|
||||
{
|
||||
printf ("Usage: %s -I FvInfFileName\n", UTILITY_NAME);
|
||||
printf (" Where:\n");
|
||||
printf ("\tFvInfFileName is the name of the image description file.\n\n");
|
||||
int Index;
|
||||
const char *Str[] = {
|
||||
"",
|
||||
"Usage:",
|
||||
" "UTILITY_NAME" [OPTION]",
|
||||
"Options:",
|
||||
" -I FvInfFileName The name of the image description file.",
|
||||
NULL
|
||||
};
|
||||
|
||||
for (Index = 0; Str[Index] != NULL; Index++) {
|
||||
fprintf (stdout, "%s\n", Str[Index]);
|
||||
}
|
||||
}
|
||||
|
||||
EFI_STATUS
|
||||
|
@@ -1,6 +1,6 @@
|
||||
/*++
|
||||
|
||||
Copyright (c) 2004, Intel Corporation. All rights reserved.<BR>
|
||||
Copyright (c) 2004 - 2010, 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
|
||||
@@ -38,8 +38,7 @@ Abstract:
|
||||
//
|
||||
// Utility version information
|
||||
//
|
||||
#define UTILITY_MAJOR_VERSION 0
|
||||
#define UTILITY_MINOR_VERSION 1
|
||||
#define UTILITY_VERSION "v1.1"
|
||||
#define UTILITY_DATE __DATE__
|
||||
|
||||
//
|
||||
|
@@ -1,6 +1,6 @@
|
||||
/*++
|
||||
|
||||
Copyright (c) 2004 - 2007, Intel Corporation. All rights reserved.<BR>
|
||||
Copyright (c) 2004 - 2010, 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
|
||||
@@ -968,13 +968,17 @@ Returns:
|
||||
Status = FindToken (InfFile, OPTIONS_SECTION_STRING, EFI_NUM_BLOCKS_STRING, Index, Value);
|
||||
|
||||
if (Status == EFI_SUCCESS) {
|
||||
//
|
||||
// Update the number of blocks
|
||||
//
|
||||
Status = AsciiStringToUint64 (Value, FALSE, &Value64);
|
||||
if (EFI_ERROR (Status)) {
|
||||
Error (NULL, 0, 0, Value, "invalid value for %s", EFI_NUM_BLOCKS_STRING);
|
||||
return EFI_ABORTED;
|
||||
if (strcmp (Value, AUTO_STRING) == 0) {
|
||||
Value64 = (UINT64) -1;
|
||||
} else {
|
||||
//
|
||||
// Update the number of blocks
|
||||
//
|
||||
Status = AsciiStringToUint64 (Value, FALSE, &Value64);
|
||||
if (EFI_ERROR (Status)) {
|
||||
Error (NULL, 0, 0, Value, "invalid value for %s", EFI_NUM_BLOCKS_STRING);
|
||||
return EFI_ABORTED;
|
||||
}
|
||||
}
|
||||
|
||||
FvInfo->FvBlocks[Index].NumBlocks = (UINT32) Value64;
|
||||
@@ -1040,91 +1044,25 @@ Returns:
|
||||
|
||||
if (FindSection (InfFile, COMPONENT_SECTION_STRING)) {
|
||||
Index = 0;
|
||||
//
|
||||
// Read component FV_VARIABLE
|
||||
//
|
||||
Status = FindToken (InfFile, COMPONENT_SECTION_STRING, EFI_NV_VARIABLE_STRING, 0, Value);
|
||||
|
||||
if (Status == EFI_SUCCESS) {
|
||||
//
|
||||
// Add the component
|
||||
//
|
||||
strcpy (FvInfo->FvComponents[Index].ComponentName, EFI_NV_VARIABLE_STRING);
|
||||
while (TRUE) {
|
||||
Status = FindTokenInstanceInSection (
|
||||
InfFile,
|
||||
COMPONENT_SECTION_STRING,
|
||||
Index,
|
||||
FvInfo->FvComponents[Index].ComponentName,
|
||||
Value
|
||||
);
|
||||
if (EFI_ERROR (Status)) {
|
||||
break;
|
||||
}
|
||||
Status = AsciiStringToUint64 (Value, FALSE, &Value64);
|
||||
if (EFI_ERROR (Status)) {
|
||||
printf ("ERROR: %s is not a valid integer.\n", EFI_NV_VARIABLE_STRING);
|
||||
Error (NULL, 0, 0, Value, "not a valid integer");
|
||||
return EFI_ABORTED;
|
||||
}
|
||||
|
||||
FvInfo->FvComponents[Index].Size = (UINTN) Value64;
|
||||
} else {
|
||||
printf ("WARNING: Could not read %s.\n", EFI_NV_VARIABLE_STRING);
|
||||
}
|
||||
|
||||
Index++;
|
||||
//
|
||||
// Read component FV_EVENT_LOG
|
||||
//
|
||||
Status = FindToken (InfFile, COMPONENT_SECTION_STRING, EFI_NV_EVENT_LOG_STRING, 0, Value);
|
||||
|
||||
if (Status == EFI_SUCCESS) {
|
||||
//
|
||||
// Add the component
|
||||
//
|
||||
strcpy (FvInfo->FvComponents[Index].ComponentName, EFI_NV_EVENT_LOG_STRING);
|
||||
Status = AsciiStringToUint64 (Value, FALSE, &Value64);
|
||||
if (EFI_ERROR (Status)) {
|
||||
printf ("ERROR: %s is not a valid integer.\n", EFI_NV_EVENT_LOG_STRING);
|
||||
return EFI_ABORTED;
|
||||
}
|
||||
|
||||
FvInfo->FvComponents[Index].Size = (UINTN) Value64;
|
||||
} else {
|
||||
printf ("WARNING: Could not read %s.\n", EFI_NV_EVENT_LOG_STRING);
|
||||
}
|
||||
|
||||
Index++;
|
||||
//
|
||||
// Read component FV_FTW_WORKING
|
||||
//
|
||||
Status = FindToken (InfFile, COMPONENT_SECTION_STRING, EFI_NV_FTW_WORKING_STRING, 0, Value);
|
||||
|
||||
if (Status == EFI_SUCCESS) {
|
||||
//
|
||||
// Add the component
|
||||
//
|
||||
strcpy (FvInfo->FvComponents[Index].ComponentName, EFI_NV_FTW_WORKING_STRING);
|
||||
Status = AsciiStringToUint64 (Value, FALSE, &Value64);
|
||||
if (EFI_ERROR (Status)) {
|
||||
printf ("ERROR: %s is not a valid integer.\n", EFI_NV_FTW_WORKING_STRING);
|
||||
return EFI_ABORTED;
|
||||
}
|
||||
|
||||
FvInfo->FvComponents[Index].Size = (UINTN) Value64;
|
||||
} else {
|
||||
printf ("WARNING: Could not read %s.\n", EFI_NV_FTW_WORKING_STRING);
|
||||
}
|
||||
|
||||
Index++;
|
||||
//
|
||||
// Read component FV_FTW_SPARE
|
||||
//
|
||||
Status = FindToken (InfFile, COMPONENT_SECTION_STRING, EFI_NV_FTW_SPARE_STRING, 0, Value);
|
||||
|
||||
if (Status == EFI_SUCCESS) {
|
||||
//
|
||||
// Add the component
|
||||
//
|
||||
strcpy (FvInfo->FvComponents[Index].ComponentName, EFI_NV_FTW_SPARE_STRING);
|
||||
Status = AsciiStringToUint64 (Value, FALSE, &Value64);
|
||||
if (EFI_ERROR (Status)) {
|
||||
printf ("ERROR: %s is not a valid integer.\n", EFI_NV_FTW_SPARE_STRING);
|
||||
return EFI_ABORTED;
|
||||
}
|
||||
|
||||
FvInfo->FvComponents[Index].Size = (UINTN) Value64;
|
||||
} else {
|
||||
printf ("WARNING: Could not read %s.\n", EFI_NV_FTW_SPARE_STRING);
|
||||
Index++;
|
||||
}
|
||||
}
|
||||
//
|
||||
@@ -1132,7 +1070,33 @@ Returns:
|
||||
//
|
||||
FvInfo->Size = 0;
|
||||
for (Index = 0; FvInfo->FvBlocks[Index].NumBlocks; Index++) {
|
||||
FvInfo->Size += FvInfo->FvBlocks[Index].NumBlocks * FvInfo->FvBlocks[Index].BlockLength;
|
||||
if ((FvInfo->Size == (UINTN) -1 && Index > 0) ||
|
||||
(FvInfo->FvBlocks[Index].NumBlocks == (UINT32) -1 && Index > 0)
|
||||
) {
|
||||
//
|
||||
// Error 1. more pairs after AUTO
|
||||
// Error 2. AUTO appear in non-first position
|
||||
//
|
||||
Error (NULL, 0, 0, NULL, "cannot have more than one pair of %s and %s if %s is set to %s",
|
||||
EFI_NUM_BLOCKS_STRING, EFI_BLOCK_SIZE_STRING,
|
||||
EFI_NUM_BLOCKS_STRING, AUTO_STRING
|
||||
);
|
||||
return EFI_ABORTED;
|
||||
}
|
||||
|
||||
if (FvInfo->FvBlocks[Index].NumBlocks == (UINT32) -1) {
|
||||
FvInfo->Size = (UINTN) -1;
|
||||
} else {
|
||||
FvInfo->Size += FvInfo->FvBlocks[Index].NumBlocks * FvInfo->FvBlocks[Index].BlockLength;
|
||||
}
|
||||
}
|
||||
|
||||
if (FvInfo->Size == (UINTN) -1 && FvInfo->FvFiles[0][0] == 0) {
|
||||
//
|
||||
// Non FFS FV cannot set block number to AUTO
|
||||
//
|
||||
Error (NULL, 0, 0, "non-FFS FV", "cannot set %s to %s", EFI_NUM_BLOCKS_STRING, AUTO_STRING);
|
||||
return EFI_ABORTED;
|
||||
}
|
||||
|
||||
return EFI_SUCCESS;
|
||||
@@ -1372,7 +1336,11 @@ Returns:
|
||||
PadFile->State = 0;
|
||||
PadFile->IntegrityCheck.Checksum.Header = CalculateChecksum8 ((UINT8 *) PadFile, sizeof (EFI_FFS_FILE_HEADER));
|
||||
if (PadFile->Attributes & FFS_ATTRIB_CHECKSUM) {
|
||||
#if (PI_SPECIFICATION_VERSION < 0x00010000)
|
||||
PadFile->IntegrityCheck.Checksum.File = CalculateChecksum8 ((UINT8 *) PadFile, PadFileSize);
|
||||
#else
|
||||
PadFile->IntegrityCheck.Checksum.File = CalculateChecksum8 ((UINT8 *) ((UINTN)PadFile + sizeof (EFI_FFS_FILE_HEADER)), PadFileSize - sizeof (EFI_FFS_FILE_HEADER));
|
||||
#endif
|
||||
} else {
|
||||
PadFile->IntegrityCheck.Checksum.File = FFS_FIXED_CHECKSUM;
|
||||
}
|
||||
@@ -1875,13 +1843,140 @@ Returns:
|
||||
return EFI_SUCCESS;
|
||||
}
|
||||
|
||||
EFI_STATUS
|
||||
ReallocateFvImage (
|
||||
IN OUT MEMORY_FILE *FvImage,
|
||||
IN OUT FV_INFO *FvInfo,
|
||||
IN OUT EFI_FFS_FILE_HEADER **VtfFileImage,
|
||||
IN OUT UINTN *FvImageCapacity
|
||||
)
|
||||
/*++
|
||||
Routine Description:
|
||||
Increase the size of FV image by 1 block. The routine may reallocate memory
|
||||
depending on the capacity of the FV image.
|
||||
|
||||
Arguments:
|
||||
FvImage The memory image of the FV to add it to. The current offset
|
||||
must be valid.
|
||||
FvInfo Pointer to information about the FV.
|
||||
VtfFileImage A pointer to the VTF file within the FvImage. If this is equal
|
||||
to the end of the FvImage then no VTF previously found.
|
||||
FvImageCapacity Capacity of image buffer for FV.
|
||||
|
||||
Returns:
|
||||
EFI_SUCCESS The function completed successfully.
|
||||
EFI_OUT_OF_RESOURCES Insufficient resources exist to complete the reallocation.
|
||||
|
||||
--*/
|
||||
{
|
||||
CHAR8 *FileImage;
|
||||
UINTN OldSize;
|
||||
UINTN IncreaseSize;
|
||||
EFI_FIRMWARE_VOLUME_HEADER *FvHeader;
|
||||
BOOLEAN AllocateNewMemory;
|
||||
EFI_FFS_FILE_HEADER *NewVtfFileImage;
|
||||
UINT32 VtfFileLength;
|
||||
UINT8 TempByte;
|
||||
|
||||
OldSize = (UINTN) FvImage->Eof - (UINTN) FvImage->FileImage;
|
||||
IncreaseSize = FvInfo->FvBlocks[0].BlockLength;
|
||||
assert (OldSize == FvInfo->FvBlocks[0].NumBlocks * FvInfo->FvBlocks[0].BlockLength);
|
||||
|
||||
//
|
||||
// Assume we have enough capacity
|
||||
//
|
||||
AllocateNewMemory = FALSE;
|
||||
|
||||
|
||||
if (OldSize + IncreaseSize > *FvImageCapacity) {
|
||||
AllocateNewMemory = TRUE;
|
||||
//
|
||||
// Increase capacity by one unit
|
||||
//
|
||||
*FvImageCapacity = OldSize + FV_CAPACITY_INCREASE_UNIT;
|
||||
FileImage = malloc (*FvImageCapacity);
|
||||
|
||||
if (FileImage == NULL) {
|
||||
Error (NULL, 0, 0, "memory allocation failure", NULL);
|
||||
return EFI_OUT_OF_RESOURCES;
|
||||
}
|
||||
|
||||
//
|
||||
// Initialize the content per FV polarity
|
||||
//
|
||||
if (FvInfo->FvAttributes & EFI_FVB_ERASE_POLARITY) {
|
||||
memset (FileImage, -1, *FvImageCapacity);
|
||||
} else {
|
||||
memset (FileImage, 0, *FvImageCapacity);
|
||||
}
|
||||
|
||||
//
|
||||
// Copy the FV content before VTF
|
||||
//
|
||||
memcpy (FileImage, FvImage->FileImage, (UINTN) *VtfFileImage - (UINTN) FvImage->FileImage);
|
||||
} else {
|
||||
FileImage = FvImage->FileImage;
|
||||
}
|
||||
|
||||
//
|
||||
// Move VTF if it exists
|
||||
//
|
||||
NewVtfFileImage = (EFI_FFS_FILE_HEADER *) (FileImage + ((UINTN) *VtfFileImage - (UINTN) FvImage->FileImage) + IncreaseSize);
|
||||
if ((UINTN) *VtfFileImage != (UINTN) FvImage->Eof) {
|
||||
//
|
||||
// Exchange the VTF buffer from end to start for two purpose:
|
||||
// 1. Exchange: Preserve the default value per FV polarity
|
||||
// 2. End->Start: Avoid destroying the VTF data during exchanging
|
||||
//
|
||||
VtfFileLength = GetLength ((*VtfFileImage)->Size);
|
||||
while (VtfFileLength-- != 0) {
|
||||
TempByte = ((UINT8 *) VtfFileImage)[VtfFileLength];
|
||||
((UINT8 *) VtfFileImage)[VtfFileLength] = ((UINT8 *) NewVtfFileImage)[VtfFileLength];
|
||||
((UINT8 *) NewVtfFileImage)[VtfFileLength] = TempByte;
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
// Update VTF Pointer
|
||||
//
|
||||
*VtfFileImage = NewVtfFileImage;
|
||||
|
||||
//
|
||||
// Update FvInfo
|
||||
//
|
||||
FvInfo->FvBlocks[0].NumBlocks ++;
|
||||
|
||||
//
|
||||
// Update FV Header
|
||||
//
|
||||
FvHeader = (EFI_FIRMWARE_VOLUME_HEADER *) FileImage;
|
||||
FvHeader->FvBlockMap[0].NumBlocks = FvInfo->FvBlocks[0].NumBlocks;
|
||||
FvHeader->FvLength = OldSize + IncreaseSize;
|
||||
FvHeader->Checksum = 0;
|
||||
FvHeader->Checksum = CalculateChecksum16 ((UINT16 *) FvHeader, FvHeader->HeaderLength / sizeof (UINT16));
|
||||
|
||||
//
|
||||
// Update FvImage
|
||||
//
|
||||
if (AllocateNewMemory) {
|
||||
free (FvImage->FileImage);
|
||||
FvImage->CurrentFilePointer = FileImage + (FvImage->CurrentFilePointer - FvImage->FileImage);
|
||||
FvImage->FileImage = FileImage;
|
||||
}
|
||||
FvImage->Eof = FvImage->FileImage + OldSize + IncreaseSize;
|
||||
|
||||
InitializeFvLib (FvImage->FileImage, OldSize + IncreaseSize);
|
||||
return EFI_SUCCESS;
|
||||
}
|
||||
|
||||
EFI_STATUS
|
||||
AddFile (
|
||||
IN OUT MEMORY_FILE *FvImage,
|
||||
IN FV_INFO *FvInfo,
|
||||
IN UINTN Index,
|
||||
IN OUT EFI_FFS_FILE_HEADER **VtfFileImage,
|
||||
IN OUT MEMORY_FILE *SymImage
|
||||
IN OUT MEMORY_FILE *SymImage,
|
||||
IN OUT UINTN *FvImageCapacity
|
||||
)
|
||||
/*++
|
||||
|
||||
@@ -1892,14 +1987,15 @@ Routine Description:
|
||||
|
||||
Arguments:
|
||||
|
||||
FvImage The memory image of the FV to add it to. The current offset
|
||||
must be valid.
|
||||
FvInfo Pointer to information about the FV.
|
||||
Index The file in the FvInfo file list to add.
|
||||
VtfFileImage A pointer to the VTF file within the FvImage. If this is equal
|
||||
to the end of the FvImage then no VTF previously found.
|
||||
SymImage The memory image of the Sym file to update if symbols are present.
|
||||
The current offset must be valid.
|
||||
FvImage The memory image of the FV to add it to. The current offset
|
||||
must be valid.
|
||||
FvInfo Pointer to information about the FV.
|
||||
Index The file in the FvInfo file list to add.
|
||||
VtfFileImage A pointer to the VTF file within the FvImage. If this is equal
|
||||
to the end of the FvImage then no VTF previously found.
|
||||
SymImage The memory image of the Sym file to update if symbols are present.
|
||||
The current offset must be valid.
|
||||
FvImageCapacity Capacity of image buffer for FV.
|
||||
|
||||
Returns:
|
||||
|
||||
@@ -1964,16 +2060,28 @@ Returns:
|
||||
// Verify read successful
|
||||
//
|
||||
if (NumBytesRead != sizeof (UINT8) * FileSize) {
|
||||
free (FileBuffer);
|
||||
Error (NULL, 0, 0, FvInfo->FvFiles[Index], "failed to read input file contents");
|
||||
return EFI_ABORTED;
|
||||
Status = EFI_ABORTED;
|
||||
goto Exit;
|
||||
}
|
||||
//
|
||||
// Verify space exists to add the file
|
||||
//
|
||||
if (FileSize > (UINTN) ((UINTN) *VtfFileImage - (UINTN) FvImage->CurrentFilePointer)) {
|
||||
Error (NULL, 0, 0, FvInfo->FvFiles[Index], "insufficient space remains to add the file");
|
||||
return EFI_OUT_OF_RESOURCES;
|
||||
while (FileSize > (UINTN) ((UINTN) *VtfFileImage - (UINTN) FvImage->CurrentFilePointer)) {
|
||||
if (FvInfo->Size != (UINTN) -1) {
|
||||
Error (NULL, 0, 0, FvInfo->FvFiles[Index], "insufficient space remains to add the file");
|
||||
Status = EFI_OUT_OF_RESOURCES;
|
||||
goto Exit;
|
||||
} else {
|
||||
//
|
||||
// FV Size is AUTO, increase by one block
|
||||
//
|
||||
Status = ReallocateFvImage (FvImage, FvInfo, VtfFileImage, FvImageCapacity);
|
||||
if (EFI_ERROR (Status)) {
|
||||
Error (NULL, 0, 0, FvInfo->FvFiles[Index], "insufficient resources to add the file");
|
||||
goto Exit;
|
||||
}
|
||||
}
|
||||
}
|
||||
//
|
||||
// Update the file state based on polarity of the FV.
|
||||
@@ -2033,7 +2141,11 @@ Returns:
|
||||
}
|
||||
|
||||
if ((*VtfFileImage)->Attributes & FFS_ATTRIB_CHECKSUM) {
|
||||
#if (PI_SPECIFICATION_VERSION < 0x00010000)
|
||||
VtfFileChecksum = CalculateChecksum8 ((UINT8 *) *VtfFileImage, FileSize - TailSize);
|
||||
#else
|
||||
VtfFileChecksum = CalculateChecksum8 ((UINT8 *) ((UINTN)*VtfFileImage + sizeof (EFI_FFS_FILE_HEADER)), FileSize - TailSize - sizeof(EFI_FFS_FILE_HEADER));
|
||||
#endif
|
||||
(*VtfFileImage)->IntegrityCheck.Checksum.File = VtfFileChecksum;
|
||||
} else {
|
||||
(*VtfFileImage)->IntegrityCheck.Checksum.File = FFS_FIXED_CHECKSUM;
|
||||
@@ -2048,15 +2160,15 @@ Returns:
|
||||
}
|
||||
#endif
|
||||
(*VtfFileImage)->State = FileState;
|
||||
free (FileBuffer);
|
||||
return EFI_SUCCESS;
|
||||
Status = EFI_SUCCESS;
|
||||
goto Exit;
|
||||
} else {
|
||||
//
|
||||
// Already found a VTF file.
|
||||
//
|
||||
Error (NULL, 0, 0, "multiple VTF files are illegal in a single FV", NULL);
|
||||
free (FileBuffer);
|
||||
return EFI_ABORTED;
|
||||
Status = EFI_ABORTED;
|
||||
goto Exit;
|
||||
}
|
||||
}
|
||||
//
|
||||
@@ -2065,68 +2177,93 @@ Returns:
|
||||
Status = ReadFfsAlignment ((EFI_FFS_FILE_HEADER *) FileBuffer, &CurrentFileAlignment);
|
||||
if (EFI_ERROR (Status)) {
|
||||
printf ("ERROR: Could not determine alignment of file %s.\n", FvInfo->FvFiles[Index]);
|
||||
free (FileBuffer);
|
||||
return EFI_ABORTED;
|
||||
Status = EFI_ABORTED;
|
||||
goto Exit;
|
||||
}
|
||||
//
|
||||
// Add pad file if necessary
|
||||
//
|
||||
Status = AddPadFile (FvImage, CurrentFileAlignment);
|
||||
if (EFI_ERROR (Status)) {
|
||||
printf ("ERROR: Could not align the file data properly.\n");
|
||||
free (FileBuffer);
|
||||
return EFI_ABORTED;
|
||||
while (EFI_ERROR (AddPadFile (FvImage, CurrentFileAlignment))) {
|
||||
if (FvInfo->Size != (UINTN) -1) {
|
||||
printf ("ERROR: Could not align the file data properly.\n");
|
||||
Status = EFI_ABORTED;
|
||||
goto Exit;
|
||||
} else {
|
||||
//
|
||||
// FV Size is AUTO, increase by one block
|
||||
//
|
||||
Status = ReallocateFvImage (FvImage, FvInfo, VtfFileImage, FvImageCapacity);
|
||||
if (EFI_ERROR (Status)) {
|
||||
Error (NULL, 0, 0, FvInfo->FvFiles[Index], "insufficient resources to add the file");
|
||||
goto Exit;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
// Add file
|
||||
//
|
||||
if ((FvImage->CurrentFilePointer + FileSize) < FvImage->Eof) {
|
||||
//
|
||||
// Copy the file
|
||||
//
|
||||
memcpy (FvImage->CurrentFilePointer, FileBuffer, FileSize);
|
||||
|
||||
//
|
||||
// If the file is XIP, rebase
|
||||
//
|
||||
CurrentFileBaseAddress = FvInfo->BaseAddress + ((UINTN) FvImage->CurrentFilePointer - (UINTN) FvImage->FileImage);
|
||||
//
|
||||
// Status = RebaseFfsFile ((EFI_FFS_FILE_HEADER*) FvImage->CurrentFilePointer, CurrentFileBaseAddress);
|
||||
// if (EFI_ERROR(Status)) {
|
||||
// printf ("ERROR: Could not rebase the file %s.\n", FvInfo->FvFiles[Index]);
|
||||
// return EFI_ABORTED;
|
||||
// }
|
||||
//
|
||||
// Update Symbol file
|
||||
//
|
||||
Status = AddSymFile (
|
||||
CurrentFileBaseAddress,
|
||||
(EFI_FFS_FILE_HEADER *) FvImage->CurrentFilePointer,
|
||||
SymImage,
|
||||
FvInfo->FvFiles[Index]
|
||||
);
|
||||
assert (!EFI_ERROR (Status));
|
||||
|
||||
//
|
||||
// Update the current pointer in the FV image
|
||||
//
|
||||
FvImage->CurrentFilePointer += FileSize;
|
||||
} else {
|
||||
printf ("ERROR: The firmware volume is out of space, could not add file %s.\n", FvInfo->FvFiles[Index]);
|
||||
return EFI_ABORTED;
|
||||
while (FileSize > (UINTN) ((UINTN) *VtfFileImage - (UINTN) FvImage->CurrentFilePointer)) {
|
||||
if (FvInfo->Size != (UINTN) -1) {
|
||||
printf ("ERROR: The firmware volume is out of space, could not add file %s.\n", FvInfo->FvFiles[Index]);
|
||||
Status = EFI_ABORTED;
|
||||
goto Exit;
|
||||
} else {
|
||||
//
|
||||
// FV Size is AUTO, increase by one one block
|
||||
//
|
||||
Status = ReallocateFvImage (FvImage, FvInfo, VtfFileImage, FvImageCapacity);
|
||||
if (EFI_ERROR (Status)) {
|
||||
Error (NULL, 0, 0, FvInfo->FvFiles[Index], "insufficient resources to add the file");
|
||||
goto Exit;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
// Copy the file
|
||||
//
|
||||
memcpy (FvImage->CurrentFilePointer, FileBuffer, FileSize);
|
||||
|
||||
//
|
||||
// If the file is XIP, rebase
|
||||
//
|
||||
CurrentFileBaseAddress = FvInfo->BaseAddress + ((UINTN) FvImage->CurrentFilePointer - (UINTN) FvImage->FileImage);
|
||||
//
|
||||
// Status = RebaseFfsFile ((EFI_FFS_FILE_HEADER*) FvImage->CurrentFilePointer, CurrentFileBaseAddress);
|
||||
// if (EFI_ERROR(Status)) {
|
||||
// printf ("ERROR: Could not rebase the file %s.\n", FvInfo->FvFiles[Index]);
|
||||
// return EFI_ABORTED;
|
||||
// }
|
||||
//
|
||||
// Update Symbol file
|
||||
//
|
||||
Status = AddSymFile (
|
||||
CurrentFileBaseAddress,
|
||||
(EFI_FFS_FILE_HEADER *) FvImage->CurrentFilePointer,
|
||||
SymImage,
|
||||
FvInfo->FvFiles[Index]
|
||||
);
|
||||
assert (!EFI_ERROR (Status));
|
||||
|
||||
//
|
||||
// Update the current pointer in the FV image
|
||||
//
|
||||
FvImage->CurrentFilePointer += FileSize;
|
||||
|
||||
//
|
||||
// Make next file start at QWord Boundry
|
||||
//
|
||||
while (((UINTN) FvImage->CurrentFilePointer & 0x07) != 0) {
|
||||
FvImage->CurrentFilePointer++;
|
||||
}
|
||||
|
||||
Exit:
|
||||
//
|
||||
// Free allocated memory.
|
||||
//
|
||||
free (FileBuffer);
|
||||
|
||||
return EFI_SUCCESS;
|
||||
return Status;
|
||||
}
|
||||
|
||||
EFI_STATUS
|
||||
@@ -2250,8 +2387,7 @@ Returns:
|
||||
} else if (_stricmp (FvInfo->FvComponents[Index].ComponentName, EFI_NV_FTW_SPARE_STRING) == 0) {
|
||||
AddFTWSpareBlock (FvImage, FvInfo->FvComponents[Index].Size, FvInfo);
|
||||
} else {
|
||||
printf ("Error. Unknown Non-FFS block %s \n", FvInfo->FvComponents[Index].ComponentName);
|
||||
return EFI_ABORTED;
|
||||
printf ("Warning: Unknown Non-FFS block %s \n", FvInfo->FvComponents[Index].ComponentName);
|
||||
}
|
||||
|
||||
FvImage = FvImage + FvInfo->FvComponents[Index].Size;
|
||||
@@ -2332,7 +2468,11 @@ Returns:
|
||||
PadFile->State = 0;
|
||||
PadFile->IntegrityCheck.Checksum.Header = CalculateChecksum8 ((UINT8 *) PadFile, sizeof (EFI_FFS_FILE_HEADER));
|
||||
if (PadFile->Attributes & FFS_ATTRIB_CHECKSUM) {
|
||||
#if (PI_SPECIFICATION_VERSION < 0x00010000)
|
||||
PadFile->IntegrityCheck.Checksum.File = CalculateChecksum8 ((UINT8 *) PadFile, FileSize);
|
||||
#else
|
||||
PadFile->IntegrityCheck.Checksum.File = CalculateChecksum8 ((UINT8 *) ((UINTN) PadFile + sizeof (EFI_FFS_FILE_HEADER)), FileSize - sizeof (EFI_FFS_FILE_HEADER));
|
||||
#endif
|
||||
} else {
|
||||
PadFile->IntegrityCheck.Checksum.File = FFS_FIXED_CHECKSUM;
|
||||
}
|
||||
@@ -2611,10 +2751,18 @@ Returns:
|
||||
VtfFile->IntegrityCheck.Checksum.File = 0;
|
||||
VtfFile->State = 0;
|
||||
if (VtfFile->Attributes & FFS_ATTRIB_CHECKSUM) {
|
||||
#if (PI_SPECIFICATION_VERSION < 0x00010000)
|
||||
VtfFile->IntegrityCheck.Checksum.File = CalculateChecksum8 (
|
||||
(UINT8 *) VtfFile,
|
||||
GetLength (VtfFile->Size) - TailSize
|
||||
);
|
||||
|
||||
#else
|
||||
VtfFile->IntegrityCheck.Checksum.File = CalculateChecksum8 (
|
||||
(UINT8 *) ((UINTN)VtfFile + sizeof (EFI_FFS_FILE_HEADER)),
|
||||
GetLength (VtfFile->Size) - TailSize - sizeof (EFI_FFS_FILE_HEADER)
|
||||
);
|
||||
#endif
|
||||
} else {
|
||||
VtfFile->IntegrityCheck.Checksum.File = FFS_FIXED_CHECKSUM;
|
||||
}
|
||||
@@ -2780,6 +2928,7 @@ Returns:
|
||||
UINTN Index;
|
||||
EFI_FIRMWARE_VOLUME_HEADER *FvHeader;
|
||||
EFI_FFS_FILE_HEADER *VtfFileImage;
|
||||
UINTN FvImageCapacity;
|
||||
|
||||
//
|
||||
// Check for invalid parameter
|
||||
@@ -2811,12 +2960,22 @@ Returns:
|
||||
//
|
||||
// Calculate the FV size
|
||||
//
|
||||
*FvImageSize = FvInfo.Size;
|
||||
if (FvInfo.Size != (UINTN) -1) {
|
||||
*FvImageSize = FvInfo.Size;
|
||||
FvImageCapacity = FvInfo.Size;
|
||||
} else {
|
||||
//
|
||||
// For auto size, set default as one block
|
||||
//
|
||||
FvInfo.FvBlocks[0].NumBlocks = 1;
|
||||
*FvImageSize = FvInfo.FvBlocks[0].BlockLength;
|
||||
FvImageCapacity = FV_CAPACITY_INCREASE_UNIT;
|
||||
}
|
||||
|
||||
//
|
||||
// Allocate the FV
|
||||
//
|
||||
*FvImage = malloc (*FvImageSize);
|
||||
*FvImage = malloc (FvImageCapacity);
|
||||
if (*FvImage == NULL) {
|
||||
return EFI_OUT_OF_RESOURCES;
|
||||
}
|
||||
@@ -2831,9 +2990,9 @@ Returns:
|
||||
// Initialize the FV to the erase polarity
|
||||
//
|
||||
if (FvInfo.FvAttributes & EFI_FVB_ERASE_POLARITY) {
|
||||
memset (*FvImage, -1, *FvImageSize);
|
||||
memset (*FvImage, -1, FvImageCapacity);
|
||||
} else {
|
||||
memset (*FvImage, 0, *FvImageSize);
|
||||
memset (*FvImage, 0, FvImageCapacity);
|
||||
}
|
||||
//
|
||||
// Initialize FV header
|
||||
@@ -2913,7 +3072,7 @@ Returns:
|
||||
//
|
||||
// Initialize the FV library.
|
||||
//
|
||||
InitializeFvLib (FvImageMemoryFile.FileImage, FvInfo.Size);
|
||||
InitializeFvLib (FvImageMemoryFile.FileImage, *FvImageSize);
|
||||
|
||||
//
|
||||
// Files start on 8 byte alignments, so move to the next 8 byte aligned
|
||||
@@ -2935,7 +3094,15 @@ Returns:
|
||||
//
|
||||
// Add the file
|
||||
//
|
||||
Status = AddFile (&FvImageMemoryFile, &FvInfo, Index, &VtfFileImage, &SymImageMemoryFile);
|
||||
Status = AddFile (&FvImageMemoryFile, &FvInfo, Index, &VtfFileImage, &SymImageMemoryFile, &FvImageCapacity);
|
||||
|
||||
//
|
||||
// Update FvImageSize and FvImage as they may be changed in AddFile routine
|
||||
//
|
||||
if (FvInfo.Size == (UINTN) -1) {
|
||||
*FvImageSize = FvInfo.FvBlocks[0].NumBlocks * FvInfo.FvBlocks[0].BlockLength;
|
||||
*FvImage = FvImageMemoryFile.FileImage;
|
||||
}
|
||||
|
||||
//
|
||||
// Exit if error detected while adding the file
|
||||
@@ -2966,7 +3133,7 @@ Returns:
|
||||
// reset vector. If the PEI Core is found, the VTF file will probably get
|
||||
// corrupted by updating the entry point.
|
||||
//
|
||||
if ((FvInfo.BaseAddress + FvInfo.Size) == FV_IMAGES_TOP_ADDRESS) {
|
||||
if ((FvInfo.BaseAddress + *FvImageSize) == FV_IMAGES_TOP_ADDRESS) {
|
||||
Status = UpdateResetVector (&FvImageMemoryFile, &FvInfo, VtfFileImage);
|
||||
if (EFI_ERROR(Status)) {
|
||||
printf ("ERROR: Could not update the reset vector.\n");
|
||||
@@ -2974,7 +3141,7 @@ Returns:
|
||||
return EFI_ABORTED;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
//
|
||||
// Determine final Sym file size
|
||||
//
|
||||
|
@@ -1,6 +1,6 @@
|
||||
/*++
|
||||
|
||||
Copyright (c) 2004 - 2007, Intel Corporation. All rights reserved.<BR>
|
||||
Copyright (c) 2004 - 2010, 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
|
||||
@@ -44,6 +44,8 @@ Abstract:
|
||||
#define MAX_NUMBER_OF_FILES_IN_FV 1000
|
||||
#define MAX_NUMBER_OF_COMPONENTS_IN_FV 10
|
||||
|
||||
#define FV_CAPACITY_INCREASE_UNIT 0x100000
|
||||
|
||||
//
|
||||
// INF file strings
|
||||
//
|
||||
@@ -150,6 +152,7 @@ Abstract:
|
||||
#define TRUE_STRING "TRUE"
|
||||
#define FALSE_STRING "FALSE"
|
||||
#define NULL_STRING "NULL"
|
||||
#define AUTO_STRING "AUTO"
|
||||
|
||||
//
|
||||
// Defines to calculate the offset for PEI CORE entry points
|
||||
@@ -206,6 +209,7 @@ EFI_STATUS
|
||||
ParseFvInf (
|
||||
IN MEMORY_FILE *InfFile,
|
||||
IN FV_INFO *FvInfo
|
||||
);
|
||||
)
|
||||
;
|
||||
|
||||
#endif
|
||||
|
@@ -1,6 +1,6 @@
|
||||
/*++
|
||||
|
||||
Copyright (c) 2004 - 2007, Intel Corporation. All rights reserved.<BR>
|
||||
Copyright (c) 2004 - 2010, 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
|
||||
@@ -35,6 +35,7 @@ Abstract:
|
||||
#include EFI_PROTOCOL_DEFINITION (GuidedSectionExtraction)
|
||||
|
||||
#define UTILITY_NAME "GenSection"
|
||||
#define UTILITY_VERSION "v1.0"
|
||||
|
||||
#define PARAMETER_NOT_SPECIFIED "Parameter not specified"
|
||||
#define MAXIMUM_INPUT_FILE_NUM 10
|
||||
@@ -81,37 +82,52 @@ PrintUsageMessage (
|
||||
VOID
|
||||
)
|
||||
{
|
||||
UINTN SectionType;
|
||||
UINTN DisplayCount;
|
||||
UINTN SectionType;
|
||||
int Index;
|
||||
const char *Str[] = {
|
||||
UTILITY_NAME" "UTILITY_VERSION" - Intel Generate Section Utility",
|
||||
" Copyright (C), 2004 - 2008 Intel Corporation",
|
||||
|
||||
#if ( defined(UTILITY_BUILD) && defined(UTILITY_VENDOR) )
|
||||
" Built from "UTILITY_BUILD", project of "UTILITY_VENDOR,
|
||||
#endif
|
||||
"",
|
||||
"Usage:",
|
||||
" "UTILITY_NAME" [OPTION]",
|
||||
"Common Options:",
|
||||
" -i InputFile Specifies the input file",
|
||||
" -o OutputFile Specifies the output file",
|
||||
" -s SectionType Specifies the type of the section, which can be one of",
|
||||
NULL
|
||||
};
|
||||
|
||||
printf ("Usage: "UTILITY_NAME " -i InputFile -o OutputFile -s SectionType [SectionType params]\n\n");
|
||||
printf (" Where SectionType is one of the following section types:\n\n");
|
||||
|
||||
DisplayCount = 0;
|
||||
for (SectionType = 0; SectionType <= EFI_SECTION_LAST_SECTION_TYPE; SectionType++) {
|
||||
if (SectionTypeName[SectionType] != NULL) {
|
||||
printf (" %s\n", SectionTypeName[SectionType]);
|
||||
}
|
||||
for (Index = 0; Str[Index] != NULL; Index++) {
|
||||
fprintf (stdout, "%s\n", Str[Index]);
|
||||
}
|
||||
|
||||
printf ("\n and SectionType dependent parameters are as follows:\n\n");
|
||||
printf (
|
||||
" %s: -t < %s | %s >\n",
|
||||
for (SectionType = 0; SectionType <= EFI_SECTION_LAST_SECTION_TYPE; SectionType++) {
|
||||
if (SectionTypeName[SectionType] != NULL) {
|
||||
fprintf (stdout, " %s\n", SectionTypeName[SectionType]);
|
||||
}
|
||||
}
|
||||
fprintf (stdout, "Section dependent options:\n");
|
||||
fprintf (stdout,
|
||||
" %s: -t < %s | %s >\n",
|
||||
SectionTypeName[EFI_SECTION_COMPRESSION],
|
||||
CompressionTypeName[EFI_NOT_COMPRESSED],
|
||||
CompressionTypeName[EFI_STANDARD_COMPRESSION]
|
||||
);
|
||||
printf (
|
||||
" %s: -t < %s >\n"" // Currently only CRC32 is supported\n\n",
|
||||
fprintf (stdout,
|
||||
" %s: -t < %s > // Only CRC32 is supported\n",
|
||||
SectionTypeName[EFI_SECTION_GUID_DEFINED],
|
||||
GUIDedSectionTypeName[EFI_SECTION_CRC32_GUID_DEFINED]
|
||||
);
|
||||
printf (
|
||||
" %s: -v VersionNumber\n"" [-a \"Version string\"]\n\n",
|
||||
" %s: -v VersionNumber [-a \"Version string\"]\n",
|
||||
SectionTypeName[EFI_SECTION_VERSION]
|
||||
);
|
||||
printf (
|
||||
" %s: -a \"Human readable name\"\n\n",
|
||||
" %s: -a \"Human readable name\"\n",
|
||||
SectionTypeName[EFI_SECTION_USER_INTERFACE]
|
||||
);
|
||||
}
|
||||
|
@@ -1,6 +1,6 @@
|
||||
/*++
|
||||
|
||||
Copyright (c) 1999 - 2007, Intel Corporation. All rights reserved.<BR>
|
||||
Copyright (c) 1999 - 2010, 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
|
||||
@@ -33,7 +33,7 @@ Abstract:
|
||||
// Version of this utility
|
||||
//
|
||||
#define UTILITY_NAME "GenTEImage"
|
||||
#define UTILITY_VERSION "v0.11"
|
||||
#define UTILITY_VERSION "v1.0"
|
||||
|
||||
//
|
||||
// Define the max length of a filename
|
||||
@@ -767,23 +767,28 @@ Returns:
|
||||
|
||||
--*/
|
||||
{
|
||||
int Index;
|
||||
static const char *Msg[] = {
|
||||
UTILITY_NAME " version "UTILITY_VERSION " - TE image utility",
|
||||
" Generate a TE image from an EFI PE32 image",
|
||||
" Usage: "UTILITY_NAME " {-v} {-dump} {-h|-?} {-o OutFileName} InFileName",
|
||||
" [-e|-b] [FileName(s)]",
|
||||
" where:",
|
||||
" -v - for verbose output",
|
||||
" -dump - to dump the input file to a text file",
|
||||
" -h -? - for this help information",
|
||||
" -o OutFileName - to write output to OutFileName rather than InFileName"DEFAULT_OUTPUT_EXTENSION,
|
||||
" InFileName - name of the input PE32 file",
|
||||
int Index;
|
||||
const char *Str[] = {
|
||||
UTILITY_NAME" "UTILITY_VERSION" - Intel Generate TE Image Utility",
|
||||
" Copyright (C), 1999 - 2008 Intel Corporation",
|
||||
|
||||
#if ( defined(UTILITY_BUILD) && defined(UTILITY_VENDOR) )
|
||||
" Built from "UTILITY_BUILD", project of "UTILITY_VENDOR,
|
||||
#endif
|
||||
"",
|
||||
"Usage:",
|
||||
" "UTILITY_NAME" [OPTION]... PE32IMAGE",
|
||||
"Description:",
|
||||
" Generate a TE image from an EFI PE32 image.",
|
||||
"Options:",
|
||||
" -v - for verbose output",
|
||||
" -dump - to dump the input file to a text file",
|
||||
" -h -? - for this help information",
|
||||
" -o OutFileName - to write output to OutFileName rather than PE32IMAGE"DEFAULT_OUTPUT_EXTENSION,
|
||||
NULL
|
||||
};
|
||||
for (Index = 0; Msg[Index] != NULL; Index++) {
|
||||
fprintf (stdout, "%s\n", Msg[Index]);
|
||||
for (Index = 0; Str[Index] != NULL; Index++) {
|
||||
fprintf (stdout, "%s\n", Str[Index]);
|
||||
}
|
||||
}
|
||||
|
||||
|
@@ -1,6 +1,6 @@
|
||||
/*++
|
||||
|
||||
Copyright (c) 2004 - 2007, Intel Corporation. All rights reserved.<BR>
|
||||
Copyright (c) 2004 - 2010, 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
|
||||
@@ -38,6 +38,9 @@ Abstract:
|
||||
#define MAX_PATH 1024
|
||||
#endif
|
||||
|
||||
#define UTILITY_NAME "GuidChk"
|
||||
#define UTILITY_VERSION "v1.0"
|
||||
|
||||
typedef struct {
|
||||
INT8 *Extension;
|
||||
INT8 ExtensionCode;
|
||||
@@ -593,25 +596,32 @@ Usage (
|
||||
VOID
|
||||
)
|
||||
{
|
||||
int Index;
|
||||
char *Str[] = {
|
||||
"GuidChk - scan files for duplicate GUID or signature definitions",
|
||||
"",
|
||||
"Usage: GuidChk {options}\n",
|
||||
" Options: ",
|
||||
" -d dirname exclude searching of a directory",
|
||||
" -f filename exclude searching of a file",
|
||||
" -e extension exclude searching of files by extension",
|
||||
" -p print all GUIDS found",
|
||||
" -g check for duplicate guids",
|
||||
" -s check for duplicate signatures",
|
||||
" -x print guid+defined symbol name",
|
||||
" -b outfile write internal GUID+basename list to outfile",
|
||||
" -u dirname exclude searching all subdirectories of a directory",
|
||||
" -h -? print this help text",
|
||||
" ",
|
||||
" Example: GuidChk -g -u build -d fv -f make.inf -e .pkg",
|
||||
int Index;
|
||||
const char *Str[] = {
|
||||
UTILITY_NAME" "UTILITY_VERSION" - Intel GUID Check Utility",
|
||||
" Copyright (C), 2004 - 2008 Intel Corporation",
|
||||
|
||||
#if ( defined(UTILITY_BUILD) && defined(UTILITY_VENDOR) )
|
||||
" Built from "UTILITY_BUILD", project of "UTILITY_VENDOR,
|
||||
#endif
|
||||
"",
|
||||
"Usage:",
|
||||
" "UTILITY_NAME" [OPTION]...",
|
||||
"Description:",
|
||||
" Scan files for duplicate GUID or signature definitions.",
|
||||
"Options:",
|
||||
" -d dirname exclude searching of a directory",
|
||||
" -f filename exclude searching of a file",
|
||||
" -e extension exclude searching of files by extension",
|
||||
" -p print all GUIDS found",
|
||||
" -g check for duplicate guids",
|
||||
" -s check for duplicate signatures",
|
||||
" -x print guid+defined symbol name",
|
||||
" -b outfile write internal GUID+basename list to outfile",
|
||||
" -u dirname exclude searching all subdirectories of a directory",
|
||||
" -h -? print this help text",
|
||||
"Example Usage:",
|
||||
" GuidChk -g -u build -d fv -f make.inf -e .pkg",
|
||||
NULL
|
||||
};
|
||||
for (Index = 0; Str[Index] != NULL; Index++) {
|
||||
|
208
EdkCompatibilityPkg/Sample/Tools/Source/HiiPack/FindFiles.c
Normal file
208
EdkCompatibilityPkg/Sample/Tools/Source/HiiPack/FindFiles.c
Normal file
@@ -0,0 +1,208 @@
|
||||
/*++
|
||||
|
||||
Copyright (c) 2004 - 2010, 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.
|
||||
|
||||
Module Name:
|
||||
|
||||
FindFiles.c
|
||||
|
||||
Abstract:
|
||||
|
||||
OS-specific functions to assist in finding files in
|
||||
subdirectories.
|
||||
|
||||
--*/
|
||||
|
||||
#include <windows.h>
|
||||
#include <direct.h>
|
||||
//
|
||||
// #include <io.h> // for _chmod()
|
||||
//
|
||||
#include <sys/stat.h>
|
||||
//
|
||||
// #include <errno.h> // for errno
|
||||
//
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <stdlib.h>
|
||||
#include <ctype.h>
|
||||
|
||||
#include "HiiPack.h"
|
||||
|
||||
extern
|
||||
void
|
||||
Error (
|
||||
char *Name,
|
||||
UINT32 LineNumber,
|
||||
UINT32 MessageCode,
|
||||
char *Text,
|
||||
char *MsgFmt,
|
||||
...
|
||||
);
|
||||
|
||||
static
|
||||
int
|
||||
ProcessDirectory (
|
||||
char *RootDirectory,
|
||||
char *FileMask,
|
||||
FIND_FILE_CALLBACK Callback
|
||||
);
|
||||
|
||||
/*****************************************************************************/
|
||||
int
|
||||
FindFiles (
|
||||
char *RootDirectory,
|
||||
char *FileMask,
|
||||
FIND_FILE_CALLBACK Callback
|
||||
)
|
||||
/*++
|
||||
|
||||
Routine Description:
|
||||
Find files of a given name under a root directory
|
||||
|
||||
Arguments:
|
||||
RootDirectory - base directory -- look in this directory and
|
||||
all its subdirectories for files matching FileMask.
|
||||
FileMask - file mask of files to find
|
||||
Callback - function to call for each file found
|
||||
|
||||
Returns:
|
||||
|
||||
--*/
|
||||
{
|
||||
char FullPath[MAX_PATH];
|
||||
//
|
||||
// If RootDirectory is relative, then append to cwd.
|
||||
//
|
||||
if (isalpha (RootDirectory[0]) && (RootDirectory[1] == ':')) {
|
||||
strcpy (FullPath, RootDirectory);
|
||||
} else {
|
||||
//
|
||||
// Get current working directory
|
||||
//
|
||||
if (_getcwd (FullPath, sizeof (FullPath)) == NULL) {
|
||||
Error (NULL, 0, 0, "failed to get current working directory", NULL);
|
||||
return 1;
|
||||
}
|
||||
//
|
||||
// Append the relative path they passed in
|
||||
//
|
||||
if (FullPath[strlen (FullPath) - 1] != '\\') {
|
||||
strcat (FullPath, "\\");
|
||||
}
|
||||
|
||||
strcat (FullPath, RootDirectory);
|
||||
}
|
||||
|
||||
if (FullPath[strlen (FullPath) - 1] == '\\') {
|
||||
FullPath[strlen (FullPath) - 1] = 0;
|
||||
}
|
||||
//
|
||||
// Process the directory
|
||||
//
|
||||
return ProcessDirectory (FullPath, FileMask, Callback);
|
||||
}
|
||||
|
||||
static
|
||||
int
|
||||
ProcessDirectory (
|
||||
char *RootDirectory,
|
||||
char *FileMask,
|
||||
FIND_FILE_CALLBACK Callback
|
||||
)
|
||||
/*++
|
||||
|
||||
Routine Description:
|
||||
Process a directory to find all files matching a given file mask
|
||||
|
||||
Arguments:
|
||||
RootDirectory - base directory -- look in this directory and
|
||||
all its subdirectories for files matching FileMask.
|
||||
FileMask - file mask of files to find
|
||||
Callback - function to call for each file found
|
||||
|
||||
Returns:
|
||||
|
||||
--*/
|
||||
{
|
||||
HANDLE Handle;
|
||||
WIN32_FIND_DATA FindData;
|
||||
char TempName[MAX_PATH];
|
||||
|
||||
Handle = INVALID_HANDLE_VALUE;
|
||||
//
|
||||
// Concatenate the filemask to the directory to create the full
|
||||
// path\mask path name.
|
||||
//
|
||||
strcpy (TempName, RootDirectory);
|
||||
strcat (TempName, "\\");
|
||||
strcat (TempName, FileMask);
|
||||
memset (&FindData, 0, sizeof (FindData));
|
||||
Handle = FindFirstFile (TempName, &FindData);
|
||||
if (Handle != INVALID_HANDLE_VALUE) {
|
||||
do {
|
||||
if ((FindData.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) == 0) {
|
||||
strcpy (TempName, RootDirectory);
|
||||
strcat (TempName, "\\");
|
||||
strcat (TempName, FindData.cFileName);
|
||||
if (Callback (TempName) != 0) {
|
||||
goto Done;
|
||||
}
|
||||
}
|
||||
} while (FindNextFile (Handle, &FindData));
|
||||
}
|
||||
|
||||
if (Handle != INVALID_HANDLE_VALUE) {
|
||||
FindClose (Handle);
|
||||
Handle = INVALID_HANDLE_VALUE;
|
||||
}
|
||||
//
|
||||
// Now create a *.* file mask to get all subdirectories and recursive call this
|
||||
// function to handle each one found.
|
||||
//
|
||||
strcpy (TempName, RootDirectory);
|
||||
strcat (TempName, "\\*.*");
|
||||
memset (&FindData, 0, sizeof (FindData));
|
||||
Handle = FindFirstFile (TempName, &FindData);
|
||||
//
|
||||
// Loop until no more files/directories
|
||||
//
|
||||
if (Handle != INVALID_HANDLE_VALUE) {
|
||||
do {
|
||||
if (FindData.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) {
|
||||
//
|
||||
// Make sure it's not "." or ".."
|
||||
//
|
||||
if ((strcmp (FindData.cFileName, ".") != 0) && (strcmp (FindData.cFileName, "..") != 0)) {
|
||||
//
|
||||
// Found a valid directory. Put it all together and make a recursive call
|
||||
// to process it.
|
||||
//
|
||||
strcpy (TempName, RootDirectory);
|
||||
strcat (TempName, "\\");
|
||||
strcat (TempName, FindData.cFileName);
|
||||
if (ProcessDirectory (TempName, FileMask, Callback) != 0) {
|
||||
goto Done;
|
||||
}
|
||||
}
|
||||
}
|
||||
} while (FindNextFile (Handle, &FindData));
|
||||
}
|
||||
|
||||
Done:
|
||||
//
|
||||
// Free the handle
|
||||
//
|
||||
if (Handle != INVALID_HANDLE_VALUE) {
|
||||
FindClose (Handle);
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
2561
EdkCompatibilityPkg/Sample/Tools/Source/HiiPack/HiiPack.c
Normal file
2561
EdkCompatibilityPkg/Sample/Tools/Source/HiiPack/HiiPack.c
Normal file
File diff suppressed because it is too large
Load Diff
63
EdkCompatibilityPkg/Sample/Tools/Source/HiiPack/HiiPack.h
Normal file
63
EdkCompatibilityPkg/Sample/Tools/Source/HiiPack/HiiPack.h
Normal file
@@ -0,0 +1,63 @@
|
||||
/*++
|
||||
|
||||
Copyright (c) 2004 - 2010, 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.
|
||||
|
||||
Module Name:
|
||||
|
||||
HiiPack.h
|
||||
|
||||
Abstract:
|
||||
|
||||
Common defines and prototypes for the HII pack tool.
|
||||
|
||||
--*/
|
||||
|
||||
#ifndef _HII_PACK_H_
|
||||
#define _HII_PACK_H_
|
||||
|
||||
#define DEFAULT_VARIABLE_NAME_L L"Setup"
|
||||
#define DEFAULT_VARIABLE_NAME "Setup"
|
||||
|
||||
#define MAX_VARIABLE_NAME 256
|
||||
#define FIRST_HII_PACK_HANDLE 1
|
||||
|
||||
typedef
|
||||
int
|
||||
(*FIND_FILE_CALLBACK) (
|
||||
char *FileName
|
||||
);
|
||||
|
||||
extern
|
||||
int
|
||||
FindFiles (
|
||||
char *RootDirectory,
|
||||
char *FileMask,
|
||||
FIND_FILE_CALLBACK Callback
|
||||
)
|
||||
/*++
|
||||
|
||||
Routine Description:
|
||||
|
||||
GC_TODO: Add function description
|
||||
|
||||
Arguments:
|
||||
|
||||
RootDirectory - GC_TODO: add argument description
|
||||
FileMask - GC_TODO: add argument description
|
||||
Callback - GC_TODO: add argument description
|
||||
|
||||
Returns:
|
||||
|
||||
GC_TODO: add return values
|
||||
|
||||
--*/
|
||||
;
|
||||
|
||||
#endif // #ifndef _HII_PACK_H_
|
2533
EdkCompatibilityPkg/Sample/Tools/Source/HiiPack/IfrParse.c
Normal file
2533
EdkCompatibilityPkg/Sample/Tools/Source/HiiPack/IfrParse.c
Normal file
File diff suppressed because it is too large
Load Diff
267
EdkCompatibilityPkg/Sample/Tools/Source/HiiPack/IfrParse.h
Normal file
267
EdkCompatibilityPkg/Sample/Tools/Source/HiiPack/IfrParse.h
Normal file
@@ -0,0 +1,267 @@
|
||||
/*++
|
||||
|
||||
Copyright (c) 2004 - 2010, 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.
|
||||
|
||||
Module Name:
|
||||
|
||||
IfrParse.h
|
||||
|
||||
Abstract:
|
||||
|
||||
Prototypes and defines for the IFR parsing services.
|
||||
|
||||
--*/
|
||||
|
||||
#ifndef _IFR_PARSE_H_
|
||||
#define _IFR_PARSE_H_
|
||||
|
||||
#define DEFAULT_HII_PACK_FILENAME_EXTENSION ".hpk"
|
||||
//
|
||||
// When we parse IFR, we'll keep the IFR in a linked list of
|
||||
// these.
|
||||
//
|
||||
typedef struct _IFR_PARSE_ENTRY {
|
||||
struct _IFR_PARSE_ENTRY *Next;
|
||||
int Tag; // for debugging
|
||||
EFI_IFR_OP_HEADER *RawIfrHeader;
|
||||
//
|
||||
// GUIDs for variable storage
|
||||
//
|
||||
EFI_GUID *VarStoreGuid1;
|
||||
char *VarStoreName1;
|
||||
EFI_GUID *VarStoreGuid2;
|
||||
char *VarStoreName2;
|
||||
} IFR_PARSE_ENTRY;
|
||||
|
||||
typedef struct _IFR_PARSE_CONTEXT {
|
||||
struct _IFR_PARSE_CONTEXT *Next;
|
||||
EFI_HII_IFR_PACK *PackHeader;
|
||||
char *IfrBufferStart;
|
||||
char *CurrentPos;
|
||||
long IfrBufferLen;
|
||||
int Handle;
|
||||
IFR_PARSE_ENTRY *Ifr;
|
||||
IFR_PARSE_ENTRY *LastIfr;
|
||||
IFR_PARSE_ENTRY *CurrentIfr;
|
||||
FILE *OutFptr;
|
||||
CHAR16 *Language;
|
||||
EFI_GUID *FormsetGuid;
|
||||
EFI_GUID NullGuid; // for use until we set the Guid field correctly
|
||||
EFI_GUID PackageGuid; // from the PackageGuid in the HII data table
|
||||
} IFR_PARSE_CONTEXT;
|
||||
|
||||
STATUS
|
||||
IfrGetVarPack (
|
||||
int VarIndex,
|
||||
EFI_HII_VARIABLE_PACK **VarPack
|
||||
)
|
||||
/*++
|
||||
|
||||
Routine Description:
|
||||
|
||||
GC_TODO: Add function description
|
||||
|
||||
Arguments:
|
||||
|
||||
VarIndex - GC_TODO: add argument description
|
||||
VarPack - GC_TODO: add argument description
|
||||
|
||||
Returns:
|
||||
|
||||
GC_TODO: add return values
|
||||
|
||||
--*/
|
||||
;
|
||||
|
||||
STATUS
|
||||
IfrParsePack (
|
||||
int Handle,
|
||||
EFI_HII_IFR_PACK *PackHeader,
|
||||
EFI_GUID *PackageGuid
|
||||
)
|
||||
/*++
|
||||
|
||||
Routine Description:
|
||||
|
||||
GC_TODO: Add function description
|
||||
|
||||
Arguments:
|
||||
|
||||
Handle - GC_TODO: add argument description
|
||||
PackHeader - GC_TODO: add argument description
|
||||
PackageGuid - GC_TODO: add argument description
|
||||
|
||||
Returns:
|
||||
|
||||
GC_TODO: add return values
|
||||
|
||||
--*/
|
||||
;
|
||||
|
||||
STATUS
|
||||
IfrParseCheck (
|
||||
char *Buffer,
|
||||
long BufferSize
|
||||
)
|
||||
/*++
|
||||
|
||||
Routine Description:
|
||||
|
||||
GC_TODO: Add function description
|
||||
|
||||
Arguments:
|
||||
|
||||
Buffer - GC_TODO: add argument description
|
||||
BufferSize - GC_TODO: add argument description
|
||||
|
||||
Returns:
|
||||
|
||||
GC_TODO: add return values
|
||||
|
||||
--*/
|
||||
;
|
||||
|
||||
STATUS
|
||||
IfrParseInit (
|
||||
VOID
|
||||
)
|
||||
/*++
|
||||
|
||||
Routine Description:
|
||||
|
||||
GC_TODO: Add function description
|
||||
|
||||
Arguments:
|
||||
|
||||
None
|
||||
|
||||
Returns:
|
||||
|
||||
GC_TODO: add return values
|
||||
|
||||
--*/
|
||||
;
|
||||
|
||||
STATUS
|
||||
IfrParseEnd (
|
||||
VOID
|
||||
)
|
||||
/*++
|
||||
|
||||
Routine Description:
|
||||
|
||||
GC_TODO: Add function description
|
||||
|
||||
Arguments:
|
||||
|
||||
None
|
||||
|
||||
Returns:
|
||||
|
||||
GC_TODO: add return values
|
||||
|
||||
--*/
|
||||
;
|
||||
|
||||
STATUS
|
||||
IfrParseDump (
|
||||
int Handle,
|
||||
CHAR16 *Language,
|
||||
FILE *OutFptr
|
||||
)
|
||||
/*++
|
||||
|
||||
Routine Description:
|
||||
|
||||
GC_TODO: Add function description
|
||||
|
||||
Arguments:
|
||||
|
||||
Handle - GC_TODO: add argument description
|
||||
Language - GC_TODO: add argument description
|
||||
OutFptr - GC_TODO: add argument description
|
||||
|
||||
Returns:
|
||||
|
||||
GC_TODO: add return values
|
||||
|
||||
--*/
|
||||
;
|
||||
|
||||
STATUS
|
||||
IfrSetDefaults (
|
||||
int MfgDefaults
|
||||
)
|
||||
/*++
|
||||
|
||||
Routine Description:
|
||||
|
||||
GC_TODO: Add function description
|
||||
|
||||
Arguments:
|
||||
|
||||
MfgDefaults - GC_TODO: add argument description
|
||||
|
||||
Returns:
|
||||
|
||||
GC_TODO: add return values
|
||||
|
||||
--*/
|
||||
;
|
||||
|
||||
STATUS
|
||||
IfrGetIfrPack (
|
||||
int Handle,
|
||||
EFI_HII_IFR_PACK **PackHeader,
|
||||
EFI_GUID *FormsetGuid
|
||||
)
|
||||
/*++
|
||||
|
||||
Routine Description:
|
||||
|
||||
GC_TODO: Add function description
|
||||
|
||||
Arguments:
|
||||
|
||||
Handle - GC_TODO: add argument description
|
||||
PackHeader - GC_TODO: add argument description
|
||||
FormsetGuid - GC_TODO: add argument description
|
||||
|
||||
Returns:
|
||||
|
||||
GC_TODO: add return values
|
||||
|
||||
--*/
|
||||
;
|
||||
|
||||
STATUS
|
||||
IfrReferencesVarPack (
|
||||
int IfrHandle,
|
||||
EFI_HII_VARIABLE_PACK *VarPack
|
||||
)
|
||||
/*++
|
||||
|
||||
Routine Description:
|
||||
|
||||
GC_TODO: Add function description
|
||||
|
||||
Arguments:
|
||||
|
||||
IfrHandle - GC_TODO: add argument description
|
||||
VarPack - GC_TODO: add argument description
|
||||
|
||||
Returns:
|
||||
|
||||
GC_TODO: add return values
|
||||
|
||||
--*/
|
||||
;
|
||||
|
||||
#endif // #ifndef _IFR_PARSE_H_
|
103
EdkCompatibilityPkg/Sample/Tools/Source/HiiPack/Makefile
Normal file
103
EdkCompatibilityPkg/Sample/Tools/Source/HiiPack/Makefile
Normal file
@@ -0,0 +1,103 @@
|
||||
#/*++
|
||||
#
|
||||
# Copyright (c) 2004 - 2010, 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.
|
||||
#
|
||||
# Module Name:
|
||||
#
|
||||
# Makefile
|
||||
#
|
||||
# Abstract:
|
||||
#
|
||||
# This file is used to build the HiiPack utility
|
||||
#
|
||||
#--*/
|
||||
|
||||
#
|
||||
# Make sure environmental variable EDK_SOURCE is set
|
||||
#
|
||||
!IFNDEF EDK_SOURCE
|
||||
!ERROR EDK_SOURCE environmental variable not set
|
||||
!ENDIF
|
||||
|
||||
#
|
||||
# Do this if you want to compile from this directory
|
||||
#
|
||||
!IFNDEF TOOLCHAIN
|
||||
TOOLCHAIN = TOOLCHAIN_MSVC
|
||||
!ENDIF
|
||||
|
||||
!INCLUDE $(BUILD_DIR)\PlatformTools.env
|
||||
|
||||
#
|
||||
# Target specific information
|
||||
#
|
||||
|
||||
TARGET_NAME = HiiPack
|
||||
TARGET_SRC_DIR = $(EDK_TOOLS_SOURCE)\$(TARGET_NAME)
|
||||
TARGET_EXE = $(EDK_TOOLS_OUTPUT)\HiiPack.exe
|
||||
|
||||
#
|
||||
# Build targets
|
||||
#
|
||||
|
||||
all: $(TARGET_EXE)
|
||||
|
||||
INC = $(INC) -I "$(EDK_SOURCE)\Foundation\Framework\Protocol\Hii"
|
||||
|
||||
INC_DEPS = "$(TARGET_SRC_DIR)\HiiPack.h" "$(TARGET_SRC_DIR)\IfrParse.h" "$(TARGET_SRC_DIR)\StringParse.h"
|
||||
|
||||
LIBS = "$(EDK_TOOLS_OUTPUT)\Common.lib"
|
||||
|
||||
OBJECTS = $(EDK_TOOLS_OUTPUT)\FindFiles.obj \
|
||||
$(EDK_TOOLS_OUTPUT)\HiiPack.obj \
|
||||
$(EDK_TOOLS_OUTPUT)\IfrParse.obj \
|
||||
$(EDK_TOOLS_OUTPUT)\StringParse.obj
|
||||
|
||||
#
|
||||
# Build EXE
|
||||
#
|
||||
|
||||
$(EDK_TOOLS_OUTPUT)\FindFiles.obj : $(TARGET_SRC_DIR)\FindFiles.c $(INC_DEPS)
|
||||
$(CC) $(C_FLAGS) $(INC) $(TARGET_SRC_DIR)\FindFiles.c /Fo$@
|
||||
|
||||
$(EDK_TOOLS_OUTPUT)\HiiPack.obj : $(TARGET_SRC_DIR)\HiiPack.c $(INC_DEPS)
|
||||
$(CC) $(C_FLAGS) $(INC) $(TARGET_SRC_DIR)\HiiPack.c /Fo$@
|
||||
|
||||
$(EDK_TOOLS_OUTPUT)\IfrParse.obj : $(TARGET_SRC_DIR)\IfrParse.c $(INC_DEPS)
|
||||
$(CC) $(C_FLAGS) $(INC) $(TARGET_SRC_DIR)\IfrParse.c /Fo$@
|
||||
|
||||
$(EDK_TOOLS_OUTPUT)\StringParse.obj : $(TARGET_SRC_DIR)\StringParse.c $(INC_DEPS)
|
||||
$(CC) $(C_FLAGS) $(INC) $(TARGET_SRC_DIR)\StringParse.c /Fo$@
|
||||
|
||||
#
|
||||
# Add Binary Build description for this tool.
|
||||
#
|
||||
|
||||
!IF (("$(EFI_BINARY_TOOLS)" == "YES") && EXIST($(EFI_PLATFORM_BIN)\Tools\$(TARGET_NAME).exe))
|
||||
$(TARGET_EXE): $(EFI_PLATFORM_BIN)\Tools\$(TARGET_NAME).exe
|
||||
copy $(EFI_PLATFORM_BIN)\Tools\$(TARGET_NAME).exe $(TARGET_EXE) /Y
|
||||
if exist $(EFI_PLATFORM_BIN)\Tools\$(TARGET_NAME).pdb \
|
||||
copy $(EFI_PLATFORM_BIN)\Tools\$(TARGET_NAME).pdb $(EDK_TOOLS_OUTPUT)\$(TARGET_NAME).pdb /Y
|
||||
!ELSE
|
||||
$(TARGET_EXE) : $(OBJECTS) $(LIBS)
|
||||
$(LINK) $(MSVS_LINK_LIBPATHS) $(L_FLAGS) $(LIBS) /out:$(TARGET_EXE) $(OBJECTS)
|
||||
!IF ("$(EFI_BINARY_BUILD)" == "YES")
|
||||
if not exist $(EFI_PLATFORM_BIN)\Tools mkdir $(EFI_PLATFORM_BIN)\Tools
|
||||
if exist $(TARGET_EXE) copy $(TARGET_EXE) $(EFI_PLATFORM_BIN)\tools\$(TARGET_NAME).exe /Y
|
||||
if exist $(EDK_TOOLS_OUTPUT)\$(TARGET_NAME).pdb \
|
||||
copy $(EDK_TOOLS_OUTPUT)\$(TARGET_NAME).pdb $(EFI_PLATFORM_BIN)\Tools\$(TARGET_NAME).pdb /Y
|
||||
!ENDIF
|
||||
!ENDIF
|
||||
|
||||
clean:
|
||||
@if exist $(EDK_TOOLS_OUTPUT)\$(TARGET_NAME).* del $(EDK_TOOLS_OUTPUT)\$(TARGET_NAME).* > NUL
|
||||
@if exist $(EDK_TOOLS_OUTPUT)\FindFiles.* del $(EDK_TOOLS_OUTPUT)\FindFiles.* > NUL
|
||||
@if exist $(EDK_TOOLS_OUTPUT)\IfrParse* del $(EDK_TOOLS_OUTPUT)\IfrParse.* > NUL
|
||||
@if exist $(EDK_TOOLS_OUTPUT)\StringParse.* del $(EDK_TOOLS_OUTPUT)\StringParse.* > NUL
|
244
EdkCompatibilityPkg/Sample/Tools/Source/HiiPack/StringParse.c
Normal file
244
EdkCompatibilityPkg/Sample/Tools/Source/HiiPack/StringParse.c
Normal file
@@ -0,0 +1,244 @@
|
||||
/*++
|
||||
|
||||
Copyright (c) 2004 - 2010, 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.
|
||||
|
||||
Module Name:
|
||||
|
||||
StringParse.c
|
||||
|
||||
Abstract:
|
||||
|
||||
Routines for parsing HII string packs
|
||||
|
||||
--*/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
#include "Tiano.h"
|
||||
#include "EfiUtilityMsgs.h"
|
||||
#include "EfiInternalFormRepresentation.h"
|
||||
#include "Hii.h"
|
||||
#include "StringParse.h"
|
||||
#include "HiiPack.h"
|
||||
|
||||
typedef struct _STRING_PACK_RECORD {
|
||||
struct _STRING_PACK_RECORD *Next;
|
||||
int Handle;
|
||||
EFI_GUID PackageGuid;
|
||||
EFI_GUID FormsetGuid;
|
||||
EFI_HII_STRING_PACK *StringPack;
|
||||
int StringPackSize;
|
||||
int NumStringPacks;
|
||||
} STRING_PACK_RECORD;
|
||||
|
||||
static STRING_PACK_RECORD *mStringPacks = NULL;
|
||||
|
||||
STATUS
|
||||
StringGetPack (
|
||||
int Handle, // matches handle passed in with StringParsePack()
|
||||
EFI_HII_STRING_PACK **StringPack, // returned pointer to string pack
|
||||
int *StringPackSize, // sizeof buffer pointed to by StringPack
|
||||
int *NumStringPacks, // in the array pointed to by StringPack
|
||||
EFI_GUID *FormsetGuid,
|
||||
EFI_GUID *PackageGuid
|
||||
)
|
||||
/*++
|
||||
|
||||
Routine Description:
|
||||
|
||||
Get a string pack given to us previously
|
||||
|
||||
Arguments:
|
||||
Handle - handle of string pack to get
|
||||
StringPack - outgoing pointer to string pack on the given handle
|
||||
StringPackSize - outgoing size of string pack pointed to by StringPack
|
||||
NumStringPacks - outgoing number of string packs in StringPack[] array
|
||||
FormsetGuid - outgoing GUID passed in with the string pack when it was parsed
|
||||
PackageGuid - outgoing GUID passed in with the string pack when it was parsed
|
||||
|
||||
Returns:
|
||||
|
||||
STATUS_SUCCESS - string pack with matching handle was found
|
||||
STATUS_ERROR - otherwise
|
||||
|
||||
--*/
|
||||
{
|
||||
STRING_PACK_RECORD *Rec;
|
||||
|
||||
for (Rec = mStringPacks; Rec != NULL; Rec = Rec->Next) {
|
||||
if (Rec->Handle == Handle) {
|
||||
*StringPack = Rec->StringPack;
|
||||
*StringPackSize = Rec->StringPackSize;
|
||||
*NumStringPacks = Rec->NumStringPacks;
|
||||
return STATUS_SUCCESS;
|
||||
}
|
||||
}
|
||||
|
||||
return STATUS_ERROR;
|
||||
}
|
||||
|
||||
STATUS
|
||||
StringParsePack (
|
||||
int Handle,
|
||||
EFI_HII_STRING_PACK *StringPack,
|
||||
EFI_GUID *FormsetGuid,
|
||||
EFI_GUID *PackageGuid
|
||||
)
|
||||
/*++
|
||||
|
||||
Routine Description:
|
||||
|
||||
Parse a string pack, saving the information for later retrieval by the caller
|
||||
|
||||
Arguments:
|
||||
Handle - handle of string pack
|
||||
StringPack - pointer to string pack array to parse
|
||||
FormsetGuid - GUID of the string pack
|
||||
PackageGuid - package GUID from the HII data table from which this string pack orginated
|
||||
|
||||
Returns:
|
||||
|
||||
STATUS_SUCCESS - Stringpack processed successfully
|
||||
STATUS_ERROR - otherwise
|
||||
|
||||
--*/
|
||||
{
|
||||
STRING_PACK_RECORD *Rec;
|
||||
|
||||
STRING_PACK_RECORD *TempRec;
|
||||
int PackSize;
|
||||
EFI_HII_STRING_PACK *TempPack;
|
||||
//
|
||||
// Allocate a new string pack record
|
||||
//
|
||||
Rec = (STRING_PACK_RECORD *) malloc (sizeof (STRING_PACK_RECORD));
|
||||
if (Rec == NULL) {
|
||||
Error (NULL, 0, 0, "memory allocation failure", NULL);
|
||||
return STATUS_ERROR;
|
||||
}
|
||||
|
||||
memset (Rec, 0, sizeof (STRING_PACK_RECORD));
|
||||
Rec->Handle = Handle;
|
||||
if (PackageGuid != NULL) {
|
||||
memcpy (&Rec->PackageGuid, PackageGuid, sizeof (EFI_GUID));
|
||||
}
|
||||
|
||||
if (FormsetGuid != NULL) {
|
||||
memcpy (&Rec->FormsetGuid, FormsetGuid, sizeof (EFI_GUID));
|
||||
}
|
||||
//
|
||||
// Walk the string packs to find the terminator
|
||||
//
|
||||
TempPack = StringPack;
|
||||
PackSize = 0;
|
||||
while (TempPack->Header.Length > 0) {
|
||||
if (TempPack->Header.Type != EFI_HII_STRING) {
|
||||
Error (NULL, 0, 0, "found a non-string pack in the string pack array", NULL);
|
||||
free (Rec);
|
||||
return STATUS_ERROR;
|
||||
}
|
||||
|
||||
PackSize += TempPack->Header.Length;
|
||||
Rec->NumStringPacks++;
|
||||
TempPack = (EFI_HII_STRING_PACK *) ((char *) TempPack + TempPack->Header.Length);
|
||||
}
|
||||
//
|
||||
// Add space for the terminator
|
||||
//
|
||||
PackSize += sizeof (EFI_HII_STRING_PACK);
|
||||
Rec->StringPackSize = PackSize;
|
||||
//
|
||||
// Make a copy of the incoming string pack
|
||||
//
|
||||
Rec->StringPack = (EFI_HII_STRING_PACK *) malloc (PackSize);
|
||||
if (Rec->StringPack == NULL) {
|
||||
Error (NULL, 0, 0, "memory allocation failure", NULL);
|
||||
free (Rec);
|
||||
return STATUS_ERROR;
|
||||
}
|
||||
|
||||
memcpy ((void *) Rec->StringPack, StringPack, PackSize);
|
||||
//
|
||||
// Add this record to our list
|
||||
//
|
||||
if (mStringPacks == NULL) {
|
||||
mStringPacks = Rec;
|
||||
} else {
|
||||
for (TempRec = mStringPacks; TempRec->Next != NULL; TempRec = TempRec->Next)
|
||||
;
|
||||
TempRec->Next = Rec;
|
||||
}
|
||||
free (Rec->StringPack);
|
||||
free (Rec);
|
||||
return STATUS_SUCCESS;
|
||||
}
|
||||
|
||||
STATUS
|
||||
StringInit (
|
||||
VOID
|
||||
)
|
||||
/*++
|
||||
|
||||
Routine Description:
|
||||
|
||||
GC_TODO: Add function description
|
||||
|
||||
Arguments:
|
||||
|
||||
None
|
||||
|
||||
Returns:
|
||||
|
||||
GC_TODO: add return values
|
||||
|
||||
--*/
|
||||
{
|
||||
StringEnd ();
|
||||
return STATUS_SUCCESS;
|
||||
}
|
||||
|
||||
STATUS
|
||||
StringEnd (
|
||||
VOID
|
||||
)
|
||||
/*++
|
||||
|
||||
Routine Description:
|
||||
|
||||
GC_TODO: Add function description
|
||||
|
||||
Arguments:
|
||||
|
||||
None
|
||||
|
||||
Returns:
|
||||
|
||||
GC_TODO: add return values
|
||||
|
||||
--*/
|
||||
{
|
||||
STRING_PACK_RECORD *Next;
|
||||
//
|
||||
// Free up all the memory we've allocated
|
||||
//
|
||||
while (mStringPacks != NULL) {
|
||||
if (mStringPacks->StringPack != NULL) {
|
||||
free (mStringPacks->StringPack);
|
||||
}
|
||||
|
||||
Next = mStringPacks->Next;
|
||||
free (mStringPacks);
|
||||
mStringPacks = Next;
|
||||
}
|
||||
|
||||
return STATUS_SUCCESS;
|
||||
}
|
125
EdkCompatibilityPkg/Sample/Tools/Source/HiiPack/StringParse.h
Normal file
125
EdkCompatibilityPkg/Sample/Tools/Source/HiiPack/StringParse.h
Normal file
@@ -0,0 +1,125 @@
|
||||
/*++
|
||||
|
||||
Copyright (c) 2004 - 2010, 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.
|
||||
|
||||
Module Name:
|
||||
|
||||
StringParse.h
|
||||
|
||||
Abstract:
|
||||
|
||||
Prototypes and defines for the string pack parsing services.
|
||||
|
||||
--*/
|
||||
|
||||
#ifndef _STRING_PARSE_H_
|
||||
#define _STRING_PARSE_H_
|
||||
|
||||
STATUS
|
||||
StringGetPack (
|
||||
int Handle, // matches handle passed in with StringParsePack()
|
||||
EFI_HII_STRING_PACK **StringPack, // returned pointer to string pack
|
||||
int *StringPackSize, // sizeof buffer pointed to by StringPack
|
||||
int *NumStringPacks, // in the array pointed to by StringPack
|
||||
EFI_GUID *FormsetGuid,
|
||||
EFI_GUID *PackageGuid
|
||||
)
|
||||
/*++
|
||||
|
||||
Routine Description:
|
||||
|
||||
GC_TODO: Add function description
|
||||
|
||||
Arguments:
|
||||
|
||||
Handle - GC_TODO: add argument description
|
||||
StringPack - GC_TODO: add argument description
|
||||
StringPackSize - GC_TODO: add argument description
|
||||
NumStringPacks - GC_TODO: add argument description
|
||||
FormsetGuid - GC_TODO: add argument description
|
||||
PackageGuid - GC_TODO: add argument description
|
||||
|
||||
Returns:
|
||||
|
||||
GC_TODO: add return values
|
||||
|
||||
--*/
|
||||
;
|
||||
|
||||
STATUS
|
||||
StringParsePack (
|
||||
int Handle,
|
||||
EFI_HII_STRING_PACK *StringPack,
|
||||
EFI_GUID *FormsetGuid,
|
||||
EFI_GUID *PackageGuid
|
||||
)
|
||||
/*++
|
||||
|
||||
Routine Description:
|
||||
|
||||
GC_TODO: Add function description
|
||||
|
||||
Arguments:
|
||||
|
||||
Handle - GC_TODO: add argument description
|
||||
StringPack - GC_TODO: add argument description
|
||||
FormsetGuid - GC_TODO: add argument description
|
||||
PackageGuid - GC_TODO: add argument description
|
||||
|
||||
Returns:
|
||||
|
||||
GC_TODO: add return values
|
||||
|
||||
--*/
|
||||
;
|
||||
|
||||
STATUS
|
||||
StringInit (
|
||||
VOID
|
||||
)
|
||||
/*++
|
||||
|
||||
Routine Description:
|
||||
|
||||
GC_TODO: Add function description
|
||||
|
||||
Arguments:
|
||||
|
||||
None
|
||||
|
||||
Returns:
|
||||
|
||||
GC_TODO: add return values
|
||||
|
||||
--*/
|
||||
;
|
||||
|
||||
STATUS
|
||||
StringEnd (
|
||||
VOID
|
||||
)
|
||||
/*++
|
||||
|
||||
Routine Description:
|
||||
|
||||
GC_TODO: Add function description
|
||||
|
||||
Arguments:
|
||||
|
||||
None
|
||||
|
||||
Returns:
|
||||
|
||||
GC_TODO: add return values
|
||||
|
||||
--*/
|
||||
;
|
||||
|
||||
#endif // #ifndef _STRING_PARSE_H_
|
@@ -1,6 +1,6 @@
|
||||
/*++
|
||||
|
||||
Copyright (c) 2004 - 2007, Intel Corporation. All rights reserved.<BR>
|
||||
Copyright (c) 2004 - 2010, 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
|
||||
@@ -37,6 +37,7 @@ typedef struct _STRING_LIST {
|
||||
} STRING_LIST;
|
||||
|
||||
#define UTILITY_NAME "MakeDeps"
|
||||
#define UTILITY_VERSION "v1.0"
|
||||
|
||||
#define MAX_LINE_LEN 2048
|
||||
#define MAX_PATH 2048
|
||||
@@ -1488,30 +1489,36 @@ Returns:
|
||||
|
||||
--*/
|
||||
{
|
||||
int Index;
|
||||
static const char *Str[] = {
|
||||
UTILITY_NAME " -- make dependencies",
|
||||
" Usage: MakeDeps [options]",
|
||||
" Options include:",
|
||||
" -h or -? for this help information",
|
||||
" -f SourceFile add SourceFile to list of files to scan",
|
||||
" -i IncludePath add IncludePath to list of search paths",
|
||||
" -o OutputFile write output dependencies to OutputFile",
|
||||
" -s SubDir for each IncludePath, also search IncludePath\\SubDir",
|
||||
" -v for verbose output",
|
||||
" -ignorenotfound don't warn for files not found",
|
||||
" -target Target for single SourceFile, target is Target, not SourceFile.obj",
|
||||
" -q quiet mode to not report files not found if ignored",
|
||||
" -sub sym str replace all occurrances of 'str' with 'sym' in the output",
|
||||
" -nosystem not process system <include> files",
|
||||
" -neverfail always return a success return code",
|
||||
//
|
||||
// " -nodupes keep track of include files, don't rescan duplicates",
|
||||
//
|
||||
" -usesumdeps path use summary dependency files in 'path' directory.",
|
||||
" -asm The SourceFiles are assembler files",
|
||||
" -cl The SourceFiles are the output of cl with /showIncludes",
|
||||
int Index;
|
||||
const char *Str[] = {
|
||||
UTILITY_NAME" "UTILITY_VERSION" - Intel Make Dependencies Utility",
|
||||
" Copyright (C), 2004 - 2008 Intel Corporation",
|
||||
|
||||
#if ( defined(UTILITY_BUILD) && defined(UTILITY_VENDOR) )
|
||||
" Built from "UTILITY_BUILD", project of "UTILITY_VENDOR,
|
||||
#endif
|
||||
"",
|
||||
"Usage:",
|
||||
" "UTILITY_NAME" [OPTION]...",
|
||||
"Options:",
|
||||
" -h or -? for this help information",
|
||||
" -f SourceFile add SourceFile to list of files to scan",
|
||||
" -i IncludePath add IncludePath to list of search paths",
|
||||
" -o OutputFile write output dependencies to OutputFile",
|
||||
" -s SubDir for each IncludePath, also search IncludePath\\SubDir",
|
||||
" -v for verbose output",
|
||||
" -ignorenotfound don't warn for files not found",
|
||||
" -target Target for single SourceFile, target is Target, not SourceFile.obj",
|
||||
" -q quiet mode to not report files not found if ignored",
|
||||
" -sub sym str replace all occurrances of 'str' with 'sym' in the output",
|
||||
" -nosystem not process system <include> files",
|
||||
" -neverfail always return a success return code",
|
||||
//
|
||||
// " -nodupes keep track of include files, don't rescan duplicates",
|
||||
//
|
||||
" -usesumdeps path use summary dependency files in 'path' directory.",
|
||||
" -asm The SourceFiles are assembler files",
|
||||
" -cl The SourceFiles are the output of cl with /showIncludes",
|
||||
NULL
|
||||
};
|
||||
for (Index = 0; Str[Index] != NULL; Index++) {
|
||||
|
@@ -1,6 +1,6 @@
|
||||
#/*++
|
||||
#
|
||||
# Copyright (c) 2004 - 2007, Intel Corporation. All rights reserved.<BR>
|
||||
# Copyright (c) 2004 - 2010, 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
|
||||
@@ -44,9 +44,11 @@ MAKEFILES = $(EDK_TOOLS_SOURCE)\Common\Makefile \
|
||||
!IF "$(EFI_SPECIFICATION_VERSION)" >= "0x0002000A"
|
||||
$(EDK_TOOLS_SOURCE)\UefiVfrCompile\makefile \
|
||||
$(EDK_TOOLS_SOURCE)\UefiStrGather\makefile \
|
||||
$(EDK_TOOLS_SOURCE)\UefiHiiPack\Makefile \
|
||||
!ELSE
|
||||
$(EDK_TOOLS_SOURCE)\VfrCompile\makefile \
|
||||
$(EDK_TOOLS_SOURCE)\StrGather\makefile \
|
||||
$(EDK_TOOLS_SOURCE)\HiiPack\Makefile \
|
||||
!ENDIF
|
||||
$(EDK_TOOLS_SOURCE)\SplitFile\Makefile \
|
||||
$(EDK_TOOLS_SOURCE)\Strip\Makefile \
|
||||
|
@@ -1,6 +1,6 @@
|
||||
/*++
|
||||
|
||||
Copyright (c) 1999 - 2002, Intel Corporation. All rights reserved.<BR>
|
||||
Copyright (c) 1999 - 2010, 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
|
||||
@@ -23,6 +23,8 @@ Abstract:
|
||||
#include "stdio.h"
|
||||
#include "string.h"
|
||||
|
||||
#define UTILITY_NAME "ModifyInf"
|
||||
#define UTILITY_VERSION "v1.0"
|
||||
//
|
||||
// Read a line into buffer including '\r\n'
|
||||
//
|
||||
@@ -263,7 +265,22 @@ Returns:
|
||||
|
||||
--*/
|
||||
{
|
||||
printf ("ModifyInf InputFVInfFileName OutputFVInfFileName [Pattern strings]\r\n");
|
||||
int Index;
|
||||
const char *Str[] = {
|
||||
UTILITY_NAME" "UTILITY_VERSION" - Intel Modify INF File Utility",
|
||||
" Copyright (C), 1999 - 2008 Intel Corporation",
|
||||
|
||||
#if ( defined(UTILITY_BUILD) && defined(UTILITY_VENDOR) )
|
||||
" Built from "UTILITY_BUILD", project of "UTILITY_VENDOR,
|
||||
#endif
|
||||
"",
|
||||
"Usage:",
|
||||
" "UTILITY_NAME" SOURCE DEST [PATTERN]",
|
||||
NULL
|
||||
};
|
||||
for (Index = 0; Str[Index] != NULL; Index++) {
|
||||
fprintf (stdout, "%s\n", Str[Index]);
|
||||
}
|
||||
}
|
||||
|
||||
int
|
||||
|
@@ -1,6 +1,6 @@
|
||||
/*++
|
||||
|
||||
Copyright (c) 2004 - 2007, Intel Corporation. All rights reserved.<BR>
|
||||
Copyright (c) 2004 - 2010, 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
|
||||
@@ -35,18 +35,7 @@ Abstract:
|
||||
#define EFI_BASE_ADDRESS "EFI_BASE_ADDRESS"
|
||||
#define DEFAULT_FV_INF_DIR "FV" // default dir for where we create the FV INF file
|
||||
#define DEFAULT_FV_DIR "$(BUILD_DIR)" // where the FV file comes from
|
||||
#define MALLOC(size) malloc (size)
|
||||
#define FREE(ptr) free (ptr)
|
||||
|
||||
//
|
||||
// Disable warning for unused function arguments
|
||||
//
|
||||
#pragma warning(disable : 4100)
|
||||
//
|
||||
// Disable warning for while(1) code
|
||||
//
|
||||
// #pragma warning (disable : 4127)
|
||||
//
|
||||
typedef struct {
|
||||
char *ComponentType;
|
||||
char *Extension;
|
||||
@@ -196,8 +185,7 @@ static
|
||||
void
|
||||
AddFirmwareVolumes (
|
||||
char *FVs,
|
||||
int ComponentsInstance,
|
||||
FILE_LIST *FileListPtr
|
||||
int ComponentsInstance
|
||||
);
|
||||
|
||||
static
|
||||
@@ -503,7 +491,7 @@ Returns:
|
||||
// Add these firmware volumes to the list of known firmware
|
||||
// volume names.
|
||||
//
|
||||
AddFirmwareVolumes (FVs, ComponentsInstance, Ptr);
|
||||
AddFirmwareVolumes (FVs, ComponentsInstance);
|
||||
|
||||
return STATUS_SUCCESS;
|
||||
}
|
||||
@@ -528,7 +516,7 @@ CFVDestructor (
|
||||
//
|
||||
while (mFVList != NULL) {
|
||||
mFVListLast = mFVList->Next;
|
||||
FREE (mFVList);
|
||||
free (mFVList);
|
||||
mFVList = mFVListLast;
|
||||
}
|
||||
}
|
||||
@@ -957,10 +945,10 @@ Returns:
|
||||
//
|
||||
// Now go through the list of all NonFFS FVs they specified and search for
|
||||
// a [build.fv.$(FV)] or [build.fv] command and emit the commands to the
|
||||
// output makefile. Add them to the "fvs" target as well.
|
||||
// output makefile. Add them to the "fvs_0" target as well.
|
||||
//
|
||||
if (mNonFfsFVList != NULL) {
|
||||
fprintf (MakeFptr, "fvs ::");
|
||||
fprintf (MakeFptr, "fvs_0 ::");
|
||||
FVPtr = mNonFfsFVList;
|
||||
while (FVPtr != NULL) {
|
||||
fprintf (MakeFptr, " %s%s.fv", FVDir, FVPtr->FVFileName);
|
||||
@@ -1022,43 +1010,40 @@ Returns:
|
||||
DSCFileRestorePosition (DSC);
|
||||
}
|
||||
}
|
||||
//
|
||||
// Go through our list of firmware volumes and create an "fvs" target that
|
||||
// builds everything. It has to be a mix of components and FV's in order.
|
||||
// For example: fvs : components_0 fv\fv001.fv fv\fv002.fv components_1 fv\fv003.fv
|
||||
//
|
||||
ComponentsInstance = 0;
|
||||
ComponentCount = 0;
|
||||
fprintf (MakeFptr, "fvs ::");
|
||||
for (;;) {
|
||||
//
|
||||
// First see if we have any components for this section. If we don't,
|
||||
// then we're done
|
||||
//
|
||||
for (FileListPtr = mFileList; FileListPtr != NULL; FileListPtr = FileListPtr->Next) {
|
||||
if (FileListPtr->ComponentsInstance == ComponentsInstance) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (FileListPtr == NULL) {
|
||||
break;
|
||||
//
|
||||
// Get the components count
|
||||
//
|
||||
ComponentCount = -1;
|
||||
for (FileListPtr = mFileList; FileListPtr != NULL; FileListPtr = FileListPtr->Next) {
|
||||
if (FileListPtr->ComponentsInstance > ComponentCount) {
|
||||
ComponentCount = FileListPtr->ComponentsInstance;
|
||||
}
|
||||
}
|
||||
ComponentCount++;
|
||||
|
||||
fprintf (MakeFptr, " components_%d", ComponentsInstance);
|
||||
ComponentCount++;
|
||||
//
|
||||
// Now print any firmware volumes that match this components instance
|
||||
//
|
||||
//
|
||||
// Now print firmware volumes build targets fvs_0, fvs_1 etc.
|
||||
//
|
||||
for (ComponentsInstance = 0; ComponentsInstance < ComponentCount; ComponentsInstance++) {
|
||||
fprintf (MakeFptr, "fvs_%d ::", ComponentsInstance);
|
||||
for (FVPtr = mFVList; FVPtr != NULL; FVPtr = FVPtr->Next) {
|
||||
if (FVPtr->ComponentsInstance == ComponentsInstance) {
|
||||
fprintf (MakeFptr, " %s%s.fv", FVDir, FVPtr->FVFileName);
|
||||
}
|
||||
}
|
||||
|
||||
ComponentsInstance++;
|
||||
fprintf (MakeFptr, "\n\n");
|
||||
}
|
||||
|
||||
//
|
||||
// Create an "fvs" target that builds everything. It has to be a mix of
|
||||
// components and FV's in order. For example:
|
||||
// fvs :: components_0 fvs_0 components_1 fvs_1
|
||||
//
|
||||
fprintf (MakeFptr, "fvs ::");
|
||||
for (ComponentsInstance = 0; ComponentsInstance < ComponentCount; ComponentsInstance++) {
|
||||
fprintf (MakeFptr, " components_%d fvs_%d", ComponentsInstance, ComponentsInstance);
|
||||
}
|
||||
|
||||
fprintf (MakeFptr, "\n\n");
|
||||
|
||||
//
|
||||
@@ -1351,8 +1336,7 @@ static
|
||||
void
|
||||
AddFirmwareVolumes (
|
||||
char *FVs,
|
||||
int ComponentsInstance,
|
||||
FILE_LIST *FileListPtr
|
||||
int ComponentsInstance
|
||||
)
|
||||
{
|
||||
FV_LIST *FvPtr;
|
||||
@@ -1386,7 +1370,7 @@ AddFirmwareVolumes (
|
||||
// If we didn't find a match, then create a new one
|
||||
//
|
||||
if (FvPtr == NULL) {
|
||||
FvPtr = MALLOC (sizeof (FV_LIST));
|
||||
FvPtr = malloc (sizeof (FV_LIST));
|
||||
if (FvPtr == NULL) {
|
||||
Error (__FILE__, __LINE__, 0, "application error", "memory allocation failed");
|
||||
return ;
|
||||
|
@@ -1,6 +1,6 @@
|
||||
#/*++
|
||||
#
|
||||
# Copyright (c) 2004 - 2007, Intel Corporation. All rights reserved.<BR>
|
||||
# Copyright (c) 2004 - 2010, 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
|
||||
@@ -49,25 +49,31 @@ TARGET_EXE = $(EDK_TOOLS_OUTPUT)\ProcessDsc.exe
|
||||
|
||||
all: $(TARGET_EXE)
|
||||
|
||||
INC_DEPS = $(TARGET_SRC_DIR)\DSCFile.h $(INC_DEPS)
|
||||
INC_DEPS = $(TARGET_SRC_DIR)\FWVolume.h $(INC_DEPS)
|
||||
INC_DEPS = $(TARGET_SRC_DIR)\Exceptions.h $(INC_DEPS)
|
||||
INC_DEPS = $(TARGET_SRC_DIR)\Common.h $(INC_DEPS)
|
||||
INC_DEPS = $(TARGET_SRC_DIR)\DSCFile.h $(INC_DEPS)
|
||||
INC_DEPS = $(TARGET_SRC_DIR)\MultiThread.h $(INC_DEPS)
|
||||
INC_DEPS = $(TARGET_SRC_DIR)\FWVolume.h $(INC_DEPS)
|
||||
INC_DEPS = $(TARGET_SRC_DIR)\Exceptions.h $(INC_DEPS)
|
||||
INC_DEPS = $(TARGET_SRC_DIR)\Common.h $(INC_DEPS)
|
||||
|
||||
LIBS = $(LIBS) "$(EDK_TOOLS_OUTPUT)\Common.lib"
|
||||
|
||||
OBJECTS = $(EDK_TOOLS_OUTPUT)\DSCFile.obj \
|
||||
$(EDK_TOOLS_OUTPUT)\FWVolume.obj \
|
||||
$(EDK_TOOLS_OUTPUT)\ProcessDsc.obj \
|
||||
OBJECTS = $(EDK_TOOLS_OUTPUT)\DSCFile.obj \
|
||||
$(EDK_TOOLS_OUTPUT)\MultiThread.obj \
|
||||
$(EDK_TOOLS_OUTPUT)\FWVolume.obj \
|
||||
$(EDK_TOOLS_OUTPUT)\ProcessDsc.obj \
|
||||
$(EDK_TOOLS_OUTPUT)\Exceptions.obj
|
||||
|
||||
#
|
||||
# Compile each source file
|
||||
#
|
||||
C_FLAGS = $(C_FLAGS) /MT /wd4201
|
||||
|
||||
$(EDK_TOOLS_OUTPUT)\DSCFile.obj : $(TARGET_SRC_DIR)\DSCFile.c $(INC_DEPS)
|
||||
$(CC) $(C_FLAGS) $(TARGET_SRC_DIR)\DSCFile.c /Fo$@
|
||||
|
||||
$(EDK_TOOLS_OUTPUT)\MultiThread.obj : $(TARGET_SRC_DIR)\MultiThread.c $(INC_DEPS)
|
||||
$(CC) $(C_FLAGS) $(TARGET_SRC_DIR)\MultiThread.c /Fo$@
|
||||
|
||||
$(EDK_TOOLS_OUTPUT)\FWVolume.obj : $(TARGET_SRC_DIR)\FWVolume.c $(INC_DEPS)
|
||||
$(CC) $(C_FLAGS) $(TARGET_SRC_DIR)\FWVolume.c /Fo$@
|
||||
|
||||
@@ -88,7 +94,9 @@ $(TARGET_EXE): $(EFI_PLATFORM_BIN)\Tools\$(TARGET_NAME).exe
|
||||
copy $(EFI_PLATFORM_BIN)\Tools\$(TARGET_NAME).pdb $(EDK_TOOLS_OUTPUT)\$(TARGET_NAME).pdb /Y
|
||||
!ELSE
|
||||
$(TARGET_EXE) : $(OBJECTS) $(LIBS)
|
||||
$(LINK) $(MSVS_LINK_LIBPATHS) $(L_FLAGS) $(LIBS) /out:$(TARGET_EXE) $(OBJECTS)
|
||||
$(LINK) $(MSVS_LINK_LIBPATHS) $(L_FLAGS) $(LIBS) /out:$(TARGET_EXE) $(OBJECTS) shlwapi.lib \
|
||||
/NODEFAULTLIB:libc.lib /NODEFAULTLIB:msvcrt.lib /NODEFAULTLIB:libcd.lib \
|
||||
/NODEFAULTLIB:libcmtd.lib /NODEFAULTLIB:msvcrtd.lib
|
||||
!IF ("$(EFI_BINARY_BUILD)" == "YES")
|
||||
if not exist $(EFI_PLATFORM_BIN)\Tools mkdir $(EFI_PLATFORM_BIN)\Tools
|
||||
if exist $(TARGET_EXE) copy $(TARGET_EXE) $(EFI_PLATFORM_BIN)\tools\$(TARGET_NAME).exe /Y
|
||||
@@ -100,5 +108,6 @@ $(TARGET_EXE) : $(OBJECTS) $(LIBS)
|
||||
clean:
|
||||
@if exist $(EDK_TOOLS_OUTPUT)\$(TARGET_NAME).* del $(EDK_TOOLS_OUTPUT)\$(TARGET_NAME).* > NUL
|
||||
@if exist $(EDK_TOOLS_OUTPUT)\DscFile.* del $(EDK_TOOLS_OUTPUT)\DscFile.* > NUL
|
||||
@if exist $(EDK_TOOLS_OUTPUT)\MultiThread.* del $(EDK_TOOLS_OUTPUT)\MultiThread.* > NUL
|
||||
@if exist $(EDK_TOOLS_OUTPUT)\Exceptions* del $(EDK_TOOLS_OUTPUT)\Exceptions.* > NUL
|
||||
@if exist $(EDK_TOOLS_OUTPUT)\FwVolume.* del $(EDK_TOOLS_OUTPUT)\FwVolume.* > NUL
|
||||
|
905
EdkCompatibilityPkg/Sample/Tools/Source/ProcessDsc/MultiThread.c
Normal file
905
EdkCompatibilityPkg/Sample/Tools/Source/ProcessDsc/MultiThread.c
Normal file
@@ -0,0 +1,905 @@
|
||||
/*++
|
||||
|
||||
Copyright (c) 2008 - 2010, 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.
|
||||
|
||||
Module Name:
|
||||
|
||||
MultiThread.c
|
||||
|
||||
Abstract:
|
||||
|
||||
This module is used to add multi-thread build support to ProcessDsc utility
|
||||
to improve the build performance.
|
||||
|
||||
--*/
|
||||
|
||||
#include <windows.h>
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <stdlib.h>
|
||||
#include <direct.h>
|
||||
#include "Common.h"
|
||||
#include "MultiThread.h"
|
||||
|
||||
BUILD_ITEM *
|
||||
AddBuildItem (
|
||||
BUILD_ITEM **BuildList,
|
||||
INT8 *BaseName,
|
||||
INT8 *Processor,
|
||||
INT8 *Makefile
|
||||
)
|
||||
/*++
|
||||
|
||||
Routine Description:
|
||||
|
||||
Add a build item to a specified build list
|
||||
|
||||
Arguments:
|
||||
|
||||
BuildList - build list where the new build item will be added
|
||||
BaseName - base name of the new module
|
||||
Processor - processor type of the new module
|
||||
Makefile - makefile name of the new module
|
||||
|
||||
Returns:
|
||||
|
||||
Pointer to the newly added build item
|
||||
|
||||
--*/
|
||||
{
|
||||
BUILD_ITEM *NewBuildItem;
|
||||
|
||||
//
|
||||
// Create a new build item
|
||||
//
|
||||
NewBuildItem = malloc (sizeof (BUILD_ITEM));
|
||||
if (NewBuildItem == NULL) {
|
||||
return NULL;
|
||||
}
|
||||
memset (NewBuildItem, 0, sizeof (BUILD_ITEM));
|
||||
NewBuildItem->BaseName = _strdup (BaseName);
|
||||
NewBuildItem->Processor = _strdup (Processor);
|
||||
NewBuildItem->Makefile = _strdup (Makefile);
|
||||
|
||||
//
|
||||
// Add the build item to the head of the build list
|
||||
//
|
||||
NewBuildItem->Next = *BuildList;
|
||||
*BuildList = NewBuildItem;
|
||||
|
||||
return NewBuildItem;
|
||||
}
|
||||
|
||||
SOURCE_FILE_ITEM *
|
||||
AddSourceFile (
|
||||
BUILD_ITEM *BuildItem,
|
||||
INT8 *FileName
|
||||
)
|
||||
/*++
|
||||
|
||||
Routine Description:
|
||||
|
||||
Add a source file for a build item
|
||||
|
||||
Arguments:
|
||||
|
||||
BuildItem - build item to add the source file
|
||||
FileName - source file name to be added
|
||||
|
||||
Returns:
|
||||
|
||||
Pointer to the newly added source file item
|
||||
|
||||
--*/
|
||||
{
|
||||
SOURCE_FILE_ITEM *NewSourceFile;
|
||||
|
||||
//
|
||||
// Create a new source file item
|
||||
//
|
||||
NewSourceFile = malloc (sizeof (SOURCE_FILE_ITEM));
|
||||
if (NewSourceFile == NULL) {
|
||||
return NULL;
|
||||
}
|
||||
memset (NewSourceFile, 0, sizeof (SOURCE_FILE_ITEM));
|
||||
NewSourceFile->FileName = _strdup (FileName);
|
||||
|
||||
//
|
||||
// Add the source file item to the head of the source file list
|
||||
//
|
||||
NewSourceFile->Next = BuildItem->SourceFileList;
|
||||
BuildItem->SourceFileList = NewSourceFile;
|
||||
|
||||
return NewSourceFile;
|
||||
}
|
||||
|
||||
DEPENDENCY_ITEM *
|
||||
AddDependency (
|
||||
BUILD_ITEM *BuildList,
|
||||
BUILD_ITEM *BuildItem,
|
||||
INT8 *BaseName,
|
||||
INT8 AdjustIndex
|
||||
)
|
||||
/*++
|
||||
|
||||
Routine Description:
|
||||
|
||||
Add a build dependency for a build item in the specified build list
|
||||
|
||||
Arguments:
|
||||
|
||||
BuildList - build list where to search the dependency
|
||||
BuildItem - build item to add the dependency
|
||||
BaseName - dependency module base name
|
||||
AdjustIndex - Adjust BuildItem->Index when non-zero
|
||||
|
||||
Returns:
|
||||
|
||||
Pointer to the newly added build dependency
|
||||
|
||||
--*/
|
||||
{
|
||||
BUILD_ITEM *TempBuildItem;
|
||||
DEPENDENCY_ITEM *NewDependency;
|
||||
|
||||
//
|
||||
// Search the dependency in the build list
|
||||
//
|
||||
TempBuildItem = BuildList;
|
||||
while (TempBuildItem != NULL) {
|
||||
if ((_stricmp (TempBuildItem->BaseName, BaseName) == 0) &&
|
||||
(_stricmp (TempBuildItem->Processor, BuildItem->Processor) == 0) &&
|
||||
(TempBuildItem != BuildItem)) {
|
||||
break;
|
||||
}
|
||||
TempBuildItem = TempBuildItem->Next;
|
||||
}
|
||||
if (TempBuildItem == NULL) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
//
|
||||
// This index is used to isolate two modules with same base name and processor.
|
||||
// (ProcessDsc allows duplicate base name libraries.)
|
||||
//
|
||||
if (AdjustIndex) {
|
||||
BuildItem->Index = TempBuildItem->Index + 1;
|
||||
}
|
||||
|
||||
//
|
||||
// Create a new build dependency item
|
||||
//
|
||||
NewDependency = malloc (sizeof (DEPENDENCY_ITEM));
|
||||
if (NewDependency == NULL) {
|
||||
return NULL;
|
||||
}
|
||||
memset (NewDependency, 0, sizeof (DEPENDENCY_ITEM));
|
||||
NewDependency->Dependency = TempBuildItem;
|
||||
|
||||
//
|
||||
// Add the build dependency item to the head of the dependency list
|
||||
//
|
||||
NewDependency->Next = BuildItem->DependencyList;
|
||||
BuildItem->DependencyList = NewDependency;
|
||||
|
||||
return NewDependency;
|
||||
}
|
||||
|
||||
void
|
||||
FreeBuildList (
|
||||
BUILD_ITEM *BuildList
|
||||
)
|
||||
/*++
|
||||
|
||||
Routine Description:
|
||||
|
||||
Free a build list
|
||||
|
||||
Arguments:
|
||||
|
||||
BuildList - build list to be freed
|
||||
|
||||
Returns:
|
||||
|
||||
--*/
|
||||
{
|
||||
BUILD_ITEM *TempBuildItem;
|
||||
BUILD_ITEM *FreeBuildItem;
|
||||
SOURCE_FILE_ITEM *TempSourceFile;
|
||||
SOURCE_FILE_ITEM *FreeSourceFile;
|
||||
DEPENDENCY_ITEM *TempDependency;
|
||||
DEPENDENCY_ITEM *FreeDependency;
|
||||
|
||||
TempBuildItem = BuildList;
|
||||
while (TempBuildItem != NULL) {
|
||||
free (TempBuildItem->BaseName);
|
||||
free (TempBuildItem->Processor);
|
||||
free (TempBuildItem->Makefile);
|
||||
|
||||
//
|
||||
// Free source file list
|
||||
//
|
||||
TempSourceFile = TempBuildItem->SourceFileList;
|
||||
while (TempSourceFile != NULL) {
|
||||
FreeSourceFile = TempSourceFile;
|
||||
TempSourceFile = TempSourceFile->Next;
|
||||
free (FreeSourceFile);
|
||||
}
|
||||
|
||||
//
|
||||
// Free dependency list
|
||||
//
|
||||
TempDependency = TempBuildItem->DependencyList;
|
||||
while (TempDependency != NULL) {
|
||||
FreeDependency = TempDependency;
|
||||
TempDependency = TempDependency->Next;
|
||||
free (FreeDependency);
|
||||
}
|
||||
|
||||
FreeBuildItem = TempBuildItem;
|
||||
TempBuildItem = TempBuildItem->Next;
|
||||
free (FreeBuildItem);
|
||||
}
|
||||
}
|
||||
|
||||
COMPONENTS_ITEM *
|
||||
AddComponentsItem (
|
||||
COMPONENTS_ITEM **ComponentsList
|
||||
)
|
||||
/*++
|
||||
|
||||
Routine Description:
|
||||
|
||||
Add a new components item to a specified components list
|
||||
|
||||
Arguments:
|
||||
|
||||
ComponentsList - components list where the new components item will be added
|
||||
|
||||
Returns:
|
||||
|
||||
Pointer to the newly added components item
|
||||
|
||||
--*/
|
||||
{
|
||||
COMPONENTS_ITEM *NewComponents;
|
||||
COMPONENTS_ITEM *TempComponents;
|
||||
|
||||
//
|
||||
// Create a new components item
|
||||
//
|
||||
NewComponents = malloc (sizeof (COMPONENTS_ITEM));
|
||||
if (NewComponents == NULL) {
|
||||
return NULL;
|
||||
}
|
||||
memset (NewComponents, 0, sizeof (COMPONENTS_ITEM));
|
||||
|
||||
//
|
||||
// Add the components item to the tail of the components list
|
||||
//
|
||||
TempComponents = *ComponentsList;
|
||||
if (TempComponents == NULL) {
|
||||
*ComponentsList = NewComponents;
|
||||
} else {
|
||||
while (TempComponents->Next != NULL) {
|
||||
TempComponents = TempComponents->Next;
|
||||
}
|
||||
TempComponents->Next = NewComponents;
|
||||
}
|
||||
|
||||
return NewComponents;
|
||||
}
|
||||
|
||||
void
|
||||
FreeComponentsList (
|
||||
COMPONENTS_ITEM *ComponentsList
|
||||
)
|
||||
/*++
|
||||
|
||||
Routine Description:
|
||||
|
||||
Free a components list
|
||||
|
||||
Arguments:
|
||||
|
||||
ComponentsList - components list to be freed
|
||||
|
||||
Returns:
|
||||
|
||||
--*/
|
||||
{
|
||||
COMPONENTS_ITEM *TempComponents;
|
||||
COMPONENTS_ITEM *FreeComponents;
|
||||
|
||||
TempComponents = ComponentsList;
|
||||
while (TempComponents != NULL) {
|
||||
FreeBuildList (TempComponents->BuildList);
|
||||
FreeComponents = TempComponents;
|
||||
TempComponents = TempComponents->Next;
|
||||
free (FreeComponents);
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
// Module globals for multi-thread build
|
||||
//
|
||||
static INT8 mError; // non-zero means error occurred
|
||||
static INT8 mDone; // non-zero means no more build items available for build
|
||||
static UINT32 mThreadNumber; // thread number
|
||||
static INT8 *mBuildDir; // build directory
|
||||
static INT8 mLogDir[MAX_PATH]; // build item log dir
|
||||
static CRITICAL_SECTION mCriticalSection; // critical section object
|
||||
static HANDLE mSemaphoreHandle; // semaphore for "ready for build" items in mWaitingList
|
||||
static HANDLE mEventHandle; // event signaled when one build item is finished
|
||||
static BUILD_ITEM *mPendingList; // build list for build items which are not ready for build
|
||||
static BUILD_ITEM *mWaitingList; // build list for build items which are ready for build
|
||||
static BUILD_ITEM *mBuildingList; // build list for build items which are buiding
|
||||
static BUILD_ITEM *mDoneList; // build list for build items which already finish the build
|
||||
|
||||
//
|
||||
// Restore the BuildList (not care about the sequence of the build items)
|
||||
//
|
||||
static void
|
||||
RestoreBuildList (
|
||||
BUILD_ITEM **BuildList
|
||||
)
|
||||
{
|
||||
BUILD_ITEM *TempBuildItem;
|
||||
|
||||
if (mPendingList != NULL) {
|
||||
//
|
||||
// Add the mPendingList to the header of *BuildList
|
||||
//
|
||||
TempBuildItem = mPendingList;
|
||||
while (TempBuildItem->Next != NULL) {
|
||||
TempBuildItem = TempBuildItem->Next;
|
||||
}
|
||||
TempBuildItem->Next = *BuildList;
|
||||
*BuildList = mPendingList;
|
||||
}
|
||||
|
||||
if (mWaitingList != NULL) {
|
||||
//
|
||||
// Add the mWaitingList to the header of *BuildList
|
||||
//
|
||||
TempBuildItem = mWaitingList;
|
||||
while (TempBuildItem->Next != NULL) {
|
||||
TempBuildItem = TempBuildItem->Next;
|
||||
}
|
||||
TempBuildItem->Next = *BuildList;
|
||||
*BuildList = mWaitingList;
|
||||
}
|
||||
|
||||
if (mBuildingList != NULL) {
|
||||
//
|
||||
// Add the mBuildingList to the header of *BuildList
|
||||
//
|
||||
TempBuildItem = mBuildingList;
|
||||
while (TempBuildItem->Next != NULL) {
|
||||
TempBuildItem = TempBuildItem->Next;
|
||||
}
|
||||
TempBuildItem->Next = *BuildList;
|
||||
*BuildList = mBuildingList;
|
||||
}
|
||||
|
||||
if (mDoneList != NULL) {
|
||||
//
|
||||
// Add the mDoneList to the header of *BuildList
|
||||
//
|
||||
TempBuildItem = mDoneList;
|
||||
while (TempBuildItem->Next != NULL) {
|
||||
TempBuildItem = TempBuildItem->Next;
|
||||
}
|
||||
TempBuildItem->Next = *BuildList;
|
||||
*BuildList = mDoneList;
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
// Return non-zero when no source file build conflict
|
||||
//
|
||||
static INT8
|
||||
CheckSourceFile (
|
||||
SOURCE_FILE_ITEM *SourceFileList
|
||||
)
|
||||
{
|
||||
BUILD_ITEM *TempBuildItem;
|
||||
SOURCE_FILE_ITEM *TempSourceFile;
|
||||
|
||||
while (SourceFileList != NULL) {
|
||||
TempBuildItem = mBuildingList;
|
||||
while (TempBuildItem != NULL) {
|
||||
TempSourceFile = TempBuildItem->SourceFileList;
|
||||
while (TempSourceFile != NULL) {
|
||||
if (_stricmp (SourceFileList->FileName, TempSourceFile->FileName) == 0) {
|
||||
return 0;
|
||||
}
|
||||
TempSourceFile = TempSourceFile->Next;
|
||||
}
|
||||
TempBuildItem = TempBuildItem->Next;
|
||||
}
|
||||
SourceFileList = SourceFileList->Next;
|
||||
}
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
//
|
||||
// Return non-zero when all the dependency build items has been built
|
||||
//
|
||||
static INT8
|
||||
CheckDependency (
|
||||
DEPENDENCY_ITEM *DependencyList
|
||||
)
|
||||
{
|
||||
while (DependencyList != NULL) {
|
||||
if (!(DependencyList->Dependency->CompleteFlag)) {
|
||||
return 0;
|
||||
}
|
||||
DependencyList = DependencyList->Next;
|
||||
}
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
//
|
||||
// Run the build task. The system() function call will cause stdout conflict
|
||||
// in multi-thread envroment, so implement this through CreateProcess().
|
||||
//
|
||||
static INT8
|
||||
RunBuildTask (
|
||||
INT8 *WorkingDir,
|
||||
INT8 *LogFile,
|
||||
INT8 *BuildCmd
|
||||
)
|
||||
{
|
||||
HANDLE FileHandle;
|
||||
SECURITY_ATTRIBUTES SecAttr;
|
||||
PROCESS_INFORMATION ProcInfo;
|
||||
STARTUPINFO StartInfo;
|
||||
BOOL FuncRetn;
|
||||
DWORD ExitCode;
|
||||
|
||||
//
|
||||
// Init SecAttr
|
||||
//
|
||||
SecAttr.nLength = sizeof (SECURITY_ATTRIBUTES);
|
||||
SecAttr.bInheritHandle = TRUE;
|
||||
SecAttr.lpSecurityDescriptor = NULL;
|
||||
|
||||
//
|
||||
// Create the log file
|
||||
//
|
||||
FileHandle = CreateFile (
|
||||
LogFile, // file to create
|
||||
GENERIC_WRITE, // open for writing
|
||||
0, // do not share
|
||||
&SecAttr, // can be inherited by child processes
|
||||
CREATE_ALWAYS, // overwrite existing
|
||||
FILE_ATTRIBUTE_NORMAL, // normal file
|
||||
NULL // no attr. template
|
||||
);
|
||||
|
||||
if (FileHandle == INVALID_HANDLE_VALUE) {
|
||||
EnterCriticalSection (&mCriticalSection);
|
||||
Error (NULL, 0, 0, NULL, "could not open file %s", LogFile);
|
||||
LeaveCriticalSection (&mCriticalSection);
|
||||
return 1;
|
||||
}
|
||||
|
||||
//
|
||||
// Init ProcInfo and StartInfo
|
||||
//
|
||||
ZeroMemory (&ProcInfo, sizeof (PROCESS_INFORMATION));
|
||||
ZeroMemory (&StartInfo, sizeof (STARTUPINFO));
|
||||
StartInfo.cb = sizeof (STARTUPINFO);
|
||||
StartInfo.hStdError = FileHandle;
|
||||
StartInfo.hStdOutput = FileHandle;
|
||||
StartInfo.hStdInput = GetStdHandle (STD_INPUT_HANDLE);
|
||||
StartInfo.dwFlags = STARTF_USESTDHANDLES;
|
||||
|
||||
//
|
||||
// Create the child process
|
||||
//
|
||||
FuncRetn = CreateProcess (
|
||||
NULL, // no application name
|
||||
BuildCmd, // command line
|
||||
NULL, // process security attributes
|
||||
NULL, // primary thread security attributes
|
||||
TRUE, // handles are inherited
|
||||
0, // creation flags
|
||||
NULL, // use parent's environment
|
||||
WorkingDir, // set current directory
|
||||
&StartInfo, // STARTUPINFO pointer
|
||||
&ProcInfo // receives PROCESS_INFORMATION
|
||||
);
|
||||
|
||||
if (FuncRetn == FALSE) {
|
||||
EnterCriticalSection (&mCriticalSection);
|
||||
Error (NULL, 0, 0, NULL, "could not create child process");
|
||||
LeaveCriticalSection (&mCriticalSection);
|
||||
CloseHandle (FileHandle);
|
||||
return 1;
|
||||
}
|
||||
|
||||
//
|
||||
// Wait until child process exits
|
||||
//
|
||||
WaitForSingleObject (ProcInfo.hProcess, INFINITE);
|
||||
GetExitCodeProcess (ProcInfo.hProcess, &ExitCode);
|
||||
CloseHandle (ProcInfo.hProcess);
|
||||
CloseHandle (ProcInfo.hThread);
|
||||
CloseHandle (FileHandle);
|
||||
|
||||
if (ExitCode != 0) {
|
||||
return 1;
|
||||
} else {
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
// Thread function
|
||||
//
|
||||
static DWORD WINAPI
|
||||
ThreadProc (
|
||||
LPVOID lpParam
|
||||
)
|
||||
{
|
||||
UINT32 ThreadId;
|
||||
BUILD_ITEM *PreviousBuildItem;
|
||||
BUILD_ITEM *CurrentBuildItem;
|
||||
BUILD_ITEM *NextBuildItem;
|
||||
INT8 WorkingDir[MAX_PATH];
|
||||
INT8 LogFile[MAX_PATH];
|
||||
INT8 BuildCmd[MAX_PATH];
|
||||
|
||||
ThreadId = (UINT32)lpParam;
|
||||
//
|
||||
// Loop until error occurred or no more build items available for build
|
||||
//
|
||||
for (;;) {
|
||||
WaitForSingleObject (mSemaphoreHandle, INFINITE);
|
||||
if (mError || mDone) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
//
|
||||
// When code runs here, there must have one build item available for this
|
||||
// thread. Loop until error occurred or get one build item for build.
|
||||
//
|
||||
for (;;) {
|
||||
EnterCriticalSection (&mCriticalSection);
|
||||
PreviousBuildItem = NULL;
|
||||
CurrentBuildItem = mWaitingList;
|
||||
while (CurrentBuildItem != NULL) {
|
||||
NextBuildItem = CurrentBuildItem->Next;
|
||||
//
|
||||
// CheckSourceFile() is to avoid concurrently build the same source file
|
||||
// which may cause the muti-thread build failure
|
||||
//
|
||||
if (CheckSourceFile (CurrentBuildItem->SourceFileList)) {
|
||||
//
|
||||
// Move the current build item from mWaitingList
|
||||
//
|
||||
if (PreviousBuildItem != NULL) {
|
||||
PreviousBuildItem->Next = NextBuildItem;
|
||||
} else {
|
||||
mWaitingList = NextBuildItem;
|
||||
}
|
||||
//
|
||||
// Add the current build item to the head of mBuildingList
|
||||
//
|
||||
CurrentBuildItem->Next = mBuildingList;
|
||||
mBuildingList = CurrentBuildItem;
|
||||
//
|
||||
// If no more build items is pending or waiting for build,
|
||||
// wake up every child thread for exit.
|
||||
//
|
||||
if ((mPendingList == NULL) && (mWaitingList == NULL)) {
|
||||
mDone = 1;
|
||||
//
|
||||
// Make sure to wake up every child thread for exit
|
||||
//
|
||||
ReleaseSemaphore (mSemaphoreHandle, mThreadNumber, NULL);
|
||||
}
|
||||
break;
|
||||
}
|
||||
PreviousBuildItem = CurrentBuildItem;
|
||||
CurrentBuildItem = NextBuildItem;
|
||||
}
|
||||
if (CurrentBuildItem != NULL) {
|
||||
//
|
||||
// Display build item info
|
||||
//
|
||||
printf ("\t[Thread_%d] nmake -nologo -f %s all\n", ThreadId, CurrentBuildItem->Makefile);
|
||||
//
|
||||
// Prepare build task
|
||||
//
|
||||
sprintf (WorkingDir, "%s\\%s", mBuildDir, CurrentBuildItem->Processor);
|
||||
sprintf (LogFile, "%s\\%s_%s_%d.txt", mLogDir, CurrentBuildItem->BaseName,
|
||||
CurrentBuildItem->Processor, CurrentBuildItem->Index);
|
||||
sprintf (BuildCmd, "nmake -nologo -f %s all", CurrentBuildItem->Makefile);
|
||||
LeaveCriticalSection (&mCriticalSection);
|
||||
break;
|
||||
} else {
|
||||
LeaveCriticalSection (&mCriticalSection);
|
||||
//
|
||||
// All the build items in mWaitingList have source file conflict with
|
||||
// mBuildingList. This rarely hapeens. Need wait for the build items in
|
||||
// mBuildingList to be finished by other child threads.
|
||||
//
|
||||
Sleep (1000);
|
||||
if (mError) {
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
// Start to build the CurrentBuildItem
|
||||
//
|
||||
if (RunBuildTask (WorkingDir, LogFile, BuildCmd)) {
|
||||
//
|
||||
// Build failure
|
||||
//
|
||||
mError = 1;
|
||||
//
|
||||
// Make sure to wake up every child thread for exit
|
||||
//
|
||||
ReleaseSemaphore (mSemaphoreHandle, mThreadNumber, NULL);
|
||||
SetEvent(mEventHandle);
|
||||
|
||||
return mError;
|
||||
} else {
|
||||
//
|
||||
// Build success
|
||||
//
|
||||
CurrentBuildItem->CompleteFlag = 1;
|
||||
|
||||
EnterCriticalSection (&mCriticalSection);
|
||||
//
|
||||
// Move this build item from mBuildingList
|
||||
//
|
||||
if (mBuildingList == CurrentBuildItem) {
|
||||
mBuildingList = mBuildingList->Next;
|
||||
} else {
|
||||
NextBuildItem = mBuildingList;
|
||||
while (NextBuildItem->Next != CurrentBuildItem) {
|
||||
NextBuildItem = NextBuildItem->Next;
|
||||
}
|
||||
NextBuildItem->Next = CurrentBuildItem->Next;
|
||||
}
|
||||
//
|
||||
// Add this build item to mDoneList
|
||||
//
|
||||
CurrentBuildItem->Next = mDoneList;
|
||||
mDoneList = CurrentBuildItem;
|
||||
LeaveCriticalSection (&mCriticalSection);
|
||||
|
||||
SetEvent(mEventHandle);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
INT8
|
||||
StartMultiThreadBuild (
|
||||
BUILD_ITEM **BuildList,
|
||||
UINT32 ThreadNumber,
|
||||
INT8 *BuildDir
|
||||
)
|
||||
/*++
|
||||
|
||||
Routine Description:
|
||||
|
||||
Start multi-thread build for a specified build list
|
||||
|
||||
Arguments:
|
||||
|
||||
BuildList - build list for multi-thread build
|
||||
ThreadNumber - thread number for multi-thread build
|
||||
BuildDir - build dir
|
||||
|
||||
Returns:
|
||||
|
||||
0 - Successfully finished the multi-thread build
|
||||
other value - Build failure
|
||||
|
||||
--*/
|
||||
{
|
||||
UINT32 Index;
|
||||
UINT32 Count;
|
||||
BUILD_ITEM *PreviousBuildItem;
|
||||
BUILD_ITEM *CurrentBuildItem;
|
||||
BUILD_ITEM *NextBuildItem;
|
||||
HANDLE *ThreadHandle;
|
||||
INT8 Cmd[MAX_PATH];
|
||||
|
||||
mError = 0;
|
||||
mDone = 0;
|
||||
mThreadNumber = ThreadNumber;
|
||||
mBuildDir = BuildDir;
|
||||
mPendingList = *BuildList;
|
||||
*BuildList = NULL;
|
||||
mWaitingList = NULL;
|
||||
mBuildingList = NULL;
|
||||
mDoneList = NULL;
|
||||
|
||||
//
|
||||
// Do nothing when mPendingList is empty
|
||||
//
|
||||
if (mPendingList == NULL) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
//
|
||||
// Get build item count of mPendingList
|
||||
//
|
||||
Count = 0;
|
||||
CurrentBuildItem = mPendingList;
|
||||
while (CurrentBuildItem != NULL) {
|
||||
Count++;
|
||||
CurrentBuildItem = CurrentBuildItem->Next;
|
||||
}
|
||||
|
||||
//
|
||||
// The semaphore is also used to wake up child threads for exit,
|
||||
// so need to make sure "maximum count" >= "thread number".
|
||||
//
|
||||
if (Count < ThreadNumber) {
|
||||
Count = ThreadNumber;
|
||||
}
|
||||
|
||||
//
|
||||
// Init mSemaphoreHandle
|
||||
//
|
||||
mSemaphoreHandle = CreateSemaphore (
|
||||
NULL, // default security attributes
|
||||
0, // initial count
|
||||
Count, // maximum count
|
||||
NULL // unnamed semaphore
|
||||
);
|
||||
if (mSemaphoreHandle == NULL) {
|
||||
Error (NULL, 0, 0, NULL, "failed to create semaphore");
|
||||
RestoreBuildList (BuildList);
|
||||
return 1;
|
||||
}
|
||||
|
||||
//
|
||||
// Init mEventHandle
|
||||
//
|
||||
mEventHandle = CreateEvent(
|
||||
NULL, // default security attributes
|
||||
FALSE, // auto-reset event
|
||||
TRUE, // initial state is signaled
|
||||
NULL // object not named
|
||||
);
|
||||
if (mEventHandle == NULL) {
|
||||
Error (NULL, 0, 0, NULL, "failed to create event");
|
||||
CloseHandle (mSemaphoreHandle);
|
||||
RestoreBuildList (BuildList);
|
||||
return 1;
|
||||
}
|
||||
|
||||
//
|
||||
// Init mCriticalSection
|
||||
//
|
||||
InitializeCriticalSection (&mCriticalSection);
|
||||
|
||||
//
|
||||
// Create build item log dir
|
||||
//
|
||||
sprintf (mLogDir, "%s\\Log", mBuildDir);
|
||||
_mkdir (mLogDir);
|
||||
|
||||
//
|
||||
// Create child threads for muti-thread build
|
||||
//
|
||||
ThreadHandle = malloc (ThreadNumber * sizeof (HANDLE));
|
||||
if (ThreadHandle == NULL) {
|
||||
Error (NULL, 0, 0, NULL, "failed to allocate memory");
|
||||
CloseHandle (mSemaphoreHandle);
|
||||
CloseHandle (mEventHandle);
|
||||
RestoreBuildList (BuildList);
|
||||
return 1;
|
||||
}
|
||||
for (Index = 0; Index < ThreadNumber; Index++) {
|
||||
ThreadHandle[Index] = CreateThread (
|
||||
NULL, // default security attributes
|
||||
0, // use default stack size
|
||||
ThreadProc, // thread function
|
||||
(LPVOID)Index, // argument to thread function: use Index as thread id
|
||||
0, // use default creation flags
|
||||
NULL // thread identifier not needed
|
||||
);
|
||||
if (ThreadHandle[Index] == NULL) {
|
||||
Error (NULL, 0, 0, NULL, "failed to create Thread_%d", Index);
|
||||
mError = 1;
|
||||
ThreadNumber = Index;
|
||||
//
|
||||
// Make sure to wake up every child thread for exit
|
||||
//
|
||||
ReleaseSemaphore (mSemaphoreHandle, ThreadNumber, NULL);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
// Loop until error occurred or no more build items pending for build
|
||||
//
|
||||
for (;;) {
|
||||
WaitForSingleObject (mEventHandle, INFINITE);
|
||||
if (mError) {
|
||||
break;
|
||||
}
|
||||
Count = 0;
|
||||
|
||||
EnterCriticalSection (&mCriticalSection);
|
||||
PreviousBuildItem = NULL;
|
||||
CurrentBuildItem = mPendingList;
|
||||
while (CurrentBuildItem != NULL) {
|
||||
NextBuildItem = CurrentBuildItem->Next;
|
||||
if (CheckDependency (CurrentBuildItem->DependencyList)) {
|
||||
//
|
||||
// Move the current build item from mPendingList
|
||||
//
|
||||
if (PreviousBuildItem != NULL) {
|
||||
PreviousBuildItem->Next = NextBuildItem;
|
||||
} else {
|
||||
mPendingList = NextBuildItem;
|
||||
}
|
||||
//
|
||||
// Add the current build item to the head of mWaitingList
|
||||
//
|
||||
CurrentBuildItem->Next = mWaitingList;
|
||||
mWaitingList = CurrentBuildItem;
|
||||
Count++;
|
||||
} else {
|
||||
PreviousBuildItem = CurrentBuildItem;
|
||||
}
|
||||
CurrentBuildItem = NextBuildItem;
|
||||
}
|
||||
LeaveCriticalSection (&mCriticalSection);
|
||||
|
||||
ReleaseSemaphore (mSemaphoreHandle, Count, NULL);
|
||||
if (mPendingList == NULL) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
// Wait until all threads have terminated
|
||||
//
|
||||
WaitForMultipleObjects (ThreadNumber, ThreadHandle, TRUE, INFINITE);
|
||||
|
||||
if (mError && (mBuildingList != NULL)) {
|
||||
//
|
||||
// Dump build failure log of the first build item which doesn't finish the build
|
||||
//
|
||||
printf ("\tnmake -nologo -f %s all\n", mBuildingList->Makefile);
|
||||
sprintf (Cmd, "type %s\\%s_%s_%d.txt 2>NUL", mLogDir, mBuildingList->BaseName,
|
||||
mBuildingList->Processor, mBuildingList->Index);
|
||||
_flushall ();
|
||||
if (system (Cmd)) {
|
||||
Error (NULL, 0, 0, NULL, "failed to run \"%s\"", Cmd);
|
||||
}
|
||||
}
|
||||
|
||||
DeleteCriticalSection (&mCriticalSection);
|
||||
for (Index = 0; Index < ThreadNumber; Index++) {
|
||||
CloseHandle (ThreadHandle[Index]);
|
||||
}
|
||||
free (ThreadHandle);
|
||||
CloseHandle (mSemaphoreHandle);
|
||||
CloseHandle (mEventHandle);
|
||||
RestoreBuildList (BuildList);
|
||||
|
||||
return mError;
|
||||
}
|
116
EdkCompatibilityPkg/Sample/Tools/Source/ProcessDsc/MultiThread.h
Normal file
116
EdkCompatibilityPkg/Sample/Tools/Source/ProcessDsc/MultiThread.h
Normal file
@@ -0,0 +1,116 @@
|
||||
/*++
|
||||
|
||||
Copyright (c) 2008 - 2010, 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.
|
||||
|
||||
Module Name:
|
||||
|
||||
MultiThread.h
|
||||
|
||||
Abstract:
|
||||
|
||||
Defines and function prototypes for the ProcessDsc utility.
|
||||
|
||||
--*/
|
||||
|
||||
#ifndef _MULTI_THREAD_H_
|
||||
#define _MULTI_THREAD_H_
|
||||
|
||||
typedef struct _COMPONENTS_ITEM COMPONENTS_ITEM;
|
||||
typedef struct _BUILD_ITEM BUILD_ITEM;
|
||||
typedef struct _SOURCE_FILE_ITEM SOURCE_FILE_ITEM;
|
||||
typedef struct _DEPENDENCY_ITEM DEPENDENCY_ITEM;
|
||||
|
||||
//
|
||||
// Use this structure to keep track of module build items
|
||||
//
|
||||
typedef struct _BUILD_ITEM {
|
||||
BUILD_ITEM *Next;
|
||||
INT8 *BaseName;
|
||||
INT8 *Processor;
|
||||
INT8 *Makefile;
|
||||
UINT32 Index;
|
||||
UINT32 CompleteFlag;
|
||||
SOURCE_FILE_ITEM *SourceFileList;
|
||||
DEPENDENCY_ITEM *DependencyList;
|
||||
} BUILD_ITEM;
|
||||
|
||||
//
|
||||
// Use this structure to keep track of module source files
|
||||
//
|
||||
typedef struct _SOURCE_FILE_ITEM {
|
||||
SOURCE_FILE_ITEM *Next;
|
||||
INT8 *FileName;
|
||||
} SOURCE_FILE_ITEM;
|
||||
|
||||
//
|
||||
// Use this structure to keep track of module build dependencies
|
||||
//
|
||||
typedef struct _DEPENDENCY_ITEM {
|
||||
DEPENDENCY_ITEM *Next;
|
||||
BUILD_ITEM *Dependency;
|
||||
} DEPENDENCY_ITEM;
|
||||
|
||||
//
|
||||
// Use this structure to keep track of [components] and [components.n] sections
|
||||
//
|
||||
typedef struct _COMPONENTS_ITEM {
|
||||
COMPONENTS_ITEM *Next;
|
||||
BUILD_ITEM *BuildList;
|
||||
} COMPONENTS_ITEM;
|
||||
|
||||
//
|
||||
// Function prototypes
|
||||
//
|
||||
BUILD_ITEM *
|
||||
AddBuildItem (
|
||||
BUILD_ITEM **BuildList,
|
||||
INT8 *BaseName,
|
||||
INT8 *Processor,
|
||||
INT8 *Makefile
|
||||
);
|
||||
|
||||
|
||||
SOURCE_FILE_ITEM *
|
||||
AddSourceFile (
|
||||
BUILD_ITEM *BuildItem,
|
||||
INT8 *FileName
|
||||
);
|
||||
|
||||
DEPENDENCY_ITEM *
|
||||
AddDependency (
|
||||
BUILD_ITEM *BuildList,
|
||||
BUILD_ITEM *BuildItem,
|
||||
INT8 *BaseName,
|
||||
INT8 AdjustIndex
|
||||
);
|
||||
|
||||
void
|
||||
FreeBuildList (
|
||||
BUILD_ITEM *BuildList
|
||||
);
|
||||
|
||||
COMPONENTS_ITEM *
|
||||
AddComponentsItem (
|
||||
COMPONENTS_ITEM **ComponentsList
|
||||
);
|
||||
|
||||
void
|
||||
FreeComponentsList (
|
||||
COMPONENTS_ITEM *ComponentsList
|
||||
);
|
||||
|
||||
INT8
|
||||
StartMultiThreadBuild (
|
||||
BUILD_ITEM **BuildList,
|
||||
UINT32 ThreadNumber,
|
||||
INT8 *BuildDir
|
||||
);
|
||||
|
||||
#endif // ifndef _MULTI_THREAD_H_
|
@@ -1,6 +1,6 @@
|
||||
/*++
|
||||
|
||||
Copyright (c) 2004 - 2007, Intel Corporation. All rights reserved.<BR>
|
||||
Copyright (c) 2004 - 2010, 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
|
||||
@@ -27,25 +27,18 @@ Abstract:
|
||||
#include <direct.h> // for _mkdir()
|
||||
#include <errno.h>
|
||||
#include <stdlib.h> // for getenv()
|
||||
#include <shlwapi.h> // for PathCanonicalize()
|
||||
#include "DSCFile.h"
|
||||
#include "MultiThread.h"
|
||||
#include "FWVolume.h"
|
||||
#include "Exceptions.h"
|
||||
#include "Common.h"
|
||||
|
||||
#include "EfiUtilityMsgs.h"
|
||||
#include "TianoBind.h"
|
||||
//
|
||||
// Disable warning for while(1) code
|
||||
//
|
||||
#pragma warning(disable : 4127)
|
||||
//
|
||||
// Disable warning for unreferenced function parameters
|
||||
//
|
||||
#pragma warning(disable : 4100)
|
||||
|
||||
extern int errno;
|
||||
|
||||
#define PROGRAM_NAME "ProcessDsc"
|
||||
#define UTILITY_NAME "ProcessDsc"
|
||||
#define UTILITY_VERSION "v1.0"
|
||||
|
||||
//
|
||||
// Common symbol name definitions. For example, the user can reference
|
||||
@@ -220,25 +213,39 @@ typedef struct _SYMBOL {
|
||||
} SYMBOL;
|
||||
|
||||
//
|
||||
// Define new SYMBOL list to record all module name used in the platform.dsc file.
|
||||
// Module globals for multi-thread build
|
||||
//
|
||||
SYMBOL *gModuleList = NULL;
|
||||
static BUILD_ITEM **mCurrentBuildList; // build list currently handling
|
||||
static BUILD_ITEM *mCurrentBuildItem; // build item currently handling
|
||||
|
||||
//
|
||||
// Define masks for the build targets
|
||||
//
|
||||
#define BUILD_TARGET_COMPONENTS 0x01
|
||||
#define BUILD_TARGET_LIBRARIES 0x02
|
||||
#define BUILD_TARGET_FVS 0x04
|
||||
#define BUILD_TARGET_ALL 0xff
|
||||
|
||||
|
||||
//
|
||||
// This structure is used to save globals
|
||||
//
|
||||
struct {
|
||||
INT8 *DscFilename;
|
||||
SYMBOL *Symbol;
|
||||
INT8 MakefileName[MAX_PATH]; // output makefile name
|
||||
INT8 XRefFileName[MAX_PATH];
|
||||
INT8 GuidDatabaseFileName[MAX_PATH];
|
||||
INT8 ModuleMakefileName[MAX_PATH];
|
||||
FILE *MakefileFptr;
|
||||
FILE *ModuleMakefileFptr;
|
||||
SYMBOL *ModuleList;
|
||||
SYMBOL *OutdirList;
|
||||
UINT32 Verbose;
|
||||
INT8 *DscFilename;
|
||||
SYMBOL *Symbol;
|
||||
INT8 MakefileName[MAX_PATH]; // output makefile name
|
||||
INT8 XRefFileName[MAX_PATH];
|
||||
INT8 GuidDatabaseFileName[MAX_PATH];
|
||||
INT8 ModuleMakefileName[MAX_PATH];
|
||||
FILE *MakefileFptr;
|
||||
FILE *ModuleMakefileFptr;
|
||||
SYMBOL *ModuleList;
|
||||
SYMBOL *OutdirList;
|
||||
UINT32 Verbose;
|
||||
UINT32 ThreadNumber;
|
||||
UINT32 BuildTarget;
|
||||
BUILD_ITEM *LibraryList;
|
||||
COMPONENTS_ITEM *ComponentsList;
|
||||
} gGlobals;
|
||||
|
||||
//
|
||||
@@ -584,16 +591,18 @@ Returns:
|
||||
|
||||
--*/
|
||||
{
|
||||
int i;
|
||||
DSC_FILE DSCFile;
|
||||
SECTION *Sect;
|
||||
INT8 Line[MAX_LINE_LEN];
|
||||
INT8 ExpLine[MAX_LINE_LEN];
|
||||
INT8 *EMsg;
|
||||
FILE *FpModule;
|
||||
SYMBOL *TempSymbol;
|
||||
int i;
|
||||
DSC_FILE DSCFile;
|
||||
SECTION *Sect;
|
||||
INT8 Line[MAX_LINE_LEN];
|
||||
INT8 ExpLine[MAX_LINE_LEN];
|
||||
INT8 *BuildDir;
|
||||
INT8 *EMsg;
|
||||
FILE *FpModule;
|
||||
SYMBOL *TempSymbol;
|
||||
COMPONENTS_ITEM *TempComponents;
|
||||
|
||||
SetUtilityName (PROGRAM_NAME);
|
||||
SetUtilityName (UTILITY_NAME);
|
||||
|
||||
InitExceptions ();
|
||||
|
||||
@@ -710,6 +719,7 @@ Returns:
|
||||
//
|
||||
Sect = DSCFileFindSection (&DSCFile, LIBRARIES_SECTION_NAME);
|
||||
if (Sect != NULL) {
|
||||
mCurrentBuildList = &gGlobals.LibraryList;
|
||||
ProcessSectionComponents (&DSCFile, DSC_SECTION_TYPE_LIBRARIES, 0);
|
||||
}
|
||||
|
||||
@@ -721,6 +731,7 @@ Returns:
|
||||
//
|
||||
Sect = DSCFileFindSection (&DSCFile, LIBRARIES_PLATFORM_SECTION_NAME);
|
||||
if (Sect != NULL) {
|
||||
mCurrentBuildList = &gGlobals.LibraryList;
|
||||
ProcessSectionComponents (&DSCFile, DSC_SECTION_TYPE_PLATFORM_LIBRARIES, 0);
|
||||
}
|
||||
|
||||
@@ -735,6 +746,8 @@ Returns:
|
||||
Sect = DSCFileFindSection (&DSCFile, COMPONENTS_SECTION_NAME);
|
||||
if (Sect != NULL) {
|
||||
fprintf (gGlobals.MakefileFptr, "components_0 : \n");
|
||||
TempComponents = AddComponentsItem (&gGlobals.ComponentsList);
|
||||
mCurrentBuildList = &TempComponents->BuildList;
|
||||
ProcessSectionComponents (&DSCFile, DSC_SECTION_TYPE_COMPONENTS, 0);
|
||||
fprintf (gGlobals.MakefileFptr, "\n");
|
||||
}
|
||||
@@ -754,6 +767,8 @@ Returns:
|
||||
Sect = DSCFileFindSection (&DSCFile, Line);
|
||||
if (Sect != NULL) {
|
||||
fprintf (gGlobals.MakefileFptr, "components_%d : \n", i);
|
||||
TempComponents = AddComponentsItem (&gGlobals.ComponentsList);
|
||||
mCurrentBuildList = &TempComponents->BuildList;
|
||||
ProcessSectionComponents (&DSCFile, DSC_SECTION_TYPE_COMPONENTS, i);
|
||||
fprintf (gGlobals.MakefileFptr, "\n");
|
||||
} else {
|
||||
@@ -807,12 +822,52 @@ ProcessingError:
|
||||
fclose (gGlobals.ModuleMakefileFptr);
|
||||
gGlobals.ModuleMakefileFptr = NULL;
|
||||
}
|
||||
|
||||
|
||||
//
|
||||
// Start multi-thread build if ThreadNumber is specified and no error status
|
||||
//
|
||||
if ((gGlobals.ThreadNumber != 0) && (GetUtilityStatus () < STATUS_ERROR)) {
|
||||
BuildDir = GetSymbolValue (BUILD_DIR);
|
||||
if (gGlobals.BuildTarget & BUILD_TARGET_LIBRARIES) {
|
||||
if (StartMultiThreadBuild (&gGlobals.LibraryList, gGlobals.ThreadNumber, BuildDir) != 0) {
|
||||
Error (NULL, 0, 0, NULL, "Multi-thread build libraries failure");
|
||||
goto Cleanup;
|
||||
}
|
||||
}
|
||||
i = 0;
|
||||
TempComponents = gGlobals.ComponentsList;
|
||||
while (TempComponents != NULL) {
|
||||
if (gGlobals.BuildTarget & BUILD_TARGET_COMPONENTS) {
|
||||
if (StartMultiThreadBuild (&TempComponents->BuildList, gGlobals.ThreadNumber, BuildDir) != 0) {
|
||||
Error (NULL, 0, 0, NULL, "Multi-thread build components %d failure", i);
|
||||
goto Cleanup;
|
||||
}
|
||||
}
|
||||
if (gGlobals.BuildTarget & BUILD_TARGET_FVS) {
|
||||
sprintf (ExpLine, "nmake -nologo -f %s fvs_%d", gGlobals.MakefileName, i);
|
||||
_flushall ();
|
||||
if (system (ExpLine)) {
|
||||
Error (NULL, 0, 0, NULL, "Build FVs for components %d failure", i);
|
||||
goto Cleanup;
|
||||
}
|
||||
}
|
||||
i++;
|
||||
TempComponents = TempComponents->Next;
|
||||
}
|
||||
}
|
||||
|
||||
Cleanup:
|
||||
//
|
||||
// Clean up
|
||||
//
|
||||
FreeBuildList (gGlobals.LibraryList);
|
||||
gGlobals.LibraryList = NULL;
|
||||
FreeComponentsList (gGlobals.ComponentsList);
|
||||
gGlobals.ComponentsList = NULL;
|
||||
FreeSymbols (gGlobals.ModuleList);
|
||||
gGlobals.ModuleList = NULL;
|
||||
FreeSymbols (gGlobals.OutdirList);
|
||||
gGlobals.OutdirList = NULL;
|
||||
FreeSymbols (gGlobals.Symbol);
|
||||
gGlobals.Symbol = NULL;
|
||||
CFVDestructor ();
|
||||
@@ -1311,6 +1366,16 @@ Returns:
|
||||
CreatePackageFile (DSCFile);
|
||||
}
|
||||
|
||||
//
|
||||
// Add a new build item to mCurrentBuildList
|
||||
//
|
||||
mCurrentBuildItem = AddBuildItem (mCurrentBuildList, GetSymbolValue (BASE_NAME), Processor, FileName);
|
||||
//
|
||||
// ProcessDsc allows duplicate base name libraries. Make sure the duplicate
|
||||
// base name libraries will be built in the same order as listed in DSC file.
|
||||
//
|
||||
AddDependency (*mCurrentBuildList, mCurrentBuildItem, mCurrentBuildItem->BaseName, 1);
|
||||
|
||||
//
|
||||
// Add Module name to the global module list
|
||||
//
|
||||
@@ -1336,6 +1401,7 @@ Returns:
|
||||
// files in this component. This macro can then be used elsewhere to
|
||||
// process all the files making up the component. Required for scanning
|
||||
// files for string localization.
|
||||
// Also add source files to mCurrentBuildItem.
|
||||
//
|
||||
ProcessSourceFiles (DSCFile, &ComponentFile, MakeFptr, SOURCE_MODE_SOURCE_FILES);
|
||||
//
|
||||
@@ -1370,7 +1436,8 @@ Returns:
|
||||
// Process all the libraries to define "LIBS = x.lib y.lib..."
|
||||
// Be generous and append ".lib" if they forgot.
|
||||
// Make a macro definition: LIBS = $(LIBS) xlib.lib ylib.lib...
|
||||
// Also add libs dependency for single module build: basenamebuild :: xlibbuild ylibbuild ...
|
||||
// Add libs dependency for single module build: basenamebuild :: xlibbuild ylibbuild ...
|
||||
// Also add libs dependency to mCurrentBuildItem.
|
||||
//
|
||||
ProcessLibs (&ComponentFile, MakeFptr);
|
||||
|
||||
@@ -1829,8 +1896,14 @@ Returns:
|
||||
OverridePath = GetSymbolValue (SOURCE_OVERRIDE_PATH);
|
||||
if (OverridePath != NULL) {
|
||||
ReplaceSlash (OverridePath);
|
||||
fprintf (MakeFptr, "!IF EXIST(%s)\n", OverridePath);
|
||||
fprintf (MakeFptr, "INC = $(INC) -I %s\n", OverridePath);
|
||||
fprintf (MakeFptr, "INC = $(INC) -I %s\\%s \n", OverridePath, Processor);
|
||||
fprintf (MakeFptr, "!IF EXIST(%s\\%s)\n", OverridePath, Processor);
|
||||
fprintf (MakeFptr, "INC = $(INC) -I %s\\%s\n", OverridePath, Processor);
|
||||
fprintf (MakeFptr, "!ENDIF\n");
|
||||
fprintf (MakeFptr, "!ELSE\n");
|
||||
fprintf (MakeFptr, "!MESSAGE Warning: include dir %s does not exist\n", OverridePath);
|
||||
fprintf (MakeFptr, "!ENDIF\n");
|
||||
}
|
||||
//
|
||||
// Try for an [includes.$(PROCESSOR).$(PLATFORM)]
|
||||
@@ -1909,43 +1982,45 @@ ProcessIncludesSectionSingle (
|
||||
//
|
||||
if (Cptr[1] == 0) {
|
||||
fprintf (MakeFptr, "INC = $(INC) -I $(SOURCE_DIR)\n");
|
||||
fprintf (
|
||||
MakeFptr,
|
||||
"INC = $(INC) -I $(SOURCE_DIR)\\%s \n",
|
||||
Processor
|
||||
);
|
||||
fprintf (MakeFptr, "!IF EXIST($(SOURCE_DIR)\\%s)\n", Processor);
|
||||
fprintf (MakeFptr, "INC = $(INC) -I $(SOURCE_DIR)\\%s\n", Processor);
|
||||
fprintf (MakeFptr, "!ENDIF\n");
|
||||
} else {
|
||||
//
|
||||
// Handle case of ".\path\path\path" or "..\path\path\path"
|
||||
//
|
||||
fprintf (
|
||||
MakeFptr,
|
||||
"INC = $(INC) -I $(SOURCE_DIR)\\%s \n",
|
||||
Cptr
|
||||
);
|
||||
fprintf (
|
||||
MakeFptr,
|
||||
"INC = $(INC) -I $(SOURCE_DIR)\\%s\\%s \n",
|
||||
Cptr,
|
||||
Processor
|
||||
);
|
||||
fprintf (MakeFptr, "!IF EXIST($(SOURCE_DIR)\\%s)\n", Cptr);
|
||||
fprintf (MakeFptr, "INC = $(INC) -I $(SOURCE_DIR)\\%s\n", Cptr);
|
||||
fprintf (MakeFptr, "!IF EXIST($(SOURCE_DIR)\\%s\\%s)\n", Cptr, Processor);
|
||||
fprintf (MakeFptr, "INC = $(INC) -I $(SOURCE_DIR)\\%s\\%s\n", Cptr, Processor);
|
||||
fprintf (MakeFptr, "!ENDIF\n");
|
||||
fprintf (MakeFptr, "!ELSE\n");
|
||||
fprintf (MakeFptr, "!MESSAGE Warning: include dir $(SOURCE_DIR)\\%s does not exist\n", Cptr);
|
||||
fprintf (MakeFptr, "!ENDIF\n");
|
||||
}
|
||||
} else if ((Cptr[1] != ':') && isalpha (*Cptr)) {
|
||||
fprintf (MakeFptr, "INC = $(INC) -I $(EFI_SOURCE)\\%s \n", Cptr);
|
||||
fprintf (
|
||||
MakeFptr,
|
||||
"INC = $(INC) -I $(EFI_SOURCE)\\%s\\%s \n",
|
||||
Cptr,
|
||||
Processor
|
||||
);
|
||||
fprintf (MakeFptr, "!IF EXIST($(EFI_SOURCE)\\%s)\n", Cptr);
|
||||
fprintf (MakeFptr, "INC = $(INC) -I $(EFI_SOURCE)\\%s\n", Cptr);
|
||||
fprintf (MakeFptr, "!IF EXIST($(EFI_SOURCE)\\%s\\%s)\n", Cptr, Processor);
|
||||
fprintf (MakeFptr, "INC = $(INC) -I $(EFI_SOURCE)\\%s\\%s\n", Cptr, Processor);
|
||||
fprintf (MakeFptr, "!ENDIF\n");
|
||||
fprintf (MakeFptr, "!ELSE\n");
|
||||
fprintf (MakeFptr, "!MESSAGE Warning: include dir $(EFI_SOURCE)\\%s does not exist\n", Cptr);
|
||||
fprintf (MakeFptr, "!ENDIF\n");
|
||||
} else {
|
||||
//
|
||||
// The line is something like: $(EFI_SOURCE)\dxe\include. Add it to
|
||||
// the existing $(INC) definition. Add user includes before any
|
||||
// other existing paths.
|
||||
//
|
||||
fprintf (MakeFptr, "INC = $(INC) -I %s \n", Cptr);
|
||||
fprintf (MakeFptr, "INC = $(INC) -I %s\\%s \n", Cptr, Processor);
|
||||
fprintf (MakeFptr, "!IF EXIST(%s)\n", Cptr);
|
||||
fprintf (MakeFptr, "INC = $(INC) -I %s\n", Cptr);
|
||||
fprintf (MakeFptr, "!IF EXIST(%s\\%s)\n", Cptr, Processor);
|
||||
fprintf (MakeFptr, "INC = $(INC) -I %s\\%s\n", Cptr, Processor);
|
||||
fprintf (MakeFptr, "!ENDIF\n");
|
||||
fprintf (MakeFptr, "!ELSE\n");
|
||||
fprintf (MakeFptr, "!MESSAGE Warning: include dir %s does not exist\n", Cptr);
|
||||
fprintf (MakeFptr, "!ENDIF\n");
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -2260,16 +2335,35 @@ ProcessSourceFilesSection (
|
||||
// SOURCE_FILES = $(SOURCE_FILES) c:\Path\ThisFile.c
|
||||
//
|
||||
fprintf (MakeFptr, "SOURCE_FILES = $(SOURCE_FILES) %s\n", TempFileName);
|
||||
//
|
||||
// Save the source absolute path
|
||||
//
|
||||
if (PathCanonicalize (FilePath, TempFileName)) {
|
||||
AddSourceFile (mCurrentBuildItem, FilePath);
|
||||
}
|
||||
} else if (IsAbsolutePath (FileName)) {
|
||||
//
|
||||
// For Absolute path, don't print $(SOURCE_FILE) directory.
|
||||
//
|
||||
fprintf (MakeFptr, "SOURCE_FILES = $(SOURCE_FILES) %s\n", FileName);
|
||||
//
|
||||
// Save the source absolute path
|
||||
//
|
||||
if (PathCanonicalize (FilePath, FileName)) {
|
||||
AddSourceFile (mCurrentBuildItem, FilePath);
|
||||
}
|
||||
} else {
|
||||
//
|
||||
// SOURCE_FILES = $(SOURCE_FILES) $(SOURCE_DIR)\ThisFile.c
|
||||
//
|
||||
fprintf (MakeFptr, "SOURCE_FILES = $(SOURCE_FILES) $(SOURCE_DIR)\\%s\n", FileName);
|
||||
//
|
||||
// Save the source absolute path
|
||||
//
|
||||
sprintf (Str, "%s\\%s", GetSymbolValue (SOURCE_DIR), FileName);
|
||||
if (PathCanonicalize (FilePath, Str)) {
|
||||
AddSourceFile (mCurrentBuildItem, FilePath);
|
||||
}
|
||||
}
|
||||
} else if (Mode & SOURCE_MODE_BUILD_COMMANDS) {
|
||||
//
|
||||
@@ -2612,6 +2706,10 @@ ProcessLibsSingle (
|
||||
Cptr[strlen (Cptr) - 4] = 0;
|
||||
fprintf (gGlobals.ModuleMakefileFptr, " %sbuild", Cptr);
|
||||
}
|
||||
//
|
||||
// Add libs dependency for mCurrentBuildItem
|
||||
//
|
||||
AddDependency (*mCurrentBuildList, mCurrentBuildItem, Cptr, 0);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -2767,8 +2865,9 @@ ProcessIncludeFilesSingle (
|
||||
if (Cptr >= TempFileName) {
|
||||
*Cptr = 0;
|
||||
}
|
||||
|
||||
fprintf (MakeFptr, "!IF EXIST(%s)\n", TempFileName);
|
||||
fprintf (MakeFptr, "INC = -I %s $(INC)\n", TempFileName);
|
||||
fprintf (MakeFptr, "!ENDIF\n");
|
||||
}
|
||||
}
|
||||
//
|
||||
@@ -4173,6 +4272,63 @@ Returns:
|
||||
}
|
||||
break;
|
||||
|
||||
//
|
||||
// Enable multi-thread build and specify the thread number
|
||||
//
|
||||
case 'n':
|
||||
case 'N':
|
||||
//
|
||||
// Skip to next arg
|
||||
//
|
||||
Argc--;
|
||||
Argv++;
|
||||
if (Argc == 0) {
|
||||
Argv--;
|
||||
Error (NULL, 0, 0, Argv[0], "missing input thread number with option");
|
||||
Usage ();
|
||||
return STATUS_ERROR;
|
||||
} else {
|
||||
gGlobals.ThreadNumber = atoi (Argv[0]);
|
||||
if (gGlobals.ThreadNumber == 0) {
|
||||
Argv--;
|
||||
Error (NULL, 0, 0, Argv[0], "input thread number should not be %s", Argv[1]);
|
||||
return STATUS_ERROR;
|
||||
} else if (gGlobals.ThreadNumber > MAXIMUM_WAIT_OBJECTS) {
|
||||
Argv--;
|
||||
Error (NULL, 0, 0, Argv[0], "input thread number should not greater than %d", MAXIMUM_WAIT_OBJECTS);
|
||||
return STATUS_ERROR;
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
//
|
||||
// Specify the multi-thread build target
|
||||
//
|
||||
case 't':
|
||||
case 'T':
|
||||
//
|
||||
// Skip to next arg
|
||||
//
|
||||
Argc--;
|
||||
Argv++;
|
||||
if (Argc == 0) {
|
||||
Argv--;
|
||||
Error (NULL, 0, 0, Argv[0], "missing input build target with option");
|
||||
Usage ();
|
||||
return STATUS_ERROR;
|
||||
} else if (_stricmp (Argv[0], "all") == 0) {
|
||||
gGlobals.BuildTarget |= BUILD_TARGET_ALL;
|
||||
} else if (_stricmp (Argv[0], "libraries") == 0) {
|
||||
gGlobals.BuildTarget |= BUILD_TARGET_LIBRARIES;
|
||||
} else if (_stricmp (Argv[0], "components") == 0) {
|
||||
gGlobals.BuildTarget |= BUILD_TARGET_COMPONENTS;
|
||||
} else {
|
||||
Argv--;
|
||||
Error (NULL, 0, 0, Argv[0], "input build target not supported");
|
||||
Usage ();
|
||||
}
|
||||
break;
|
||||
|
||||
case 'v':
|
||||
case 'V':
|
||||
gGlobals.Verbose = 1;
|
||||
@@ -4228,7 +4384,14 @@ Returns:
|
||||
if (FreeCwd) {
|
||||
free (Cptr);
|
||||
}
|
||||
|
||||
|
||||
//
|
||||
// Default build target is all
|
||||
//
|
||||
if (gGlobals.BuildTarget == 0) {
|
||||
gGlobals.BuildTarget = BUILD_TARGET_ALL;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -4426,18 +4589,29 @@ Usage (
|
||||
VOID
|
||||
)
|
||||
{
|
||||
int i;
|
||||
static const INT8 *Help[] = {
|
||||
"Usage: ProcessDsc {options} [Dsc Filename]",
|
||||
" Options:",
|
||||
" -d var=value to define symbol 'var' to 'value'",
|
||||
" -v for verbose mode",
|
||||
" -g filename to preparse GUID listing file",
|
||||
" -x filename to create a cross-reference file",
|
||||
int Index;
|
||||
const char *Str[] = {
|
||||
UTILITY_NAME" "UTILITY_VERSION" - Intel Process DSC File Utility",
|
||||
" Copyright (C), 2004 - 2008 Intel Corporation",
|
||||
|
||||
#if ( defined(UTILITY_BUILD) && defined(UTILITY_VENDOR) )
|
||||
" Built from "UTILITY_BUILD", project of "UTILITY_VENDOR,
|
||||
#endif
|
||||
"",
|
||||
"Usage:",
|
||||
" "UTILITY_NAME" [OPTION]... DSCFILE",
|
||||
"Options:",
|
||||
" -d var=value to define symbol 'var' to 'value'",
|
||||
" -v for verbose mode",
|
||||
" -g filename to preparse GUID listing file",
|
||||
" -x filename to create a cross-reference file",
|
||||
" -n threadnumber to build with multi-thread",
|
||||
" -t target to build the specified target:",
|
||||
" all, libraries or components",
|
||||
NULL
|
||||
};
|
||||
for (i = 0; Help[i] != NULL; i++) {
|
||||
fprintf (stdout, "%s\n", Help[i]);
|
||||
for (Index = 0; Str[Index] != NULL; Index++) {
|
||||
fprintf (stdout, "%s\n", Str[Index]);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -4562,7 +4736,7 @@ SmartOpen (
|
||||
if (SmartFile->FileContent != NULL) {
|
||||
memset (SmartFile->FileContent, 0, FileSize + 1);
|
||||
//
|
||||
// Usually FileLength < FileSize, because in text mode, carriage return-linefeed
|
||||
// Usually FileLength < FileSize, because in text mode, carriage return<EFBFBD>Clinefeed
|
||||
// combinations are translated into single linefeeds on input
|
||||
//
|
||||
SmartFile->FileLength = fread (SmartFile->FileContent, sizeof(char), FileSize, Fptr);
|
||||
|
@@ -1,6 +1,6 @@
|
||||
/*++
|
||||
|
||||
Copyright (c) 2004, Intel Corporation. All rights reserved.<BR>
|
||||
Copyright (c) 2004 - 2010, 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
|
||||
@@ -22,7 +22,8 @@ Abstract:
|
||||
#include <time.h>
|
||||
|
||||
#define LINE_MAXLEN 80
|
||||
|
||||
#define UTILITY_NAME "SetStamp"
|
||||
#define UTILITY_VERSION "v1.0"
|
||||
void
|
||||
PrintUsage (
|
||||
void
|
||||
@@ -38,10 +39,25 @@ Returns:
|
||||
None
|
||||
--*/
|
||||
{
|
||||
//
|
||||
// print usage of command
|
||||
//
|
||||
printf ("Usage: SetStamp <PE-File> <TIME-File>\n");
|
||||
int Index;
|
||||
const char *Str[] = {
|
||||
UTILITY_NAME" "UTILITY_VERSION" - Intel Set Time Stamp Utility",
|
||||
" Copyright (C), 2004 - 2008 Intel Corporation",
|
||||
|
||||
#if ( defined(UTILITY_BUILD) && defined(UTILITY_VENDOR) )
|
||||
" Built from "UTILITY_BUILD", project of "UTILITY_VENDOR,
|
||||
#endif
|
||||
"",
|
||||
"Usage:",
|
||||
" "UTILITY_NAME" PEFILE TIMEFILE",
|
||||
"Description:",
|
||||
" Set Date/Time Stamp of Portable Executable (PE) format file",
|
||||
NULL
|
||||
};
|
||||
for (Index = 0; Str[Index] != NULL; Index++) {
|
||||
fprintf (stdout, "%s\n", Str[Index]);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
int
|
||||
|
@@ -1,6 +1,6 @@
|
||||
/*++
|
||||
|
||||
Copyright (c) 2006, Intel Corporation. All rights reserved.<BR>
|
||||
Copyright (c) 2006 - 2010, 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
|
||||
@@ -21,6 +21,9 @@ Abstract:
|
||||
#include "string.h"
|
||||
#include "stdlib.h"
|
||||
|
||||
#define UTILITY_NAME "SplitFile"
|
||||
#define UTILITY_VERSION "v1.0"
|
||||
|
||||
void
|
||||
helpmsg (
|
||||
void
|
||||
@@ -40,11 +43,24 @@ Returns:
|
||||
|
||||
--*/
|
||||
{
|
||||
printf (
|
||||
"SplitFile Filename Offset\n"" Filename = Input file to split\n"" Offset = offset at which to split file\n"
|
||||
"\n\n""SplitFile will break a file in two pieces at the requested offset\n"
|
||||
" outputting Filename1 and Filename2\n"
|
||||
);
|
||||
int Index;
|
||||
const char *Str[] = {
|
||||
UTILITY_NAME" "UTILITY_VERSION" - Intel Split File Utility",
|
||||
" Copyright (C), 2006 - 2008 Intel Corporation",
|
||||
|
||||
#if ( defined(UTILITY_BUILD) && defined(UTILITY_VENDOR) )
|
||||
" Built from "UTILITY_BUILD", project of "UTILITY_VENDOR,
|
||||
#endif
|
||||
"",
|
||||
"Usage:",
|
||||
" "UTILITY_NAME" FILE OFFSET",
|
||||
"Description:",
|
||||
" Break the FILE in two pieces FILE1 and FILE2 at the requested OFFSET.",
|
||||
NULL
|
||||
};
|
||||
for (Index = 0; Str[Index] != NULL; Index++) {
|
||||
fprintf (stdout, "%s\n", Str[Index]);
|
||||
}
|
||||
}
|
||||
|
||||
int
|
||||
|
@@ -1,6 +1,6 @@
|
||||
/*++
|
||||
|
||||
Copyright (c) 2004 - 2007, Intel Corporation. All rights reserved.<BR>
|
||||
Copyright (c) 2004 - 2010, 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
|
||||
@@ -29,7 +29,8 @@ Abstract:
|
||||
#include "StrGather.h"
|
||||
#include "StringDB.h"
|
||||
|
||||
#define TOOL_VERSION "0.31"
|
||||
#define UTILITY_NAME "StrGather"
|
||||
#define UTILITY_VERSION "v1.0"
|
||||
|
||||
typedef UINT16 WCHAR;
|
||||
|
||||
@@ -281,11 +282,6 @@ ParseIndirectionFiles (
|
||||
TEXT_STRING_LIST *Files
|
||||
);
|
||||
|
||||
STATUS
|
||||
StringDBCreateHiiExportPack (
|
||||
INT8 *OutputFileName
|
||||
);
|
||||
|
||||
int
|
||||
main (
|
||||
int Argc,
|
||||
@@ -311,7 +307,7 @@ Returns:
|
||||
{
|
||||
STATUS Status;
|
||||
|
||||
SetUtilityName (PROGRAM_NAME);
|
||||
SetUtilityName (UTILITY_NAME);
|
||||
//
|
||||
// Process the command-line arguments
|
||||
//
|
||||
@@ -405,7 +401,7 @@ Returns:
|
||||
// Dump the string data as HII binary string pack if requested
|
||||
//
|
||||
if ((mGlobals.HiiExportPackFileName[0] != 0) && (GetUtilityStatus () < STATUS_ERROR)) {
|
||||
StringDBCreateHiiExportPack (mGlobals.HiiExportPackFileName);
|
||||
StringDBCreateHiiExportPack (mGlobals.HiiExportPackFileName, mGlobals.Language);
|
||||
}
|
||||
//
|
||||
// Always update the database if no errors and not in dump mode. If they specified -od
|
||||
@@ -1481,7 +1477,7 @@ FindFile (
|
||||
// Put the path and filename together
|
||||
//
|
||||
if (strlen (List->Str) + strlen (FileName) + 1 > FoundFileNameLen) {
|
||||
Error (PROGRAM_NAME, 0, 0, NULL, "internal error - cannot concatenate path+filename");
|
||||
Error (UTILITY_NAME, 0, 0, NULL, "internal error - cannot concatenate path+filename");
|
||||
return NULL;
|
||||
}
|
||||
//
|
||||
@@ -1581,7 +1577,7 @@ ProcessArgs (
|
||||
// check for one more arg
|
||||
//
|
||||
if ((Argc <= 1) || (Argv[1][0] == '-')) {
|
||||
Error (PROGRAM_NAME, 0, 0, Argv[0], "missing include path");
|
||||
Error (UTILITY_NAME, 0, 0, Argv[0], "missing include path");
|
||||
return STATUS_ERROR;
|
||||
}
|
||||
//
|
||||
@@ -1591,7 +1587,7 @@ ProcessArgs (
|
||||
//
|
||||
NewList = malloc (sizeof (TEXT_STRING_LIST));
|
||||
if (NewList == NULL) {
|
||||
Error (PROGRAM_NAME, 0, 0, NULL, "memory allocation failure");
|
||||
Error (UTILITY_NAME, 0, 0, NULL, "memory allocation failure");
|
||||
return STATUS_ERROR;
|
||||
}
|
||||
|
||||
@@ -1599,7 +1595,7 @@ ProcessArgs (
|
||||
NewList->Str = malloc (strlen (Argv[1]) + 2);
|
||||
if (NewList->Str == NULL) {
|
||||
free (NewList);
|
||||
Error (PROGRAM_NAME, 0, 0, NULL, "memory allocation failure");
|
||||
Error (UTILITY_NAME, 0, 0, NULL, "memory allocation failure");
|
||||
return STATUS_ERROR;
|
||||
}
|
||||
|
||||
@@ -1624,7 +1620,7 @@ ProcessArgs (
|
||||
// Indirection file -- check for one more arg
|
||||
//
|
||||
if ((Argc <= 1) || (Argv[1][0] == '-')) {
|
||||
Error (PROGRAM_NAME, 0, 0, Argv[0], "missing indirection file name");
|
||||
Error (UTILITY_NAME, 0, 0, Argv[0], "missing indirection file name");
|
||||
return STATUS_ERROR;
|
||||
}
|
||||
//
|
||||
@@ -1634,7 +1630,7 @@ ProcessArgs (
|
||||
//
|
||||
NewList = malloc (sizeof (TEXT_STRING_LIST));
|
||||
if (NewList == NULL) {
|
||||
Error (PROGRAM_NAME, 0, 0, NULL, "memory allocation failure");
|
||||
Error (UTILITY_NAME, 0, 0, NULL, "memory allocation failure");
|
||||
return STATUS_ERROR;
|
||||
}
|
||||
|
||||
@@ -1642,7 +1638,7 @@ ProcessArgs (
|
||||
NewList->Str = malloc (strlen (Argv[1]) + 1);
|
||||
if (NewList->Str == NULL) {
|
||||
free (NewList);
|
||||
Error (PROGRAM_NAME, 0, 0, NULL, "memory allocation failure");
|
||||
Error (UTILITY_NAME, 0, 0, NULL, "memory allocation failure");
|
||||
return STATUS_ERROR;
|
||||
}
|
||||
|
||||
@@ -1665,13 +1661,13 @@ ProcessArgs (
|
||||
// Check for one more arg (the database file name)
|
||||
//
|
||||
if ((Argc <= 1) || (Argv[1][0] == '-')) {
|
||||
Error (PROGRAM_NAME, 0, 0, Argv[0], "missing database file name");
|
||||
Error (UTILITY_NAME, 0, 0, Argv[0], "missing database file name");
|
||||
return STATUS_ERROR;
|
||||
}
|
||||
|
||||
NewList = malloc (sizeof (TEXT_STRING_LIST));
|
||||
if (NewList == NULL) {
|
||||
Error (PROGRAM_NAME, 0, 0, NULL, "memory allocation failure");
|
||||
Error (UTILITY_NAME, 0, 0, NULL, "memory allocation failure");
|
||||
return STATUS_ERROR;
|
||||
}
|
||||
|
||||
@@ -1679,7 +1675,7 @@ ProcessArgs (
|
||||
NewList->Str = malloc (strlen (Argv[1]) + 1);
|
||||
if (NewList->Str == NULL) {
|
||||
free (NewList);
|
||||
Error (PROGRAM_NAME, 0, 0, NULL, "memory allocation failure");
|
||||
Error (UTILITY_NAME, 0, 0, NULL, "memory allocation failure");
|
||||
return STATUS_ERROR;
|
||||
}
|
||||
|
||||
@@ -1702,14 +1698,14 @@ ProcessArgs (
|
||||
// which we can dump our database.
|
||||
//
|
||||
if ((Argc <= 1) || (Argv[1][0] == '-')) {
|
||||
Error (PROGRAM_NAME, 0, 0, Argv[0], "missing database dump output file name");
|
||||
Error (UTILITY_NAME, 0, 0, Argv[0], "missing database dump output file name");
|
||||
return STATUS_ERROR;
|
||||
}
|
||||
|
||||
if (mGlobals.DumpUFileName[0] == 0) {
|
||||
strcpy (mGlobals.DumpUFileName, Argv[1]);
|
||||
} else {
|
||||
Error (PROGRAM_NAME, 0, 0, Argv[1], "-ou option already specified with '%s'", mGlobals.DumpUFileName);
|
||||
Error (UTILITY_NAME, 0, 0, Argv[1], "-ou option already specified with '%s'", mGlobals.DumpUFileName);
|
||||
return STATUS_ERROR;
|
||||
}
|
||||
|
||||
@@ -1720,14 +1716,14 @@ ProcessArgs (
|
||||
// -hpk option to create an HII export pack of the input database file
|
||||
//
|
||||
if ((Argc <= 1) || (Argv[1][0] == '-')) {
|
||||
Error (PROGRAM_NAME, 0, 0, Argv[0], "missing raw string data dump output file name");
|
||||
Error (UTILITY_NAME, 0, 0, Argv[0], "missing raw string data dump output file name");
|
||||
return STATUS_ERROR;
|
||||
}
|
||||
|
||||
if (mGlobals.HiiExportPackFileName[0] == 0) {
|
||||
strcpy (mGlobals.HiiExportPackFileName, Argv[1]);
|
||||
} else {
|
||||
Error (PROGRAM_NAME, 0, 0, Argv[1], "-or option already specified with '%s'", mGlobals.HiiExportPackFileName);
|
||||
Error (UTILITY_NAME, 0, 0, Argv[1], "-or option already specified with '%s'", mGlobals.HiiExportPackFileName);
|
||||
return STATUS_ERROR;
|
||||
}
|
||||
|
||||
@@ -1751,7 +1747,7 @@ ProcessArgs (
|
||||
// check for one more arg
|
||||
//
|
||||
if ((Argc <= 1) || (Argv[1][0] == '-')) {
|
||||
Error (PROGRAM_NAME, 0, 0, Argv[0], "missing output C filename");
|
||||
Error (UTILITY_NAME, 0, 0, Argv[0], "missing output C filename");
|
||||
return STATUS_ERROR;
|
||||
}
|
||||
|
||||
@@ -1763,7 +1759,7 @@ ProcessArgs (
|
||||
// check for one more arg
|
||||
//
|
||||
if ((Argc <= 1) || (Argv[1][0] == '-')) {
|
||||
Error (PROGRAM_NAME, 0, 0, Argv[0], "missing base name");
|
||||
Error (UTILITY_NAME, 0, 0, Argv[0], "missing base name");
|
||||
Usage ();
|
||||
return STATUS_ERROR;
|
||||
}
|
||||
@@ -1776,7 +1772,7 @@ ProcessArgs (
|
||||
// -oh to specify output .h defines file name
|
||||
//
|
||||
if ((Argc <= 1) || (Argv[1][0] == '-')) {
|
||||
Error (PROGRAM_NAME, 0, 0, Argv[0], "missing output .h filename");
|
||||
Error (UTILITY_NAME, 0, 0, Argv[0], "missing output .h filename");
|
||||
return STATUS_ERROR;
|
||||
}
|
||||
|
||||
@@ -1788,7 +1784,7 @@ ProcessArgs (
|
||||
// -dep to specify output dependency file name
|
||||
//
|
||||
if ((Argc <= 1) || (Argv[1][0] == '-')) {
|
||||
Error (PROGRAM_NAME, 0, 0, Argv[0], "missing output dependency filename");
|
||||
Error (UTILITY_NAME, 0, 0, Argv[0], "missing output dependency filename");
|
||||
return STATUS_ERROR;
|
||||
}
|
||||
|
||||
@@ -1800,7 +1796,7 @@ ProcessArgs (
|
||||
// -skipext to skip scanning of files with certain filename extensions
|
||||
//
|
||||
if ((Argc <= 1) || (Argv[1][0] == '-')) {
|
||||
Error (PROGRAM_NAME, 0, 0, Argv[0], "missing filename extension");
|
||||
Error (UTILITY_NAME, 0, 0, Argv[0], "missing filename extension");
|
||||
return STATUS_ERROR;
|
||||
}
|
||||
//
|
||||
@@ -1810,7 +1806,7 @@ ProcessArgs (
|
||||
//
|
||||
NewList = malloc (sizeof (TEXT_STRING_LIST));
|
||||
if (NewList == NULL) {
|
||||
Error (PROGRAM_NAME, 0, 0, NULL, "memory allocation failure");
|
||||
Error (UTILITY_NAME, 0, 0, NULL, "memory allocation failure");
|
||||
return STATUS_ERROR;
|
||||
}
|
||||
|
||||
@@ -1818,7 +1814,7 @@ ProcessArgs (
|
||||
NewList->Str = malloc (strlen (Argv[1]) + 2);
|
||||
if (NewList->Str == NULL) {
|
||||
free (NewList);
|
||||
Error (PROGRAM_NAME, 0, 0, NULL, "memory allocation failure");
|
||||
Error (UTILITY_NAME, 0, 0, NULL, "memory allocation failure");
|
||||
return STATUS_ERROR;
|
||||
}
|
||||
|
||||
@@ -1845,7 +1841,7 @@ ProcessArgs (
|
||||
// "-lang eng" or "-lang spa+cat" to only output certain languages
|
||||
//
|
||||
if ((Argc <= 1) || (Argv[1][0] == '-')) {
|
||||
Error (PROGRAM_NAME, 0, 0, Argv[0], "missing language name");
|
||||
Error (UTILITY_NAME, 0, 0, Argv[0], "missing language name");
|
||||
Usage ();
|
||||
return STATUS_ERROR;
|
||||
}
|
||||
@@ -1861,7 +1857,7 @@ ProcessArgs (
|
||||
// Output database file name -- check for another arg
|
||||
//
|
||||
if ((Argc <= 1) || (Argv[1][0] == '-')) {
|
||||
Error (PROGRAM_NAME, 0, 0, Argv[0], "missing output database file name");
|
||||
Error (UTILITY_NAME, 0, 0, Argv[0], "missing output database file name");
|
||||
return STATUS_ERROR;
|
||||
}
|
||||
|
||||
@@ -1872,7 +1868,7 @@ ProcessArgs (
|
||||
//
|
||||
// Unrecognized arg
|
||||
//
|
||||
Error (PROGRAM_NAME, 0, 0, Argv[0], "unrecognized option");
|
||||
Error (UTILITY_NAME, 0, 0, Argv[0], "unrecognized option");
|
||||
Usage ();
|
||||
return STATUS_ERROR;
|
||||
}
|
||||
@@ -1919,7 +1915,7 @@ ProcessArgs (
|
||||
//
|
||||
if (mGlobals.Mode == MODE_SCAN) {
|
||||
if (Argc < 1) {
|
||||
Error (PROGRAM_NAME, 0, 0, NULL, "must specify at least one source file to scan with -scan");
|
||||
Error (UTILITY_NAME, 0, 0, NULL, "must specify at least one source file to scan with -scan");
|
||||
Usage ();
|
||||
return STATUS_ERROR;
|
||||
}
|
||||
@@ -1929,14 +1925,14 @@ ProcessArgs (
|
||||
while (Argc > 0) {
|
||||
NewList = malloc (sizeof (TEXT_STRING_LIST));
|
||||
if (NewList == NULL) {
|
||||
Error (PROGRAM_NAME, 0, 0, "memory allocation failure", NULL);
|
||||
Error (UTILITY_NAME, 0, 0, "memory allocation failure", NULL);
|
||||
return STATUS_ERROR;
|
||||
}
|
||||
|
||||
memset (NewList, 0, sizeof (TEXT_STRING_LIST));
|
||||
NewList->Str = (UINT8 *) malloc (strlen (Argv[0]) + 1);
|
||||
if (NewList->Str == NULL) {
|
||||
Error (PROGRAM_NAME, 0, 0, "memory allocation failure", NULL);
|
||||
Error (UTILITY_NAME, 0, 0, "memory allocation failure", NULL);
|
||||
return STATUS_ERROR;
|
||||
}
|
||||
|
||||
@@ -1956,7 +1952,7 @@ ProcessArgs (
|
||||
// Parse mode -- must specify an input unicode file name
|
||||
//
|
||||
if (Argc < 1) {
|
||||
Error (PROGRAM_NAME, 0, 0, NULL, "must specify input unicode string file name with -parse");
|
||||
Error (UTILITY_NAME, 0, 0, NULL, "must specify input unicode string file name with -parse");
|
||||
Usage ();
|
||||
return STATUS_ERROR;
|
||||
}
|
||||
@@ -1989,7 +1985,7 @@ AddCommandLineLanguage (
|
||||
//
|
||||
WNewList = MALLOC (sizeof (WCHAR_STRING_LIST));
|
||||
if (WNewList == NULL) {
|
||||
Error (PROGRAM_NAME, 0, 0, NULL, "memory allocation failure");
|
||||
Error (UTILITY_NAME, 0, 0, NULL, "memory allocation failure");
|
||||
return STATUS_ERROR;
|
||||
}
|
||||
|
||||
@@ -1997,7 +1993,7 @@ AddCommandLineLanguage (
|
||||
WNewList->Str = malloc ((strlen (Language) + 1) * sizeof (WCHAR));
|
||||
if (WNewList->Str == NULL) {
|
||||
free (WNewList);
|
||||
Error (PROGRAM_NAME, 0, 0, NULL, "memory allocation failure");
|
||||
Error (UTILITY_NAME, 0, 0, NULL, "memory allocation failure");
|
||||
return STATUS_ERROR;
|
||||
}
|
||||
//
|
||||
@@ -2024,7 +2020,7 @@ AddCommandLineLanguage (
|
||||
(From[LANGUAGE_IDENTIFIER_NAME_LEN] != L',')
|
||||
)
|
||||
) {
|
||||
Error (PROGRAM_NAME, 0, 0, Language, "invalid format for language name on command line");
|
||||
Error (UTILITY_NAME, 0, 0, Language, "invalid format for language name on command line");
|
||||
FREE (WNewList->Str);
|
||||
FREE (WNewList);
|
||||
return STATUS_ERROR;
|
||||
@@ -2523,48 +2519,56 @@ Returns:
|
||||
|
||||
--*/
|
||||
{
|
||||
int Index;
|
||||
static const char *Str[] = {
|
||||
int Index;
|
||||
const char *Str[] = {
|
||||
UTILITY_NAME" "UTILITY_VERSION" - Intel String Gather Utility",
|
||||
" Copyright (C), 2004 - 2008 Intel Corporation",
|
||||
|
||||
#if ( defined(UTILITY_BUILD) && defined(UTILITY_VENDOR) )
|
||||
" Built from "UTILITY_BUILD", project of "UTILITY_VENDOR,
|
||||
#endif
|
||||
"",
|
||||
PROGRAM_NAME " version "TOOL_VERSION " -- process unicode strings file",
|
||||
" Usage: "PROGRAM_NAME " -parse {parse options} [FileNames]",
|
||||
" "PROGRAM_NAME " -scan {scan options} [FileName]",
|
||||
" "PROGRAM_NAME " -dump {dump options}",
|
||||
" Common options include:",
|
||||
" -h or -? for this help information",
|
||||
" -db Database required name of output/input database file",
|
||||
" -bn BaseName for use in the .h and .c output files",
|
||||
" Default = "DEFAULT_BASE_NAME,
|
||||
" -v for verbose output",
|
||||
" -vdbw for verbose output when writing database",
|
||||
" -vdbr for verbose output when reading database",
|
||||
" -od FileName to specify an output database file name",
|
||||
" Parse options include:",
|
||||
" -i IncludePath add IncludePath to list of search paths",
|
||||
" -dep FileName to specify an output dependency file name",
|
||||
" -newdb to not read in existing database file",
|
||||
" -uqs to indicate that unquoted strings are used",
|
||||
" FileNames name of one or more unicode files to parse",
|
||||
" Scan options include:",
|
||||
" -scan scan text file(s) for STRING_TOKEN() usage",
|
||||
" -skipext .ext to skip scan of files with .ext filename extension",
|
||||
" -ignorenotfound ignore if a given STRING_TOKEN(STR) is not ",
|
||||
" found in the database",
|
||||
" FileNames one or more files to scan",
|
||||
" Dump options include:",
|
||||
" -oc FileName write string data to FileName",
|
||||
" -oh FileName write string defines to FileName",
|
||||
" -ou FileName dump database to unicode file FileName",
|
||||
" -lang Lang only dump for the language 'Lang'",
|
||||
" -if FileName to specify an indirection file",
|
||||
" -hpk FileName to create an HII export pack of the strings",
|
||||
"Usage:",
|
||||
" "UTILITY_NAME" -parse [OPTION] FILE",
|
||||
" "UTILITY_NAME" -scan [OPTION] FILE",
|
||||
" "UTILITY_NAME" -dump [OPTION]",
|
||||
"Description:",
|
||||
" Process unicode strings file.",
|
||||
"Common options include:",
|
||||
" -h or -? for this help information",
|
||||
" -db Database required name of output/input database file",
|
||||
" -bn BaseName for use in the .h and .c output files",
|
||||
" Default = "DEFAULT_BASE_NAME,
|
||||
" -v for verbose output",
|
||||
" -vdbw for verbose output when writing database",
|
||||
" -vdbr for verbose output when reading database",
|
||||
" -od FileName to specify an output database file name",
|
||||
"Parse options include:",
|
||||
" -i IncludePath add IncludePath to list of search paths",
|
||||
" -dep FileName to specify an output dependency file name",
|
||||
" -newdb to not read in existing database file",
|
||||
" -uqs to indicate that unquoted strings are used",
|
||||
" FileNames name of one or more unicode files to parse",
|
||||
"Scan options include:",
|
||||
" -scan scan text file(s) for STRING_TOKEN() usage",
|
||||
" -skipext .ext to skip scan of files with .ext filename extension",
|
||||
" -ignorenotfound ignore if a given STRING_TOKEN(STR) is not ",
|
||||
" found in the database",
|
||||
" FileNames one or more files to scan",
|
||||
"Dump options include:",
|
||||
" -oc FileName write string data to FileName",
|
||||
" -oh FileName write string defines to FileName",
|
||||
" -ou FileName dump database to unicode file FileName",
|
||||
" -lang Lang only dump for the language 'Lang'",
|
||||
" -if FileName to specify an indirection file",
|
||||
" -hpk FileName to create an HII export pack of the strings",
|
||||
"",
|
||||
" The expected process is to parse a unicode string file to create an initial",
|
||||
" database of string identifier names and string definitions. Then text files",
|
||||
" should be scanned for STRING_TOKEN() usages, and the referenced",
|
||||
" strings will be tagged as used in the database. After all files have been",
|
||||
" scanned, then the database should be dumped to create the necessary output",
|
||||
" files.",
|
||||
"The expected process is to parse a unicode string file to create an initial",
|
||||
"database of string identifier names and string definitions. Then text files",
|
||||
"should be scanned for STRING_TOKEN() usages, and the referenced",
|
||||
"strings will be tagged as used in the database. After all files have been",
|
||||
"scanned, then the database should be dumped to create the necessary output",
|
||||
"files.",
|
||||
"",
|
||||
NULL
|
||||
};
|
||||
|
@@ -1,6 +1,6 @@
|
||||
/*++
|
||||
|
||||
Copyright (c) 2004, Intel Corporation. All rights reserved.<BR>
|
||||
Copyright (c) 2004 - 2010, 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
|
||||
@@ -25,8 +25,6 @@ Abstract:
|
||||
#define MALLOC(size) malloc (size)
|
||||
#define FREE(ptr) free (ptr)
|
||||
|
||||
#define PROGRAM_NAME "StrGather"
|
||||
|
||||
typedef CHAR16 WCHAR;
|
||||
|
||||
#define UNICODE_TO_ASCII(w) (INT8) ((w) & 0xFF)
|
||||
|
@@ -1,6 +1,6 @@
|
||||
/*++
|
||||
|
||||
Copyright (c) 2004 - 2007, Intel Corporation. All rights reserved.<BR>
|
||||
Copyright (c) 2004 - 2010, 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
|
||||
@@ -2508,7 +2508,8 @@ Returns:
|
||||
--*/
|
||||
STATUS
|
||||
StringDBCreateHiiExportPack (
|
||||
INT8 *FileName
|
||||
INT8 *FileName,
|
||||
WCHAR_STRING_LIST *LanguagesOfInterest
|
||||
)
|
||||
{
|
||||
FILE *Fptr;
|
||||
@@ -2524,6 +2525,9 @@ StringDBCreateHiiExportPack (
|
||||
WCHAR *TempStringPtr;
|
||||
WCHAR *LangName;
|
||||
STRING_IDENTIFIER *StringIdentifier;
|
||||
WCHAR_STRING_LIST *LOIPtr;
|
||||
BOOLEAN LanguageOk;
|
||||
|
||||
|
||||
if ((Fptr = fopen (FileName, "wb")) == NULL) {
|
||||
Error (NULL, 0, 0, FileName, "failed to open output HII export file");
|
||||
@@ -2544,6 +2548,25 @@ StringDBCreateHiiExportPack (
|
||||
//
|
||||
ZeroString[0] = 0;
|
||||
for (Lang = mDBData.LanguageList; Lang != NULL; Lang = Lang->Next) {
|
||||
//
|
||||
// If we have a language list, then make sure this language is in that
|
||||
// list.
|
||||
//
|
||||
LanguageOk = TRUE;
|
||||
if (LanguagesOfInterest != NULL) {
|
||||
LanguageOk = FALSE;
|
||||
for (LOIPtr = LanguagesOfInterest; LOIPtr != NULL; LOIPtr = LOIPtr->Next) {
|
||||
if (wcsncmp (LOIPtr->Str, Lang->LanguageName, LANGUAGE_IDENTIFIER_NAME_LEN) == 0) {
|
||||
LanguageOk = TRUE;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (!LanguageOk) {
|
||||
continue;
|
||||
}
|
||||
|
||||
//
|
||||
// Process each string for this language. We have to make 3 passes on the strings:
|
||||
// Pass1: computes sizes and fill in the string pack header
|
||||
|
@@ -1,6 +1,6 @@
|
||||
/*++
|
||||
|
||||
Copyright (c) 2004, Intel Corporation. All rights reserved.<BR>
|
||||
Copyright (c) 2004 - 2010, 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
|
||||
@@ -28,11 +28,13 @@ Abstract:
|
||||
void
|
||||
StringDBConstructor (
|
||||
void
|
||||
);
|
||||
)
|
||||
;
|
||||
void
|
||||
StringDBDestructor (
|
||||
void
|
||||
);
|
||||
)
|
||||
;
|
||||
|
||||
STATUS
|
||||
StringDBAddString (
|
||||
@@ -42,12 +44,14 @@ StringDBAddString (
|
||||
WCHAR *String,
|
||||
BOOLEAN Format,
|
||||
UINT16 Flags
|
||||
);
|
||||
)
|
||||
;
|
||||
|
||||
STATUS
|
||||
StringDBSetScope (
|
||||
WCHAR *Scope
|
||||
);
|
||||
)
|
||||
;
|
||||
|
||||
#define STRING_FLAGS_REFERENCED 0x0001 // if referenced somewhere
|
||||
#define STRING_FLAGS_UNDEFINED 0x0002 // if we added it for padding purposes
|
||||
@@ -61,33 +65,38 @@ StringDBAddStringIdentifier (
|
||||
WCHAR *StringIdentifier,
|
||||
UINT16 *NewId,
|
||||
UINT16 Flags
|
||||
);
|
||||
)
|
||||
;
|
||||
|
||||
STATUS
|
||||
StringDBReadDatabase (
|
||||
INT8 *DBFileName,
|
||||
BOOLEAN IgnoreIfNotExist,
|
||||
BOOLEAN Verbose
|
||||
);
|
||||
)
|
||||
;
|
||||
|
||||
STATUS
|
||||
StringDBWriteDatabase (
|
||||
INT8 *DBFileName,
|
||||
BOOLEAN Verbose
|
||||
);
|
||||
)
|
||||
;
|
||||
|
||||
STATUS
|
||||
StringDBDumpDatabase (
|
||||
INT8 *DBFileName,
|
||||
INT8 *OutputFileName,
|
||||
BOOLEAN Verbose
|
||||
);
|
||||
)
|
||||
;
|
||||
|
||||
STATUS
|
||||
StringDBAddLanguage (
|
||||
WCHAR *LanguageName,
|
||||
WCHAR *PrintableLanguageName
|
||||
);
|
||||
)
|
||||
;
|
||||
|
||||
STATUS
|
||||
StringDBDumpCStrings (
|
||||
@@ -95,28 +104,40 @@ StringDBDumpCStrings (
|
||||
INT8 *BaseName,
|
||||
WCHAR_STRING_LIST *LanguagesOfInterest,
|
||||
WCHAR_MATCHING_STRING_LIST *IndirectionList
|
||||
);
|
||||
)
|
||||
;
|
||||
|
||||
STATUS
|
||||
StringDBDumpStringDefines (
|
||||
INT8 *FileName,
|
||||
INT8 *BaseName
|
||||
);
|
||||
)
|
||||
;
|
||||
|
||||
STATUS
|
||||
StringDBSetCurrentLanguage (
|
||||
WCHAR *LanguageName
|
||||
);
|
||||
)
|
||||
;
|
||||
|
||||
STATUS
|
||||
StringDBSetStringReferenced (
|
||||
INT8 *StringIdentifierName,
|
||||
BOOLEAN IgnoreNotFound
|
||||
);
|
||||
)
|
||||
;
|
||||
|
||||
void
|
||||
StringDBFormatString (
|
||||
WCHAR *String
|
||||
)
|
||||
;
|
||||
|
||||
STATUS
|
||||
StringDBCreateHiiExportPack (
|
||||
INT8 *OutputFileName,
|
||||
WCHAR_STRING_LIST *LanguagesOfInterest
|
||||
);
|
||||
|
||||
|
||||
#endif // #ifndef _STRING_DB_H_
|
||||
|
@@ -1,6 +1,6 @@
|
||||
/*++
|
||||
|
||||
Copyright (c) 2006, Intel Corporation. All rights reserved.<BR>
|
||||
Copyright (c) 2006 - 2010, 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
|
||||
@@ -24,6 +24,50 @@ Abstract:
|
||||
#include <string.h>
|
||||
#include <malloc.h>
|
||||
|
||||
#define UTILITY_NAME "Strip"
|
||||
#define UTILITY_VERSION "v1.0"
|
||||
|
||||
static
|
||||
void
|
||||
Usage (
|
||||
)
|
||||
/*++
|
||||
|
||||
Routine Description:
|
||||
|
||||
Print usage information for this utility.
|
||||
|
||||
Arguments:
|
||||
|
||||
None.
|
||||
|
||||
Returns:
|
||||
|
||||
Nothing.
|
||||
|
||||
--*/
|
||||
{
|
||||
int Index;
|
||||
const char *Str[] = {
|
||||
UTILITY_NAME" "UTILITY_VERSION" - Intel Strip Utility",
|
||||
" Copyright (C), 2006 - 2008 Intel Corporation",
|
||||
|
||||
#if ( defined(UTILITY_BUILD) && defined(UTILITY_VENDOR) )
|
||||
" Built from "UTILITY_BUILD", project of "UTILITY_VENDOR,
|
||||
#endif
|
||||
"",
|
||||
"Usage:",
|
||||
" "UTILITY_NAME" SOURCE DEST",
|
||||
"Description:",
|
||||
" Convert executable files to binary files.",
|
||||
NULL
|
||||
};
|
||||
|
||||
for (Index = 0; Str[Index] != NULL; Index++) {
|
||||
fprintf (stdout, "%s\n", Str[Index]);
|
||||
}
|
||||
}
|
||||
|
||||
int
|
||||
main (
|
||||
int argc,
|
||||
@@ -55,7 +99,7 @@ Returns:
|
||||
char *Ptrx;
|
||||
|
||||
if (argc < 3) {
|
||||
printf ("Need more args, such as file name to convert and output name\n");
|
||||
Usage ();
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
740
EdkCompatibilityPkg/Sample/Tools/Source/UefiHiiPack/HiiPack.c
Normal file
740
EdkCompatibilityPkg/Sample/Tools/Source/UefiHiiPack/HiiPack.c
Normal file
@@ -0,0 +1,740 @@
|
||||
/*++
|
||||
|
||||
Copyright (c) 2008 - 2010, 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.
|
||||
|
||||
Module Name:
|
||||
|
||||
HiiPack.c
|
||||
|
||||
Abstract:
|
||||
|
||||
Process HII package files to generate HII package list binary file or PE/COFF
|
||||
resource script file (i.e. .rc file).
|
||||
|
||||
--*/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
|
||||
#include "Tiano.h"
|
||||
#include "EfiHii.h"
|
||||
|
||||
#include "EfiUtilityMsgs.h"
|
||||
#include "ParseInf.h"
|
||||
|
||||
#define UTILITY_VERSION "v1.0"
|
||||
#define UTILITY_NAME "HiiPack"
|
||||
#define MAX_PATH 260
|
||||
|
||||
//
|
||||
// Define HII resource section type and name
|
||||
//
|
||||
#define HII_RESOURCE_TYPE "HII"
|
||||
#define HII_RESOURCE_NAME 1
|
||||
|
||||
//
|
||||
// We'll store lists of file names from the command line in
|
||||
// a linked list of these
|
||||
//
|
||||
typedef struct _FILE_NAME_LIST {
|
||||
struct _FILE_NAME_LIST *Next;
|
||||
UINT8 FileName[MAX_PATH];
|
||||
UINT32 PackageType;
|
||||
UINT32 Length;
|
||||
UINT8 *Data;
|
||||
} FILE_NAME_LIST;
|
||||
|
||||
//
|
||||
// Create some defines for the different operation modes supported by this utility
|
||||
//
|
||||
#define MODE_CREATE_HII_RESOURCE_FILE 0x0001
|
||||
#define MODE_CREATE_HII_PACKAGE_LIST 0x0002
|
||||
|
||||
//
|
||||
// Here's all our globals.
|
||||
//
|
||||
static struct {
|
||||
FILE_NAME_LIST *PackageFile; // all include paths to search
|
||||
FILE_NAME_LIST *LastPackageFile;
|
||||
UINT8 PackageListFileName[MAX_PATH]; // Output package list file name
|
||||
UINT8 ResourceFileName[MAX_PATH]; // Output HII resource file name
|
||||
EFI_GUID Guid; // Guid specified on command line
|
||||
BOOLEAN GuidSpecified;
|
||||
BOOLEAN Verbose;
|
||||
UINT32 Mode; // Mode this utility is operating in
|
||||
} mGlobals;
|
||||
|
||||
static
|
||||
void
|
||||
Usage (
|
||||
VOID
|
||||
);
|
||||
|
||||
static
|
||||
STATUS
|
||||
ProcessArgs (
|
||||
int Argc,
|
||||
char *Argv[]
|
||||
);
|
||||
|
||||
static
|
||||
void
|
||||
FreeGlobals (
|
||||
VOID
|
||||
);
|
||||
|
||||
static
|
||||
void
|
||||
DumpRawBytes (
|
||||
FILE *OutFptr,
|
||||
UINT8 *Buffer,
|
||||
int Count,
|
||||
int Indent
|
||||
);
|
||||
|
||||
static
|
||||
STATUS
|
||||
CreateResourceScript (
|
||||
char *OutputFileName,
|
||||
EFI_GUID *PackageListGuid,
|
||||
FILE_NAME_LIST *PackageFiles
|
||||
);
|
||||
|
||||
static
|
||||
STATUS
|
||||
CreatePackageList (
|
||||
char *OutputFileName,
|
||||
EFI_GUID *PackageListGuid,
|
||||
FILE_NAME_LIST *PackageFiles
|
||||
);
|
||||
|
||||
int
|
||||
main (
|
||||
int Argc,
|
||||
char *Argv[]
|
||||
)
|
||||
/*++
|
||||
|
||||
Routine Description:
|
||||
|
||||
Call the routine to parse the command-line options, then process the file.
|
||||
|
||||
Arguments:
|
||||
|
||||
Standard C main() argc and argv.
|
||||
|
||||
Returns:
|
||||
|
||||
0 if successful
|
||||
nonzero otherwise
|
||||
|
||||
--*/
|
||||
{
|
||||
STATUS Status;
|
||||
|
||||
//
|
||||
// Set the utility name for error reporting purposes
|
||||
//
|
||||
SetUtilityName (UTILITY_NAME);
|
||||
|
||||
//
|
||||
// Process the command-line arguments
|
||||
//
|
||||
Status = ProcessArgs (Argc, Argv);
|
||||
if (Status != STATUS_SUCCESS) {
|
||||
return Status;
|
||||
}
|
||||
|
||||
//
|
||||
// Switch based on args
|
||||
//
|
||||
if (mGlobals.Mode & MODE_CREATE_HII_RESOURCE_FILE) {
|
||||
CreateResourceScript (mGlobals.ResourceFileName, &mGlobals.Guid, mGlobals.PackageFile);
|
||||
}
|
||||
|
||||
if (mGlobals.Mode & MODE_CREATE_HII_PACKAGE_LIST) {
|
||||
CreatePackageList (mGlobals.PackageListFileName, &mGlobals.Guid, mGlobals.PackageFile);
|
||||
}
|
||||
|
||||
FreeGlobals ();
|
||||
|
||||
return GetUtilityStatus ();
|
||||
}
|
||||
|
||||
/******************************************************************************/
|
||||
static const char *gRcFileHeader[] = {
|
||||
"//",
|
||||
"// DO NOT EDIT -- auto-generated file",
|
||||
"//",
|
||||
"// This file is generated by the hiipack utility",
|
||||
"//",
|
||||
NULL
|
||||
};
|
||||
|
||||
static
|
||||
STATUS
|
||||
CreateResourceScript (
|
||||
char *OutputFileName,
|
||||
EFI_GUID *PackageListGuid,
|
||||
FILE_NAME_LIST *PackageFiles
|
||||
)
|
||||
/*++
|
||||
|
||||
Routine Description:
|
||||
|
||||
Given a linked list of HII package files, walk the list to
|
||||
process them and create a single HII resource script file.
|
||||
|
||||
Arguments:
|
||||
|
||||
OutputFileName - name of output HII resource script file to create
|
||||
PackageListGuid - the specified package list GUID
|
||||
PackageFiles - linked list of HII package files to process
|
||||
|
||||
Returns:
|
||||
|
||||
STATUS_SUCCESS - if successful
|
||||
STATUS_ERROR - otherwise
|
||||
|
||||
--*/
|
||||
{
|
||||
STATUS Status;
|
||||
UINT8 *PackageList;
|
||||
UINT8 *Buffer;
|
||||
UINT32 PackageListLen;
|
||||
FILE *OutFptr;
|
||||
UINTN Index;
|
||||
FILE_NAME_LIST *Package;
|
||||
|
||||
//
|
||||
// If no input HII pack files, then why are we here? Should have been caught when
|
||||
// args were processed though.
|
||||
//
|
||||
if (PackageFiles == NULL) {
|
||||
Error (NULL, 0, 0, "no input package file(s) specified", NULL);
|
||||
return STATUS_ERROR;
|
||||
}
|
||||
|
||||
OutFptr = NULL;
|
||||
Status = STATUS_ERROR;
|
||||
|
||||
//
|
||||
// Open the output file for writing
|
||||
//
|
||||
if ((OutFptr = fopen (OutputFileName, "w")) == NULL) {
|
||||
Error (NULL, 0, 0, OutputFileName, "failed to open output file for writing");
|
||||
goto Done;
|
||||
}
|
||||
|
||||
//
|
||||
// Write file header
|
||||
//
|
||||
for (Index = 0; gRcFileHeader[Index] != NULL; Index++) {
|
||||
fprintf (OutFptr, "%s\n", gRcFileHeader[Index]);
|
||||
}
|
||||
|
||||
//
|
||||
// Write nameID and typeID
|
||||
//
|
||||
fprintf (OutFptr, "\n");
|
||||
fprintf (OutFptr, "%d %s\n", HII_RESOURCE_NAME, HII_RESOURCE_TYPE);
|
||||
fprintf (OutFptr, "{\n");
|
||||
|
||||
//
|
||||
// Prepare package list
|
||||
//
|
||||
PackageListLen = sizeof (EFI_HII_PACKAGE_LIST_HEADER);
|
||||
Package = PackageFiles;
|
||||
while (Package != NULL) {
|
||||
PackageListLen += Package->Length;
|
||||
Package = Package->Next;
|
||||
}
|
||||
//
|
||||
// Inlucde the length of EFI_HII_PACKAGE_END
|
||||
//
|
||||
PackageListLen += sizeof (EFI_HII_PACKAGE_HEADER);
|
||||
|
||||
Buffer = (UINT8 *) malloc (PackageListLen);
|
||||
if (Buffer == NULL) {
|
||||
Error (NULL, 0, 0, "memory allocation failure", NULL);
|
||||
goto Done;
|
||||
}
|
||||
PackageList = Buffer;
|
||||
|
||||
memcpy (Buffer, PackageListGuid, sizeof (EFI_GUID));
|
||||
Buffer += sizeof (EFI_GUID);
|
||||
memcpy (Buffer, &PackageListLen, sizeof (UINT32));
|
||||
Buffer += sizeof (UINT32);
|
||||
|
||||
Package = PackageFiles;
|
||||
while (Package != NULL) {
|
||||
memcpy (Buffer, Package->Data, Package->Length);
|
||||
Buffer += Package->Length;
|
||||
Package = Package->Next;
|
||||
}
|
||||
//
|
||||
// Append EFI_HII_PACKAGE_END
|
||||
//
|
||||
((EFI_HII_PACKAGE_HEADER *) Buffer)->Type = EFI_HII_PACKAGE_END;
|
||||
((EFI_HII_PACKAGE_HEADER *) Buffer)->Length = sizeof (EFI_HII_PACKAGE_HEADER);
|
||||
|
||||
//
|
||||
// Dump package list
|
||||
//
|
||||
DumpRawBytes (OutFptr, PackageList, PackageListLen, 2);
|
||||
|
||||
//
|
||||
// Write file tail
|
||||
//
|
||||
fprintf (OutFptr, "}\n");
|
||||
|
||||
Status = STATUS_SUCCESS;
|
||||
|
||||
Done:
|
||||
if (OutFptr != NULL) {
|
||||
fclose (OutFptr);
|
||||
}
|
||||
|
||||
return Status;
|
||||
}
|
||||
|
||||
static
|
||||
STATUS
|
||||
CreatePackageList (
|
||||
char *OutputFileName,
|
||||
EFI_GUID *PackageListGuid,
|
||||
FILE_NAME_LIST *PackageFiles
|
||||
)
|
||||
/*++
|
||||
|
||||
Routine Description:
|
||||
|
||||
Given a linked list of HII package files, walk the list to
|
||||
process them and create a binary HII package list file.
|
||||
|
||||
Arguments:
|
||||
|
||||
OutputFileName - name of output HII package list file to create
|
||||
PackageListGuid - the specified package list GUID
|
||||
PackageFiles - linked list of HII package files to process
|
||||
|
||||
Returns:
|
||||
|
||||
STATUS_SUCCESS - if successful
|
||||
STATUS_ERROR - otherwise
|
||||
|
||||
--*/
|
||||
{
|
||||
FILE *OutFptr;
|
||||
UINT32 PackageListLen;
|
||||
FILE_NAME_LIST *Package;
|
||||
|
||||
if (OutputFileName == NULL || PackageListGuid == NULL || PackageFiles == NULL) {
|
||||
return STATUS_ERROR;
|
||||
}
|
||||
|
||||
//
|
||||
// Open the output file for writing
|
||||
//
|
||||
if ((OutFptr = fopen (OutputFileName, "wb")) == NULL) {
|
||||
Error (NULL, 0, 0, OutputFileName, "failed to open output file for writing");
|
||||
goto Done;
|
||||
}
|
||||
|
||||
//
|
||||
// Write package list header
|
||||
//
|
||||
PackageListLen = sizeof (EFI_HII_PACKAGE_LIST_HEADER);
|
||||
Package = PackageFiles;
|
||||
while (Package != NULL) {
|
||||
PackageListLen += Package->Length;
|
||||
Package = Package->Next;
|
||||
}
|
||||
fwrite (PackageListGuid, sizeof (UINT8), sizeof (EFI_GUID), OutFptr);
|
||||
fwrite (&PackageListLen, sizeof (UINT8), sizeof (UINT32), OutFptr);
|
||||
|
||||
//
|
||||
// Write packages
|
||||
//
|
||||
Package = PackageFiles;
|
||||
while (Package != NULL) {
|
||||
fwrite (Package->Data, sizeof (UINT8), Package->Length, OutFptr);
|
||||
Package = Package->Next;
|
||||
}
|
||||
|
||||
Done:
|
||||
if (OutFptr != NULL) {
|
||||
fclose (OutFptr);
|
||||
}
|
||||
|
||||
return STATUS_SUCCESS;
|
||||
}
|
||||
|
||||
static
|
||||
void
|
||||
FreeGlobals (
|
||||
VOID
|
||||
)
|
||||
/*++
|
||||
|
||||
Routine Description:
|
||||
|
||||
Free up an memory we allocated so we can exit cleanly
|
||||
|
||||
Arguments:
|
||||
|
||||
Returns: NA
|
||||
|
||||
--*/
|
||||
{
|
||||
FILE_NAME_LIST *Next;
|
||||
|
||||
//
|
||||
// Free up input package file names
|
||||
//
|
||||
while (mGlobals.PackageFile != NULL) {
|
||||
Next = mGlobals.PackageFile->Next;
|
||||
if (mGlobals.PackageFile->Data != NULL) {
|
||||
free (mGlobals.PackageFile->Data);
|
||||
}
|
||||
free (mGlobals.PackageFile);
|
||||
mGlobals.PackageFile = Next;
|
||||
}
|
||||
}
|
||||
|
||||
static
|
||||
void
|
||||
DumpRawBytes (
|
||||
FILE *OutFptr,
|
||||
UINT8 *Buffer,
|
||||
int Count,
|
||||
int Indent
|
||||
)
|
||||
/*++
|
||||
|
||||
Routine Description:
|
||||
|
||||
Dump buffer data into output file.
|
||||
|
||||
Arguments:
|
||||
|
||||
OutFptr - FILE pointer to output file.
|
||||
Buffer - the buffer to dump
|
||||
Count - number of bytes to dump
|
||||
Indent - indent at each line start
|
||||
|
||||
Returns:
|
||||
|
||||
Nothing.
|
||||
|
||||
--*/
|
||||
{
|
||||
int Counter;
|
||||
int Count2;
|
||||
UINT16 *Ptr16;
|
||||
|
||||
Ptr16 = (UINT16 *) Buffer;
|
||||
Count2 = Count - (Count & 0x1);
|
||||
|
||||
for (Counter = 0; Counter < Count2; Counter += 2) {
|
||||
if ((Counter & 0xF) == 0) {
|
||||
if (Counter == 0) {
|
||||
fprintf (OutFptr, "%*c", Indent, ' ');
|
||||
} else {
|
||||
fprintf (OutFptr, "\n%*c", Indent, ' ');
|
||||
}
|
||||
}
|
||||
|
||||
fprintf (OutFptr, "0x%04X, ", (unsigned int) *Ptr16);
|
||||
Ptr16++;
|
||||
}
|
||||
|
||||
//
|
||||
// Handle the last byte
|
||||
//
|
||||
if ((Count & 0x1) != 0) {
|
||||
if ((Counter & 0xF) == 0) {
|
||||
if (Counter == 0) {
|
||||
fprintf (OutFptr, "%*c", Indent, ' ');
|
||||
} else {
|
||||
fprintf (OutFptr, "\n%*c", Indent, ' ');
|
||||
}
|
||||
}
|
||||
|
||||
fprintf (OutFptr, "0x%04X, ", (unsigned int) (*Ptr16 & 0xff));
|
||||
}
|
||||
|
||||
fprintf (OutFptr, "\n");
|
||||
}
|
||||
|
||||
static
|
||||
STATUS
|
||||
LoadPackage (
|
||||
FILE_NAME_LIST *NameList
|
||||
)
|
||||
/*++
|
||||
|
||||
Routine Description:
|
||||
|
||||
Process the command line arguments
|
||||
|
||||
Arguments:
|
||||
|
||||
NameList - the FILE_NAME_LIST linked list node
|
||||
|
||||
Returns:
|
||||
|
||||
STATUS_SUCCESS - if successful
|
||||
STATUS_ERROR - otherwise
|
||||
|
||||
--*/
|
||||
{
|
||||
STATUS Status;
|
||||
FILE *InFptr;
|
||||
UINT32 BufferSize;
|
||||
UINT8 *Buffer;
|
||||
EFI_HII_PACKAGE_HEADER *PackageHeader;
|
||||
EFI_IFR_FORM_SET *FormSet;
|
||||
|
||||
Status = STATUS_SUCCESS;
|
||||
if (NameList == NULL) {
|
||||
return STATUS_ERROR;
|
||||
}
|
||||
|
||||
//
|
||||
// Try to open the package file
|
||||
//
|
||||
if ((InFptr = fopen (NameList->FileName, "rb")) == NULL) {
|
||||
Error (NULL, 0, 0, NameList->FileName, "failed to open input file for read");
|
||||
return STATUS_ERROR;
|
||||
}
|
||||
|
||||
//
|
||||
// Get the file size, then allocate a buffer and read in the file contents.
|
||||
//
|
||||
fseek (InFptr, 0, SEEK_END);
|
||||
BufferSize = (UINT32) ftell (InFptr);
|
||||
fseek (InFptr, 0, SEEK_SET);
|
||||
Buffer = (UINT8 *) malloc (BufferSize);
|
||||
if (Buffer == NULL) {
|
||||
Error (NULL, 0, 0, "memory allocation failure", NULL);
|
||||
goto Done;
|
||||
}
|
||||
|
||||
if (fread (Buffer, sizeof (UINT8), BufferSize, InFptr) != BufferSize) {
|
||||
Error (NULL, 0, 0, NameList->FileName, "error reading file contents");
|
||||
Status = STATUS_ERROR;
|
||||
goto Done;
|
||||
}
|
||||
|
||||
NameList->Length = BufferSize;
|
||||
NameList->Data = Buffer;
|
||||
|
||||
PackageHeader = (EFI_HII_PACKAGE_HEADER *) Buffer;
|
||||
NameList->PackageType = PackageHeader->Type;
|
||||
|
||||
if (!mGlobals.GuidSpecified && NameList->PackageType == EFI_HII_PACKAGE_FORMS) {
|
||||
FormSet = (EFI_IFR_FORM_SET *) (Buffer + sizeof (EFI_HII_PACKAGE_HEADER));
|
||||
memcpy (&mGlobals.Guid, &FormSet->Guid, sizeof (EFI_GUID));
|
||||
mGlobals.GuidSpecified = TRUE;
|
||||
}
|
||||
|
||||
Done:
|
||||
fclose (InFptr);
|
||||
|
||||
return Status;
|
||||
}
|
||||
|
||||
|
||||
static
|
||||
STATUS
|
||||
ProcessArgs (
|
||||
int Argc,
|
||||
char *Argv[]
|
||||
)
|
||||
/*++
|
||||
|
||||
Routine Description:
|
||||
|
||||
Process the command line arguments
|
||||
|
||||
Arguments:
|
||||
|
||||
As per standard C main()
|
||||
|
||||
Returns:
|
||||
|
||||
STATUS_SUCCESS - if successful
|
||||
STATUS_ERROR - otherwise
|
||||
|
||||
--*/
|
||||
{
|
||||
FILE_NAME_LIST *NewList;
|
||||
STATUS Status;
|
||||
|
||||
Status = STATUS_SUCCESS;
|
||||
memset ((void *) &mGlobals, 0, sizeof (mGlobals));
|
||||
|
||||
//
|
||||
// Skip program name
|
||||
//
|
||||
Argc--;
|
||||
Argv++;
|
||||
|
||||
if (Argc == 0) {
|
||||
Usage ();
|
||||
return STATUS_ERROR;
|
||||
}
|
||||
|
||||
if (_stricmp (Argv[0], "-h") == 0 || _stricmp (Argv[0], "-?") == 0) {
|
||||
Usage ();
|
||||
return STATUS_ERROR;
|
||||
}
|
||||
|
||||
//
|
||||
// Process until no more args.
|
||||
//
|
||||
while (Argc > 0) {
|
||||
if (_stricmp (Argv[0], "-rc") == 0) {
|
||||
Argc--;
|
||||
Argv++;
|
||||
|
||||
if (Argc == 0) {
|
||||
Error (UTILITY_NAME, 0, 0, "mising HII resource file name", NULL);
|
||||
Status = STATUS_ERROR;
|
||||
goto Done;
|
||||
}
|
||||
|
||||
strcpy (mGlobals.ResourceFileName, Argv[0]);
|
||||
mGlobals.Mode |= MODE_CREATE_HII_RESOURCE_FILE;
|
||||
|
||||
} else if (_stricmp (Argv[0], "-hii") == 0) {
|
||||
Argc--;
|
||||
Argv++;
|
||||
|
||||
if (Argc == 0) {
|
||||
Error (UTILITY_NAME, 0, 0, "mising HII package list file name", NULL);
|
||||
Status = STATUS_ERROR;
|
||||
goto Done;
|
||||
}
|
||||
|
||||
strcpy (mGlobals.PackageListFileName, Argv[0]);
|
||||
mGlobals.Mode |= MODE_CREATE_HII_PACKAGE_LIST;
|
||||
|
||||
} else if (_stricmp (Argv[0], "-g") == 0) {
|
||||
Argc--;
|
||||
Argv++;
|
||||
|
||||
if (Argc == 0) {
|
||||
Error (UTILITY_NAME, 0, 0, "mising package list GUID", NULL);
|
||||
Status = STATUS_ERROR;
|
||||
goto Done;
|
||||
}
|
||||
|
||||
Status = StringToGuid (Argv[0], &mGlobals.Guid);
|
||||
if (Status != STATUS_SUCCESS) {
|
||||
goto Done;
|
||||
}
|
||||
mGlobals.GuidSpecified = TRUE;
|
||||
|
||||
} else {
|
||||
//
|
||||
// This is a package file
|
||||
//
|
||||
NewList = malloc (sizeof (FILE_NAME_LIST));
|
||||
if (NewList == NULL) {
|
||||
Error (UTILITY_NAME, 0, 0, "memory allocation failure", NULL);
|
||||
Status = STATUS_ERROR;
|
||||
goto Done;
|
||||
}
|
||||
|
||||
memset (NewList, 0, sizeof (FILE_NAME_LIST));
|
||||
strcpy (NewList->FileName, Argv[0]);
|
||||
|
||||
if (mGlobals.PackageFile == NULL) {
|
||||
mGlobals.PackageFile = NewList;
|
||||
} else {
|
||||
mGlobals.LastPackageFile->Next = NewList;
|
||||
}
|
||||
mGlobals.LastPackageFile = NewList;
|
||||
|
||||
Status = LoadPackage (NewList);
|
||||
if (Status != STATUS_SUCCESS) {
|
||||
goto Done;
|
||||
}
|
||||
}
|
||||
|
||||
Argc--;
|
||||
Argv++;
|
||||
}
|
||||
|
||||
if (!mGlobals.GuidSpecified) {
|
||||
Error (UTILITY_NAME, 0, 0, "please specify HII pakcage list GUID", NULL);
|
||||
Status = STATUS_ERROR;
|
||||
}
|
||||
|
||||
Done:
|
||||
if (Status != STATUS_SUCCESS) {
|
||||
FreeGlobals ();
|
||||
}
|
||||
|
||||
return Status;
|
||||
}
|
||||
|
||||
static
|
||||
void
|
||||
Usage (
|
||||
VOID
|
||||
)
|
||||
/*++
|
||||
|
||||
Routine Description:
|
||||
|
||||
Print usage information for this utility.
|
||||
|
||||
Arguments:
|
||||
|
||||
None.
|
||||
|
||||
Returns:
|
||||
|
||||
Nothing.
|
||||
|
||||
--*/
|
||||
{
|
||||
int i;
|
||||
const char *Str[] = {
|
||||
UTILITY_NAME" "UTILITY_VERSION" - UEFI HII Package List Utility",
|
||||
" Copyright (C), 2008 Intel Corporation",
|
||||
|
||||
#if ( defined(UTILITY_BUILD) && defined(UTILITY_VENDOR) )
|
||||
" Built from "UTILITY_BUILD", project of "UTILITY_VENDOR,
|
||||
#endif
|
||||
"",
|
||||
"Usage:",
|
||||
" "UTILITY_NAME" [OPTION] PACKAGE [PACKAGE [...]]",
|
||||
"Description:",
|
||||
" Merge HII package files into a single HII Package List.",
|
||||
"Options:",
|
||||
" -rc FileName write output to PE/COFF Resource Script file",
|
||||
" -hii FileName write output to binary Package List file",
|
||||
" -g GUID use GUID for the HII Package List Guid",
|
||||
"",
|
||||
"PACKAGE is the raw binary HII package file generated by StrGather or",
|
||||
"VfrCompiler which named as *.hpk. For example, merge a Form package and",
|
||||
"a String package into one HII package list:",
|
||||
" \""UTILITY_NAME" -rc Sample.rc -hii Sample.hii \\",
|
||||
" -g 12345678-1234-1234-1234-123456789abc Vfr.hpk Strings.hpk\"",
|
||||
NULL
|
||||
};
|
||||
for (i = 0; Str[i] != NULL; i++) {
|
||||
fprintf (stdout, "%s\n", Str[i]);
|
||||
}
|
||||
}
|
71
EdkCompatibilityPkg/Sample/Tools/Source/UefiHiiPack/Makefile
Normal file
71
EdkCompatibilityPkg/Sample/Tools/Source/UefiHiiPack/Makefile
Normal file
@@ -0,0 +1,71 @@
|
||||
#/*++
|
||||
#
|
||||
# Copyright (c) 2008 - 2010, 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.
|
||||
#
|
||||
# Module Name:
|
||||
#
|
||||
# Makefile
|
||||
#
|
||||
# Abstract:
|
||||
#
|
||||
# Makefile for building the UEFI HiiPack utility
|
||||
#
|
||||
#--*/
|
||||
|
||||
#
|
||||
# Make sure environmental variable EDK_SOURCE is set
|
||||
#
|
||||
!IFNDEF EDK_SOURCE
|
||||
!ERROR EDK_SOURCE environmental variable not set
|
||||
!ENDIF
|
||||
|
||||
!INCLUDE $(BUILD_DIR)\PlatformTools.env
|
||||
|
||||
#
|
||||
# Target specific information
|
||||
#
|
||||
TARGET_NAME = HiiPack
|
||||
TARGET_SOURCE_DIR = $(EDK_TOOLS_SOURCE)\Uefi$(TARGET_NAME)
|
||||
TARGET_EXE = $(EDK_TOOLS_OUTPUT)\$(TARGET_NAME).exe
|
||||
|
||||
OBJECTS = $(EDK_TOOLS_OUTPUT)\HiiPack.obj
|
||||
LIBS = $(LIBS) $(EDK_TOOLS_OUTPUT)\Common.lib
|
||||
|
||||
#
|
||||
# Build targets
|
||||
#
|
||||
|
||||
all: $(TARGET_EXE)
|
||||
|
||||
#
|
||||
# Compile each tool source file
|
||||
#
|
||||
$(EDK_TOOLS_OUTPUT)\HiiPack.obj : $(TARGET_SOURCE_DIR)\HiiPack.c
|
||||
$(CC) $(C_FLAGS) $(TARGET_SOURCE_DIR)\HiiPack.c /Fo$@
|
||||
|
||||
#
|
||||
# Add Binary Build description for this tool.
|
||||
#
|
||||
|
||||
!IF (("$(EFI_BINARY_TOOLS)" == "YES") && EXIST($(EFI_PLATFORM_BIN)\Tools\$(TARGET_NAME).exe))
|
||||
$(TARGET_EXE): $(EFI_PLATFORM_BIN)\Tools\$(TARGET_NAME).exe
|
||||
copy $(EFI_PLATFORM_BIN)\Tools\$(TARGET_NAME).exe $(TARGET_EXE) /Y
|
||||
if exist $(EFI_PLATFORM_BIN)\Tools\$(TARGET_NAME).pdb \
|
||||
copy $(EFI_PLATFORM_BIN)\Tools\$(TARGET_NAME).pdb $(EDK_TOOLS_OUTPUT)\$(TARGET_NAME).pdb /Y
|
||||
!ELSE
|
||||
$(TARGET_EXE) : $(OBJECTS) $(LIBS)
|
||||
$(LINK) $(MSVS_LINK_LIBPATHS) $(L_FLAGS) $(LIBS) /out:$(TARGET_EXE) $(OBJECTS)
|
||||
!IF ("$(EFI_BINARY_BUILD)" == "YES")
|
||||
if not exist $(EFI_PLATFORM_BIN)\Tools mkdir $(EFI_PLATFORM_BIN)\Tools
|
||||
if exist $(TARGET_EXE) copy $(TARGET_EXE) $(EFI_PLATFORM_BIN)\tools\$(TARGET_NAME).exe /Y
|
||||
if exist $(EDK_TOOLS_OUTPUT)\$(TARGET_NAME).pdb \
|
||||
copy $(EDK_TOOLS_OUTPUT)\$(TARGET_NAME).pdb $(EFI_PLATFORM_BIN)\Tools\$(TARGET_NAME).pdb /Y
|
||||
!ENDIF
|
||||
!ENDIF
|
@@ -1,6 +1,6 @@
|
||||
/*++
|
||||
|
||||
Copyright (c) 2004 - 2007, Intel Corporation. All rights reserved.<BR>
|
||||
Copyright (c) 2004 - 2010, 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
|
||||
@@ -11,7 +11,7 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
|
||||
|
||||
Module Name:
|
||||
|
||||
StrGather.c
|
||||
StrGather.c
|
||||
|
||||
Abstract:
|
||||
|
||||
@@ -29,7 +29,8 @@ Abstract:
|
||||
#include "StrGather.h"
|
||||
#include "StringDB.h"
|
||||
|
||||
#define TOOL_VERSION "0.31"
|
||||
#define UTILITY_NAME "StrGather"
|
||||
#define UTILITY_VERSION "v1.2"
|
||||
|
||||
typedef UINT16 WCHAR;
|
||||
|
||||
@@ -47,6 +48,15 @@ typedef UINT16 WCHAR;
|
||||
#define MODE_SCAN 2
|
||||
#define MODE_DUMP 3
|
||||
|
||||
//
|
||||
// This is how we invoke the C preprocessor on the source file
|
||||
// to resolve #if, #else, etc.
|
||||
//
|
||||
#define PREPROCESSOR_COMMAND "cl"
|
||||
#define PREPROCESSOR_OPTIONS "/nologo /EP /TC /DSTRGATHER"
|
||||
#define PREPROCESS_TEMP_FILE_EXTENSION ".ii"
|
||||
#define PREPROCESS_OUTPUT_FILE_EXTENSION ".iii"
|
||||
|
||||
//
|
||||
// We keep a linked list of these for the source files we process
|
||||
//
|
||||
@@ -83,6 +93,8 @@ static struct {
|
||||
TEXT_STRING_LIST *LastIndirectionFileName;
|
||||
TEXT_STRING_LIST *DatabaseFileName;
|
||||
TEXT_STRING_LIST *LastDatabaseFileName;
|
||||
TEXT_STRING_LIST *PreprocessFlags;
|
||||
TEXT_STRING_LIST *LastPreprocessFlags;
|
||||
WCHAR_STRING_LIST *Language;
|
||||
WCHAR_STRING_LIST *LastLanguage;
|
||||
WCHAR_MATCHING_STRING_LIST *IndirectionList; // from indirection file(s)
|
||||
@@ -94,6 +106,8 @@ static struct {
|
||||
BOOLEAN IgnoreNotFound; // when scanning
|
||||
BOOLEAN VerboseScan;
|
||||
BOOLEAN UnquotedStrings; // -uqs option
|
||||
BOOLEAN Preprocess; // -ppflag option
|
||||
INT8 PreprocessFileName[MAX_PATH];
|
||||
INT8 OutputDatabaseFileName[MAX_PATH];
|
||||
INT8 StringHFileName[MAX_PATH];
|
||||
INT8 StringCFileName[MAX_PATH]; // output .C filename
|
||||
@@ -294,11 +308,6 @@ ParseIndirectionFiles (
|
||||
TEXT_STRING_LIST *Files
|
||||
);
|
||||
|
||||
STATUS
|
||||
StringDBCreateHiiExportPack (
|
||||
INT8 *OutputFileName
|
||||
);
|
||||
|
||||
int
|
||||
main (
|
||||
int Argc,
|
||||
@@ -309,7 +318,7 @@ main (
|
||||
Routine Description:
|
||||
|
||||
Call the routine to parse the command-line options, then process the file.
|
||||
|
||||
|
||||
Arguments:
|
||||
|
||||
Argc - Standard C main() argc and argv.
|
||||
@@ -319,12 +328,12 @@ Returns:
|
||||
|
||||
0 if successful
|
||||
nonzero otherwise
|
||||
|
||||
|
||||
--*/
|
||||
{
|
||||
STATUS Status;
|
||||
|
||||
SetUtilityName (PROGRAM_NAME);
|
||||
SetUtilityName (UTILITY_NAME);
|
||||
//
|
||||
// Process the command-line arguments
|
||||
//
|
||||
@@ -374,12 +383,12 @@ Returns:
|
||||
if ((mGlobals.OutputDependencyFptr = fopen (mGlobals.OutputDependencyFileName, "w")) == NULL) {
|
||||
Error (NULL, 0, 0, mGlobals.OutputDependencyFileName, "failed to open output dependency file");
|
||||
goto Finish;
|
||||
}
|
||||
}
|
||||
}
|
||||
Status = ProcessIncludeFile (&mGlobals.SourceFiles, NULL);
|
||||
if (mGlobals.OutputDependencyFptr != NULL) {
|
||||
fclose (mGlobals.OutputDependencyFptr);
|
||||
}
|
||||
}
|
||||
if (Status != STATUS_SUCCESS) {
|
||||
goto Finish;
|
||||
}
|
||||
@@ -401,7 +410,8 @@ Returns:
|
||||
if ((mGlobals.StringCFileName[0] != 0) && (GetUtilityStatus () < STATUS_ERROR)) {
|
||||
Status = StringDBDumpCStrings (
|
||||
mGlobals.BaseName,
|
||||
mGlobals.StringCFileName
|
||||
mGlobals.StringCFileName,
|
||||
mGlobals.Language
|
||||
);
|
||||
if (Status != EFI_SUCCESS) {
|
||||
goto Finish;
|
||||
@@ -418,7 +428,7 @@ Returns:
|
||||
// Dump the string data as HII binary string pack if requested
|
||||
//
|
||||
if ((mGlobals.HiiExportPackFileName[0] != 0) && (GetUtilityStatus () < STATUS_ERROR)) {
|
||||
StringDBCreateHiiExportPack (mGlobals.HiiExportPackFileName);
|
||||
StringDBCreateHiiExportPack (mGlobals.HiiExportPackFileName, mGlobals.Language);
|
||||
}
|
||||
//
|
||||
// Always update the database if no errors and not in dump mode. If they specified -od
|
||||
@@ -457,7 +467,7 @@ ProcessIncludeFile (
|
||||
Routine Description:
|
||||
|
||||
Given a source file, open the file and parse it
|
||||
|
||||
|
||||
Arguments:
|
||||
|
||||
SourceFile - name of file to parse
|
||||
@@ -466,7 +476,7 @@ Arguments:
|
||||
Returns:
|
||||
|
||||
Standard status.
|
||||
|
||||
|
||||
--*/
|
||||
{
|
||||
static UINT32 NestDepth = 0;
|
||||
@@ -513,18 +523,18 @@ Returns:
|
||||
goto Finish;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//
|
||||
// Output the dependency
|
||||
// Output the dependency
|
||||
//
|
||||
if (mGlobals.OutputDependencyFptr != NULL) {
|
||||
fprintf (mGlobals.OutputDependencyFptr, "%s : %s\n", mGlobals.DatabaseFileName->Str, FoundFileName);
|
||||
fprintf (mGlobals.OutputDependencyFptr, "%s : %s\n", mGlobals.DatabaseFileName->Str, FoundFileName);
|
||||
//
|
||||
// Add pseudo target to avoid incremental build failure when the file is deleted
|
||||
//
|
||||
fprintf (mGlobals.OutputDependencyFptr, "%s : \n", FoundFileName);
|
||||
fprintf (mGlobals.OutputDependencyFptr, "%s : \n", FoundFileName);
|
||||
}
|
||||
|
||||
|
||||
//
|
||||
// Process the file found
|
||||
//
|
||||
@@ -695,13 +705,13 @@ PreprocessFile (
|
||||
Routine Description:
|
||||
Preprocess a file to replace all carriage returns with NULLs so
|
||||
we can print lines from the file to the screen.
|
||||
|
||||
|
||||
Arguments:
|
||||
SourceFile - structure that we use to keep track of an input file.
|
||||
|
||||
Returns:
|
||||
Nothing.
|
||||
|
||||
|
||||
--*/
|
||||
{
|
||||
BOOLEAN InComment;
|
||||
@@ -1736,7 +1746,7 @@ FindFile (
|
||||
// Put the path and filename together
|
||||
//
|
||||
if (strlen (List->Str) + strlen (FileName) + 1 > FoundFileNameLen) {
|
||||
Error (PROGRAM_NAME, 0, 0, NULL, "internal error - cannot concatenate path+filename");
|
||||
Error (UTILITY_NAME, 0, 0, NULL, "internal error - cannot concatenate path+filename");
|
||||
return NULL;
|
||||
}
|
||||
//
|
||||
@@ -1770,6 +1780,9 @@ ProcessArgs (
|
||||
)
|
||||
{
|
||||
TEXT_STRING_LIST *NewList;
|
||||
char *Cptr;
|
||||
char *Cptr2;
|
||||
|
||||
//
|
||||
// Clear our globals
|
||||
//
|
||||
@@ -1836,7 +1849,7 @@ ProcessArgs (
|
||||
// check for one more arg
|
||||
//
|
||||
if ((Argc <= 1) || (Argv[1][0] == '-')) {
|
||||
Error (PROGRAM_NAME, 0, 0, Argv[0], "missing include path");
|
||||
Error (UTILITY_NAME, 0, 0, Argv[0], "missing include path");
|
||||
return STATUS_ERROR;
|
||||
}
|
||||
//
|
||||
@@ -1846,7 +1859,7 @@ ProcessArgs (
|
||||
//
|
||||
NewList = malloc (sizeof (TEXT_STRING_LIST));
|
||||
if (NewList == NULL) {
|
||||
Error (PROGRAM_NAME, 0, 0, NULL, "memory allocation failure");
|
||||
Error (UTILITY_NAME, 0, 0, NULL, "memory allocation failure");
|
||||
return STATUS_ERROR;
|
||||
}
|
||||
|
||||
@@ -1854,7 +1867,7 @@ ProcessArgs (
|
||||
NewList->Str = malloc (strlen (Argv[1]) + 2);
|
||||
if (NewList->Str == NULL) {
|
||||
free (NewList);
|
||||
Error (PROGRAM_NAME, 0, 0, NULL, "memory allocation failure");
|
||||
Error (UTILITY_NAME, 0, 0, NULL, "memory allocation failure");
|
||||
return STATUS_ERROR;
|
||||
}
|
||||
|
||||
@@ -1879,7 +1892,7 @@ ProcessArgs (
|
||||
// Indirection file -- check for one more arg
|
||||
//
|
||||
if ((Argc <= 1) || (Argv[1][0] == '-')) {
|
||||
Error (PROGRAM_NAME, 0, 0, Argv[0], "missing indirection file name");
|
||||
Error (UTILITY_NAME, 0, 0, Argv[0], "missing indirection file name");
|
||||
return STATUS_ERROR;
|
||||
}
|
||||
//
|
||||
@@ -1889,7 +1902,7 @@ ProcessArgs (
|
||||
//
|
||||
NewList = malloc (sizeof (TEXT_STRING_LIST));
|
||||
if (NewList == NULL) {
|
||||
Error (PROGRAM_NAME, 0, 0, NULL, "memory allocation failure");
|
||||
Error (UTILITY_NAME, 0, 0, NULL, "memory allocation failure");
|
||||
return STATUS_ERROR;
|
||||
}
|
||||
|
||||
@@ -1897,7 +1910,7 @@ ProcessArgs (
|
||||
NewList->Str = malloc (strlen (Argv[1]) + 1);
|
||||
if (NewList->Str == NULL) {
|
||||
free (NewList);
|
||||
Error (PROGRAM_NAME, 0, 0, NULL, "memory allocation failure");
|
||||
Error (UTILITY_NAME, 0, 0, NULL, "memory allocation failure");
|
||||
return STATUS_ERROR;
|
||||
}
|
||||
|
||||
@@ -1920,13 +1933,13 @@ ProcessArgs (
|
||||
// Check for one more arg (the database file name)
|
||||
//
|
||||
if ((Argc <= 1) || (Argv[1][0] == '-')) {
|
||||
Error (PROGRAM_NAME, 0, 0, Argv[0], "missing database file name");
|
||||
Error (UTILITY_NAME, 0, 0, Argv[0], "missing database file name");
|
||||
return STATUS_ERROR;
|
||||
}
|
||||
|
||||
NewList = malloc (sizeof (TEXT_STRING_LIST));
|
||||
if (NewList == NULL) {
|
||||
Error (PROGRAM_NAME, 0, 0, NULL, "memory allocation failure");
|
||||
Error (UTILITY_NAME, 0, 0, NULL, "memory allocation failure");
|
||||
return STATUS_ERROR;
|
||||
}
|
||||
|
||||
@@ -1934,7 +1947,7 @@ ProcessArgs (
|
||||
NewList->Str = malloc (strlen (Argv[1]) + 1);
|
||||
if (NewList->Str == NULL) {
|
||||
free (NewList);
|
||||
Error (PROGRAM_NAME, 0, 0, NULL, "memory allocation failure");
|
||||
Error (UTILITY_NAME, 0, 0, NULL, "memory allocation failure");
|
||||
return STATUS_ERROR;
|
||||
}
|
||||
|
||||
@@ -1957,14 +1970,14 @@ ProcessArgs (
|
||||
// which we can dump our database.
|
||||
//
|
||||
if ((Argc <= 1) || (Argv[1][0] == '-')) {
|
||||
Error (PROGRAM_NAME, 0, 0, Argv[0], "missing database dump output file name");
|
||||
Error (UTILITY_NAME, 0, 0, Argv[0], "missing database dump output file name");
|
||||
return STATUS_ERROR;
|
||||
}
|
||||
|
||||
if (mGlobals.DumpUFileName[0] == 0) {
|
||||
strcpy (mGlobals.DumpUFileName, Argv[1]);
|
||||
} else {
|
||||
Error (PROGRAM_NAME, 0, 0, Argv[1], "-ou option already specified with '%s'", mGlobals.DumpUFileName);
|
||||
Error (UTILITY_NAME, 0, 0, Argv[1], "-ou option already specified with '%s'", mGlobals.DumpUFileName);
|
||||
return STATUS_ERROR;
|
||||
}
|
||||
|
||||
@@ -1975,14 +1988,14 @@ ProcessArgs (
|
||||
// -hpk option to create an HII export pack of the input database file
|
||||
//
|
||||
if ((Argc <= 1) || (Argv[1][0] == '-')) {
|
||||
Error (PROGRAM_NAME, 0, 0, Argv[0], "missing raw string data dump output file name");
|
||||
Error (UTILITY_NAME, 0, 0, Argv[0], "missing raw string data dump output file name");
|
||||
return STATUS_ERROR;
|
||||
}
|
||||
|
||||
if (mGlobals.HiiExportPackFileName[0] == 0) {
|
||||
strcpy (mGlobals.HiiExportPackFileName, Argv[1]);
|
||||
} else {
|
||||
Error (PROGRAM_NAME, 0, 0, Argv[1], "-or option already specified with '%s'", mGlobals.HiiExportPackFileName);
|
||||
Error (UTILITY_NAME, 0, 0, Argv[1], "-or option already specified with '%s'", mGlobals.HiiExportPackFileName);
|
||||
return STATUS_ERROR;
|
||||
}
|
||||
|
||||
@@ -2006,7 +2019,7 @@ ProcessArgs (
|
||||
// check for one more arg
|
||||
//
|
||||
if ((Argc <= 1) || (Argv[1][0] == '-')) {
|
||||
Error (PROGRAM_NAME, 0, 0, Argv[0], "missing output C filename");
|
||||
Error (UTILITY_NAME, 0, 0, Argv[0], "missing output C filename");
|
||||
return STATUS_ERROR;
|
||||
}
|
||||
|
||||
@@ -2018,7 +2031,7 @@ ProcessArgs (
|
||||
// check for one more arg
|
||||
//
|
||||
if ((Argc <= 1) || (Argv[1][0] == '-')) {
|
||||
Error (PROGRAM_NAME, 0, 0, Argv[0], "missing base name");
|
||||
Error (UTILITY_NAME, 0, 0, Argv[0], "missing base name");
|
||||
Usage ();
|
||||
return STATUS_ERROR;
|
||||
}
|
||||
@@ -2031,7 +2044,7 @@ ProcessArgs (
|
||||
// -oh to specify output .h defines file name
|
||||
//
|
||||
if ((Argc <= 1) || (Argv[1][0] == '-')) {
|
||||
Error (PROGRAM_NAME, 0, 0, Argv[0], "missing output .h filename");
|
||||
Error (UTILITY_NAME, 0, 0, Argv[0], "missing output .h filename");
|
||||
return STATUS_ERROR;
|
||||
}
|
||||
|
||||
@@ -2043,7 +2056,7 @@ ProcessArgs (
|
||||
// -dep to specify output dependency file name
|
||||
//
|
||||
if ((Argc <= 1) || (Argv[1][0] == '-')) {
|
||||
Error (PROGRAM_NAME, 0, 0, Argv[0], "missing output dependency filename");
|
||||
Error (UTILITY_NAME, 0, 0, Argv[0], "missing output dependency filename");
|
||||
return STATUS_ERROR;
|
||||
}
|
||||
|
||||
@@ -2055,7 +2068,7 @@ ProcessArgs (
|
||||
// -skipext to skip scanning of files with certain filename extensions
|
||||
//
|
||||
if ((Argc <= 1) || (Argv[1][0] == '-')) {
|
||||
Error (PROGRAM_NAME, 0, 0, Argv[0], "missing filename extension");
|
||||
Error (UTILITY_NAME, 0, 0, Argv[0], "missing filename extension");
|
||||
return STATUS_ERROR;
|
||||
}
|
||||
//
|
||||
@@ -2065,7 +2078,7 @@ ProcessArgs (
|
||||
//
|
||||
NewList = malloc (sizeof (TEXT_STRING_LIST));
|
||||
if (NewList == NULL) {
|
||||
Error (PROGRAM_NAME, 0, 0, NULL, "memory allocation failure");
|
||||
Error (UTILITY_NAME, 0, 0, NULL, "memory allocation failure");
|
||||
return STATUS_ERROR;
|
||||
}
|
||||
|
||||
@@ -2073,7 +2086,7 @@ ProcessArgs (
|
||||
NewList->Str = malloc (strlen (Argv[1]) + 2);
|
||||
if (NewList->Str == NULL) {
|
||||
free (NewList);
|
||||
Error (PROGRAM_NAME, 0, 0, NULL, "memory allocation failure");
|
||||
Error (UTILITY_NAME, 0, 0, NULL, "memory allocation failure");
|
||||
return STATUS_ERROR;
|
||||
}
|
||||
|
||||
@@ -2097,10 +2110,10 @@ ProcessArgs (
|
||||
Argv++;
|
||||
} else if (_stricmp (Argv[0], "-lang") == 0) {
|
||||
//
|
||||
// "-lang eng" or "-lang spa+cat" to only output certain languages
|
||||
// "-lang zh-Hans" or "-lang en-US" to only output certain languages
|
||||
//
|
||||
if ((Argc <= 1) || (Argv[1][0] == '-')) {
|
||||
Error (PROGRAM_NAME, 0, 0, Argv[0], "missing language name");
|
||||
Error (UTILITY_NAME, 0, 0, Argv[0], "missing language name");
|
||||
Usage ();
|
||||
return STATUS_ERROR;
|
||||
}
|
||||
@@ -2116,18 +2129,78 @@ ProcessArgs (
|
||||
// Output database file name -- check for another arg
|
||||
//
|
||||
if ((Argc <= 1) || (Argv[1][0] == '-')) {
|
||||
Error (PROGRAM_NAME, 0, 0, Argv[0], "missing output database file name");
|
||||
Error (UTILITY_NAME, 0, 0, Argv[0], "missing output database file name");
|
||||
return STATUS_ERROR;
|
||||
}
|
||||
|
||||
strcpy (mGlobals.OutputDatabaseFileName, Argv[1]);
|
||||
Argv++;
|
||||
Argc--;
|
||||
} else if (_stricmp (Argv[0], "-ppflag") == 0) {
|
||||
//
|
||||
// -ppflag "Preprocess flags" -- check for another arg
|
||||
//
|
||||
if ((Argc <= 1) || (Argv[1][0] == '-')) {
|
||||
Error (UTILITY_NAME, 0, 0, Argv[0], "missing preprocess flags");
|
||||
Usage ();
|
||||
return STATUS_ERROR;
|
||||
}
|
||||
|
||||
//
|
||||
// Allocate memory for a new list element, fill it in, and
|
||||
// add it to our list of preprocess flag.
|
||||
//
|
||||
NewList = malloc (sizeof (TEXT_STRING_LIST));
|
||||
if (NewList == NULL) {
|
||||
Error (UTILITY_NAME, 0, 0, NULL, "memory allocation failure");
|
||||
return STATUS_ERROR;
|
||||
}
|
||||
|
||||
memset ((char *) NewList, 0, sizeof (TEXT_STRING_LIST));
|
||||
NewList->Str = malloc (strlen (Argv[1]) * 2 + 1);
|
||||
if (NewList->Str == NULL) {
|
||||
free (NewList);
|
||||
Error (UTILITY_NAME, 0, 0, NULL, "memory allocation failure");
|
||||
return STATUS_ERROR;
|
||||
}
|
||||
|
||||
//
|
||||
// Convert '"' to '\"' in preprocess flag
|
||||
//
|
||||
Cptr = Argv[1];
|
||||
Cptr2 = NewList->Str;
|
||||
if (*Cptr == '"') {
|
||||
*Cptr2++ = '\\';
|
||||
*Cptr2++ = '"';
|
||||
Cptr++;
|
||||
}
|
||||
while (*Cptr != '\0') {
|
||||
if ((*Cptr == '"') && (*(Cptr - 1) != '\\')) {
|
||||
*Cptr2++ = '\\';
|
||||
}
|
||||
*Cptr2++ = *Cptr++;
|
||||
}
|
||||
*Cptr2 = '\0';
|
||||
|
||||
//
|
||||
// Add it to our linked list
|
||||
//
|
||||
if (mGlobals.PreprocessFlags == NULL) {
|
||||
mGlobals.PreprocessFlags = NewList;
|
||||
} else {
|
||||
mGlobals.LastPreprocessFlags->Next = NewList;
|
||||
}
|
||||
mGlobals.LastPreprocessFlags = NewList;
|
||||
|
||||
mGlobals.Preprocess = TRUE;
|
||||
|
||||
Argv++;
|
||||
Argc--;
|
||||
} else {
|
||||
//
|
||||
// Unrecognized arg
|
||||
//
|
||||
Error (PROGRAM_NAME, 0, 0, Argv[0], "unrecognized option");
|
||||
Error (UTILITY_NAME, 0, 0, Argv[0], "unrecognized option");
|
||||
Usage ();
|
||||
return STATUS_ERROR;
|
||||
}
|
||||
@@ -2174,7 +2247,15 @@ ProcessArgs (
|
||||
//
|
||||
if (mGlobals.Mode == MODE_SCAN) {
|
||||
if (Argc < 1) {
|
||||
Error (PROGRAM_NAME, 0, 0, NULL, "must specify at least one source file to scan with -scan");
|
||||
Error (UTILITY_NAME, 0, 0, NULL, "must specify at least one source file to scan with -scan");
|
||||
Usage ();
|
||||
return STATUS_ERROR;
|
||||
}
|
||||
//
|
||||
// If -ppflag is specified, -oh should also be specified for preprocess
|
||||
//
|
||||
if (mGlobals.Preprocess && (mGlobals.StringHFileName[0] == 0)) {
|
||||
Error (UTILITY_NAME, 0, 0, NULL, "must specify string defines file name to preprocess before scan");
|
||||
Usage ();
|
||||
return STATUS_ERROR;
|
||||
}
|
||||
@@ -2184,14 +2265,14 @@ ProcessArgs (
|
||||
while (Argc > 0) {
|
||||
NewList = malloc (sizeof (TEXT_STRING_LIST));
|
||||
if (NewList == NULL) {
|
||||
Error (PROGRAM_NAME, 0, 0, "memory allocation failure", NULL);
|
||||
Error (UTILITY_NAME, 0, 0, "memory allocation failure", NULL);
|
||||
return STATUS_ERROR;
|
||||
}
|
||||
|
||||
memset (NewList, 0, sizeof (TEXT_STRING_LIST));
|
||||
NewList->Str = (UINT8 *) malloc (strlen (Argv[0]) + 1);
|
||||
if (NewList->Str == NULL) {
|
||||
Error (PROGRAM_NAME, 0, 0, "memory allocation failure", NULL);
|
||||
Error (UTILITY_NAME, 0, 0, "memory allocation failure", NULL);
|
||||
return STATUS_ERROR;
|
||||
}
|
||||
|
||||
@@ -2211,7 +2292,7 @@ ProcessArgs (
|
||||
// Parse mode -- must specify an input unicode file name
|
||||
//
|
||||
if (Argc < 1) {
|
||||
Error (PROGRAM_NAME, 0, 0, NULL, "must specify input unicode string file name with -parse");
|
||||
Error (UTILITY_NAME, 0, 0, NULL, "must specify input unicode string file name with -parse");
|
||||
Usage ();
|
||||
return STATUS_ERROR;
|
||||
}
|
||||
@@ -2222,7 +2303,7 @@ ProcessArgs (
|
||||
return STATUS_SUCCESS;
|
||||
}
|
||||
//
|
||||
// Found "-lang eng,spa+cat" on the command line. Parse the
|
||||
// Found "-lang zh-Hans;en-US" on the command line. Parse the
|
||||
// language list and save the setting for later processing.
|
||||
//
|
||||
static
|
||||
@@ -2231,69 +2312,33 @@ AddCommandLineLanguage (
|
||||
IN INT8 *Language
|
||||
)
|
||||
{
|
||||
char Separator[] = ";";
|
||||
char *Token;
|
||||
WCHAR_STRING_LIST *WNewList;
|
||||
WCHAR *From;
|
||||
WCHAR *To;
|
||||
|
||||
//
|
||||
// Keep processing the input string until we find the end.
|
||||
//
|
||||
while (*Language) {
|
||||
//
|
||||
// Allocate memory for a new list element, fill it in, and
|
||||
// add it to our list.
|
||||
//
|
||||
Token = strtok (Language, Separator);
|
||||
while (Token != NULL) {
|
||||
WNewList = MALLOC (sizeof (WCHAR_STRING_LIST));
|
||||
if (WNewList == NULL) {
|
||||
Error (PROGRAM_NAME, 0, 0, NULL, "memory allocation failure");
|
||||
Error (UTILITY_NAME, 0, 0, NULL, "memory allocation failure");
|
||||
return STATUS_ERROR;
|
||||
}
|
||||
|
||||
memset ((char *) WNewList, 0, sizeof (WCHAR_STRING_LIST));
|
||||
WNewList->Str = malloc ((strlen (Language) + 1) * sizeof (WCHAR));
|
||||
WNewList->Next = NULL;
|
||||
WNewList->Str = MALLOC ((strlen (Token) + 1) * sizeof (WCHAR));
|
||||
if (WNewList->Str == NULL) {
|
||||
free (WNewList);
|
||||
Error (PROGRAM_NAME, 0, 0, NULL, "memory allocation failure");
|
||||
Error (UTILITY_NAME, 0, 0, NULL, "memory allocation failure");
|
||||
return STATUS_ERROR;
|
||||
}
|
||||
//
|
||||
// Copy it as unicode to our new structure. Then remove the
|
||||
// plus signs in it, and verify each language name is 3 characters
|
||||
// long. If we find a comma, then we're done with this group, so
|
||||
// break out.
|
||||
//
|
||||
#ifdef USE_VC8
|
||||
swprintf (WNewList->Str, (strlen (Language) + 1) * sizeof (WCHAR), L"%S", Language);
|
||||
swprintf (WNewList->Str, (strlen (Token) + 1) * sizeof (WCHAR), L"%S", Token);
|
||||
#else
|
||||
swprintf (WNewList->Str, L"%S", Language);
|
||||
swprintf (WNewList->Str, L"%S", Token);
|
||||
#endif
|
||||
From = To = WNewList->Str;
|
||||
while (*From) {
|
||||
if (*From == L',') {
|
||||
break;
|
||||
}
|
||||
|
||||
if ((wcslen (From) < LANGUAGE_IDENTIFIER_NAME_LEN) ||
|
||||
(
|
||||
(From[LANGUAGE_IDENTIFIER_NAME_LEN] != 0) &&
|
||||
(From[LANGUAGE_IDENTIFIER_NAME_LEN] != UNICODE_PLUS_SIGN) &&
|
||||
(From[LANGUAGE_IDENTIFIER_NAME_LEN] != L',')
|
||||
)
|
||||
) {
|
||||
Error (PROGRAM_NAME, 0, 0, Language, "invalid format for language name on command line");
|
||||
FREE (WNewList->Str);
|
||||
FREE (WNewList);
|
||||
return STATUS_ERROR;
|
||||
}
|
||||
|
||||
wcsncpy (To, From, LANGUAGE_IDENTIFIER_NAME_LEN);
|
||||
To += LANGUAGE_IDENTIFIER_NAME_LEN;
|
||||
From += LANGUAGE_IDENTIFIER_NAME_LEN;
|
||||
if (*From == L'+') {
|
||||
From++;
|
||||
}
|
||||
}
|
||||
|
||||
*To = 0;
|
||||
//
|
||||
// Add it to our linked list
|
||||
//
|
||||
@@ -2304,17 +2349,7 @@ AddCommandLineLanguage (
|
||||
}
|
||||
|
||||
mGlobals.LastLanguage = WNewList;
|
||||
//
|
||||
// Skip to next entry (comma-separated list)
|
||||
//
|
||||
while (*Language) {
|
||||
if (*Language == L',') {
|
||||
Language++;
|
||||
break;
|
||||
}
|
||||
|
||||
Language++;
|
||||
}
|
||||
Token = strtok (NULL, Separator);
|
||||
}
|
||||
|
||||
return STATUS_SUCCESS;
|
||||
@@ -2449,6 +2484,166 @@ Done:
|
||||
return STATUS_SUCCESS;
|
||||
}
|
||||
|
||||
static
|
||||
INTN
|
||||
PreprocessSourceFile (
|
||||
UINT8 *SourceFileName
|
||||
)
|
||||
{
|
||||
char *Cptr;
|
||||
FILE *InFptr;
|
||||
FILE *OutFptr;
|
||||
UINT32 CmdLen;
|
||||
char *PreProcessCmd;
|
||||
char BaseName[MAX_PATH];
|
||||
char TempFileName[MAX_PATH];
|
||||
char SourceFileDir[MAX_PATH];
|
||||
char Line[MAX_LINE_LEN];
|
||||
TEXT_STRING_LIST *List;
|
||||
char InsertLine[] = "#undef STRING_TOKEN\n";
|
||||
int Status;
|
||||
|
||||
//
|
||||
// Check whehter source file exist
|
||||
//
|
||||
InFptr = fopen (SourceFileName, "r");
|
||||
if (InFptr == NULL) {
|
||||
Error (NULL, 0, 0, SourceFileName, "failed to open input file for scanning");
|
||||
return STATUS_ERROR;
|
||||
}
|
||||
|
||||
//
|
||||
// Get source file directory
|
||||
//
|
||||
strcpy (SourceFileDir, SourceFileName);
|
||||
Cptr = strrchr (SourceFileDir, '\\');
|
||||
if (Cptr != NULL) {
|
||||
*Cptr = '\0';
|
||||
}
|
||||
|
||||
//
|
||||
// Generate preprocess output file name
|
||||
//
|
||||
strcpy (BaseName, mGlobals.OutputDatabaseFileName);
|
||||
Cptr = strrchr (BaseName, '\\');
|
||||
if (Cptr != NULL) {
|
||||
*++Cptr = '\0';
|
||||
}
|
||||
|
||||
Cptr = strrchr (SourceFileName, '\\');
|
||||
if (Cptr != NULL) {
|
||||
Cptr++;
|
||||
}
|
||||
strcat (BaseName, Cptr);
|
||||
|
||||
Cptr = strrchr (BaseName, '.');
|
||||
if (Cptr != NULL) {
|
||||
*Cptr = '\0';
|
||||
}
|
||||
|
||||
strcpy (mGlobals.PreprocessFileName, BaseName);
|
||||
strcat (mGlobals.PreprocessFileName, PREPROCESS_OUTPUT_FILE_EXTENSION);
|
||||
|
||||
strcpy (TempFileName, BaseName);
|
||||
strcat (TempFileName, PREPROCESS_TEMP_FILE_EXTENSION);
|
||||
|
||||
//
|
||||
// Insert "#undef STRING_TOKEN" after each line of "#include ...", so as to
|
||||
// preserve the STRING_TOKEN() for scanning after preprocess
|
||||
//
|
||||
OutFptr = fopen (TempFileName, "w");
|
||||
if (OutFptr == NULL) {
|
||||
Error (NULL, 0, 0, TempFileName, "failed to open file for write");
|
||||
fclose (InFptr);
|
||||
return STATUS_ERROR;
|
||||
}
|
||||
while (fgets (Line, MAX_LINE_LEN, InFptr) != NULL) {
|
||||
fputs (Line, OutFptr);
|
||||
Cptr = Line;
|
||||
|
||||
//
|
||||
// Skip leading blank space
|
||||
//
|
||||
while (*Cptr == ' ' || *Cptr == '\t') {
|
||||
Cptr++;
|
||||
}
|
||||
|
||||
if (*Cptr == '#' && strncmp (Cptr + 1, "include", 7) == 0){
|
||||
fputs (InsertLine, OutFptr);
|
||||
}
|
||||
}
|
||||
fclose (InFptr);
|
||||
fclose (OutFptr);
|
||||
|
||||
//
|
||||
// Prepare preprocess command
|
||||
//
|
||||
CmdLen = 1;
|
||||
CmdLen += strlen (PREPROCESSOR_COMMAND);
|
||||
CmdLen++;
|
||||
CmdLen += strlen (PREPROCESSOR_OPTIONS);
|
||||
CmdLen++;
|
||||
|
||||
//
|
||||
// "-I SourceFileDir "
|
||||
//
|
||||
CmdLen += strlen (SourceFileDir);
|
||||
CmdLen += 4;
|
||||
|
||||
List = mGlobals.PreprocessFlags;
|
||||
while (List != NULL) {
|
||||
CmdLen += strlen (List->Str);
|
||||
CmdLen++;
|
||||
|
||||
List = List->Next;
|
||||
}
|
||||
|
||||
CmdLen += strlen (TempFileName);
|
||||
CmdLen += 3;
|
||||
CmdLen += strlen (mGlobals.PreprocessFileName);
|
||||
|
||||
PreProcessCmd = malloc (CmdLen);
|
||||
if (PreProcessCmd == NULL) {
|
||||
Error (NULL, 0, 0, UTILITY_NAME, "memory allocation fail (%d bytes)\n", CmdLen);
|
||||
return STATUS_ERROR;
|
||||
}
|
||||
|
||||
strcpy (PreProcessCmd, PREPROCESSOR_COMMAND);
|
||||
strcat (PreProcessCmd, " ");
|
||||
strcat (PreProcessCmd, PREPROCESSOR_OPTIONS);
|
||||
strcat (PreProcessCmd, " ");
|
||||
|
||||
|
||||
strcat (PreProcessCmd, "-I ");
|
||||
strcat (PreProcessCmd, SourceFileDir);
|
||||
strcat (PreProcessCmd, " ");
|
||||
|
||||
List = mGlobals.PreprocessFlags;
|
||||
while (List != NULL) {
|
||||
strcat (PreProcessCmd, List->Str);
|
||||
strcat (PreProcessCmd, " ");
|
||||
|
||||
List = List->Next;
|
||||
}
|
||||
|
||||
strcat (PreProcessCmd, TempFileName);
|
||||
strcat (PreProcessCmd, " > ");
|
||||
strcat (PreProcessCmd, mGlobals.PreprocessFileName);
|
||||
|
||||
//
|
||||
// Preprocess the source file
|
||||
//
|
||||
Status = system (PreProcessCmd);
|
||||
if (Status != 0) {
|
||||
Error (NULL, 0, 0, PreProcessCmd, "failed to spawn C preprocessor on source file\n");
|
||||
free (PreProcessCmd);
|
||||
return STATUS_ERROR;
|
||||
}
|
||||
|
||||
free (PreProcessCmd);
|
||||
return STATUS_SUCCESS;
|
||||
}
|
||||
|
||||
static
|
||||
STATUS
|
||||
ScanFiles (
|
||||
@@ -2457,6 +2652,7 @@ ScanFiles (
|
||||
{
|
||||
char Line[MAX_LINE_LEN];
|
||||
FILE *Fptr;
|
||||
char *FileName;
|
||||
UINT32 LineNum;
|
||||
char *Cptr;
|
||||
char *SavePtr;
|
||||
@@ -2464,6 +2660,7 @@ ScanFiles (
|
||||
char *StringTokenPos;
|
||||
TEXT_STRING_LIST *SList;
|
||||
BOOLEAN SkipIt;
|
||||
BOOLEAN FileExist;
|
||||
|
||||
//
|
||||
// Put a null-terminator at the end of the line. If we read in
|
||||
@@ -2474,6 +2671,7 @@ ScanFiles (
|
||||
// Process each file. If they gave us a skip extension list, then
|
||||
// skip it if the extension matches.
|
||||
//
|
||||
FileExist = FALSE;
|
||||
while (ScanFiles != NULL) {
|
||||
SkipIt = FALSE;
|
||||
for (SList = mGlobals.SkipExt; SList != NULL; SList = SList->Next) {
|
||||
@@ -2493,9 +2691,36 @@ ScanFiles (
|
||||
printf ("Scanning %s\n", ScanFiles->Str);
|
||||
}
|
||||
|
||||
Fptr = fopen (ScanFiles->Str, "r");
|
||||
if (mGlobals.Preprocess) {
|
||||
//
|
||||
// Create an empty string defines file for preprocessor
|
||||
//
|
||||
if (!FileExist) {
|
||||
Fptr = fopen (mGlobals.StringHFileName, "w");
|
||||
if (Fptr == NULL) {
|
||||
Error (NULL, 0, 0, mGlobals.StringHFileName, "failed to open file for write");
|
||||
return STATUS_ERROR;
|
||||
}
|
||||
|
||||
fclose (Fptr);
|
||||
FileExist = TRUE;
|
||||
}
|
||||
|
||||
//
|
||||
// Preprocess using C preprocessor
|
||||
//
|
||||
if (PreprocessSourceFile (ScanFiles->Str) != STATUS_SUCCESS) {
|
||||
return STATUS_ERROR;
|
||||
}
|
||||
|
||||
FileName = mGlobals.PreprocessFileName;
|
||||
} else {
|
||||
FileName = ScanFiles->Str;
|
||||
}
|
||||
|
||||
Fptr = fopen (FileName, "r");
|
||||
if (Fptr == NULL) {
|
||||
Error (NULL, 0, 0, ScanFiles->Str, "failed to open input file for scanning");
|
||||
Error (NULL, 0, 0, FileName, "failed to open input file for scanning");
|
||||
return STATUS_ERROR;
|
||||
}
|
||||
|
||||
@@ -2613,6 +2838,13 @@ ScanFiles (
|
||||
ScanFiles = ScanFiles->Next;
|
||||
}
|
||||
|
||||
//
|
||||
// Remove the empty string defines file
|
||||
//
|
||||
if (FileExist) {
|
||||
remove (mGlobals.StringHFileName);
|
||||
}
|
||||
|
||||
return STATUS_SUCCESS;
|
||||
}
|
||||
//
|
||||
@@ -2647,6 +2879,15 @@ FreeLists (
|
||||
mGlobals.ScanFileName = Temp;
|
||||
}
|
||||
//
|
||||
// Free up preprocess flags list
|
||||
//
|
||||
while (mGlobals.PreprocessFlags != NULL) {
|
||||
Temp = mGlobals.PreprocessFlags->Next;
|
||||
free (mGlobals.PreprocessFlags->Str);
|
||||
free (mGlobals.PreprocessFlags);
|
||||
mGlobals.PreprocessFlags = Temp;
|
||||
}
|
||||
//
|
||||
// If they gave us a list of filename extensions to
|
||||
// skip on scan, then free them up.
|
||||
//
|
||||
@@ -2767,7 +3008,7 @@ Usage (
|
||||
Routine Description:
|
||||
|
||||
Print usage information for this utility.
|
||||
|
||||
|
||||
Arguments:
|
||||
|
||||
None.
|
||||
@@ -2775,51 +3016,62 @@ Arguments:
|
||||
Returns:
|
||||
|
||||
Nothing.
|
||||
|
||||
|
||||
--*/
|
||||
{
|
||||
int Index;
|
||||
static const char *Str[] = {
|
||||
int Index;
|
||||
const char *Str[] = {
|
||||
UTILITY_NAME" "UTILITY_VERSION" - Intel UEFI String Gather Utility",
|
||||
" Copyright (C), 2004 - 2008 Intel Corporation",
|
||||
|
||||
#if ( defined(UTILITY_BUILD) && defined(UTILITY_VENDOR) )
|
||||
" Built from "UTILITY_BUILD", project of "UTILITY_VENDOR,
|
||||
#endif
|
||||
"",
|
||||
PROGRAM_NAME " version "TOOL_VERSION " -- process unicode strings file",
|
||||
" Usage: "PROGRAM_NAME " -parse {parse options} [FileNames]",
|
||||
" "PROGRAM_NAME " -scan {scan options} [FileName]",
|
||||
" "PROGRAM_NAME " -dump {dump options}",
|
||||
" Common options include:",
|
||||
" -h or -? for this help information",
|
||||
" -db Database required name of output/input database file",
|
||||
" -bn BaseName for use in the .h and .c output files",
|
||||
" Default = "DEFAULT_BASE_NAME,
|
||||
" -v for verbose output",
|
||||
" -vdbw for verbose output when writing database",
|
||||
" -vdbr for verbose output when reading database",
|
||||
" -od FileName to specify an output database file name",
|
||||
" Parse options include:",
|
||||
" -i IncludePath add IncludePath to list of search paths",
|
||||
" -dep FileName to specify an output dependency file name",
|
||||
" -newdb to not read in existing database file",
|
||||
" -uqs to indicate that unquoted strings are used",
|
||||
" FileNames name of one or more unicode files to parse",
|
||||
" Scan options include:",
|
||||
" -scan scan text file(s) for STRING_TOKEN() usage",
|
||||
" -skipext .ext to skip scan of files with .ext filename extension",
|
||||
" -ignorenotfound ignore if a given STRING_TOKEN(STR) is not ",
|
||||
" found in the database",
|
||||
" FileNames one or more files to scan",
|
||||
" Dump options include:",
|
||||
" -oc FileName write string data to FileName",
|
||||
" -oh FileName write string defines to FileName",
|
||||
" -ou FileName dump database to unicode file FileName",
|
||||
" -lang Lang only dump for the language 'Lang'",
|
||||
" -if FileName to specify an indirection file",
|
||||
" -hpk FileName to create an HII export pack of the strings",
|
||||
"Usage:",
|
||||
" "UTILITY_NAME" -parse [OPTION] FILE",
|
||||
" "UTILITY_NAME" -scan [OPTION] FILE",
|
||||
" "UTILITY_NAME" -dump [OPTION]",
|
||||
"Description:",
|
||||
" Process unicode strings file.",
|
||||
"Common options include:",
|
||||
" -h or -? for this help information",
|
||||
" -db Database required name of output/input database file",
|
||||
" -bn BaseName for use in the .h and .c output files",
|
||||
" Default = "DEFAULT_BASE_NAME,
|
||||
" -v for verbose output",
|
||||
" -vdbw for verbose output when writing database",
|
||||
" -vdbr for verbose output when reading database",
|
||||
" -od FileName to specify an output database file name",
|
||||
"Parse options include:",
|
||||
" -i IncludePath add IncludePath to list of search paths",
|
||||
" -dep FileName to specify an output dependency file name",
|
||||
" -newdb to not read in existing database file",
|
||||
" -uqs to indicate that unquoted strings are used",
|
||||
" FileNames name of one or more unicode files to parse",
|
||||
"Scan options include:",
|
||||
" -scan scan text file(s) for STRING_TOKEN() usage",
|
||||
" -skipext .ext to skip scan of files with .ext filename extension",
|
||||
" -ppflag \"Flags\" to specify the C preprocessor flags",
|
||||
" -oh FileName to specify string defines file name for preprocessor",
|
||||
" -ignorenotfound ignore if a given STRING_TOKEN(STR) is not ",
|
||||
" found in the database",
|
||||
" FileNames one or more files to scan",
|
||||
"Dump options include:",
|
||||
" -oc FileName write string data to FileName",
|
||||
" -oh FileName write string defines to FileName",
|
||||
" -ou FileName dump database to unicode file FileName",
|
||||
" -lang Lang only dump for the language 'Lang'",
|
||||
" use ';' to separate multiple languages",
|
||||
" -if FileName to specify an indirection file",
|
||||
" -hpk FileName to create an HII export pack of the strings",
|
||||
"",
|
||||
" The expected process is to parse a unicode string file to create an initial",
|
||||
" database of string identifier names and string definitions. Then text files",
|
||||
" should be scanned for STRING_TOKEN() usages, and the referenced",
|
||||
" strings will be tagged as used in the database. After all files have been",
|
||||
" scanned, then the database should be dumped to create the necessary output",
|
||||
" files.",
|
||||
"The expected process is to parse a unicode string file to create an initial",
|
||||
"database of string identifier names and string definitions. Then text files",
|
||||
"should be scanned for STRING_TOKEN() usages, and the referenced",
|
||||
"strings will be tagged as used in the database. After all files have been",
|
||||
"scanned, then the database should be dumped to create the necessary output",
|
||||
"files.",
|
||||
"",
|
||||
NULL
|
||||
};
|
||||
|
@@ -1,6 +1,6 @@
|
||||
/*++
|
||||
|
||||
Copyright (c) 2004, Intel Corporation. All rights reserved.<BR>
|
||||
Copyright (c) 2004 - 2010, 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
|
||||
@@ -25,8 +25,6 @@ Abstract:
|
||||
#define MALLOC(size) malloc (size)
|
||||
#define FREE(ptr) do { if ((ptr) != NULL) { free (ptr); } } while (0)
|
||||
|
||||
#define PROGRAM_NAME "StrGather"
|
||||
|
||||
typedef CHAR16 WCHAR;
|
||||
|
||||
#define UNICODE_TO_ASCII(w) (INT8) ((w) & 0xFF)
|
||||
|
@@ -1,6 +1,6 @@
|
||||
/*++
|
||||
|
||||
Copyright (c) 2004 - 2007, Intel Corporation. All rights reserved.<BR>
|
||||
Copyright (c) 2004 - 2010, 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
|
||||
@@ -2559,13 +2559,15 @@ ExportPackOut:
|
||||
|
||||
STATUS
|
||||
StringDBCreateHiiExportPack (
|
||||
INT8 *FileName
|
||||
INT8 *FileName,
|
||||
WCHAR_STRING_LIST *LanguagesOfInterest
|
||||
)
|
||||
{
|
||||
FILE *File = NULL;
|
||||
LANGUAGE_LIST *Lang = NULL;
|
||||
EFI_HII_STRING_PACKAGE_HDR *StrPkgHdr = NULL;
|
||||
SPkgBlkBuffer *BlkList = NULL;
|
||||
FILE *File;
|
||||
LANGUAGE_LIST *Lang;
|
||||
EFI_HII_STRING_PACKAGE_HDR *StrPkgHdr;
|
||||
SPkgBlkBuffer *BlkList;
|
||||
WCHAR_STRING_LIST *LOIPtr;
|
||||
|
||||
if (FileName == NULL) {
|
||||
return STATUS_ERROR;
|
||||
@@ -2577,18 +2579,26 @@ StringDBCreateHiiExportPack (
|
||||
}
|
||||
|
||||
for (Lang = mDBData.LanguageList; Lang != NULL; Lang = Lang->Next) {
|
||||
if (StringDBGenStrPkgHdrAndBlkList(Lang, &StrPkgHdr, &BlkList) != STATUS_SUCCESS) {
|
||||
fclose (File);
|
||||
return STATUS_SUCCESS;
|
||||
for (LOIPtr = LanguagesOfInterest; LOIPtr != NULL; LOIPtr = LOIPtr->Next) {
|
||||
if (wcscmp (LOIPtr->Str, Lang->LanguageName) == 0) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
StrPkgWriteHdrBinary (File, StrPkgHdr);
|
||||
StrPkgWriteBlkListBinary (File, BlkList);
|
||||
if ((LanguagesOfInterest == NULL) ||
|
||||
(LanguagesOfInterest != NULL && LOIPtr != NULL)) {
|
||||
if (StringDBGenStrPkgHdrAndBlkList(Lang, &StrPkgHdr, &BlkList) != STATUS_SUCCESS) {
|
||||
fclose (File);
|
||||
return STATUS_SUCCESS;
|
||||
}
|
||||
|
||||
StrPkgHdrFree (StrPkgHdr);
|
||||
StrPkgBlkBufferListFree (BlkList);
|
||||
StrPkgWriteHdrBinary (File, StrPkgHdr);
|
||||
StrPkgWriteBlkListBinary (File, BlkList);
|
||||
|
||||
StrPkgHdrFree (StrPkgHdr);
|
||||
StrPkgBlkBufferListFree (BlkList);
|
||||
}
|
||||
}
|
||||
|
||||
fclose (File);
|
||||
return STATUS_SUCCESS;
|
||||
}
|
||||
@@ -2605,16 +2615,18 @@ static const char *gSourceFileHeader[] = {
|
||||
STATUS
|
||||
StringDBDumpCStrings (
|
||||
INT8 *BaseName,
|
||||
INT8 *FileName
|
||||
INT8 *FileName,
|
||||
WCHAR_STRING_LIST *LanguagesOfInterest
|
||||
)
|
||||
{
|
||||
EFI_STATUS Status;
|
||||
FILE *File = NULL;
|
||||
LANGUAGE_LIST *Lang = NULL;
|
||||
EFI_HII_STRING_PACKAGE_HDR **StrPkgHdr = NULL;
|
||||
SPkgBlkBuffer **BlkList = NULL;
|
||||
FILE *File;
|
||||
LANGUAGE_LIST *Lang;
|
||||
EFI_HII_STRING_PACKAGE_HDR **StrPkgHdr;
|
||||
SPkgBlkBuffer **BlkList;
|
||||
UINT32 Index;
|
||||
UINT32 LangNumber = 0;
|
||||
UINT32 LangNumber;
|
||||
WCHAR_STRING_LIST *LOIPtr;
|
||||
|
||||
if ((BaseName == NULL) || (FileName == NULL)) {
|
||||
return STATUS_ERROR;
|
||||
@@ -2631,14 +2643,36 @@ StringDBDumpCStrings (
|
||||
BlkList = (SPkgBlkBuffer **) malloc (sizeof (SPkgBlkBuffer *) * LangNumber);
|
||||
for (Index = 0; Index < LangNumber; Index++) {
|
||||
StrPkgHdr[Index] = NULL;
|
||||
BlkList[Index] = NULL;
|
||||
BlkList[Index] = NULL;
|
||||
}
|
||||
|
||||
for (Index = 0, Lang = mDBData.LanguageList; Lang != NULL; Lang = Lang->Next, Index++) {
|
||||
Status = StringDBGenStrPkgHdrAndBlkList(Lang, &StrPkgHdr[Index], &BlkList[Index]);
|
||||
if (EFI_ERROR(Status)) {
|
||||
return Status;
|
||||
for (Index = 0, Lang = mDBData.LanguageList; Lang != NULL; Lang = Lang->Next) {
|
||||
for (LOIPtr = LanguagesOfInterest; LOIPtr != NULL; LOIPtr = LOIPtr->Next) {
|
||||
if (wcscmp (LOIPtr->Str, Lang->LanguageName) == 0) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
if ((LanguagesOfInterest == NULL) ||
|
||||
(LanguagesOfInterest != NULL && LOIPtr != NULL)) {
|
||||
Status = StringDBGenStrPkgHdrAndBlkList(Lang, &StrPkgHdr[Index], &BlkList[Index]);
|
||||
Index++;
|
||||
if (EFI_ERROR(Status)) {
|
||||
free (StrPkgHdr);
|
||||
free (BlkList);
|
||||
return STATUS_ERROR;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
// Update LangNumber after filter
|
||||
//
|
||||
LangNumber = Index;
|
||||
|
||||
if (LangNumber == 0) {
|
||||
free (StrPkgHdr);
|
||||
free (BlkList);
|
||||
return STATUS_SUCCESS;
|
||||
}
|
||||
|
||||
if ((File = fopen (FileName, "w")) == NULL) {
|
||||
@@ -2657,11 +2691,9 @@ StringDBDumpCStrings (
|
||||
//
|
||||
StrPkgWirteArrayLength (File, LangNumber, StrPkgHdr);
|
||||
|
||||
for (Index = 0, Lang = mDBData.LanguageList; Lang != NULL; Lang = Lang->Next, Index++) {
|
||||
if (StrPkgHdr[Index] != NULL) {
|
||||
StrPkgWriteHdrCFile (File, StrPkgHdr[Index]);
|
||||
StrPkgWriteBlkListCFile (File, BlkList[Index], (Lang->Next == NULL) ? TRUE : FALSE);
|
||||
}
|
||||
for (Index = 0; Index < LangNumber; Index++) {
|
||||
StrPkgWriteHdrCFile (File, StrPkgHdr[Index]);
|
||||
StrPkgWriteBlkListCFile (File, BlkList[Index], (Index == LangNumber - 1) ? TRUE : FALSE);
|
||||
|
||||
StrPkgHdrFree (StrPkgHdr[Index]);
|
||||
StrPkgBlkBufferListFree (BlkList[Index]);
|
||||
@@ -2670,5 +2702,7 @@ StringDBDumpCStrings (
|
||||
fprintf (File, "\n};\n");
|
||||
|
||||
fclose (File);
|
||||
free (StrPkgHdr);
|
||||
free (BlkList);
|
||||
return STATUS_SUCCESS;
|
||||
}
|
||||
|
@@ -1,6 +1,6 @@
|
||||
/*++
|
||||
|
||||
Copyright (c) 2004, Intel Corporation. All rights reserved.<BR>
|
||||
Copyright (c) 2004 - 2010, 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
|
||||
@@ -134,11 +134,13 @@ typedef struct _SPkgBlkBuffer {
|
||||
void
|
||||
StringDBConstructor (
|
||||
void
|
||||
);
|
||||
)
|
||||
;
|
||||
void
|
||||
StringDBDestructor (
|
||||
void
|
||||
);
|
||||
)
|
||||
;
|
||||
|
||||
STATUS
|
||||
StringDBAddString (
|
||||
@@ -148,12 +150,14 @@ StringDBAddString (
|
||||
WCHAR *String,
|
||||
BOOLEAN Format,
|
||||
UINT16 Flags
|
||||
);
|
||||
)
|
||||
;
|
||||
|
||||
STATUS
|
||||
StringDBSetScope (
|
||||
WCHAR *Scope
|
||||
);
|
||||
)
|
||||
;
|
||||
|
||||
#define STRING_FLAGS_REFERENCED 0x0001 // if referenced somewhere
|
||||
#define STRING_FLAGS_UNDEFINED 0x0002 // if we added it for padding purposes
|
||||
@@ -167,72 +171,92 @@ StringDBAddStringIdentifier (
|
||||
WCHAR *StringIdentifier,
|
||||
UINT16 *NewId,
|
||||
UINT16 Flags
|
||||
);
|
||||
)
|
||||
;
|
||||
|
||||
STATUS
|
||||
StringDBReadDatabase (
|
||||
INT8 *DBFileName,
|
||||
BOOLEAN IgnoreIfNotExist,
|
||||
BOOLEAN Verbose
|
||||
);
|
||||
)
|
||||
;
|
||||
|
||||
STATUS
|
||||
StringDBWriteDatabase (
|
||||
INT8 *DBFileName,
|
||||
BOOLEAN Verbose
|
||||
);
|
||||
)
|
||||
;
|
||||
|
||||
STATUS
|
||||
StringDBDumpDatabase (
|
||||
INT8 *DBFileName,
|
||||
INT8 *OutputFileName,
|
||||
BOOLEAN Verbose
|
||||
);
|
||||
)
|
||||
;
|
||||
|
||||
STATUS
|
||||
StringDBAddLanguage (
|
||||
WCHAR *LanguageName,
|
||||
WCHAR *PrintableLanguageName,
|
||||
WCHAR *SecondaryLanguageList
|
||||
);
|
||||
)
|
||||
;
|
||||
|
||||
STATUS
|
||||
StringDBAddSecondaryLanguage (
|
||||
WCHAR *LanguageName,
|
||||
WCHAR *SecondaryLanguageList
|
||||
);
|
||||
)
|
||||
;
|
||||
|
||||
STATUS
|
||||
StringDBDumpCStrings (
|
||||
INT8 *BaseName,
|
||||
INT8 *FileName
|
||||
);
|
||||
INT8 *FileName,
|
||||
WCHAR_STRING_LIST *LanguagesOfInterests
|
||||
)
|
||||
;
|
||||
|
||||
STATUS
|
||||
StringDBCreateHiiExportPack (
|
||||
INT8 *OutputFileName,
|
||||
WCHAR_STRING_LIST *LanguagesOfInterests
|
||||
)
|
||||
;
|
||||
|
||||
STATUS
|
||||
StringDBDumpStringDefines (
|
||||
INT8 *FileName,
|
||||
INT8 *BaseName
|
||||
);
|
||||
)
|
||||
;
|
||||
|
||||
STATUS
|
||||
StringDBSetCurrentLanguage (
|
||||
WCHAR *LanguageName
|
||||
);
|
||||
)
|
||||
;
|
||||
|
||||
STATUS
|
||||
StringDBSetStringReferenced (
|
||||
INT8 *StringIdentifierName,
|
||||
BOOLEAN IgnoreNotFound
|
||||
);
|
||||
)
|
||||
;
|
||||
|
||||
void
|
||||
StringDBFormatString (
|
||||
WCHAR *String
|
||||
);
|
||||
)
|
||||
;
|
||||
|
||||
LANGUAGE_LIST *
|
||||
StringDBFindLanguageList (
|
||||
WCHAR *LanguageName
|
||||
);
|
||||
)
|
||||
;
|
||||
|
||||
#endif // #ifndef _STRING_DB_H_
|
||||
|
@@ -1,6 +1,6 @@
|
||||
/*++
|
||||
|
||||
Copyright (c) 2004 - 2007, Intel Corporation. All rights reserved.<BR>
|
||||
Copyright (c) 2004 - 2010, 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
|
||||
@@ -15,8 +15,6 @@ Module Name:
|
||||
|
||||
Abstract:
|
||||
|
||||
Defines and prototypes for the UEFI VFR compiler internal use.
|
||||
|
||||
--*/
|
||||
|
||||
#ifndef _EFIVFR_H_
|
||||
|
@@ -11,7 +11,7 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
|
||||
|
||||
Module Name:
|
||||
|
||||
VfrCompiler.cpp
|
||||
VfrCompiler.cpp
|
||||
|
||||
Abstract:
|
||||
|
||||
@@ -41,7 +41,7 @@ CVfrCompiler::IS_RUN_STATUS (
|
||||
|
||||
VOID
|
||||
CVfrCompiler::OptionInitialization (
|
||||
IN INT32 Argc,
|
||||
IN INT32 Argc,
|
||||
IN INT8 **Argv
|
||||
)
|
||||
{
|
||||
@@ -57,6 +57,7 @@ CVfrCompiler::OptionInitialization (
|
||||
mOptions.PreprocessorOutputFileName[0] = '\0';
|
||||
mOptions.VfrBaseFileName[0] = '\0';
|
||||
mOptions.IncludePaths = NULL;
|
||||
mOptions.SkipCPreprocessor = FALSE;
|
||||
mOptions.CPreprocessorOptions = NULL;
|
||||
|
||||
for (Index = 1; (Index < Argc) && (Argv[Index][0] == '-'); Index++) {
|
||||
@@ -70,7 +71,7 @@ CVfrCompiler::OptionInitialization (
|
||||
} else if (_stricmp(Argv[Index], "-i") == 0) {
|
||||
Index++;
|
||||
if ((Index >= Argc) || (Argv[Index][0] == '-')) {
|
||||
printf ("%s -i - missing path argument\n", PROGRAM_NAME);
|
||||
printf ("%s -i - missing path argument\n", UTILITY_NAME);
|
||||
goto Fail;
|
||||
}
|
||||
|
||||
@@ -78,30 +79,33 @@ CVfrCompiler::OptionInitialization (
|
||||
} else if (_stricmp(Argv[Index], "-od") == 0) {
|
||||
Index++;
|
||||
if ((Index >= Argc) || (Argv[Index][0] == '-')) {
|
||||
printf ("%s -od - missing output directory name\n", PROGRAM_NAME);
|
||||
printf ("%s -od - missing output directory name\n", UTILITY_NAME);
|
||||
goto Fail;
|
||||
}
|
||||
strcpy (mOptions.OutputDirectory, Argv[Index]);
|
||||
strcat (mOptions.OutputDirectory, "\\");
|
||||
} else if (_stricmp(Argv[Index], "-ibin") == 0) {
|
||||
mOptions.CreateIfrPkgFile = TRUE;
|
||||
} else if (_stricmp(Argv[Index], "-nostrings") == 0) {
|
||||
} else if (_stricmp(Argv[Index], "-nopp") == 0) {
|
||||
mOptions.SkipCPreprocessor = TRUE;
|
||||
} else if (_stricmp(Argv[Index], "-ppflag") == 0) {
|
||||
Index++;
|
||||
if ((Index >= Argc) || (Argv[Index][0] == '-')) {
|
||||
printf ("%s -od - missing C-preprocessor argument\n", PROGRAM_NAME);
|
||||
printf ("%s -od - missing C-preprocessor argument\n", UTILITY_NAME);
|
||||
goto Fail;
|
||||
}
|
||||
|
||||
AppendCPreprocessorOptions (Argv[Index]);
|
||||
} else {
|
||||
printf ("%s unrecognized option %s\n", PROGRAM_NAME, Argv[Index]);
|
||||
printf ("%s unrecognized option %s\n", UTILITY_NAME, Argv[Index]);
|
||||
Usage ();
|
||||
goto Fail;
|
||||
}
|
||||
}
|
||||
|
||||
if (Index != Argc - 1) {
|
||||
printf ("%s must specify VFR file name", PROGRAM_NAME);
|
||||
printf ("%s must specify VFR file name\n", UTILITY_NAME);
|
||||
Usage ();
|
||||
goto Fail;
|
||||
} else {
|
||||
@@ -140,7 +144,7 @@ Fail:
|
||||
if (mOptions.IncludePaths != NULL) {
|
||||
delete mOptions.IncludePaths;
|
||||
mOptions.IncludePaths = NULL;
|
||||
}
|
||||
}
|
||||
if (mOptions.CPreprocessorOptions != NULL) {
|
||||
delete mOptions.CPreprocessorOptions;
|
||||
mOptions.CPreprocessorOptions = NULL;
|
||||
@@ -161,7 +165,7 @@ CVfrCompiler::AppendIncludePath (
|
||||
}
|
||||
IncludePaths = new INT8[Len];
|
||||
if (IncludePaths == NULL) {
|
||||
printf ("%s memory allocation failure\n", PROGRAM_NAME);
|
||||
printf ("%s memory allocation failure\n", UTILITY_NAME);
|
||||
return;
|
||||
}
|
||||
IncludePaths[0] = '\0';
|
||||
@@ -190,7 +194,7 @@ CVfrCompiler::AppendCPreprocessorOptions (
|
||||
}
|
||||
Opt = new INT8[Len];
|
||||
if (Opt == NULL) {
|
||||
printf ("%s memory allocation failure\n", PROGRAM_NAME);
|
||||
printf ("%s memory allocation failure\n", UTILITY_NAME);
|
||||
return;
|
||||
}
|
||||
Opt[0] = 0;
|
||||
@@ -217,7 +221,11 @@ CVfrCompiler::SetBaseFileName (
|
||||
}
|
||||
|
||||
pFileName = mOptions.VfrFileName;
|
||||
while ((pPath = strchr (pFileName, '\\')) != NULL) {
|
||||
while (
|
||||
((pPath = strchr (pFileName, '\\')) != NULL) ||
|
||||
((pPath = strchr (pFileName, '/')) != NULL)
|
||||
)
|
||||
{
|
||||
pFileName = pPath + 1;
|
||||
}
|
||||
|
||||
@@ -300,7 +308,7 @@ CVfrCompiler::SetRecordListFileName (
|
||||
}
|
||||
|
||||
CVfrCompiler::CVfrCompiler (
|
||||
IN INT32 Argc,
|
||||
IN INT32 Argc,
|
||||
IN INT8 **Argv
|
||||
)
|
||||
{
|
||||
@@ -333,35 +341,40 @@ CVfrCompiler::~CVfrCompiler (
|
||||
SET_RUN_STATUS(STATUS_DEAD);
|
||||
}
|
||||
|
||||
VOID
|
||||
VOID
|
||||
CVfrCompiler::Usage (
|
||||
VOID
|
||||
)
|
||||
{
|
||||
UINT32 Index;
|
||||
CONST INT8 *Help[] = {
|
||||
" ",
|
||||
"VfrCompile version " VFR_COMPILER_VERSION,
|
||||
" ",
|
||||
" Usage: VfrCompile {options} [VfrFile]",
|
||||
" ",
|
||||
" where options include:",
|
||||
" -? or -h prints this help",
|
||||
" -l create an output IFR listing file",
|
||||
" -i IncPath add IncPath to the search path for VFR included files",
|
||||
" -od OutputDir deposit all output files to directory OutputDir (default=cwd)",
|
||||
" -ibin create an IFR HII pack file"
|
||||
" -ppflag C-preprocessor argument",
|
||||
" where parameters include:",
|
||||
" VfrFile name of the input VFR script file",
|
||||
" ",
|
||||
int Index;
|
||||
const char *Str[] = {
|
||||
UTILITY_NAME" "UTILITY_VERSION" - Intel UEFI VFR Compiler Utility",
|
||||
" Copyright (C), 2004 - 2008 Intel Corporation",
|
||||
#if ( defined(UTILITY_BUILD) && defined(UTILITY_VENDOR) )
|
||||
" Built from "UTILITY_BUILD", project of "UTILITY_VENDOR,
|
||||
#endif
|
||||
"",
|
||||
"Usage:",
|
||||
" "UTILITY_NAME" [OPTION] VFRFILE",
|
||||
"Description:",
|
||||
" Compile VFRFILE.",
|
||||
"Options:",
|
||||
" -? or -h print this help",
|
||||
" -l create an output IFR listing file",
|
||||
" -i IncPath add IncPath to the search path for VFR included files",
|
||||
" -od OutputDir deposit all output files to directory OutputDir (default=cwd)",
|
||||
" -ibin create an IFR HII pack file",
|
||||
" -ppflag CFlags pass Flags as C-preprocessor-flag",
|
||||
" -v or -version print version information",
|
||||
NULL
|
||||
};
|
||||
for (Index = 0; Help[Index] != NULL; Index++) {
|
||||
fprintf (stdout, "%s\n", Help[Index]);
|
||||
};
|
||||
|
||||
for (Index = 0; Str[Index] != NULL; Index++) {
|
||||
fprintf (stdout, "%s\n", Str[Index]);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
VOID
|
||||
CVfrCompiler::PreProcess (
|
||||
VOID
|
||||
@@ -375,8 +388,12 @@ CVfrCompiler::PreProcess (
|
||||
goto Fail;
|
||||
}
|
||||
|
||||
if (mOptions.SkipCPreprocessor == TRUE) {
|
||||
goto Out;
|
||||
}
|
||||
|
||||
if ((pVfrFile = fopen (mOptions.VfrFileName, "r")) == NULL) {
|
||||
printf ("%s could not open input VFR file - %s\n", PROGRAM_NAME, mOptions.VfrFileName);
|
||||
printf ("%s could not open input VFR file - %s\n", UTILITY_NAME, mOptions.VfrFileName);
|
||||
goto Fail;
|
||||
}
|
||||
fclose (pVfrFile);
|
||||
@@ -392,7 +409,7 @@ CVfrCompiler::PreProcess (
|
||||
|
||||
PreProcessCmd = new INT8[CmdLen + 10];
|
||||
if (PreProcessCmd == NULL) {
|
||||
printf ("%s could not allocate memory\n", PROGRAM_NAME);
|
||||
printf ("%s could not allocate memory\n", UTILITY_NAME);
|
||||
goto Fail;
|
||||
}
|
||||
strcpy (PreProcessCmd, mPreProcessCmd), strcat (PreProcessCmd, " ");
|
||||
@@ -407,11 +424,13 @@ CVfrCompiler::PreProcess (
|
||||
strcat (PreProcessCmd, mOptions.PreprocessorOutputFileName);
|
||||
|
||||
if (system (PreProcessCmd) != 0) {
|
||||
printf ("%s failed to spawn C preprocessor on VFR file \n\t - %s\n", PROGRAM_NAME, PreProcessCmd);
|
||||
printf ("%s failed to spawn C preprocessor on VFR file \n\t - %s\n", UTILITY_NAME, PreProcessCmd);
|
||||
goto Fail;
|
||||
}
|
||||
|
||||
delete PreProcessCmd;
|
||||
|
||||
Out:
|
||||
SET_RUN_STATUS (STATUS_PREPROCESSED);
|
||||
return;
|
||||
|
||||
@@ -429,22 +448,27 @@ CVfrCompiler::Compile (
|
||||
VOID
|
||||
)
|
||||
{
|
||||
FILE *VfrFile = NULL;
|
||||
FILE *pInFile = NULL;
|
||||
INT8 *InFileName = NULL;
|
||||
|
||||
if (!IS_RUN_STATUS(STATUS_PREPROCESSED)) {
|
||||
goto Fail;
|
||||
}
|
||||
|
||||
if ((VfrFile = fopen (mOptions.PreprocessorOutputFileName, "r")) == NULL) {
|
||||
printf ("%s failed to open input VFR preprocessor output file - %s\n", PROGRAM_NAME, mOptions.PreprocessorOutputFileName);
|
||||
InFileName = (mOptions.SkipCPreprocessor == TRUE) ? mOptions.VfrFileName : mOptions.PreprocessorOutputFileName;
|
||||
|
||||
gCVfrErrorHandle.SetInputFile (InFileName);
|
||||
|
||||
if ((pInFile = fopen (InFileName, "r")) == NULL) {
|
||||
printf ("%s failed to open input file - %s\n", UTILITY_NAME, InFileName);
|
||||
goto Fail;
|
||||
}
|
||||
|
||||
if (VfrParserStart (VfrFile) != 0) {
|
||||
if (VfrParserStart (pInFile) != 0) {
|
||||
goto Fail;
|
||||
}
|
||||
|
||||
fclose (VfrFile);
|
||||
fclose (pInFile);
|
||||
|
||||
if (gCFormPkg.HavePendingUnassigned () == TRUE) {
|
||||
gCFormPkg.PendingAssignPrintAll ();
|
||||
@@ -456,11 +480,11 @@ CVfrCompiler::Compile (
|
||||
|
||||
Fail:
|
||||
if (!IS_RUN_STATUS(STATUS_DEAD)) {
|
||||
printf ("%s compile error!\n", PROGRAM_NAME);
|
||||
printf ("%s compile error!\n", UTILITY_NAME);
|
||||
SET_RUN_STATUS (STATUS_FAILED);
|
||||
}
|
||||
if (VfrFile != NULL) {
|
||||
fclose (VfrFile);
|
||||
if (pInFile != NULL) {
|
||||
fclose (pInFile);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -477,7 +501,7 @@ CVfrCompiler::GenBinary (
|
||||
|
||||
if (mOptions.CreateIfrPkgFile == TRUE) {
|
||||
if ((pFile = fopen (mOptions.PkgOutputFileName, "wb")) == NULL) {
|
||||
printf ("can not open PkgFileName\n", mOptions.PkgOutputFileName);
|
||||
printf ("can not open %s\n", mOptions.PkgOutputFileName);
|
||||
goto Fail;
|
||||
}
|
||||
if (gCFormPkg.BuildPkg (pFile) != VFR_RETURN_SUCCESS) {
|
||||
@@ -548,27 +572,30 @@ CVfrCompiler::GenRecordListFile (
|
||||
VOID
|
||||
)
|
||||
{
|
||||
FILE *pInFile = NULL;
|
||||
FILE *pOutFile = NULL;
|
||||
INT8 *InFileName = NULL;
|
||||
FILE *pInFile = NULL;
|
||||
FILE *pOutFile = NULL;
|
||||
INT8 LineBuf[MAX_LINE_LEN];
|
||||
UINT32 LineNo;
|
||||
|
||||
InFileName = (mOptions.SkipCPreprocessor == TRUE) ? mOptions.VfrFileName : mOptions.PreprocessorOutputFileName;
|
||||
|
||||
if (mOptions.CreateRecordListFile == TRUE) {
|
||||
if ((mOptions.PreprocessorOutputFileName[0] == '\0') || (mOptions.RecordListFile[0] == '\0')) {
|
||||
if ((InFileName[0] == '\0') || (mOptions.RecordListFile[0] == '\0')) {
|
||||
return;
|
||||
}
|
||||
|
||||
if ((pInFile = fopen (mOptions.PreprocessorOutputFileName, "r")) == NULL) {
|
||||
printf ("%s failed to open input VFR preprocessor output file - %s\n", PROGRAM_NAME, mOptions.PreprocessorOutputFileName);
|
||||
if ((pInFile = fopen (InFileName, "r")) == NULL) {
|
||||
printf ("%s failed to open input VFR preprocessor output file - %s\n", UTILITY_NAME, InFileName);
|
||||
return;
|
||||
}
|
||||
|
||||
if ((pOutFile = fopen (mOptions.RecordListFile, "w")) == NULL) {
|
||||
printf ("%s failed to open record list file for writing - %s\n", PROGRAM_NAME, mOptions.RecordListFile);
|
||||
printf ("%s failed to open record list file for writing - %s\n", UTILITY_NAME, mOptions.RecordListFile);
|
||||
goto Err1;
|
||||
}
|
||||
|
||||
fprintf (pOutFile, "//\n// VFR compiler version " VFR_COMPILER_VERSION "\n//\n");
|
||||
fprintf (pOutFile, "//\n// VFR compiler version " UTILITY_VERSION "\n//\n");
|
||||
LineNo = 0;
|
||||
while (!feof (pInFile)) {
|
||||
if (fgets (LineBuf, MAX_LINE_LEN, pInFile) != NULL) {
|
||||
@@ -590,7 +617,7 @@ Err1:
|
||||
|
||||
INT32
|
||||
main (
|
||||
IN INT32 Argc,
|
||||
IN INT32 Argc,
|
||||
IN INT8 **Argv
|
||||
)
|
||||
{
|
||||
|
@@ -1,17 +1,17 @@
|
||||
/*++
|
||||
|
||||
Copyright (c) 2004 - 2009, Intel Corporation. All rights reserved.<BR>
|
||||
Copyright (c) 2004 - 2010, 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.
|
||||
|
||||
Module Name:
|
||||
|
||||
VfrCompiler.h
|
||||
VfrCompiler.h
|
||||
|
||||
Abstract:
|
||||
|
||||
@@ -26,8 +26,8 @@ Abstract:
|
||||
#include "VfrFormPkg.h"
|
||||
#include "VfrUtilityLib.h"
|
||||
|
||||
#define PROGRAM_NAME "VfrCompile"
|
||||
#define VFR_COMPILER_VERSION "UEFI 2.1"
|
||||
#define UTILITY_NAME "VfrCompile"
|
||||
#define UTILITY_VERSION "v1.1"
|
||||
|
||||
//
|
||||
// This is how we invoke the C preprocessor on the VFR source file
|
||||
@@ -56,6 +56,7 @@ typedef struct {
|
||||
INT8 PreprocessorOutputFileName[MAX_PATH];
|
||||
INT8 VfrBaseFileName[MAX_PATH]; // name of input VFR file with no path or extension
|
||||
INT8 *IncludePaths;
|
||||
bool SkipCPreprocessor;
|
||||
INT8 *CPreprocessorOptions;
|
||||
} OPTIONS;
|
||||
|
||||
|
@@ -11,7 +11,7 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
|
||||
|
||||
Module Name:
|
||||
|
||||
VfrError.cpp
|
||||
VfrError.cpp
|
||||
|
||||
Abstract:
|
||||
|
||||
@@ -25,33 +25,36 @@ Abstract:
|
||||
static SVFR_ERROR_HANDLE VFR_ERROR_HANDLE_TABLE [] = {
|
||||
{ VFR_RETURN_SUCCESS, NULL },
|
||||
{ VFR_RETURN_ERROR_SKIPED, NULL },
|
||||
{ VFR_RETURN_FATAL_ERROR, "fatal error!!" },
|
||||
{ VFR_RETURN_FATAL_ERROR, ": fatal error!!" },
|
||||
|
||||
{ VFR_RETURN_MISMATCHED, "unexpected token" },
|
||||
{ VFR_RETURN_INVALID_PARAMETER, "Invalid parameter" },
|
||||
{ VFR_RETURN_OUT_FOR_RESOURCES, "system out of memory" },
|
||||
{ VFR_RETURN_UNSUPPORTED, "unsupported" },
|
||||
{ VFR_RETURN_REDEFINED, "already defined" },
|
||||
{ VFR_RETURN_FORMID_REDEFINED, "form id already defined" },
|
||||
{ VFR_RETURN_QUESTIONID_REDEFINED, "question id already defined" },
|
||||
{ VFR_RETURN_VARSTOREID_REDEFINED, "varstore id already defined" },
|
||||
{ VFR_RETURN_UNDEFINED, "undefined" },
|
||||
{ VFR_RETURN_VAR_NOTDEFINED_BY_QUESTION, "some variable has not defined by a question"},
|
||||
{ VFR_RETURN_GET_EFIVARSTORE_ERROR, "get efi varstore error"},
|
||||
{ VFR_RETURN_EFIVARSTORE_USE_ERROR, "can not use the efi varstore like this" },
|
||||
{ VFR_RETURN_EFIVARSTORE_SIZE_ERROR, "unsupport efi varstore size should be <= 8 bytes" },
|
||||
{ VFR_RETURN_GET_NVVARSTORE_ERROR, "get name value varstore error" },
|
||||
{ VFR_RETURN_QVAR_REUSE, "variable reused by more than one question" },
|
||||
{ VFR_RETURN_FLAGS_UNSUPPORTED, "flags unsupported" },
|
||||
{ VFR_RETURN_ERROR_ARRARY_NUM, "array number error" },
|
||||
{ VFR_RETURN_DATA_STRING_ERROR, "data field string error or not support"},
|
||||
{ VFR_RETURN_CODEUNDEFINED, "Undefined Error Code" }
|
||||
{ VFR_RETURN_MISMATCHED, ": unexpected token" },
|
||||
{ VFR_RETURN_INVALID_PARAMETER, ": invalid parameter" },
|
||||
{ VFR_RETURN_OUT_FOR_RESOURCES, ": system out of memory" },
|
||||
{ VFR_RETURN_UNSUPPORTED, ": unsupported" },
|
||||
{ VFR_RETURN_REDEFINED, ": already defined" },
|
||||
{ VFR_RETURN_FORMID_REDEFINED, ": form id already defined" },
|
||||
{ VFR_RETURN_QUESTIONID_REDEFINED, ": question id already defined" },
|
||||
{ VFR_RETURN_VARSTOREID_REDEFINED, ": varstore id already defined" },
|
||||
{ VFR_RETURN_UNDEFINED, ": undefined" },
|
||||
{ VFR_RETURN_VAR_NOTDEFINED_BY_QUESTION, ": some variable has not defined by a question"},
|
||||
{ VFR_RETURN_GET_EFIVARSTORE_ERROR, ": get efi varstore error"},
|
||||
{ VFR_RETURN_EFIVARSTORE_USE_ERROR, ": can not use the efi varstore like this" },
|
||||
{ VFR_RETURN_EFIVARSTORE_SIZE_ERROR, ": unsupport efi varstore size should be <= 8 bytes" },
|
||||
{ VFR_RETURN_GET_NVVARSTORE_ERROR, ": get name value varstore error" },
|
||||
{ VFR_RETURN_QVAR_REUSE, ": variable reused by more than one question" },
|
||||
{ VFR_RETURN_FLAGS_UNSUPPORTED, ": flags unsupported" },
|
||||
{ VFR_RETURN_ERROR_ARRARY_NUM, ": array number error" },
|
||||
{ VFR_RETURN_DATA_STRING_ERROR, ": data field string error or not support"},
|
||||
{ VFR_RETURN_DEFAULT_VALUE_REDEFINED, ": default value re-defined with different value"},
|
||||
{ VFR_RETURN_CONSTANT_ONLY, ": only constant is allowed in the expression"},
|
||||
{ VFR_RETURN_CODEUNDEFINED, ": undefined Error Code" }
|
||||
};
|
||||
|
||||
CVfrErrorHandle::CVfrErrorHandle (
|
||||
VOID
|
||||
)
|
||||
{
|
||||
mInputFileName = NULL;
|
||||
mScopeRecordListHead = NULL;
|
||||
mScopeRecordListTail = NULL;
|
||||
mVfrErrorHandleTable = VFR_ERROR_HANDLE_TABLE;
|
||||
@@ -63,6 +66,10 @@ CVfrErrorHandle::~CVfrErrorHandle (
|
||||
{
|
||||
SVfrFileScopeRecord *pNode = NULL;
|
||||
|
||||
if (mInputFileName != NULL) {
|
||||
delete mInputFileName;
|
||||
}
|
||||
|
||||
while (mScopeRecordListHead != NULL) {
|
||||
pNode = mScopeRecordListHead;
|
||||
mScopeRecordListHead = mScopeRecordListHead->mNext;
|
||||
@@ -74,8 +81,19 @@ CVfrErrorHandle::~CVfrErrorHandle (
|
||||
mVfrErrorHandleTable = NULL;
|
||||
}
|
||||
|
||||
VOID
|
||||
CVfrErrorHandle::SetInputFile (
|
||||
IN INT8 *InputFile
|
||||
)
|
||||
{
|
||||
if (InputFile != NULL) {
|
||||
mInputFileName = new INT8[strlen(InputFile) + 1];
|
||||
strcpy (mInputFileName, InputFile);
|
||||
}
|
||||
}
|
||||
|
||||
SVfrFileScopeRecord::SVfrFileScopeRecord (
|
||||
IN INT8 *Record,
|
||||
IN INT8 *Record,
|
||||
IN UINT32 LineNum
|
||||
)
|
||||
{
|
||||
@@ -116,7 +134,7 @@ SVfrFileScopeRecord::~SVfrFileScopeRecord (
|
||||
|
||||
VOID
|
||||
CVfrErrorHandle::ParseFileScopeRecord (
|
||||
IN INT8 *Record,
|
||||
IN INT8 *Record,
|
||||
IN UINT32 WholeScopeLine
|
||||
)
|
||||
{
|
||||
@@ -155,6 +173,15 @@ CVfrErrorHandle::GetFileNameLineNum (
|
||||
*FileName = NULL;
|
||||
*FileLine = 0xFFFFFFFF;
|
||||
|
||||
//
|
||||
// Some errors occur before scope record list been built.
|
||||
//
|
||||
if (mScopeRecordListHead == NULL) {
|
||||
*FileLine = LineNum;
|
||||
*FileName = mInputFileName;
|
||||
return ;
|
||||
}
|
||||
|
||||
for (pNode = mScopeRecordListHead; pNode->mNext != NULL; pNode = pNode->mNext) {
|
||||
if ((LineNum > pNode->mWholeScopeLine) && (pNode->mNext->mWholeScopeLine > LineNum)) {
|
||||
*FileName = pNode->mFileName;
|
||||
@@ -168,9 +195,10 @@ CVfrErrorHandle::GetFileNameLineNum (
|
||||
}
|
||||
|
||||
VOID
|
||||
CVfrErrorHandle::PrintError (
|
||||
CVfrErrorHandle::PrintMsg (
|
||||
IN UINT32 LineNum,
|
||||
IN INT8 *TokName,
|
||||
IN INT8 *MsgType,
|
||||
IN INT8 *ErrorMsg
|
||||
)
|
||||
{
|
||||
@@ -178,7 +206,7 @@ CVfrErrorHandle::PrintError (
|
||||
UINT32 FileLine;
|
||||
|
||||
GetFileNameLineNum (LineNum, &FileName, &FileLine);
|
||||
printf ("%s line %d: error %s %s\n", FileName, FileLine, TokName, ErrorMsg);
|
||||
printf ("%s line %d: %s %s %s\n", FileName, FileLine, MsgType, TokName, ErrorMsg);
|
||||
}
|
||||
|
||||
UINT8
|
||||
|
@@ -11,7 +11,7 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
|
||||
|
||||
Module Name:
|
||||
|
||||
VfrError.h
|
||||
VfrError.h
|
||||
|
||||
Abstract:
|
||||
|
||||
@@ -45,6 +45,8 @@ typedef enum {
|
||||
VFR_RETURN_FLAGS_UNSUPPORTED,
|
||||
VFR_RETURN_ERROR_ARRARY_NUM,
|
||||
VFR_RETURN_DATA_STRING_ERROR,
|
||||
VFR_RETURN_DEFAULT_VALUE_REDEFINED,
|
||||
VFR_RETURN_CONSTANT_ONLY,
|
||||
VFR_RETURN_CODEUNDEFINED
|
||||
} EFI_VFR_RETURN_CODE;
|
||||
|
||||
@@ -65,6 +67,7 @@ struct SVfrFileScopeRecord {
|
||||
|
||||
class CVfrErrorHandle {
|
||||
private:
|
||||
INT8 *mInputFileName;
|
||||
SVFR_ERROR_HANDLE *mVfrErrorHandleTable;
|
||||
SVfrFileScopeRecord *mScopeRecordListHead;
|
||||
SVfrFileScopeRecord *mScopeRecordListTail;
|
||||
@@ -73,10 +76,11 @@ public:
|
||||
CVfrErrorHandle (VOID);
|
||||
~CVfrErrorHandle (VOID);
|
||||
|
||||
VOID SetInputFile (IN INT8 *);
|
||||
VOID ParseFileScopeRecord (IN INT8 *, IN UINT32);
|
||||
VOID GetFileNameLineNum (IN UINT32, OUT INT8 **, OUT UINT32 *);
|
||||
UINT8 HandleError (IN EFI_VFR_RETURN_CODE, IN UINT32 LineNum = 0, IN INT8 *TokName = "\0");
|
||||
VOID PrintError (IN UINT32 LineNum = 0, IN INT8 *TokName = "\0", IN INT8 *ErrorMsg = "\0");
|
||||
VOID PrintMsg (IN UINT32 LineNum = 0, IN INT8 *TokName = "\0", IN INT8 *MsgType = "Error", IN INT8 *ErrorMsg = "\0");
|
||||
};
|
||||
|
||||
#define CHECK_ERROR_RETURN(f, v) do { EFI_VFR_RETURN_CODE r; if ((r = (f)) != (v)) { return r; } } while (0)
|
||||
|
@@ -11,7 +11,7 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
|
||||
|
||||
Module Name:
|
||||
|
||||
VfrFormPkg.cpp
|
||||
VfrFormPkg.cpp
|
||||
|
||||
Abstract:
|
||||
|
||||
@@ -25,25 +25,34 @@ Abstract:
|
||||
*/
|
||||
|
||||
SPendingAssign::SPendingAssign (
|
||||
IN INT8 *Key,
|
||||
IN VOID *Addr,
|
||||
IN UINT32 Len,
|
||||
IN UINT32 LineNo
|
||||
IN INT8 *Key,
|
||||
IN VOID *Addr,
|
||||
IN UINT32 Len,
|
||||
IN UINT32 LineNo,
|
||||
IN INT8 *Msg
|
||||
)
|
||||
{
|
||||
mKey = NULL;
|
||||
mAddr = Addr;
|
||||
mLen = Len;
|
||||
mFlag = PENDING;
|
||||
mLineNo = LineNo;
|
||||
mMsg = NULL;
|
||||
mNext = NULL;
|
||||
|
||||
if (Key != NULL) {
|
||||
mKey = new INT8[strlen (Key) + 1];
|
||||
if (mKey != NULL) {
|
||||
strcpy (mKey, Key);
|
||||
}
|
||||
} else {
|
||||
mKey = NULL;
|
||||
}
|
||||
mAddr = Addr;
|
||||
mLen = Len;
|
||||
mFlag = PENDING;
|
||||
mLineNo = LineNo;
|
||||
mNext = NULL;
|
||||
|
||||
if (Msg != NULL) {
|
||||
mMsg = new INT8[strlen (Msg) + 1];
|
||||
if (mMsg != NULL) {
|
||||
strcpy (mMsg, Msg);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
SPendingAssign::~SPendingAssign (
|
||||
@@ -56,12 +65,15 @@ SPendingAssign::~SPendingAssign (
|
||||
mAddr = NULL;
|
||||
mLen = 0;
|
||||
mLineNo = 0;
|
||||
if (mMsg != NULL) {
|
||||
delete mMsg;
|
||||
}
|
||||
mNext = NULL;
|
||||
}
|
||||
|
||||
VOID
|
||||
SPendingAssign::SetAddrAndLen (
|
||||
IN VOID *Addr,
|
||||
IN VOID *Addr,
|
||||
IN UINT32 LineNo
|
||||
)
|
||||
{
|
||||
@@ -71,7 +83,7 @@ SPendingAssign::SetAddrAndLen (
|
||||
|
||||
VOID
|
||||
SPendingAssign::AssignValue (
|
||||
IN VOID *Addr,
|
||||
IN VOID *Addr,
|
||||
IN UINT32 Len
|
||||
)
|
||||
{
|
||||
@@ -227,7 +239,7 @@ CFormPkg::Close (
|
||||
|
||||
UINT32
|
||||
CFormPkg::Read (
|
||||
IN CHAR8 *Buffer,
|
||||
IN CHAR8 *Buffer,
|
||||
IN UINT32 Size
|
||||
)
|
||||
{
|
||||
@@ -270,7 +282,7 @@ CFormPkg::BuildPkgHdr (
|
||||
return VFR_RETURN_OUT_FOR_RESOURCES;
|
||||
}
|
||||
|
||||
(*PkgHdr)->Type = EFI_HII_PACKAGE_FORM;
|
||||
(*PkgHdr)->Type = EFI_HII_PACKAGE_FORMS;
|
||||
(*PkgHdr)->Length = mPkgLength + sizeof (EFI_HII_PACKAGE_HEADER);
|
||||
return VFR_RETURN_SUCCESS;
|
||||
}
|
||||
@@ -357,7 +369,7 @@ CFormPkg::_WRITE_PKG_END (
|
||||
|
||||
#define BYTES_PRE_LINE 0x10
|
||||
|
||||
EFI_VFR_RETURN_CODE
|
||||
EFI_VFR_RETURN_CODE
|
||||
CFormPkg::GenCFile (
|
||||
IN INT8 *BaseName,
|
||||
IN FILE *pFile
|
||||
@@ -407,15 +419,16 @@ CFormPkg::GenCFile (
|
||||
|
||||
EFI_VFR_RETURN_CODE
|
||||
CFormPkg::AssignPending (
|
||||
IN INT8 *Key,
|
||||
IN VOID *ValAddr,
|
||||
IN INT8 *Key,
|
||||
IN VOID *ValAddr,
|
||||
IN UINT32 ValLen,
|
||||
IN UINT32 LineNo
|
||||
IN UINT32 LineNo,
|
||||
IN INT8 *Msg
|
||||
)
|
||||
{
|
||||
SPendingAssign *pNew;
|
||||
|
||||
pNew = new SPendingAssign (Key, ValAddr, ValLen, LineNo);
|
||||
pNew = new SPendingAssign (Key, ValAddr, ValLen, LineNo, Msg);
|
||||
if (pNew == NULL) {
|
||||
return VFR_RETURN_OUT_FOR_RESOURCES;
|
||||
}
|
||||
@@ -427,8 +440,8 @@ CFormPkg::AssignPending (
|
||||
|
||||
VOID
|
||||
CFormPkg::DoPendingAssign (
|
||||
IN INT8 *Key,
|
||||
IN VOID *ValAddr,
|
||||
IN INT8 *Key,
|
||||
IN VOID *ValAddr,
|
||||
IN UINT32 ValLen
|
||||
)
|
||||
{
|
||||
@@ -470,7 +483,7 @@ CFormPkg::PendingAssignPrintAll (
|
||||
|
||||
for (pNode = PendingAssignList; pNode != NULL; pNode = pNode->mNext) {
|
||||
if (pNode->mFlag == PENDING) {
|
||||
gCVfrErrorHandle.PrintError (pNode->mLineNo, pNode->mKey, "can not assign value because not defined");
|
||||
gCVfrErrorHandle.PrintMsg (pNode->mLineNo, pNode->mKey, "Error", pNode->mMsg);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -492,10 +505,7 @@ SIfrRecord::~SIfrRecord (
|
||||
VOID
|
||||
)
|
||||
{
|
||||
if (mIfrBinBuf != NULL) {
|
||||
delete mIfrBinBuf;
|
||||
mIfrBinBuf = NULL;
|
||||
}
|
||||
mIfrBinBuf = NULL;
|
||||
mLineNo = 0xFFFFFFFF;
|
||||
mOffset = 0xFFFFFFFF;
|
||||
mBinBufLen = 0;
|
||||
@@ -537,8 +547,8 @@ CIfrRecordInfoDB::GetRecordInfoFromIdx (
|
||||
return NULL;
|
||||
}
|
||||
|
||||
for (Idx = (EFI_IFR_RECORDINFO_IDX_START + 1), pNode = mIfrRecordListHead;
|
||||
(Idx != RecordIdx) && (pNode != NULL);
|
||||
for (Idx = (EFI_IFR_RECORDINFO_IDX_START + 1), pNode = mIfrRecordListHead;
|
||||
(Idx != RecordIdx) && (pNode != NULL);
|
||||
Idx++, pNode = pNode->mNext)
|
||||
;
|
||||
|
||||
@@ -547,8 +557,8 @@ CIfrRecordInfoDB::GetRecordInfoFromIdx (
|
||||
|
||||
UINT32
|
||||
CIfrRecordInfoDB::IfrRecordRegister (
|
||||
IN UINT32 LineNo,
|
||||
IN CHAR8 *IfrBinBuf,
|
||||
IN UINT32 LineNo,
|
||||
IN CHAR8 *IfrBinBuf,
|
||||
IN UINT8 BinBufLen,
|
||||
IN UINT32 Offset
|
||||
)
|
||||
@@ -577,7 +587,7 @@ CIfrRecordInfoDB::IfrRecordRegister (
|
||||
|
||||
VOID
|
||||
CIfrRecordInfoDB::IfrRecordInfoUpdate (
|
||||
IN UINT32 RecordIdx,
|
||||
IN UINT32 RecordIdx,
|
||||
IN UINT32 LineNo,
|
||||
IN CHAR8 *BinBuf,
|
||||
IN UINT8 BinBufLen,
|
||||
@@ -585,23 +595,25 @@ CIfrRecordInfoDB::IfrRecordInfoUpdate (
|
||||
)
|
||||
{
|
||||
SIfrRecord *pNode;
|
||||
SIfrRecord *Prev;
|
||||
|
||||
if ((pNode = GetRecordInfoFromIdx (RecordIdx)) == NULL) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (LineNo == 0) {
|
||||
//
|
||||
// Line number is not specified explicitly, try to use line number of previous opcode
|
||||
//
|
||||
Prev = GetRecordInfoFromIdx (RecordIdx - 1);
|
||||
if (Prev != NULL) {
|
||||
LineNo = Prev->mLineNo;
|
||||
}
|
||||
}
|
||||
pNode->mLineNo = LineNo;
|
||||
pNode->mOffset = Offset;
|
||||
pNode->mBinBufLen = BinBufLen;
|
||||
if (BinBuf != NULL) {
|
||||
if (pNode->mIfrBinBuf != NULL) {
|
||||
delete pNode->mIfrBinBuf;
|
||||
}
|
||||
pNode->mIfrBinBuf = new CHAR8[BinBufLen];
|
||||
if (pNode->mIfrBinBuf != NULL) {
|
||||
memcpy (pNode->mIfrBinBuf, BinBuf, BinBufLen);
|
||||
}
|
||||
}
|
||||
pNode->mIfrBinBuf = BinBuf;
|
||||
}
|
||||
|
||||
VOID
|
||||
@@ -626,7 +638,7 @@ CIfrRecordInfoDB::IfrRecordOutput (
|
||||
fprintf (File, ">%08X: ", pNode->mOffset);
|
||||
if (pNode->mIfrBinBuf != NULL) {
|
||||
for (Index = 0; Index < pNode->mBinBufLen; Index++) {
|
||||
fprintf (File, "%02X ", pNode->mIfrBinBuf[Index]);
|
||||
fprintf (File, "%02X ", (UINT8)(pNode->mIfrBinBuf[Index]));
|
||||
}
|
||||
}
|
||||
fprintf (File, "\n");
|
||||
@@ -650,6 +662,7 @@ CIfrObj::_EMIT_PENDING_OBJ (
|
||||
|
||||
if (mObjBinBuf != NULL) {
|
||||
delete mObjBinBuf;
|
||||
mObjBinBuf = ObjBinBuf;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -689,7 +702,7 @@ static struct {
|
||||
{ sizeof (EFI_IFR_DATE), 1 }, // EFI_IFR_DATE_OP
|
||||
{ sizeof (EFI_IFR_TIME), 1 }, // EFI_IFR_TIME_OP
|
||||
{ sizeof (EFI_IFR_STRING), 1 }, // EFI_IFR_STRING_OP
|
||||
{ sizeof (EFI_IFR_REFRESH), 1 }, // EFI_IFR_REFRESH_OP
|
||||
{ sizeof (EFI_IFR_REFRESH), 0 }, // EFI_IFR_REFRESH_OP
|
||||
{ sizeof (EFI_IFR_DISABLE_IF), 1 }, // EFI_IFR_DISABLE_IF_OP - 0x1E
|
||||
{ 0, 0 }, // 0x1F
|
||||
{ sizeof (EFI_IFR_TO_LOWER), 0 }, // EFI_IFR_TO_LOWER_OP - 0x20
|
||||
@@ -829,10 +842,10 @@ CIfrObj::~CIfrObj (
|
||||
UINT8 gScopeCount = 0;
|
||||
|
||||
CIfrOpHeader::CIfrOpHeader (
|
||||
IN UINT8 OpCode,
|
||||
IN UINT8 OpCode,
|
||||
IN VOID *StartAddr,
|
||||
IN UINT8 Length
|
||||
) : mHeader ((EFI_IFR_OP_HEADER *)StartAddr)
|
||||
IN UINT8 Length
|
||||
) : mHeader ((EFI_IFR_OP_HEADER *)StartAddr)
|
||||
{
|
||||
mHeader->OpCode = OpCode;
|
||||
mHeader->Length = (Length == 0) ? gOpcodeSizesScopeTable[OpCode].mSize : Length;
|
||||
|
@@ -11,7 +11,7 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
|
||||
|
||||
Module Name:
|
||||
|
||||
VfrFormPkg.h
|
||||
VfrFormPkg.h
|
||||
|
||||
Abstract:
|
||||
|
||||
@@ -25,6 +25,8 @@ Abstract:
|
||||
#include "VfrError.h"
|
||||
#include "VfrUtilityLib.h"
|
||||
|
||||
#define NO_QST_REFED "no question refered"
|
||||
|
||||
/*
|
||||
* The functions below are used for flags setting
|
||||
*/
|
||||
@@ -75,9 +77,10 @@ struct SPendingAssign {
|
||||
UINT32 mLen;
|
||||
ASSIGN_FLAG mFlag;
|
||||
UINT32 mLineNo;
|
||||
INT8 *mMsg;
|
||||
struct SPendingAssign *mNext;
|
||||
|
||||
SPendingAssign (IN INT8 *, IN VOID *, IN UINT32, IN UINT32);
|
||||
SPendingAssign (IN INT8 *, IN VOID *, IN UINT32, IN UINT32, IN INT8 *);
|
||||
~SPendingAssign ();
|
||||
|
||||
VOID SetAddrAndLen (IN VOID *, IN UINT32);
|
||||
@@ -126,7 +129,7 @@ public:
|
||||
EFI_VFR_RETURN_CODE GenCFile (IN INT8 *, IN FILE *);
|
||||
|
||||
public:
|
||||
EFI_VFR_RETURN_CODE AssignPending (IN INT8 *, IN VOID *, IN UINT32, IN UINT32);
|
||||
EFI_VFR_RETURN_CODE AssignPending (IN INT8 *, IN VOID *, IN UINT32, IN UINT32, IN INT8 *Msg = NULL);
|
||||
VOID DoPendingAssign (IN INT8 *, IN VOID *, IN UINT32);
|
||||
bool HavePendingUnassigned (VOID);
|
||||
VOID PendingAssignPrintAll (VOID);
|
||||
@@ -368,48 +371,159 @@ public:
|
||||
}
|
||||
};
|
||||
|
||||
static CIfrQuestionHeader *gCurrentQuestion = NULL;
|
||||
|
||||
/*
|
||||
* The definition of CIfrMinMaxStepData
|
||||
*/
|
||||
class CIfrMinMaxStepData {
|
||||
private:
|
||||
MINMAXSTEP_DATA *mMinMaxStepData;
|
||||
BOOLEAN ValueIsSet;
|
||||
BOOLEAN IsNumeric;
|
||||
|
||||
public:
|
||||
CIfrMinMaxStepData (MINMAXSTEP_DATA *DataAddr) : mMinMaxStepData (DataAddr) {
|
||||
CIfrMinMaxStepData (MINMAXSTEP_DATA *DataAddr, BOOLEAN NumericOpcode=FALSE) : mMinMaxStepData (DataAddr) {
|
||||
mMinMaxStepData->u64.MinValue = 0;
|
||||
mMinMaxStepData->u64.MaxValue = 0;
|
||||
mMinMaxStepData->u64.Step = 0;
|
||||
ValueIsSet = FALSE;
|
||||
IsNumeric = NumericOpcode;
|
||||
}
|
||||
|
||||
VOID SetMinMaxStepData (IN UINT64 MinValue, IN UINT64 MaxValue, IN UINT64 Step) {
|
||||
mMinMaxStepData->u64.MinValue = MinValue;
|
||||
mMinMaxStepData->u64.MaxValue = MaxValue;
|
||||
mMinMaxStepData->u64.Step = Step;
|
||||
if (!ValueIsSet) {
|
||||
mMinMaxStepData->u64.MinValue = MinValue;
|
||||
mMinMaxStepData->u64.MaxValue = MaxValue;
|
||||
ValueIsSet = TRUE;
|
||||
} else {
|
||||
if (MinValue < mMinMaxStepData->u64.MinValue) {
|
||||
mMinMaxStepData->u64.MinValue = MinValue;
|
||||
}
|
||||
if (MaxValue > mMinMaxStepData->u64.MaxValue) {
|
||||
mMinMaxStepData->u64.MaxValue = MaxValue;
|
||||
}
|
||||
}
|
||||
mMinMaxStepData->u64.Step = Step;
|
||||
}
|
||||
|
||||
VOID SetMinMaxStepData (IN UINT32 MinValue, IN UINT32 MaxValue, IN UINT32 Step) {
|
||||
mMinMaxStepData->u32.MinValue = MinValue;
|
||||
mMinMaxStepData->u32.MaxValue = MaxValue;
|
||||
mMinMaxStepData->u32.Step = Step;
|
||||
if (!ValueIsSet) {
|
||||
mMinMaxStepData->u32.MinValue = MinValue;
|
||||
mMinMaxStepData->u32.MaxValue = MaxValue;
|
||||
ValueIsSet = TRUE;
|
||||
} else {
|
||||
if (MinValue < mMinMaxStepData->u32.MinValue) {
|
||||
mMinMaxStepData->u32.MinValue = MinValue;
|
||||
}
|
||||
if (MaxValue > mMinMaxStepData->u32.MaxValue) {
|
||||
mMinMaxStepData->u32.MaxValue = MaxValue;
|
||||
}
|
||||
}
|
||||
mMinMaxStepData->u32.Step = Step;
|
||||
}
|
||||
|
||||
VOID SetMinMaxStepData (IN UINT16 MinValue, IN UINT16 MaxValue, IN UINT16 Step) {
|
||||
mMinMaxStepData->u16.MinValue = MinValue;
|
||||
mMinMaxStepData->u16.MaxValue = MaxValue;
|
||||
mMinMaxStepData->u16.Step = Step;
|
||||
if (!ValueIsSet) {
|
||||
mMinMaxStepData->u16.MinValue = MinValue;
|
||||
mMinMaxStepData->u16.MaxValue = MaxValue;
|
||||
ValueIsSet = TRUE;
|
||||
} else {
|
||||
if (MinValue < mMinMaxStepData->u16.MinValue) {
|
||||
mMinMaxStepData->u16.MinValue = MinValue;
|
||||
}
|
||||
if (MaxValue > mMinMaxStepData->u16.MaxValue) {
|
||||
mMinMaxStepData->u16.MaxValue = MaxValue;
|
||||
}
|
||||
}
|
||||
mMinMaxStepData->u16.Step = Step;
|
||||
}
|
||||
|
||||
VOID SetMinMaxStepData (IN UINT8 MinValue, IN UINT8 MaxValue, IN UINT8 Step) {
|
||||
mMinMaxStepData->u8.MinValue = MinValue;
|
||||
mMinMaxStepData->u8.MaxValue = MaxValue;
|
||||
mMinMaxStepData->u8.Step = Step;
|
||||
if (!ValueIsSet) {
|
||||
mMinMaxStepData->u8.MinValue = MinValue;
|
||||
mMinMaxStepData->u8.MaxValue = MaxValue;
|
||||
ValueIsSet = TRUE;
|
||||
} else {
|
||||
if (MinValue < mMinMaxStepData->u8.MinValue) {
|
||||
mMinMaxStepData->u8.MinValue = MinValue;
|
||||
}
|
||||
if (MaxValue > mMinMaxStepData->u8.MaxValue) {
|
||||
mMinMaxStepData->u8.MaxValue = MaxValue;
|
||||
}
|
||||
}
|
||||
mMinMaxStepData->u8.Step = Step;
|
||||
}
|
||||
|
||||
UINT64 GetMinData (UINT8 VarType) {
|
||||
UINT64 MinValue = 0;
|
||||
switch (VarType) {
|
||||
case EFI_IFR_TYPE_NUM_SIZE_64:
|
||||
MinValue = mMinMaxStepData->u64.MinValue;
|
||||
break;
|
||||
case EFI_IFR_TYPE_NUM_SIZE_32:
|
||||
MinValue = (UINT64) mMinMaxStepData->u32.MinValue;
|
||||
break;
|
||||
case EFI_IFR_TYPE_NUM_SIZE_16:
|
||||
MinValue = (UINT64) mMinMaxStepData->u16.MinValue;
|
||||
break;
|
||||
case EFI_IFR_TYPE_NUM_SIZE_8:
|
||||
MinValue = (UINT64) mMinMaxStepData->u8.MinValue;
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
return MinValue;
|
||||
}
|
||||
|
||||
UINT64 GetMaxData (UINT8 VarType) {
|
||||
UINT64 MaxValue = 0;
|
||||
switch (VarType) {
|
||||
case EFI_IFR_TYPE_NUM_SIZE_64:
|
||||
MaxValue = mMinMaxStepData->u64.MaxValue;
|
||||
break;
|
||||
case EFI_IFR_TYPE_NUM_SIZE_32:
|
||||
MaxValue = (UINT64) mMinMaxStepData->u32.MaxValue;
|
||||
break;
|
||||
case EFI_IFR_TYPE_NUM_SIZE_16:
|
||||
MaxValue = (UINT64) mMinMaxStepData->u16.MaxValue;
|
||||
break;
|
||||
case EFI_IFR_TYPE_NUM_SIZE_8:
|
||||
MaxValue = (UINT64) mMinMaxStepData->u8.MaxValue;
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
return MaxValue;
|
||||
}
|
||||
|
||||
UINT64 GetStepData (UINT8 VarType) {
|
||||
UINT64 MaxValue = 0;
|
||||
switch (VarType) {
|
||||
case EFI_IFR_TYPE_NUM_SIZE_64:
|
||||
MaxValue = mMinMaxStepData->u64.Step;
|
||||
break;
|
||||
case EFI_IFR_TYPE_NUM_SIZE_32:
|
||||
MaxValue = (UINT64) mMinMaxStepData->u32.Step;
|
||||
break;
|
||||
case EFI_IFR_TYPE_NUM_SIZE_16:
|
||||
MaxValue = (UINT64) mMinMaxStepData->u16.Step;
|
||||
break;
|
||||
case EFI_IFR_TYPE_NUM_SIZE_8:
|
||||
MaxValue = (UINT64) mMinMaxStepData->u8.Step;
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
return MaxValue;
|
||||
}
|
||||
|
||||
BOOLEAN IsNumericOpcode () {
|
||||
return IsNumeric;
|
||||
}
|
||||
};
|
||||
|
||||
static CIfrQuestionHeader *gCurrentQuestion = NULL;
|
||||
static CIfrMinMaxStepData *gCurrentMinMaxData = NULL;
|
||||
|
||||
/*
|
||||
* The definition of all of the UEFI IFR Objects
|
||||
*/
|
||||
@@ -418,10 +532,11 @@ private:
|
||||
EFI_IFR_FORM_SET *mFormSet;
|
||||
|
||||
public:
|
||||
CIfrFormSet () : CIfrObj (EFI_IFR_FORM_SET_OP, (CHAR8 **)&mFormSet),
|
||||
CIfrOpHeader (EFI_IFR_FORM_SET_OP, &mFormSet->Header) {
|
||||
CIfrFormSet (UINT8 Size) : CIfrObj (EFI_IFR_FORM_SET_OP, (CHAR8 **)&mFormSet, Size),
|
||||
CIfrOpHeader (EFI_IFR_FORM_SET_OP, &mFormSet->Header, Size) {
|
||||
mFormSet->Help = EFI_STRING_ID_INVALID;
|
||||
mFormSet->FormSetTitle = EFI_STRING_ID_INVALID;
|
||||
mFormSet->Flags = 0;
|
||||
memset (&mFormSet->Guid, 0, sizeof (EFI_GUID));
|
||||
}
|
||||
|
||||
@@ -436,6 +551,17 @@ public:
|
||||
VOID SetHelp (IN EFI_STRING_ID Help) {
|
||||
mFormSet->Help = Help;
|
||||
}
|
||||
|
||||
VOID SetClassGuid (IN EFI_GUID *Guid) {
|
||||
if (mFormSet->Flags > 0 && ExpendObjBin(sizeof(EFI_GUID))) {
|
||||
IncLength (sizeof (EFI_GUID));
|
||||
}
|
||||
memcpy (&(mFormSet->ClassGuid[mFormSet->Flags++]), Guid, sizeof (EFI_GUID));
|
||||
}
|
||||
|
||||
UINT8 GetFlags() {
|
||||
return mFormSet->Flags;
|
||||
}
|
||||
};
|
||||
|
||||
class CIfrEnd : public CIfrObj, public CIfrOpHeader {
|
||||
@@ -817,7 +943,7 @@ private:
|
||||
public:
|
||||
CIfrResetButton () : CIfrObj (EFI_IFR_RESET_BUTTON_OP, (CHAR8 **)&mResetButton),
|
||||
CIfrOpHeader (EFI_IFR_RESET_BUTTON_OP, &mResetButton->Header),
|
||||
CIfrStatementHeader (&mResetButton->Question.Header) {
|
||||
CIfrStatementHeader (&mResetButton->Statement) {
|
||||
mResetButton->DefaultId = EFI_HII_DEFAULT_CLASS_STANDARD;
|
||||
}
|
||||
|
||||
@@ -834,7 +960,7 @@ public:
|
||||
CIfrCheckBox () : CIfrObj (EFI_IFR_CHECKBOX_OP, (CHAR8 **)&mCheckBox),
|
||||
CIfrOpHeader (EFI_IFR_CHECKBOX_OP, &mCheckBox->Header),
|
||||
CIfrQuestionHeader (&mCheckBox->Question) {
|
||||
mCheckBox->Flags = EFI_IFR_CHECKBOX_DEFAULT;
|
||||
mCheckBox->Flags = 0;
|
||||
gCurrentQuestion = this;
|
||||
}
|
||||
|
||||
@@ -860,6 +986,10 @@ public:
|
||||
|
||||
return _FLAGS_ZERO (LFlags) ? VFR_RETURN_SUCCESS : VFR_RETURN_FLAGS_UNSUPPORTED;
|
||||
}
|
||||
|
||||
UINT8 GetFlags (VOID) {
|
||||
return mCheckBox->Flags;
|
||||
}
|
||||
};
|
||||
|
||||
class CIfrAction : public CIfrObj, public CIfrOpHeader, public CIfrQuestionHeader {
|
||||
@@ -929,13 +1059,15 @@ public:
|
||||
CIfrNumeric () : CIfrObj (EFI_IFR_NUMERIC_OP, (CHAR8 **)&mNumeric),
|
||||
CIfrOpHeader (EFI_IFR_NUMERIC_OP, &mNumeric->Header),
|
||||
CIfrQuestionHeader (&mNumeric->Question),
|
||||
CIfrMinMaxStepData (&mNumeric->data) {
|
||||
CIfrMinMaxStepData (&mNumeric->data, TRUE) {
|
||||
mNumeric->Flags = EFI_IFR_NUMERIC_SIZE_1 | EFI_IFR_DISPLAY_UINT_DEC;
|
||||
gCurrentQuestion = this;
|
||||
gCurrentQuestion = this;
|
||||
gCurrentMinMaxData = this;
|
||||
}
|
||||
|
||||
~CIfrNumeric () {
|
||||
gCurrentQuestion = NULL;
|
||||
gCurrentQuestion = NULL;
|
||||
gCurrentMinMaxData = NULL;
|
||||
}
|
||||
|
||||
EFI_VFR_RETURN_CODE SetFlags (IN UINT8 HFlags, IN UINT8 LFlags) {
|
||||
@@ -965,11 +1097,13 @@ public:
|
||||
CIfrQuestionHeader (&mOneOf->Question),
|
||||
CIfrMinMaxStepData (&mOneOf->data) {
|
||||
mOneOf->Flags = 0;
|
||||
gCurrentQuestion = this;
|
||||
gCurrentQuestion = this;
|
||||
gCurrentMinMaxData = this;
|
||||
}
|
||||
|
||||
~CIfrOneOf () {
|
||||
gCurrentQuestion = NULL;
|
||||
gCurrentQuestion = NULL;
|
||||
gCurrentMinMaxData = NULL;
|
||||
}
|
||||
|
||||
EFI_VFR_RETURN_CODE SetFlags (IN UINT8 HFlags, IN UINT8 LFlags) {
|
||||
@@ -1428,7 +1562,7 @@ public:
|
||||
if (QuestionId != EFI_QUESTION_ID_INVALID) {
|
||||
mEqIdId->QuestionId1 = QuestionId;
|
||||
} else {
|
||||
gCFormPkg.AssignPending (VarIdStr, (VOID *)(&mEqIdId->QuestionId1), sizeof (EFI_QUESTION_ID), LineNo);
|
||||
gCFormPkg.AssignPending (VarIdStr, (VOID *)(&mEqIdId->QuestionId1), sizeof (EFI_QUESTION_ID), LineNo, NO_QST_REFED);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1440,7 +1574,7 @@ public:
|
||||
if (QuestionId != EFI_QUESTION_ID_INVALID) {
|
||||
mEqIdId->QuestionId2 = QuestionId;
|
||||
} else {
|
||||
gCFormPkg.AssignPending (VarIdStr, (VOID *)(&mEqIdId->QuestionId2), sizeof (EFI_QUESTION_ID), LineNo);
|
||||
gCFormPkg.AssignPending (VarIdStr, (VOID *)(&mEqIdId->QuestionId2), sizeof (EFI_QUESTION_ID), LineNo, NO_QST_REFED);
|
||||
}
|
||||
}
|
||||
};
|
||||
@@ -1466,7 +1600,7 @@ public:
|
||||
if (QuestionId != EFI_QUESTION_ID_INVALID) {
|
||||
mEqIdVal->QuestionId = QuestionId;
|
||||
} else {
|
||||
gCFormPkg.AssignPending (VarIdStr, (VOID *)(&mEqIdVal->QuestionId), sizeof (EFI_QUESTION_ID), LineNo);
|
||||
gCFormPkg.AssignPending (VarIdStr, (VOID *)(&mEqIdVal->QuestionId), sizeof (EFI_QUESTION_ID), LineNo, NO_QST_REFED);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1498,7 +1632,7 @@ public:
|
||||
if (QuestionId != EFI_QUESTION_ID_INVALID) {
|
||||
mEqIdVList->QuestionId = QuestionId;
|
||||
} else {
|
||||
gCFormPkg.AssignPending (VarIdStr, (VOID *)(&mEqIdVList->QuestionId), sizeof (EFI_QUESTION_ID), LineNo);
|
||||
gCFormPkg.AssignPending (VarIdStr, (VOID *)(&mEqIdVList->QuestionId), sizeof (EFI_QUESTION_ID), LineNo, NO_QST_REFED);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1540,7 +1674,7 @@ public:
|
||||
if (QuestionId != EFI_QUESTION_ID_INVALID) {
|
||||
mQuestionRef1->QuestionId = QuestionId;
|
||||
} else {
|
||||
gCFormPkg.AssignPending (VarIdStr, (VOID *)(&mQuestionRef1->QuestionId), sizeof (EFI_QUESTION_ID), LineNo);
|
||||
gCFormPkg.AssignPending (VarIdStr, (VOID *)(&mQuestionRef1->QuestionId), sizeof (EFI_QUESTION_ID), LineNo, NO_QST_REFED);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
File diff suppressed because it is too large
Load Diff
@@ -1,5 +1,4 @@
|
||||
/*++
|
||||
|
||||
Copyright (c) 2004 - 2010, 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
|
||||
@@ -10,8 +9,7 @@ THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
|
||||
|
||||
Module Name:
|
||||
|
||||
VfrUtilityLib.cpp
|
||||
VfrUtilityLib.cpp
|
||||
|
||||
Abstract:
|
||||
|
||||
@@ -74,12 +72,13 @@ CVfrBinaryOutput::WriteEnd (
|
||||
}
|
||||
|
||||
SConfigInfo::SConfigInfo (
|
||||
IN UINT8 Type,
|
||||
IN UINT16 Offset,
|
||||
IN UINT32 Width,
|
||||
IN UINT8 Type,
|
||||
IN UINT16 Offset,
|
||||
IN UINT32 Width,
|
||||
IN EFI_IFR_TYPE_VALUE Value
|
||||
)
|
||||
{
|
||||
mNext = NULL;
|
||||
mOffset = Offset;
|
||||
mWidth = (UINT16)Width;
|
||||
mValue = new UINT8[mWidth];
|
||||
@@ -125,54 +124,54 @@ SConfigInfo::~SConfigInfo (
|
||||
}
|
||||
|
||||
SConfigItem::SConfigItem (
|
||||
IN INT8 *Id,
|
||||
IN INT8 *Info
|
||||
IN INT8 *Name,
|
||||
IN INT8 *Id
|
||||
)
|
||||
{
|
||||
mId = NULL;
|
||||
mInfo = NULL;
|
||||
mName = NULL;
|
||||
mId = NULL;
|
||||
mInfoStrList = NULL;
|
||||
mNext = NULL;
|
||||
|
||||
if (Name != NULL) {
|
||||
if ((mName = new INT8[strlen (Name) + 1]) != NULL) {
|
||||
strcpy (mName, Name);
|
||||
}
|
||||
}
|
||||
|
||||
if (Id != NULL) {
|
||||
if ((mId = new INT8[strlen (Id) + 1]) != NULL) {
|
||||
strcpy (mId, Id);
|
||||
}
|
||||
}
|
||||
|
||||
if (Info != NULL) {
|
||||
if ((mInfo = new INT8[strlen (Info) + 1]) != NULL) {
|
||||
strcpy (mInfo, Info);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
SConfigItem::SConfigItem (
|
||||
IN INT8 *Id,
|
||||
IN INT8 *Info,
|
||||
IN INT8 *Name,
|
||||
IN INT8 *Id,
|
||||
IN UINT8 Type,
|
||||
IN UINT16 Offset,
|
||||
IN UINT16 Width,
|
||||
IN EFI_IFR_TYPE_VALUE Value
|
||||
)
|
||||
{
|
||||
mName = NULL;
|
||||
mId = NULL;
|
||||
mInfo = NULL;
|
||||
mInfoStrList = NULL;
|
||||
mNext = NULL;
|
||||
|
||||
if (Name != NULL) {
|
||||
if ((mName = new INT8[strlen (Name) + 1]) != NULL) {
|
||||
strcpy (mName, Name);
|
||||
}
|
||||
}
|
||||
|
||||
if (Id != NULL) {
|
||||
if ((mId = new INT8[strlen (Id) + 1]) != NULL) {
|
||||
strcpy (mId, Id);
|
||||
}
|
||||
}
|
||||
|
||||
if (Info != NULL) {
|
||||
if ((mInfo = new INT8[strlen (Info) + 1]) != NULL) {
|
||||
strcpy (mInfo, Info);
|
||||
}
|
||||
}
|
||||
|
||||
mInfoStrList = new SConfigInfo(Type, Offset, Width, Value);
|
||||
}
|
||||
|
||||
@@ -182,8 +181,8 @@ SConfigItem::~SConfigItem (
|
||||
{
|
||||
SConfigInfo *Info;
|
||||
|
||||
BUFFER_SAFE_FREE (mName);
|
||||
BUFFER_SAFE_FREE (mId);
|
||||
BUFFER_SAFE_FREE (mInfo);
|
||||
while (mInfoStrList != NULL) {
|
||||
Info = mInfoStrList;
|
||||
mInfoStrList = mInfoStrList->mNext;
|
||||
@@ -194,17 +193,17 @@ SConfigItem::~SConfigItem (
|
||||
|
||||
UINT8
|
||||
CVfrBufferConfig::Register (
|
||||
IN INT8 *Id,
|
||||
IN INT8 *Info
|
||||
IN INT8 *Name,
|
||||
IN INT8 *Id
|
||||
)
|
||||
{
|
||||
SConfigItem *pNew;
|
||||
|
||||
if (Select (Id) == 0) {
|
||||
if (Select (Name) == 0) {
|
||||
return 1;
|
||||
}
|
||||
|
||||
if ((pNew = new SConfigItem (Id, Info)) == NULL) {
|
||||
if ((pNew = new SConfigItem (Name, Id)) == NULL) {
|
||||
return 2;
|
||||
}
|
||||
if (mItemListHead == NULL) {
|
||||
@@ -237,25 +236,27 @@ CVfrBufferConfig::Eof(
|
||||
|
||||
UINT8
|
||||
CVfrBufferConfig::Select (
|
||||
IN INT8 *Id,
|
||||
IN INT8 *Info
|
||||
IN INT8 *Name,
|
||||
IN INT8 *Id
|
||||
)
|
||||
{
|
||||
SConfigItem *p;
|
||||
|
||||
if (Id == NULL) {
|
||||
if (Name == NULL) {
|
||||
mItemListPos = mItemListHead;
|
||||
return 0;
|
||||
} else {
|
||||
for (p = mItemListHead; p != NULL; p = p->mNext) {
|
||||
if (strcmp (p->mId, Id) != 0) {
|
||||
if (strcmp (p->mName, Name) != 0) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if ((p->mInfo != NULL) && (Info != NULL)) {
|
||||
if (strcmp (p->mInfo, Info) != 0) {
|
||||
if (Id != NULL) {
|
||||
if (p->mId == NULL || strcmp (p->mId, Id) != 0) {
|
||||
continue;
|
||||
}
|
||||
} else if (p->mId != NULL) {
|
||||
continue;
|
||||
}
|
||||
|
||||
mItemListPos = p;
|
||||
@@ -269,8 +270,8 @@ CVfrBufferConfig::Select (
|
||||
UINT8
|
||||
CVfrBufferConfig::Write (
|
||||
IN CONST CHAR8 Mode,
|
||||
IN INT8 *Id,
|
||||
IN INT8 *Info,
|
||||
IN INT8 *Name,
|
||||
IN INT8 *Id,
|
||||
IN UINT8 Type,
|
||||
IN UINT16 Offset,
|
||||
IN UINT32 Width,
|
||||
@@ -281,16 +282,14 @@ CVfrBufferConfig::Write (
|
||||
SConfigItem *pItem;
|
||||
SConfigInfo *pInfo;
|
||||
|
||||
if ((Ret = Select (Name)) != 0) {
|
||||
return Ret;
|
||||
}
|
||||
|
||||
switch (Mode) {
|
||||
case 'a' : // add
|
||||
if (Select (Id) == 0) {
|
||||
if((pInfo = new SConfigInfo (Type, Offset, Width, Value)) == NULL) {
|
||||
return 2;
|
||||
}
|
||||
pInfo->mNext = mItemListPos->mInfoStrList;
|
||||
mItemListPos->mInfoStrList = pInfo;
|
||||
} else {
|
||||
if ((pItem = new SConfigItem (Id, Info, Type, Offset, Width, Value)) == NULL) {
|
||||
if (Select (Name, Id) != 0) {
|
||||
if ((pItem = new SConfigItem (Name, Id, Type, Offset, Width, Value)) == NULL) {
|
||||
return 2;
|
||||
}
|
||||
if (mItemListHead == NULL) {
|
||||
@@ -301,14 +300,26 @@ CVfrBufferConfig::Write (
|
||||
mItemListTail = pItem;
|
||||
}
|
||||
mItemListPos = pItem;
|
||||
} else {
|
||||
// tranverse the list to find out if there's already the value for the same offset
|
||||
for (pInfo = mItemListPos->mInfoStrList; pInfo != NULL; pInfo = pInfo->mNext) {
|
||||
if (pInfo->mOffset == Offset) {
|
||||
// check if the value and width are the same; return error if not
|
||||
if ((Id != NULL) && (pInfo->mWidth != Width || memcmp(pInfo->mValue, &Value, Width) != 0)) {
|
||||
return VFR_RETURN_DEFAULT_VALUE_REDEFINED;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
if((pInfo = new SConfigInfo (Type, Offset, Width, Value)) == NULL) {
|
||||
return 2;
|
||||
}
|
||||
pInfo->mNext = mItemListPos->mInfoStrList;
|
||||
mItemListPos->mInfoStrList = pInfo;
|
||||
}
|
||||
break;
|
||||
|
||||
case 'd' : // delete
|
||||
if ((Ret = Select (Id)) != 0) {
|
||||
return Ret;
|
||||
}
|
||||
|
||||
if (mItemListHead == mItemListPos) {
|
||||
mItemListHead = mItemListPos->mNext;
|
||||
delete mItemListPos;
|
||||
@@ -327,18 +338,15 @@ CVfrBufferConfig::Write (
|
||||
break;
|
||||
|
||||
case 'i' : // set info
|
||||
if ((Ret = Select (Id)) != 0) {
|
||||
return Ret;
|
||||
if (mItemListPos->mId != NULL) {
|
||||
delete mItemListPos->mId;
|
||||
}
|
||||
if (mItemListPos->mInfo != NULL) {
|
||||
delete mItemListPos->mInfo;
|
||||
}
|
||||
mItemListPos->mInfo = NULL;
|
||||
if (Info != NULL) {
|
||||
if ((mItemListPos->mInfo = new INT8[strlen (Info) + 1]) == NULL) {
|
||||
mItemListPos->mId = NULL;
|
||||
if (Id != NULL) {
|
||||
if ((mItemListPos->mId = new INT8[strlen (Id) + 1]) == NULL) {
|
||||
return 2;
|
||||
}
|
||||
strcpy (mItemListPos->mInfo, Info);
|
||||
strcpy (mItemListPos->mId, Id);
|
||||
}
|
||||
break;
|
||||
|
||||
@@ -352,29 +360,29 @@ CVfrBufferConfig::Write (
|
||||
#if 0
|
||||
UINT8
|
||||
CVfrBufferConfig::ReadId (
|
||||
OUT INT8 **Id,
|
||||
OUT INT8 **Info
|
||||
OUT INT8 **Name,
|
||||
OUT INT8 **Id
|
||||
)
|
||||
{
|
||||
if (mInfoStrItemListPos == NULL) {
|
||||
return 1; // end read or some error occur
|
||||
}
|
||||
|
||||
if (Name != NULL) {
|
||||
*Name = new INT8 (strlen (mInfoStrItemListPos->mName + 1));
|
||||
strcpy (*Name, mInfoStrItemListPos->mName);
|
||||
}
|
||||
if (Id != NULL) {
|
||||
*Id = new INT8 (strlen (mInfoStrItemListPos->mId + 1));
|
||||
strcpy (*Id, mInfoStrItemListPos->mId);
|
||||
}
|
||||
if (Info != NULL) {
|
||||
*Info = new INT8 (strlen (mInfoStrItemListPos->mInfo + 1));
|
||||
strcpy (*Info, mInfoStrItemListPos->mInfo);
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
UINT8
|
||||
CVfrBufferConfig::ReadInfo (
|
||||
IN INT8 *Id,
|
||||
IN INT8 *Name,
|
||||
IN UINT32 Index,
|
||||
IN OUT UINT32 &Number,
|
||||
OUT INT8 *Offset,
|
||||
@@ -387,8 +395,8 @@ CVfrBufferConfig::ReadInfo (
|
||||
UINT32 idx;
|
||||
UINT32 num;
|
||||
|
||||
if (Id != NULL) {
|
||||
if ((ret = Select (Id)) != 0) {
|
||||
if (Name != NULL) {
|
||||
if ((ret = Select (Name)) != 0) {
|
||||
return ret;
|
||||
}
|
||||
}
|
||||
@@ -473,8 +481,28 @@ CVfrBufferConfig::OutputCFile (
|
||||
}
|
||||
|
||||
for (Item = mItemListHead; Item != NULL; Item = Item->mNext) {
|
||||
if (Item->mInfoStrList != NULL) {
|
||||
fprintf (pFile, "\nunsigned char %s%sDefault%04x[] = {", BaseName, Item->mId, Item->mInfo);
|
||||
if (Item->mId != NULL || Item->mInfoStrList == NULL) {
|
||||
continue;
|
||||
}
|
||||
fprintf (pFile, "\nunsigned char %s%sBlockName[] = {", BaseName, Item->mName);
|
||||
|
||||
TotalLen = sizeof (UINT32);
|
||||
for (Info = Item->mInfoStrList; Info != NULL; Info = Info->mNext) {
|
||||
TotalLen += sizeof (UINT16) * 2;
|
||||
}
|
||||
Output.WriteLine (pFile, BYTES_PRE_LINE, " ", (INT8 *)&TotalLen, sizeof (UINT32));
|
||||
|
||||
for (Info = Item->mInfoStrList; Info != NULL; Info = Info->mNext) {
|
||||
fprintf (pFile, "\n");
|
||||
Output.WriteLine (pFile, BYTES_PRE_LINE, " ", (INT8 *)&Info->mOffset, sizeof (UINT16));
|
||||
Output.WriteLine (pFile, BYTES_PRE_LINE, " ", (INT8 *)&Info->mWidth, sizeof (UINT16));
|
||||
}
|
||||
fprintf (pFile, "\n};\n");
|
||||
}
|
||||
|
||||
for (Item = mItemListHead; Item != NULL; Item = Item->mNext) {
|
||||
if (Item->mId != NULL && Item->mInfoStrList != NULL) {
|
||||
fprintf (pFile, "\nunsigned char %s%sDefault%s[] = {", BaseName, Item->mName, Item->mId);
|
||||
|
||||
TotalLen = sizeof (UINT32);
|
||||
for (Info = Item->mInfoStrList; Info != NULL; Info = Info->mNext) {
|
||||
@@ -483,6 +511,7 @@ CVfrBufferConfig::OutputCFile (
|
||||
Output.WriteLine (pFile, BYTES_PRE_LINE, " ", (INT8 *)&TotalLen, sizeof (UINT32));
|
||||
|
||||
for (Info = Item->mInfoStrList; Info != NULL; Info = Info->mNext) {
|
||||
fprintf (pFile, "\n");
|
||||
Output.WriteLine (pFile, BYTES_PRE_LINE, " ", (INT8 *)&Info->mOffset, sizeof (UINT16));
|
||||
Output.WriteLine (pFile, BYTES_PRE_LINE, " ", (INT8 *)&Info->mWidth, sizeof (UINT16));
|
||||
if (Info->mNext == NULL) {
|
||||
@@ -490,9 +519,8 @@ CVfrBufferConfig::OutputCFile (
|
||||
} else {
|
||||
Output.WriteLine (pFile, BYTES_PRE_LINE, " ", (INT8 *)Info->mValue, Info->mWidth);
|
||||
}
|
||||
fprintf (pFile, "\n");
|
||||
}
|
||||
fprintf (pFile, "};\n");
|
||||
fprintf (pFile, "\n};\n");
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -536,7 +564,7 @@ static struct {
|
||||
{"UINT16", EFI_IFR_TYPE_NUM_SIZE_16, sizeof (UINT16), sizeof (UINT16)},
|
||||
{"UINT8", EFI_IFR_TYPE_NUM_SIZE_8, sizeof (UINT8), sizeof (UINT8)},
|
||||
{"BOOLEAN", EFI_IFR_TYPE_BOOLEAN, sizeof (BOOLEAN), sizeof (BOOLEAN)},
|
||||
{"EFI_HII_DATE", EFI_IFR_TYPE_DATE, sizeof (EFI_HII_DATE), sizeof (UINT8)},
|
||||
{"EFI_HII_DATE", EFI_IFR_TYPE_DATE, sizeof (EFI_HII_DATE), sizeof (UINT16)},
|
||||
{"EFI_STRING_ID", EFI_IFR_TYPE_STRING, sizeof (EFI_STRING_ID),sizeof (EFI_STRING_ID)},
|
||||
{"EFI_HII_TIME", EFI_IFR_TYPE_TIME, sizeof (EFI_HII_TIME), sizeof (UINT8)},
|
||||
{NULL, EFI_IFR_TYPE_OTHER, 0, 0}
|
||||
@@ -610,7 +638,7 @@ _STR2U32 (
|
||||
}
|
||||
if (c >= '0' && c <= '9') {
|
||||
Value += (c - '0');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return Value;
|
||||
@@ -627,7 +655,7 @@ CVfrVarDataTypeDB::RegisterNewType (
|
||||
|
||||
EFI_VFR_RETURN_CODE
|
||||
CVfrVarDataTypeDB::ExtractStructTypeName (
|
||||
IN INT8 *&VarStr,
|
||||
IN INT8 *&VarStr,
|
||||
OUT INT8 *TName
|
||||
)
|
||||
{
|
||||
@@ -650,7 +678,7 @@ CVfrVarDataTypeDB::ExtractStructTypeName (
|
||||
|
||||
EFI_VFR_RETURN_CODE
|
||||
CVfrVarDataTypeDB::ExtractFieldNameAndArrary (
|
||||
IN INT8 *&VarStr,
|
||||
IN INT8 *&VarStr,
|
||||
IN INT8 *FName,
|
||||
OUT UINT32 &ArrayIdx
|
||||
)
|
||||
@@ -658,15 +686,15 @@ CVfrVarDataTypeDB::ExtractFieldNameAndArrary (
|
||||
UINT32 Idx;
|
||||
INT8 ArrayStr[MAX_NAME_LEN + 1];
|
||||
|
||||
ArrayIdx = INVALID_ARRAY_INDEX;
|
||||
ArrayIdx = INVALID_ARRAY_INDEX;
|
||||
|
||||
if (FName == NULL) {
|
||||
return VFR_RETURN_FATAL_ERROR;
|
||||
}
|
||||
|
||||
while((*VarStr != '\0') &&
|
||||
(*VarStr != '.') &&
|
||||
(*VarStr != '[') &&
|
||||
(*VarStr != '.') &&
|
||||
(*VarStr != '[') &&
|
||||
(*VarStr != ']')) {
|
||||
*FName = *VarStr;
|
||||
VarStr++;
|
||||
@@ -703,8 +731,8 @@ CVfrVarDataTypeDB::ExtractFieldNameAndArrary (
|
||||
|
||||
EFI_VFR_RETURN_CODE
|
||||
CVfrVarDataTypeDB::GetTypeField (
|
||||
IN INT8 *FName,
|
||||
IN SVfrDataType *Type,
|
||||
IN INT8 *FName,
|
||||
IN SVfrDataType *Type,
|
||||
OUT SVfrDataField *&Field
|
||||
)
|
||||
{
|
||||
@@ -726,7 +754,7 @@ CVfrVarDataTypeDB::GetTypeField (
|
||||
|
||||
EFI_VFR_RETURN_CODE
|
||||
CVfrVarDataTypeDB::GetFieldOffset (
|
||||
IN SVfrDataField *Field,
|
||||
IN SVfrDataField *Field,
|
||||
IN UINT32 ArrayIdx,
|
||||
OUT UINT32 &Offset
|
||||
)
|
||||
@@ -834,7 +862,7 @@ CVfrVarDataTypeDB::InternalTypesListInit (
|
||||
pSecondsField->mNext = NULL;
|
||||
pSecondsField->mArrayNum = 0;
|
||||
|
||||
New->mMembers = pHoursField;
|
||||
New->mMembers = pHoursField;
|
||||
} else {
|
||||
New->mMembers = NULL;
|
||||
}
|
||||
@@ -853,6 +881,7 @@ CVfrVarDataTypeDB::CVfrVarDataTypeDB (
|
||||
mNewDataType = NULL;
|
||||
mCurrDataField = NULL;
|
||||
mPackAlign = DEFAULT_PACK_ALIGN;
|
||||
mPackStack = NULL;
|
||||
|
||||
InternalTypesListInit ();
|
||||
}
|
||||
@@ -861,8 +890,9 @@ CVfrVarDataTypeDB::~CVfrVarDataTypeDB (
|
||||
VOID
|
||||
)
|
||||
{
|
||||
SVfrDataType *pType;
|
||||
SVfrDataField *pField;
|
||||
SVfrDataType *pType;
|
||||
SVfrDataField *pField;
|
||||
SVfrPackStackNode *pPack;
|
||||
|
||||
if (mNewDataType != NULL) {
|
||||
delete mNewDataType;
|
||||
@@ -879,32 +909,66 @@ CVfrVarDataTypeDB::~CVfrVarDataTypeDB (
|
||||
delete pType;
|
||||
}
|
||||
|
||||
while (mPackStack != NULL) {
|
||||
pPack = mPackStack;
|
||||
mPackStack = mPackStack->mNext;
|
||||
delete pPack;
|
||||
}
|
||||
}
|
||||
|
||||
EFI_VFR_RETURN_CODE
|
||||
CVfrVarDataTypeDB::Pack (
|
||||
IN UINT32 Align
|
||||
IN UINT32 LineNum,
|
||||
IN UINT8 Action,
|
||||
IN INT8 *Identifier,
|
||||
IN UINT32 Number
|
||||
)
|
||||
{
|
||||
if (Align == 0) {
|
||||
return VFR_RETURN_INVALID_PARAMETER;
|
||||
} else if (Align > 1) {
|
||||
mPackAlign = Align + Align % 2;
|
||||
} else {
|
||||
mPackAlign = Align;
|
||||
UINT32 PackAlign;
|
||||
INT8 Msg[64] = {0, };
|
||||
|
||||
if (Action & VFR_PACK_SHOW) {
|
||||
sprintf (Msg, "value of pragma pack(show) == %d", mPackAlign);
|
||||
gCVfrErrorHandle.PrintMsg (LineNum, "", "Warning", Msg);
|
||||
}
|
||||
|
||||
if (Action & VFR_PACK_PUSH) {
|
||||
SVfrPackStackNode *pNew = NULL;
|
||||
|
||||
if ((pNew = new SVfrPackStackNode (Identifier, mPackAlign)) == NULL) {
|
||||
return VFR_RETURN_FATAL_ERROR;
|
||||
}
|
||||
pNew->mNext = mPackStack;
|
||||
mPackStack = pNew;
|
||||
}
|
||||
|
||||
if (Action & VFR_PACK_POP) {
|
||||
SVfrPackStackNode *pNode = NULL;
|
||||
|
||||
if (mPackStack == NULL) {
|
||||
gCVfrErrorHandle.PrintMsg (LineNum, "", "Warning", "#pragma pack(pop...) : more pops than pushes");
|
||||
}
|
||||
|
||||
for (pNode = mPackStack; pNode != NULL; pNode = pNode->mNext) {
|
||||
if (pNode->Match (Identifier) == TRUE) {
|
||||
mPackAlign = pNode->mNumber;
|
||||
mPackStack = pNode->mNext;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (Action & VFR_PACK_ASSIGN) {
|
||||
PackAlign = (Number > 1) ? Number + Number % 2 : Number;
|
||||
if ((PackAlign == 0) || (PackAlign > 16)) {
|
||||
gCVfrErrorHandle.PrintMsg (LineNum, "", "Warning", "expected pragma parameter to be '1', '2', '4', '8', or '16'");
|
||||
} else {
|
||||
mPackAlign = PackAlign;
|
||||
}
|
||||
}
|
||||
|
||||
return VFR_RETURN_SUCCESS;
|
||||
}
|
||||
|
||||
VOID
|
||||
CVfrVarDataTypeDB::UnPack (
|
||||
VOID
|
||||
)
|
||||
{
|
||||
mPackAlign = DEFAULT_PACK_ALIGN;
|
||||
}
|
||||
|
||||
VOID
|
||||
CVfrVarDataTypeDB::DeclareDataTypeBegin (
|
||||
VOID
|
||||
@@ -952,8 +1016,8 @@ CVfrVarDataTypeDB::SetNewTypeName (
|
||||
|
||||
EFI_VFR_RETURN_CODE
|
||||
CVfrVarDataTypeDB::DataTypeAddField (
|
||||
IN INT8 *FieldName,
|
||||
IN INT8 *TypeName,
|
||||
IN INT8 *FieldName,
|
||||
IN INT8 *TypeName,
|
||||
IN UINT32 ArrayNum
|
||||
)
|
||||
{
|
||||
@@ -991,7 +1055,7 @@ CVfrVarDataTypeDB::DataTypeAddField (
|
||||
mNewDataType->mMembers = pNewField;
|
||||
pNewField->mNext = NULL;
|
||||
} else {
|
||||
for (pTmp = mNewDataType->mMembers; pTmp->mNext != NULL; pTmp = pTmp->mNext)
|
||||
for (pTmp = mNewDataType->mMembers; pTmp->mNext != NULL; pTmp = pTmp->mNext)
|
||||
;
|
||||
pTmp->mNext = pNewField;
|
||||
pNewField->mNext = NULL;
|
||||
@@ -1049,6 +1113,38 @@ CVfrVarDataTypeDB::GetDataType (
|
||||
return VFR_RETURN_UNDEFINED;
|
||||
}
|
||||
|
||||
EFI_VFR_RETURN_CODE
|
||||
CVfrVarDataTypeDB::GetDataTypeSize (
|
||||
IN UINT8 DataType,
|
||||
OUT UINT32 *Size
|
||||
)
|
||||
{
|
||||
SVfrDataType *pDataType = NULL;
|
||||
|
||||
if (Size == NULL) {
|
||||
return VFR_RETURN_FATAL_ERROR;
|
||||
}
|
||||
|
||||
*Size = 0;
|
||||
DataType = DataType & 0x0F;
|
||||
|
||||
//
|
||||
// For user defined data type, the size can't be got by this function.
|
||||
//
|
||||
if (DataType == EFI_IFR_TYPE_OTHER) {
|
||||
return VFR_RETURN_SUCCESS;
|
||||
}
|
||||
|
||||
for (pDataType = mDataTypeList; pDataType != NULL; pDataType = pDataType->mNext) {
|
||||
if (DataType == pDataType->mType) {
|
||||
*Size = pDataType->mTotalSize;
|
||||
return VFR_RETURN_SUCCESS;
|
||||
}
|
||||
}
|
||||
|
||||
return VFR_RETURN_UNDEFINED;
|
||||
}
|
||||
|
||||
EFI_VFR_RETURN_CODE
|
||||
CVfrVarDataTypeDB::GetDataTypeSize (
|
||||
IN INT8 *TypeName,
|
||||
@@ -1075,9 +1171,9 @@ CVfrVarDataTypeDB::GetDataTypeSize (
|
||||
|
||||
EFI_VFR_RETURN_CODE
|
||||
CVfrVarDataTypeDB::GetDataFieldInfo (
|
||||
IN INT8 *VarStr,
|
||||
OUT UINT16 &Offset,
|
||||
OUT UINT8 &Type,
|
||||
IN INT8 *VarStr,
|
||||
OUT UINT16 &Offset,
|
||||
OUT UINT8 &Type,
|
||||
OUT UINT32 &Size
|
||||
)
|
||||
{
|
||||
@@ -1113,7 +1209,7 @@ CVfrVarDataTypeDB::GetDataFieldInfo (
|
||||
|
||||
EFI_VFR_RETURN_CODE
|
||||
CVfrVarDataTypeDB::GetUserDefinedTypeNameList (
|
||||
OUT INT8 ***NameList,
|
||||
OUT INT8 ***NameList,
|
||||
OUT UINT32 *ListSize
|
||||
)
|
||||
{
|
||||
@@ -1444,10 +1540,10 @@ CVfrDataStorage::DeclareNameVarStoreEnd (
|
||||
return VFR_RETURN_SUCCESS;
|
||||
}
|
||||
|
||||
EFI_VFR_RETURN_CODE
|
||||
EFI_VFR_RETURN_CODE
|
||||
CVfrDataStorage::DeclareEfiVarStore (
|
||||
IN INT8 *StoreName,
|
||||
IN EFI_GUID *Guid,
|
||||
IN INT8 *StoreName,
|
||||
IN EFI_GUID *Guid,
|
||||
IN EFI_STRING_ID NameStrId,
|
||||
IN UINT32 VarSize
|
||||
)
|
||||
@@ -1480,10 +1576,10 @@ CVfrDataStorage::DeclareEfiVarStore (
|
||||
return VFR_RETURN_SUCCESS;
|
||||
}
|
||||
|
||||
EFI_VFR_RETURN_CODE
|
||||
EFI_VFR_RETURN_CODE
|
||||
CVfrDataStorage::DeclareBufferVarStore (
|
||||
IN INT8 *StoreName,
|
||||
IN EFI_GUID *Guid,
|
||||
IN INT8 *StoreName,
|
||||
IN EFI_GUID *Guid,
|
||||
IN CVfrVarDataTypeDB *DataTypeDB,
|
||||
IN INT8 *TypeName,
|
||||
IN EFI_VARSTORE_ID VarStoreId
|
||||
@@ -1521,7 +1617,7 @@ CVfrDataStorage::DeclareBufferVarStore (
|
||||
return VFR_RETURN_SUCCESS;
|
||||
}
|
||||
|
||||
EFI_VFR_RETURN_CODE
|
||||
EFI_VFR_RETURN_CODE
|
||||
CVfrDataStorage::GetVarStoreId (
|
||||
IN INT8 *StoreName,
|
||||
OUT EFI_VARSTORE_ID *VarStoreId
|
||||
@@ -1625,9 +1721,47 @@ CVfrDataStorage::GetVarStoreType (
|
||||
return VFR_RETURN_UNDEFINED;
|
||||
}
|
||||
|
||||
EFI_VFR_VARSTORE_TYPE
|
||||
CVfrDataStorage::GetVarStoreType (
|
||||
IN EFI_VARSTORE_ID VarStoreId
|
||||
)
|
||||
{
|
||||
SVfrVarStorageNode *pNode;
|
||||
EFI_VFR_VARSTORE_TYPE VarStoreType;
|
||||
|
||||
VarStoreType = EFI_VFR_VARSTORE_INVALID;
|
||||
|
||||
if (VarStoreId == EFI_VARSTORE_ID_INVALID) {
|
||||
return VarStoreType;
|
||||
}
|
||||
|
||||
for (pNode = mBufferVarStoreList; pNode != NULL; pNode = pNode->mNext) {
|
||||
if (pNode->mVarStoreId == VarStoreId) {
|
||||
VarStoreType = pNode->mVarStoreType;
|
||||
return VarStoreType;
|
||||
}
|
||||
}
|
||||
|
||||
for (pNode = mEfiVarStoreList; pNode != NULL; pNode = pNode->mNext) {
|
||||
if (pNode->mVarStoreId == VarStoreId) {
|
||||
VarStoreType = pNode->mVarStoreType;
|
||||
return VarStoreType;
|
||||
}
|
||||
}
|
||||
|
||||
for (pNode = mNameVarStoreList; pNode != NULL; pNode = pNode->mNext) {
|
||||
if (pNode->mVarStoreId == VarStoreId) {
|
||||
VarStoreType = pNode->mVarStoreType;
|
||||
return VarStoreType;
|
||||
}
|
||||
}
|
||||
|
||||
return VarStoreType;
|
||||
}
|
||||
|
||||
EFI_VFR_RETURN_CODE
|
||||
CVfrDataStorage::GetVarStoreName (
|
||||
IN EFI_VARSTORE_ID VarStoreId,
|
||||
IN EFI_VARSTORE_ID VarStoreId,
|
||||
OUT INT8 **VarStoreName
|
||||
)
|
||||
{
|
||||
@@ -1725,7 +1859,7 @@ CVfrDataStorage::BufferVarStoreRequestElementAdd (
|
||||
INT8 NewReqElt[128] = {'\0',};
|
||||
INT8 *OldReqElt = NULL;
|
||||
SVfrVarStorageNode *pNode = NULL;
|
||||
EFI_IFR_TYPE_VALUE Value;
|
||||
EFI_IFR_TYPE_VALUE Value = {0};
|
||||
|
||||
for (pNode = mBufferVarStoreList; pNode != NULL; pNode = pNode->mNext) {
|
||||
if (strcmp (pNode->mVarStoreName, StoreName) == NULL) {
|
||||
@@ -1749,8 +1883,8 @@ CVfrDataStorage::BufferVarStoreRequestElementAdd (
|
||||
|
||||
SVfrDefaultStoreNode::SVfrDefaultStoreNode (
|
||||
IN EFI_IFR_DEFAULTSTORE *ObjBinAddr,
|
||||
IN INT8 *RefName,
|
||||
IN EFI_STRING_ID DefaultStoreNameId,
|
||||
IN INT8 *RefName,
|
||||
IN EFI_STRING_ID DefaultStoreNameId,
|
||||
IN UINT16 DefaultId
|
||||
)
|
||||
{
|
||||
@@ -1828,7 +1962,7 @@ CVfrDefaultStore::RegisterDefaultStore (
|
||||
}
|
||||
|
||||
/*
|
||||
* assign new reference name or new default store name id only if
|
||||
* assign new reference name or new default store name id only if
|
||||
* the original is invalid
|
||||
*/
|
||||
EFI_VFR_RETURN_CODE
|
||||
@@ -1911,8 +2045,8 @@ CVfrDefaultStore::GetDefaultId (
|
||||
STATIC
|
||||
EFI_VFR_RETURN_CODE
|
||||
AltCfgItemPrintToBuffer (
|
||||
IN INT8 *NewAltCfg,
|
||||
IN EFI_VARSTORE_INFO Info,
|
||||
IN INT8 *NewAltCfg,
|
||||
IN EFI_VARSTORE_INFO Info,
|
||||
IN UINT8 Type,
|
||||
IN EFI_IFR_TYPE_VALUE Value
|
||||
)
|
||||
@@ -1923,9 +2057,9 @@ AltCfgItemPrintToBuffer (
|
||||
|
||||
if (NewAltCfg != NULL) {
|
||||
Count = sprintf (
|
||||
NewAltCfg,
|
||||
"&OFFSET=%x&WIDTH=%x&VALUE=",
|
||||
Info.mInfo.mVarOffset,
|
||||
NewAltCfg,
|
||||
"&OFFSET=%x&WIDTH=%x&VALUE=",
|
||||
Info.mInfo.mVarOffset,
|
||||
Info.mVarTotalSize
|
||||
);
|
||||
NewAltCfg += Count;
|
||||
@@ -1984,7 +2118,7 @@ AltCfgItemPrintToBuffer (
|
||||
}
|
||||
}
|
||||
|
||||
return VFR_RETURN_FATAL_ERROR;
|
||||
return VFR_RETURN_FATAL_ERROR;
|
||||
}
|
||||
|
||||
EFI_VFR_RETURN_CODE
|
||||
@@ -1998,6 +2132,7 @@ CVfrDefaultStore::BufferVarStoreAltConfigAdd (
|
||||
{
|
||||
SVfrDefaultStoreNode *pNode = NULL;
|
||||
INT8 NewAltCfg[2 * 2 * sizeof (UINT16) + 1] = {0,};
|
||||
INTN Returnvalue = 0;
|
||||
|
||||
if (VarStoreName == NULL) {
|
||||
return VFR_RETURN_FATAL_ERROR;
|
||||
@@ -2016,28 +2151,23 @@ CVfrDefaultStore::BufferVarStoreAltConfigAdd (
|
||||
gCVfrBufferConfig.Open ();
|
||||
|
||||
sprintf (NewAltCfg, "%04x", pNode->mDefaultId);
|
||||
if ((gCVfrBufferConfig.Select(VarStoreName) == 0) &&
|
||||
(gCVfrBufferConfig.Select(VarStoreName, NewAltCfg) != 0)) {
|
||||
if (gCVfrBufferConfig.Write ('i', VarStoreName, NewAltCfg, Type, Info.mInfo.mVarOffset, Info.mVarTotalSize, Value) != 0) {
|
||||
if ((Returnvalue = gCVfrBufferConfig.Select(VarStoreName)) == 0) {
|
||||
if ((Returnvalue = gCVfrBufferConfig.Write ('a', VarStoreName, NewAltCfg, Type, Info.mInfo.mVarOffset, Info.mVarTotalSize, Value)) != 0) {
|
||||
goto WriteError;
|
||||
}
|
||||
}
|
||||
|
||||
if (gCVfrBufferConfig.Write ('a', VarStoreName, NULL, Type, Info.mInfo.mVarOffset, Info.mVarTotalSize, Value) != 0) {
|
||||
goto WriteError;
|
||||
}
|
||||
|
||||
gCVfrBufferConfig.Close ();
|
||||
|
||||
return VFR_RETURN_SUCCESS;
|
||||
|
||||
WriteError:
|
||||
gCVfrBufferConfig.Close ();
|
||||
return VFR_RETURN_FATAL_ERROR;
|
||||
return (EFI_VFR_RETURN_CODE)Returnvalue;
|
||||
}
|
||||
|
||||
SVfrRuleNode::SVfrRuleNode (
|
||||
IN INT8 *RuleName,
|
||||
IN INT8 *RuleName,
|
||||
IN UINT8 RuleId
|
||||
)
|
||||
{
|
||||
@@ -2143,7 +2273,7 @@ EFI_VARSTORE_INFO::EFI_VARSTORE_INFO (
|
||||
mVarTotalSize = Info.mVarTotalSize;
|
||||
}
|
||||
|
||||
BOOLEAN
|
||||
BOOLEAN
|
||||
EFI_VARSTORE_INFO::operator == (
|
||||
IN EFI_VARSTORE_INFO *Info
|
||||
)
|
||||
@@ -2195,7 +2325,7 @@ CVfrQuestionDB::ChekQuestionIdFree (
|
||||
return (mFreeQIdBitMap[Index] & (0x80000000 >> Offset)) == 0;
|
||||
}
|
||||
|
||||
VOID
|
||||
VOID
|
||||
CVfrQuestionDB::MarkQuestionIdUsed (
|
||||
IN EFI_QUESTION_ID QId
|
||||
)
|
||||
@@ -2206,7 +2336,7 @@ CVfrQuestionDB::MarkQuestionIdUsed (
|
||||
mFreeQIdBitMap[Index] |= (0x80000000 >> Offset);
|
||||
}
|
||||
|
||||
VOID
|
||||
VOID
|
||||
CVfrQuestionDB::MarkQuestionIdUnused (
|
||||
IN EFI_QUESTION_ID QId
|
||||
)
|
||||
@@ -2321,9 +2451,9 @@ CVfrQuestionDB::RegisterQuestion (
|
||||
|
||||
VOID
|
||||
CVfrQuestionDB::RegisterOldDateQuestion (
|
||||
IN INT8 *YearVarId,
|
||||
IN INT8 *MonthVarId,
|
||||
IN INT8 *DayVarId,
|
||||
IN INT8 *YearVarId,
|
||||
IN INT8 *MonthVarId,
|
||||
IN INT8 *DayVarId,
|
||||
IN OUT EFI_QUESTION_ID &QuestionId
|
||||
)
|
||||
{
|
||||
@@ -2379,7 +2509,7 @@ Err:
|
||||
VOID
|
||||
CVfrQuestionDB::RegisterNewDateQuestion (
|
||||
IN INT8 *Name,
|
||||
IN INT8 *BaseVarId,
|
||||
IN INT8 *BaseVarId,
|
||||
IN OUT EFI_QUESTION_ID &QuestionId
|
||||
)
|
||||
{
|
||||
@@ -2463,9 +2593,9 @@ Err:
|
||||
|
||||
VOID
|
||||
CVfrQuestionDB::RegisterOldTimeQuestion (
|
||||
IN INT8 *HourVarId,
|
||||
IN INT8 *MinuteVarId,
|
||||
IN INT8 *SecondVarId,
|
||||
IN INT8 *HourVarId,
|
||||
IN INT8 *MinuteVarId,
|
||||
IN INT8 *SecondVarId,
|
||||
IN OUT EFI_QUESTION_ID &QuestionId
|
||||
)
|
||||
{
|
||||
@@ -2634,7 +2764,7 @@ CVfrQuestionDB::UpdateQuestionId (
|
||||
return VFR_RETURN_SUCCESS;
|
||||
}
|
||||
|
||||
VOID
|
||||
VOID
|
||||
CVfrQuestionDB::GetQuestionId (
|
||||
IN INT8 *Name,
|
||||
IN INT8 *VarIdStr,
|
||||
@@ -2672,7 +2802,7 @@ CVfrQuestionDB::GetQuestionId (
|
||||
return ;
|
||||
}
|
||||
|
||||
EFI_VFR_RETURN_CODE
|
||||
EFI_VFR_RETURN_CODE
|
||||
CVfrQuestionDB::FindQuestion (
|
||||
IN EFI_QUESTION_ID QuestionId
|
||||
)
|
||||
@@ -2692,7 +2822,7 @@ CVfrQuestionDB::FindQuestion (
|
||||
return VFR_RETURN_UNDEFINED;
|
||||
}
|
||||
|
||||
EFI_VFR_RETURN_CODE
|
||||
EFI_VFR_RETURN_CODE
|
||||
CVfrQuestionDB::FindQuestion (
|
||||
IN INT8 *Name
|
||||
)
|
||||
|
@@ -1,5 +1,4 @@
|
||||
/*++
|
||||
|
||||
Copyright (c) 2004 - 2010, 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
|
||||
@@ -10,8 +9,7 @@ THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
|
||||
|
||||
Module Name:
|
||||
|
||||
VfrUtilityLib.h
|
||||
VfrUtilityLib.h
|
||||
|
||||
Abstract:
|
||||
|
||||
@@ -28,7 +26,7 @@ Abstract:
|
||||
|
||||
#define MAX_NAME_LEN 64
|
||||
#define DEFAULT_ALIGN 1
|
||||
#define DEFAULT_PACK_ALIGN 0xFFFFFFFF
|
||||
#define DEFAULT_PACK_ALIGN 0x8
|
||||
#define DEFAULT_NAME_TABLE_ITEMS 1024
|
||||
|
||||
#define EFI_BITS_SHIFT_PER_UINT32 0x5
|
||||
@@ -58,9 +56,9 @@ struct SConfigInfo {
|
||||
};
|
||||
|
||||
struct SConfigItem {
|
||||
INT8 *mId;
|
||||
INT8 *mInfo;
|
||||
SConfigInfo *mInfoStrList;
|
||||
INT8 *mName; // varstore name
|
||||
INT8 *mId; // varstore ID
|
||||
SConfigInfo *mInfoStrList; // list of Offset/Value in the varstore
|
||||
SConfigItem *mNext;
|
||||
|
||||
public:
|
||||
@@ -115,10 +113,59 @@ struct SVfrDataType {
|
||||
SVfrDataType *mNext;
|
||||
};
|
||||
|
||||
#define VFR_PACK_ASSIGN 0x01
|
||||
#define VFR_PACK_SHOW 0x02
|
||||
#define VFR_PACK_PUSH 0x04
|
||||
#define VFR_PACK_POP 0x08
|
||||
|
||||
#define PACKSTACK_MAX_SIZE 0x400
|
||||
|
||||
struct SVfrPackStackNode {
|
||||
INT8 *mIdentifier;
|
||||
UINT32 mNumber;
|
||||
SVfrPackStackNode *mNext;
|
||||
|
||||
SVfrPackStackNode (IN INT8 *Identifier, IN UINT32 Number) {
|
||||
mIdentifier = NULL;
|
||||
mNumber = Number;
|
||||
mNext = NULL;
|
||||
|
||||
if (Identifier != NULL) {
|
||||
mIdentifier = new INT8[strlen (Identifier) + 1];
|
||||
strcpy (mIdentifier, Identifier);
|
||||
}
|
||||
}
|
||||
|
||||
~SVfrPackStackNode (VOID) {
|
||||
if (mIdentifier != NULL) {
|
||||
delete mIdentifier;
|
||||
}
|
||||
mNext = NULL;
|
||||
}
|
||||
|
||||
bool Match (IN INT8 *Identifier) {
|
||||
if (Identifier == NULL) {
|
||||
return TRUE;
|
||||
} else if (mIdentifier == NULL) {
|
||||
return FALSE;
|
||||
} else if (strcmp (Identifier, mIdentifier) == 0) {
|
||||
return TRUE;
|
||||
} else {
|
||||
return FALSE;
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
class CVfrVarDataTypeDB {
|
||||
private:
|
||||
SVfrDataType *mDataTypeList;
|
||||
UINT32 mPackAlign;
|
||||
SVfrPackStackNode *mPackStack;
|
||||
|
||||
public:
|
||||
EFI_VFR_RETURN_CODE Pack (IN UINT32, IN UINT8, IN INT8 *Identifier = NULL, IN UINT32 Number = DEFAULT_PACK_ALIGN);
|
||||
|
||||
private:
|
||||
SVfrDataType *mDataTypeList;
|
||||
|
||||
SVfrDataType *mNewDataType;
|
||||
SVfrDataType *mCurrDataType;
|
||||
@@ -138,9 +185,6 @@ public:
|
||||
CVfrVarDataTypeDB (VOID);
|
||||
~CVfrVarDataTypeDB (VOID);
|
||||
|
||||
EFI_VFR_RETURN_CODE Pack (IN UINT32);
|
||||
VOID UnPack (VOID);
|
||||
|
||||
VOID DeclareDataTypeBegin (VOID);
|
||||
EFI_VFR_RETURN_CODE SetNewTypeName (IN INT8 *);
|
||||
EFI_VFR_RETURN_CODE DataTypeAddField (IN INT8 *, IN INT8 *, IN UINT32);
|
||||
@@ -148,6 +192,7 @@ public:
|
||||
|
||||
EFI_VFR_RETURN_CODE GetDataType (IN INT8 *, OUT SVfrDataType **);
|
||||
EFI_VFR_RETURN_CODE GetDataTypeSize (IN INT8 *, OUT UINT32 *);
|
||||
EFI_VFR_RETURN_CODE GetDataTypeSize (IN UINT8, OUT UINT32 *);
|
||||
EFI_VFR_RETURN_CODE GetDataFieldInfo (IN INT8 *, OUT UINT16 &, OUT UINT8 &, OUT UINT32 &);
|
||||
|
||||
EFI_VFR_RETURN_CODE GetUserDefinedTypeNameList (OUT INT8 ***, OUT UINT32 *);
|
||||
@@ -245,6 +290,7 @@ public:
|
||||
|
||||
EFI_VFR_RETURN_CODE GetVarStoreId (IN INT8 *, OUT EFI_VARSTORE_ID *);
|
||||
EFI_VFR_RETURN_CODE GetVarStoreType (IN INT8 *, OUT EFI_VFR_VARSTORE_TYPE &);
|
||||
EFI_VFR_VARSTORE_TYPE GetVarStoreType (IN EFI_VARSTORE_ID);
|
||||
EFI_VFR_RETURN_CODE GetVarStoreName (IN EFI_VARSTORE_ID, OUT INT8 **);
|
||||
|
||||
EFI_VFR_RETURN_CODE GetBufferVarStoreDataTypeName (IN INT8 *, OUT INT8 **);
|
||||
|
@@ -1,6 +1,6 @@
|
||||
#/*++
|
||||
#
|
||||
# Copyright (c) 2004 - 2007, Intel Corporation. All rights reserved.<BR>
|
||||
# Copyright (c) 2004 - 2010, 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
|
||||
@@ -55,7 +55,8 @@ INC = -I $(SRC) \
|
||||
ANTLR_FLAGS = -CC -e3 -ck 3 -k 2
|
||||
DLG_FLAGS = -C2 -i -CC
|
||||
LINK_FLAGS_PCCTS = /DEBUG /PDB:$*.pdb
|
||||
C_FLAGS_PCCTS = -I. -I$(ANTLR_H) /WX /Od /EHsc /Zi /Fd$(ETO)\$(TARGET_NAME)Obj /D _CRT_SECURE_NO_DEPRECATE $(VERSION_FLAGS) /D PCCTS_USE_NAMESPACE_STD #/D CVFR_VARDATATYPEDB_DEBUG /D CIFROBJ_DEUBG /D VFREXP_DEBUG
|
||||
C_FLAGS_PCCTS = -I. -I$(ANTLR_H) /WX /Od /EHsc /Zi /Fd$(ETO)\$(TARGET_NAME)Obj /D _CRT_SECURE_NO_DEPRECATE $(VERSION_FLAGS) \
|
||||
$(BUILD_STRING_FLAGS) /D PCCTS_USE_NAMESPACE_STD #/D CVFR_VARDATATYPEDB_DEBUG /D CIFROBJ_DEUBG /D VFREXP_DEBUG
|
||||
|
||||
VFR_GRAMMER_FILE = $(SRC)\VfrSyntax.g
|
||||
|
||||
|
@@ -1,6 +1,6 @@
|
||||
/*++
|
||||
|
||||
Copyright (c) 2004 - 2005, Intel Corporation. All rights reserved.<BR>
|
||||
Copyright (c) 2004 - 2010, 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
|
||||
@@ -31,7 +31,8 @@ Abstract:
|
||||
// This number should be incremented with each change to the VFR compiler.
|
||||
// We write the version to the output list file for debug purposes.
|
||||
//
|
||||
#define VFR_COMPILER_VERSION "1.88"
|
||||
#define UTILITY_VERSION "v1.9"
|
||||
#define UTILITY_NAME "VfrCompile"
|
||||
|
||||
//
|
||||
// Maximum file path for filenames
|
||||
@@ -39,7 +40,6 @@ Abstract:
|
||||
#define MAX_PATH 255
|
||||
#define MAX_QUEUE_COUNT 255
|
||||
#define MAX_LINE_LEN 1024
|
||||
#define PROGRAM_NAME "VfrCompile"
|
||||
|
||||
//
|
||||
// We parse C-style structure definitions which can then be referenced
|
||||
|
@@ -1,6 +1,6 @@
|
||||
/*++
|
||||
|
||||
Copyright (c) 2004 - 2007, Intel Corporation. All rights reserved.<BR>
|
||||
Copyright (c) 2004 - 2010, 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
|
||||
@@ -130,7 +130,7 @@ Returns:
|
||||
// Set our program name for the error printing routines.
|
||||
// Then set printing limits.
|
||||
//
|
||||
SetUtilityName (PROGRAM_NAME);
|
||||
SetUtilityName (UTILITY_NAME);
|
||||
SetPrintLimits (20, 20, 30);
|
||||
//
|
||||
// Process the command-line arguments
|
||||
@@ -145,7 +145,7 @@ Returns:
|
||||
// Verify the VFR script file exists
|
||||
//
|
||||
if ((VfrFptr = fopen (gOptions.VfrFileName, "r")) == NULL) {
|
||||
Error (PROGRAM_NAME, 0, 0, gOptions.VfrFileName, "could not open input VFR file");
|
||||
Error (UTILITY_NAME, 0, 0, gOptions.VfrFileName, "could not open input VFR file");
|
||||
Cleanup();
|
||||
return STATUS_ERROR;
|
||||
}
|
||||
@@ -164,7 +164,7 @@ Returns:
|
||||
}
|
||||
Cmd = (char *)malloc (Len);
|
||||
if (Cmd == NULL) {
|
||||
Error (PROGRAM_NAME, 0, 0, NULL, "could not allocate memory");
|
||||
Error (UTILITY_NAME, 0, 0, NULL, "could not allocate memory");
|
||||
Cleanup();
|
||||
return STATUS_ERROR;
|
||||
}
|
||||
@@ -182,7 +182,7 @@ Returns:
|
||||
strcat (Cmd, gOptions.PreprocessorOutputFileName);
|
||||
Status = system (Cmd);
|
||||
if (Status != 0) {
|
||||
Error (PROGRAM_NAME, 0, 0, gOptions.VfrFileName, "failed to spawn C preprocessor on VFR file");
|
||||
Error (UTILITY_NAME, 0, 0, gOptions.VfrFileName, "failed to spawn C preprocessor on VFR file");
|
||||
printf ("Command: '%s %s'\n", PREPROCESSOR_COMMAND, Cmd);
|
||||
Cleanup();
|
||||
return STATUS_ERROR;
|
||||
@@ -192,7 +192,7 @@ Returns:
|
||||
// Open the preprocessor output file
|
||||
//
|
||||
if ((VfrFptr = fopen (gOptions.PreprocessorOutputFileName, "r")) == NULL) {
|
||||
Error (PROGRAM_NAME, 0, 0, "failed to open input VFR preprocessor output file",
|
||||
Error (UTILITY_NAME, 0, 0, "failed to open input VFR preprocessor output file",
|
||||
gOptions.PreprocessorOutputFileName);
|
||||
Cleanup();
|
||||
return STATUS_ERROR;
|
||||
@@ -339,7 +339,7 @@ Returns:
|
||||
//
|
||||
} else if (_stricmp (Argv[0], "-i") == 0) {
|
||||
if ((Argc < 2) || (Argv[1][0] == '-')) {
|
||||
Error (PROGRAM_NAME, 0, 0, Argv[0], "missing path argument");
|
||||
Error (UTILITY_NAME, 0, 0, Argv[0], "missing path argument");
|
||||
return STATUS_ERROR;
|
||||
}
|
||||
Argc--;
|
||||
@@ -351,7 +351,7 @@ Returns:
|
||||
}
|
||||
IncludePaths = (INT8 *)malloc (Len);
|
||||
if (IncludePaths == NULL) {
|
||||
Error (PROGRAM_NAME, 0, 0, NULL, "memory allocation failure");
|
||||
Error (UTILITY_NAME, 0, 0, NULL, "memory allocation failure");
|
||||
return STATUS_ERROR;
|
||||
}
|
||||
IncludePaths[0] = 0;
|
||||
@@ -367,7 +367,7 @@ Returns:
|
||||
//
|
||||
} else if (_stricmp (Argv[0], "-od") == 0) {
|
||||
if ((Argc < 2) || (Argv[1][0] == '-')) {
|
||||
Error (PROGRAM_NAME, 0, 0, Argv[0], "missing output directory name");
|
||||
Error (UTILITY_NAME, 0, 0, Argv[0], "missing output directory name");
|
||||
return STATUS_ERROR;
|
||||
}
|
||||
Argc--;
|
||||
@@ -383,7 +383,7 @@ Returns:
|
||||
//
|
||||
} else if (_stricmp (Argv[0], "-ppflag") == 0) {
|
||||
if (Argc < 2) {
|
||||
Error (PROGRAM_NAME, 0, 0, Argv[0], "missing C-preprocessor argument");
|
||||
Error (UTILITY_NAME, 0, 0, Argv[0], "missing C-preprocessor argument");
|
||||
return STATUS_ERROR;
|
||||
}
|
||||
Argc--;
|
||||
@@ -394,7 +394,7 @@ Returns:
|
||||
}
|
||||
CPreprocessorOptions = (INT8 *)malloc (Len);
|
||||
if (CPreprocessorOptions == NULL) {
|
||||
Error (PROGRAM_NAME, 0, 0, NULL, "memory allocation failure");
|
||||
Error (UTILITY_NAME, 0, 0, NULL, "memory allocation failure");
|
||||
return STATUS_ERROR;
|
||||
}
|
||||
CPreprocessorOptions[0] = 0;
|
||||
@@ -406,7 +406,7 @@ Returns:
|
||||
strcat (CPreprocessorOptions, Argv[0]);
|
||||
gOptions.CPreprocessorOptions = CPreprocessorOptions;
|
||||
} else {
|
||||
Error (PROGRAM_NAME, 0, 0, Argv[0], "unrecognized option");
|
||||
Error (UTILITY_NAME, 0, 0, Argv[0], "unrecognized option");
|
||||
return STATUS_ERROR;
|
||||
}
|
||||
Argc--;
|
||||
@@ -416,10 +416,10 @@ Returns:
|
||||
// Must specify at least the vfr file name
|
||||
//
|
||||
if (Argc > 1) {
|
||||
Error (PROGRAM_NAME, 0, 0, Argv[1], "unrecognized argument after VFR file name");
|
||||
Error (UTILITY_NAME, 0, 0, Argv[1], "unrecognized argument after VFR file name");
|
||||
return STATUS_ERROR;
|
||||
} else if (Argc < 1) {
|
||||
Error (PROGRAM_NAME, 0, 0, NULL, "must specify VFR file name");
|
||||
Error (UTILITY_NAME, 0, 0, NULL, "must specify VFR file name");
|
||||
return STATUS_ERROR;
|
||||
}
|
||||
strcpy (gOptions.VfrFileName, Argv[0]);
|
||||
@@ -501,26 +501,31 @@ Returns:
|
||||
|
||||
--*/
|
||||
{
|
||||
int Index;
|
||||
const char *Help[] = {
|
||||
" ",
|
||||
"VfrCompile version " VFR_COMPILER_VERSION,
|
||||
" ",
|
||||
" Usage: VfrCompile {options} [VfrFile]",
|
||||
" ",
|
||||
" where options include:",
|
||||
" -? or -h prints this help",
|
||||
" -l create an output IFR listing file",
|
||||
" -i IncPath add IncPath to the search path for VFR included files",
|
||||
" -od OutputDir deposit all output files to directory OutputDir (default=cwd)",
|
||||
" -ibin create an IFR HII pack file",
|
||||
" where parameters include:",
|
||||
" VfrFile name of the input VFR script file",
|
||||
" ",
|
||||
int Index;
|
||||
const char *Str[] = {
|
||||
UTILITY_NAME" "UTILITY_VERSION" - Intel VFR Compiler Utility",
|
||||
" Copyright (C), 2004 - 2008 Intel Corporation",
|
||||
#if ( defined(UTILITY_BUILD) && defined(UTILITY_VENDOR) )
|
||||
" Built from "UTILITY_BUILD", project of "UTILITY_VENDOR,
|
||||
#endif
|
||||
"",
|
||||
"Usage:",
|
||||
" "UTILITY_NAME" [OPTION] VFRFILE",
|
||||
"Description:",
|
||||
" Compile VFRFILE.",
|
||||
"Options:",
|
||||
" -? or -h print this help",
|
||||
" -l create an output IFR listing file",
|
||||
" -i IncPath add IncPath to the search path for VFR included files",
|
||||
" -od OutputDir deposit all output files to directory OutputDir (default=cwd)",
|
||||
" -ibin create an IFR HII pack file",
|
||||
" -ppflag CFlags pass Flags as C-preprocessor-flag",
|
||||
" -v or -version print version information",
|
||||
NULL
|
||||
};
|
||||
for (Index = 0; Help[Index] != NULL; Index++) {
|
||||
fprintf (stdout, "%s\n", Help[Index]);
|
||||
};
|
||||
|
||||
for (Index = 0; Str[Index] != NULL; Index++) {
|
||||
fprintf (stdout, "%s\n", Str[Index]);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -591,7 +596,7 @@ Returns:
|
||||
}
|
||||
gLastLineDefinition = LineDef;
|
||||
} else {
|
||||
Error (PROGRAM_NAME, 0, 0, "invalid line definition in preprocessor output file", TokenString);
|
||||
Error (UTILITY_NAME, 0, 0, "invalid line definition in preprocessor output file", TokenString);
|
||||
free (LineDef);
|
||||
return;
|
||||
}
|
||||
@@ -2318,7 +2323,7 @@ EfiVfrParser::QueueIdEqValList (
|
||||
|
||||
U16 = (UINT16_LIST *)malloc (sizeof (UINT16_LIST));
|
||||
if (U16 == NULL) {
|
||||
Error (PROGRAM_NAME, 0, 0, NULL, "memory allocation failed");
|
||||
Error (UTILITY_NAME, 0, 0, NULL, "memory allocation failed");
|
||||
} else {
|
||||
memset ((char *)U16, 0, sizeof (UINT16_LIST));
|
||||
U16->Value = Value;
|
||||
@@ -2378,7 +2383,7 @@ EfiVfrParser::PrintErrorMessage (
|
||||
FileName = ConvertLineNumber ((UINT32 *)&LineNum);
|
||||
Error (FileName, LineNum, 0, Msg1, Msg2);
|
||||
} else {
|
||||
Error (PROGRAM_NAME, 0, 0, Msg1, Msg2);
|
||||
Error (UTILITY_NAME, 0, 0, Msg1, Msg2);
|
||||
}
|
||||
}
|
||||
VOID
|
||||
@@ -2394,7 +2399,7 @@ EfiVfrParser::PrintWarningMessage (
|
||||
FileName = ConvertLineNumber ((UINT32 *)&LineNum);
|
||||
Warning (FileName, LineNum, 0, Msg1, Msg2);
|
||||
} else {
|
||||
Warning (PROGRAM_NAME, 0, 0, Msg1, Msg2);
|
||||
Warning (UTILITY_NAME, 0, 0, Msg1, Msg2);
|
||||
}
|
||||
}
|
||||
VOID
|
||||
@@ -3357,7 +3362,7 @@ Returns:
|
||||
|
||||
NewRef = (GOTO_REFERENCE *)malloc (sizeof (GOTO_REFERENCE));
|
||||
if (NewRef == NULL) {
|
||||
Error (PROGRAM_NAME, 0, 0, NULL, "memory allocation failure");
|
||||
Error (UTILITY_NAME, 0, 0, NULL, "memory allocation failure");
|
||||
return;
|
||||
}
|
||||
memset ((char *)NewRef, 0, sizeof (GOTO_REFERENCE));
|
||||
@@ -3423,7 +3428,7 @@ Returns:
|
||||
//
|
||||
NewFormId = (FORM_ID_VALUE *)malloc (sizeof (FORM_ID_VALUE));
|
||||
if (NewFormId == NULL) {
|
||||
Error (PROGRAM_NAME, 0, 0, NULL, "memory allocation failure");
|
||||
Error (UTILITY_NAME, 0, 0, NULL, "memory allocation failure");
|
||||
return;
|
||||
}
|
||||
memset ((char *)NewFormId, 0, sizeof (FORM_ID_VALUE));
|
||||
|
@@ -1,6 +1,6 @@
|
||||
/*++
|
||||
|
||||
Copyright (c) 2004 - 2007, Intel Corporation. All rights reserved.<BR>
|
||||
Copyright (c) 2004 - 2010, 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
|
||||
@@ -220,7 +220,7 @@ Returns:
|
||||
//
|
||||
if (GetUtilityStatus () != STATUS_ERROR) {
|
||||
if ((IfrBinFptr = fopen (gOptions.IfrOutputFileName, "w")) == NULL) {
|
||||
Error (PROGRAM_NAME, 0, 0, gOptions.IfrOutputFileName, "could not open file for writing");
|
||||
Error (UTILITY_NAME, 0, 0, gOptions.IfrOutputFileName, "could not open file for writing");
|
||||
return;
|
||||
}
|
||||
//
|
||||
@@ -290,7 +290,7 @@ Returns:
|
||||
strcat (gOptions.IfrOutputFileName, ".hpk");
|
||||
}
|
||||
if ((IfrBinFptr = fopen (gOptions.IfrOutputFileName, "wb")) == NULL) {
|
||||
Error (PROGRAM_NAME, 0, 0, gOptions.IfrOutputFileName, "could not open file for writing");
|
||||
Error (UTILITY_NAME, 0, 0, gOptions.IfrOutputFileName, "could not open file for writing");
|
||||
return;
|
||||
}
|
||||
//
|
||||
@@ -329,10 +329,10 @@ Returns:
|
||||
// Open the input VFR file and the output list file
|
||||
//
|
||||
if ((InFptr = fopen (gOptions.PreprocessorOutputFileName, "r")) == NULL) {
|
||||
Warning (PROGRAM_NAME, 0, 0, gOptions.PreprocessorOutputFileName, "could not open file for creating a list file");
|
||||
Warning (UTILITY_NAME, 0, 0, gOptions.PreprocessorOutputFileName, "could not open file for creating a list file");
|
||||
} else {
|
||||
if ((OutFptr = fopen (gOptions.VfrListFileName, "w")) == NULL) {
|
||||
Warning (PROGRAM_NAME, 0, 0, gOptions.VfrListFileName, "could not open output list file for writing");
|
||||
Warning (UTILITY_NAME, 0, 0, gOptions.VfrListFileName, "could not open output list file for writing");
|
||||
fclose (InFptr);
|
||||
InFptr = NULL;
|
||||
} else {
|
||||
@@ -350,7 +350,7 @@ Returns:
|
||||
//
|
||||
// Write out the VFR compiler version
|
||||
//
|
||||
fprintf (OutFptr, "//\n// VFR compiler version " VFR_COMPILER_VERSION "\n//\n");
|
||||
fprintf (OutFptr, "//\n// VFR compiler version " UTILITY_VERSION "\n//\n");
|
||||
Curr = mIfrBytes;
|
||||
while (Curr != NULL) {
|
||||
//
|
||||
@@ -590,7 +590,7 @@ Returns:
|
||||
// Check for buffer overflow
|
||||
//
|
||||
if (mQueuedByteCount >= MAX_QUEUE_COUNT) {
|
||||
Error (PROGRAM_NAME, 0, 0, NULL, "opcode queue overflow");
|
||||
Error (UTILITY_NAME, 0, 0, NULL, "opcode queue overflow");
|
||||
} else {
|
||||
mQueuedBytes[mQueuedByteCount] = ByteVal;
|
||||
mQueuedKeyBytes[mQueuedByteCount] = KeyByte;
|
||||
@@ -750,5 +750,5 @@ Returns:
|
||||
//
|
||||
// Write out the VFR compiler version
|
||||
//
|
||||
fprintf (OutFptr, "// VFR compiler version " VFR_COMPILER_VERSION "\n//\n");
|
||||
fprintf (OutFptr, "// VFR compiler version " UTILITY_VERSION "\n//\n");
|
||||
}
|
||||
|
@@ -1,6 +1,6 @@
|
||||
#/*++
|
||||
#
|
||||
# Copyright (c) 2004 - 2007, Intel Corporation. All rights reserved.<BR>
|
||||
# Copyright (c) 2004 - 2010, 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
|
||||
@@ -37,7 +37,7 @@ TOOLCHAIN = TOOLCHAIN_MSVC
|
||||
|
||||
TARGET_NAME = VfrCompile
|
||||
ANTLR_H = $(PCCTS_DIR)\h
|
||||
C_FLAGS_PCCTS = -I. -I$(ANTLR_H) /Zi /Fd$(EDK_TOOLS_OUTPUT)\$(TARGET_NAME)Obj /WX /Od /D _CRT_SECURE_NO_DEPRECATE $(VERSION_FLAGS)
|
||||
C_FLAGS_PCCTS = -I. -I$(ANTLR_H) /Zi /Fd$(EDK_TOOLS_OUTPUT)\$(TARGET_NAME)Obj /WX /Od /D _CRT_SECURE_NO_DEPRECATE $(VERSION_FLAGS) $(BUILD_STRING_FLAGS)
|
||||
C_FLAGS_PCCTS = $(C_FLAGS_PCCTS)
|
||||
|
||||
LINK_FLAGS_PCCTS =
|
||||
|
Reference in New Issue
Block a user