summaryrefslogtreecommitdiff
path: root/BaseTools/Source/C
diff options
context:
space:
mode:
authorlgao4 <lgao4@6f19259b-4bc3-4df7-8a09-765794883524>2009-11-09 11:47:35 +0000
committerlgao4 <lgao4@6f19259b-4bc3-4df7-8a09-765794883524>2009-11-09 11:47:35 +0000
commitb303ea726e1c8ed240dad2bce54821318567eab3 (patch)
tree355db6226949afd1bfcc87d69e09a320ea9b7bb7 /BaseTools/Source/C
parent4c913fe619bd00861270cb0866feb34bcdc1592e (diff)
downloadedk2-platforms-b303ea726e1c8ed240dad2bce54821318567eab3.tar.xz
Sync tool code to BuildTools project r1739.
git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@9397 6f19259b-4bc3-4df7-8a09-765794883524
Diffstat (limited to 'BaseTools/Source/C')
-rw-r--r--BaseTools/Source/C/Common/FirmwareVolumeBuffer.c4
-rw-r--r--BaseTools/Source/C/Common/FvLib.c6
-rw-r--r--BaseTools/Source/C/GenFfs/GenFfs.c2
-rw-r--r--BaseTools/Source/C/GenFv/GenFvInternalLib.c204
-rw-r--r--BaseTools/Source/C/GenFv/GenFvInternalLib.h14
-rw-r--r--BaseTools/Source/C/GenFw/GenFw.c522
-rw-r--r--BaseTools/Source/C/GenVtf/GenVtf.c22
-rw-r--r--BaseTools/Source/C/GenVtf/GenVtf.h4
-rw-r--r--BaseTools/Source/C/Include/Common/PiFirmwareFile.h3
-rw-r--r--BaseTools/Source/C/Include/Common/UefiInternalFormRepresentation.h10
-rw-r--r--BaseTools/Source/C/Include/IndustryStandard/PeImage.h53
-rw-r--r--BaseTools/Source/C/VfrCompile/VfrCompiler.cpp28
-rw-r--r--BaseTools/Source/C/VfrCompile/VfrFormPkg.cpp4
-rw-r--r--BaseTools/Source/C/VfrCompile/VfrFormPkg.h8
-rw-r--r--BaseTools/Source/C/VfrCompile/VfrSyntax.g34
-rw-r--r--BaseTools/Source/C/VolInfo/VolInfo.c83
16 files changed, 720 insertions, 281 deletions
diff --git a/BaseTools/Source/C/Common/FirmwareVolumeBuffer.c b/BaseTools/Source/C/Common/FirmwareVolumeBuffer.c
index d51e359043..2d3b1353cb 100644
--- a/BaseTools/Source/C/Common/FirmwareVolumeBuffer.c
+++ b/BaseTools/Source/C/Common/FirmwareVolumeBuffer.c
@@ -236,8 +236,8 @@ Returns:
if (File->Attributes & FFS_ATTRIB_CHECKSUM) {
File->IntegrityCheck.Checksum.File = FvBufCalculateChecksum8 (
- (VOID*)File,
- FileSize
+ (VOID*)(File + 1),
+ FileSize - sizeof (EFI_FFS_FILE_HEADER)
);
} else {
File->IntegrityCheck.Checksum.File = FFS_FIXED_CHECKSUM;
diff --git a/BaseTools/Source/C/Common/FvLib.c b/BaseTools/Source/C/Common/FvLib.c
index 292b077f34..dc50e877e6 100644
--- a/BaseTools/Source/C/Common/FvLib.c
+++ b/BaseTools/Source/C/Common/FvLib.c
@@ -703,8 +703,8 @@ Returns:
// Verify file data checksum
//
FileLength = GetLength (FfsHeader->Size);
- Checksum = CalculateSum8 ((UINT8 *) FfsHeader, FileLength);
- Checksum = (UINT8) (Checksum - FfsHeader->State);
+ Checksum = CalculateSum8 ((UINT8 *) (FfsHeader + 1), FileLength - sizeof (EFI_FFS_FILE_HEADER));
+ Checksum = Checksum + FfsHeader->IntegrityCheck.Checksum.File;
if (Checksum != 0) {
Error (NULL, 0, 0006, "invalid FFS file checksum", "Ffs file with Guid %s", FileGuidString);
return EFI_ABORTED;
@@ -712,7 +712,7 @@ Returns:
} else {
//
// File does not have a checksum
- // Verify contents are 0x5A as spec'd
+ // Verify contents are 0xAA as spec'd
//
if (FfsHeader->IntegrityCheck.Checksum.File != FFS_FIXED_CHECKSUM) {
Error (NULL, 0, 0006, "invalid fixed FFS file header checksum", "Ffs file with Guid %s", FileGuidString);
diff --git a/BaseTools/Source/C/GenFfs/GenFfs.c b/BaseTools/Source/C/GenFfs/GenFfs.c
index 12a3b2f18c..324490a707 100644
--- a/BaseTools/Source/C/GenFfs/GenFfs.c
+++ b/BaseTools/Source/C/GenFfs/GenFfs.c
@@ -134,6 +134,8 @@ Returns:
EFI_FV_FILETYPE_PEI_CORE, EFI_FV_FILETYPE_DXE_CORE,\n\
EFI_FV_FILETYPE_DRIVER, EFI_FV_FILETYPE_APPLICATION,\n\
EFI_FV_FILETYPE_COMBINED_PEIM_DRIVER,\n\
+ EFI_FV_FILETYPE_SMM, EFI_FV_FILETYPE_SMM_CORE,\n\
+ EFI_FV_FILETYPE_COMBINED_SMM_DXE, \n\
EFI_FV_FILETYPE_FIRMWARE_VOLUME_IMAGE.\n");
fprintf (stdout, " -g FileGuid, --fileguid FileGuid\n\
FileGuid is one module guid.\n\
diff --git a/BaseTools/Source/C/GenFv/GenFvInternalLib.c b/BaseTools/Source/C/GenFv/GenFvInternalLib.c
index 917baa11e8..6b5d6bda2a 100644
--- a/BaseTools/Source/C/GenFv/GenFvInternalLib.c
+++ b/BaseTools/Source/C/GenFv/GenFvInternalLib.c
@@ -229,22 +229,11 @@ Returns:
}
//
- // Read the FV Name Guid
+ // Read the FV Extension Header File Name
//
- if (!FvInfo->FvNameGuidSet) {
- Status = FindToken (InfFile, ATTRIBUTES_SECTION_STRING, EFI_FV_NAMEGUID_STRING, 0, Value);
- if (Status == EFI_SUCCESS) {
- //
- // Get the guid value
- //
- Status = StringToGuid (Value, &GuidValue);
- if (EFI_ERROR (Status)) {
- Error (NULL, 0, 2000, "Invalid parameter", "%s = %s", EFI_FV_NAMEGUID_STRING, Value);
- return EFI_ABORTED;
- }
- memcpy (&FvInfo->FvNameGuid, &GuidValue, sizeof (EFI_GUID));
- FvInfo->FvNameGuidSet = TRUE;
- }
+ Status = FindToken (InfFile, ATTRIBUTES_SECTION_STRING, EFI_FV_EXT_HEADER_FILE_NAME, 0, Value);
+ if (Status == EFI_SUCCESS) {
+ strcpy (FvInfo->FvExtHeaderFile, Value);
}
//
@@ -1272,6 +1261,7 @@ Returns:
EFI_FFS_FILE_STATE SavedState;
UINT64 FitAddress;
FIT_TABLE *FitTablePtr;
+ BOOLEAN Vtf0Detected;
//
// Verify input parameters
@@ -1292,11 +1282,32 @@ Returns:
return EFI_INVALID_PARAMETER;
}
+ if (
+ (((UINTN)FvImage->Eof - (UINTN)FvImage->FileImage) >=
+ IA32_X64_VTF_SIGNATURE_OFFSET) &&
+ (*(UINT32 *)(VOID*)((UINTN) FvImage->Eof -
+ IA32_X64_VTF_SIGNATURE_OFFSET) ==
+ IA32_X64_VTF0_SIGNATURE)
+ ) {
+ Vtf0Detected = TRUE;
+ } else {
+ Vtf0Detected = FALSE;
+ }
+
//
// Find the Sec Core
//
Status = GetFileByType (EFI_FV_FILETYPE_SECURITY_CORE, 1, &SecCoreFile);
if (EFI_ERROR (Status) || SecCoreFile == NULL) {
+ if (Vtf0Detected) {
+ //
+ // If the SEC core file is not found, but the VTF-0 signature
+ // is found, we'll treat it as a VTF-0 'Volume Top File'.
+ // This means no modifications are required to the VTF.
+ //
+ return EFI_SUCCESS;
+ }
+
Error (NULL, 0, 3000, "Invalid", "could not find the SEC core file in the FV.");
return EFI_ABORTED;
}
@@ -1325,6 +1336,19 @@ Returns:
return EFI_ABORTED;
}
+ if (
+ Vtf0Detected &&
+ (MachineType == EFI_IMAGE_MACHINE_IA32 ||
+ MachineType == EFI_IMAGE_MACHINE_X64)
+ ) {
+ //
+ // If the SEC core code is IA32 or X64 and the VTF-0 signature
+ // is found, we'll treat it as a VTF-0 'Volume Top File'.
+ // This means no modifications are required to the VTF.
+ //
+ return EFI_SUCCESS;
+ }
+
//
// Physical address is FV base + offset of PE32 + offset of the entry point
//
@@ -1428,16 +1452,6 @@ Returns:
SecCoreEntryAddressPtr = (EFI_PHYSICAL_ADDRESS *) ((UINTN) FvImage->Eof - IPF_SALE_ENTRY_ADDRESS_OFFSET);
*SecCoreEntryAddressPtr = SecCorePhysicalAddress;
- } else if (
- (MachineType == EFI_IMAGE_MACHINE_IA32 ||
- MachineType == EFI_IMAGE_MACHINE_X64) &&
- (((UINTN)FvImage->Eof - (UINTN)FvImage->FileImage) >= IA32_X64_VTF_SIGNATURE_OFFSET) &&
- (*(UINT32 *)(VOID*)((UINTN) FvImage->Eof - IA32_X64_VTF_SIGNATURE_OFFSET) ==
- IA32_X64_VTF0_SIGNATURE)
- ) {
- //
- // If VTF-0 signature is found, then no modifications are needed.
- //
} else if (MachineType == EFI_IMAGE_MACHINE_IA32 || MachineType == EFI_IMAGE_MACHINE_X64) {
//
// Get the location to update
@@ -1545,8 +1559,8 @@ Returns:
VtfFile->State = 0;
if (VtfFile->Attributes & FFS_ATTRIB_CHECKSUM) {
VtfFile->IntegrityCheck.Checksum.File = CalculateChecksum8 (
- (UINT8 *) VtfFile,
- GetLength (VtfFile->Size)
+ (UINT8 *) (VtfFile + 1),
+ GetLength (VtfFile->Size) - sizeof (EFI_FFS_FILE_HEADER)
);
} else {
VtfFile->IntegrityCheck.Checksum.File = FFS_FIXED_CHECKSUM;
@@ -1938,19 +1952,21 @@ Returns:
--*/
{
- EFI_STATUS Status;
- MEMORY_FILE InfMemoryFile;
- MEMORY_FILE FvImageMemoryFile;
- UINTN Index;
- EFI_FIRMWARE_VOLUME_HEADER *FvHeader;
- EFI_FFS_FILE_HEADER *VtfFileImage;
- UINT8 *FvBufferHeader; // to make sure fvimage header 8 type alignment.
- UINT8 *FvImage;
- UINTN FvImageSize;
- FILE *FvFile;
- CHAR8 FvMapName [_MAX_PATH];
- FILE *FvMapFile;
- EFI_FIRMWARE_VOLUME_EXT_HEADER FvExtHeader;
+ EFI_STATUS Status;
+ MEMORY_FILE InfMemoryFile;
+ MEMORY_FILE FvImageMemoryFile;
+ UINTN Index;
+ EFI_FIRMWARE_VOLUME_HEADER *FvHeader;
+ EFI_FFS_FILE_HEADER *VtfFileImage;
+ UINT8 *FvBufferHeader; // to make sure fvimage header 8 type alignment.
+ UINT8 *FvImage;
+ UINTN FvImageSize;
+ FILE *FvFile;
+ CHAR8 FvMapName [_MAX_PATH];
+ FILE *FvMapFile;
+ EFI_FIRMWARE_VOLUME_EXT_HEADER *FvExtHeader;
+ FILE *FvExtHeaderFile;
+ UINTN FileSize;
FvBufferHeader = NULL;
FvFile = NULL;
@@ -2008,6 +2024,58 @@ Returns:
mFvDataInfo.FvFileSystemGuid.Data4[6],
mFvDataInfo.FvFileSystemGuid.Data4[7]);
}
+
+ //
+ // Add PI FV extension header
+ //
+ FvExtHeader = NULL;
+ FvExtHeaderFile = NULL;
+ if (mFvDataInfo.FvExtHeaderFile[0] != 0) {
+ //
+ // Open the FV Extension Header file
+ //
+ FvExtHeaderFile = fopen (mFvDataInfo.FvExtHeaderFile, "rb");
+
+ //
+ // Get the file size
+ //
+ FileSize = _filelength (fileno (FvExtHeaderFile));
+
+ //
+ // Allocate a buffer for the FV Extension Header
+ //
+ FvExtHeader = malloc(FileSize);
+ if (FvExtHeader == NULL) {
+ fclose (FvExtHeaderFile);
+ return EFI_OUT_OF_RESOURCES;
+ }
+
+ //
+ // Read the FV Extension Header
+ //
+ fread (FvExtHeader, sizeof (UINT8), FileSize, FvExtHeaderFile);
+ fclose (FvExtHeaderFile);
+
+ //
+ // See if there is an override for the FV Name GUID
+ //
+ if (mFvDataInfo.FvNameGuidSet) {
+ memcpy (&FvExtHeader->FvName, &mFvDataInfo.FvNameGuid, sizeof (EFI_GUID));
+ }
+ memcpy (&mFvDataInfo.FvNameGuid, &FvExtHeader->FvName, sizeof (EFI_GUID));
+ mFvDataInfo.FvNameGuidSet = TRUE;
+ } else if (mFvDataInfo.FvNameGuidSet) {
+ //
+ // Allocate a buffer for the FV Extension Header
+ //
+ FvExtHeader = malloc(sizeof (EFI_FIRMWARE_VOLUME_EXT_HEADER));
+ if (FvExtHeader == NULL) {
+ return EFI_OUT_OF_RESOURCES;
+ }
+ memcpy (&FvExtHeader->FvName, &mFvDataInfo.FvNameGuid, sizeof (EFI_GUID));
+ FvExtHeader->ExtHeaderSize = sizeof (EFI_FIRMWARE_VOLUME_EXT_HEADER);
+ }
+
//
// Debug message Fv Name Guid
//
@@ -2173,12 +2241,14 @@ Returns:
}
//
- // Set PI FV extension header
+ // Add PI FV extension header
//
- if (mFvDataInfo.FvNameGuidSet) {
- memcpy (&FvExtHeader.FvName, &mFvDataInfo.FvNameGuid, sizeof (EFI_GUID));
- FvExtHeader.ExtHeaderSize = sizeof (EFI_FIRMWARE_VOLUME_EXT_HEADER);
- AddPadFile (&FvImageMemoryFile, 4, VtfFileImage, &FvExtHeader);
+ if (FvExtHeader != NULL) {
+ //
+ // Add FV Extended Header contents to the FV as a PAD file
+ //
+ AddPadFile (&FvImageMemoryFile, 4, VtfFileImage, FvExtHeader);
+
//
// Fv Extension header change update Fv Header Check sum
//
@@ -2282,6 +2352,10 @@ Finish:
if (FvBufferHeader != NULL) {
free (FvBufferHeader);
}
+
+ if (FvExtHeader != NULL) {
+ free (FvExtHeader);
+ }
if (FvFile != NULL) {
fclose (FvFile);
@@ -2385,11 +2459,13 @@ Returns:
UINTN Index;
FILE *fpin;
UINTN FfsFileSize;
+ UINTN FvExtendHeaderSize;
UINT32 FfsAlignment;
EFI_FFS_FILE_HEADER FfsHeader;
BOOLEAN VtfFileFlag;
UINTN VtfFileSize;
+ FvExtendHeaderSize = 0;
VtfFileSize = 0;
VtfFileFlag = FALSE;
fpin = NULL;
@@ -2418,7 +2494,17 @@ Returns:
//
// Calculate PI extension header
//
- if (CompareGuid (&mFvDataInfo.FvNameGuid, &mZeroGuid) != 0) {
+ if (mFvDataInfo.FvExtHeaderFile[0] != '\0') {
+ fpin = fopen (mFvDataInfo.FvExtHeaderFile, "rb");
+ if (fpin == NULL) {
+ Error (NULL, 0, 0001, "Error opening file", mFvDataInfo.FvExtHeaderFile);
+ return EFI_ABORTED;
+ }
+ FvExtendHeaderSize = _filelength (fileno (fpin));
+ fclose (fpin);
+ CurrentOffset += sizeof (EFI_FFS_FILE_HEADER) + FvExtendHeaderSize;
+ CurrentOffset = (CurrentOffset + 7) & (~7);
+ } else if (mFvDataInfo.FvNameGuidSet) {
CurrentOffset += sizeof (EFI_FFS_FILE_HEADER) + sizeof (EFI_FIRMWARE_VOLUME_EXT_HEADER);
CurrentOffset = (CurrentOffset + 7) & (~7);
}
@@ -2959,15 +3045,10 @@ Returns:
SavedState = FfsFile->State;
FfsFile->IntegrityCheck.Checksum.File = 0;
FfsFile->State = 0;
- if (FfsFile->Attributes & FFS_ATTRIB_CHECKSUM) {
- FfsFile->IntegrityCheck.Checksum.File = CalculateChecksum8 (
- (UINT8 *) FfsFile,
- GetLength (FfsFile->Size)
- );
- } else {
- FfsFile->IntegrityCheck.Checksum.File = FFS_FIXED_CHECKSUM;
- }
-
+ FfsFile->IntegrityCheck.Checksum.File = CalculateChecksum8 (
+ (UINT8 *) (FfsFile + 1),
+ GetLength (FfsFile->Size) - sizeof (EFI_FFS_FILE_HEADER)
+ );
FfsFile->State = SavedState;
}
@@ -3189,15 +3270,10 @@ WritePeMap:
SavedState = FfsFile->State;
FfsFile->IntegrityCheck.Checksum.File = 0;
FfsFile->State = 0;
- if (FfsFile->Attributes & FFS_ATTRIB_CHECKSUM) {
- FfsFile->IntegrityCheck.Checksum.File = CalculateChecksum8 (
- (UINT8 *) FfsFile,
- GetLength (FfsFile->Size)
- );
- } else {
- FfsFile->IntegrityCheck.Checksum.File = FFS_FIXED_CHECKSUM;
- }
-
+ FfsFile->IntegrityCheck.Checksum.File = CalculateChecksum8 (
+ (UINT8 *)(FfsFile + 1),
+ GetLength (FfsFile->Size) - sizeof (EFI_FFS_FILE_HEADER)
+ );
FfsFile->State = SavedState;
}
//
diff --git a/BaseTools/Source/C/GenFv/GenFvInternalLib.h b/BaseTools/Source/C/GenFv/GenFvInternalLib.h
index d6b3ad7fc1..3c0e9336bd 100644
--- a/BaseTools/Source/C/GenFv/GenFvInternalLib.h
+++ b/BaseTools/Source/C/GenFv/GenFvInternalLib.h
@@ -61,13 +61,12 @@ Abstract:
#define MAX_NUMBER_OF_FILES_IN_FV 1000
#define MAX_NUMBER_OF_FILES_IN_CAP 1000
#define EFI_FFS_FILE_HEADER_ALIGNMENT 8
-
//
// INF file strings
//
-#define OPTIONS_SECTION_STRING "[options]"
-#define ATTRIBUTES_SECTION_STRING "[attributes]"
-#define FILES_SECTION_STRING "[files]"
+#define OPTIONS_SECTION_STRING "[options]"
+#define ATTRIBUTES_SECTION_STRING "[attributes]"
+#define FILES_SECTION_STRING "[files]"
//
// Options section
@@ -158,6 +157,12 @@ Abstract:
#define NULL_STRING "NULL"
//
+//
+//
+#define EFI_FV_EXT_HEADER_FILE_NAME "EFI_FV_EXT_HEADER_FILE_NAME"
+
+
+//
// VTF (Firmware Volume Top File) signatures
//
#define IA32_X64_VTF_SIGNATURE_OFFSET 0x14
@@ -229,6 +234,7 @@ typedef struct {
BOOLEAN FvFileSystemGuidSet;
EFI_GUID FvNameGuid;
BOOLEAN FvNameGuidSet;
+ CHAR8 FvExtHeaderFile[_MAX_PATH];
UINTN Size;
EFI_FVB_ATTRIBUTES FvAttributes;
CHAR8 FvName[_MAX_PATH];
diff --git a/BaseTools/Source/C/GenFw/GenFw.c b/BaseTools/Source/C/GenFw/GenFw.c
index 8c648eb407..e72f052869 100644
--- a/BaseTools/Source/C/GenFw/GenFw.c
+++ b/BaseTools/Source/C/GenFw/GenFw.c
@@ -33,6 +33,7 @@ Abstract:
#include <Common/UefiBaseTypes.h>
#include <IndustryStandard/PeImage.h>
+#include <Common/UefiInternalFormRepresentation.h>
//
// Acpi Table definition
@@ -60,6 +61,8 @@ Abstract:
#define UTILITY_MAJOR_VERSION 0
#define UTILITY_MINOR_VERSION 2
+#define HII_RESOURCE_SECTION_INDEX 1
+#define HII_RESOURCE_SECTION_NAME "HII"
//
// Action for this tool.
//
@@ -73,6 +76,7 @@ Abstract:
#define FW_MCI_IMAGE 7
#define FW_MERGE_IMAGE 8
#define FW_RELOC_STRIPEED_IMAGE 9
+#define FW_HII_PACKAGE_LIST_RCIMAGE 10
#define DUMP_TE_HEADER 0x11
@@ -100,6 +104,15 @@ typedef struct {
UINT32 Reserved[3];
} MICROCODE_IMAGE_HEADER;
+static EFI_GUID mZeroGuid = {0x0, 0x0, 0x0, {0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0}};
+
+static const char *gHiiPackageRCFileHeader[] = {
+ "//",
+ "// DO NOT EDIT -- auto-generated file",
+ "//",
+ NULL
+};
+
STATIC CHAR8 *mInImageName;
STATIC
@@ -258,6 +271,16 @@ Returns:
fprintf (stdout, " -r, --replace Overwrite the input file with the output content.\n\
If more input files are specified,\n\
the last input file will be as the output file.\n");
+ fprintf (stdout, " -g HiiPackageListGuid, --hiiguid HiiPackageListGuid\n\
+ HiiListPackageGuidGuid is from the module guid.\n\
+ Its format is xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx\n\
+ If not specified, the first Form FormSet guid is used.\n");
+ fprintf (stdout, " --hiipackage Combine all input binary hii pacakges into \n\
+ a single package list as the text resource data(RC).\n\
+ It can't be combined with other action options\n\
+ except for -o option. It is a action option.\n\
+ If it is combined with other action options, the later\n\
+ input action option will override the previous one.\n");
fprintf (stdout, " -v, --verbose Turn on verbose output with informational messages.\n");
fprintf (stdout, " -q, --quiet Disable all messages except key message and fatal error\n");
fprintf (stdout, " -d, --debug level Enable debug messages, at input debug level.\n");
@@ -440,7 +463,7 @@ typedef Elf32_Dyn Elf_Dyn;
#define ELFCLASS ELFCLASS32
#define ELF_R_TYPE(r) ELF32_R_TYPE(r)
#define ELF_R_SYM(r) ELF32_R_SYM(r)
-
+#define ELF_HII_SECTION_NAME ".hii"
//
// Well known ELF structures.
//
@@ -452,7 +475,7 @@ Elf_Phdr *gPhdrBase;
// PE section alignment.
//
const UINT32 CoffAlignment = 0x20;
-const UINT16 CoffNbrSections = 4;
+const UINT16 CoffNbrSections = 5;
//
// Current offset in coff file.
@@ -475,8 +498,15 @@ UINT32 NtHdrOffset;
UINT32 TableOffset;
UINT32 TextOffset;
UINT32 DataOffset;
+UINT32 HiiRsrcOffset;
UINT32 RelocOffset;
+//
+// HiiBinData
+//
+UINT8* HiiBinData = NULL;
+UINT32 HiiBinSize = 0;
+
EFI_IMAGE_BASE_RELOCATION *CoffBaseRel;
UINT16 *CoffEntryRel;
@@ -548,10 +578,27 @@ IsTextShdr(
}
int
+IsHiiRsrcShdr(
+ Elf_Shdr *Shdr
+ )
+{
+ Elf_Shdr *Namedr = GetShdrByIndex(Ehdr->e_shstrndx);
+
+ if (strcmp((CHAR8*)Ehdr + Namedr->sh_offset + Shdr->sh_name, ELF_HII_SECTION_NAME) == 0) {
+ return 1;
+ }
+
+ return 0;
+}
+
+int
IsDataShdr(
Elf_Shdr *Shdr
)
{
+ if (IsHiiRsrcShdr(Shdr)) {
+ return 0;
+ }
return (Shdr->sh_flags & (SHF_WRITE | SHF_ALLOC)) == (SHF_ALLOC | SHF_WRITE);
}
@@ -581,6 +628,128 @@ CreateSectionHeader(
}
VOID
+GetBinaryHiiData (
+ CHAR8 *RcString,
+ UINT32 Size,
+ UINT32 OffsetToFile
+ )
+{
+ unsigned Data16;
+ UINT32 HiiBinOffset;
+ UINT32 Index;
+ EFI_IMAGE_RESOURCE_DIRECTORY *ResourceDirectory;
+ EFI_IMAGE_RESOURCE_DIRECTORY_ENTRY *ResourceDirectoryEntry;
+ EFI_IMAGE_RESOURCE_DIRECTORY_STRING *ResourceDirectoryString;
+ EFI_IMAGE_RESOURCE_DATA_ENTRY *ResourceDataEntry;
+
+ Index = 0;
+ while (Index < Size && *RcString != '\0' && *RcString != '{') {
+ RcString ++;
+ Index ++;
+ }
+
+ if (*RcString == '\0' || Index == Size) {
+ return;
+ }
+
+ //
+ // Skip '{' character
+ // Skip space and ',' character
+ //
+ RcString ++;
+ Index ++;
+ while (Index < Size && *RcString != '\0' && (isspace (*RcString) || *RcString == ',')){
+ RcString ++;
+ Index ++;
+ }
+
+ //
+ // '}' end character
+ //
+ if (*RcString == '}' || Index == Size) {
+ return;
+ }
+
+ HiiBinOffset = 0;
+ HiiBinSize = 0x1000;
+ HiiBinData = (UINT8 *) malloc (HiiBinSize);
+ if (HiiBinData == NULL) {
+ return;
+ }
+ memset (HiiBinData, 0, HiiBinSize);
+ //
+ // Fill Resource section entry
+ //
+ ResourceDirectory = (EFI_IMAGE_RESOURCE_DIRECTORY *) (HiiBinData + HiiBinOffset);
+ HiiBinOffset += sizeof (EFI_IMAGE_RESOURCE_DIRECTORY);
+ ResourceDirectory->NumberOfNamedEntries = 1;
+
+ ResourceDirectoryEntry = (EFI_IMAGE_RESOURCE_DIRECTORY_ENTRY *) (HiiBinData + HiiBinOffset);
+ HiiBinOffset += sizeof (EFI_IMAGE_RESOURCE_DIRECTORY_ENTRY);
+ ResourceDirectoryEntry->u1.s.NameIsString = 1;
+ ResourceDirectoryEntry->u1.s.NameOffset = HiiBinOffset;
+
+ ResourceDirectoryString = (EFI_IMAGE_RESOURCE_DIRECTORY_STRING *) (HiiBinData + HiiBinOffset);
+ ResourceDirectoryString->Length = 3;
+ ResourceDirectoryString->String[0] =L'H';
+ ResourceDirectoryString->String[1] =L'I';
+ ResourceDirectoryString->String[2] =L'I';
+ HiiBinOffset = HiiBinOffset + sizeof (ResourceDirectoryString->Length) + ResourceDirectoryString->Length * sizeof (ResourceDirectoryString->String[0]);
+
+ ResourceDirectoryEntry->u2.OffsetToData = HiiBinOffset;
+ ResourceDataEntry = (EFI_IMAGE_RESOURCE_DATA_ENTRY *) (HiiBinData + HiiBinOffset);
+ HiiBinOffset += sizeof (EFI_IMAGE_RESOURCE_DATA_ENTRY);
+ ResourceDataEntry->OffsetToData = OffsetToFile + HiiBinOffset;
+
+ while (sscanf (RcString, "0x%X", &Data16) != EOF) {
+ //
+ // Convert the string data to the binary data.
+ //
+ *(UINT16 *)(HiiBinData + HiiBinOffset) = (UINT16) Data16;
+ HiiBinOffset += 2;
+ //
+ // Jump to the next data.
+ //
+ RcString = RcString + 2 + 4;
+ Index = Index + 2 + 4;
+ //
+ // Skip space and ',' character
+ //
+ while (Index < Size && *RcString != '\0' && (isspace (*RcString) || *RcString == ',')){
+ RcString ++;
+ Index ++;
+ }
+ //
+ // '}' end character
+ //
+ if (*RcString == '}'|| Index == Size) {
+ break;
+ }
+ //
+ // Check BinBuffer size
+ //
+ if (HiiBinOffset >= HiiBinSize) {
+ HiiBinSize += 0x1000;
+ HiiBinData = (UINT8 *) realloc (HiiBinData, HiiBinSize);
+ //
+ // Memory allocation is failure.
+ //
+ if (HiiBinData == NULL) {
+ HiiBinSize = 0;
+ break;
+ }
+ }
+ }
+
+ if (HiiBinData != NULL) {
+ HiiBinSize = HiiBinOffset;
+ ResourceDataEntry->Size = HiiBinSize + OffsetToFile - ResourceDataEntry->OffsetToData;
+ }
+
+ return;
+}
+
+VOID
ScanSections(
VOID
)
@@ -605,11 +774,11 @@ ScanSections(
break;
case EM_X86_64:
case EM_IA_64:
- CoffOffset += sizeof (EFI_IMAGE_NT_HEADERS64);
+ CoffOffset += sizeof (EFI_IMAGE_NT_HEADERS64);
break;
default:
VerboseMsg ("%s unknown e_machine type. Assume IA-32", (UINTN)Ehdr->e_machine);
- CoffOffset += sizeof (EFI_IMAGE_NT_HEADERS32);
+ CoffOffset += sizeof (EFI_IMAGE_NT_HEADERS32);
break;
}
@@ -672,13 +841,41 @@ ScanSections(
Error (NULL, 0, 3000, "Invalid", "Unsupported section alignment.");
}
}
-
CoffSectionsOffset[i] = CoffOffset;
CoffOffset += shdr->sh_size;
}
}
CoffOffset = CoffAlign(CoffOffset);
+ //
+ // The HII resource sections.
+ //
+ HiiRsrcOffset = CoffOffset;
+ for (i = 0; i < Ehdr->e_shnum; i++) {
+ Elf_Shdr *shdr = GetShdrByIndex(i);
+ if (IsHiiRsrcShdr(shdr)) {
+ if ((shdr->sh_addralign != 0) && (shdr->sh_addralign != 1)) {
+ // the alignment field is valid
+ if ((shdr->sh_addr & (shdr->sh_addralign - 1)) == 0) {
+ // if the section address is aligned we must align PE/COFF
+ CoffOffset = (CoffOffset + shdr->sh_addralign - 1) & ~(shdr->sh_addralign - 1);
+ } else if ((shdr->sh_addr % shdr->sh_addralign) != (CoffOffset % shdr->sh_addralign)) {
+ // ARM RVCT tools have behavior outside of the ELF specification to try
+ // and make images smaller. If sh_addr is not aligned to sh_addralign
+ // then the section needs to preserve sh_addr MOD sh_addralign.
+ // Normally doing nothing here works great.
+ Error (NULL, 0, 3000, "Invalid", "Unsupported section alignment.");
+ }
+ }
+ GetBinaryHiiData ((CHAR8*)Ehdr + shdr->sh_offset, shdr->sh_size, HiiRsrcOffset);
+ if (HiiBinSize != 0) {
+ CoffOffset += HiiBinSize;
+ CoffOffset = CoffAlign(CoffOffset);
+ }
+ break;
+ }
+ }
+
RelocOffset = CoffOffset;
//
@@ -760,8 +957,8 @@ ScanSections(
NtHdr->Pe32.FileHeader.NumberOfSections--;
}
- if ((RelocOffset - TextOffset) > 0) {
- CreateSectionHeader (".data", DataOffset, RelocOffset - DataOffset,
+ if ((HiiRsrcOffset - DataOffset) > 0) {
+ CreateSectionHeader (".data", DataOffset, HiiRsrcOffset - DataOffset,
EFI_IMAGE_SCN_CNT_INITIALIZED_DATA
| EFI_IMAGE_SCN_MEM_WRITE
| EFI_IMAGE_SCN_MEM_READ);
@@ -769,6 +966,24 @@ ScanSections(
// Don't make a section of size 0.
NtHdr->Pe32.FileHeader.NumberOfSections--;
}
+
+ if ((RelocOffset - HiiRsrcOffset) > 0) {
+ CreateSectionHeader (".rsrc", HiiRsrcOffset, RelocOffset - HiiRsrcOffset,
+ EFI_IMAGE_SCN_CNT_INITIALIZED_DATA
+ | EFI_IMAGE_SCN_MEM_READ);
+
+ NtHdr->Pe32.OptionalHeader.DataDirectory[EFI_IMAGE_DIRECTORY_ENTRY_RESOURCE].Size = HiiBinSize;
+ NtHdr->Pe32.OptionalHeader.DataDirectory[EFI_IMAGE_DIRECTORY_ENTRY_RESOURCE].VirtualAddress = HiiRsrcOffset;
+
+ memcpy(CoffFile + HiiRsrcOffset, HiiBinData, HiiBinSize);
+ free (HiiBinData);
+ HiiBinData = NULL;
+ HiiBinSize = 0;
+ } else {
+ // Don't make a section of size 0.
+ NtHdr->Pe32.FileHeader.NumberOfSections--;
+ }
+
}
VOID
@@ -1215,141 +1430,6 @@ ConvertElf (
}
}
-void
-ZeroXdataSection (
- IN CHAR8 *ImageName,
- IN OUT UINT8 *FileBuffer,
- IN EFI_IMAGE_SECTION_HEADER *SectionHeader,
- IN UINT32 SectionTotalNumber
- )
-{
- FILE *fpMapFile;
- CHAR8 MapFileName[_MAX_PATH];
- CHAR8 Line [MAX_LINE_LEN];
- CHAR8 KeyWord [MAX_LINE_LEN];
- CHAR8 SectionName [MAX_LINE_LEN];
- UINT32 FunctionType = 0;
- unsigned SectionOffset = 0;
- unsigned SectionLength = 0;
- unsigned SectionNumber = 0;
- CHAR8 *PdbPointer;
- INT32 Index;
- UINT32 Index2;
-
- for (Index2 = 0; Index2 < SectionTotalNumber; Index2++) {
- if (stricmp ((char *)SectionHeader[Index2].Name, ".zdata") == 0) {
- //
- // try to zero the customized .zdata section, which is mapped to .xdata
- //
- memset (FileBuffer + SectionHeader[Index2].PointerToRawData, 0, SectionHeader[Index2].SizeOfRawData);
- DebugMsg (NULL, 0, 9, NULL, "Zero the .xdata section for PE image at Offset 0x%x and Length 0x%x", (unsigned) SectionHeader[Index2].PointerToRawData, (unsigned) SectionHeader[Index2].SizeOfRawData);
- return;
- }
- }
- //
- // Try to get PDB file name
- //
- PdbPointer = (CHAR8 *) PeCoffLoaderGetPdbPointer (FileBuffer);
- if (PdbPointer != NULL) {
- strcpy (MapFileName, PdbPointer);
- } else {
- strcpy (MapFileName, ImageName);
- }
-
- //
- // Construct map file name
- //
- Index = strlen (MapFileName) - 1;
- while (Index >= 0 && MapFileName[Index] != '.') {
- Index --;
- }
- if (Index < 0) {
- //
- // don't know how to costruct map file
- //
- return;
- }
-
- //
- // fill map file postfix
- //
- MapFileName[Index + 1] = 'm';
- MapFileName[Index + 2] = 'a';
- MapFileName[Index + 3] = 'p';
- MapFileName[Index + 4] = '\0';
-
- //
- // try opening Map File
- //
- fpMapFile = fopen (MapFileName, "r");
- if (fpMapFile == NULL) {
- //
- // Can't open Map file. Maybe it doesn't exist.
- //
- return;
- }
-
- //
- // Output Functions information into Fv Map file
- //
- while (fgets (Line, MAX_LINE_LEN, fpMapFile) != NULL) {
- //
- // Skip blank line
- //
- if (Line[0] == 0x0a) {
- if (FunctionType != 0) {
- //
- // read all section table data
- //
- FunctionType = 0;
- break;
- }
- FunctionType = 0;
- continue;
- }
-
- //
- // By Start keyword
- //
- if (FunctionType == 0) {
- sscanf (Line, "%s", KeyWord);
- if (stricmp (KeyWord, "Start") == 0) {
- //
- // function list
- //
- FunctionType = 1;
- }
- continue;
- }
- //
- // Printf Function Information
- //
- if (FunctionType == 1) {
- sscanf (Line, "%x:%x %xH %s", &SectionNumber, &SectionOffset, &SectionLength, SectionName);
- if (stricmp (SectionName, ".xdata") == 0) {
- FunctionType = 2;
- break;
- }
- }
- }
-
- if (FunctionType != 2) {
- //
- // no .xdata section is found
- //
- fclose (fpMapFile);
- return;
- }
-
- //
- // Zero .xdata Section data
- //
- memset (FileBuffer + SectionHeader[SectionNumber-1].PointerToRawData + SectionOffset, 0, SectionLength);
- DebugMsg (NULL, 0, 9, NULL, "Zero the .xdata section for PE image at Offset 0x%x and Length 0x%x", (unsigned) SectionHeader[SectionNumber-1].PointerToRawData + SectionOffset, SectionLength);
- fclose (fpMapFile);
- return;
-}
-
int
main (
int argc,
@@ -1413,6 +1493,14 @@ Returns:
EFI_IMAGE_OPTIONAL_HEADER64 *Optional64;
EFI_IMAGE_DOS_HEADER BackupDosHdr;
MICROCODE_IMAGE_HEADER *MciHeader;
+ UINT8 *HiiPackageListBuffer;
+ UINT8 *HiiPackageDataPointer;
+ EFI_GUID HiiPackageListGuid;
+ EFI_HII_PACKAGE_LIST_HEADER HiiPackageListHeader;
+ EFI_HII_PACKAGE_HEADER HiiPackageHeader;
+ EFI_IFR_FORM_SET IfrFormSet;
+ UINT8 NumberOfFormPacakge;
+ EFI_HII_PACKAGE_HEADER EndPackage;
SetUtilityName (UTILITY_NAME);
@@ -1445,6 +1533,12 @@ Returns:
Optional64 = NULL;
KeepExceptionTableFlag = FALSE;
KeepZeroPendingFlag = FALSE;
+ NumberOfFormPacakge = 0;
+ HiiPackageListBuffer = NULL;
+ HiiPackageDataPointer = NULL;
+ EndPackage.Length = sizeof (EFI_HII_PACKAGE_HEADER);
+ EndPackage.Type = EFI_HII_PACKAGE_END;
+ memset (&HiiPackageListGuid, 0, sizeof (HiiPackageListGuid));
if (argc == 1) {
Error (NULL, 0, 1001, "Missing options", "No input options.");
@@ -1636,6 +1730,24 @@ Returns:
continue;
}
+ if ((stricmp (argv[0], "-g") == 0) || (stricmp (argv[0], "--hiiguid") == 0)) {
+ Status = StringToGuid (argv[1], &HiiPackageListGuid);
+ if (EFI_ERROR (Status)) {
+ Error (NULL, 0, 1003, "Invalid option value", "%s = %s", argv[0], argv[1]);
+ goto Finish;
+ }
+ argc -= 2;
+ argv += 2;
+ continue;
+ }
+
+ if (stricmp (argv[0], "--hiipackage") == 0) {
+ OutImageType = FW_HII_PACKAGE_LIST_RCIMAGE;
+ argc --;
+ argv ++;
+ continue;
+ }
+
if (argv[0][0] == '-') {
Error (NULL, 0, 1000, "Unknown option", argv[0]);
goto Finish;
@@ -1700,6 +1812,14 @@ Returns:
}
//
+ // Combine HiiBinary packages to a single package list
+ //
+ if ((OutImageType == FW_HII_PACKAGE_LIST_RCIMAGE) && ReplaceFlag) {
+ Error (NULL, 0, 1002, "Conflicting option", "-r replace option cannot be used with --hiipackage merge files option.");
+ goto Finish;
+ }
+
+ //
// Input image file
//
mInImageName = InputFileName [InputFileNum - 1];
@@ -1739,6 +1859,9 @@ Returns:
case FW_MERGE_IMAGE:
VerboseMsg ("Combine the input multi microcode bin files to one bin file.");
break;
+ case FW_HII_PACKAGE_LIST_RCIMAGE:
+ VerboseMsg ("Combine the input multi hii bin packages to one text pacakge list RC file.");
+ break;
default:
break;
}
@@ -1780,6 +1903,107 @@ Returns:
}
//
+ // Combine multi binary HII package files to a single text package list RC file.
+ //
+ if (OutImageType == FW_HII_PACKAGE_LIST_RCIMAGE) {
+ //
+ // Get hii package list lenght
+ //
+ HiiPackageListHeader.PackageLength = sizeof (EFI_HII_PACKAGE_LIST_HEADER);
+ for (Index = 0; Index < InputFileNum; Index ++) {
+ fpIn = fopen (InputFileName [Index], "rb");
+ if (!fpIn) {
+ Error (NULL, 0, 0001, "Error opening file", InputFileName [Index]);
+ goto Finish;
+ }
+ FileLength = _filelength (fileno (fpIn));
+ fread (&HiiPackageHeader, 1, sizeof (HiiPackageHeader), fpIn);
+ if (HiiPackageHeader.Type == EFI_HII_PACKAGE_FORM) {
+ if (HiiPackageHeader.Length != FileLength) {
+ Error (NULL, 0, 3000, "Invalid", "The wrong package size is in HII package file %s", InputFileName [Index]);
+ fclose (fpIn);
+ goto Finish;
+ }
+ if (memcmp (&HiiPackageListGuid, &mZeroGuid, sizeof (EFI_GUID)) == 0) {
+ fread (&IfrFormSet, 1, sizeof (IfrFormSet), fpIn);
+ memcpy (&HiiPackageListGuid, &IfrFormSet.Guid, sizeof (EFI_GUID));
+ }
+ NumberOfFormPacakge ++;
+ }
+ HiiPackageListHeader.PackageLength += FileLength;
+ fclose (fpIn);
+ }
+ HiiPackageListHeader.PackageLength += sizeof (EndPackage);
+ //
+ // Check whether hii packages are valid
+ //
+ if (NumberOfFormPacakge > 1) {
+ Error (NULL, 0, 3000, "Invalid", "The input hii packages contains more than one hii form package");
+ goto Finish;
+ }
+ if (memcmp (&HiiPackageListGuid, &mZeroGuid, sizeof (EFI_GUID)) == 0) {
+ Error (NULL, 0, 3000, "Invalid", "HII pacakge list guid is not specified!");
+ goto Finish;
+ }
+ memcpy (&HiiPackageListHeader.PackageListGuid, &HiiPackageListGuid, sizeof (EFI_GUID));
+ //
+ // read hii packages
+ //
+ HiiPackageListBuffer = malloc (HiiPackageListHeader.PackageLength);
+ if (HiiPackageListBuffer == NULL) {
+ Error (NULL, 0, 4001, "Resource", "memory cannot be allocated!");
+ goto Finish;
+ }
+ memcpy (HiiPackageListBuffer, &HiiPackageListHeader, sizeof (HiiPackageListHeader));
+ HiiPackageDataPointer = HiiPackageListBuffer + sizeof (HiiPackageListHeader);
+ for (Index = 0; Index < InputFileNum; Index ++) {
+ fpIn = fopen (InputFileName [Index], "rb");
+ if (!fpIn) {
+ Error (NULL, 0, 0001, "Error opening file", InputFileName [Index]);
+ free (HiiPackageListBuffer);
+ goto Finish;
+ }
+
+ FileLength = _filelength (fileno (fpIn));
+ fread (HiiPackageDataPointer, 1, FileLength, fpIn);
+ fclose (fpIn);
+ HiiPackageDataPointer = HiiPackageDataPointer + FileLength;
+ }
+ memcpy (HiiPackageDataPointer, &EndPackage, sizeof (EndPackage));
+ //
+ // write the hii package into the text package list rc file.
+ //
+ for (Index = 0; gHiiPackageRCFileHeader[Index] != NULL; Index++) {
+ fprintf (fpOut, "%s\n", gHiiPackageRCFileHeader[Index]);
+ }
+ fprintf (fpOut, "\n%d %s\n{", HII_RESOURCE_SECTION_INDEX, HII_RESOURCE_SECTION_NAME);
+
+ HiiPackageDataPointer = HiiPackageListBuffer;
+ for (Index = 0; Index + 2 < HiiPackageListHeader.PackageLength; Index += 2) {
+ if (Index % 16 == 0) {
+ fprintf (fpOut, "\n ");
+ }
+ fprintf (fpOut, " 0x%04X,", *(UINT16 *) HiiPackageDataPointer);
+ HiiPackageDataPointer += 2;
+ }
+
+ if (Index % 16 == 0) {
+ fprintf (fpOut, "\n ");
+ }
+ if ((Index + 2) == HiiPackageListHeader.PackageLength) {
+ fprintf (fpOut, " 0x%04X\n}\n", *(UINT16 *) HiiPackageDataPointer);
+ }
+ if ((Index + 1) == HiiPackageListHeader.PackageLength) {
+ fprintf (fpOut, " 0x%04X\n}\n", *(UINT8 *) HiiPackageDataPointer);
+ }
+ free (HiiPackageListBuffer);
+ //
+ // Done successfully
+ //
+ goto Finish;
+ }
+
+ //
// Combine MciBinary files to one file
//
if (OutImageType == FW_MERGE_IMAGE) {
@@ -2471,12 +2695,13 @@ Returns:
for (Index1 = 0; Index1 < Optional64->DataDirectory[EFI_IMAGE_DIRECTORY_ENTRY_EXCEPTION].Size / sizeof (RUNTIME_FUNCTION); Index1++, RuntimeFunction++) {
SectionHeader = (EFI_IMAGE_SECTION_HEADER *) ((UINT8 *) &(PeHdr->Pe32.OptionalHeader) + PeHdr->Pe32.FileHeader.SizeOfOptionalHeader);
for (Index2 = 0; Index2 < PeHdr->Pe32.FileHeader.NumberOfSections; Index2++, SectionHeader++) {
- if (RuntimeFunction->UnwindInfoAddress > SectionHeader->VirtualAddress && RuntimeFunction->UnwindInfoAddress < (SectionHeader->VirtualAddress + SectionHeader->SizeOfRawData)) {
+ if (RuntimeFunction->UnwindInfoAddress >= SectionHeader->VirtualAddress && RuntimeFunction->UnwindInfoAddress < (SectionHeader->VirtualAddress + SectionHeader->SizeOfRawData)) {
UnwindInfo = (UNWIND_INFO *)(FileBuffer + SectionHeader->PointerToRawData + (RuntimeFunction->UnwindInfoAddress - SectionHeader->VirtualAddress));
if (UnwindInfo->Version == 1) {
memset (UnwindInfo + 1, 0, UnwindInfo->CountOfUnwindCodes * sizeof (UINT16));
memset (UnwindInfo, 0, sizeof (UNWIND_INFO));
}
+ break;
}
}
memset (RuntimeFunction, 0, sizeof (RUNTIME_FUNCTION));
@@ -2552,7 +2777,16 @@ Returns:
//
if (!KeepExceptionTableFlag) {
SectionHeader = (EFI_IMAGE_SECTION_HEADER *) ((UINT8 *) &(PeHdr->Pe32.OptionalHeader) + PeHdr->Pe32.FileHeader.SizeOfOptionalHeader);
- ZeroXdataSection(mInImageName, FileBuffer, SectionHeader, PeHdr->Pe32.FileHeader.NumberOfSections);
+ for (Index = 0; Index < PeHdr->Pe32.FileHeader.NumberOfSections; Index++) {
+ if (stricmp ((char *)SectionHeader[Index].Name, ".xdata") == 0) {
+ //
+ // zero .xdata section
+ //
+ memset (FileBuffer + SectionHeader[Index].PointerToRawData, 0, SectionHeader[Index].SizeOfRawData);
+ DebugMsg (NULL, 0, 9, NULL, "Zero the .xdata section for PE image at Offset 0x%x and Length 0x%x", (unsigned) SectionHeader[Index].PointerToRawData, (unsigned) SectionHeader[Index].SizeOfRawData);
+ break;
+ }
+ }
}
//
diff --git a/BaseTools/Source/C/GenVtf/GenVtf.c b/BaseTools/Source/C/GenVtf/GenVtf.c
index eafbcbf002..890cfd98fd 100644
--- a/BaseTools/Source/C/GenVtf/GenVtf.c
+++ b/BaseTools/Source/C/GenVtf/GenVtf.c
@@ -1267,7 +1267,7 @@ Returns:
//
// Update the SYM file for this component based on it's start address.
//
- Status = UpdateSymFile (CompStartAddress, SymFileName, VtfInfo->CompSymName);
+ Status = UpdateSymFile (CompStartAddress, SymFileName, VtfInfo->CompSymName, FileSize);
if (EFI_ERROR (Status)) {
//
@@ -1406,7 +1406,7 @@ Returns:
//
// Update the SYM file for this component based on it's start address.
//
- Status = UpdateSymFile (PalStartAddress, SymFileName, VtfInfo->CompSymName);
+ Status = UpdateSymFile (PalStartAddress, SymFileName, VtfInfo->CompSymName, FileSize);
if (EFI_ERROR (Status)) {
//
@@ -1688,7 +1688,7 @@ Returns:
FileHeader->IntegrityCheck.Checksum.File = 0;
FileHeader->State = 0;
FileHeader->IntegrityCheck.Checksum.Header = CalculateChecksum8 ((UINT8 *) FileHeader, sizeof (EFI_FFS_FILE_HEADER));
- FileHeader->IntegrityCheck.Checksum.File = CalculateChecksum8 ((UINT8 *) FileHeader, TotalVtfSize);
+ FileHeader->IntegrityCheck.Checksum.File = CalculateChecksum8 ((UINT8 *) (FileHeader + 1), TotalVtfSize - sizeof (EFI_FFS_FILE_HEADER));
FileHeader->State = EFI_FILE_HEADER_CONSTRUCTION | EFI_FILE_HEADER_VALID | EFI_FILE_DATA_VALID;
return EFI_SUCCESS;
@@ -2153,7 +2153,9 @@ EFI_STATUS
UpdateSymFile (
IN UINT64 BaseAddress,
IN CHAR8 *DestFileName,
- IN CHAR8 *SourceFileName
+ IN CHAR8 *SourceFileName,
+ IN UINT64 FileSize
+
)
/*++
@@ -2167,6 +2169,7 @@ Arguments:
BaseAddress - The base address for the new SYM tokens.
DestFileName - The destination file.
SourceFileName - The source file.
+ FileSize - Size of bin file.
Returns:
@@ -2185,7 +2188,7 @@ Returns:
CHAR8 Token[_MAX_PATH];
CHAR8 BaseToken[_MAX_PATH];
UINT64 TokenAddress;
- long StartLocation;
+ long StartLocation;
//
// Verify input parameters.
@@ -2275,13 +2278,20 @@ Returns:
// Get the token address
//
AsciiStringToUint64 (Address, TRUE, &TokenAddress);
+ if (TokenAddress > FileSize) {
+ //
+ // Symbol offset larger than FileSize. This Symbol can't be in Bin file. Don't print them.
+ //
+ break;
+ }
//
// Add the base address, the size of the FFS file header and the size of the peim header.
//
TokenAddress += BaseAddress &~IPF_CACHE_BIT;
- fprintf (DestFile, "%s | %016llX | %s | %s%s\n", Type, (unsigned long long) TokenAddress, Section, BaseToken, Token);
+ fprintf (DestFile, "%s | %016llX | ", Type, (unsigned long long) TokenAddress);
+ fprintf (DestFile, "%s | %s\n %s\n", Section, Token, BaseToken);
}
}
diff --git a/BaseTools/Source/C/GenVtf/GenVtf.h b/BaseTools/Source/C/GenVtf/GenVtf.h
index eab14f3aa6..012ebb672a 100644
--- a/BaseTools/Source/C/GenVtf/GenVtf.h
+++ b/BaseTools/Source/C/GenVtf/GenVtf.h
@@ -205,7 +205,8 @@ EFI_STATUS
UpdateSymFile (
IN UINT64 BaseAddress,
IN CHAR8 *DestFileName,
- IN CHAR8 *SourceFileName
+ IN CHAR8 *SourceFileName,
+ IN UINT64 FileSize
)
/*++
@@ -219,6 +220,7 @@ Arguments:
BaseAddress - The base address for the new SYM tokens.
DestFileName - The destination file.
SourceFileName - The source file.
+ FileSize - Size of bin file.
Returns:
diff --git a/BaseTools/Source/C/Include/Common/PiFirmwareFile.h b/BaseTools/Source/C/Include/Common/PiFirmwareFile.h
index 158e672970..33b5645b12 100644
--- a/BaseTools/Source/C/Include/Common/PiFirmwareFile.h
+++ b/BaseTools/Source/C/Include/Common/PiFirmwareFile.h
@@ -50,7 +50,10 @@ typedef UINT8 EFI_FFS_FILE_STATE;
#define EFI_FV_FILETYPE_DRIVER 0x07
#define EFI_FV_FILETYPE_COMBINED_PEIM_DRIVER 0x08
#define EFI_FV_FILETYPE_APPLICATION 0x09
+#define EFI_FV_FILETYPE_SMM 0x0A
#define EFI_FV_FILETYPE_FIRMWARE_VOLUME_IMAGE 0x0B
+#define EFI_FV_FILETYPE_COMBINED_SMM_DXE 0x0C
+#define EFI_FV_FILETYPE_SMM_CORE 0x0D
#define EFI_FV_FILETYPE_OEM_MIN 0xc0
#define EFI_FV_FILETYPE_OEM_MAX 0xdf
#define EFI_FV_FILETYPE_DEBUG_MIN 0xe0
diff --git a/BaseTools/Source/C/Include/Common/UefiInternalFormRepresentation.h b/BaseTools/Source/C/Include/Common/UefiInternalFormRepresentation.h
index f54614abf2..5e926ac08d 100644
--- a/BaseTools/Source/C/Include/Common/UefiInternalFormRepresentation.h
+++ b/BaseTools/Source/C/Include/Common/UefiInternalFormRepresentation.h
@@ -3,7 +3,7 @@
IFR is primarily consumed by the EFI presentation engine, and produced by EFI
internal application and drivers as well as all add-in card option-ROM drivers
- Copyright (c) 2006 - 2008, Intel Corporation All rights reserved.
+ Copyright (c) 2006 - 2009, Intel Corporation All rights reserved.
This program and the accompanying materials are licensed and made available
under the terms and conditions of the BSD License which accompanies this
@@ -268,8 +268,8 @@ typedef struct _EFI_HII_GUID_PACKAGE_HDR {
// String Package
//
-#define UEFI_CONFIG_LANG L"x-UEFI"
-#define UEFI_CONFIG_LANG2 L"x-i-UEFI" // BUGBUG, spec need to be updated.
+#define UEFI_CONFIG_LANG "x-UEFI"
+#define UEFI_CONFIG_LANG2 "x-i-UEFI"
typedef struct _EFI_HII_STRING_PACKAGE_HDR {
EFI_HII_PACKAGE_HEADER Header;
@@ -1034,12 +1034,12 @@ typedef struct _EFI_IFR_EQ_ID_VAL {
UINT16 Value;
} EFI_IFR_EQ_ID_VAL;
-typedef struct _EFI_IFR_EQ_ID_LIST {
+typedef struct _EFI_IFR_EQ_ID_VAL_LIST {
EFI_IFR_OP_HEADER Header;
EFI_QUESTION_ID QuestionId;
UINT16 ListLength;
UINT16 ValueList[1];
-} EFI_IFR_EQ_ID_LIST;
+} EFI_IFR_EQ_ID_VAL_LIST;
typedef struct _EFI_IFR_QUESTION_REF1 {
EFI_IFR_OP_HEADER Header;
diff --git a/BaseTools/Source/C/Include/IndustryStandard/PeImage.h b/BaseTools/Source/C/Include/IndustryStandard/PeImage.h
index 1595a987e1..57cbc2366b 100644
--- a/BaseTools/Source/C/Include/IndustryStandard/PeImage.h
+++ b/BaseTools/Source/C/Include/IndustryStandard/PeImage.h
@@ -657,6 +657,59 @@ typedef struct {
} UNWIND_INFO;
///
+/// Resource format.
+///
+typedef struct {
+ UINT32 Characteristics;
+ UINT32 TimeDateStamp;
+ UINT16 MajorVersion;
+ UINT16 MinorVersion;
+ UINT16 NumberOfNamedEntries;
+ UINT16 NumberOfIdEntries;
+ //
+ // Array of EFI_IMAGE_RESOURCE_DIRECTORY_ENTRY entries goes here.
+ //
+} EFI_IMAGE_RESOURCE_DIRECTORY;
+
+///
+/// Resource directory entry format.
+///
+typedef struct {
+ union {
+ struct {
+ UINT32 NameOffset:31;
+ UINT32 NameIsString:1;
+ } s;
+ UINT32 Id;
+ } u1;
+ union {
+ UINT32 OffsetToData;
+ struct {
+ UINT32 OffsetToDirectory:31;
+ UINT32 DataIsDirectory:1;
+ } s;
+ } u2;
+} EFI_IMAGE_RESOURCE_DIRECTORY_ENTRY;
+
+///
+/// Resource directory entry for string.
+///
+typedef struct {
+ UINT16 Length;
+ CHAR16 String[1];
+} EFI_IMAGE_RESOURCE_DIRECTORY_STRING;
+
+///
+/// Resource directory entry for data array.
+///
+typedef struct {
+ UINT32 OffsetToData;
+ UINT32 Size;
+ UINT32 CodePage;
+ UINT32 Reserved;
+} EFI_IMAGE_RESOURCE_DATA_ENTRY;
+
+///
/// Header format for TE images
///
typedef struct {
diff --git a/BaseTools/Source/C/VfrCompile/VfrCompiler.cpp b/BaseTools/Source/C/VfrCompile/VfrCompiler.cpp
index 195727c2eb..e3c150cd3d 100644
--- a/BaseTools/Source/C/VfrCompile/VfrCompiler.cpp
+++ b/BaseTools/Source/C/VfrCompile/VfrCompiler.cpp
@@ -628,23 +628,27 @@ CVfrCompiler::GenCFile (
if (!IS_RUN_STATUS(STATUS_GENBINARY)) {
goto Fail;
}
+
+ if (!mOptions.CreateIfrPkgFile || mOptions.CompatibleMode) {
+ if ((pFile = fopen (mOptions.COutputFileName, "w")) == NULL) {
+ Error (NULL, 0, 0001, "Error opening output C file", mOptions.COutputFileName);
+ goto Fail;
+ }
- if ((pFile = fopen (mOptions.COutputFileName, "w")) == NULL) {
- Error (NULL, 0, 0001, "Error opening output C file", mOptions.COutputFileName);
- goto Fail;
- }
-
- for (Index = 0; gSourceFileHeader[Index] != NULL; Index++) {
- fprintf (pFile, "%s\n", gSourceFileHeader[Index]);
- }
+ for (Index = 0; gSourceFileHeader[Index] != NULL; Index++) {
+ fprintf (pFile, "%s\n", gSourceFileHeader[Index]);
+ }
- gCVfrBufferConfig.OutputCFile (pFile, mOptions.VfrBaseFileName);
+ if (mOptions.CompatibleMode) {
+ gCVfrBufferConfig.OutputCFile (pFile, mOptions.VfrBaseFileName);
+ }
- if (gCFormPkg.GenCFile (mOptions.VfrBaseFileName, pFile, &gRBuffer) != VFR_RETURN_SUCCESS) {
+ if (gCFormPkg.GenCFile (mOptions.VfrBaseFileName, pFile, &gRBuffer) != VFR_RETURN_SUCCESS) {
+ fclose (pFile);
+ goto Fail;
+ }
fclose (pFile);
- goto Fail;
}
- fclose (pFile);
SET_RUN_STATUS (STATUS_FINISHED);
return;
diff --git a/BaseTools/Source/C/VfrCompile/VfrFormPkg.cpp b/BaseTools/Source/C/VfrCompile/VfrFormPkg.cpp
index 298eb0289b..87da95af71 100644
--- a/BaseTools/Source/C/VfrCompile/VfrFormPkg.cpp
+++ b/BaseTools/Source/C/VfrCompile/VfrFormPkg.cpp
@@ -2,7 +2,7 @@
The definition of CFormPkg's member function
-Copyright (c) 2004 - 2008, Intel Corporation
+Copyright (c) 2004 - 2009, Intel Corporation
All rights reserved. This program and the accompanying materials
are licensed and made available under the terms and conditions of the BSD License
which accompanies this distribution. The full text of the license may be found at
@@ -1228,7 +1228,7 @@ static struct {
{ sizeof (EFI_IFR_INCONSISTENT_IF), 1 }, // EFI_IFR_INCONSISTENT_IF_OP
{ sizeof (EFI_IFR_EQ_ID_VAL), 0 }, // EFI_IFR_EQ_ID_VAL_OP
{ sizeof (EFI_IFR_EQ_ID_ID), 0 }, // EFI_IFR_EQ_ID_ID_OP
- { sizeof (EFI_IFR_EQ_ID_LIST), 0 }, // EFI_IFR_EQ_ID_LIST_OP - 0x14
+ { sizeof (EFI_IFR_EQ_ID_VAL_LIST), 0 }, // EFI_IFR_EQ_ID_LIST_OP - 0x14
{ sizeof (EFI_IFR_AND), 0 }, // EFI_IFR_AND_OP
{ sizeof (EFI_IFR_OR), 0 }, // EFI_IFR_OR_OP
{ sizeof (EFI_IFR_NOT), 0 }, // EFI_IFR_NOT_OP
diff --git a/BaseTools/Source/C/VfrCompile/VfrFormPkg.h b/BaseTools/Source/C/VfrCompile/VfrFormPkg.h
index fa671c1b1e..324078a148 100644
--- a/BaseTools/Source/C/VfrCompile/VfrFormPkg.h
+++ b/BaseTools/Source/C/VfrCompile/VfrFormPkg.h
@@ -2,7 +2,7 @@
The definition of CFormPkg's member function
-Copyright (c) 2004 - 2008, Intel Corporation
+Copyright (c) 2004 - 2009, Intel Corporation
All rights reserved. This program and the accompanying materials
are licensed and made available under the terms and conditions of the BSD License
which accompanies this distribution. The full text of the license may be found at
@@ -1568,12 +1568,12 @@ public:
class CIfrEqIdList : public CIfrObj, public CIfrOpHeader {
private:
- EFI_IFR_EQ_ID_LIST *mEqIdVList;
+ EFI_IFR_EQ_ID_VAL_LIST *mEqIdVList;
public:
CIfrEqIdList (
IN UINT32 LineNo
- ) : CIfrObj (EFI_IFR_EQ_ID_LIST_OP, (CHAR8 **)&mEqIdVList, sizeof (EFI_IFR_EQ_ID_LIST), TRUE),
+ ) : CIfrObj (EFI_IFR_EQ_ID_LIST_OP, (CHAR8 **)&mEqIdVList, sizeof (EFI_IFR_EQ_ID_VAL_LIST), TRUE),
CIfrOpHeader (EFI_IFR_EQ_ID_LIST_OP, &mEqIdVList->Header) {
SetLineNo (LineNo);
mEqIdVList->QuestionId = EFI_QUESTION_ID_INVALID;
@@ -1584,7 +1584,7 @@ public:
VOID UpdateIfrBuffer (
) {
_EMIT_PENDING_OBJ();
- mEqIdVList = (EFI_IFR_EQ_ID_LIST *) GetObjBinAddr();
+ mEqIdVList = (EFI_IFR_EQ_ID_VAL_LIST *) GetObjBinAddr();
UpdateHeader (&mEqIdVList->Header);
}
diff --git a/BaseTools/Source/C/VfrCompile/VfrSyntax.g b/BaseTools/Source/C/VfrCompile/VfrSyntax.g
index c01f16e5d5..ea529a5e15 100644
--- a/BaseTools/Source/C/VfrCompile/VfrSyntax.g
+++ b/BaseTools/Source/C/VfrCompile/VfrSyntax.g
@@ -1911,7 +1911,7 @@ vfrStatementOrderedList :
>>
L:OrderedList << OLObj.SetLineNo(L->getLine()); >>
vfrQuestionHeader[OLObj] ","
- << OLObj.SetMaxContainers ((UINT8)_GET_CURRQEST_VARSIZE()); >>
+ << OLObj.SetMaxContainers ((UINT8) _GET_CURRQEST_ARRAY_SIZE()); >>
{
MaxContainers "=" M:Number "," << OLObj.SetMaxContainers (_STOU8(M->getText())); >>
}
@@ -3179,6 +3179,7 @@ private:
UINT8 _GET_CURRQEST_DATATYPE ();
UINT32 _GET_CURRQEST_VARSIZE ();
+ UINT32 _GET_CURRQEST_ARRAY_SIZE();
public:
VOID _PCATCH (IN INTN, IN INTN, IN ANTLRTokenPtr, IN CHAR8 *);
@@ -3286,6 +3287,37 @@ EfiVfrParser::_GET_CURRQEST_VARTINFO (
return mCurrQestVarInfo;
}
+UINT32
+EfiVfrParser::_GET_CURRQEST_ARRAY_SIZE (
+ VOID
+ )
+{
+ UINT8 Size = 1;
+
+ switch (mCurrQestVarInfo.mVarType) {
+ case EFI_IFR_TYPE_NUM_SIZE_8:
+ Size = 1;
+ break;
+
+ case EFI_IFR_TYPE_NUM_SIZE_16:
+ Size = 2;
+ break;
+
+ case EFI_IFR_TYPE_NUM_SIZE_32:
+ Size = 4;
+ break;
+
+ case EFI_IFR_TYPE_NUM_SIZE_64:
+ Size = 8;
+ break;
+
+ default:
+ break;
+ }
+
+ return (mCurrQestVarInfo.mVarTotalSize / Size);
+}
+
UINT8
EfiVfrParser::_GET_CURRQEST_DATATYPE (
VOID
diff --git a/BaseTools/Source/C/VolInfo/VolInfo.c b/BaseTools/Source/C/VolInfo/VolInfo.c
index b7237b08e8..ff61c9bd63 100644
--- a/BaseTools/Source/C/VolInfo/VolInfo.c
+++ b/BaseTools/Source/C/VolInfo/VolInfo.c
@@ -437,122 +437,126 @@ Returns:
{
CHAR8 *SectionStr;
CHAR8 *SectionTypeStringTable[] = {
- "EFI_SECTION_ALL",
//
// 0X00
//
- "EFI_SECTION_COMPRESSION",
+ "EFI_SECTION_ALL",
//
// 0x01
//
- "EFI_SECTION_GUID_DEFINED",
+ "EFI_SECTION_COMPRESSION",
//
// 0x02
//
- "Unknown section type - Reserved 0x03",
+ "EFI_SECTION_GUID_DEFINED",
//
// 0x03
//
- "Unknown section type - Reserved 0x04",
+ "Unknown section type - Reserved 0x03",
//
// 0x04
//
- "Unknown section type - Reserved 0x05",
+ "Unknown section type - Reserved 0x04",
//
// 0x05
//
- "Unknown section type - Reserved 0x06",
+ "Unknown section type - Reserved 0x05",
//
// 0x06
//
- "Unknown section type - Reserved 0x07",
+ "Unknown section type - Reserved 0x06",
//
// 0x07
//
- "Unknown section type - Reserved 0x08",
+ "Unknown section type - Reserved 0x07",
//
// 0x08
//
- "Unknown section type - Reserved 0x09",
+ "Unknown section type - Reserved 0x08",
//
// 0x09
//
- "Unknown section type - Reserved 0x0A",
+ "Unknown section type - Reserved 0x09",
//
// 0x0A
//
- "Unknown section type - Reserved 0x0B",
+ "Unknown section type - Reserved 0x0A",
//
// 0x0B
//
- "Unknown section type - Reserved 0x0C",
+ "Unknown section type - Reserved 0x0B",
//
// 0x0C
//
- "Unknown section type - Reserved 0x0D",
+ "Unknown section type - Reserved 0x0C",
//
// 0x0D
//
- "Unknown section type - Reserved 0x0E",
+ "Unknown section type - Reserved 0x0D",
//
// 0x0E
//
- "Unknown section type - Reserved 0x0F",
+ "Unknown section type - Reserved 0x0E",
//
// 0x0F
//
- "EFI_SECTION_PE32",
+ "Unknown section type - Reserved 0x0E",
//
// 0x10
//
- "EFI_SECTION_PIC",
+ "EFI_SECTION_PE32",
//
// 0x11
//
- "EFI_SECTION_TE",
+ "EFI_SECTION_PIC",
//
// 0x12
//
- "EFI_SECTION_DXE_DEPEX",
+ "EFI_SECTION_TE",
//
// 0x13
//
- "EFI_SECTION_VERSION",
+ "EFI_SECTION_DXE_DEPEX",
//
// 0x14
//
- "EFI_SECTION_USER_INTERFACE",
+ "EFI_SECTION_VERSION",
//
// 0x15
//
- "EFI_SECTION_COMPATIBILITY16",
+ "EFI_SECTION_USER_INTERFACE",
//
// 0x16
//
- "EFI_SECTION_FIRMWARE_VOLUME_IMAGE ",
+ "EFI_SECTION_COMPATIBILITY16",
//
// 0x17
//
- "EFI_SECTION_FREEFORM_SUBTYPE_GUID ",
+ "EFI_SECTION_FIRMWARE_VOLUME_IMAGE ",
//
// 0x18
//
- "EFI_SECTION_RAW",
+ "EFI_SECTION_FREEFORM_SUBTYPE_GUID ",
//
// 0x19
//
- "Unknown section type - 0x1A",
+ "EFI_SECTION_RAW",
//
// 0x1A
//
- "EFI_SECTION_PEI_DEPEX",
+ "Unknown section type - 0x1A",
//
// 0x1B
//
- "Unknown section type - Reserved - beyond last defined section"
+ "EFI_SECTION_PEI_DEPEX",
+ //
+ // 0x1C
+ //
+ "EFI_SECTION_SMM_DEPEX",
//
// 0x1C+
//
+ "Unknown section type - Reserved - beyond last defined section"
};
if (Type > EFI_SECTION_LAST_SECTION_TYPE) {
@@ -1055,15 +1059,15 @@ Returns:
//
// Calculate file checksum
//
- Checksum = CalculateSum8 ((UINT8 *) FileHeader, FileLength);
- Checksum = (UINT8) (Checksum - FileHeader->State);
+ Checksum = CalculateSum8 ((UINT8 *) (FileHeader + 1), FileLength - sizeof (EFI_FFS_FILE_HEADER));
+ Checksum = Checksum + FileHeader->IntegrityCheck.Checksum.File;
if (Checksum != 0) {
Error (NULL, 0, 0003, "error parsing FFS file", "FFS file with Guid %s has invalid file checksum", GuidBuffer);
return EFI_ABORTED;
}
} else {
if (FileHeader->IntegrityCheck.Checksum.File != FFS_FIXED_CHECKSUM) {
- Error (NULL, 0, 0003, "error parsing FFS file", "FFS file with Guid %s has invalid header checksum -- not set to fixed value of 0x5A", GuidBuffer);
+ Error (NULL, 0, 0003, "error parsing FFS file", "FFS file with Guid %s has invalid header checksum -- not set to fixed value of 0xAA", GuidBuffer);
return EFI_ABORTED;
}
}
@@ -1130,10 +1134,22 @@ Returns:
printf ("EFI_FV_FILETYPE_APPLICATION\n");
break;
+ case EFI_FV_FILETYPE_SMM:
+ printf ("EFI_FV_FILETYPE_SMM\n");
+ break;
+
case EFI_FV_FILETYPE_FIRMWARE_VOLUME_IMAGE:
printf ("EFI_FV_FILETYPE_FIRMWARE_VOLUME_IMAGE\n");
break;
+ case EFI_FV_FILETYPE_COMBINED_SMM_DXE:
+ printf ("EFI_FV_FILETYPE_COMBINED_SMM_DXE\n");
+ break;
+
+ case EFI_FV_FILETYPE_SMM_CORE:
+ printf ("EFI_FV_FILETYPE_SMM_CORE\n");
+ break;
+
case EFI_FV_FILETYPE_FFS_PAD:
printf ("EFI_FV_FILETYPE_FFS_PAD\n");
break;
@@ -1273,8 +1289,9 @@ Returns:
//
break;
- case EFI_SECTION_DXE_DEPEX:
case EFI_SECTION_PEI_DEPEX:
+ case EFI_SECTION_DXE_DEPEX:
+ case EFI_SECTION_SMM_DEPEX:
DumpDepexSection (Ptr, SectionLength);
break;