//\r
#define UTILITY_MAJOR_VERSION 0\r
#define UTILITY_MINOR_VERSION 1\r
+#define GENFV_UPDATE_TIME " updated on 2008/11/21"\r
+\r
+EFI_GUID mEfiFirmwareFileSystem2Guid = EFI_FIRMWARE_FILE_SYSTEM2_GUID;\r
\r
STATIC\r
VOID \r
\r
--*/\r
{\r
- fprintf (stdout, "%s Version %d.%d\n", UTILITY_NAME, UTILITY_MAJOR_VERSION, UTILITY_MINOR_VERSION);\r
+ fprintf (stdout, "%s Version %d.%d %s\n", UTILITY_NAME, UTILITY_MAJOR_VERSION, UTILITY_MINOR_VERSION, GENFV_UPDATE_TIME);\r
}\r
\r
STATIC\r
fprintf (stdout, " -f FfsFile, --ffsfile FfsFile\n\\r
FfsFile is placed into Fv Image\n\\r
multi files can input one by one\n");\r
+ fprintf (stdout, " -s FileTakenSize, --filetakensize FileTakenSize\n\\r
+ FileTakenSize specifies the size of the required\n\\r
+ space that the input file is placed in Fvimage.\n\\r
+ It is specified together with the input file.\n");\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, " -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, " --capguid GuidValue\n\\r
- GuidValue is one specific capsule vendor guid value.\n\\r
+ fprintf (stdout, " -g Guid, --capguid GuidValue\n\\r
+ GuidValue is one specific capsule or fv vendor guid value.\n\\r
Its format is xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx\n");\r
fprintf (stdout, " --capflag CapFlag\n\\r
Capsule Reset Flag can be PersistAcrossReset,\n\\r
mFvTakenSize = 0;\r
\r
SetUtilityName (UTILITY_NAME);\r
-\r
+ \r
if (argc == 1) {\r
Error (NULL, 0, 1001, "Missing options", "No input options specified.");\r
Usage ();\r
//\r
// Init global data to Zero\r
//\r
- memset (&gFvDataInfo, 0, sizeof (FV_INFO));\r
- memset (&gCapDataInfo, 0, sizeof (CAP_INFO)); \r
+ memset (&mFvDataInfo, 0, sizeof (FV_INFO));\r
+ memset (&mCapDataInfo, 0, sizeof (CAP_INFO)); \r
+ //\r
+ // Set the default FvGuid\r
+ //\r
+ memcpy (&mFvDataInfo.FvGuid, &mEfiFirmwareFileSystem2Guid, sizeof (EFI_GUID));\r
\r
//\r
// Parse command line\r
Error (NULL, 0, 1003, "Invalid option value", "%s = %s", argv[0], argv[1]);\r
return STATUS_ERROR; \r
}\r
- gFvDataInfo.FvBlocks[0].Length = (UINT32) TempNumber;\r
+ mFvDataInfo.FvBlocks[0].Length = (UINT32) TempNumber;\r
DebugMsg (NULL, 0, 9, "FV Block Size", "%s = 0x%x", EFI_BLOCK_SIZE_STRING, TempNumber);\r
argc -= 2;\r
argv += 2;\r
Error (NULL, 0, 1003, "Invalid option value", "%s = %s", argv[0], argv[1]);\r
return STATUS_ERROR; \r
}\r
- gFvDataInfo.FvBlocks[0].NumBlocks = (UINT32) TempNumber;\r
+ mFvDataInfo.FvBlocks[0].NumBlocks = (UINT32) TempNumber;\r
DebugMsg (NULL, 0, 9, "FV Number Block", "%s = 0x%x", EFI_NUM_BLOCKS_STRING, TempNumber);\r
argc -= 2;\r
argv += 2;\r
Error (NULL, 0, 1003, "Invalid option value", "Input Ffsfile can't be null");\r
return STATUS_ERROR;\r
}\r
- strcpy (gFvDataInfo.FvFiles[Index++], argv[1]);\r
- DebugMsg (NULL, 0, 9, "FV component file", "the %dth name is %s", Index - 1, argv[1]);\r
+ strcpy (mFvDataInfo.FvFiles[Index], argv[1]);\r
+ DebugMsg (NULL, 0, 9, "FV component file", "the %dth name is %s", Index + 1, argv[1]);\r
argc -= 2;\r
argv += 2;\r
+\r
+ if (argc > 0) {\r
+ if ((stricmp (argv[0], "-s") == 0) || (stricmp (argv[0], "--filetakensize") == 0)) {\r
+ if (argv[1] == NULL) {\r
+ Error (NULL, 0, 1003, "Invalid option value", "Ffsfile Size can't be null");\r
+ return STATUS_ERROR;\r
+ }\r
+ Status = AsciiStringToUint64 (argv[1], FALSE, &TempNumber);\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
+ mFvDataInfo.SizeofFvFiles[Index] = TempNumber;\r
+ DebugMsg (NULL, 0, 9, "FV component file size", "the %dth size is %s", Index + 1, argv[1]);\r
+ argc -= 2;\r
+ argv += 2;\r
+ }\r
+ }\r
+ Index ++;\r
continue; \r
}\r
\r
Error (NULL, 0, 1003, "Invalid option value", "%s = %s", argv[0], argv[1]);\r
return STATUS_ERROR; \r
}\r
- gCapDataInfo.HeaderSize = (UINT32) TempNumber;\r
+ mCapDataInfo.HeaderSize = (UINT32) TempNumber;\r
DebugMsg (NULL, 0, 9, "Capsule Header size", "%s = 0x%x", EFI_CAPSULE_HEADER_SIZE_STRING, TempNumber);\r
argc -= 2;\r
argv += 2;\r
return STATUS_ERROR;\r
}\r
if (strcmp (argv[1], "PopulateSystemTable") == 0) {\r
- gCapDataInfo.Flags |= CAPSULE_FLAGS_PERSIST_ACROSS_RESET | CAPSULE_FLAGS_POPULATE_SYSTEM_TABLE;\r
+ mCapDataInfo.Flags |= CAPSULE_FLAGS_PERSIST_ACROSS_RESET | CAPSULE_FLAGS_POPULATE_SYSTEM_TABLE;\r
} else if (strcmp (argv[1], "PersistAcrossReset") == 0) {\r
- gCapDataInfo.Flags |= CAPSULE_FLAGS_PERSIST_ACROSS_RESET;\r
+ mCapDataInfo.Flags |= CAPSULE_FLAGS_PERSIST_ACROSS_RESET;\r
} else {\r
Error (NULL, 0, 1003, "Invalid option value", "%s = %s", argv[0], argv[1]);\r
return STATUS_ERROR;\r
//\r
// Get the Capsule Guid\r
//\r
- Status = StringToGuid (argv[1], &gCapDataInfo.CapGuid);\r
+ Status = StringToGuid (argv[1], &mCapDataInfo.CapGuid);\r
if (EFI_ERROR (Status)) {\r
Error (NULL, 0, 1003, "Invalid option value", "%s = %s", EFI_CAPSULE_GUID_STRING, argv[1]);\r
return EFI_ABORTED;\r
continue; \r
}\r
\r
+ if (stricmp (argv[0], "-g") == 0) {\r
+ //\r
+ // Get the Capsule or Fv Guid\r
+ //\r
+ Status = StringToGuid (argv[1], &mCapDataInfo.CapGuid);\r
+ if (EFI_ERROR (Status)) {\r
+ Error (NULL, 0, 1003, "Invalid option value", "%s = %s", EFI_GUID_STRING, argv[1]);\r
+ return EFI_ABORTED;\r
+ }\r
+ memcpy (&mFvDataInfo.FvGuid, &mCapDataInfo.CapGuid, sizeof (EFI_GUID));\r
+ DebugMsg (NULL, 0, 9, "Capsule Guid", "%s = %s", EFI_CAPSULE_GUID_STRING, argv[1]);\r
+ DebugMsg (NULL, 0, 9, "FV Guid", "%s = %s", EFI_FV_GUID_STRING, argv[1]);\r
+ argc -= 2;\r
+ argv += 2;\r
+ continue; \r
+ }\r
+\r
if ((stricmp (argv[0], "-p") == 0) || (stricmp (argv[0], "--dump") == 0)) {\r
DumpCapsule = TRUE;\r
argc --;\r
Error (NULL, 0, 1001, "Missing option", "Input Capsule Image");\r
return STATUS_ERROR;\r
}\r
- VerboseMsg ("the input file name is %s", InfFileName);\r
+ VerboseMsg ("the input FvInf or CapInf file name is %s", InfFileName);\r
\r
if (!DumpCapsule && OutFileName == NULL) {\r
Error (NULL, 0, 1001, "Missing option", "Output File");\r
//\r
// Call the GenerateCapImage to generate Capsule Image\r
//\r
- for (Index = 0; gFvDataInfo.FvFiles[Index][0] != '\0'; Index ++) {\r
- strcpy (gCapDataInfo.CapFiles[Index], gFvDataInfo.FvFiles[Index]);\r
+ for (Index = 0; mFvDataInfo.FvFiles[Index][0] != '\0'; Index ++) {\r
+ strcpy (mCapDataInfo.CapFiles[Index], mFvDataInfo.FvFiles[Index]);\r
}\r
\r
Status = GenerateCapImage (\r
if (mFvTotalSize != 0) {\r
fprintf (FpFile, EFI_FV_TOTAL_SIZE_STRING);\r
fprintf (FpFile, " = 0x%x\n", mFvTotalSize);\r
- DebugMsg (NULL, 0, 9, "The Total Fv Size", "%s = 0x%x", EFI_FV_TOTAL_SIZE_STRING, mFvTotalSize);\r
}\r
if (mFvTakenSize != 0) {\r
fprintf (FpFile, EFI_FV_TAKEN_SIZE_STRING);\r
fprintf (FpFile, " = 0x%x\n", mFvTakenSize);\r
- DebugMsg (NULL, 0, 9, "The used Fv Size", "%s = 0x%x", EFI_FV_TAKEN_SIZE_STRING, mFvTakenSize);\r
}\r
if (mFvTotalSize != 0 && mFvTakenSize != 0) {\r
fprintf (FpFile, EFI_FV_SPACE_SIZE_STRING);\r
fprintf (FpFile, " = 0x%x\n", mFvTotalSize - mFvTakenSize);\r
- DebugMsg (NULL, 0, 9, "The space Fv size", "%s = 0x%x", EFI_FV_SPACE_SIZE_STRING, mFvTotalSize - mFvTakenSize);\r
}\r
fclose (FpFile);\r
}\r
+ \r
+ if (Status == EFI_SUCCESS) {\r
+ DebugMsg (NULL, 0, 9, "The Total Fv Size", "%s = 0x%x", EFI_FV_TOTAL_SIZE_STRING, mFvTotalSize);\r
+ DebugMsg (NULL, 0, 9, "The used Fv Size", "%s = 0x%x", EFI_FV_TAKEN_SIZE_STRING, mFvTakenSize);\r
+ DebugMsg (NULL, 0, 9, "The space Fv size", "%s = 0x%x", EFI_FV_SPACE_SIZE_STRING, mFvTotalSize - mFvTakenSize);\r
+ }\r
\r
VerboseMsg ("%s tool done with return code is 0x%x.", UTILITY_NAME, GetUtilityStatus ());\r
\r
\r
STATIC UINT32 MaxFfsAlignment = 0;\r
\r
-EFI_GUID mEfiFirmwareFileSystem2Guid = EFI_FIRMWARE_FILE_SYSTEM2_GUID;\r
EFI_GUID mEfiFirmwareVolumeTopFileGuid = EFI_FFS_VOLUME_TOP_FILE_GUID;\r
EFI_GUID mFileGuidArray [MAX_NUMBER_OF_FILES_IN_FV] = {0};\r
EFI_GUID mZeroGuid = {0x0, 0x0, 0x0, {0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0}};\r
0x00\r
};\r
\r
-FV_INFO gFvDataInfo;\r
-CAP_INFO gCapDataInfo;\r
+FV_INFO mFvDataInfo;\r
+CAP_INFO mCapDataInfo;\r
\r
EFI_STATUS\r
ParseFvInf (\r
//\r
// Get the guid value\r
//\r
- Status = StringToGuid (Value, &FvInfo->FvGuid);\r
- if (EFI_ERROR (Status)) {\r
- memcpy (&FvInfo->FvGuid, &mEfiFirmwareFileSystem2Guid, sizeof (EFI_GUID));\r
- }\r
- } else {\r
- memcpy (&FvInfo->FvGuid, &mEfiFirmwareFileSystem2Guid, sizeof (EFI_GUID));\r
+ StringToGuid (Value, &FvInfo->FvGuid);\r
}\r
DebugMsg (NULL, 0, 9, "FV File Guid", "%08X-%04X-%04X-%02X%02X-%02X%02X%02X%02X%02X%02X", \r
FvInfo->FvGuid.Data1,\r
}\r
}\r
\r
+EFI_STATUS\r
+WriteMapFile (\r
+ IN OUT FILE *FvMapFile,\r
+ IN CHAR8 *FileName,\r
+ IN EFI_GUID *FileGuidPtr, \r
+ IN EFI_PHYSICAL_ADDRESS ImageBaseAddress,\r
+ IN PE_COFF_LOADER_IMAGE_CONTEXT *pImageContext\r
+ )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+ This function gets the basic debug information (entrypoint, baseaddress, .text, .data section base address)\r
+ from PE/COFF image and abstracts Pe Map file information and add them into FvMap file for Debug.\r
+\r
+Arguments:\r
+\r
+ FvMapFile A pointer to FvMap File\r
+ FileName Ffs File PathName\r
+ FileGuidPtr Guid Value of Ffs file\r
+ ImageBaseAddress PeImage Base Address.\r
+ pImageContext Image Context Information.\r
+\r
+Returns:\r
+\r
+ EFI_SUCCESS Added required map information.\r
+\r
+--*/\r
+{\r
+ CHAR8 PeMapFileName [_MAX_PATH];\r
+ CHAR8 *Cptr, *Cptr2;\r
+ CHAR8 FileGuidName [MAX_LINE_LEN];\r
+ FILE *PeMapFile;\r
+ CHAR8 Line [MAX_LINE_LEN];\r
+ CHAR8 KeyWord [MAX_LINE_LEN];\r
+ CHAR8 FunctionName [MAX_LINE_LEN];\r
+ EFI_PHYSICAL_ADDRESS FunctionAddress;\r
+ UINT32 FunctionType;\r
+ CHAR8 FunctionTypeName [MAX_LINE_LEN];\r
+ UINT32 Index;\r
+ UINT32 AddressOfEntryPoint;\r
+ UINT32 Offset;\r
+ EFI_IMAGE_NT_HEADERS *PeHdr;\r
+ EFI_TE_IMAGE_HEADER *TEImageHeader;\r
+ EFI_IMAGE_SECTION_HEADER *SectionHeader;\r
+ \r
+ //\r
+ // Init local variable\r
+ //\r
+ FunctionType = 0;\r
+ //\r
+ // Print FileGuid to string buffer. \r
+ //\r
+ PrintGuidToBuffer (FileGuidPtr, FileGuidName, MAX_LINE_LEN, TRUE);\r
+ \r
+ //\r
+ // Construct Map file Name \r
+ //\r
+ strcpy (PeMapFileName, FileName);\r
+ \r
+ //\r
+ // Change '\\' to '/', unified path format.\r
+ //\r
+ Cptr = PeMapFileName;\r
+ while (*Cptr != '\0') {\r
+ if (*Cptr == '\\') {\r
+ *Cptr = FILE_SEP_CHAR;\r
+ }\r
+ Cptr ++;\r
+ }\r
+ \r
+ //\r
+ // Get Map file\r
+ // \r
+ Cptr = PeMapFileName + strlen (PeMapFileName);\r
+ while ((*Cptr != '.') && (Cptr >= PeMapFileName)) {\r
+ Cptr --;\r
+ }\r
+ if (Cptr < PeMapFileName) {\r
+ return EFI_NOT_FOUND;\r
+ } else {\r
+ *(Cptr + 1) = 'm';\r
+ *(Cptr + 2) = 'a';\r
+ *(Cptr + 3) = 'p';\r
+ *(Cptr + 4) = '\0';\r
+ }\r
+\r
+ //\r
+ // Get module Name\r
+ //\r
+ Cptr2 = Cptr;\r
+ while ((*Cptr != FILE_SEP_CHAR) && (Cptr >= PeMapFileName)) {\r
+ Cptr --;\r
+ }\r
+ *Cptr2 = '\0';\r
+ strcpy (KeyWord, Cptr + 1);\r
+ *Cptr2 = '.';\r
+\r
+ //\r
+ // AddressOfEntryPoint and Offset in Image\r
+ //\r
+ if (!pImageContext->IsTeImage) {\r
+ PeHdr = (EFI_IMAGE_NT_HEADERS *) ((UINT8 *) pImageContext->Handle + pImageContext->PeCoffHeaderOffset);\r
+ AddressOfEntryPoint = PeHdr->OptionalHeader.AddressOfEntryPoint;\r
+ Offset = 0;\r
+ SectionHeader = (EFI_IMAGE_SECTION_HEADER *) (\r
+ (UINT8 *) PeHdr +\r
+ sizeof (UINT32) + \r
+ sizeof (EFI_IMAGE_FILE_HEADER) + \r
+ PeHdr->FileHeader.SizeOfOptionalHeader\r
+ );\r
+ Index = PeHdr->FileHeader.NumberOfSections;\r
+ } else {\r
+ TEImageHeader = (EFI_TE_IMAGE_HEADER *) pImageContext->Handle;\r
+ AddressOfEntryPoint = TEImageHeader->AddressOfEntryPoint;\r
+ Offset = TEImageHeader->StrippedSize - sizeof (EFI_TE_IMAGE_HEADER);\r
+ SectionHeader = (EFI_IMAGE_SECTION_HEADER *) (TEImageHeader + 1);\r
+ Index = TEImageHeader->NumberOfSections;\r
+ }\r
+ \r
+ //\r
+ // module information output\r
+ //\r
+ if (ImageBaseAddress == 0) {\r
+ fprintf (FvMapFile, "%s (dummy) (", KeyWord);\r
+ fprintf (FvMapFile, "BaseAddress=%08lx, ", ImageBaseAddress);\r
+ } else {\r
+ fprintf (FvMapFile, "%s (", KeyWord);\r
+ fprintf (FvMapFile, "BaseAddress=%08lx, ", ImageBaseAddress + Offset);\r
+ }\r
+ fprintf (FvMapFile, "EntryPoint=%08lx, ", ImageBaseAddress + AddressOfEntryPoint);\r
+ fprintf (FvMapFile, "GUID=%s", FileGuidName);\r
+ fprintf (FvMapFile, ")\n"); \r
+ \r
+ for (Index; Index > 0;Index --, SectionHeader ++) {\r
+ if (stricmp (SectionHeader->Name, ".text") == 0) {\r
+ fprintf (FvMapFile, ".textbaseaddress=%08lx ",ImageBaseAddress + SectionHeader->VirtualAddress);\r
+ } else if (stricmp (SectionHeader->Name, ".data") == 0) {\r
+ fprintf (FvMapFile, ".databaseaddress=%08lx ",ImageBaseAddress + SectionHeader->VirtualAddress);\r
+ }\r
+ }\r
+ fprintf (FvMapFile, "\n\n"); \r
+ \r
+ //\r
+ // Open PeMapFile\r
+ //\r
+ PeMapFile = fopen (PeMapFileName, "r");\r
+ if (PeMapFile == NULL) {\r
+ // fprintf (stdout, "can't open %s file to reading\n", PeMapFileName);\r
+ return EFI_ABORTED;\r
+ }\r
+ VerboseMsg ("The map file is %s", PeMapFileName);\r
+ \r
+ //\r
+ // Output Functions information into Fv Map file\r
+ //\r
+ while (fgets (Line, MAX_LINE_LEN, PeMapFile) != NULL) {\r
+ //\r
+ // Skip blank line\r
+ //\r
+ if (Line[0] == 0x0a) {\r
+ FunctionType = 0;\r
+ continue;\r
+ }\r
+ //\r
+ // By Address and Static keyword\r
+ // \r
+ if (FunctionType == 0) {\r
+ sscanf (Line, "%s", KeyWord);\r
+ if (stricmp (KeyWord, "Address") == 0) {\r
+ //\r
+ // function list\r
+ //\r
+ FunctionType = 1;\r
+ fgets (Line, MAX_LINE_LEN, PeMapFile);\r
+ } else if (stricmp (KeyWord, "Static") == 0) {\r
+ //\r
+ // static function list\r
+ //\r
+ FunctionType = 2;\r
+ fgets (Line, MAX_LINE_LEN, PeMapFile);\r
+ }\r
+ continue;\r
+ }\r
+ //\r
+ // Printf Function Information\r
+ //\r
+ if (FunctionType == 1) {\r
+ sscanf (Line, "%s %s %lx %s", KeyWord, FunctionName, &FunctionAddress, FunctionTypeName);\r
+ if (FunctionTypeName [1] == '\0' && (FunctionTypeName [0] == 'f' || FunctionTypeName [0] == 'F')) {\r
+ fprintf (FvMapFile, " %016lx ", ImageBaseAddress + FunctionAddress);\r
+ fprintf (FvMapFile, "(%08lx) F ", FunctionAddress - Offset);\r
+ fprintf (FvMapFile, "%s\n", FunctionName);\r
+ } else {\r
+ fprintf (FvMapFile, " %016lx ", ImageBaseAddress + FunctionAddress);\r
+ fprintf (FvMapFile, "(%08lx) ", FunctionAddress - Offset);\r
+ fprintf (FvMapFile, "%s\n", FunctionName);\r
+ }\r
+ } else if (FunctionType == 2) {\r
+ sscanf (Line, "%s %s %lx %s", KeyWord, FunctionName, &FunctionAddress, FunctionTypeName);\r
+ if (FunctionTypeName [1] == '\0' && (FunctionTypeName [0] == 'f' || FunctionTypeName [0] == 'F')) {\r
+ fprintf (FvMapFile, " %016lx ", ImageBaseAddress + FunctionAddress);\r
+ fprintf (FvMapFile, "(%08lx) FS ", FunctionAddress - Offset);\r
+ fprintf (FvMapFile, "%s\n", FunctionName);\r
+ } else {\r
+ fprintf (FvMapFile, " %016lx ", ImageBaseAddress + FunctionAddress);\r
+ fprintf (FvMapFile, "(%08lx) ", FunctionAddress - Offset);\r
+ fprintf (FvMapFile, "%s\n", FunctionName);\r
+ }\r
+ }\r
+ }\r
+ //\r
+ // Close PeMap file\r
+ //\r
+ fprintf (FvMapFile, "\n\n");\r
+ fclose (PeMapFile);\r
+ \r
+ return EFI_SUCCESS;\r
+}\r
+\r
EFI_STATUS\r
AddFile (\r
IN OUT MEMORY_FILE *FvImage,\r
return EFI_ABORTED;\r
}\r
\r
+ //\r
+ // For None PI Ffs file, directly add them into FvImage.\r
+ //\r
+ if (!FvInfo->IsPiFvImage) {\r
+ memcpy (FvImage->CurrentFilePointer, FileBuffer, FileSize);\r
+ if (FvInfo->SizeofFvFiles[Index] > FileSize) {\r
+ FvImage->CurrentFilePointer += FvInfo->SizeofFvFiles[Index];\r
+ } else {\r
+ FvImage->CurrentFilePointer += FileSize;\r
+ }\r
+ goto Done;\r
+ }\r
+ \r
//\r
// Verify Ffs file\r
//\r
FvImage->CurrentFilePointer++;\r
}\r
\r
+Done: \r
//\r
// Free allocated memory.\r
//\r
//\r
// Parse the FV inf file for header information\r
//\r
- Status = ParseFvInf (&InfMemoryFile, &gFvDataInfo);\r
+ Status = ParseFvInf (&InfMemoryFile, &mFvDataInfo);\r
if (EFI_ERROR (Status)) {\r
Error (NULL, 0, 0003, "Error parsing file", "the input INF file.");\r
return Status;\r
//\r
// Update the file name return values\r
//\r
- if (FvFileName == NULL && gFvDataInfo.FvName[0] != '\0') {\r
- FvFileName = gFvDataInfo.FvName;\r
+ if (FvFileName == NULL && mFvDataInfo.FvName[0] != '\0') {\r
+ FvFileName = mFvDataInfo.FvName;\r
}\r
\r
if (FvFileName == NULL) {\r
return EFI_ABORTED;\r
}\r
\r
- if (gFvDataInfo.FvBlocks[0].Length == 0) {\r
+ if (mFvDataInfo.FvBlocks[0].Length == 0) {\r
Error (NULL, 0, 1001, "Missing required argument", "Block Size");\r
return EFI_ABORTED;\r
}\r
- \r
+\r
+ if (CompareGuid (&mFvDataInfo.FvGuid, &mEfiFirmwareFileSystem2Guid) == 0) {\r
+ mFvDataInfo.IsPiFvImage = TRUE;\r
+ } \r
+\r
//\r
// FvMap file to log the function address of all modules in one Fvimage\r
//\r
// Update FvImage Base Address, XipBase not same to BtBase, RtBase address.\r
//\r
if (XipBaseAddress != 0) {\r
- gFvDataInfo.BaseAddress = XipBaseAddress;\r
+ mFvDataInfo.BaseAddress = XipBaseAddress;\r
}\r
if (*BtBaseAddress != 0) {\r
- gFvDataInfo.BootBaseAddress = *BtBaseAddress;\r
+ mFvDataInfo.BootBaseAddress = *BtBaseAddress;\r
}\r
if (*RtBaseAddress != 0) {\r
- gFvDataInfo.RuntimeBaseAddress = *RtBaseAddress;\r
+ mFvDataInfo.RuntimeBaseAddress = *RtBaseAddress;\r
}\r
\r
//\r
// Calculate the FV size and Update Fv Size based on the actual FFS files.\r
- // And Update gFvDataInfo data.\r
+ // And Update mFvDataInfo data.\r
//\r
- Status = CalculateFvSize (&gFvDataInfo);\r
+ Status = CalculateFvSize (&mFvDataInfo);\r
if (EFI_ERROR (Status)) {\r
return Status; \r
}\r
- VerboseMsg ("the generated FV image size is %d bytes", gFvDataInfo.Size);\r
+ VerboseMsg ("the generated FV image size is %d bytes", mFvDataInfo.Size);\r
\r
//\r
// support fv image and empty fv image\r
//\r
- FvImageSize = gFvDataInfo.Size;\r
+ FvImageSize = mFvDataInfo.Size;\r
\r
//\r
// Allocate the FV, assure FvImage Header 8 byte alignment\r
//\r
// Initialize the FV to the erase polarity\r
//\r
- if (gFvDataInfo.FvAttributes == 0) {\r
+ if (mFvDataInfo.FvAttributes == 0) {\r
//\r
// Set Default Fv Attribute \r
//\r
- gFvDataInfo.FvAttributes = FV_DEFAULT_ATTRIBUTE;\r
+ mFvDataInfo.FvAttributes = FV_DEFAULT_ATTRIBUTE;\r
}\r
- if (gFvDataInfo.FvAttributes & EFI_FVB2_ERASE_POLARITY) {\r
+ if (mFvDataInfo.FvAttributes & EFI_FVB2_ERASE_POLARITY) {\r
memset (FvImage, -1, FvImageSize);\r
} else {\r
memset (FvImage, 0, FvImageSize);\r
//\r
// Copy the FFS GUID\r
//\r
- memcpy (&FvHeader->FileSystemGuid, &gFvDataInfo.FvGuid, sizeof (EFI_GUID));\r
+ memcpy (&FvHeader->FileSystemGuid, &mFvDataInfo.FvGuid, sizeof (EFI_GUID));\r
\r
FvHeader->FvLength = FvImageSize;\r
FvHeader->Signature = EFI_FVH_SIGNATURE;\r
- FvHeader->Attributes = gFvDataInfo.FvAttributes;\r
+ FvHeader->Attributes = mFvDataInfo.FvAttributes;\r
FvHeader->Revision = EFI_FVH_REVISION;\r
FvHeader->ExtHeaderOffset = 0;\r
FvHeader->Reserved[0] = 0;\r
//\r
// Copy firmware block map\r
//\r
- for (Index = 0; gFvDataInfo.FvBlocks[Index].Length != 0; Index++) {\r
- FvHeader->BlockMap[Index].NumBlocks = gFvDataInfo.FvBlocks[Index].NumBlocks;\r
- FvHeader->BlockMap[Index].Length = gFvDataInfo.FvBlocks[Index].Length;\r
+ for (Index = 0; mFvDataInfo.FvBlocks[Index].Length != 0; Index++) {\r
+ FvHeader->BlockMap[Index].NumBlocks = mFvDataInfo.FvBlocks[Index].NumBlocks;\r
+ FvHeader->BlockMap[Index].Length = mFvDataInfo.FvBlocks[Index].Length;\r
}\r
\r
//\r
//\r
// If there is no FFS file, generate one empty FV\r
//\r
- if (gFvDataInfo.FvFiles[0][0] == 0) {\r
+ if (mFvDataInfo.FvFiles[0][0] == 0) {\r
goto WriteFile;\r
}\r
\r
//\r
// Add files to FV\r
//\r
- for (Index = 0; gFvDataInfo.FvFiles[Index][0] != 0; Index++) {\r
+ for (Index = 0; mFvDataInfo.FvFiles[Index][0] != 0; Index++) {\r
//\r
// Add the file\r
//\r
- Status = AddFile (&FvImageMemoryFile, &gFvDataInfo, Index, &VtfFileImage, FvMapFile);\r
+ Status = AddFile (&FvImageMemoryFile, &mFvDataInfo, Index, &VtfFileImage, FvMapFile);\r
\r
//\r
// Exit if error detected while adding the file\r
// reset vector. If the PEI Core is found, the VTF file will probably get \r
// corrupted by updating the entry point. \r
//\r
- if ((gFvDataInfo.BaseAddress + gFvDataInfo.Size) == FV_IMAGES_TOP_ADDRESS) { \r
- Status = UpdateResetVector (&FvImageMemoryFile, &gFvDataInfo, VtfFileImage);\r
+ if ((mFvDataInfo.BaseAddress + mFvDataInfo.Size) == FV_IMAGES_TOP_ADDRESS) { \r
+ Status = UpdateResetVector (&FvImageMemoryFile, &mFvDataInfo, VtfFileImage);\r
if (EFI_ERROR(Status)) { \r
Error (NULL, 0, 3000, "Invalid", "Could not update the reset vector.");\r
goto Finish; \r
//\r
// Update BootAddress and RuntimeAddress\r
//\r
- *BtBaseAddress = gFvDataInfo.BootBaseAddress;\r
- *RtBaseAddress = gFvDataInfo.RuntimeBaseAddress;\r
+ *BtBaseAddress = mFvDataInfo.BootBaseAddress;\r
+ *RtBaseAddress = mFvDataInfo.RuntimeBaseAddress;\r
\r
return Status;\r
}\r
// close file\r
//\r
fclose (fpin);\r
- //\r
- // Check whether this ffs file is vtf file\r
- //\r
- if (IsVtfFile (&FfsHeader)) {\r
- if (VtfFileFlag) {\r
- //\r
- // One Fv image can't have two vtf files.\r
- //\r
- return EFI_ABORTED;\r
- }\r
- VtfFileFlag = TRUE;\r
- //\r
- // The space between Vft File and the latest file must be able to contain \r
- // one ffs file header in order to add one pad file.\r
- //\r
- CurrentOffset += sizeof (EFI_FFS_FILE_HEADER);\r
- }\r
- //\r
- // Get the alignment of FFS file \r
- //\r
- ReadFfsAlignment (&FfsHeader, &FfsAlignment);\r
- FfsAlignment = 1 << FfsAlignment;\r
- //\r
- // Add Pad file\r
- //\r
- if (((CurrentOffset + sizeof (EFI_FFS_FILE_HEADER)) % FfsAlignment) != 0) {\r
- CurrentOffset = (CurrentOffset + sizeof (EFI_FFS_FILE_HEADER) * 2 + FfsAlignment - 1) & ~(FfsAlignment - 1);\r
- CurrentOffset -= sizeof (EFI_FFS_FILE_HEADER);\r
- }\r
+ \r
+ if (FvInfoPtr->IsPiFvImage) {\r
+ //\r
+ // Check whether this ffs file is vtf file\r
+ //\r
+ if (IsVtfFile (&FfsHeader)) {\r
+ if (VtfFileFlag) {\r
+ //\r
+ // One Fv image can't have two vtf files.\r
+ //\r
+ return EFI_ABORTED;\r
+ }\r
+ VtfFileFlag = TRUE;\r
+ //\r
+ // The space between Vft File and the latest file must be able to contain \r
+ // one ffs file header in order to add one pad file.\r
+ //\r
+ CurrentOffset += sizeof (EFI_FFS_FILE_HEADER);\r
+ }\r
+ //\r
+ // Get the alignment of FFS file \r
+ //\r
+ ReadFfsAlignment (&FfsHeader, &FfsAlignment);\r
+ FfsAlignment = 1 << FfsAlignment;\r
+ //\r
+ // Add Pad file\r
+ //\r
+ if (((CurrentOffset + sizeof (EFI_FFS_FILE_HEADER)) % FfsAlignment) != 0) {\r
+ CurrentOffset = (CurrentOffset + sizeof (EFI_FFS_FILE_HEADER) * 2 + FfsAlignment - 1) & ~(FfsAlignment - 1);\r
+ CurrentOffset -= sizeof (EFI_FFS_FILE_HEADER);\r
+ }\r
+ }\r
+\r
//\r
// Add ffs file size\r
//\r
- CurrentOffset += FfsFileSize; \r
+ if (FvInfoPtr->SizeofFvFiles[Index] > FfsFileSize) {\r
+ CurrentOffset += FvInfoPtr->SizeofFvFiles[Index];\r
+ } else {\r
+ CurrentOffset += FfsFileSize;\r
+ }\r
+ \r
//\r
// Make next ffs file start at QWord Boundry\r
//\r
- CurrentOffset = (CurrentOffset + EFI_FFS_FILE_HEADER_ALIGNMENT - 1) & ~(EFI_FFS_FILE_HEADER_ALIGNMENT - 1);\r
+ if (FvInfoPtr->IsPiFvImage) {\r
+ CurrentOffset = (CurrentOffset + EFI_FFS_FILE_HEADER_ALIGNMENT - 1) & ~(EFI_FFS_FILE_HEADER_ALIGNMENT - 1);\r
+ }\r
}\r
\r
DebugMsg (NULL, 0, 9, "FvImage size", "The caculated fv image size is 0x%x and the current set fv image size is 0x%x", CurrentOffset, FvInfoPtr->Size);\r
{\r
EFI_STATUS Status;\r
PE_COFF_LOADER_IMAGE_CONTEXT ImageContext;\r
+ PE_COFF_LOADER_IMAGE_CONTEXT OrigImageContext; \r
EFI_PHYSICAL_ADDRESS XipBase;\r
EFI_PHYSICAL_ADDRESS NewPe32BaseAddress;\r
EFI_PHYSICAL_ADDRESS *BaseToUpdate;\r
ImageContext.ImageRead = (PE_COFF_LOADER_READ_FILE) FfsRebaseImageRead;\r
Status = PeCoffLoaderGetImageInfo (&ImageContext);\r
if (EFI_ERROR (Status)) {\r
- Error (NULL, 0, 3000, "Invalid", "GetImageInfo() call failed on rebase %s.", FileName);\r
+ Error (NULL, 0, 3000, "Invalid PeImage", "The input file is %s and the return status is %x", FileName, Status);\r
return Status;\r
}\r
+ //\r
+ // Keep Image Context for PE image in FV\r
+ //\r
+ memcpy (&OrigImageContext, &ImageContext, sizeof (ImageContext));\r
\r
//\r
// Get File PdbPointer\r
ImageContext.Handle = PeFileBuffer;\r
Status = PeCoffLoaderGetImageInfo (&ImageContext);\r
if (EFI_ERROR (Status)) {\r
- Error (NULL, 0, 3000, "Invalid", "GetImageInfo() call failed on rebase of %s", FileName);\r
+ Error (NULL, 0, 3000, "Invalid PeImage", "The input file is %s and the return status is %x", FileName, Status);\r
return Status;\r
}\r
ImageContext.RelocationsStripped = FALSE;\r
break;\r
\r
case EFI_FV_FILETYPE_DRIVER:\r
+ case EFI_FV_FILETYPE_DXE_CORE:\r
switch (PeHdr->OptionalHeader.Subsystem) {\r
case EFI_IMAGE_SUBSYSTEM_EFI_RUNTIME_DRIVER:\r
- if ((Flags & REBASE_RUNTIME_FILE) == 0) {\r
+ if ((Flags & REBASE_XIP_FILE) == REBASE_XIP_FILE) {\r
+ //\r
+ // Check if section-alignment and file-alignment match or not\r
+ //\r
+ if ((PeHdr->OptionalHeader.SectionAlignment != PeHdr->OptionalHeader.FileAlignment)) {\r
+ //\r
+ // Xip module has the same section alignment and file alignment.\r
+ //\r
+ Error (NULL, 0, 3000, "Invalid", "Section-Alignment and File-Alignment do not match : %s.", FileName);\r
+ return EFI_ABORTED;\r
+ }\r
+ NewPe32BaseAddress = XipBase + (UINTN) CurrentPe32Section.Pe32Section + sizeof (EFI_PE32_SECTION) - (UINTN)FfsFile;\r
+ BaseToUpdate = &XipBase; \r
+ } else if ((Flags & REBASE_RUNTIME_FILE) == REBASE_RUNTIME_FILE) {\r
+ //\r
+ // make sure image base address at the section alignment\r
+ //\r
+ FvInfo->RuntimeBaseAddress = (FvInfo->RuntimeBaseAddress - ImageContext.ImageSize) & (~(ImageContext.SectionAlignment - 1));\r
+ FvInfo->RuntimeBaseAddress = FvInfo->RuntimeBaseAddress & (~(EFI_PAGE_SIZE - 1));\r
+ NewPe32BaseAddress = FvInfo->RuntimeBaseAddress;\r
+ BaseToUpdate = &(FvInfo->RuntimeBaseAddress);\r
+ } else {\r
//\r
// RT drivers aren't supposed to be relocated\r
//\r
goto WritePeMap;\r
}\r
- //\r
- // make sure image base address at the section alignment\r
- //\r
- FvInfo->RuntimeBaseAddress = (FvInfo->RuntimeBaseAddress - ImageContext.ImageSize) & (~(ImageContext.SectionAlignment - 1));\r
- FvInfo->RuntimeBaseAddress = FvInfo->RuntimeBaseAddress & (~(EFI_PAGE_SIZE - 1));\r
- NewPe32BaseAddress = FvInfo->RuntimeBaseAddress;\r
- BaseToUpdate = &(FvInfo->RuntimeBaseAddress);\r
break;\r
\r
default:\r
//\r
// We treat all other subsystems the same as BS_DRIVER\r
//\r
- if ((Flags & REBASE_BOOTTIME_FILE) == 0) {\r
+ if ((Flags & REBASE_XIP_FILE) == REBASE_XIP_FILE) {\r
+ //\r
+ // Check if section-alignment and file-alignment match or not\r
+ //\r
+ if ((PeHdr->OptionalHeader.SectionAlignment != PeHdr->OptionalHeader.FileAlignment)) {\r
+ //\r
+ // Xip module has the same section alignment and file alignment.\r
+ //\r
+ Error (NULL, 0, 3000, "Invalid", "Section-Alignment and File-Alignment do not match : %s.", FileName);\r
+ return EFI_ABORTED;\r
+ }\r
+ NewPe32BaseAddress = XipBase + (UINTN) CurrentPe32Section.Pe32Section + sizeof (EFI_PE32_SECTION) - (UINTN)FfsFile;\r
+ BaseToUpdate = &XipBase; \r
+ } else if ((Flags & REBASE_BOOTTIME_FILE) == REBASE_BOOTTIME_FILE) {\r
+ //\r
+ // make sure image base address at the Section and Page alignment\r
+ //\r
+ FvInfo->BootBaseAddress = (FvInfo->BootBaseAddress - ImageContext.ImageSize) & (~(ImageContext.SectionAlignment - 1));\r
+ FvInfo->BootBaseAddress = FvInfo->BootBaseAddress & (~(EFI_PAGE_SIZE - 1));\r
+ NewPe32BaseAddress = FvInfo->BootBaseAddress;\r
+ BaseToUpdate = &(FvInfo->BootBaseAddress);\r
+ } else {\r
//\r
// Skip all BS_DRIVER's\r
//\r
goto WritePeMap;\r
}\r
- //\r
- // make sure image base address at the Section and Page alignment\r
- //\r
- FvInfo->BootBaseAddress = (FvInfo->BootBaseAddress - ImageContext.ImageSize) & (~(ImageContext.SectionAlignment - 1));\r
- FvInfo->BootBaseAddress = FvInfo->BootBaseAddress & (~(EFI_PAGE_SIZE - 1));\r
- NewPe32BaseAddress = FvInfo->BootBaseAddress;\r
- BaseToUpdate = &(FvInfo->BootBaseAddress);\r
break;\r
}\r
break;\r
\r
- case EFI_FV_FILETYPE_DXE_CORE:\r
- if ((Flags & REBASE_BOOTTIME_FILE) == 0) {\r
- //\r
- // Skip DxeCore Driver\r
- //\r
- goto WritePeMap;\r
- }\r
- //\r
- // make sure image base address at the Section and Page alignment\r
- //\r
- FvInfo->BootBaseAddress = (FvInfo->BootBaseAddress - ImageContext.ImageSize) & (~(ImageContext.SectionAlignment - 1));\r
- FvInfo->BootBaseAddress = FvInfo->BootBaseAddress & (~(EFI_PAGE_SIZE - 1));\r
- NewPe32BaseAddress = FvInfo->BootBaseAddress;\r
- BaseToUpdate = &(FvInfo->BootBaseAddress);\r
- break;\r
-\r
default:\r
//\r
// Not supported file type\r
if (PdbPointer == NULL) {\r
PdbPointer = FileName;\r
}\r
- WriteMapFile (FvMapFile, PdbPointer, (EFI_GUID *) FfsFile, NewPe32BaseAddress, PeHdr->OptionalHeader.AddressOfEntryPoint, 0);\r
+\r
+ WriteMapFile (FvMapFile, PdbPointer, (EFI_GUID *) FfsFile, NewPe32BaseAddress, &OrigImageContext);\r
}\r
\r
if (FfsFile->Type != EFI_FV_FILETYPE_SECURITY_CORE &&\r
ImageContext.ImageRead = (PE_COFF_LOADER_READ_FILE) FfsRebaseImageRead;\r
Status = PeCoffLoaderGetImageInfo (&ImageContext);\r
if (EFI_ERROR (Status)) {\r
- Error (NULL, 0, 3000, "Invalid", "GetImageInfo() call failed on rebase of TE image %s", FileName);\r
+ Error (NULL, 0, 3000, "Invalid TeImage", "The input file is %s and the return status is %x", FileName, Status);\r
return Status;\r
}\r
+ //\r
+ // Keep Image Context for TE image in FV\r
+ //\r
+ memcpy (&OrigImageContext, &ImageContext, sizeof (ImageContext));\r
\r
//\r
// Get File PdbPointer\r
ImageContext.Handle = PeFileBuffer;\r
Status = PeCoffLoaderGetImageInfo (&ImageContext);\r
if (EFI_ERROR (Status)) {\r
- Error (NULL, 0, 3000, "Invalid", "GetImageInfo() call failed on rebase of TE image %s", FileName);\r
+ Error (NULL, 0, 3000, "Invalid TeImage", "The input file is %s and the return status is %x", FileName, Status);\r
return Status;\r
}\r
ImageContext.RelocationsStripped = FALSE;\r
if (PdbPointer == NULL) {\r
PdbPointer = FileName;\r
}\r
+\r
WriteMapFile (\r
FvMapFile, \r
PdbPointer, \r
(EFI_GUID *) FfsFile,\r
NewPe32BaseAddress, \r
- TEImageHeader->AddressOfEntryPoint, \r
- TEImageHeader->StrippedSize - sizeof (EFI_TE_IMAGE_HEADER)\r
+ &OrigImageContext\r
);\r
}\r
\r
return EFI_NOT_FOUND;\r
}\r
\r
-EFI_STATUS\r
-WriteMapFile (\r
- IN OUT FILE *FvMapFile,\r
- IN CHAR8 *FileName,\r
- IN EFI_GUID *FileGuidPtr, \r
- IN EFI_PHYSICAL_ADDRESS ImageBaseAddress,\r
- IN UINT32 AddressOfEntryPoint,\r
- IN UINT32 Offset\r
- )\r
-/*++\r
-\r
-Routine Description:\r
-\r
- This function abstracts Pe Map file information and add them into FvMap file for Debug.\r
-\r
-Arguments:\r
-\r
- FvMapFile A pointer to FvMap File\r
- FileName Ffs File PathName\r
- ImageBaseAddress PeImage Base Address.\r
- AddressOfEntryPoint EntryPoint address relative to PeBase Address\r
- Offset Offset between TeImage address and original PeImage.\r
-\r
-Returns:\r
-\r
- EFI_SUCCESS Added required map information.\r
-\r
---*/\r
-{\r
- CHAR8 PeMapFileName [_MAX_PATH];\r
- CHAR8 *Cptr;\r
- CHAR8 FileGuidName [MAX_LINE_LEN];\r
- FILE *PeMapFile;\r
- CHAR8 Line [MAX_LINE_LEN];\r
- CHAR8 KeyWord [MAX_LINE_LEN];\r
- CHAR8 FunctionName [MAX_LINE_LEN];\r
- EFI_PHYSICAL_ADDRESS FunctionAddress;\r
- UINT32 FunctionType;\r
- CHAR8 FunctionTypeName [MAX_LINE_LEN];\r
- \r
- //\r
- // Init local variable\r
- //\r
- FunctionType = 0;\r
- //\r
- // Print FileGuid to string buffer. \r
- //\r
- PrintGuidToBuffer (FileGuidPtr, FileGuidName, MAX_LINE_LEN, TRUE);\r
- \r
- //\r
- // Construct Map file Name \r
- //\r
- strcpy (PeMapFileName, FileName);\r
- \r
- //\r
- // Change '\\' to '/', unified path format.\r
- //\r
- Cptr = PeMapFileName;\r
- while (*Cptr != '\0') {\r
- if (*Cptr == '\\') {\r
- *Cptr = FILE_SEP_CHAR;\r
- }\r
- Cptr ++;\r
- }\r
- \r
- //\r
- // Get Map file\r
- // \r
- Cptr = PeMapFileName + strlen (PeMapFileName);\r
- while (*Cptr != '.') {\r
- Cptr --;\r
- }\r
- if (*Cptr != '.') {\r
- return EFI_NOT_FOUND;\r
- } else {\r
- *(Cptr + 1) = 'm';\r
- *(Cptr + 2) = 'a';\r
- *(Cptr + 3) = 'p';\r
- *(Cptr + 4) = '\0';\r
- }\r
- //\r
- // Open PeMapFile\r
- //\r
- PeMapFile = fopen (PeMapFileName, "r");\r
- if (PeMapFile == NULL) {\r
- // fprintf (stdout, "can't open %s file to reading\n", PeMapFileName);\r
- return EFI_ABORTED;\r
- }\r
- VerboseMsg ("The map file is %s", PeMapFileName);\r
- \r
- //\r
- // Output Functions information into Fv Map file\r
- //\r
- fgets (Line, MAX_LINE_LEN, PeMapFile);\r
- sscanf (Line, "%s", KeyWord);\r
- //\r
- // module information output\r
- //\r
- if (ImageBaseAddress == 0) {\r
- fprintf (FvMapFile, "%s (dummy) (", KeyWord);\r
- fprintf (FvMapFile, "BaseAddress=%08lx, ", ImageBaseAddress);\r
- } else {\r
- fprintf (FvMapFile, "%s (", KeyWord);\r
- fprintf (FvMapFile, "BaseAddress=%08lx, ", ImageBaseAddress + Offset);\r
- }\r
- fprintf (FvMapFile, "EntryPoint=%08lx, ", ImageBaseAddress + AddressOfEntryPoint);\r
- fprintf (FvMapFile, "GUID=%s", FileGuidName);\r
- fprintf (FvMapFile, ")\n\n");\r
-\r
- while (fgets (Line, MAX_LINE_LEN, PeMapFile) != NULL) {\r
- //\r
- // Skip blank line\r
- //\r
- if (Line[0] == 0x0a) {\r
- FunctionType = 0;\r
- continue;\r
- }\r
- //\r
- // By Address and Static keyword\r
- // \r
- if (FunctionType == 0) {\r
- sscanf (Line, "%s", KeyWord);\r
- if (stricmp (KeyWord, "Address") == 0) {\r
- //\r
- // function list\r
- //\r
- FunctionType = 1;\r
- fgets (Line, MAX_LINE_LEN, PeMapFile);\r
- } else if (stricmp (KeyWord, "Static") == 0) {\r
- //\r
- // static function list\r
- //\r
- FunctionType = 2;\r
- fgets (Line, MAX_LINE_LEN, PeMapFile);\r
- }\r
- continue;\r
- }\r
- //\r
- // Printf Function Information\r
- //\r
- if (FunctionType == 1) {\r
- sscanf (Line, "%s %s %lx %s", KeyWord, FunctionName, &FunctionAddress, FunctionTypeName);\r
- if (FunctionTypeName [1] == '\0' && (FunctionTypeName [0] == 'f' || FunctionTypeName [0] == 'F')) {\r
- fprintf (FvMapFile, " %016lx ", ImageBaseAddress + FunctionAddress);\r
- fprintf (FvMapFile, "(%08lx) F ", FunctionAddress - Offset);\r
- fprintf (FvMapFile, "%s\n", FunctionName);\r
- } else {\r
- fprintf (FvMapFile, " %016lx ", ImageBaseAddress + FunctionAddress);\r
- fprintf (FvMapFile, "(%08lx) ", FunctionAddress - Offset);\r
- fprintf (FvMapFile, "%s\n", FunctionName);\r
- }\r
- } else if (FunctionType == 2) {\r
- sscanf (Line, "%s %s %lx %s", KeyWord, FunctionName, &FunctionAddress, FunctionTypeName);\r
- if (FunctionTypeName [1] == '\0' && (FunctionTypeName [0] == 'f' || FunctionTypeName [0] == 'F')) {\r
- fprintf (FvMapFile, " %016lx ", ImageBaseAddress + FunctionAddress);\r
- fprintf (FvMapFile, "(%08lx) FS ", FunctionAddress - Offset);\r
- fprintf (FvMapFile, "%s\n", FunctionName);\r
- } else {\r
- fprintf (FvMapFile, " %016lx ", ImageBaseAddress + FunctionAddress);\r
- fprintf (FvMapFile, "(%08lx) ", FunctionAddress - Offset);\r
- fprintf (FvMapFile, "%s\n", FunctionName);\r
- }\r
- }\r
- }\r
- //\r
- // Close PeMap file\r
- //\r
- fprintf (FvMapFile, "\n\n");\r
- fclose (PeMapFile);\r
- \r
- return EFI_SUCCESS;\r
-}\r
-\r
EFI_STATUS\r
ParseCapInf (\r
IN MEMORY_FILE *InfFile,\r
//\r
// Parse the Cap inf file for header information\r
//\r
- Status = ParseCapInf (&InfMemoryFile, &gCapDataInfo);\r
+ Status = ParseCapInf (&InfMemoryFile, &mCapDataInfo);\r
if (Status != EFI_SUCCESS) {\r
return Status;\r
}\r
}\r
\r
- if (gCapDataInfo.HeaderSize == 0) {\r
+ if (mCapDataInfo.HeaderSize == 0) {\r
//\r
// make header size align 16 bytes.\r
//\r
- gCapDataInfo.HeaderSize = sizeof (EFI_CAPSULE_HEADER);\r
- gCapDataInfo.HeaderSize = (gCapDataInfo.HeaderSize + 0xF) & ~0xF;\r
+ mCapDataInfo.HeaderSize = sizeof (EFI_CAPSULE_HEADER);\r
+ mCapDataInfo.HeaderSize = (mCapDataInfo.HeaderSize + 0xF) & ~0xF;\r
}\r
\r
- if (gCapDataInfo.HeaderSize < sizeof (EFI_CAPSULE_HEADER)) {\r
+ if (mCapDataInfo.HeaderSize < sizeof (EFI_CAPSULE_HEADER)) {\r
Error (NULL, 0, 2000, "Invalid parameter", "The specified HeaderSize cannot be less than the size of EFI_CAPSULE_HEADER.");\r
return EFI_INVALID_PARAMETER;\r
}\r
\r
- if (CapFileName == NULL && gCapDataInfo.CapName[0] != '\0') {\r
- CapFileName = gCapDataInfo.CapName;\r
+ if (CapFileName == NULL && mCapDataInfo.CapName[0] != '\0') {\r
+ CapFileName = mCapDataInfo.CapName;\r
}\r
\r
if (CapFileName == NULL) {\r
//\r
// Set Default Capsule Guid value\r
//\r
- if (CompareGuid (&gCapDataInfo.CapGuid, &mZeroGuid) == 0) {\r
- memcpy (&gCapDataInfo.CapGuid, &mDefaultCapsuleGuid, sizeof (EFI_GUID));\r
+ if (CompareGuid (&mCapDataInfo.CapGuid, &mZeroGuid) == 0) {\r
+ memcpy (&mCapDataInfo.CapGuid, &mDefaultCapsuleGuid, sizeof (EFI_GUID));\r
}\r
//\r
// Calculate the size of capsule image.\r
//\r
Index = 0;\r
FileSize = 0;\r
- CapSize = gCapDataInfo.HeaderSize;\r
- while (gCapDataInfo.CapFiles [Index][0] != '\0') {\r
- fpin = fopen (gCapDataInfo.CapFiles[Index], "rb");\r
+ CapSize = mCapDataInfo.HeaderSize;\r
+ while (mCapDataInfo.CapFiles [Index][0] != '\0') {\r
+ fpin = fopen (mCapDataInfo.CapFiles[Index], "rb");\r
if (fpin == NULL) {\r
- Error (NULL, 0, 0001, "Error opening file", gCapDataInfo.CapFiles[Index]);\r
+ Error (NULL, 0, 0001, "Error opening file", mCapDataInfo.CapFiles[Index]);\r
return EFI_ABORTED;\r
}\r
FileSize = _filelength (fileno (fpin));\r
//\r
// Initialize the capsule header to zero\r
//\r
- memset (CapBuffer, 0, gCapDataInfo.HeaderSize);\r
+ memset (CapBuffer, 0, mCapDataInfo.HeaderSize);\r
\r
//\r
// create capsule header and get capsule body\r
//\r
CapsuleHeader = (EFI_CAPSULE_HEADER *) CapBuffer;\r
- memcpy (&CapsuleHeader->CapsuleGuid, &gCapDataInfo.CapGuid, sizeof (EFI_GUID));\r
- CapsuleHeader->HeaderSize = gCapDataInfo.HeaderSize;\r
- CapsuleHeader->Flags = gCapDataInfo.Flags;\r
+ memcpy (&CapsuleHeader->CapsuleGuid, &mCapDataInfo.CapGuid, sizeof (EFI_GUID));\r
+ CapsuleHeader->HeaderSize = mCapDataInfo.HeaderSize;\r
+ CapsuleHeader->Flags = mCapDataInfo.Flags;\r
CapsuleHeader->CapsuleImageSize = CapSize;\r
\r
Index = 0;\r
FileSize = 0;\r
CapSize = CapsuleHeader->HeaderSize;\r
- while (gCapDataInfo.CapFiles [Index][0] != '\0') {\r
- fpin = fopen (gCapDataInfo.CapFiles[Index], "rb");\r
+ while (mCapDataInfo.CapFiles [Index][0] != '\0') {\r
+ fpin = fopen (mCapDataInfo.CapFiles[Index], "rb");\r
if (fpin == NULL) {\r
- Error (NULL, 0, 0001, "Error opening file", gCapDataInfo.CapFiles[Index]);\r
+ Error (NULL, 0, 0001, "Error opening file", mCapDataInfo.CapFiles[Index]);\r
free (CapBuffer);\r
return EFI_ABORTED;\r
}\r