//\r
// If dumping an image, then do that and quit\r
//\r
- if (mOptions.DumpOption) {\r
+ if (mOptions.DumpOption == 1) {\r
for (FList = mOptions.FileList; FList != NULL; FList = FList->Next) {\r
if ((Ptr0 = strstr ((CONST CHAR8 *)FList->FileName, DEFAULT_OUTPUT_EXTENSION)) != NULL) {\r
DumpImage (mOptions.FileList);\r
goto BailOut;\r
} else {\r
Error (NULL, 0, 1002, "No PciRom input file", "No *.rom input file");\r
- //printf("\n *.rom file has not been generated, so -d option should be used after the *.rom Option Rom binary generated!");\r
goto BailOut;\r
}\r
}\r
TotalSize = 0;\r
for (FList = mOptions.FileList; FList != NULL; FList = FList->Next) {\r
Size = 0;\r
- if (FList->FileFlags & FILE_FLAG_EFI) {\r
+ if ((FList->FileFlags & FILE_FLAG_EFI) != 0) {\r
if (mOptions.Verbose) {\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
+ } else if ((FList->FileFlags & FILE_FLAG_BINARY) !=0 ) {\r
if (mOptions.Verbose) {\r
VerboseMsg("Processing binary file %s\n", FList->FileName);\r
}\r
// Check the header is conform to PCI2.3 or PCI3.0\r
//\r
if (mOptions.Pci23 == 1) {\r
- PciDs23 = (PCI_DATA_STRUCTURE *) (Buffer + RomHdr->PcirOffset);\r
- if (PciDs23->Signature != PCI_DATA_STRUCTURE_SIGNATURE) {\r
- Error (NULL, 0, 2000, "Invalid parameter", "PCI data structure has an invalid signature.");\r
- Status = STATUS_ERROR;\r
- goto BailOut;\r
- }\r
+ PciDs23 = (PCI_DATA_STRUCTURE *) (Buffer + RomHdr->PcirOffset);\r
+ if (PciDs23->Signature != PCI_DATA_STRUCTURE_SIGNATURE) {\r
+ Error (NULL, 0, 2000, "Invalid parameter", "PCI data structure has an invalid signature.");\r
+ Status = STATUS_ERROR;\r
+ goto BailOut;\r
+ }\r
} else {\r
//\r
// Default setting is PCI3.0 header\r
//\r
PciDs30 = (PCI_3_0_DATA_STRUCTURE *)(Buffer + RomHdr->PcirOffset);\r
- if (PciDs30->Signature != PCI_DATA_STRUCTURE_SIGNATURE) {\r
- Error (NULL, 0, 2000, "Invalid parameter", "PCI data structure has an invalid signature.");\r
- Status = STATUS_ERROR;\r
- goto BailOut;\r
- } \r
+ if (PciDs30->Signature != PCI_DATA_STRUCTURE_SIGNATURE) {\r
+ Error (NULL, 0, 2000, "Invalid parameter", "PCI data structure has an invalid signature.");\r
+ Status = STATUS_ERROR;\r
+ goto BailOut;\r
+ }\r
}\r
\r
\r
//\r
if ((InFile->Next == NULL) && (mOptions.NoLast == 0)) {\r
if (mOptions.Pci23 == 1) {\r
- PciDs23->Indicator = INDICATOR_LAST;\r
- } else {\r
- PciDs30->Indicator = INDICATOR_LAST;\r
- }\r
+ PciDs23->Indicator = INDICATOR_LAST;\r
+ } else {\r
+ PciDs30->Indicator = INDICATOR_LAST;\r
+ }\r
} else {\r
if (mOptions.Pci23 == 1) {\r
PciDs23->Indicator = 0;\r
- } else {\r
- PciDs30->Indicator = 0;\r
+ } else {\r
+ PciDs30->Indicator = 0;\r
}\r
}\r
\r
} else {\r
HeaderPadBytes = 0;\r
}\r
+ \r
+ //\r
+ // For Pci3.0 to use the different data structure.\r
+ //\r
+ if (mOptions.Pci23 == 1) {\r
+ HeaderSize = sizeof (PCI_DATA_STRUCTURE) + HeaderPadBytes + sizeof (EFI_PCI_EXPANSION_ROM_HEADER);\r
+ } else {\r
+ HeaderSize = sizeof (PCI_3_0_DATA_STRUCTURE) + HeaderPadBytes + sizeof (EFI_PCI_EXPANSION_ROM_HEADER);\r
+ }\r
\r
- HeaderSize = sizeof (PCI_DATA_STRUCTURE) + HeaderPadBytes + sizeof (EFI_PCI_EXPANSION_ROM_HEADER);\r
if (mOptions.Verbose) {\r
VerboseMsg(" File size = 0x%X\n", FileSize);\r
}\r
// Now determine the size of the final output file. It's either the header size\r
// plus the file's size, or the header size plus the compressed file size.\r
//\r
- if (InFile->FileFlags & FILE_FLAG_COMPRESS) {\r
+ if ((InFile->FileFlags & FILE_FLAG_COMPRESS) != 0) {\r
//\r
// Allocate a buffer into which we can compress the image, compress it,\r
// and use that size as the new size.\r
if (mOptions.Pci23 == 1) {\r
memset (&PciDs23, 0, sizeof (PCI_DATA_STRUCTURE));\r
} else {\r
- memset (&PciDs30, 0, sizeof (PCI_3_0_DATA_STRUCTURE));\r
+ memset (&PciDs30, 0, sizeof (PCI_3_0_DATA_STRUCTURE));\r
}\r
\r
if (mOptions.Pci23 == 1) {\r
- PciDs23.Signature = PCI_DATA_STRUCTURE_SIGNATURE;\r
- PciDs23.VendorId = VendId;\r
- PciDs23.DeviceId = DevId;\r
- PciDs23.Length = (UINT16) sizeof (PCI_DATA_STRUCTURE);\r
- PciDs23.Revision = 0;\r
- //\r
- // Class code and code revision from the command line (optional)\r
- //\r
- PciDs23.ClassCode[0] = (UINT8) InFile->ClassCode;\r
- PciDs23.ClassCode[1] = (UINT8) (InFile->ClassCode >> 8);\r
- PciDs23.ClassCode[2] = (UINT8) (InFile->ClassCode >> 16);\r
- PciDs23.ImageLength = RomHdr.InitializationSize;\r
- PciDs23.CodeRevision = InFile->CodeRevision;\r
- PciDs23.CodeType = PCI_CODE_TYPE_EFI_IMAGE;\r
+ PciDs23.Signature = PCI_DATA_STRUCTURE_SIGNATURE;\r
+ PciDs23.VendorId = VendId;\r
+ PciDs23.DeviceId = DevId;\r
+ PciDs23.Length = (UINT16) sizeof (PCI_DATA_STRUCTURE);\r
+ PciDs23.Revision = 0;\r
+ //\r
+ // Class code and code revision from the command line (optional)\r
+ //\r
+ PciDs23.ClassCode[0] = (UINT8) InFile->ClassCode;\r
+ PciDs23.ClassCode[1] = (UINT8) (InFile->ClassCode >> 8);\r
+ PciDs23.ClassCode[2] = (UINT8) (InFile->ClassCode >> 16);\r
+ PciDs23.ImageLength = RomHdr.InitializationSize;\r
+ PciDs23.CodeRevision = InFile->CodeRevision;\r
+ PciDs23.CodeType = PCI_CODE_TYPE_EFI_IMAGE;\r
} else {\r
- PciDs30.Signature = PCI_DATA_STRUCTURE_SIGNATURE;\r
- PciDs30.VendorId = VendId;\r
- PciDs30.DeviceId = DevId;\r
- PciDs30.DeviceListOffset = 0; // to be fixed\r
- PciDs30.Length = (UINT16) sizeof (PCI_3_0_DATA_STRUCTURE);\r
- PciDs30.Revision = 0;\r
- //\r
- // Class code and code revision from the command line (optional)\r
- //\r
- PciDs30.ClassCode[0] = (UINT8) InFile->ClassCode;\r
- PciDs30.ClassCode[1] = (UINT8) (InFile->ClassCode >> 8);\r
- PciDs30.ClassCode[2] = (UINT8) (InFile->ClassCode >> 16);\r
- PciDs30.ImageLength = RomHdr.InitializationSize;\r
- PciDs30.CodeRevision = InFile->CodeRevision;\r
- PciDs30.CodeType = PCI_CODE_TYPE_EFI_IMAGE;\r
- PciDs30.MaxRuntimeImageLength = 0; // to be fixed\r
- PciDs30.ConfigUtilityCodeHeaderOffset = 0; // to be fixed\r
- PciDs30.DMTFCLPEntryPointOffset = 0; // to be fixed\r
+ PciDs30.Signature = PCI_DATA_STRUCTURE_SIGNATURE;\r
+ PciDs30.VendorId = VendId;\r
+ PciDs30.DeviceId = DevId;\r
+ PciDs30.DeviceListOffset = 0; // to be fixed\r
+ PciDs30.Length = (UINT16) sizeof (PCI_3_0_DATA_STRUCTURE);\r
+ PciDs30.Revision = 0;\r
+ //\r
+ // Class code and code revision from the command line (optional)\r
+ //\r
+ PciDs30.ClassCode[0] = (UINT8) InFile->ClassCode;\r
+ PciDs30.ClassCode[1] = (UINT8) (InFile->ClassCode >> 8);\r
+ PciDs30.ClassCode[2] = (UINT8) (InFile->ClassCode >> 16);\r
+ PciDs30.ImageLength = RomHdr.InitializationSize;\r
+ PciDs30.CodeRevision = InFile->CodeRevision;\r
+ PciDs30.CodeType = PCI_CODE_TYPE_EFI_IMAGE;\r
+ PciDs30.MaxRuntimeImageLength = 0; // to be fixed\r
+ PciDs30.ConfigUtilityCodeHeaderOffset = 0; // to be fixed\r
+ PciDs30.DMTFCLPEntryPointOffset = 0; // to be fixed\r
}\r
//\r
// If this is the last image, then set the LAST bit unless requested not\r
if (mOptions.Pci23 == 1) {\r
PciDs23.Indicator = 0;\r
} else {\r
- PciDs30.Indicator = 0;\r
- }\r
+ PciDs30.Indicator = 0;\r
+ }\r
}\r
//\r
// Write the ROM header to the output file\r
// Write the PCI data structure header to the output file\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
- Status = STATUS_ERROR;\r
- goto BailOut;\r
- } \r
+ if (fwrite (&PciDs23, sizeof (PciDs23), 1, OutFptr) != 1) {\r
+ Error (NULL, 0, 0002, "Failed to write PCI ROM header to output file!");\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
- Status = STATUS_ERROR;\r
- goto BailOut;\r
- } \r
+ if (fwrite (&PciDs30, sizeof (PciDs30), 1, OutFptr) != 1) {\r
+ Error (NULL, 0, 0002, "Failed to write PCI ROM header to output file!");\r
+ Status = STATUS_ERROR;\r
+ goto BailOut;\r
+ } \r
}\r
//\r
// Keep track of how many bytes left to write\r
if (InFptr != NULL) {\r
fclose (InFptr);\r
}\r
-\r
//\r
// Free up our buffers\r
//\r
//\r
// Specify binary files with -b\r
//\r
- FileFlags = (FileFlags &~FILE_FLAG_EFI) | FILE_FLAG_BINARY;\r
+ FileFlags = FILE_FLAG_BINARY;\r
} else if ((stricmp (Argv[0], "-e") == 0) || (stricmp (Argv[0], "-ec") == 0)) {\r
//\r
// Specify EFI files with -e. Specify EFI-compressed with -c.\r
//\r
- FileFlags = (FileFlags &~FILE_FLAG_BINARY) | FILE_FLAG_EFI;\r
+ FileFlags = FILE_FLAG_EFI;\r
if ((Argv[0][2] == 'c') || (Argv[0][2] == 'C')) {\r
FileFlags |= FILE_FLAG_COMPRESS;\r
}\r
Error (NULL, 0, 4001, "Resource", "memory cannot be allocated!");\r
return STATUS_ERROR;\r
}\r
-\r
+ \r
+ //\r
+ // set flag and class code for this image.\r
+ //\r
memset ((char *) FileList, 0, sizeof (FILE_LIST));\r
- FileList->FileName = Argv[0];\r
- FileList->FileFlags = FileFlags;\r
+ FileList->FileName = Argv[0];\r
+ FileList->FileFlags = FileFlags;\r
+ FileList->ClassCode = ClassCode;\r
+ FileList->CodeRevision = (UINT16) CodeRevision;\r
+ ClassCode = 0;\r
+ CodeRevision = 0;\r
+\r
if (Options->FileList == NULL) {\r
Options->FileList = FileList;\r
} else {\r
Error (NULL, 0, 2000, "Invalid parameter", "Missing input file name!");\r
Usage ();\r
return STATUS_ERROR;\r
- } \r
- //\r
- // Set the class code and code revision for this file, then reset the values.\r
- //\r
- FileList->ClassCode = ClassCode;\r
- FileList->CodeRevision = (UINT16) CodeRevision;\r
- ClassCode = 0;\r
- CodeRevision = 0; \r
+ }\r
+\r
//\r
// Make sure they specified a device ID and vendor ID\r
//\r
-/* \r
if (!Options->VendIdValid) {\r
- Error (NULL, 0, 2000, "Missing Vendor ID in command line");\r
- Usage ();\r
+ Error (NULL, 0, 2000, "Missing Vendor ID in command line", NULL);\r
return STATUS_ERROR;\r
}\r
\r
if (!Options->DevIdValid) {\r
- Error (NULL, 0, 2000, "Missing Device ID in command line");\r
+ Error (NULL, 0, 2000, "Missing Device ID in command line", NULL);\r
Usage ();\r
return STATUS_ERROR;\r
}\r
-*/ \r
+\r
return 0;\r
}\r
\r
// Read the option ROM header. Have to assume a raw binary image for now.\r
//\r
if (fread (&PciRomHdr, sizeof (PciRomHdr), 1, InFptr) != 1) {\r
- if (ImageStart == 0) {\r
Error (NULL, 0, 3001, "Not supported", "Failed to read PCI ROM header from file!");\r
goto BailOut;\r
- }\r
- else\r
- goto BailOut;\r
}\r
\r
//\r
//\r
// Read and dump the PCI data structure\r
//\r
+ memset (&PciDs23, 0, sizeof (PciDs23));\r
+ memset (&PciDs30, 0, sizeof (PciDs30));\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 %s!", InFile->FileName);\r
- goto BailOut;\r
- }\r
+ if (fread (&PciDs23, sizeof (PciDs23), 1, InFptr) != 1) {\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 %s!", InFile->FileName);\r
- goto BailOut;\r
- }\r
+ if (fread (&PciDs30, sizeof (PciDs30), 1, InFptr) != 1) {\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
// Seek to the start of the next image\r
//\r
if (mOptions.Pci23 == 1) {\r
- if (fseek (InFptr, ImageStart + (PciDs23.ImageLength * 512), SEEK_SET)) {\r
- Error (NULL, 0, 3001, "Not supported", "Failed to seek to next image!");\r
- goto BailOut;\r
- } \r
+ if (fseek (InFptr, ImageStart + (PciDs23.ImageLength * 512), SEEK_SET)) {\r
+ Error (NULL, 0, 3001, "Not supported", "Failed to seek to next image!");\r
+ goto BailOut;\r
+ }\r
} else {\r
- if (fseek (InFptr, ImageStart + (PciDs30.ImageLength * 512), SEEK_SET)) {\r
- Error (NULL, 0, 3001, "Not supported", "Failed to seek to next image!");\r
- goto BailOut;\r
- }\r
+ if (fseek (InFptr, ImageStart + (PciDs30.ImageLength * 512), SEEK_SET)) {\r
+ Error (NULL, 0, 3001, "Not supported", "Failed to seek to next image!");\r
+ goto BailOut;\r
+ }\r
}\r
}\r
\r