Sync BaseTool trunk (version r2640) into EDKII BaseTools.
Signed-off-by: Gao, Liming <liming.gao@intel.com> Reviewed-by: Liu, Jiang A <jiang.a.liu@intel.com> git-svn-id: https://svn.code.sf.net/p/edk2/code/trunk/edk2@15089 6f19259b-4bc3-4df7-8a09-765794883524
This commit is contained in:
@ -1,6 +1,6 @@
|
||||
/** @file
|
||||
|
||||
Copyright (c) 1999 - 2011, Intel Corporation. All rights reserved.<BR>
|
||||
Copyright (c) 1999 - 2013, Intel Corporation. All rights reserved.<BR>
|
||||
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
|
||||
@ -237,6 +237,7 @@ Returns:
|
||||
PCI_3_0_DATA_STRUCTURE *PciDs30;
|
||||
UINT32 Index;
|
||||
UINT8 ByteCheckSum;
|
||||
UINT16 CodeType;
|
||||
|
||||
PciDs23 = NULL;
|
||||
PciDs30 = NULL;
|
||||
@ -337,8 +338,10 @@ Returns:
|
||||
//
|
||||
if (mOptions.Pci23 == 1) {
|
||||
PciDs23->ImageLength = (UINT16) (TotalSize / 512);
|
||||
CodeType = PciDs23->CodeType;
|
||||
} else {
|
||||
PciDs30->ImageLength = (UINT16) (TotalSize / 512);
|
||||
CodeType = PciDs30->CodeType;
|
||||
}
|
||||
|
||||
//
|
||||
@ -359,14 +362,16 @@ Returns:
|
||||
}
|
||||
}
|
||||
|
||||
ByteCheckSum = 0;
|
||||
for (Index = 0; Index < FileSize - 1; Index++) {
|
||||
ByteCheckSum = (UINT8) (ByteCheckSum + Buffer[Index]);
|
||||
}
|
||||
if (CodeType != PCI_CODE_TYPE_EFI_IMAGE) {
|
||||
ByteCheckSum = 0;
|
||||
for (Index = 0; Index < FileSize - 1; Index++) {
|
||||
ByteCheckSum = (UINT8) (ByteCheckSum + Buffer[Index]);
|
||||
}
|
||||
|
||||
Buffer[FileSize - 1] = (UINT8) ((~ByteCheckSum) + 1);
|
||||
if (mOptions.Verbose) {
|
||||
VerboseMsg(" Checksum = %02x\n\n", Buffer[FileSize - 1]);
|
||||
Buffer[FileSize - 1] = (UINT8) ((~ByteCheckSum) + 1);
|
||||
if (mOptions.Verbose) {
|
||||
VerboseMsg(" Checksum = %02x\n\n", Buffer[FileSize - 1]);
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
@ -449,6 +454,8 @@ Returns:
|
||||
UINT16 MachineType;
|
||||
UINT16 SubSystem;
|
||||
UINT32 HeaderPadBytes;
|
||||
UINT32 PadBytesBeforeImage;
|
||||
UINT32 PadBytesAfterImage;
|
||||
|
||||
//
|
||||
// Try to open the input file
|
||||
@ -559,6 +566,18 @@ Returns:
|
||||
TotalSize = (TotalSize + 0x200) &~0x1ff;
|
||||
}
|
||||
//
|
||||
// Workaround:
|
||||
// If compressed, put the pad bytes after the image,
|
||||
// else put the pad bytes before the image.
|
||||
//
|
||||
if ((InFile->FileFlags & FILE_FLAG_COMPRESS) != 0) {
|
||||
PadBytesBeforeImage = 0;
|
||||
PadBytesAfterImage = TotalSize - (FileSize + HeaderSize);
|
||||
} else {
|
||||
PadBytesBeforeImage = TotalSize - (FileSize + HeaderSize);
|
||||
PadBytesAfterImage = 0;
|
||||
}
|
||||
//
|
||||
// Check size
|
||||
//
|
||||
if (TotalSize > MAX_OPTION_ROM_SIZE) {
|
||||
@ -581,7 +600,7 @@ Returns:
|
||||
RomHdr.EfiSignature = EFI_PCI_EXPANSION_ROM_HEADER_EFISIGNATURE;
|
||||
RomHdr.EfiSubsystem = SubSystem;
|
||||
RomHdr.EfiMachineType = MachineType;
|
||||
RomHdr.EfiImageHeaderOffset = (UINT16) HeaderSize;
|
||||
RomHdr.EfiImageHeaderOffset = (UINT16) (HeaderSize + PadBytesBeforeImage);
|
||||
RomHdr.PcirOffset = (UINT16) (sizeof (RomHdr) + HeaderPadBytes);
|
||||
//
|
||||
// Set image as compressed or not
|
||||
@ -686,11 +705,18 @@ Returns:
|
||||
goto BailOut;
|
||||
}
|
||||
}
|
||||
//
|
||||
// Keep track of how many bytes left to write
|
||||
//
|
||||
TotalSize -= HeaderSize;
|
||||
|
||||
//
|
||||
// Pad head to make it a multiple of 512 bytes
|
||||
//
|
||||
while (PadBytesBeforeImage > 0) {
|
||||
if (putc (~0, OutFptr) == EOF) {
|
||||
Error (NULL, 0, 2000, "Failed to write trailing pad bytes output file!", NULL);
|
||||
Status = STATUS_ERROR;
|
||||
goto BailOut;
|
||||
}
|
||||
PadBytesBeforeImage--;
|
||||
}
|
||||
//
|
||||
// Now dump the input file's contents to the output file
|
||||
//
|
||||
@ -700,18 +726,17 @@ Returns:
|
||||
goto BailOut;
|
||||
}
|
||||
|
||||
TotalSize -= FileSize;
|
||||
//
|
||||
// Pad the rest of the image to make it a multiple of 512 bytes
|
||||
//
|
||||
while (TotalSize > 0) {
|
||||
while (PadBytesAfterImage > 0) {
|
||||
if (putc (~0, OutFptr) == EOF) {
|
||||
Error (NULL, 0, 2000, "Failed to write trailing pad bytes output file!", NULL);
|
||||
Status = STATUS_ERROR;
|
||||
goto BailOut;
|
||||
}
|
||||
|
||||
TotalSize--;
|
||||
PadBytesAfterImage--;
|
||||
}
|
||||
|
||||
BailOut:
|
||||
@ -1205,7 +1230,7 @@ Returns:
|
||||
//
|
||||
// Copyright declaration
|
||||
//
|
||||
fprintf (stdout, "Copyright (c) 2007 - 2011, Intel Corporation. All rights reserved.\n\n");
|
||||
fprintf (stdout, "Copyright (c) 2007 - 2013, Intel Corporation. All rights reserved.\n\n");
|
||||
|
||||
//
|
||||
// Details Option
|
||||
|
Reference in New Issue
Block a user