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>
#define PROGRAM_NAME "CreateMtFile"
#define UTILITY_NAME "CreateMtFile"
#define UTILITY_MAJOR_VERSION 1
#define UTILITY_MINOR_VERSION 1
typedef struct {
INT8 *OutFileName;
@ -44,7 +46,13 @@ ProcessArgs (
static
void
Usage (
CMFUsage (
VOID
);
static
void
CMFVersion (
VOID
);
@ -86,11 +94,7 @@ Returns:
// Open the output file
//
if ((OutFptr = fopen (Options.OutFileName, "wb")) == NULL) {
fprintf (
stdout,
PROGRAM_NAME " ERROR: Could not open output file '%s' for writing\n",
Options.OutFileName
);
printf (" ERROR: Could not open output file '%s' for writing\n", Options.OutFileName);
return EFI_DEVICE_ERROR;
}
//
@ -99,7 +103,7 @@ Returns:
while (Options.FileSize > 0) {
if (fwrite (&Options.ByteValue, 1, 1, OutFptr) != 1) {
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;
}
@ -151,15 +155,32 @@ Returns:
//
Argv++;
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) {
Usage ();
CMFUsage ();
return EFI_INVALID_PARAMETER;
}
//
// If first arg is dash-option, then print usage.
//
if (Argv[0][0] == '-') {
Usage ();
CMFUsage ();
return EFI_INVALID_PARAMETER;
}
//
@ -176,13 +197,22 @@ Returns:
if ((Argv[0][strlen (Argv[0]) - 1] == 'k') || (Argv[0][strlen (Argv[0]) - 1] == 'K')) {
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
//
if ((Argv[0][0] == '0') && ((Argv[0][1] == 'x') || (Argv[0][1] == 'X'))) {
if (sscanf (Argv[0], "%x", &Options->FileSize) != 1) {
fprintf (stdout, PROGRAM_NAME " ERROR: Invalid file size '%s'\n", Argv[0]);
Usage ();
printf ("ERROR: Invalid file size '%s'\n", Argv[0]);
CMFUsage ();
return EFI_INVALID_PARAMETER;
}
//
@ -190,12 +220,12 @@ Returns:
//
} else {
if (sscanf (Argv[0], "%d", &Options->FileSize) != 1) {
fprintf (stdout, PROGRAM_NAME " ERROR: Invalid file size '%s'\n", Argv[0]);
Usage ();
printf ("ERROR: Invalid file size '%s'\n", Argv[0]);
CMFUsage ();
return EFI_INVALID_PARAMETER;
}
}
Options->FileSize *= Multiplier;
//
// Assume byte value of 0xff
@ -203,12 +233,39 @@ Returns:
Options->ByteValue = (INT8) (UINT8) 0xFF;
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
//
static
void
Usage (
CMFUsage (
VOID
)
/*++
@ -226,22 +283,15 @@ Returns:
GC_TODO: add return values
--*/
{
UINT32 Index;
static const INT8 *Text[] = {
" ",
"Usage: "PROGRAM_NAME " OutFileName FileSize",
" where:",
" OutFileName is the name of the output file to generate",
" FileSize is the size of the file to create",
" Examples:",
" "PROGRAM_NAME " OutFile.bin 32K",
" "PROGRAM_NAME " OutFile.bin 0x1000",
" ",
NULL
};
{
CMFVersion();
printf ("\n Usage: %s OutFileName FileSize \n\
where: \n\
OutFileName is the name of the output file to generate \n\
FileSize is the size of the file to create \n\
Examples: \n\
%s OutFile.bin 32K \n\
%s OutFile.bin 0x1000 \n",UTILITY_NAME, UTILITY_NAME, UTILITY_NAME);
}
for (Index = 0; Text[Index] != NULL; Index++) {
fprintf (stdout, "%s\n", Text[Index]);
}
}

View File

@ -27,9 +27,61 @@ Abstract:
#include <stdio.h>
#include <Common/UefiBaseTypes.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
main (
INT32 argc,
@ -65,19 +117,28 @@ Returns:
// Added for makefile debug - KCE
//
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;
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) {
printf ("Usage: EFICOMPRESS <infile> <outfile>\n");
ECUsage();
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
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
@ -86,7 +86,7 @@ ParseDepex (
);
VOID
PrintGenDepexUtilityInfo (
GDVersion (
VOID
)
/*++
@ -111,11 +111,11 @@ Returns:
UTILITY_MAJOR_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
PrintGenDepexUsageInfo (
GDUsage (
VOID
)
/*++
@ -134,15 +134,16 @@ Returns:
--*/
{
GDVersion();
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
);
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");
printf (" Where:\n");
printf (" InputFile is the input pre-processed dependency text 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 (" This is the boundary to align the output file size to.\n");
}
DEPENDENCY_OPCODE
@ -855,9 +856,25 @@ Returns:
Output_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) {
printf ("Not enough arguments\n");
PrintGenDepexUsageInfo ();
GDUsage();
return EFI_INVALID_PARAMETER;
}
@ -901,17 +918,15 @@ Returns:
}
}
PrintGenDepexUtilityInfo ();
if (InFile == NULL) {
printf ("Can not open <INFILE> for reading.\n");
PrintGenDepexUsageInfo ();
GDUsage();
return EFI_ABORTED;
}
if (OutFile == NULL) {
printf ("Can not open <OUTFILE> for writting.\n");
PrintGenDepexUsageInfo ();
GDUsage();
return EFI_ABORTED;
}

View File

@ -24,6 +24,10 @@ Abstract:
#include "stdio.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'
//
@ -242,29 +246,67 @@ Returns:
return 0;
}
void
Usage (
void
MIVersion(
void
)
/*++
Routine Description:
GC_TODO: Add function description
Print out version information for Strip.
Arguments:
None
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 ¡­]\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) ¡­] \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
main (
int argc,
@ -291,8 +333,24 @@ Returns:
FILE *fpin;
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) {
Usage ();
MIUsage();
return -1;
}

View File

@ -25,6 +25,59 @@ Abstract:
#include <string.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
main (
int argc,
@ -54,9 +107,25 @@ Returns:
int FileSize;
char *Buffer;
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) {
printf ("Need more args, such as file name to convert and output name\n");
StripUsage();
return -1;
}
@ -64,12 +133,12 @@ Returns:
OutFile = fopen (argv[2], "wb");
if (!InFile) {
printf ("no file, exit\n");
printf ("Unable to open input file, exit\n");
return -1;
}
if (OutFile == NULL) {
printf ("Unable to open output file.\n");
printf ("Unable to open output file, exit.\n");
return -1;
}
@ -77,7 +146,7 @@ Returns:
FileSize = ftell (InFile);
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;
}