Added/modified utility usage and version display.

git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@2209 6f19259b-4bc3-4df7-8a09-765794883524
This commit is contained in:
ywang 2007-01-10 20:52:01 +00:00
parent 715a44f11b
commit fd23b925fb
2 changed files with 42 additions and 28 deletions

View File

@ -104,11 +104,28 @@ Returns:
// Set utility name for error/warning reporting purposes. // Set utility name for error/warning reporting purposes.
// //
SetUtilityName (UTILITY_NAME); SetUtilityName (UTILITY_NAME);
if (argc == 1) {
Usage();
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;
}
// //
// Verify the correct number of arguments // Verify the correct number of arguments
// //
if (argc != MAX_ARGS) { if (argc != MAX_ARGS) {
PrintUsage (); Usage ();
return STATUS_ERROR; return STATUS_ERROR;
} }
@ -135,7 +152,7 @@ Returns:
// Make sure argument pair begin with - or / // Make sure argument pair begin with - or /
// //
if (argv[Index][0] != '-' && argv[Index][0] != '/') { if (argv[Index][0] != '-' && argv[Index][0] != '/') {
PrintUsage (); Usage ();
Error (NULL, 0, 0, argv[Index], "unrecognized option"); Error (NULL, 0, 0, argv[Index], "unrecognized option");
return STATUS_ERROR; return STATUS_ERROR;
} }
@ -143,7 +160,7 @@ Returns:
// Make sure argument specifier is only one letter // Make sure argument specifier is only one letter
// //
if (argv[Index][2] != 0) { if (argv[Index][2] != 0) {
PrintUsage (); Usage ();
Error (NULL, 0, 0, argv[Index], "unrecognized option"); Error (NULL, 0, 0, argv[Index], "unrecognized option");
return STATUS_ERROR; return STATUS_ERROR;
} }
@ -156,7 +173,7 @@ Returns:
if (strlen (InputFileName) == 0) { if (strlen (InputFileName) == 0) {
strcpy (InputFileName, argv[Index + 1]); strcpy (InputFileName, argv[Index + 1]);
} else { } else {
PrintUsage (); Usage ();
Error (NULL, 0, 0, argv[Index + 1], "only one -i InputFileName may be specified"); Error (NULL, 0, 0, argv[Index + 1], "only one -i InputFileName may be specified");
return STATUS_ERROR; return STATUS_ERROR;
} }
@ -167,7 +184,7 @@ Returns:
if (OutputFileName == NULL) { if (OutputFileName == NULL) {
OutputFileName = argv[Index + 1]; OutputFileName = argv[Index + 1];
} else { } else {
PrintUsage (); Usage ();
Error (NULL, 0, 0, argv[Index + 1], "only one -o OutputFileName may be specified"); Error (NULL, 0, 0, argv[Index + 1], "only one -o OutputFileName may be specified");
return STATUS_ERROR; return STATUS_ERROR;
} }
@ -204,14 +221,14 @@ Returns:
case 'B': case 'B':
case 'b': case 'b':
if (BaseTypes & 1) { if (BaseTypes & 1) {
PrintUsage (); Usage ();
Error (NULL, 0, 0, argv[Index + 1], "XipBaseAddress may be specified only once by either -b or -f"); Error (NULL, 0, 0, argv[Index + 1], "XipBaseAddress may be specified only once by either -b or -f");
return STATUS_ERROR; return STATUS_ERROR;
} }
Status = AsciiStringToUint64 (argv[Index + 1], FALSE, &XipBase); Status = AsciiStringToUint64 (argv[Index + 1], FALSE, &XipBase);
if (EFI_ERROR (Status)) { if (EFI_ERROR (Status)) {
PrintUsage (); Usage ();
Error (NULL, 0, 0, argv[Index + 1], "invalid hex digit given for XIP base address"); Error (NULL, 0, 0, argv[Index + 1], "invalid hex digit given for XIP base address");
return STATUS_ERROR; return STATUS_ERROR;
} }
@ -222,14 +239,14 @@ Returns:
case 'D': case 'D':
case 'd': case 'd':
if (BaseTypes & 2) { if (BaseTypes & 2) {
PrintUsage (); Usage ();
Error (NULL, 0, 0, argv[Index + 1], "-d BsBaseAddress may be specified only once"); Error (NULL, 0, 0, argv[Index + 1], "-d BsBaseAddress may be specified only once");
return STATUS_ERROR; return STATUS_ERROR;
} }
Status = AsciiStringToUint64 (argv[Index + 1], FALSE, &BsBase); Status = AsciiStringToUint64 (argv[Index + 1], FALSE, &BsBase);
if (EFI_ERROR (Status)) { if (EFI_ERROR (Status)) {
PrintUsage (); Usage ();
Error (NULL, 0, 0, argv[Index + 1], "invalid hex digit given for BS_DRIVER base address"); Error (NULL, 0, 0, argv[Index + 1], "invalid hex digit given for BS_DRIVER base address");
return STATUS_ERROR; return STATUS_ERROR;
} }
@ -240,14 +257,14 @@ Returns:
case 'R': case 'R':
case 'r': case 'r':
if (BaseTypes & 4) { if (BaseTypes & 4) {
PrintUsage (); Usage ();
Error (NULL, 0, 0, argv[Index + 1], "-r RtBaseAddress may be specified only once"); Error (NULL, 0, 0, argv[Index + 1], "-r RtBaseAddress may be specified only once");
return STATUS_ERROR; return STATUS_ERROR;
} }
Status = AsciiStringToUint64 (argv[Index + 1], FALSE, &RtBase); Status = AsciiStringToUint64 (argv[Index + 1], FALSE, &RtBase);
if (EFI_ERROR (Status)) { if (EFI_ERROR (Status)) {
PrintUsage (); Usage ();
Error (NULL, 0, 0, argv[Index + 1], "invalid hex digit given for RT_DRIVER base address"); Error (NULL, 0, 0, argv[Index + 1], "invalid hex digit given for RT_DRIVER base address");
return STATUS_ERROR; return STATUS_ERROR;
} }
@ -256,7 +273,7 @@ Returns:
break; break;
default: default:
PrintUsage (); Usage ();
Error (NULL, 0, 0, argv[Index], "unrecognized argument"); Error (NULL, 0, 0, argv[Index], "unrecognized argument");
return STATUS_ERROR; return STATUS_ERROR;
break; break;
@ -490,7 +507,7 @@ Returns:
} }
VOID VOID
PrintUtilityInfo ( Version (
VOID VOID
) )
/*++ /*++
@ -509,17 +526,12 @@ Returns:
--*/ --*/
{ {
printf ( printf ("%s v%d.%d -PEI Rebase Utility.\n", UTILITY_NAME, UTILITY_MAJOR_VERSION, UTILITY_MINOR_VERSION);
"%s, PEI Rebase Utility. Version %i.%i, %s.\n\n", printf ("Copyright (c) 1999-2007 Intel Corporation. All rights reserved.\n");
UTILITY_NAME,
UTILITY_MAJOR_VERSION,
UTILITY_MINOR_VERSION,
UTILITY_DATE
);
} }
VOID VOID
PrintUsage ( Usage (
VOID VOID
) )
/*++ /*++
@ -538,15 +550,17 @@ Returns:
--*/ --*/
{ {
Version();
printf ( printf (
"Usage: %s -I InputFileName -O OutputFileName -B BaseAddress\n", "\nUsage: %s -I InputFileName -O OutputFileName -B BaseAddress\n",
UTILITY_NAME UTILITY_NAME
); );
printf (" Where:\n"); printf (" Where:\n");
printf (" InputFileName is the name of the EFI FV file to rebase.\n"); printf (" InputFileName is the name of the EFI FV file to rebase.\n");
printf (" OutputFileName is the desired output file name.\n"); printf (" OutputFileName is the desired output file name.\n");
printf (" BaseAddress is the FV base address to rebase against.\n"); printf (" BaseAddress is the FV base address to rebase agains.\n");
printf (" Argument pair may be in any order.\n\n"); printf (" Argument pair may be in any order.\n");
} }
EFI_STATUS EFI_STATUS

View File

@ -54,7 +54,7 @@ Abstract:
// The function that displays general utility information // The function that displays general utility information
// //
VOID VOID
PrintUtilityInfo ( Version (
VOID VOID
) )
/*++ /*++
@ -78,7 +78,7 @@ Returns:
// The function that displays the utility usage message. // The function that displays the utility usage message.
// //
VOID VOID
PrintUsage ( Usage (
VOID VOID
) )
/*++ /*++