IN CHAR8 *AlignBuffer,\r
OUT UINT32 *AlignNumber\r
)\r
+/*++\r
+\r
+Routine Description:\r
+\r
+ Converts Align String to align value (1~64K). \r
+\r
+Arguments:\r
+\r
+ AlignBuffer - Pointer to Align string.\r
+ AlignNumber - Pointer to Align value.\r
+\r
+Returns:\r
+\r
+ EFI_SUCCESS Successfully convert align string to align value.\r
+ EFI_INVALID_PARAMETER Align string is invalid or align value is not in scope.\r
+\r
+--*/\r
{\r
UINT32 Index = 0;\r
//\r
argv ++;\r
\r
if ((stricmp (argv[0], "-h") == 0) || (stricmp (argv[0], "--help") == 0)) {\r
- Usage();\r
+ Version ();\r
+ Usage ();\r
return STATUS_SUCCESS; \r
}\r
\r
fprintf (stdout, " -r Address, --baseaddr Address\n\\r
Address is the rebase start address for drivers that\n\\r
run in Flash. It supports DEC or HEX digital format.\n");\r
- fprintf (stdout, " -b Address, --bootbaseaddr Address\n\\r
- Address is the boot time driver base address, which is\n\\r
- used to define the prefered loaded address for all\n\\r
- boot time drivers in this Fv image.\n\\r
- It supports DEC or HEX digital format.\n");\r
- fprintf (stdout, " -t Address, --runtimebaseaddr Address\n\\r
- Address is the runtime driver base address, which is\n\\r
- used to define the prefered loaded address for all\n\\r
- runtime drivers in this Fv image.\n\\r
- It supports DEC or HEX digital format.\n");\r
+ fprintf (stdout, " -a AddressFile, --addrfile AddressFile\n\\r
+ AddressFile is one file used to record boot driver base\n\\r
+ address and runtime driver base address. And this tool\n\\r
+ will update these two addresses after it relocates all\n\\r
+ boot drivers and runtime drivers in this fv iamge to\n\\r
+ the preferred loaded memory address.\n");\r
+ fprintf (stdout, " -m logfile, --map logfile\n\\r
+ Logfile is the output fv map file name. if it is not\n\\r
+ given, the FvName.map will be the default map file name\n"); \r
fprintf (stdout, " -c, --capsule Create Capsule Image.\n");\r
+ fprintf (stdout, " -p, --dump Dump Capsule Image header.\n");\r
fprintf (stdout, " -v, --verbose Turn on verbose output with informational messages.\n");\r
fprintf (stdout, " --version Show program's version number and exit.\n");\r
fprintf (stdout, " -h, --help Show this help message and exit.\n");\r
{\r
EFI_STATUS Status;\r
CHAR8 *InfFileName;\r
+ CHAR8 *AddrFileName;\r
+ CHAR8 *MapFileName;\r
CHAR8 *InfFileImage;\r
UINTN InfFileSize;\r
CHAR8 *OutFileName;\r
+ CHAR8 ValueString[_MAX_PATH];\r
EFI_PHYSICAL_ADDRESS XipBase;\r
EFI_PHYSICAL_ADDRESS BtBase;\r
EFI_PHYSICAL_ADDRESS RtBase;\r
BOOLEAN CapsuleFlag;\r
+ BOOLEAN DumpCapsule;\r
+ MEMORY_FILE AddrMemoryFile;\r
+ FILE *FpFile;\r
\r
InfFileName = NULL;\r
+ AddrFileName = NULL;\r
InfFileImage = NULL;\r
OutFileName = NULL;\r
+ MapFileName = NULL;\r
XipBase = -1;\r
BtBase = 0;\r
RtBase = 0;\r
InfFileSize = 0;\r
CapsuleFlag = FALSE;\r
+ DumpCapsule = FALSE;\r
+ FpFile = NULL;\r
\r
SetUtilityName (UTILITY_NAME);\r
\r
argv ++;\r
\r
if ((stricmp (argv[0], "-h") == 0) || (stricmp (argv[0], "--help") == 0)) {\r
+ Version ();\r
Usage ();\r
return STATUS_SUCCESS; \r
}\r
continue; \r
}\r
\r
- if ((stricmp (argv[0], "-o") == 0) || (stricmp (argv[0], "--outputfile") == 0)) {\r
- OutFileName = argv[1];\r
+ if ((stricmp (argv[0], "-a") == 0) || (stricmp (argv[0], "--addrfile") == 0)) {\r
+ AddrFileName = argv[1];\r
argc -= 2;\r
argv += 2;\r
continue; \r
}\r
\r
- if ((stricmp (argv[0], "-r") == 0) || (stricmp (argv[0], "--baseaddr") == 0)) {\r
- Status = AsciiStringToUint64 (argv[1], FALSE, &XipBase);\r
- if (EFI_ERROR (Status)) {\r
- Error (NULL, 0, 1003, "Invalid option value", "%s = %s", argv[0], argv[1]);\r
- return STATUS_ERROR; \r
- }\r
+ if ((stricmp (argv[0], "-o") == 0) || (stricmp (argv[0], "--outputfile") == 0)) {\r
+ OutFileName = argv[1];\r
argc -= 2;\r
argv += 2;\r
continue; \r
}\r
\r
- if ((stricmp (argv[0], "-b") == 0) || (stricmp (argv[0], "--bootbaseaddr") == 0)) {\r
- Status = AsciiStringToUint64 (argv[1], FALSE, &BtBase);\r
+ if ((stricmp (argv[0], "-r") == 0) || (stricmp (argv[0], "--baseaddr") == 0)) {\r
+ Status = AsciiStringToUint64 (argv[1], FALSE, &XipBase);\r
if (EFI_ERROR (Status)) {\r
Error (NULL, 0, 1003, "Invalid option value", "%s = %s", argv[0], argv[1]);\r
return STATUS_ERROR; \r
continue; \r
}\r
\r
- if ((stricmp (argv[0], "-t") == 0) || (stricmp (argv[0], "--runtimebaseaddr") == 0)) {\r
- Status = AsciiStringToUint64 (argv[1], FALSE, &RtBase);\r
- if (EFI_ERROR (Status)) {\r
- Error (NULL, 0, 1003, "Invalid option value", "%s = %s", argv[0], argv[1]);\r
- return STATUS_ERROR; \r
- }\r
- argc -= 2;\r
- argv += 2;\r
+ if ((stricmp (argv[0], "-c") == 0) || (stricmp (argv[0], "--capsule") == 0)) {\r
+ CapsuleFlag = TRUE;\r
+ argc --;\r
+ argv ++;\r
continue; \r
}\r
\r
- if ((stricmp (argv[0], "-c") == 0) || (stricmp (argv[0], "--capsule") == 0)) {\r
- CapsuleFlag = TRUE;\r
+ if ((stricmp (argv[0], "-p") == 0) || (stricmp (argv[0], "--dump") == 0)) {\r
+ DumpCapsule = TRUE;\r
argc --;\r
argv ++;\r
continue; \r
}\r
\r
+ if ((stricmp (argv[0], "-m") == 0) || (stricmp (argv[0], "--map") == 0)) {\r
+ MapFileName = argv[1];\r
+ argc -= 2;\r
+ argv += 2;\r
+ continue; \r
+ }\r
+\r
if ((stricmp (argv[0], "-v") == 0) || (stricmp (argv[0], "--verbose") == 0)) {\r
VerboseMode = TRUE;\r
argc --;\r
Error (NULL, 0, 1001, "Missing Option", "Input File");\r
return STATUS_ERROR;\r
}\r
+\r
+ if (OutFileName == NULL) {\r
+ Error (NULL, 0, 1001, "Missing option", "Output file name");\r
+ return STATUS_ERROR;\r
+ }\r
\r
+ //\r
+ // Read boot and runtime address from address file\r
+ //\r
+ if (AddrFileName != NULL) {\r
+ Status = GetFileImage (AddrFileName, &InfFileImage, &InfFileSize);\r
+ if (EFI_ERROR (Status)) {\r
+ return STATUS_ERROR;\r
+ }\r
+\r
+ AddrMemoryFile.FileImage = InfFileImage;\r
+ AddrMemoryFile.CurrentFilePointer = InfFileImage;\r
+ AddrMemoryFile.Eof = InfFileImage + InfFileSize;\r
+\r
+ //\r
+ // Read the boot driver base address for this FV image\r
+ //\r
+ Status = FindToken (&AddrMemoryFile, OPTIONS_SECTION_STRING, EFI_FV_BOOT_DRIVER_BASE_ADDRESS_STRING, 0, ValueString);\r
+ if (Status == EFI_SUCCESS) {\r
+ //\r
+ // Get the base address\r
+ //\r
+ Status = AsciiStringToUint64 (ValueString, FALSE, &BtBase);\r
+ if (EFI_ERROR (Status)) {\r
+ Error (NULL, 0, 2000, "Invalid paramter", "%s = %s", EFI_FV_BOOT_DRIVER_BASE_ADDRESS_STRING, ValueString);\r
+ return STATUS_ERROR;\r
+ }\r
+ }\r
+ \r
+ //\r
+ // Read the FV runtime driver base address\r
+ //\r
+ Status = FindToken (&AddrMemoryFile, OPTIONS_SECTION_STRING, EFI_FV_RUNTIME_DRIVER_BASE_ADDRESS_STRING, 0, ValueString);\r
+ if (Status == EFI_SUCCESS) {\r
+ //\r
+ // Get the base address\r
+ //\r
+ Status = AsciiStringToUint64 (ValueString, FALSE, &RtBase);\r
+ if (EFI_ERROR (Status)) {\r
+ Error (NULL, 0, 2000, "Invalid paramter", "%s = %s", EFI_FV_RUNTIME_DRIVER_BASE_ADDRESS_STRING, ValueString);\r
+ return STATUS_ERROR;\r
+ }\r
+ }\r
+ \r
+ //\r
+ // free the allocated memory space for addr file.\r
+ //\r
+ free (InfFileImage);\r
+ }\r
+\r
//\r
// Read the INF file image\r
//\r
InfFileImage,\r
InfFileSize,\r
OutFileName,\r
+ MapFileName,\r
XipBase,\r
- BtBase,\r
- RtBase\r
+ &BtBase,\r
+ &RtBase\r
);\r
}\r
\r
//\r
// free InfFileImage memory\r
//\r
- if (InfFileImage == NULL) {\r
+ if (InfFileImage != NULL) {\r
free (InfFileImage);\r
}\r
+ \r
+ //\r
+ // update boot driver address and runtime driver address in address file\r
+ //\r
+ if (AddrFileName != NULL) {\r
+ FpFile = fopen (AddrFileName, "w");\r
+ if (FpFile == NULL) {\r
+ Error (NULL, 0, 0001, "Error opening file", AddrFileName);\r
+ return STATUS_ERROR;\r
+ }\r
+ fprintf (FpFile, OPTIONS_SECTION_STRING);\r
+ fprintf (FpFile, "\n");\r
+ fprintf (FpFile, EFI_FV_BOOT_DRIVER_BASE_ADDRESS_STRING);\r
+ fprintf (FpFile, " = 0x%x\n", BtBase);\r
+ fprintf (FpFile, EFI_FV_RUNTIME_DRIVER_BASE_ADDRESS_STRING);\r
+ fprintf (FpFile, " = 0x%x\n", RtBase);\r
+ fclose (FpFile);\r
+ }\r
\r
if (VerboseMode) {\r
fprintf (stdout, "%s tool done with return code is 0x%x.\n", UTILITY_NAME, GetUtilityStatus ()); \r
#include "PeCoffLib.h"\r
#include "WinNtInclude.h"\r
\r
-EFI_STATUS\r
-ParseCapInf (\r
- IN MEMORY_FILE *InfFile,\r
- OUT CAP_INFO *CapInfo\r
- );\r
-\r
-EFI_STATUS\r
-FindApResetVectorPosition (\r
- IN MEMORY_FILE *FvImage,\r
- OUT UINT8 **Pointer\r
- ); \r
-\r
-EFI_STATUS\r
-CalculateFvSize (\r
- FV_INFO *FvInfoPtr\r
- );\r
-/*++\r
-Routine Description:\r
- Calculate the FV size and Update Fv Size based on the actual FFS files.\r
- And Update FvInfo data.\r
-\r
-Arguments:\r
- FvInfoPtr - The pointer to FV_INFO structure.\r
-\r
-Returns:\r
- EFI_ABORTED - Ffs Image Error\r
- EFI_SUCCESS - Successfully update FvSize\r
---*/\r
-\r
-EFI_STATUS\r
-FfsRebase ( \r
- IN OUT FV_INFO *FvInfo, \r
- IN CHAR8 *FileName, \r
- IN OUT EFI_FFS_FILE_HEADER *FfsFile,\r
- IN UINTN XipOffset,\r
- IN FILE *FvMapFile\r
- );\r
-/*++\r
-\r
-Routine Description:\r
-\r
- This function determines if a file is XIP and should be rebased. It will\r
- rebase any PE32 sections found in the file using the base address.\r
-\r
-Arguments:\r
- \r
- FvInfo A pointer to FV_INFO struture.\r
- FileName Ffs file Name\r
- FfsFile A pointer to Ffs file image.\r
- XipOffset The offset address to use for rebasing the XIP file image.\r
- FvMapFile File pointer to FvMap file\r
-\r
-Returns:\r
-\r
- EFI_SUCCESS The image was properly rebased.\r
- EFI_INVALID_PARAMETER An input parameter is invalid.\r
- EFI_ABORTED An error occurred while rebasing the input file image.\r
- EFI_OUT_OF_RESOURCES Could not allocate a required resource.\r
- EFI_NOT_FOUND No compressed sections could be found.\r
-\r
---*/\r
-\r
static UINT32 MaxFfsAlignment = 0;\r
\r
EFI_GUID gEfiFirmwareFileSystem2Guid = EFI_FIRMWARE_FILE_SYSTEM2_GUID;\r
FvInfo->BaseAddress = Value64;\r
}\r
\r
- //\r
- // Read the FV boot driver base address\r
- //\r
- Status = FindToken (InfFile, OPTIONS_SECTION_STRING, EFI_FV_BOOT_DRIVER_BASE_ADDRESS_STRING, 0, Value);\r
- if (Status == EFI_SUCCESS) {\r
- //\r
- // Get the base address\r
- //\r
- Status = AsciiStringToUint64 (Value, FALSE, &Value64);\r
- if (EFI_ERROR (Status)) {\r
- Error (NULL, 0, 2000, "Invalid paramter", "%s = %s", EFI_FV_BOOT_DRIVER_BASE_ADDRESS_STRING, Value);\r
- return EFI_ABORTED;\r
- }\r
-\r
- FvInfo->BootBaseAddress = Value64;\r
- }\r
-\r
- //\r
- // Read the FV runtime driver base address\r
- //\r
- Status = FindToken (InfFile, OPTIONS_SECTION_STRING, EFI_FV_RUNTIME_DRIVER_BASE_ADDRESS_STRING, 0, Value);\r
- if (Status == EFI_SUCCESS) {\r
- //\r
- // Get the base address\r
- //\r
- Status = AsciiStringToUint64 (Value, FALSE, &Value64);\r
- if (EFI_ERROR (Status)) {\r
- Error (NULL, 0, 2000, "Invalid paramter", "%s = %s", EFI_FV_RUNTIME_DRIVER_BASE_ADDRESS_STRING, Value);\r
- return EFI_ABORTED;\r
- }\r
-\r
- FvInfo->RuntimeBaseAddress = Value64;\r
- }\r
-\r
//\r
// Read the FV Guid\r
//\r
\r
return EFI_SUCCESS;\r
}\r
-//\r
-// Exposed function implementations (prototypes are defined in GenFvImageLib.h)\r
-//\r
+\r
EFI_STATUS\r
GenerateFvImage (\r
IN CHAR8 *InfFileImage,\r
IN UINTN InfFileSize,\r
IN CHAR8 *FvFileName,\r
+ IN CHAR8 *MapFileName,\r
IN EFI_PHYSICAL_ADDRESS XipBaseAddress,\r
- IN EFI_PHYSICAL_ADDRESS BtBaseAddress,\r
- IN EFI_PHYSICAL_ADDRESS RtBaseAddress\r
+ IN EFI_PHYSICAL_ADDRESS *BtBaseAddress,\r
+ IN EFI_PHYSICAL_ADDRESS *RtBaseAddress\r
)\r
/*++\r
\r
InfFileImage Buffer containing the INF file contents.\r
InfFileSize Size of the contents of the InfFileImage buffer.\r
FvFileName Requested name for the FV file.\r
+ MapFileName Fv map file to log fv driver information.\r
XipBaseAddress BaseAddress is to be rebased.\r
- BtBaseAddress BaseAddress is to set the prefer loaded image start address for boot drivers.\r
- RtBaseAddress BaseAddress is to set the prefer loaded image start address for runtime drivers.\r
+ BtBaseAddress Pointer to BaseAddress is to set the prefer loaded image start address for boot drivers.\r
+ RtBaseAddress Pointer to BaseAddress is to set the prefer loaded image start address for runtime drivers.\r
\r
Returns:\r
\r
}\r
\r
//\r
- // FvMap file to record the function address of all modules in one Fvimage\r
+ // FvMap file to log the function address of all modules in one Fvimage\r
//\r
- strcpy (FvMapName, FvFileName);\r
- strcat (FvMapName, ".map");\r
+ if (MapFileName != NULL) {\r
+ strcpy (FvMapName, MapFileName);\r
+ } else {\r
+ strcpy (FvMapName, FvFileName);\r
+ strcat (FvMapName, ".map");\r
+ }\r
+\r
FvMapFile = fopen (FvMapName, "w");\r
if (FvMapFile == NULL) {\r
Error (NULL, 0, 0001, "Error opening file", FvMapName);\r
if (XipBaseAddress != -1) {\r
FvInfo.BaseAddress = XipBaseAddress;\r
}\r
- if (BtBaseAddress != 0) {\r
- FvInfo.BootBaseAddress = BtBaseAddress;\r
+ if (*BtBaseAddress != 0) {\r
+ FvInfo.BootBaseAddress = *BtBaseAddress;\r
}\r
- if (RtBaseAddress != 0) {\r
- FvInfo.RuntimeBaseAddress = RtBaseAddress;\r
+ if (*RtBaseAddress != 0) {\r
+ FvInfo.RuntimeBaseAddress = *RtBaseAddress;\r
}\r
\r
//\r
fclose (FvMapFile);\r
}\r
\r
+ //\r
+ // Update BootAddress and RuntimeAddress\r
+ //\r
+ *BtBaseAddress = FvInfo.BootBaseAddress;\r
+ *RtBaseAddress = FvInfo.RuntimeBaseAddress;\r
+\r
return Status;\r
}\r
\r
//\r
continue;\r
}\r
-\r
+ //\r
+ // make sure image base address at the section alignment\r
+ //\r
+ FvInfo->RuntimeBaseAddress = (FvInfo->RuntimeBaseAddress + ImageContext.SectionAlignment - 1) & (~(ImageContext.SectionAlignment - 1));\r
NewPe32BaseAddress = FvInfo->RuntimeBaseAddress;\r
BaseToUpdate = &(FvInfo->RuntimeBaseAddress);\r
break;\r
//\r
continue;\r
}\r
-\r
+ //\r
+ // make sure image base address at the section alignment\r
+ //\r
+ FvInfo->BootBaseAddress = (FvInfo->BootBaseAddress + ImageContext.SectionAlignment - 1) & (~(ImageContext.SectionAlignment - 1));\r
NewPe32BaseAddress = FvInfo->BootBaseAddress;\r
BaseToUpdate = &(FvInfo->BootBaseAddress);\r
break;\r
//\r
return EFI_SUCCESS;\r
}\r
-\r
+ //\r
+ // make sure image base address at the section alignment\r
+ //\r
+ FvInfo->BootBaseAddress = (FvInfo->BootBaseAddress + ImageContext.SectionAlignment - 1) & (~(ImageContext.SectionAlignment - 1));\r
NewPe32BaseAddress = FvInfo->BootBaseAddress;\r
BaseToUpdate = &(FvInfo->BootBaseAddress);\r
break;\r
free ((VOID *) MemoryImagePointer);\r
\r
//\r
- // Update BASE address\r
+ // Update BASE address by add one page size.\r
//\r
- *BaseToUpdate += EFI_SIZE_TO_PAGES (ImageContext.ImageSize) * EFI_PAGE_SIZE;\r
+ *BaseToUpdate += ImageContext.ImageSize + EFI_PAGE_SIZE;\r
\r
//\r
// Now update file checksum\r
IN MEMORY_FILE *FvImage,\r
OUT UINT8 **Pointer\r
)\r
+/*++\r
+\r
+Routine Description:\r
+\r
+ Find the position in this FvImage to place Ap reset vector.\r
+\r
+Arguments:\r
+\r
+ FvImage Memory file for the FV memory image.\r
+ Pointer Pointer to pointer to position.\r
+\r
+Returns:\r
+\r
+ EFI_NOT_FOUND - No satisfied position is found.\r
+ EFI_SUCCESS - The suitable position is return.\r
+\r
+--*/\r
{\r
EFI_FFS_FILE_HEADER *PadFile;\r
UINT32 Index;\r
} COMPONENT_INFO;\r
\r
//\r
-// FV information holder\r
+// FV and capsule information holder\r
//\r
typedef struct {\r
EFI_PHYSICAL_ADDRESS BaseAddress;\r
OUT UINT16 *MachineType\r
);\r
\r
+EFI_STATUS\r
+ParseCapInf (\r
+ IN MEMORY_FILE *InfFile,\r
+ OUT CAP_INFO *CapInfo\r
+ );\r
+\r
+EFI_STATUS\r
+FindApResetVectorPosition (\r
+ IN MEMORY_FILE *FvImage,\r
+ OUT UINT8 **Pointer\r
+ ); \r
+\r
+EFI_STATUS\r
+CalculateFvSize (\r
+ FV_INFO *FvInfoPtr\r
+ );\r
+\r
+EFI_STATUS\r
+FfsRebase ( \r
+ IN OUT FV_INFO *FvInfo, \r
+ IN CHAR8 *FileName, \r
+ IN OUT EFI_FFS_FILE_HEADER *FfsFile,\r
+ IN UINTN XipOffset,\r
+ IN FILE *FvMapFile\r
+ );\r
+\r
//\r
// Exported function prototypes\r
//\r
IN CHAR8 *InfFileImage,\r
IN UINTN InfFileSize,\r
IN CHAR8 *CapFileName\r
- );\r
+ )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+ This is the main function which will be called from application to \r
+ generate UEFI Capsule image.\r
+\r
+Arguments:\r
+\r
+ InfFileImage Buffer containing the INF file contents.\r
+ InfFileSize Size of the contents of the InfFileImage buffer.\r
+ CapFileName Requested name for the Cap file.\r
+\r
+Returns:\r
+\r
+ EFI_SUCCESS Function completed successfully.\r
+ EFI_OUT_OF_RESOURCES Could not allocate required resources.\r
+ EFI_ABORTED Error encountered.\r
+ EFI_INVALID_PARAMETER A required parameter was NULL.\r
+\r
+--*/\r
+;\r
\r
EFI_STATUS\r
GenerateFvImage (\r
IN CHAR8 *InfFileImage,\r
IN UINTN InfFileSize,\r
IN CHAR8 *FvFileName, \r
+ IN CHAR8 *MapFileName,\r
IN EFI_PHYSICAL_ADDRESS XipBaseAddress,\r
- IN EFI_PHYSICAL_ADDRESS BtBaseAddress,\r
- IN EFI_PHYSICAL_ADDRESS RtBaseAddress\r
+ IN EFI_PHYSICAL_ADDRESS *BtBaseAddress,\r
+ IN EFI_PHYSICAL_ADDRESS *RtBaseAddress\r
)\r
/*++\r
\r
Routine Description:\r
\r
- This is the main function which will be called from application.\r
+ This is the main function which will be called from application to \r
+ generate Firmware Image conforms to PI spec.\r
\r
Arguments:\r
\r
InfFileImage Buffer containing the INF file contents.\r
InfFileSize Size of the contents of the InfFileImage buffer.\r
FvFileName Requested name for the FV file.\r
+ MapFileName Fv map file to log fv driver information.\r
XipBaseAddress BaseAddress is to be rebased.\r
- BtBaseAddress BaseAddress is to set the prefer loaded image start address for boot drivers.\r
- RtBaseAddress BaseAddress is to set the prefer loaded image start address for runtime drivers.\r
+ BtBaseAddress Pointer to BaseAddress is to set the prefer loaded image start address for boot drivers.\r
+ RtBaseAddress Pointer to BaseAddress is to set the prefer loaded image start address for runtime drivers.\r
\r
Returns:\r
\r
Usage (\r
VOID\r
)\r
+/*++\r
+\r
+Routine Description:\r
+\r
+ Print Help message.\r
+\r
+Arguments:\r
+\r
+ void\r
+\r
+Returns:\r
+\r
+ None\r
+\r
+--*/\r
{\r
//\r
// Summary usage\r
fprintf (stdout, " -o FileName, --outputfile FileName\n\\r
File will be created to store the ouput content.\n");\r
fprintf (stdout, " -e EFI_FILETYPE, --efiImage EFI_FILETYPE\n\\r
- EFI_FILETYPE is one of BASE, SEC, PEI_CORE, PEIM, \n\\r
- DXE_CORE, DXE_RUNTIME_DRIVER, DXE_SAL_DRIVER, \n\\r
- DXE_SMM_DRIVER, UEFI_DRIVER, UEFI_APPLICATIOn, \n\\r
- SECURITY_CORE, COMBINED_PEIM_DRIVER, PIC_PEIM, \n\\r
- RELOCATABLE_PEIM, BS_DRIVER, RT_DRIVER, APPLICATION, \n\\r
- SAL_RT_DRIVER to support all module types.\n");\r
+ Create Efi Image. EFI_FILETYPE is one of BASE, SEC,\n\\r
+ PEI_CORE, PEIM, DXE_CORE, DXE_RUNTIME_DRIVER,\n\\r
+ DXE_SAL_DRIVER, UEFI_DRIVER, UEFI_APPLICATIOn, \n\\r
+ DXE_SMM_DRIVER, SECURITY_CORE, COMBINED_PEIM_DRIVER, \n\\r
+ PIC_PEIM, RELOCATABLE_PEIM, BS_DRIVER, RT_DRIVER,\n\\r
+ APPLICATION, SAL_RT_DRIVER to support all module types\n");\r
fprintf (stdout, " -c, --acpi Create Acpi table.\n");\r
fprintf (stdout, " -t, --terse Create Te Image.\n");\r
fprintf (stdout, " -u, --dump Dump TeImage Header.\n");\r
fprintf (stdout, " -z, --zero Zero the Debug Data Fields in the PE input image file.\n");\r
fprintf (stdout, " -b, --exe2bin Convert the input EXE to the output BIN file.\n");\r
- fprintf (stdout, " -r, --replace Overwrite the input file with the ouput content.\n");\r
- fprintf (stdout, " -s [time-date], --stamp [time-date]\n\\r
- time-date format is yyyy-mm-dd 00:00:00. if time-data \n\\r
+ fprintf (stdout, " -r, --replace Overwrite the input file with the output content.\n");\r
+ fprintf (stdout, " -s timedate, --stamp timedate\n\\r
+ timedate format is \"yyyy-mm-dd 00:00:00\". if timedata \n\\r
is set to NOW, current system time is used.\n");\r
fprintf (stdout, " -m, --mcifile Convert input microcode txt file to microcode bin file.\n");\r
- fprintf (stdout, " -j, --join Combine multi microcode bin files to one files.\n");\r
+ fprintf (stdout, " -j, --join Combine multi microcode bin files to one file.\n");\r
fprintf (stdout, " -a NUM, --align NUM NUM is one HEX or DEC format alignment value.\n");\r
fprintf (stdout, " -p NUM, --pad NUM NUM is one HEX or DEC format padding value.\n");\r
fprintf (stdout, " -v, --verbose Turn on verbose output with informational messages.\n");\r
argv ++; \r
\r
if ((stricmp (argv[0], "-h") == 0) || (stricmp (argv[0], "--help") == 0)) {\r
+ Version ();\r
Usage ();\r
return STATUS_SUCCESS; \r
}\r
\r
if ((stricmp (argv[0], "-e") == 0) || (stricmp (argv[0], "--efiImage") == 0)) {\r
ModuleType = argv[1];\r
- if (OutImageType == FW_DUMMY_IMAGE) {\r
+ if (OutImageType != FW_TE_IMAGE) {\r
OutImageType = FW_EFI_IMAGE;\r
}\r
argc -= 2;\r
ZeroDebugData (\r
IN OUT UINT8 *FileBuffer\r
)\r
+/*++\r
+\r
+Routine Description:\r
+\r
+ Zero debug information in PeImage.\r
+\r
+Arguments:\r
+\r
+ FileBuffer - Pointer to PeImage.\r
+\r
+Returns:\r
+\r
+ EFI_ABORTED - PeImage is invalid.\r
+ EFI_SUCCESS - Zero debug data successfully.\r
+\r
+--*/\r
{\r
UINTN Index;\r
UINTN DebugDirectoryEntryRva;\r
IN OUT UINT8 *FileBuffer, \r
IN CHAR8 *TimeStamp\r
)\r
+/*++\r
+\r
+Routine Description:\r
+\r
+ Set new time stamp into PeImage FileHdr and Directory table: \r
+ Debug, Export and Resource.\r
+\r
+Arguments:\r
+\r
+ FileBuffer - Pointer to PeImage.\r
+ TimeStamp - Time stamp string.\r
+\r
+Returns:\r
+\r
+ EFI_INVALID_PARAMETER - TimeStamp format is not recognized.\r
+ EFI_SUCCESS - Set new time stamp in this image successfully.\r
+\r
+--*/\r
{\r
- struct tm stime;\r
- time_t newtime;\r
+ struct tm stime;\r
+ time_t newtime;\r
UINTN Index;\r
UINTN DebugDirectoryEntryRva;\r
UINTN DebugDirectoryEntryFileOffset;\r
Usage (\r
VOID\r
)\r
+/*++\r
+\r
+Routine Description:\r
+\r
+ Print Help message.\r
+\r
+Arguments:\r
+\r
+ void\r
+\r
+Returns:\r
+\r
+ None\r
+\r
+--*/\r
{\r
//\r
// Summary usage\r
//\r
- fprintf (stdout, "Usage: %s [options] <input_file>\n\n", UTILITY_NAME);\r
+ fprintf (stdout, "Usage: %s [options] [input_file]\n\n", UTILITY_NAME);\r
\r
//\r
// Copyright declaration\r
fprintf (stdout, " -c [Type], --compress [Type]\n\\r
Compress method type can be PI_NONE or PI_STD.\n\\r
if Type is not given, PI_STD is default type.\n"); \r
- fprintf (stdout, " -g GuidValue, --vendorguid GuidValue\n\\r
+ fprintf (stdout, " -g GuidValue, --vendor GuidValue\n\\r
GuidValue is one specific vendor guid value.\n\\r
Its format is 00000000-0000-0000-0000-000000000000\n");\r
fprintf (stdout, " -r GuidAttr, --attributes GuidAttr\n\\r
CHAR8 *String,\r
FILE *OutFile\r
)\r
+/*++\r
+\r
+Routine Description:\r
+\r
+ Write ascii string as unicode string format to FILE \r
+\r
+Arguments:\r
+\r
+ String - Pointer to string that is written to FILE.\r
+ OutFile - Pointer to FILE\r
+\r
+Returns:\r
+\r
+ NULL\r
+\r
+--*/\r
{\r
UINT32 Index;\r
UINT8 AsciiNull;\r
fwrite (&String[Index], 1, 1, OutFile);\r
fwrite (&AsciiNull, 1, 1, OutFile);\r
} while (String[Index++] != 0);\r
-}\r
+} \r
\r
STATUS\r
GenSectionCommonLeafSection (\r
argv ++;\r
\r
if ((stricmp (argv[0], "-h") == 0) || (stricmp (argv[0], "--help") == 0)) {\r
- Usage();\r
+ Version ();\r
+ Usage ();\r
return STATUS_SUCCESS; \r
}\r
\r
continue;\r
}\r
\r
- if ((stricmp (argv[0], "-g") == 0) || (stricmp (argv[0], "--vendorguid") == 0)) {\r
+ if ((stricmp (argv[0], "-g") == 0) || (stricmp (argv[0], "--vendor") == 0)) {\r
Status = StringToGuid (argv[1], &VendorGuid);\r
if (EFI_ERROR (Status)) {\r
Error (NULL, 0, 1003, "Invalid option value", "%s = %s", argv[0], argv[1]);\r