The Help information provided by VolInfo does not follow the EDK II Tools
Design doc, so this patch update the help text and add the generic
options: -d, -v, -q, -s.
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Yonghong Zhu
---
BaseTools/Source/C/VolInfo/VolInfo.c | 141 +++
1 file changed, 94 insertions(+), 47 deletions(-)
diff --git a/BaseTools/Source/C/VolInfo/VolInfo.c
b/BaseTools/Source/C/VolInfo/VolInfo.c
index 4fa87d4..ba26042 100644
--- a/BaseTools/Source/C/VolInfo/VolInfo.c
+++ b/BaseTools/Source/C/VolInfo/VolInfo.c
@@ -37,10 +37,11 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER
EXPRESS OR IMPLIED.
#include "EfiUtilityMsgs.h"
#include "FirmwareVolumeBufferLib.h"
#include "OsPath.h"
#include "ParseGuidedSectionTools.h"
#include "StringFuncs.h"
+#include "ParseInf.h"
//
// Utility global variables
//
@@ -161,10 +162,11 @@ Returns:
EFI_FIRMWARE_VOLUME_HEADER *FvImage;
UINT32 FvSize;
EFI_STATUS Status;
int Offset;
BOOLEAN ErasePolarity;
+ UINT64 LogLevel;
SetUtilityName (UTILITY_NAME);
//
// Print utility header
//
@@ -173,32 +175,50 @@ Returns:
UTILITY_MAJOR_VERSION,
UTILITY_MINOR_VERSION,
__BUILD_VERSION
);
- //
- // Save, and then skip filename arg
- //
- mUtilityFilename = argv[0];
+ if (argc == 1) {
+Usage ();
+return -1;
+ }
+
argc--;
argv++;
-
+ LogLevel = 0;
Offset = 0;
//
+ // Look for help options
+ //
+ if ((strcmp(argv[0], "-h") == 0) || (strcmp(argv[0], "--help") == 0) ||
+ (strcmp(argv[0], "-?") == 0) || (strcmp(argv[0], "/?") == 0)) {
+Usage();
+return STATUS_SUCCESS;
+ }
+ //
+ // Version has already be printed, so just return success
+ //
+ if (strcmp(argv[0], "--version") == 0) {
+return STATUS_SUCCESS;
+ }
+
+ //
// If they specified -x xref guid/basename cross-reference files, process it.
// This will print the basename beside each file guid. To use it, specify
// -x xref_filename to processdsc, then use xref_filename as a parameter
// here.
//
- while (argc > 2) {
+ while (argc > 0) {
if ((strcmp(argv[0], "-x") == 0) || (strcmp(argv[0], "--xref") == 0)) {
ParseGuidBaseNameFile (argv[1]);
printf("ParseGuidBaseNameFile: %s\n", argv[1]);
argc -= 2;
argv += 2;
-} else if (strcmp(argv[0], "--offset") == 0) {
+ continue;
+}
+if (strcmp(argv[0], "--offset") == 0) {
//
// Hex or decimal?
//
if ((argv[1][0] == '0') && (tolower ((int)argv[1][1]) == 'x')) {
if (sscanf (argv[1], "%x", ) != 1) {
@@ -218,42 +238,59 @@ Returns:
}
}
argc -= 2;
argv += 2;
-} else {
- Usage ();
- return -1;
+ continue;
}
+
+if ((stricmp (argv[0], "-v") == 0) || (stricmp (argv[0], "--verbose") ==
0)) {
+ SetPrintLevel (VERBOSE_LOG_LEVEL);
+ argc --;
+ argv ++;
+ continue;
+}
+
+if ((stricmp (argv[0], "-q") == 0) || (stricmp (argv[0], "--quiet") == 0))
{
+ SetPrintLevel (KEY_LOG_LEVEL);
+ argc --;
+ argv ++;
+ continue;
+}
+
+if ((stricmp (argv[0], "-d") == 0) || (stricmp (argv[0], "--debug") == 0))
{
+ Status = AsciiStringToUint64 (argv[1], FALSE, );
+ if (EFI_ERROR (Status)) {
+Error (NULL, 0, 1003, "Invalid option value", "%s = %s", argv[0],
argv[1]);
+return -1;
+ }
+ if (LogLevel > 9) {
+Error (NULL, 0, 1003, "Invalid option value", "Debug Level range is
0-9, current input level is %d", (int) LogLevel);
+return -1;
+ }
+ SetPrintLevel (LogLevel);
+ DebugMsg (NULL, 0, 9, "Debug Mode Set", "Debug Output Mode Level %s is
set!", argv[1]);
+ argc -= 2;
+ argv += 2;
+ continue;
+}
+
+mUtilityFilename = argv[0];
+argc --;
+argv ++;
}
- //
- // Check for proper number of arguments
- //
- if (argc != 1) {
-Usage ();
-return STATUS_ERROR;
- }
- //
- // Look for help options
- //
- if ((strcmp(argv[0], "-h") == 0) || (strcmp(argv[0], "--help") == 0) ||
- (strcmp(argv[0], "-?") == 0) || (strcmp(argv[0], "/?") == 0)) {
-Usage();
-return STATUS_SUCCESS;
- }
- //
- // Version has already been printed, return success.
- //
- if (strcmp(argv[0], "--version") == 0) {
-return STATUS_SUCCESS;
- }
+
//
// Open the file containing the FV
//
- InputFile = fopen (LongFilePath (argv[0]), "rb");
+ if (mUtilityFilename == NULL) {
+Error (NULL, 0, 1001, "Missing option", "Input files are not specified");
+return GetUtilityStatus ();
+ }
+ InputFile = fopen (LongFilePath (mUtilityFilename), "rb");
if (InputFile == NULL) {
-Error (NULL, 0, 0001, "Error opening the input file", argv[0]);
+Error (NULL, 0, 0001, "Error opening