File modified to add usage information and implement minor corrections.

git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@1954 6f19259b-4bc3-4df7-8a09-765794883524
This commit is contained in:
ywang
2006-11-14 22:01:45 +00:00
parent 6dbea97890
commit a85cb24e2b
5 changed files with 326 additions and 73 deletions

View File

@ -26,7 +26,9 @@ Abstract:
#include <Common/UefiBaseTypes.h> #include <Common/UefiBaseTypes.h>
#define PROGRAM_NAME "CreateMtFile" #define UTILITY_NAME "CreateMtFile"
#define UTILITY_MAJOR_VERSION 1
#define UTILITY_MINOR_VERSION 1
typedef struct { typedef struct {
INT8 *OutFileName; INT8 *OutFileName;
@ -44,7 +46,13 @@ ProcessArgs (
static static
void void
Usage ( CMFUsage (
VOID
);
static
void
CMFVersion (
VOID VOID
); );
@ -86,11 +94,7 @@ Returns:
// Open the output file // Open the output file
// //
if ((OutFptr = fopen (Options.OutFileName, "wb")) == NULL) { if ((OutFptr = fopen (Options.OutFileName, "wb")) == NULL) {
fprintf ( printf (" ERROR: Could not open output file '%s' for writing\n", Options.OutFileName);
stdout,
PROGRAM_NAME " ERROR: Could not open output file '%s' for writing\n",
Options.OutFileName
);
return EFI_DEVICE_ERROR; return EFI_DEVICE_ERROR;
} }
// //
@ -99,7 +103,7 @@ Returns:
while (Options.FileSize > 0) { while (Options.FileSize > 0) {
if (fwrite (&Options.ByteValue, 1, 1, OutFptr) != 1) { if (fwrite (&Options.ByteValue, 1, 1, OutFptr) != 1) {
fclose (OutFptr); fclose (OutFptr);
fprintf (stdout, PROGRAM_NAME " ERROR: Failed to write to output file\n"); printf (" ERROR: Failed to write to output file\n");
return EFI_DEVICE_ERROR; return EFI_DEVICE_ERROR;
} }
@ -151,15 +155,32 @@ Returns:
// //
Argv++; Argv++;
Argc--; Argc--;
if (Argc < 1) {
CMFUsage();
return EFI_INVALID_PARAMETER;
}
if ((strcmp(Argv[0], "-h") == 0) || (strcmp(Argv[0], "--help") == 0) ||
(strcmp(Argv[0], "-?") == 0) || (strcmp(Argv[0], "/?") == 0)) {
CMFUsage();
return EFI_INVALID_PARAMETER;
}
if ((strcmp(Argv[0], "-V") == 0) || (strcmp(Argv[0], "--version") == 0)) {
CMFVersion();
return EFI_INVALID_PARAMETER;
}
if (Argc < 2) { if (Argc < 2) {
Usage (); CMFUsage ();
return EFI_INVALID_PARAMETER; return EFI_INVALID_PARAMETER;
} }
// //
// If first arg is dash-option, then print usage. // If first arg is dash-option, then print usage.
// //
if (Argv[0][0] == '-') { if (Argv[0][0] == '-') {
Usage (); CMFUsage ();
return EFI_INVALID_PARAMETER; return EFI_INVALID_PARAMETER;
} }
// //
@ -176,13 +197,22 @@ Returns:
if ((Argv[0][strlen (Argv[0]) - 1] == 'k') || (Argv[0][strlen (Argv[0]) - 1] == 'K')) { if ((Argv[0][strlen (Argv[0]) - 1] == 'k') || (Argv[0][strlen (Argv[0]) - 1] == 'K')) {
Multiplier = 1024; Multiplier = 1024;
} }
//
// Check for negtive size
//
if (Argv[0][0] == '-') {
printf("ERROR: File size should be non-negtive.\n");
return EFI_INVALID_PARAMETER;
}
// //
// Look for 0x prefix on file size // Look for 0x prefix on file size
// //
if ((Argv[0][0] == '0') && ((Argv[0][1] == 'x') || (Argv[0][1] == 'X'))) { if ((Argv[0][0] == '0') && ((Argv[0][1] == 'x') || (Argv[0][1] == 'X'))) {
if (sscanf (Argv[0], "%x", &Options->FileSize) != 1) { if (sscanf (Argv[0], "%x", &Options->FileSize) != 1) {
fprintf (stdout, PROGRAM_NAME " ERROR: Invalid file size '%s'\n", Argv[0]); printf ("ERROR: Invalid file size '%s'\n", Argv[0]);
Usage (); CMFUsage ();
return EFI_INVALID_PARAMETER; return EFI_INVALID_PARAMETER;
} }
// //
@ -190,12 +220,12 @@ Returns:
// //
} else { } else {
if (sscanf (Argv[0], "%d", &Options->FileSize) != 1) { if (sscanf (Argv[0], "%d", &Options->FileSize) != 1) {
fprintf (stdout, PROGRAM_NAME " ERROR: Invalid file size '%s'\n", Argv[0]); printf ("ERROR: Invalid file size '%s'\n", Argv[0]);
Usage (); CMFUsage ();
return EFI_INVALID_PARAMETER; return EFI_INVALID_PARAMETER;
} }
} }
Options->FileSize *= Multiplier; Options->FileSize *= Multiplier;
// //
// Assume byte value of 0xff // Assume byte value of 0xff
@ -203,12 +233,39 @@ Returns:
Options->ByteValue = (INT8) (UINT8) 0xFF; Options->ByteValue = (INT8) (UINT8) 0xFF;
return EFI_SUCCESS; return EFI_SUCCESS;
} }
static
void
CMFVersion(
void
)
/*++
Routine Description:
Print out version information for Strip.
Arguments:
None
Returns:
None
--*/
{
printf ("%s v%d.%d -EDK utility to create a pad file containing fixed data\n", UTILITY_NAME, UTILITY_MAJOR_VERSION, UTILITY_MINOR_VERSION);
printf ("Copyright (c) 1999-2006 Intel Corporation. All rights reserved.\n");
}
// //
// Print utility usage info // Print utility usage info
// //
static static
void void
Usage ( CMFUsage (
VOID VOID
) )
/*++ /*++
@ -226,22 +283,15 @@ Returns:
GC_TODO: add return values GC_TODO: add return values
--*/ --*/
{ {
UINT32 Index; CMFVersion();
static const INT8 *Text[] = {
" ", printf ("\n Usage: %s OutFileName FileSize \n\
"Usage: "PROGRAM_NAME " OutFileName FileSize", where: \n\
" where:", OutFileName is the name of the output file to generate \n\
" OutFileName is the name of the output file to generate", FileSize is the size of the file to create \n\
" FileSize is the size of the file to create", Examples: \n\
" Examples:", %s OutFile.bin 32K \n\
" "PROGRAM_NAME " OutFile.bin 32K", %s OutFile.bin 0x1000 \n",UTILITY_NAME, UTILITY_NAME, UTILITY_NAME);
" "PROGRAM_NAME " OutFile.bin 0x1000", }
" ",
NULL
};
for (Index = 0; Text[Index] != NULL; Index++) {
fprintf (stdout, "%s\n", Text[Index]);
}
}

View File

@ -27,9 +27,61 @@ Abstract:
#include <stdio.h> #include <stdio.h>
#include <Common/UefiBaseTypes.h> #include <Common/UefiBaseTypes.h>
#include "EfiCompress.h" #include "EfiCompress.h"
#define UTILITY_NAME "EfiCompress"
#define UTILITY_MAJOR_VERSION 1
#define UTILITY_MINOR_VERSION 1
void
ECVersion(
void
)
/*++
Routine Description:
Print out version information for EfiCompress.
Arguments:
None
Returns:
None
--*/
{
printf ("%s v%d.%d -EDK Efi Compress Utility\n", UTILITY_NAME, UTILITY_MAJOR_VERSION, UTILITY_MINOR_VERSION);
printf ("Copyright (c) 2005-2006 Intel Corporation. All rights reserved.\n");
}
void
ECUsage(
void
)
/*++
Routine Description:
Print out usage information for EfiCompress.
Arguments:
None
Returns:
None
--*/
{
ECVersion();
printf ("\n Usage: %s Inputfile Outputfile\n", UTILITY_NAME);
}
int int
main ( main (
INT32 argc, INT32 argc,
@ -65,19 +117,28 @@ Returns:
// Added for makefile debug - KCE // Added for makefile debug - KCE
// //
INT32 arg_counter; INT32 arg_counter;
printf ("\n\n");
for (arg_counter = 0; arg_counter < argc; arg_counter++) {
printf ("%s ", argv[arg_counter]);
}
printf ("\n\n");
SrcBuffer = DstBuffer = NULL; SrcBuffer = DstBuffer = NULL;
infile = outfile = NULL; infile = outfile = NULL;
if (argc < 1) {
ECUsage();
goto Done;
}
if ((strcmp(argv[1], "-h") == 0) || (strcmp(argv[1], "--help") == 0) ||
(strcmp(argv[1], "-?") == 0) || (strcmp(argv[1], "/?") == 0)) {
ECUsage();
goto Done;
}
if ((strcmp(argv[1], "-V") == 0) || (strcmp(argv[1], "--version") == 0)) {
ECVersion();
goto Done;
}
if (argc != 3) { if (argc != 3) {
printf ("Usage: EFICOMPRESS <infile> <outfile>\n"); ECUsage();
goto Done; goto Done;
} }

View File

@ -1,6 +1,6 @@
/*++ /*++
Copyright (c) 2004, Intel Corporation Copyright (c) 2004-2006, 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
@ -86,7 +86,7 @@ ParseDepex (
); );
VOID VOID
PrintGenDepexUtilityInfo ( GDVersion (
VOID VOID
) )
/*++ /*++
@ -111,11 +111,11 @@ Returns:
UTILITY_MAJOR_VERSION, UTILITY_MAJOR_VERSION,
UTILITY_MINOR_VERSION UTILITY_MINOR_VERSION
); );
printf ("Copyright (C) 1996-2002 Intel Corporation. All rights reserved.\n\n"); printf ("Copyright (C) 1996-2006 Intel Corporation. All rights reserved.\n");
} }
VOID VOID
PrintGenDepexUsageInfo ( GDUsage (
VOID VOID
) )
/*++ /*++
@ -134,15 +134,16 @@ Returns:
--*/ --*/
{ {
GDVersion();
printf ( printf (
"Usage: %s -I <INFILE> -O <OUTFILE> [-P <Optional Boundary for padding up>] \n", "\n Usage: %s -I InputFile -O OutputFile [-P <Optional Boundary for padding up>] \n",
UTILITY_NAME UTILITY_NAME
); );
printf (" Where:\n"); printf (" Where:\n");
printf (" <INFILE> is the input pre-processed dependency text files name.\n"); printf (" InputFile is the input pre-processed dependency text files name.\n");
printf (" <OUTFILE> is the output binary dependency files name.\n"); printf (" OutputFile is the output binary dependency files name.\n");
printf (" <Optional Boundary for padding up> is the padding integer value.\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"); printf (" This is the boundary to align the output file size to.\n");
} }
DEPENDENCY_OPCODE DEPENDENCY_OPCODE
@ -855,9 +856,25 @@ Returns:
Output_Flag = FALSE; Output_Flag = FALSE;
Pad_Flag = FALSE; Pad_Flag = FALSE;
if (argc < 1) {
GDUsage();
return -1;
}
if ((strcmp(argv[1], "-h") == 0) || (strcmp(argv[1], "--help") == 0) ||
(strcmp(argv[1], "-?") == 0) || (strcmp(argv[1], "/?") == 0)) {
GDUsage();
return 0;
}
if ((strcmp(argv[1], "-V") == 0) || (strcmp(argv[1], "--version") == 0)) {
GDVersion();
return 0;
}
if (argc < 5) { if (argc < 5) {
printf ("Not enough arguments\n"); printf ("Not enough arguments\n");
PrintGenDepexUsageInfo (); GDUsage();
return EFI_INVALID_PARAMETER; return EFI_INVALID_PARAMETER;
} }
@ -901,17 +918,15 @@ Returns:
} }
} }
PrintGenDepexUtilityInfo ();
if (InFile == NULL) { if (InFile == NULL) {
printf ("Can not open <INFILE> for reading.\n"); printf ("Can not open <INFILE> for reading.\n");
PrintGenDepexUsageInfo (); GDUsage();
return EFI_ABORTED; return EFI_ABORTED;
} }
if (OutFile == NULL) { if (OutFile == NULL) {
printf ("Can not open <OUTFILE> for writting.\n"); printf ("Can not open <OUTFILE> for writting.\n");
PrintGenDepexUsageInfo (); GDUsage();
return EFI_ABORTED; return EFI_ABORTED;
} }

View File

@ -24,6 +24,10 @@ Abstract:
#include "stdio.h" #include "stdio.h"
#include "string.h" #include "string.h"
#define UTILITY_NAME "ModifyInf"
#define UTILITY_MAJOR_VERSION 1
#define UTILITY_MINOR_VERSION 1
// //
// Read a line into buffer including '\r\n' // Read a line into buffer including '\r\n'
// //
@ -242,29 +246,67 @@ Returns:
return 0; return 0;
} }
void void
Usage ( MIVersion(
void void
) )
/*++ /*++
Routine Description: Routine Description:
GC_TODO: Add function description Print out version information for Strip.
Arguments: Arguments:
None None
Returns: Returns:
GC_TODO: add return values None
--*/ --*/
{ {
printf ("ModifyInf InputFVInfFileName OutputFVInfFileName [Pattern strings]\r\n"); printf ("%s v%d.%d -EDK Modify fields in FV inf files.\n", UTILITY_NAME, UTILITY_MAJOR_VERSION, UTILITY_MINOR_VERSION);
printf ("Copyright (c) 2005-2006 Intel Corporation. All rights reserved.\n");
} }
void
MIUsage(
void
)
/*++
Routine Description:
Print out usage information for Strip.
Arguments:
None
Returns:
None
--*/
{
MIVersion();
printf ("\n Usage: %s InputFile OutputFile Pattern_String [Pattern_String <20><>]\n\
Where: \n\
Pattern_String is of the format (note that the section name must be \n\
enclosed within square brackets):\n\
[section]FieldKey<op>Value [(FieldKey<op>Value) <20><>] \n\
The operator, <op>, must be one of the following: \n\
'==' replace a field value with a new value \n\
'+=' append a string at the end of original line \n\
'-' prevent the line from applying any patterns \n\
Example: \n\
ModifyInf BuildRootFvFvMain.inf BuildRootFvFvMainEXP.inf \\ \n\
[files]EFI_FILE_NAME+=.Org EFI_NUM_BLOCKS==0x20 \\ \n\
[options]EFI_FILENAME==FcMainCompact.fv -DpsdSignature.dxe \n", UTILITY_NAME);
}
int int
main ( main (
int argc, int argc,
@ -291,8 +333,24 @@ Returns:
FILE *fpin; FILE *fpin;
FILE *fpout; FILE *fpout;
if (argc < 1) {
MIUsage();
return -1;
}
if ((strcmp(argv[1], "-h") == 0) || (strcmp(argv[1], "--help") == 0) ||
(strcmp(argv[1], "-?") == 0) || (strcmp(argv[1], "/?") == 0)) {
MIUsage();
return 0;
}
if ((strcmp(argv[1], "-V") == 0) || (strcmp(argv[1], "--version") == 0)) {
MIVersion();
return 0;
}
if (argc < 3) { if (argc < 3) {
Usage (); MIUsage();
return -1; return -1;
} }

View File

@ -25,6 +25,59 @@ Abstract:
#include <string.h> #include <string.h>
#include <stdlib.h> #include <stdlib.h>
#define UTILITY_NAME "Strip"
#define UTILITY_MAJOR_VERSION 1
#define UTILITY_MINOR_VERSION 1
void
StripVersion(
void
)
/*++
Routine Description:
Print out version information for Strip.
Arguments:
None
Returns:
None
--*/
{
printf ("%s v%d.%d -EDK Convert EXE to BIN\n", UTILITY_NAME, UTILITY_MAJOR_VERSION, UTILITY_MINOR_VERSION);
printf ("Copyright (c) 2005-2006 Intel Corporation. All rights reserved.\n");
}
void
StripUsage(
void
)
/*++
Routine Description:
Print out usage information for Strip.
Arguments:
None
Returns:
None
--*/
{
StripVersion();
printf ("\n Usage: %s InputFile OutputFile\n", UTILITY_NAME);
}
int int
main ( main (
int argc, int argc,
@ -54,9 +107,25 @@ Returns:
int FileSize; int FileSize;
char *Buffer; char *Buffer;
char *Ptrx; char *Ptrx;
if (argc < 1) {
StripUsage();
return -1;
}
if ((strcmp(argv[1], "-h") == 0) || (strcmp(argv[1], "--help") == 0) ||
(strcmp(argv[1], "-?") == 0) || (strcmp(argv[1], "/?") == 0)) {
StripUsage();
return 0;
}
if ((strcmp(argv[1], "-V") == 0) || (strcmp(argv[1], "--version") == 0)) {
StripVersion();
return 0;
}
if (argc < 3) { if (argc < 3) {
printf ("Need more args, such as file name to convert and output name\n"); StripUsage();
return -1; return -1;
} }
@ -64,12 +133,12 @@ Returns:
OutFile = fopen (argv[2], "wb"); OutFile = fopen (argv[2], "wb");
if (!InFile) { if (!InFile) {
printf ("no file, exit\n"); printf ("Unable to open input file, exit\n");
return -1; return -1;
} }
if (OutFile == NULL) { if (OutFile == NULL) {
printf ("Unable to open output file.\n"); printf ("Unable to open output file, exit.\n");
return -1; return -1;
} }
@ -77,7 +146,7 @@ Returns:
FileSize = ftell (InFile); FileSize = ftell (InFile);
if (FileSize < 0x200) { if (FileSize < 0x200) {
printf ("%d is not a legal size, exit\n", FileSize); printf ("%d is not a legal file size, exit\n", FileSize);
return -1; return -1;
} }