}\r
\r
if (mOptions.Verbose) {\r
- fprintf (stdout, "%s tool start.\n", UTILITY_NAME);\r
+ VerboseMsg("%s tool start.\n", UTILITY_NAME);\r
} \r
//\r
// If dumping an image, then do that and quit\r
Size = 0;\r
if (FList->FileFlags & FILE_FLAG_EFI) {\r
if (mOptions.Verbose) {\r
- fprintf (stdout, "Processing EFI file %s\n", FList->FileName);\r
+ VerboseMsg("Processing EFI file %s\n", FList->FileName);\r
}\r
\r
Status = ProcessEfiFile (FptrOut, FList, mOptions.VendId, mOptions.DevId, &Size);\r
} else if (FList->FileFlags & FILE_FLAG_BINARY) {\r
if (mOptions.Verbose) {\r
- fprintf (stdout, "Processing binary file %s\n", FList->FileName);\r
+ VerboseMsg("Processing binary file %s\n", FList->FileName);\r
}\r
\r
Status = ProcessBinFile (FptrOut, FList, &Size);\r
}\r
\r
if (mOptions.Verbose) {\r
- fprintf (stdout, " Output size = 0x%X\n", Size);\r
+ VerboseMsg(" Output size = 0x%X\n", Size);\r
}\r
\r
if (Status != STATUS_SUCCESS) {\r
}\r
}\r
if (mOptions.Verbose) {\r
- fprintf (stdout, "%s tool done with return code is 0x%x.\n", UTILITY_NAME, GetUtilityStatus ()); \r
+ VerboseMsg("%s tool done with return code is 0x%x.\n", UTILITY_NAME, GetUtilityStatus ());\r
}\r
\r
return GetUtilityStatus (); \r
fseek (InFptr, 0, SEEK_END);\r
FileSize = ftell (InFptr);\r
if (mOptions.Verbose) {\r
- fprintf (stdout, " File size = 0x%X\n", FileSize);\r
+ VerboseMsg(" File size = 0x%X\n", FileSize);\r
}\r
\r
fseek (InFptr, 0, SEEK_SET);\r
}\r
\r
Buffer[FileSize - 1] = (UINT8) ((~ByteCheckSum) + 1);\r
- fprintf (stdout, "Checksum = %02x\n", (UINT32) Buffer[FileSize - 1]);\r
+ if (mOptions.Verbose) {\r
+ VerboseMsg(" Checksum = %02x\n\n", (UINT32) Buffer[FileSize - 1]);\r
+ }\r
\r
//\r
// Now copy the input file contents out to the output file\r
\r
HeaderSize = sizeof (PCI_DATA_STRUCTURE) + HeaderPadBytes + sizeof (EFI_PCI_EXPANSION_ROM_HEADER);\r
if (mOptions.Verbose) {\r
- fprintf (stdout, " File size = 0x%X\n", FileSize);\r
+ VerboseMsg(" File size = 0x%X\n", FileSize);\r
}\r
//\r
// Allocate memory for the entire file (in case we have to compress), then\r
// Now compute the size, then swap buffer pointers.\r
//\r
if (mOptions.Verbose) {\r
- fprintf (stdout, " Comp size = 0x%X\n", CompressedFileSize);\r
+ VerboseMsg(" Comp size = 0x%X\n", CompressedFileSize);\r
}\r
\r
TotalSize = CompressedFileSize + HeaderSize;\r
\r
*SubSystem = OptionalHdr.Subsystem;\r
if (mOptions.Verbose) {\r
- fprintf (stdout, " Got subsystem = 0x%X from image\n", (int) *SubSystem);\r
+ VerboseMsg(" Got subsystem = 0x%X from image\n", (int) *SubSystem);\r
}\r
//\r
// Good to go\r
//\r
// Process until no more arguments\r
//\r
- //__asm int 3;\r
while (Argc > 0) {\r
if ((Argv[0][0] == '-') || (Argv[0][0] == '/')) {\r
//\r
//\r
// Make sure there's another parameter\r
//\r
- //printf("\nvendor id specified!\n");\r
if (Argc > 1) {\r
Options->VendId = (UINT16) strtol (Argv[1], NULL, 16);\r
Options->VendIdValid = 1;\r
return 1;\r
}\r
if (DebugLevel>=5 && DebugLevel<=9) {\r
- DebugMode = TRUE;\r
+ Options->Debug = TRUE;\r
} else {\r
- DebugMode = FALSE;\r
+ Options->Debug = FALSE;\r
}\r
- Argv++;\r
- } else if ((stricmp (Argv[0], "-quiet") == 0) || (stricmp (Argv[0], "-q") == 0)) {\r
- QuietMode = TRUE;\r
- //Argv++;\r
- //Argc--;\r
- } else if ((stricmp (Argv[0], "-dump") == 0) || (stricmp (Argv[0], "-d") == 0)) {\r
+ Argc--;\r
+ } else if ((stricmp (Argv[0], "--quiet") == 0) || (stricmp (Argv[0], "-q") == 0)) {\r
+ Options->Quiet = TRUE;\r
+ } else if ((stricmp (Argv[0], "--dump") == 0) || (stricmp (Argv[0], "-d") == 0)) {\r
//\r
// -dump for dumping a ROM image. In this case, say that the device id\r
// and vendor id are valid so we don't have to specify bogus ones on the\r
Show this help message and exit.\n");\r
fprintf (stdout, " -q, --quiet\n\\r
Disable all messages except FATAL ERRORS.\n");\r
- fprintf (stdout, " --debug [#]\n\\r
+ fprintf (stdout, " --debug [#,0-9]\n\\r
Enable debug messages at level #.\n"); \r
}\r
\r
//\r
if (mOptions.Pci23 == 1) {\r
if (fread (&PciDs23, sizeof (PciDs23), 1, InFptr) != 1) {\r
- Error (NULL, 0, 3001, "Not supported", "Failed to read PCI data structure from file");\r
+ Error (NULL, 0, 3001, "Not supported", "Failed to read PCI data structure from file %s", InFile->FileName);\r
goto BailOut;\r
}\r
} else {\r
if (fread (&PciDs30, sizeof (PciDs30), 1, InFptr) != 1) {\r
- Error (NULL, 0, 3001, "Not supported", "Failed to read PCI data structure from file");\r
+ Error (NULL, 0, 3001, "Not supported", "Failed to read PCI data structure from file %s", InFile->FileName);\r
goto BailOut;\r
}\r
}\r
+ if (mOptions.Verbose) {\r
+ VerboseMsg("Read PCI data structure from file %s", InFile->FileName);\r
+ }\r
\r
- fprintf (stdout, " PCI Data Structure\n");\r
+ //fprintf (stdout, " PCI Data Structure\n");\r
if (mOptions.Pci23 == 1) {\r
fprintf (\r
stdout,\r
VtfInfo->LocationType = SECOND_VTF;\r
} else {\r
VtfInfo->LocationType = NONE;\r
- printf ("\nWARN: Unknown location for component %s\n", VtfInfo->CompName);\r
+ Warning(UTILITY_NAME, 0, 0001, "Unknown location for component", VtfInfo->CompName);\r
}\r
} else if (strnicmp (*TokenStr, "COMP_TYPE", 9) == 0) {\r
TokenStr++;\r
}\r
}\r
\r
+//\r
+// All Parameters has been parsed, now set the message print level\r
+//\r
+ if (QuietMode) {\r
+ SetPrintLevel(40);\r
+ } else if (VerboseMode) {\r
+ SetPrintLevel(15);\r
+ } else if (DebugMode) {\r
+ SetPrintLevel(DebugLevel);\r
+ }\r
+ \r
if (VerboseMode) {\r
- fprintf (stdout, "%s tool start.\n", UTILITY_NAME);\r
+ VerboseMsg("%s tool start.\n", UTILITY_NAME);\r
}\r
\r
if (VTF_OUTPUT == FALSE) {\r
// Call the GenVtfImage\r
//\r
if (DebugMode) {\r
- fprintf(stdout, "Start to generate the VTF image\n");\r
+ DebugMsg(UTILITY_NAME, 0, DebugLevel, "Start to generate the VTF image\n");\r
}\r
Status = GenerateVtfImage (StartAddress1, FwVolSize1, StartAddress2, FwVolSize2, VtfFP);\r
\r
}\r
ERROR:\r
if (VerboseMode) {\r
- fprintf (stdout, "%s tool done with return code is 0x%x.\n", UTILITY_NAME, GetUtilityStatus ()); \r
+ VerboseMsg("%s tool done with return code is 0x%x.\n", UTILITY_NAME, GetUtilityStatus ());\r
}\r
\r
return GetUtilityStatus (); \r
}\r
if (DebugMode) {\r
- fprintf(stdout, "VTF image generated successful\n");\r
+ //fprintf(stdout, "VTF image generated successful\n");\r
+ DebugMsg(UTILITY_NAME, 0, DebugLevel, "VTF image generated successful\n");\r
}\r
return 0;\r
}\r
Show this help message and exit.\n");\r
fprintf (stdout, " -q, --quiet\n\\r
Disable all messages except FATAL ERRORS.\n");\r
- fprintf (stdout, " -d, --debug [#]\n\\r
+ fprintf (stdout, " -d, --debug [#,0-9]\n\\r
Enable debug messages at level #.\n"); \r
}\r
\r
}\r
\r
//\r
-// All Parameters has been parsed\r
-// \r
+// All Parameters has been parsed, now set the message print level\r
+//\r
+ if (QuietMode) {\r
+ SetPrintLevel(40);\r
+ } else if (VerboseMode) {\r
+ SetPrintLevel(15);\r
+ } else if (DebugMode) {\r
+ SetPrintLevel(DebugLevel);\r
+ }\r
+ \r
if (VerboseMode) {\r
- fprintf (stdout, "%s tool start.\n", UTILITY_NAME);\r
+ VerboseMsg("%s tool start.\n", UTILITY_NAME);\r
}\r
Scratch = (SCRATCH_DATA *)malloc(sizeof(SCRATCH_DATA));\r
if (Scratch == NULL) {\r
Error(NULL, 0, 4001, "Resource:", "Memory cannot be allocated!");\r
- //return 1;\r
goto ERROR;\r
}\r
\r
InputFile = fopen (InputFileName, "rb");\r
if (InputFile == NULL) {\r
Error(NULL, 0, 0001, "Error opening input file", InputFileName);\r
- //return 1;\r
goto ERROR;\r
}\r
\r
if (InputFile != NULL) {\r
fclose (InputFile);\r
}\r
- //return EFI_ABORTED;\r
goto ERROR;\r
}\r
+ } else {\r
+ OutputFileName = DEFAULT_OUTPUT_FILE;\r
+ OutputFile = fopen (OutputFileName, "wb");\r
}\r
\r
if (ENCODE) {\r
// First call TianoCompress to get DstSize\r
//\r
if (DebugMode) {\r
- fprintf(stdout, "Encoding\n");\r
+ DebugMsg(UTILITY_NAME, 0, DebugLevel, "Encoding");\r
}\r
Status = TianoCompress ((UINT8 *)FileBuffer, InputLength, OutBuffer, &DstSize);\r
\r
}\r
\r
fwrite(OutBuffer,(size_t)DstSize, 1, OutputFile);\r
+ free(Scratch);\r
free(FileBuffer);\r
free(OutBuffer);\r
\r
if (DebugMode) {\r
- fprintf(stdout, "Encoding successful\n");\r
+ DebugMsg(UTILITY_NAME, 0, DebugLevel, "Encoding Successful!\n");\r
+ }\r
+ if (VerboseMode) {\r
+ VerboseMsg("Encoding successful\n");\r
}\r
return 0; \r
}\r
else if (DECODE) {\r
if (DebugMode) {\r
- fprintf(stdout, "Decoding\n");\r
+ DebugMsg(UTILITY_NAME, 0, DebugLevel, "Decoding\n");\r
}\r
//\r
// Get Compressed file original size\r
\r
Status = Decompress((VOID *)FileBuffer, (VOID *)OutBuffer, (VOID *)Scratch, 2);\r
if (Status != EFI_SUCCESS) {\r
- //Error(NULL, 0, 0008, "Error decompressing file: %s", InputFileName);\r
goto ERROR; \r
}\r
\r
free(OutBuffer);\r
\r
if (DebugMode) {\r
- fprintf(stdout, "Decoding successful\n");\r
+ DebugMsg(UTILITY_NAME, 0, DebugLevel, "Encoding successful!\n");\r
+ }\r
+ \r
+ if (VerboseMode) {\r
+ VerboseMsg("Decoding successful\n");\r
}\r
return 0;\r
}\r
ERROR:\r
if (DebugMode) {\r
if (ENCODE) {\r
- fprintf(stdout, "Encoding Error\n");\r
+ DebugMsg(UTILITY_NAME, 0, DebugLevel, "Encoding Error\n");\r
} else if (DECODE) {\r
- fprintf(stdout, "Decoding Error\n");\r
+ DebugMsg(UTILITY_NAME, 0, DebugLevel, "Decoding Error\n");\r
}\r
}\r
free(Scratch);\r
free(FileBuffer);\r
free(OutBuffer);\r
if (VerboseMode) {\r
- fprintf (stdout, "%s tool done with return code is 0x%x.\n", UTILITY_NAME, GetUtilityStatus ()); \r
+ VerboseMsg("%s tool done with return code is 0x%x.\n", UTILITY_NAME, GetUtilityStatus ());\r
}\r
return GetUtilityStatus ();\r
}\r