Minor changes and bug fixes implemented.

git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@2196 6f19259b-4bc3-4df7-8a09-765794883524
This commit is contained in:
ywang 2007-01-08 22:27:20 +00:00
parent 66d8c20686
commit db608e6b5b
13 changed files with 237 additions and 76 deletions

View File

@ -121,7 +121,7 @@ Returns:
SrcBuffer = DstBuffer = NULL; SrcBuffer = DstBuffer = NULL;
infile = outfile = NULL; infile = outfile = NULL;
if (argc < 1) { if (argc == 1) {
Usage(); Usage();
goto Done; goto Done;
} }

View File

@ -762,7 +762,7 @@ Returns:
TimeStamp = 0; TimeStamp = 0;
TimeStampPresent = FALSE; TimeStampPresent = FALSE;
if (argc < 1) { if (argc == 1) {
Usage(); Usage();
return STATUS_ERROR; return STATUS_ERROR;
} }

View File

@ -394,7 +394,7 @@ Returns:
Index = 0; Index = 0;
Invert = 0; Invert = 0;
if (argc < 1) { if (argc == 1) {
Usage(); Usage();
return -1; return -1;
} }

View File

@ -2559,7 +2559,7 @@ Returns:
// //
// Verify the correct number of arguments // Verify the correct number of arguments
// //
if (argc < 1) { if (argc == 1) {
Usage(); Usage();
return 1; return 1;
} }

View File

@ -239,6 +239,11 @@ main (
OutputFileName = NULL; OutputFileName = NULL;
SetUtilityName (UTILITY_NAME); SetUtilityName (UTILITY_NAME);
if (argc == 1) {
Usage ();
return -1;
}
if ((strcmp(argv[1], "-h") == 0) || (strcmp(argv[1], "--help") == 0) || if ((strcmp(argv[1], "-h") == 0) || (strcmp(argv[1], "--help") == 0) ||
(strcmp(argv[1], "-?") == 0) || (strcmp(argv[1], "/?") == 0)) { (strcmp(argv[1], "-?") == 0) || (strcmp(argv[1], "/?") == 0)) {
@ -250,11 +255,6 @@ main (
Version(); Version();
return -1; return -1;
} }
if (argc == 1) {
Usage ();
return -1;
}
BufferSize = 1024 * 1024 * 16; BufferSize = 1024 * 1024 * 16;
FileBuffer = (UINT8 *) malloc (BufferSize * sizeof (UINT8)); FileBuffer = (UINT8 *) malloc (BufferSize * sizeof (UINT8));

View File

@ -2379,6 +2379,11 @@ Returns:
Version(); Version();
return STATUS_ERROR; return STATUS_ERROR;
} }
if (Argc == 1) {
Usage ();
return STATUS_ERROR;
}
// //
// Process until no more options // Process until no more options

View File

