\r
**/\r
\r
+#include "EfiUtilityMsgs.h"\r
+#include "ParseInf.h"\r
#include "EfiRom.h"\r
\r
+UINT64 DebugLevel = 0;\r
+\r
+int\r
main (\r
int Argc,\r
char *Argv[]\r
\r
--*/\r
{\r
- INT8 *Ext;\r
+ CHAR8 *Ext;\r
FILE *FptrOut;\r
UINT32 Status;\r
FILE_LIST *FList;\r
// Now open our output file\r
//\r
if ((FptrOut = fopen (mOptions.OutFileName, "wb")) == NULL) {\r
- Error (stdout, 0, 0001, "Error opening file", mOptions.OutFileName);\r
+ Error (NULL, 0, 0001, "Error opening file", "Error opening file %s", mOptions.OutFileName);\r
goto BailOut;\r
}\r
//\r
\r
Status = ProcessBinFile (FptrOut, FList, &Size);\r
} else {\r
- Error (stdout, 0, 2000, "Invalid parameter", "File type not specified, it must be either an EFI or binary file: %s.", FList->FileName);\r
+ Error (NULL, 0, 2000, "Invalid parameter", "File type not specified, it must be either an EFI or binary file: %s.", FList->FileName);\r
Status = STATUS_ERROR;\r
}\r
\r
}\r
\r
fseek (InFptr, 0, SEEK_SET);\r
- Buffer = (INT8 *) malloc (FileSize);\r
+ Buffer = (UINT8 *) malloc (FileSize);\r
if (Buffer == NULL) {\r
- Error (NULL, 0, 4003, "Resource", "memory cannot be allocated!", NULL);\r
+ Error (NULL, 0, 4003, "Resource", "memory cannot be allocated!");\r
Status = STATUS_ERROR;\r
goto BailOut;\r
}\r
// Now copy the input file contents out to the output file\r
//\r
if (fwrite (Buffer, FileSize, 1, OutFptr) != 1) {\r
- Error (NULL, 0, 0005, "Failed to write all file bytes to output file.");\r
+ Error (NULL, 0, 0005, "Failed to write all file bytes to output file.", NULL);\r
Status = STATUS_ERROR;\r
goto BailOut;\r
}\r
// Allocate memory for the entire file (in case we have to compress), then\r
// seek back to the beginning of the file and read it into our buffer.\r
//\r
- Buffer = (INT8 *) malloc (FileSize);\r
+ Buffer = (UINT8 *) malloc (FileSize);\r
if (Buffer == NULL) {\r
Error (NULL, 0, 4001, "Resource", "memory cannot be allocated!");\r
Status = STATUS_ERROR;\r
\r
fseek (InFptr, 0, SEEK_SET);\r
if (fread (Buffer, FileSize, 1, InFptr) != 1) {\r
- Error (NULL, 0, 0004, "Error reading file", InFptr);\r
+ Error (NULL, 0, 0004, "Error reading file", "File %s", InFile->FileName);\r
Status = STATUS_ERROR;\r
goto BailOut;\r
}\r
// Allocate a buffer into which we can compress the image, compress it,\r
// and use that size as the new size.\r
//\r
- CompressedBuffer = (INT8 *) malloc (FileSize);\r
+ CompressedBuffer = (UINT8 *) malloc (FileSize);\r
if (CompressedBuffer == NULL) {\r
Error (NULL, 0, 4001, "Resource", "memory cannot be allocated!");\r
Status = STATUS_ERROR;\r
CompressedFileSize = FileSize;\r
Status = EfiCompress (Buffer, FileSize, CompressedBuffer, &CompressedFileSize);\r
if (Status != STATUS_SUCCESS) {\r
- Error (NULL, 0, 0007, "Error compressing file!");\r
+ Error (NULL, 0, 0007, "Error compressing file!", NULL);\r
goto BailOut;\r
}\r
//\r
// Write the ROM header to the output file\r
//\r
if (fwrite (&RomHdr, sizeof (RomHdr), 1, OutFptr) != 1) {\r
- Error (NULL, 0, 0002, "Failed to write ROM header to output file!");\r
+ Error (NULL, 0, 0002, "Failed to write ROM header to output file!", NULL);\r
Status = STATUS_ERROR;\r
goto BailOut;\r
}\r
//\r
while (HeaderPadBytes > 0) {\r
if (putc (0, OutFptr) == EOF) {\r
- Error (NULL, 0, 0002, "Failed to write ROM header pad bytes to output file!");\r
+ Error (NULL, 0, 0002, "Failed to write ROM header pad bytes to output file!", NULL);\r
Status = STATUS_ERROR;\r
goto BailOut;\r
}\r
//\r
if (mOptions.Pci23 == 1) {\r
if (fwrite (&PciDs23, sizeof (PciDs23), 1, OutFptr) != 1) {\r
- Error (NULL, 0, 0002, "Failed to write PCI ROM header to output file!");\r
+ Error (NULL, 0, 0002, "Failed to write PCI ROM header to output file!", NULL);\r
Status = STATUS_ERROR;\r
goto BailOut;\r
} \r
} else {\r
if (fwrite (&PciDs30, sizeof (PciDs30), 1, OutFptr) != 1) {\r
- Error (NULL, 0, 0002, "Failed to write PCI ROM header to output file!");\r
+ Error (NULL, 0, 0002, "Failed to write PCI ROM header to output file!", NULL);\r
Status = STATUS_ERROR;\r
goto BailOut;\r
} \r
// Now dump the input file's contents to the output file\r
//\r
if (fwrite (Buffer, FileSize, 1, OutFptr) != 1) {\r
- Error (NULL, 0, 0002, "Failed to write all file bytes to output file!");\r
+ Error (NULL, 0, 0002, "Failed to write all file bytes to output file!", NULL);\r
Status = STATUS_ERROR;\r
goto BailOut;\r
}\r
//\r
while (TotalSize > 0) {\r
if (putc (~0, OutFptr) == EOF) {\r
- Error (NULL, 0, 2000, "Failed to write trailing pad bytes output file!");\r
+ Error (NULL, 0, 2000, "Failed to write trailing pad bytes output file!", NULL);\r
Status = STATUS_ERROR;\r
goto BailOut;\r
}\r
// Read the DOS header\r
//\r
if (fread (&DosHeader, sizeof (DosHeader), 1, Fptr) != 1) {\r
- Error (NULL, 0, 0004, "Failed to read the DOS stub from the input file!");\r
+ Error (NULL, 0, 0004, "Failed to read the DOS stub from the input file!", NULL);\r
return STATUS_ERROR;\r
}\r
//\r
//\r
fseek (Fptr, (long) DosHeader.e_lfanew, SEEK_SET);\r
if (fread (&PESig, sizeof (PESig), 1, Fptr) != 1) {\r
- Error (NULL, 0, 0004, "Failed to read PE signature bytes from input file!");\r
+ Error (NULL, 0, 0004, "Failed to read PE signature bytes from input file!", NULL);\r
return STATUS_ERROR;\r
}\r
//\r
// Read the file header and stuff their MachineType\r
//\r
if (fread (&FileHdr, sizeof (FileHdr), 1, Fptr) != 1) {\r
- Error (NULL, 0, 0004, "Failed to read PE file header from input file!");\r
+ Error (NULL, 0, 0004, "Failed to read PE file header from input file!", NULL);\r
return STATUS_ERROR;\r
}\r
\r
// Read the optional header so we can get the subsystem\r
//\r
if (fread (&OptionalHdr, sizeof (OptionalHdr), 1, Fptr) != 1) {\r
- Error (NULL, 0, 0004, "Failed to read COFF optional header from input file!");\r
+ Error (NULL, 0, 0004, "Failed to read COFF optional header from input file!", NULL);\r
return STATUS_ERROR;\r
}\r
\r
// Device ID specified with -i\r
// Make sure there's another parameter\r
//\r
- //printf("\nDevice id specified!\n");\r
if (Argc > 1) {\r
Options->DevId = (UINT16) strtol (Argv[1], NULL, 16);\r
Options->DevIdValid = 1;\r
//\r
FileList = (FILE_LIST *) malloc (sizeof (FILE_LIST));\r
if (FileList == NULL) {\r
- Error (NULL, 0, 4001, "Resource", "memory cannot be allocated!");\r
+ Error (NULL, 0, 4001, "Resource", "memory cannot be allocated!", NULL);\r
return STATUS_ERROR;\r
}\r
\r
//\r
fprintf (stdout, " EFI ROM header contents\n");\r
if (fseek (InFptr, ImageStart, SEEK_SET)) {\r
- Error (NULL, 0, 5001, "Failed to re-seek to ROM header structure!");\r
+ Error (NULL, 0, 5001, "Failed to re-seek to ROM header structure!", NULL);\r
goto BailOut;\r
}\r
\r
if (fread (&EfiRomHdr, sizeof (EfiRomHdr), 1, InFptr) != 1) {\r
- Error (NULL, 0, 5001, "Failed to read EFI PCI ROM header from file!");\r
+ Error (NULL, 0, 5001, "Failed to read EFI PCI ROM header from file!", NULL);\r
goto BailOut;\r
}\r
//\r