@ -106,7 +106,7 @@ Returns:
--*/ --*/
{ {
printf ( printf (
"%s, Tiano Dependency Expression Generation Utility. Version %d.%d.\n", "%s v%d.%d -Tiano utility to generate dependency expression.\n",
UTILITY_NAME, UTILITY_NAME,
UTILITY_MAJOR_VERSION, UTILITY_MAJOR_VERSION,
UTILITY_MINOR_VERSION UTILITY_MINOR_VERSION
@ -855,16 +855,22 @@ Returns:
Output_Flag = FALSE; Output_Flag = FALSE;
Pad_Flag = FALSE; Pad_Flag = FALSE;
// if (argc == 1) {
// Output the calling arguments Usage();
// return EFI_INVALID_PARAMETER;
printf ("\n\n");
for (Index = 0; Index < argc; Index++) {
printf ("%s ", argv[Index]);
} }
printf ("\n\n"); if ((strcmp(argv[1], "-h") == 0) || (strcmp(argv[1], "--help") == 0) ||
(strcmp(argv[1], "-?") == 0) || (strcmp(argv[1], "/?") == 0)) {
Usage();
return EFI_INVALID_PARAMETER;
}
if ((strcmp(argv[1], "-V") == 0) || (strcmp(argv[1], "--version") == 0)) {
Version();
return EFI_INVALID_PARAMETER;
}
if (argc < 5) { if (argc < 5) {
printf ("Not enough arguments\n"); printf ("Not enough arguments\n");
Usage(); Usage();

View File

@ -1,6 +1,6 @@
/*++ /*++
Copyright (c) 2004, Intel Corporation Copyright (c) 2004-2007, Intel Corporation
All rights reserved. This program and the accompanying materials All rights reserved. This program and the accompanying materials
are licensed and made available under the terms and conditions of the BSD License 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 which accompanies this distribution. The full text of the license may be found at
@ -46,8 +46,10 @@ Abstract:
#include "EfiUtilityMsgs.h" #include "EfiUtilityMsgs.h"
#include "SimpleFileParsing.h" #include "SimpleFileParsing.h"
#define UTILITY_NAME "GenFfsFile" #define UTILITY_NAME "GenFfsFile"
#define TOOLVERSION "0.32" #define UTILITY_MAJOR_VERSION 0
#define UTILITY_MINOR_VERSION 32
#define MAX_ARRAY_SIZE 100 #define MAX_ARRAY_SIZE 100
static static
@ -83,7 +85,13 @@ ProcessCommandLineArgs (
static static
void void
PrintUsage ( Version (
void
);
static
void
Usage (
void void
); );
@ -134,9 +142,34 @@ Returns:
String[Index - Index2] = 0; String[Index - Index2] = 0;
} }
static
void
Version(
void
)
/*++
Routine Description:
Print out version information for this utility.
Arguments:
None
Returns:
None
--*/
{
printf ("%s v%d.%d -EDK utility to generate a Firmware File System files.\n", UTILITY_NAME, UTILITY_MAJOR_VERSION, UTILITY_MINOR_VERSION);
printf ("Copyright (c) 1999-2007 Intel Corporation. All rights reserved.\n");
}
static static
void void
PrintUsage ( Usage (
void void
) )
/*++ /*++
@ -155,7 +188,9 @@ Returns:
--*/ --*/
{ {
printf ("Usage:\n"); Version();
printf ("\nUsage:\n");
printf (UTILITY_NAME " -b \"build directory\" -p1 \"package1.inf\" -p2 \"package2.inf\" -v\n"); printf (UTILITY_NAME " -b \"build directory\" -p1 \"package1.inf\" -p2 \"package2.inf\" -v\n");
printf (" -b \"build directory\":\n "); printf (" -b \"build directory\":\n ");
printf (" specifies the full path to the component build directory.\n"); printf (" specifies the full path to the component build directory.\n");
@ -2545,14 +2580,27 @@ Returns:
// //
// If no args, then print usage instructions and return an error // If no args, then print usage instructions and return an error
// //
if (Argc == 1) {
PrintUsage ();
return STATUS_ERROR;
}
memset (&mGlobals, 0, sizeof (mGlobals));
Argc--; Argc--;
Argv++; Argv++;
if (Argc < 1) {
Usage ();
return STATUS_ERROR;
}
if ((strcmp(Argv[0], "-h") == 0) || (strcmp(Argv[0], "--help") == 0) ||
(strcmp(Argv[0], "-?") == 0) || (strcmp(Argv[0], "/?") == 0)) {
Usage();
return STATUS_ERROR;
}
if ((strcmp(Argv[0], "-V") == 0) || (strcmp(Argv[0], "--version") == 0)) {
Version();
return STATUS_ERROR;
}
memset (&mGlobals, 0, sizeof (mGlobals));
while (Argc > 0) { while (Argc > 0) {
if (strcmpi (Argv[0], "-b") == 0) { if (strcmpi (Argv[0], "-b") == 0) {
// //
@ -2617,17 +2665,17 @@ Returns:
// //
// OPTION: -h help // OPTION: -h help
// //
PrintUsage (); Usage ();
return STATUS_ERROR; return STATUS_ERROR;
} else if (strcmpi (Argv[0], "-?") == 0) { } else if (strcmpi (Argv[0], "-?") == 0) {
// //
// OPTION: -? help // OPTION: -? help
// //
PrintUsage (); Usage ();
return STATUS_ERROR; return STATUS_ERROR;
} else { } else {
Error (NULL, 0, 0, Argv[0], "unrecognized option"); Error (NULL, 0, 0, Argv[0], "unrecognized option");
PrintUsage (); Usage ();
return STATUS_ERROR; return STATUS_ERROR;
} }

View File

@ -1,6 +1,6 @@
/*++ /*++
Copyright (c) 2004, Intel Corporation Copyright (c) 2004-2007, Intel Corporation
All rights reserved. This program and the accompanying materials All rights reserved. This program and the accompanying materials
are licensed and made available under the terms and conditions of the BSD License 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 which accompanies this distribution. The full text of the license may be found at
@ -29,10 +29,11 @@ Abstract:
#include "CommonLib.h" #include "CommonLib.h"
#include "EfiUtilityMsgs.h" #include "EfiUtilityMsgs.h"
VOID static
PrintUtilityInfo ( void
VOID Version(
) void
)
/*++ /*++
Routine Description: Routine Description:
@ -49,17 +50,15 @@ Returns:
--*/ --*/
{ {
printf ( printf ("%s v%d.%d -Tiano Firmware Volume Generation Utility.\n", UTILITY_NAME, UTILITY_MAJOR_VERSION, UTILITY_MINOR_VERSION);
"%s - Tiano Firmware Volume Generation Utility."" Version %i.%i\n\n", printf ("Copyright (c) 1999-2007 Intel Corporation. All rights reserved.\n");
UTILITY_NAME,
UTILITY_MAJOR_VERSION,
UTILITY_MINOR_VERSION
);
} }
VOID static
PrintUsage ( void
VOID Usage(
void
) )
/*++ /*++
@ -77,9 +76,11 @@ Returns:
--*/ --*/
{ {
printf ("Usage: %s -I FvInfFileName\n", UTILITY_NAME); Version();
printf ("\nUsage: %s -I FvInfFileName\n", UTILITY_NAME);
printf (" Where:\n"); printf (" Where:\n");
printf ("\tFvInfFileName is the name of the image description file.\n\n"); printf (" FvInfFileName is the name of the image description file.\n\n");
} }
int int
@ -133,17 +134,29 @@ Returns:
SymFileName = SymFileNameBuffer; SymFileName = SymFileNameBuffer;
SetUtilityName (UTILITY_NAME); SetUtilityName (UTILITY_NAME);
//
// Display utility information if (argc == 1) {
// Usage ();
PrintUtilityInfo (); return STATUS_ERROR;
}
if ((strcmp(argv[1], "-h") == 0) || (strcmp(argv[1], "--help") == 0) ||
(strcmp(argv[1], "-?") == 0) || (strcmp(argv[1], "/?") == 0)) {
Usage();
return GetUtilityStatus ();
}
if ((strcmp(argv[1], "-V") == 0) || (strcmp(argv[1], "--version") == 0)) {
Version();
return GetUtilityStatus ();
}
// //
// Verify the correct number of arguments // Verify the correct number of arguments
// //
if (argc != MAX_ARGS) { if (argc != MAX_ARGS) {
Error (NULL, 0, 0, "invalid number of input parameters specified", NULL); Error (NULL, 0, 0, "invalid number of input parameters specified", NULL);
PrintUsage (); Usage ();
return GetUtilityStatus (); return GetUtilityStatus ();
} }
// //
@ -160,7 +173,7 @@ Returns:
// //
if (argv[Index][0] != '-' && argv[Index][0] != '/') { if (argv[Index][0] != '-' && argv[Index][0] != '/') {
Error (NULL, 0, 0, argv[Index], "argument pair must begin with \"-\" or \"/\""); Error (NULL, 0, 0, argv[Index], "argument pair must begin with \"-\" or \"/\"");
PrintUsage (); Usage ();
return GetUtilityStatus (); return GetUtilityStatus ();
} }
// //
@ -168,7 +181,7 @@ Returns:
// //
if (argv[Index][2] != 0) { if (argv[Index][2] != 0) {
Error (NULL, 0, 0, argv[Index], "unrecognized argument"); Error (NULL, 0, 0, argv[Index], "unrecognized argument");
PrintUsage (); Usage ();
return GetUtilityStatus (); return GetUtilityStatus ();
} }
// //
@ -182,14 +195,14 @@ Returns:
strcpy (InfFileName, argv[Index + 1]); strcpy (InfFileName, argv[Index + 1]);
} else { } else {
Error (NULL, 0, 0, argv[Index + 1], "FvInfFileName may only be specified once"); Error (NULL, 0, 0, argv[Index + 1], "FvInfFileName may only be specified once");
PrintUsage (); Usage ();
return GetUtilityStatus (); return GetUtilityStatus ();
} }
break; break;
default: default:
Error (NULL, 0, 0, argv[Index], "unrecognized argument"); Error (NULL, 0, 0, argv[Index], "unrecognized argument");
PrintUsage (); Usage ();
return GetUtilityStatus (); return GetUtilityStatus ();
break; break;
} }

View File

@ -36,6 +36,9 @@ Abstract:
#define UTILITY_NAME "GenSection" #define UTILITY_NAME "GenSection"
#define UTILITY_MAJOR_VERSION 0
#define UTILITY_MINOR_VERSION 1
#define PARAMETER_NOT_SPECIFIED "Parameter not specified" #define PARAMETER_NOT_SPECIFIED "Parameter not specified"
#define MAXIMUM_INPUT_FILE_NUM 10 #define MAXIMUM_INPUT_FILE_NUM 10
@ -75,16 +78,43 @@ char *CompressionTypeName[] = { "NONE", "STANDARD" };
char *GUIDedSectionTypeName[] = { "CRC32" }; char *GUIDedSectionTypeName[] = { "CRC32" };
EFI_GUID gEfiCrc32SectionGuid = EFI_CRC32_GUIDED_SECTION_EXTRACTION_PROTOCOL_GUID; EFI_GUID gEfiCrc32SectionGuid = EFI_CRC32_GUIDED_SECTION_EXTRACTION_PROTOCOL_GUID;
static
void
Version(
void
)
/*++
Routine Description:
Print out version information for this utility.
Arguments:
None
Returns:
None
--*/
{
printf ("%s v%d.%d -Utility to create output file with formed section per the FV spec.\n", UTILITY_NAME, UTILITY_MAJOR_VERSION, UTILITY_MINOR_VERSION);
printf ("Copyright (c) 1999-2007 Intel Corporation. All rights reserved.\n");
}
static static
VOID VOID
PrintUsageMessage ( Usage (
VOID VOID
) )
{ {
UINTN SectionType; UINTN SectionType;
UINTN DisplayCount; UINTN DisplayCount;
printf ("Usage: "UTILITY_NAME " -i InputFile -o OutputFile -s SectionType [SectionType params]\n\n"); Version();
printf ("\nUsage: "UTILITY_NAME " -i InputFile -o OutputFile -s SectionType [SectionType params]\n\n");
printf (" Where SectionType is one of the following section types:\n\n"); printf (" Where SectionType is one of the following section types:\n\n");
DisplayCount = 0; DisplayCount = 0;
@ -659,10 +689,23 @@ Returns:
Status = EFI_SUCCESS; Status = EFI_SUCCESS;
SetUtilityName (UTILITY_NAME); SetUtilityName (UTILITY_NAME);
if (argc == 1) { if (argc == 1) {
PrintUsageMessage (); Usage ();
return STATUS_ERROR; return STATUS_ERROR;
} }
if ((strcmp(argv[1], "-h") == 0) || (strcmp(argv[1], "--help") == 0) ||
(strcmp(argv[1], "-?") == 0) || (strcmp(argv[1], "/?") == 0)) {
Usage();
return STATUS_ERROR;
}
if ((strcmp(argv[1], "-V") == 0) || (strcmp(argv[1], "--version") == 0)) {
Version();
return STATUS_ERROR;
}
// //
// Parse command line // Parse command line
// //
@ -758,7 +801,7 @@ Returns:
Index++; Index++;
ParamDigitalSignature = argv[Index]; ParamDigitalSignature = argv[Index];
} else if (strcmpi (argv[Index], "-?") == 0) { } else if (strcmpi (argv[Index], "-?") == 0) {
PrintUsageMessage (); Usage ();
return STATUS_ERROR; return STATUS_ERROR;
} else { } else {
Error (NULL, 0, 0, argv[Index], "unknown option"); Error (NULL, 0, 0, argv[Index], "unknown option");
@ -781,7 +824,7 @@ Returns:
SectionSubType = EFI_STANDARD_COMPRESSION; SectionSubType = EFI_STANDARD_COMPRESSION;
} else { } else {
Error (NULL, 0, 0, ParamSectionSubType, "unknown compression type"); Error (NULL, 0, 0, ParamSectionSubType, "unknown compression type");
PrintUsageMessage (); Usage ();
return GetUtilityStatus (); return GetUtilityStatus ();
} }
} else if (stricmp (ParamSectionType, SectionTypeName[EFI_SECTION_GUID_DEFINED]) == 0) { } else if (stricmp (ParamSectionType, SectionTypeName[EFI_SECTION_GUID_DEFINED]) == 0) {
@ -791,7 +834,7 @@ Returns:
SectionSubType = EFI_SECTION_CRC32_GUID_DEFINED; SectionSubType = EFI_SECTION_CRC32_GUID_DEFINED;
} else { } else {
Error (NULL, 0, 0, ParamSectionSubType, "unknown GUID defined section type", ParamSectionSubType); Error (NULL, 0, 0, ParamSectionSubType, "unknown GUID defined section type", ParamSectionSubType);
PrintUsageMessage (); Usage ();
return GetUtilityStatus (); return GetUtilityStatus ();
} }
} else if (stricmp (ParamSectionType, SectionTypeName[EFI_SECTION_PE32]) == 0) { } else if (stricmp (ParamSectionType, SectionTypeName[EFI_SECTION_PE32]) == 0) {
@ -808,7 +851,7 @@ Returns:
Index = sscanf (ParamVersion, "%d", &VersionNumber); Index = sscanf (ParamVersion, "%d", &VersionNumber);
if (Index != 1 || VersionNumber < 0 || VersionNumber > 65565) { if (Index != 1 || VersionNumber < 0 || VersionNumber > 65565) {
Error (NULL, 0, 0, ParamVersion, "illegal version number"); Error (NULL, 0, 0, ParamVersion, "illegal version number");
PrintUsageMessage (); Usage ();
return GetUtilityStatus (); return GetUtilityStatus ();
} }
@ -820,7 +863,7 @@ Returns:
InputFileRequired = FALSE; InputFileRequired = FALSE;
if (strcmp (AuxString, PARAMETER_NOT_SPECIFIED) == 0) { if (strcmp (AuxString, PARAMETER_NOT_SPECIFIED) == 0) {
Error (NULL, 0, 0, "user interface string not specified", NULL); Error (NULL, 0, 0, "user interface string not specified", NULL);
PrintUsageMessage (); Usage ();
return GetUtilityStatus (); return GetUtilityStatus ();
} }
} else if (stricmp (ParamSectionType, SectionTypeName[EFI_SECTION_COMPATIBILITY16]) == 0) { } else if (stricmp (ParamSectionType, SectionTypeName[EFI_SECTION_COMPATIBILITY16]) == 0) {
@ -835,7 +878,7 @@ Returns:
SectionType = EFI_SECTION_PEI_DEPEX; SectionType = EFI_SECTION_PEI_DEPEX;
} else { } else {
Error (NULL, 0, 0, ParamSectionType, "unknown section type"); Error (NULL, 0, 0, ParamSectionType, "unknown section type");
PrintUsageMessage (); Usage ();
return GetUtilityStatus (); return GetUtilityStatus ();
} }
// //

View File

@ -34,7 +34,8 @@ Abstract:
// Version of this utility // Version of this utility
// //
#define UTILITY_NAME "GenTEImage" #define UTILITY_NAME "GenTEImage"
#define UTILITY_VERSION "v0.11" #define UTILITY_MAJOR_VERSION 0
#define UTILITY_MINOR_VERSION 11
// //
// Define the max length of a filename // Define the max length of a filename
@ -84,6 +85,12 @@ static STRING_LOOKUP mSubsystemTypes[] = {
// //
// Function prototypes // Function prototypes
// //
static
void
Version (
VOID
);
static static
void void
Usage ( Usage (
@ -669,6 +676,18 @@ Returns:
Usage (); Usage ();
return STATUS_ERROR; return STATUS_ERROR;
} }
if ((strcmp(Argv[0], "-h") == 0) || (strcmp(Argv[0], "--help") == 0) ||
(strcmp(Argv[0], "-?") == 0) || (strcmp(Argv[0], "/?") == 0)) {
Usage();
return STATUS_ERROR;
}
if ((strcmp(Argv[0], "-V") == 0) || (strcmp(Argv[0], "--version") == 0)) {
Version();
return STATUS_ERROR;
}
// //
// Process until no more arguments // Process until no more arguments
// //
@ -733,6 +752,31 @@ Returns:
return STATUS_SUCCESS; return STATUS_SUCCESS;
} }
static
void
Version(
void
)
/*++
Routine Description:
Displays the standard utility information to SDTOUT
Arguments:
None
Returns:
None
--*/
{
printf ("%s v%d.%d -Utility to generate a TE image from an EFI PE32 image.\n", UTILITY_NAME, UTILITY_MAJOR_VERSION, UTILITY_MINOR_VERSION);
printf ("Copyright (c) 1999-2007 Intel Corporation. All rights reserved.\n");
}
static static
void void
Usage ( Usage (
@ -756,19 +800,21 @@ Returns:
{ {
int Index; int Index;
static const char *Msg[] = { static const char *Msg[] = {
UTILITY_NAME " version "UTILITY_VERSION " - TE image utility", "\nUsage: "UTILITY_NAME " {-v} {-dump} {-h|-?} {-o OutFileName} InFileName",
" Generate a TE image from an EFI PE32 image",
" Usage: "UTILITY_NAME " {-v} {-dump} {-h|-?} {-o OutFileName} InFileName",
" [-e|-b] [FileName(s)]", " [-e|-b] [FileName(s)]",
" where:", " where:",
" -h,--help,-?,/? to display help messages",
" -V,--version to display version information",
" -v - for verbose output", " -v - for verbose output",
" -dump - to dump the input file to a text file", " -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, " -o OutFileName - to write output to OutFileName rather than InFileName"DEFAULT_OUTPUT_EXTENSION,
" InFileName - name of the input PE32 file", " InFileName - name of the input PE32 file",
"", "",
NULL NULL
}; };
Version();
for (Index = 0; Msg[Index] != NULL; Index++) { for (Index = 0; Msg[Index] != NULL; Index++) {
fprintf (stdout, "%s\n", Msg[Index]); fprintf (stdout, "%s\n", Msg[Index]);
} }

View File

@ -333,7 +333,7 @@ Returns:
FILE *fpin; FILE *fpin;
FILE *fpout; FILE *fpout;
if (argc < 1) { if (argc == 1) {
Usage(); Usage();
return -1; return -1;
} }

View File

@ -108,7 +108,7 @@ Returns:
char *Buffer; char *Buffer;
char *Ptrx; char *Ptrx;
if (argc < 1) { if (argc == 1) {
Usage(); Usage();
return -1; return -1;
} }