Sync EDKII BaseTools to BaseTools project r1903.
git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@10123 6f19259b-4bc3-4df7-8a09-765794883524
This commit is contained in:
@@ -4,7 +4,7 @@ Abstract:
|
||||
Patch the BPB information in boot sector image file.
|
||||
Patch the MBR code in MBR image file.
|
||||
|
||||
Copyright 2006 - 2008, Intel Corporation
|
||||
Copyright 2006 - 2010, 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
|
||||
@@ -56,7 +56,7 @@ Returns:
|
||||
--*/
|
||||
{
|
||||
printf ("%s v%d.%d - Utility to break a file into two pieces at the specified offset.\n", UTILITY_NAME, UTILITY_MAJOR_VERSION, UTILITY_MINOR_VERSION);
|
||||
printf ("Copyright (c) 1999-2007 Intel Corporation. All rights reserved.\n");
|
||||
printf ("Copyright (c) 1999-2010 Intel Corporation. All rights reserved.\n");
|
||||
}
|
||||
|
||||
void
|
||||
|
@@ -44,18 +44,6 @@ STATIC UINT32 mMaxWarnings = 0;
|
||||
STATIC UINT32 mMaxWarningsPlusErrors = 0;
|
||||
STATIC INT8 mPrintLimitsSet = 0;
|
||||
|
||||
STATIC
|
||||
VOID
|
||||
PrintMessage (
|
||||
CHAR8 *Type,
|
||||
CHAR8 *FileName,
|
||||
UINT32 LineNumber,
|
||||
UINT32 MessageCode,
|
||||
CHAR8 *Text,
|
||||
CHAR8 *MsgFmt,
|
||||
va_list List
|
||||
);
|
||||
|
||||
STATIC
|
||||
VOID
|
||||
PrintLimitExceeded (
|
||||
@@ -151,12 +139,6 @@ Notes:
|
||||
va_start (List, MsgFmt);
|
||||
PrintMessage ("ERROR", FileName, LineNumber, MessageCode, Text, MsgFmt, List);
|
||||
va_end (List);
|
||||
//
|
||||
// Set status accordingly
|
||||
//
|
||||
if (mStatus < STATUS_ERROR) {
|
||||
mStatus = STATUS_ERROR;
|
||||
}
|
||||
}
|
||||
|
||||
VOID
|
||||
@@ -211,12 +193,6 @@ Returns:
|
||||
va_start (List, MsgFmt);
|
||||
PrintMessage ("ERROR", mSourceFileName, mSourceFileLineNum, MessageCode, Text, MsgFmt, List);
|
||||
va_end (List);
|
||||
//
|
||||
// Set status accordingly
|
||||
//
|
||||
if (mStatus < STATUS_ERROR) {
|
||||
mStatus = STATUS_ERROR;
|
||||
}
|
||||
}
|
||||
|
||||
VOID
|
||||
@@ -396,7 +372,6 @@ Returns:
|
||||
va_end (List);
|
||||
}
|
||||
|
||||
STATIC
|
||||
VOID
|
||||
PrintMessage (
|
||||
CHAR8 *Type,
|
||||
@@ -517,6 +492,15 @@ Notes:
|
||||
sprintf (Line, "%s", mUtilityName);
|
||||
}
|
||||
}
|
||||
|
||||
if (strcmp (Type, "ERROR") == 0) {
|
||||
//
|
||||
// Set status accordingly for ERROR information.
|
||||
//
|
||||
if (mStatus < STATUS_ERROR) {
|
||||
mStatus = STATUS_ERROR;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
@@ -545,6 +529,7 @@ Notes:
|
||||
vsprintf (Line2, MsgFmt, List);
|
||||
fprintf (stdout, " %s\n", Line2);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
STATIC
|
||||
|
@@ -70,6 +70,17 @@ SetUtilityName (
|
||||
)
|
||||
;
|
||||
|
||||
VOID
|
||||
PrintMessage (
|
||||
CHAR8 *Type,
|
||||
CHAR8 *FileName,
|
||||
UINT32 LineNumber,
|
||||
UINT32 MessageCode,
|
||||
CHAR8 *Text,
|
||||
CHAR8 *MsgFmt,
|
||||
va_list List
|
||||
);
|
||||
|
||||
VOID
|
||||
Error (
|
||||
CHAR8 *FileName,
|
||||
|
@@ -1,6 +1,6 @@
|
||||
/** @file
|
||||
|
||||
Copyright (c) 2004 - 2008, Intel Corporation
|
||||
Copyright (c) 2004 - 2010, 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
|
||||
@@ -484,13 +484,14 @@ Returns:
|
||||
--*/
|
||||
{
|
||||
UINT8 Index;
|
||||
UINT64 HexNumber;
|
||||
UINT64 Value;
|
||||
CHAR8 CurrentChar;
|
||||
|
||||
//
|
||||
// Initialize the result
|
||||
//
|
||||
HexNumber = 0;
|
||||
Value = 0;
|
||||
Index = 0;
|
||||
|
||||
//
|
||||
// Check input paramter
|
||||
@@ -498,50 +499,65 @@ Returns:
|
||||
if (AsciiString == NULL || ReturnValue == NULL) {
|
||||
return EFI_INVALID_PARAMETER;
|
||||
}
|
||||
while (AsciiString[Index] == ' ') {
|
||||
Index ++;
|
||||
}
|
||||
|
||||
//
|
||||
// Add each character to the result
|
||||
//
|
||||
if (IsHex || (AsciiString[0] == '0' && (AsciiString[1] == 'x' || AsciiString[1] == 'X'))) {
|
||||
//
|
||||
// Verify string is a hex number
|
||||
//
|
||||
for (Index = 2; Index < strlen (AsciiString); Index++) {
|
||||
if (isxdigit ((int)AsciiString[Index]) == 0) {
|
||||
return EFI_ABORTED;
|
||||
}
|
||||
}
|
||||
if (IsHex || (AsciiString[Index] == '0' && (AsciiString[Index + 1] == 'x' || AsciiString[Index + 1] == 'X'))) {
|
||||
//
|
||||
// Convert the hex string.
|
||||
//
|
||||
for (Index = 2; AsciiString[Index] != '\0'; Index++) {
|
||||
for (Index = Index + 2; AsciiString[Index] != '\0'; Index++) {
|
||||
CurrentChar = AsciiString[Index];
|
||||
HexNumber *= 16;
|
||||
if (CurrentChar >= '0' && CurrentChar <= '9') {
|
||||
HexNumber += CurrentChar - '0';
|
||||
} else if (CurrentChar >= 'a' && CurrentChar <= 'f') {
|
||||
HexNumber += CurrentChar - 'a' + 10;
|
||||
} else if (CurrentChar >= 'A' && CurrentChar <= 'F') {
|
||||
HexNumber += CurrentChar - 'A' + 10;
|
||||
} else {
|
||||
//
|
||||
// Unrecognized character
|
||||
//
|
||||
if (CurrentChar == ' ') {
|
||||
break;
|
||||
}
|
||||
//
|
||||
// Verify Hex string
|
||||
//
|
||||
if (isxdigit ((int)CurrentChar) == 0) {
|
||||
return EFI_ABORTED;
|
||||
}
|
||||
//
|
||||
// Add hex value
|
||||
//
|
||||
Value *= 16;
|
||||
if (CurrentChar >= '0' && CurrentChar <= '9') {
|
||||
Value += CurrentChar - '0';
|
||||
} else if (CurrentChar >= 'a' && CurrentChar <= 'f') {
|
||||
Value += CurrentChar - 'a' + 10;
|
||||
} else if (CurrentChar >= 'A' && CurrentChar <= 'F') {
|
||||
Value += CurrentChar - 'A' + 10;
|
||||
}
|
||||
}
|
||||
|
||||
*ReturnValue = HexNumber;
|
||||
*ReturnValue = Value;
|
||||
} else {
|
||||
//
|
||||
// Verify string is a number
|
||||
// Convert dec string is a number
|
||||
//
|
||||
for (Index = 0; Index < strlen (AsciiString); Index++) {
|
||||
if (isdigit ((int)AsciiString[Index]) == 0) {
|
||||
for (; Index < strlen (AsciiString); Index++) {
|
||||
CurrentChar = AsciiString[Index];
|
||||
if (CurrentChar == ' ') {
|
||||
break;
|
||||
}
|
||||
//
|
||||
// Verify Dec string
|
||||
//
|
||||
if (isdigit ((int)CurrentChar) == 0) {
|
||||
return EFI_ABORTED;
|
||||
}
|
||||
//
|
||||
// Add dec value
|
||||
//
|
||||
Value = Value * 10;
|
||||
Value += CurrentChar - '0';
|
||||
}
|
||||
|
||||
*ReturnValue = atol (AsciiString);
|
||||
*ReturnValue = Value;
|
||||
}
|
||||
|
||||
return EFI_SUCCESS;
|
||||
|
@@ -1,6 +1,6 @@
|
||||
/** @file
|
||||
|
||||
Copyright 2006 - 2008, Intel Corporation
|
||||
Copyright 2006 - 2010, 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
|
||||
@@ -84,7 +84,7 @@ Returns:
|
||||
--*/
|
||||
{
|
||||
printf ("%s v%d.%d -Utility to break a file into two pieces at the request offset.\n", UTILITY_NAME, UTILITY_MAJOR_VERSION, UTILITY_MINOR_VERSION);
|
||||
printf ("Copyright (c) 1999-2007 Intel Corporation. All rights reserved.\n");
|
||||
printf ("Copyright (c) 1999-2010 Intel Corporation. All rights reserved.\n");
|
||||
}
|
||||
|
||||
VOID
|
||||
|
@@ -1,6 +1,6 @@
|
||||
/** @file
|
||||
|
||||
Copyright (c) 1999-2008 Intel Corporation. All rights reserved
|
||||
Copyright (c) 1999-2010 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
|
||||
@@ -1205,7 +1205,7 @@ Returns:
|
||||
//
|
||||
// Copyright declaration
|
||||
//
|
||||
fprintf (stdout, "Copyright (c) 2007 - 2009, Intel Corporation. All rights reserved.\n\n");
|
||||
fprintf (stdout, "Copyright (c) 2007 - 2010, Intel Corporation. All rights reserved.\n\n");
|
||||
|
||||
//
|
||||
// Details Option
|
||||
|
@@ -1,6 +1,6 @@
|
||||
/** @file
|
||||
|
||||
Copyright 2006 - 2008, Intel Corporation
|
||||
Copyright 2006 - 2010, 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
|
||||
@@ -542,7 +542,7 @@ Returns:
|
||||
--*/
|
||||
{
|
||||
printf ("%s v%d.%d -Utility to retrieve and update the boot sector or MBR.\n", UTILITY_NAME, UTILITY_MAJOR_VERSION, UTILITY_MINOR_VERSION);
|
||||
printf ("Copyright (c) 2009 Intel Corporation. All rights reserved.\n");
|
||||
printf ("Copyright (c) 2009 - 2010 Intel Corporation. All rights reserved.\n");
|
||||
}
|
||||
|
||||
VOID
|
||||
|
@@ -1,6 +1,6 @@
|
||||
/** @file
|
||||
|
||||
Copyright (c) 2007 - 2008, Intel Corporation
|
||||
Copyright (c) 2007 - 2010, 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
|
||||
@@ -86,7 +86,7 @@ Returns:
|
||||
//
|
||||
// Copyright declaration
|
||||
//
|
||||
fprintf (stdout, "Copyright (c) 2007 - 2009, Intel Corporation. All rights reserved.\n\n");
|
||||
fprintf (stdout, "Copyright (c) 2007 - 2010, Intel Corporation. All rights reserved.\n\n");
|
||||
|
||||
//
|
||||
// Details Option
|
||||
|
@@ -1,6 +1,6 @@
|
||||
/**
|
||||
|
||||
Copyright (c) 2004-2008, Intel Corporation
|
||||
Copyright (c) 2004-2010, 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
|
||||
@@ -119,7 +119,7 @@ Returns:
|
||||
//
|
||||
// Copyright declaration
|
||||
//
|
||||
fprintf (stdout, "Copyright (c) 2007, Intel Corporation. All rights reserved.\n\n");
|
||||
fprintf (stdout, "Copyright (c) 2007 - 2010, Intel Corporation. All rights reserved.\n\n");
|
||||
|
||||
//
|
||||
// Details Option
|
||||
@@ -287,6 +287,8 @@ Returns:
|
||||
EFI_COMMON_SECTION_HEADER TempSectHeader;
|
||||
EFI_TE_IMAGE_HEADER TeHeader;
|
||||
UINT32 TeOffset;
|
||||
EFI_GUID_DEFINED_SECTION GuidSectHeader;
|
||||
UINT32 HeaderSize;
|
||||
|
||||
Size = 0;
|
||||
Offset = 0;
|
||||
@@ -330,6 +332,7 @@ Returns:
|
||||
// Check this section is Te/Pe section, and Calculate the numbers of Te/Pe section.
|
||||
//
|
||||
TeOffset = 0;
|
||||
HeaderSize = sizeof (EFI_COMMON_SECTION_HEADER);
|
||||
fread (&TempSectHeader, 1, sizeof (TempSectHeader), InFile);
|
||||
if (TempSectHeader.Type == EFI_SECTION_TE) {
|
||||
(*PESectionNum) ++;
|
||||
@@ -339,8 +342,14 @@ Returns:
|
||||
}
|
||||
} else if (TempSectHeader.Type == EFI_SECTION_PE32) {
|
||||
(*PESectionNum) ++;
|
||||
} else if (TempSectHeader.Type == EFI_SECTION_GUID_DEFINED) {
|
||||
fseek (InFile, 0, SEEK_SET);
|
||||
fread (&GuidSectHeader, 1, sizeof (GuidSectHeader), InFile);
|
||||
if ((GuidSectHeader.Attributes & EFI_GUIDED_SECTION_PROCESSING_REQUIRED) == 0) {
|
||||
HeaderSize = GuidSectHeader.DataOffset;
|
||||
}
|
||||
(*PESectionNum) ++;
|
||||
} else if (TempSectHeader.Type == EFI_SECTION_COMPRESSION ||
|
||||
TempSectHeader.Type == EFI_SECTION_GUID_DEFINED ||
|
||||
TempSectHeader.Type == EFI_SECTION_FIRMWARE_VOLUME_IMAGE) {
|
||||
//
|
||||
// for the encapsulated section, assume it contains Pe/Te section
|
||||
@@ -358,17 +367,18 @@ Returns:
|
||||
TeOffset = InputFileAlign [Index] - (TeOffset % InputFileAlign [Index]);
|
||||
TeOffset = TeOffset % InputFileAlign [Index];
|
||||
}
|
||||
|
||||
|
||||
//
|
||||
// make sure section data meet its alignment requirement by adding one raw pad section.
|
||||
// But the different sections have the different section header. Necessary or not?
|
||||
// Based on section type to adjust offset? Todo
|
||||
//
|
||||
if ((InputFileAlign [Index] != 0) && (((Size + sizeof (EFI_COMMON_SECTION_HEADER) + TeOffset) % InputFileAlign [Index]) != 0)) {
|
||||
Offset = (Size + 2 * sizeof (EFI_COMMON_SECTION_HEADER) + TeOffset + InputFileAlign [Index] - 1) & ~(InputFileAlign [Index] - 1);
|
||||
Offset = Offset - Size - sizeof (EFI_COMMON_SECTION_HEADER) - TeOffset;
|
||||
if ((InputFileAlign [Index] != 0) && (((Size + HeaderSize + TeOffset) % InputFileAlign [Index]) != 0)) {
|
||||
Offset = (Size + sizeof (EFI_COMMON_SECTION_HEADER) + HeaderSize + TeOffset + InputFileAlign [Index] - 1) & ~(InputFileAlign [Index] - 1);
|
||||
Offset = Offset - Size - HeaderSize - TeOffset;
|
||||
|
||||
if (FileBuffer != NULL && ((Size + Offset) < *BufferLength)) {
|
||||
memset (FileBuffer + Size, 0, Offset);
|
||||
SectHeader = (EFI_COMMON_SECTION_HEADER *) (FileBuffer + Size);
|
||||
SectHeader->Type = EFI_SECTION_RAW;
|
||||
SectHeader->Size[0] = (UINT8) (Offset & 0xff);
|
||||
|
@@ -1,6 +1,6 @@
|
||||
/** @file
|
||||
|
||||
Copyright (c) 2007 - 2009, Intel Corporation
|
||||
Copyright (c) 2007 - 2010, 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
|
||||
@@ -40,7 +40,7 @@ Abstract:
|
||||
//
|
||||
#define UTILITY_MAJOR_VERSION 0
|
||||
#define UTILITY_MINOR_VERSION 1
|
||||
#define GENFV_UPDATE_TIME " updated on 2008/11/21"
|
||||
#define GENFV_UPDATE_TIME " updated on 2010/2/1"
|
||||
|
||||
EFI_GUID mEfiFirmwareFileSystem2Guid = EFI_FIRMWARE_FILE_SYSTEM2_GUID;
|
||||
|
||||
@@ -97,7 +97,7 @@ Returns:
|
||||
//
|
||||
// Copyright declaration
|
||||
//
|
||||
fprintf (stdout, "Copyright (c) 2007, Intel Corporation. All rights reserved.\n\n");
|
||||
fprintf (stdout, "Copyright (c) 2007 - 2010, Intel Corporation. All rights reserved.\n\n");
|
||||
|
||||
//
|
||||
// Details Option
|
||||
@@ -126,11 +126,8 @@ Returns:
|
||||
run in Flash. It supports DEC or HEX digital format.\n\
|
||||
If it is set to zero, no rebase action will be taken\n");
|
||||
fprintf (stdout, " -a AddressFile, --addrfile AddressFile\n\
|
||||
AddressFile is one file used to record boot driver base\n\
|
||||
address and runtime driver base address. And this tool\n\
|
||||
will update these two addresses after it relocates all\n\
|
||||
boot drivers and runtime drivers in this fv iamge to\n\
|
||||
the preferred loaded memory address.\n");
|
||||
AddressFile is one file used to record the child\n\
|
||||
FV base address when current FV base address is set.\n");
|
||||
fprintf (stdout, " -m logfile, --map logfile\n\
|
||||
Logfile is the output fv map file name. if it is not\n\
|
||||
given, the FvName.map will be the default map file name\n");
|
||||
@@ -194,10 +191,8 @@ Returns:
|
||||
CHAR8 *InfFileImage;
|
||||
UINT32 InfFileSize;
|
||||
CHAR8 *OutFileName;
|
||||
CHAR8 ValueString[_MAX_PATH];
|
||||
BOOLEAN CapsuleFlag;
|
||||
BOOLEAN DumpCapsule;
|
||||
MEMORY_FILE AddrMemoryFile;
|
||||
FILE *FpFile;
|
||||
EFI_CAPSULE_HEADER *CapsuleHeader;
|
||||
UINT64 LogLevel, TempNumber;
|
||||
@@ -545,62 +540,6 @@ Returns:
|
||||
VerboseMsg ("the output file name is %s", OutFileName);
|
||||
}
|
||||
|
||||
//
|
||||
// Read boot and runtime address from address file
|
||||
//
|
||||
if (AddrFileName != NULL) {
|
||||
VerboseMsg ("the input address file name is %s", AddrFileName);
|
||||
Status = GetFileImage (AddrFileName, &InfFileImage, &InfFileSize);
|
||||
if (EFI_ERROR (Status)) {
|
||||
return STATUS_ERROR;
|
||||
}
|
||||
|
||||
AddrMemoryFile.FileImage = InfFileImage;
|
||||
AddrMemoryFile.CurrentFilePointer = InfFileImage;
|
||||
AddrMemoryFile.Eof = InfFileImage + InfFileSize;
|
||||
|
||||
//
|
||||
// Read the boot driver base address for this FV image
|
||||
//
|
||||
Status = FindToken (&AddrMemoryFile, OPTIONS_SECTION_STRING, EFI_FV_BOOT_DRIVER_BASE_ADDRESS_STRING, 0, ValueString);
|
||||
if (Status == EFI_SUCCESS) {
|
||||
//
|
||||
// Get the base address
|
||||
//
|
||||
Status = AsciiStringToUint64 (ValueString, FALSE, &TempNumber);
|
||||
if (EFI_ERROR (Status)) {
|
||||
Error (NULL, 0, 2000, "Invalid parameter", "%s = %s", EFI_FV_BOOT_DRIVER_BASE_ADDRESS_STRING, ValueString);
|
||||
return STATUS_ERROR;
|
||||
}
|
||||
mFvDataInfo.BootBaseAddress = TempNumber;
|
||||
DebugMsg (NULL, 0, 9, "Boot driver base address", "%s = %s", EFI_FV_BOOT_DRIVER_BASE_ADDRESS_STRING, ValueString);
|
||||
}
|
||||
|
||||
//
|
||||
// Read the FV runtime driver base address
|
||||
//
|
||||
Status = FindToken (&AddrMemoryFile, OPTIONS_SECTION_STRING, EFI_FV_RUNTIME_DRIVER_BASE_ADDRESS_STRING, 0, ValueString);
|
||||
if (Status == EFI_SUCCESS) {
|
||||
//
|
||||
// Get the base address
|
||||
//
|
||||
Status = AsciiStringToUint64 (ValueString, FALSE, &TempNumber);
|
||||
if (EFI_ERROR (Status)) {
|
||||
Error (NULL, 0, 2000, "Invalid parameter", "%s = %s", EFI_FV_RUNTIME_DRIVER_BASE_ADDRESS_STRING, ValueString);
|
||||
return STATUS_ERROR;
|
||||
}
|
||||
mFvDataInfo.RuntimeBaseAddress = TempNumber;
|
||||
DebugMsg (NULL, 0, 9, "Runtime driver base address", "%s = %s", EFI_FV_RUNTIME_DRIVER_BASE_ADDRESS_STRING, ValueString);
|
||||
}
|
||||
|
||||
//
|
||||
// free the allocated memory space for addr file.
|
||||
//
|
||||
free (InfFileImage);
|
||||
InfFileImage = NULL;
|
||||
InfFileSize = 0;
|
||||
}
|
||||
|
||||
//
|
||||
// Read the INF file image
|
||||
//
|
||||
@@ -683,32 +622,22 @@ Returns:
|
||||
//
|
||||
// update boot driver address and runtime driver address in address file
|
||||
//
|
||||
if (Status == EFI_SUCCESS && AddrFileName != NULL) {
|
||||
if (Status == EFI_SUCCESS && AddrFileName != NULL && mFvBaseAddressNumber > 0) {
|
||||
FpFile = fopen (AddrFileName, "w");
|
||||
if (FpFile == NULL) {
|
||||
Error (NULL, 0, 0001, "Error opening file", AddrFileName);
|
||||
return STATUS_ERROR;
|
||||
}
|
||||
fprintf (FpFile, OPTIONS_SECTION_STRING);
|
||||
fprintf (FpFile, FV_BASE_ADDRESS_STRING);
|
||||
fprintf (FpFile, "\n");
|
||||
if (mFvDataInfo.BootBaseAddress != 0) {
|
||||
fprintf (FpFile, EFI_FV_BOOT_DRIVER_BASE_ADDRESS_STRING);
|
||||
for (Index = 0; Index < mFvBaseAddressNumber; Index ++) {
|
||||
fprintf (
|
||||
FpFile,
|
||||
" = 0x%llx\n",
|
||||
(unsigned long long)mFvDataInfo.BootBaseAddress
|
||||
"0x%llx\n",
|
||||
(unsigned long long)mFvBaseAddress[Index]
|
||||
);
|
||||
DebugMsg (NULL, 0, 9, "Updated boot driver base address", "%s = 0x%llx", EFI_FV_RUNTIME_DRIVER_BASE_ADDRESS_STRING, (unsigned long long) mFvDataInfo.BootBaseAddress);
|
||||
}
|
||||
if (mFvDataInfo.RuntimeBaseAddress != 0) {
|
||||
fprintf (FpFile, EFI_FV_RUNTIME_DRIVER_BASE_ADDRESS_STRING);
|
||||
fprintf (
|
||||
FpFile,
|
||||
" = 0x%llx\n",
|
||||
(unsigned long long)mFvDataInfo.RuntimeBaseAddress
|
||||
);
|
||||
DebugMsg (NULL, 0, 9, "Updated runtime driver base address", "%s = 0x%llx", EFI_FV_RUNTIME_DRIVER_BASE_ADDRESS_STRING, (unsigned long long) mFvDataInfo.RuntimeBaseAddress);
|
||||
}
|
||||
fflush (FpFile);
|
||||
fclose (FpFile);
|
||||
}
|
||||
|
||||
|
@@ -1,6 +1,6 @@
|
||||
/** @file
|
||||
|
||||
Copyright (c) 2004 - 2009, Intel Corporation
|
||||
Copyright (c) 2004 - 2010, 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
|
||||
@@ -159,6 +159,9 @@ UINT8 m64kRecoveryStartupApDataArray[SIZEOF_ST
|
||||
FV_INFO mFvDataInfo;
|
||||
CAP_INFO mCapDataInfo;
|
||||
|
||||
EFI_PHYSICAL_ADDRESS mFvBaseAddress[0x10];
|
||||
UINT32 mFvBaseAddressNumber = 0;
|
||||
|
||||
EFI_STATUS
|
||||
ParseFvInf (
|
||||
IN MEMORY_FILE *InfFile,
|
||||
@@ -716,6 +719,11 @@ Returns:
|
||||
EFI_TE_IMAGE_HEADER *TEImageHeader;
|
||||
EFI_IMAGE_SECTION_HEADER *SectionHeader;
|
||||
unsigned long long TempLongAddress;
|
||||
UINT32 TextVirtualAddress;
|
||||
UINT32 DataVirtualAddress;
|
||||
EFI_PHYSICAL_ADDRESS LinkTimeBaseAddress;
|
||||
|
||||
|
||||
//
|
||||
// Init local variable
|
||||
//
|
||||
@@ -789,29 +797,35 @@ Returns:
|
||||
SectionHeader = (EFI_IMAGE_SECTION_HEADER *) (TEImageHeader + 1);
|
||||
Index = TEImageHeader->NumberOfSections;
|
||||
}
|
||||
|
||||
|
||||
//
|
||||
// module information output
|
||||
//
|
||||
if (ImageBaseAddress == 0) {
|
||||
fprintf (FvMapFile, "%s (dummy) (", KeyWord);
|
||||
fprintf (FvMapFile, "BaseAddress=%08llx, ", (unsigned long long) ImageBaseAddress);
|
||||
fprintf (FvMapFile, "BaseAddress=%010llx, ", (unsigned long long) ImageBaseAddress);
|
||||
} else {
|
||||
fprintf (FvMapFile, "%s (", KeyWord);
|
||||
fprintf (FvMapFile, "BaseAddress=%08llx, ", (unsigned long long) (ImageBaseAddress + Offset));
|
||||
fprintf (FvMapFile, "%s (Fixed Flash Address, ", KeyWord);
|
||||
fprintf (FvMapFile, "BaseAddress=0x%010llx, ", (unsigned long long) (ImageBaseAddress + Offset));
|
||||
}
|
||||
fprintf (FvMapFile, "EntryPoint=%08llx, ", (unsigned long long) (ImageBaseAddress + AddressOfEntryPoint));
|
||||
fprintf (FvMapFile, "GUID=%s", FileGuidName);
|
||||
fprintf (FvMapFile, "EntryPoint=0x%010llx", (unsigned long long) (ImageBaseAddress + AddressOfEntryPoint));
|
||||
fprintf (FvMapFile, ")\n");
|
||||
|
||||
fprintf (FvMapFile, "(GUID=%s", FileGuidName);
|
||||
TextVirtualAddress = 0;
|
||||
DataVirtualAddress = 0;
|
||||
for (; Index > 0; Index --, SectionHeader ++) {
|
||||
if (stricmp ((CHAR8 *)SectionHeader->Name, ".text") == 0) {
|
||||
fprintf (FvMapFile, ".textbaseaddress=%08llx ", (unsigned long long) (ImageBaseAddress + SectionHeader->VirtualAddress));
|
||||
if (stricmp ((CHAR8 *)SectionHeader->Name, ".text") == 0) {
|
||||
TextVirtualAddress = SectionHeader->VirtualAddress;
|
||||
} else if (stricmp ((CHAR8 *)SectionHeader->Name, ".data") == 0) {
|
||||
fprintf (FvMapFile, ".databaseaddress=%08llx ", (unsigned long long) (ImageBaseAddress + SectionHeader->VirtualAddress));
|
||||
DataVirtualAddress = SectionHeader->VirtualAddress;
|
||||
} else if (stricmp ((CHAR8 *)SectionHeader->Name, ".sdata") == 0) {
|
||||
DataVirtualAddress = SectionHeader->VirtualAddress;
|
||||
}
|
||||
}
|
||||
fprintf (FvMapFile, "\n\n");
|
||||
fprintf (FvMapFile, " .textbaseaddress=0x%010llx", (unsigned long long) (ImageBaseAddress + TextVirtualAddress));
|
||||
fprintf (FvMapFile, " .databaseaddress=0x%010llx", (unsigned long long) (ImageBaseAddress + DataVirtualAddress));
|
||||
fprintf (FvMapFile, ")\n\n");
|
||||
|
||||
//
|
||||
// Open PeMapFile
|
||||
@@ -826,6 +840,7 @@ Returns:
|
||||
//
|
||||
// Output Functions information into Fv Map file
|
||||
//
|
||||
LinkTimeBaseAddress = 0;
|
||||
while (fgets (Line, MAX_LINE_LEN, PeMapFile) != NULL) {
|
||||
//
|
||||
// Skip blank line
|
||||
@@ -851,6 +866,9 @@ Returns:
|
||||
//
|
||||
FunctionType = 2;
|
||||
fgets (Line, MAX_LINE_LEN, PeMapFile);
|
||||
} else if (stricmp (KeyWord, "Preferred") ==0) {
|
||||
sscanf (Line + strlen (" Preferred load address is"), "%llx", &TempLongAddress);
|
||||
LinkTimeBaseAddress = (UINT64) TempLongAddress;
|
||||
}
|
||||
continue;
|
||||
}
|
||||
@@ -861,24 +879,14 @@ Returns:
|
||||
sscanf (Line, "%s %s %llx %s", KeyWord, FunctionName, &TempLongAddress, FunctionTypeName);
|
||||
FunctionAddress = (UINT64) TempLongAddress;
|
||||
if (FunctionTypeName [1] == '\0' && (FunctionTypeName [0] == 'f' || FunctionTypeName [0] == 'F')) {
|
||||
fprintf (FvMapFile, " %016llx ", (unsigned long long) (ImageBaseAddress + FunctionAddress));
|
||||
fprintf (FvMapFile, "(%08llx) F ", (unsigned long long) (FunctionAddress - Offset));
|
||||
fprintf (FvMapFile, "%s\n", FunctionName);
|
||||
} else {
|
||||
fprintf (FvMapFile, " %016llx ", (unsigned long long) (ImageBaseAddress + FunctionAddress));
|
||||
fprintf (FvMapFile, "(%08llx) ", (unsigned long long) (FunctionAddress - Offset));
|
||||
fprintf (FvMapFile, " 0x%010llx ", (unsigned long long) (ImageBaseAddress + FunctionAddress - LinkTimeBaseAddress));
|
||||
fprintf (FvMapFile, "%s\n", FunctionName);
|
||||
}
|
||||
} else if (FunctionType == 2) {
|
||||
sscanf (Line, "%s %s %llx %s", KeyWord, FunctionName, &TempLongAddress, FunctionTypeName);
|
||||
FunctionAddress = (UINT64) TempLongAddress;
|
||||
if (FunctionTypeName [1] == '\0' && (FunctionTypeName [0] == 'f' || FunctionTypeName [0] == 'F')) {
|
||||
fprintf (FvMapFile, " %016llx ", (unsigned long long) (ImageBaseAddress + FunctionAddress));
|
||||
fprintf (FvMapFile, "(%08llx) FS ", (unsigned long long) (FunctionAddress - Offset));
|
||||
fprintf (FvMapFile, "%s\n", FunctionName);
|
||||
} else {
|
||||
fprintf (FvMapFile, " %016llx ", (unsigned long long) (ImageBaseAddress + FunctionAddress));
|
||||
fprintf (FvMapFile, "(%08llx) ", (unsigned long long) (FunctionAddress - Offset));
|
||||
fprintf (FvMapFile, " 0x%010llx ", (unsigned long long) (ImageBaseAddress + FunctionAddress - LinkTimeBaseAddress));
|
||||
fprintf (FvMapFile, "%s\n", FunctionName);
|
||||
}
|
||||
}
|
||||
@@ -898,7 +906,8 @@ AddFile (
|
||||
IN FV_INFO *FvInfo,
|
||||
IN UINTN Index,
|
||||
IN OUT EFI_FFS_FILE_HEADER **VtfFileImage,
|
||||
IN FILE *FvMapFile
|
||||
IN FILE *FvMapFile,
|
||||
IN FILE *FvReportFile
|
||||
)
|
||||
/*++
|
||||
|
||||
@@ -916,6 +925,7 @@ Arguments:
|
||||
VtfFileImage A pointer to the VTF file within the FvImage. If this is equal
|
||||
to the end of the FvImage then no VTF previously found.
|
||||
FvMapFile Pointer to FvMap File
|
||||
FvReportFile Pointer to FvReport File
|
||||
|
||||
Returns:
|
||||
|
||||
@@ -933,6 +943,7 @@ Returns:
|
||||
UINT32 CurrentFileAlignment;
|
||||
EFI_STATUS Status;
|
||||
UINTN Index1;
|
||||
UINT8 FileGuidString[PRINTED_GUID_BUFFER_SIZE];
|
||||
|
||||
Index1 = 0;
|
||||
//
|
||||
@@ -1071,6 +1082,10 @@ Returns:
|
||||
// copy VTF File
|
||||
//
|
||||
memcpy (*VtfFileImage, FileBuffer, FileSize);
|
||||
|
||||
PrintGuidToBuffer ((EFI_GUID *) FileBuffer, FileGuidString, sizeof (FileGuidString), TRUE);
|
||||
fprintf (FvReportFile, "0x%08X %s\n", (unsigned)(UINTN) (((UINT8 *)*VtfFileImage) - (UINTN)FvImage->FileImage), FileGuidString);
|
||||
|
||||
free (FileBuffer);
|
||||
DebugMsg (NULL, 0, 9, "Add VTF FFS file in FV image", NULL);
|
||||
return EFI_SUCCESS;
|
||||
@@ -1106,6 +1121,8 @@ Returns:
|
||||
// Copy the file
|
||||
//
|
||||
memcpy (FvImage->CurrentFilePointer, FileBuffer, FileSize);
|
||||
PrintGuidToBuffer ((EFI_GUID *) FileBuffer, FileGuidString, sizeof (FileGuidString), TRUE);
|
||||
fprintf (FvReportFile, "0x%08X %s\n", (unsigned) (FvImage->CurrentFilePointer - FvImage->FileImage), FileGuidString);
|
||||
FvImage->CurrentFilePointer += FileSize;
|
||||
} else {
|
||||
Error (NULL, 0, 4002, "Resource", "FV space is full, cannot add file %s.", FvInfo->FvFiles[Index]);
|
||||
@@ -1967,10 +1984,13 @@ Returns:
|
||||
EFI_FIRMWARE_VOLUME_EXT_HEADER *FvExtHeader;
|
||||
FILE *FvExtHeaderFile;
|
||||
UINTN FileSize;
|
||||
CHAR8 FvReportName[_MAX_PATH];
|
||||
FILE *FvReportFile;
|
||||
|
||||
FvBufferHeader = NULL;
|
||||
FvFile = NULL;
|
||||
FvMapFile = NULL;
|
||||
FvReportFile = NULL;
|
||||
|
||||
if (InfFileImage != NULL) {
|
||||
//
|
||||
@@ -2109,6 +2129,12 @@ Returns:
|
||||
}
|
||||
VerboseMsg ("FV Map file name is %s", FvMapName);
|
||||
|
||||
//
|
||||
// FvReport file to log the FV information in one Fvimage
|
||||
//
|
||||
strcpy (FvReportName, FvFileName);
|
||||
strcat (FvReportName, ".txt");
|
||||
|
||||
//
|
||||
// Calculate the FV size and Update Fv Size based on the actual FFS files.
|
||||
// And Update mFvDataInfo data.
|
||||
@@ -2224,6 +2250,14 @@ Returns:
|
||||
return EFI_ABORTED;
|
||||
}
|
||||
|
||||
//
|
||||
// Open FvReport file
|
||||
//
|
||||
FvReportFile = fopen(FvReportName, "w");
|
||||
if (FvReportFile == NULL) {
|
||||
Error (NULL, 0, 0001, "Error opening file", FvReportName);
|
||||
return EFI_ABORTED;
|
||||
}
|
||||
//
|
||||
// record FV size information into FvMap file.
|
||||
//
|
||||
@@ -2240,6 +2274,12 @@ Returns:
|
||||
fprintf (FvMapFile, " = 0x%x\n\n", (unsigned) (mFvTotalSize - mFvTakenSize));
|
||||
}
|
||||
|
||||
//
|
||||
// record FV size information to FvReportFile.
|
||||
//
|
||||
fprintf (FvReportFile, "%s = 0x%x\n", EFI_FV_TOTAL_SIZE_STRING, (unsigned) mFvTotalSize);
|
||||
fprintf (FvReportFile, "%s = 0x%x\n", EFI_FV_TAKEN_SIZE_STRING, (unsigned) mFvTakenSize);
|
||||
|
||||
//
|
||||
// Add PI FV extension header
|
||||
//
|
||||
@@ -2263,7 +2303,7 @@ Returns:
|
||||
//
|
||||
// Add the file
|
||||
//
|
||||
Status = AddFile (&FvImageMemoryFile, &mFvDataInfo, Index, &VtfFileImage, FvMapFile);
|
||||
Status = AddFile (&FvImageMemoryFile, &mFvDataInfo, Index, &VtfFileImage, FvMapFile, FvReportFile);
|
||||
|
||||
//
|
||||
// Exit if error detected while adding the file
|
||||
@@ -2358,13 +2398,19 @@ Finish:
|
||||
}
|
||||
|
||||
if (FvFile != NULL) {
|
||||
fflush (FvFile);
|
||||
fclose (FvFile);
|
||||
}
|
||||
|
||||
if (FvMapFile != NULL) {
|
||||
fflush (FvMapFile);
|
||||
fclose (FvMapFile);
|
||||
}
|
||||
|
||||
if (FvReportFile != NULL) {
|
||||
fflush (FvReportFile);
|
||||
fclose (FvReportFile);
|
||||
}
|
||||
return Status;
|
||||
}
|
||||
|
||||
@@ -2652,6 +2698,54 @@ Returns:
|
||||
return EFI_SUCCESS;
|
||||
}
|
||||
|
||||
EFI_STATUS
|
||||
GetChildFvFromFfs (
|
||||
IN FV_INFO *FvInfo,
|
||||
IN EFI_FFS_FILE_HEADER *FfsFile,
|
||||
IN UINTN XipOffset
|
||||
)
|
||||
/*++
|
||||
|
||||
Routine Description:
|
||||
|
||||
This function gets all child FvImages in the input FfsFile, and records
|
||||
their base address to the parent image.
|
||||
|
||||
Arguments:
|
||||
FvInfo A pointer to FV_INFO struture.
|
||||
FfsFile A pointer to Ffs file image that may contain FvImage.
|
||||
XipOffset The offset address to the parent FvImage base.
|
||||
|
||||
Returns:
|
||||
|
||||
EFI_SUCCESS Base address of child Fv image is recorded.
|
||||
--*/
|
||||
{
|
||||
EFI_STATUS Status;
|
||||
UINTN Index;
|
||||
EFI_FILE_SECTION_POINTER SubFvSection;
|
||||
EFI_FIRMWARE_VOLUME_HEADER *SubFvImageHeader;
|
||||
EFI_PHYSICAL_ADDRESS SubFvBaseAddress;
|
||||
|
||||
for (Index = 1;; Index++) {
|
||||
//
|
||||
// Find FV section
|
||||
//
|
||||
Status = GetSectionByType (FfsFile, EFI_SECTION_FIRMWARE_VOLUME_IMAGE, Index, &SubFvSection);
|
||||
if (EFI_ERROR (Status)) {
|
||||
break;
|
||||
}
|
||||
SubFvImageHeader = (EFI_FIRMWARE_VOLUME_HEADER *) ((UINT8 *) SubFvSection.FVImageSection + sizeof (EFI_FIRMWARE_VOLUME_IMAGE_SECTION));
|
||||
//
|
||||
// Rebase on Flash
|
||||
//
|
||||
SubFvBaseAddress = FvInfo->BaseAddress + (UINTN) SubFvImageHeader - (UINTN) FfsFile + XipOffset;
|
||||
mFvBaseAddress[mFvBaseAddressNumber ++ ] = SubFvBaseAddress;
|
||||
}
|
||||
|
||||
return EFI_SUCCESS;
|
||||
}
|
||||
|
||||
EFI_STATUS
|
||||
FfsRebase (
|
||||
IN OUT FV_INFO *FvInfo,
|
||||
@@ -2696,7 +2790,6 @@ Returns:
|
||||
EFI_FFS_FILE_STATE SavedState;
|
||||
EFI_IMAGE_OPTIONAL_HEADER_UNION *ImgHdr;
|
||||
EFI_TE_IMAGE_HEADER *TEImageHeader;
|
||||
UINT8 Flags;
|
||||
UINT8 *MemoryImagePointer;
|
||||
EFI_IMAGE_SECTION_HEADER *SectionHeader;
|
||||
CHAR8 PeFileName [_MAX_PATH];
|
||||
@@ -2717,26 +2810,12 @@ Returns:
|
||||
PeFileBuffer = NULL;
|
||||
|
||||
//
|
||||
// Check XipAddress, BootAddress and RuntimeAddress
|
||||
// Don't need to relocate image when BaseAddress is not set.
|
||||
//
|
||||
Flags = 0;
|
||||
XipBase = 0;
|
||||
if (FvInfo->BaseAddress != 0) {
|
||||
Flags |= REBASE_XIP_FILE;
|
||||
XipBase = FvInfo->BaseAddress + XipOffset;
|
||||
if (FvInfo->BaseAddress == 0) {
|
||||
return EFI_SUCCESS;
|
||||
}
|
||||
if (FvInfo->BootBaseAddress != 0) {
|
||||
Flags |= REBASE_BOOTTIME_FILE;
|
||||
}
|
||||
if (FvInfo->RuntimeBaseAddress != 0) {
|
||||
Flags |= REBASE_RUNTIME_FILE;
|
||||
}
|
||||
|
||||
//
|
||||
// Don't Rebase this FFS.
|
||||
// Only copy the original map file into the FvMap file
|
||||
// for the image that is not required to be relocated.
|
||||
//
|
||||
XipBase = FvInfo->BaseAddress + XipOffset;
|
||||
|
||||
//
|
||||
// We only process files potentially containing PE32 sections.
|
||||
@@ -2749,6 +2828,16 @@ Returns:
|
||||
case EFI_FV_FILETYPE_DRIVER:
|
||||
case EFI_FV_FILETYPE_DXE_CORE:
|
||||
break;
|
||||
case EFI_FV_FILETYPE_FIRMWARE_VOLUME_IMAGE:
|
||||
//
|
||||
// Rebase the inside FvImage.
|
||||
//
|
||||
GetChildFvFromFfs (FvInfo, FfsFile, XipOffset);
|
||||
|
||||
//
|
||||
// Search PE/TE section in FV sectin.
|
||||
//
|
||||
break;
|
||||
default:
|
||||
return EFI_SUCCESS;
|
||||
}
|
||||
@@ -2809,13 +2898,6 @@ Returns:
|
||||
case EFI_FV_FILETYPE_PEI_CORE:
|
||||
case EFI_FV_FILETYPE_PEIM:
|
||||
case EFI_FV_FILETYPE_COMBINED_PEIM_DRIVER:
|
||||
if ((Flags & REBASE_XIP_FILE) == 0) {
|
||||
//
|
||||
// We aren't relocating XIP code, so skip it.
|
||||
//
|
||||
goto WritePeMap;
|
||||
}
|
||||
|
||||
//
|
||||
// Check if section-alignment and file-alignment match or not
|
||||
//
|
||||
@@ -2889,70 +2971,18 @@ Returns:
|
||||
|
||||
case EFI_FV_FILETYPE_DRIVER:
|
||||
case EFI_FV_FILETYPE_DXE_CORE:
|
||||
switch (ImgHdr->Pe32.OptionalHeader.Subsystem) {
|
||||
case EFI_IMAGE_SUBSYSTEM_EFI_RUNTIME_DRIVER:
|
||||
if ((Flags & REBASE_XIP_FILE) == REBASE_XIP_FILE) {
|
||||
//
|
||||
// Check if section-alignment and file-alignment match or not
|
||||
//
|
||||
if ((ImgHdr->Pe32.OptionalHeader.SectionAlignment != ImgHdr->Pe32.OptionalHeader.FileAlignment)) {
|
||||
//
|
||||
// Xip module has the same section alignment and file alignment.
|
||||
//
|
||||
Error (NULL, 0, 3000, "Invalid", "Section-Alignment and File-Alignment do not match : %s.", FileName);
|
||||
return EFI_ABORTED;
|
||||
}
|
||||
NewPe32BaseAddress = XipBase + (UINTN) CurrentPe32Section.Pe32Section + sizeof (EFI_PE32_SECTION) - (UINTN)FfsFile;
|
||||
BaseToUpdate = &XipBase;
|
||||
} else if ((Flags & REBASE_RUNTIME_FILE) == REBASE_RUNTIME_FILE) {
|
||||
//
|
||||
// make sure image base address at the section alignment
|
||||
//
|
||||
FvInfo->RuntimeBaseAddress = (FvInfo->RuntimeBaseAddress - ImageContext.ImageSize) & (~(ImageContext.SectionAlignment - 1));
|
||||
FvInfo->RuntimeBaseAddress = FvInfo->RuntimeBaseAddress & (~(EFI_PAGE_SIZE - 1));
|
||||
NewPe32BaseAddress = FvInfo->RuntimeBaseAddress;
|
||||
BaseToUpdate = &(FvInfo->RuntimeBaseAddress);
|
||||
} else {
|
||||
//
|
||||
// RT drivers aren't supposed to be relocated
|
||||
//
|
||||
goto WritePeMap;
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
//
|
||||
// We treat all other subsystems the same as BS_DRIVER
|
||||
//
|
||||
if ((Flags & REBASE_XIP_FILE) == REBASE_XIP_FILE) {
|
||||
//
|
||||
// Check if section-alignment and file-alignment match or not
|
||||
//
|
||||
if ((ImgHdr->Pe32.OptionalHeader.SectionAlignment != ImgHdr->Pe32.OptionalHeader.FileAlignment)) {
|
||||
//
|
||||
// Xip module has the same section alignment and file alignment.
|
||||
//
|
||||
Error (NULL, 0, 3000, "Invalid", "Section-Alignment and File-Alignment do not match : %s.", FileName);
|
||||
return EFI_ABORTED;
|
||||
}
|
||||
NewPe32BaseAddress = XipBase + (UINTN) CurrentPe32Section.Pe32Section + sizeof (EFI_PE32_SECTION) - (UINTN)FfsFile;
|
||||
BaseToUpdate = &XipBase;
|
||||
} else if ((Flags & REBASE_BOOTTIME_FILE) == REBASE_BOOTTIME_FILE) {
|
||||
//
|
||||
// make sure image base address at the Section and Page alignment
|
||||
//
|
||||
FvInfo->BootBaseAddress = (FvInfo->BootBaseAddress - ImageContext.ImageSize) & (~(ImageContext.SectionAlignment - 1));
|
||||
FvInfo->BootBaseAddress = FvInfo->BootBaseAddress & (~(EFI_PAGE_SIZE - 1));
|
||||
NewPe32BaseAddress = FvInfo->BootBaseAddress;
|
||||
BaseToUpdate = &(FvInfo->BootBaseAddress);
|
||||
} else {
|
||||
//
|
||||
// Skip all BS_DRIVER's
|
||||
//
|
||||
goto WritePeMap;
|
||||
}
|
||||
break;
|
||||
//
|
||||
// Check if section-alignment and file-alignment match or not
|
||||
//
|
||||
if ((ImgHdr->Pe32.OptionalHeader.SectionAlignment != ImgHdr->Pe32.OptionalHeader.FileAlignment)) {
|
||||
//
|
||||
// Xip module has the same section alignment and file alignment.
|
||||
//
|
||||
Error (NULL, 0, 3000, "Invalid", "Section-Alignment and File-Alignment do not match : %s.", FileName);
|
||||
return EFI_ABORTED;
|
||||
}
|
||||
NewPe32BaseAddress = XipBase + (UINTN) CurrentPe32Section.Pe32Section + sizeof (EFI_PE32_SECTION) - (UINTN)FfsFile;
|
||||
BaseToUpdate = &XipBase;
|
||||
break;
|
||||
|
||||
default:
|
||||
@@ -2962,69 +2992,75 @@ Returns:
|
||||
return EFI_SUCCESS;
|
||||
}
|
||||
|
||||
//
|
||||
// Relocation doesn't exist
|
||||
//
|
||||
if (ImageContext.RelocationsStripped) {
|
||||
Warning (NULL, 0, 0, "Invalid", "The file %s has no .reloc section.", FileName);
|
||||
continue;
|
||||
}
|
||||
|
||||
//
|
||||
// Relocation exist and rebase
|
||||
//
|
||||
if (!ImageContext.RelocationsStripped) {
|
||||
//
|
||||
// Load and Relocate Image Data
|
||||
//
|
||||
MemoryImagePointer = (UINT8 *) malloc ((UINTN) ImageContext.ImageSize + ImageContext.SectionAlignment);
|
||||
if (MemoryImagePointer == NULL) {
|
||||
Error (NULL, 0, 4001, "Resource", "memory cannot be allocated on rebase of %s", FileName);
|
||||
return EFI_OUT_OF_RESOURCES;
|
||||
}
|
||||
memset ((VOID *) MemoryImagePointer, 0, (UINTN) ImageContext.ImageSize + ImageContext.SectionAlignment);
|
||||
ImageContext.ImageAddress = ((UINTN) MemoryImagePointer + ImageContext.SectionAlignment - 1) & (~((INT64)ImageContext.SectionAlignment - 1));
|
||||
|
||||
Status = PeCoffLoaderLoadImage (&ImageContext);
|
||||
if (EFI_ERROR (Status)) {
|
||||
Error (NULL, 0, 3000, "Invalid", "LocateImage() call failed on rebase of %s", FileName);
|
||||
free ((VOID *) MemoryImagePointer);
|
||||
return Status;
|
||||
}
|
||||
|
||||
ImageContext.DestinationAddress = NewPe32BaseAddress;
|
||||
Status = PeCoffLoaderRelocateImage (&ImageContext);
|
||||
if (EFI_ERROR (Status)) {
|
||||
Error (NULL, 0, 3000, "Invalid", "RelocateImage() call failed on rebase of %s", FileName);
|
||||
free ((VOID *) MemoryImagePointer);
|
||||
return Status;
|
||||
}
|
||||
|
||||
//
|
||||
// Copy Relocated data to raw image file.
|
||||
//
|
||||
SectionHeader = (EFI_IMAGE_SECTION_HEADER *) (
|
||||
(UINTN) ImgHdr +
|
||||
sizeof (UINT32) +
|
||||
sizeof (EFI_IMAGE_FILE_HEADER) +
|
||||
ImgHdr->Pe32.FileHeader.SizeOfOptionalHeader
|
||||
);
|
||||
|
||||
for (Index = 0; Index < ImgHdr->Pe32.FileHeader.NumberOfSections; Index ++, SectionHeader ++) {
|
||||
CopyMem (
|
||||
(UINT8 *) CurrentPe32Section.Pe32Section + sizeof (EFI_COMMON_SECTION_HEADER) + SectionHeader->PointerToRawData,
|
||||
(VOID*) (UINTN) (ImageContext.ImageAddress + SectionHeader->VirtualAddress),
|
||||
SectionHeader->SizeOfRawData
|
||||
);
|
||||
}
|
||||
|
||||
//
|
||||
// Load and Relocate Image Data
|
||||
//
|
||||
MemoryImagePointer = (UINT8 *) malloc ((UINTN) ImageContext.ImageSize + ImageContext.SectionAlignment);
|
||||
if (MemoryImagePointer == NULL) {
|
||||
Error (NULL, 0, 4001, "Resource", "memory cannot be allocated on rebase of %s", FileName);
|
||||
return EFI_OUT_OF_RESOURCES;
|
||||
}
|
||||
memset ((VOID *) MemoryImagePointer, 0, (UINTN) ImageContext.ImageSize + ImageContext.SectionAlignment);
|
||||
ImageContext.ImageAddress = ((UINTN) MemoryImagePointer + ImageContext.SectionAlignment - 1) & (~((INT64)ImageContext.SectionAlignment - 1));
|
||||
|
||||
Status = PeCoffLoaderLoadImage (&ImageContext);
|
||||
if (EFI_ERROR (Status)) {
|
||||
Error (NULL, 0, 3000, "Invalid", "LocateImage() call failed on rebase of %s", FileName);
|
||||
free ((VOID *) MemoryImagePointer);
|
||||
MemoryImagePointer = NULL;
|
||||
if (PeFileBuffer != NULL) {
|
||||
free (PeFileBuffer);
|
||||
PeFileBuffer = NULL;
|
||||
}
|
||||
return Status;
|
||||
}
|
||||
|
||||
ImageContext.DestinationAddress = NewPe32BaseAddress;
|
||||
Status = PeCoffLoaderRelocateImage (&ImageContext);
|
||||
if (EFI_ERROR (Status)) {
|
||||
Error (NULL, 0, 3000, "Invalid", "RelocateImage() call failed on rebase of %s", FileName);
|
||||
free ((VOID *) MemoryImagePointer);
|
||||
return Status;
|
||||
}
|
||||
|
||||
//
|
||||
// Copy Relocated data to raw image file.
|
||||
//
|
||||
SectionHeader = (EFI_IMAGE_SECTION_HEADER *) (
|
||||
(UINTN) ImgHdr +
|
||||
sizeof (UINT32) +
|
||||
sizeof (EFI_IMAGE_FILE_HEADER) +
|
||||
ImgHdr->Pe32.FileHeader.SizeOfOptionalHeader
|
||||
);
|
||||
|
||||
for (Index = 0; Index < ImgHdr->Pe32.FileHeader.NumberOfSections; Index ++, SectionHeader ++) {
|
||||
CopyMem (
|
||||
(UINT8 *) CurrentPe32Section.Pe32Section + sizeof (EFI_COMMON_SECTION_HEADER) + SectionHeader->PointerToRawData,
|
||||
(VOID*) (UINTN) (ImageContext.ImageAddress + SectionHeader->VirtualAddress),
|
||||
SectionHeader->SizeOfRawData
|
||||
);
|
||||
}
|
||||
|
||||
free ((VOID *) MemoryImagePointer);
|
||||
MemoryImagePointer = NULL;
|
||||
if (PeFileBuffer != NULL) {
|
||||
free (PeFileBuffer);
|
||||
PeFileBuffer = NULL;
|
||||
}
|
||||
|
||||
//
|
||||
// Update Image Base Address
|
||||
//
|
||||
if (ImgHdr->Pe32.OptionalHeader.Magic == EFI_IMAGE_NT_OPTIONAL_HDR32_MAGIC) {
|
||||
ImgHdr->Pe32.OptionalHeader.ImageBase = (UINT32) NewPe32BaseAddress;
|
||||
ImgHdr->Pe32.OptionalHeader.ImageBase = (UINT32) NewPe32BaseAddress;
|
||||
} else if (ImgHdr->Pe32Plus.OptionalHeader.Magic == EFI_IMAGE_NT_OPTIONAL_HDR64_MAGIC) {
|
||||
ImgHdr->Pe32Plus.OptionalHeader.ImageBase = NewPe32BaseAddress;
|
||||
ImgHdr->Pe32Plus.OptionalHeader.ImageBase = NewPe32BaseAddress;
|
||||
} else {
|
||||
Error (NULL, 0, 3000, "Invalid", "unknown PE magic signature %X in PE32 image %s",
|
||||
ImgHdr->Pe32.OptionalHeader.Magic,
|
||||
@@ -3033,11 +3069,6 @@ Returns:
|
||||
return EFI_ABORTED;
|
||||
}
|
||||
|
||||
//
|
||||
// Update BASE address by add one page size.
|
||||
//
|
||||
*BaseToUpdate -= EFI_PAGE_SIZE;
|
||||
|
||||
//
|
||||
// Now update file checksum
|
||||
//
|
||||
@@ -3055,7 +3086,7 @@ Returns:
|
||||
//
|
||||
// Get this module function address from ModulePeMapFile and add them into FvMap file
|
||||
//
|
||||
WritePeMap:
|
||||
|
||||
//
|
||||
// Default use FileName as map file path
|
||||
//
|
||||
@@ -3069,7 +3100,8 @@ WritePeMap:
|
||||
if (FfsFile->Type != EFI_FV_FILETYPE_SECURITY_CORE &&
|
||||
FfsFile->Type != EFI_FV_FILETYPE_PEI_CORE &&
|
||||
FfsFile->Type != EFI_FV_FILETYPE_PEIM &&
|
||||
FfsFile->Type != EFI_FV_FILETYPE_COMBINED_PEIM_DRIVER
|
||||
FfsFile->Type != EFI_FV_FILETYPE_COMBINED_PEIM_DRIVER &&
|
||||
FfsFile->Type != EFI_FV_FILETYPE_FIRMWARE_VOLUME_IMAGE
|
||||
) {
|
||||
//
|
||||
// Only Peim code may have a TE section
|
||||
@@ -3122,13 +3154,6 @@ WritePeMap:
|
||||
// Get File PdbPointer
|
||||
//
|
||||
PdbPointer = PeCoffLoaderGetPdbPointer (ImageContext.Handle);
|
||||
|
||||
if ((Flags & REBASE_XIP_FILE) == 0) {
|
||||
//
|
||||
// For none XIP PEIM module, their map info also are collected.
|
||||
//
|
||||
goto WriteTeMap;
|
||||
}
|
||||
|
||||
//
|
||||
// Set new rebased address.
|
||||
@@ -3139,7 +3164,7 @@ WritePeMap:
|
||||
//
|
||||
// if reloc is stripped, try to get the original efi image to get reloc info.
|
||||
//
|
||||
if (ImageContext.RelocationsStripped == TRUE) {
|
||||
if (ImageContext.RelocationsStripped) {
|
||||
//
|
||||
// Construct the original efi file name
|
||||
//
|
||||
@@ -3194,70 +3219,75 @@ WritePeMap:
|
||||
ImageContext.RelocationsStripped = FALSE;
|
||||
}
|
||||
}
|
||||
//
|
||||
// Relocation doesn't exist
|
||||
//
|
||||
if (ImageContext.RelocationsStripped) {
|
||||
Warning (NULL, 0, 0, "Invalid", "The file %s has no .reloc section.", FileName);
|
||||
continue;
|
||||
}
|
||||
|
||||
//
|
||||
// Relocation exist and rebase
|
||||
//
|
||||
if (!ImageContext.RelocationsStripped) {
|
||||
//
|
||||
// Load and Relocate Image Data
|
||||
//
|
||||
MemoryImagePointer = (UINT8 *) malloc ((UINTN) ImageContext.ImageSize + ImageContext.SectionAlignment);
|
||||
if (MemoryImagePointer == NULL) {
|
||||
Error (NULL, 0, 4001, "Resource", "memory cannot be allocated on rebase of %s", FileName);
|
||||
return EFI_OUT_OF_RESOURCES;
|
||||
}
|
||||
memset ((VOID *) MemoryImagePointer, 0, (UINTN) ImageContext.ImageSize + ImageContext.SectionAlignment);
|
||||
ImageContext.ImageAddress = ((UINTN) MemoryImagePointer + ImageContext.SectionAlignment - 1) & (~(ImageContext.SectionAlignment - 1));
|
||||
|
||||
Status = PeCoffLoaderLoadImage (&ImageContext);
|
||||
if (EFI_ERROR (Status)) {
|
||||
Error (NULL, 0, 3000, "Invalid", "LocateImage() call failed on rebase of %s", FileName);
|
||||
free ((VOID *) MemoryImagePointer);
|
||||
return Status;
|
||||
}
|
||||
//
|
||||
// Reloacate TeImage
|
||||
//
|
||||
ImageContext.DestinationAddress = NewPe32BaseAddress;
|
||||
Status = PeCoffLoaderRelocateImage (&ImageContext);
|
||||
if (EFI_ERROR (Status)) {
|
||||
Error (NULL, 0, 3000, "Invalid", "RelocateImage() call failed on rebase of TE image %s", FileName);
|
||||
free ((VOID *) MemoryImagePointer);
|
||||
return Status;
|
||||
}
|
||||
|
||||
//
|
||||
// Copy the relocated image into raw image file.
|
||||
//
|
||||
SectionHeader = (EFI_IMAGE_SECTION_HEADER *) (TEImageHeader + 1);
|
||||
for (Index = 0; Index < TEImageHeader->NumberOfSections; Index ++, SectionHeader ++) {
|
||||
if (!ImageContext.IsTeImage) {
|
||||
CopyMem (
|
||||
(UINT8 *) TEImageHeader + sizeof (EFI_TE_IMAGE_HEADER) - TEImageHeader->StrippedSize + SectionHeader->PointerToRawData,
|
||||
(VOID*) (UINTN) (ImageContext.ImageAddress + SectionHeader->VirtualAddress),
|
||||
SectionHeader->SizeOfRawData
|
||||
);
|
||||
} else {
|
||||
CopyMem (
|
||||
(UINT8 *) TEImageHeader + sizeof (EFI_TE_IMAGE_HEADER) - TEImageHeader->StrippedSize + SectionHeader->PointerToRawData,
|
||||
(VOID*) (UINTN) (ImageContext.ImageAddress + sizeof (EFI_TE_IMAGE_HEADER) - TEImageHeader->StrippedSize + SectionHeader->VirtualAddress),
|
||||
SectionHeader->SizeOfRawData
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
// Free the allocated memory resource
|
||||
//
|
||||
//
|
||||
// Load and Relocate Image Data
|
||||
//
|
||||
MemoryImagePointer = (UINT8 *) malloc ((UINTN) ImageContext.ImageSize + ImageContext.SectionAlignment);
|
||||
if (MemoryImagePointer == NULL) {
|
||||
Error (NULL, 0, 4001, "Resource", "memory cannot be allocated on rebase of %s", FileName);
|
||||
return EFI_OUT_OF_RESOURCES;
|
||||
}
|
||||
memset ((VOID *) MemoryImagePointer, 0, (UINTN) ImageContext.ImageSize + ImageContext.SectionAlignment);
|
||||
ImageContext.ImageAddress = ((UINTN) MemoryImagePointer + ImageContext.SectionAlignment - 1) & (~(ImageContext.SectionAlignment - 1));
|
||||
|
||||
Status = PeCoffLoaderLoadImage (&ImageContext);
|
||||
if (EFI_ERROR (Status)) {
|
||||
Error (NULL, 0, 3000, "Invalid", "LocateImage() call failed on rebase of %s", FileName);
|
||||
free ((VOID *) MemoryImagePointer);
|
||||
MemoryImagePointer = NULL;
|
||||
if (PeFileBuffer != NULL) {
|
||||
free (PeFileBuffer);
|
||||
PeFileBuffer = NULL;
|
||||
return Status;
|
||||
}
|
||||
//
|
||||
// Reloacate TeImage
|
||||
//
|
||||
ImageContext.DestinationAddress = NewPe32BaseAddress;
|
||||
Status = PeCoffLoaderRelocateImage (&ImageContext);
|
||||
if (EFI_ERROR (Status)) {
|
||||
Error (NULL, 0, 3000, "Invalid", "RelocateImage() call failed on rebase of TE image %s", FileName);
|
||||
free ((VOID *) MemoryImagePointer);
|
||||
return Status;
|
||||
}
|
||||
|
||||
//
|
||||
// Copy the relocated image into raw image file.
|
||||
//
|
||||
SectionHeader = (EFI_IMAGE_SECTION_HEADER *) (TEImageHeader + 1);
|
||||
for (Index = 0; Index < TEImageHeader->NumberOfSections; Index ++, SectionHeader ++) {
|
||||
if (!ImageContext.IsTeImage) {
|
||||
CopyMem (
|
||||
(UINT8 *) TEImageHeader + sizeof (EFI_TE_IMAGE_HEADER) - TEImageHeader->StrippedSize + SectionHeader->PointerToRawData,
|
||||
(VOID*) (UINTN) (ImageContext.ImageAddress + SectionHeader->VirtualAddress),
|
||||
SectionHeader->SizeOfRawData
|
||||
);
|
||||
} else {
|
||||
CopyMem (
|
||||
(UINT8 *) TEImageHeader + sizeof (EFI_TE_IMAGE_HEADER) - TEImageHeader->StrippedSize + SectionHeader->PointerToRawData,
|
||||
(VOID*) (UINTN) (ImageContext.ImageAddress + sizeof (EFI_TE_IMAGE_HEADER) - TEImageHeader->StrippedSize + SectionHeader->VirtualAddress),
|
||||
SectionHeader->SizeOfRawData
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
// Free the allocated memory resource
|
||||
//
|
||||
free ((VOID *) MemoryImagePointer);
|
||||
MemoryImagePointer = NULL;
|
||||
if (PeFileBuffer != NULL) {
|
||||
free (PeFileBuffer);
|
||||
PeFileBuffer = NULL;
|
||||
}
|
||||
|
||||
//
|
||||
// Update Image Base Address
|
||||
//
|
||||
@@ -3279,7 +3309,7 @@ WritePeMap:
|
||||
//
|
||||
// Get this module function address from ModulePeMapFile and add them into FvMap file
|
||||
//
|
||||
WriteTeMap:
|
||||
|
||||
//
|
||||
// Default use FileName as map file path
|
||||
//
|
||||
|
@@ -1,6 +1,6 @@
|
||||
/** @file
|
||||
|
||||
Copyright (c) 2004 - 2008, Intel Corporation
|
||||
Copyright (c) 2004 - 2010, 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
|
||||
@@ -67,6 +67,7 @@ Abstract:
|
||||
#define OPTIONS_SECTION_STRING "[options]"
|
||||
#define ATTRIBUTES_SECTION_STRING "[attributes]"
|
||||
#define FILES_SECTION_STRING "[files]"
|
||||
#define FV_BASE_ADDRESS_STRING "[FV_BASE_ADDRESS]"
|
||||
|
||||
//
|
||||
// Options section
|
||||
@@ -82,8 +83,6 @@ Abstract:
|
||||
#define EFI_CAPSULE_HEADER_SIZE_STRING "EFI_CAPSULE_HEADER_SIZE"
|
||||
#define EFI_CAPSULE_FLAGS_STRING "EFI_CAPSULE_FLAGS"
|
||||
#define EFI_CAPSULE_VERSION_STRING "EFI_CAPSULE_VERSION"
|
||||
#define EFI_FV_BOOT_DRIVER_BASE_ADDRESS_STRING "EFI_BOOT_DRIVER_BASE_ADDRESS"
|
||||
#define EFI_FV_RUNTIME_DRIVER_BASE_ADDRESS_STRING "EFI_RUNTIME_DRIVER_BASE_ADDRESS"
|
||||
|
||||
#define EFI_FV_TOTAL_SIZE_STRING "EFI_FV_TOTAL_SIZE"
|
||||
#define EFI_FV_TAKEN_SIZE_STRING "EFI_FV_TAKEN_SIZE"
|
||||
@@ -204,13 +203,6 @@ Abstract:
|
||||
#define FIT_TYPE_MASK 0x7F
|
||||
#define CHECKSUM_BIT_MASK 0x80
|
||||
|
||||
//
|
||||
// Rebase File type
|
||||
//
|
||||
#define REBASE_XIP_FILE 0x1
|
||||
#define REBASE_BOOTTIME_FILE 0x2
|
||||
#define REBASE_RUNTIME_FILE 0x4
|
||||
|
||||
//
|
||||
// Private data types
|
||||
//
|
||||
@@ -228,8 +220,6 @@ typedef struct {
|
||||
typedef struct {
|
||||
BOOLEAN BaseAddressSet;
|
||||
EFI_PHYSICAL_ADDRESS BaseAddress;
|
||||
EFI_PHYSICAL_ADDRESS BootBaseAddress;
|
||||
EFI_PHYSICAL_ADDRESS RuntimeBaseAddress;
|
||||
EFI_GUID FvFileSystemGuid;
|
||||
BOOLEAN FvFileSystemGuidSet;
|
||||
EFI_GUID FvNameGuid;
|
||||
@@ -270,6 +260,9 @@ extern CAP_INFO mCapDataInfo;
|
||||
extern EFI_GUID mEfiFirmwareFileSystem2Guid;
|
||||
extern UINT32 mFvTotalSize;
|
||||
extern UINT32 mFvTakenSize;
|
||||
|
||||
extern EFI_PHYSICAL_ADDRESS mFvBaseAddress[];
|
||||
extern UINT32 mFvBaseAddressNumber;
|
||||
//
|
||||
// Local function prototypes
|
||||
//
|
||||
|
File diff suppressed because it is too large
Load Diff
@@ -1,3 +1,17 @@
|
||||
/** @file
|
||||
Ported ELF include files from FreeBSD
|
||||
|
||||
Copyright (c) 2009 - 2010, Apple, Inc. All rights reserved.
|
||||
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
|
||||
http://opensource.org/licenses/bsd-license.php
|
||||
|
||||
THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
|
||||
|
||||
|
||||
**/
|
||||
/*-
|
||||
* Copyright (c) 1996-1998 John D. Polstra.
|
||||
* All rights reserved.
|
||||
|
@@ -1,3 +1,16 @@
|
||||
/** @file
|
||||
Ported ELF include files from FreeBSD
|
||||
|
||||
Copyright (c) 2009 - 2010, Apple, Inc. All rights reserved.
|
||||
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
|
||||
http://opensource.org/licenses/bsd-license.php
|
||||
|
||||
THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
|
||||
|
||||
**/
|
||||
/*-
|
||||
* Copyright (c) 1996-1998 John D. Polstra.
|
||||
* All rights reserved.
|
||||
|
@@ -1,3 +1,17 @@
|
||||
/** @file
|
||||
Ported ELF include files from FreeBSD
|
||||
|
||||
Copyright (c) 2009 - 2010, Apple, Inc. All rights reserved.
|
||||
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
|
||||
http://opensource.org/licenses/bsd-license.php
|
||||
|
||||
THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
|
||||
|
||||
|
||||
**/
|
||||
/*-
|
||||
* Copyright (c) 1998 John D. Polstra.
|
||||
* All rights reserved.
|
||||
|
@@ -1,6 +1,6 @@
|
||||
/** @file
|
||||
|
||||
Copyright 2006 - 2008, Intel Corporation
|
||||
Copyright 2006 - 2010, 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
|
||||
@@ -92,7 +92,7 @@ Returns:
|
||||
--*/
|
||||
{
|
||||
printf ("%s v%d.%d -Utility to generate the EfiLoader image containing page table.\n", UTILITY_NAME, UTILITY_MAJOR_VERSION, UTILITY_MINOR_VERSION);
|
||||
printf ("Copyright (c) 2008 - 2009 Intel Corporation. All rights reserved.\n");
|
||||
printf ("Copyright (c) 2008 - 2010 Intel Corporation. All rights reserved.\n");
|
||||
}
|
||||
|
||||
VOID
|
||||
|
@@ -1,6 +1,6 @@
|
||||
/** @file
|
||||
|
||||
Copyright (c) 2004 - 2008, Intel Corporation
|
||||
Copyright (c) 2004 - 2010, 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
|
||||
@@ -27,6 +27,7 @@ Abstract:
|
||||
#include <Common/UefiBaseTypes.h>
|
||||
#include <Common/PiFirmwareFile.h>
|
||||
#include <Protocol/GuidedSectionExtraction.h>
|
||||
#include <IndustryStandard/PeImage.h>
|
||||
|
||||
#include "CommonLib.h"
|
||||
#include "Compress.h"
|
||||
@@ -80,6 +81,11 @@ STATIC CHAR8 *mCompressionTypeName[] = { "PI_NONE", "PI_STD" };
|
||||
#define EFI_GUIDED_SECTION_NONE 0x80
|
||||
STATIC CHAR8 *mGUIDedSectionAttribue[] = { "NONE", "PROCESSING_REQUIRED", "AUTH_STATUS_VALID"};
|
||||
|
||||
STATIC CHAR8 *mAlignName[] = {
|
||||
"1", "2", "4", "8", "16", "32", "64", "128", "256", "512",
|
||||
"1K", "2K", "4K", "8K", "16K", "32K", "64K"
|
||||
};
|
||||
|
||||
//
|
||||
// Crc32 GUID section related definitions.
|
||||
//
|
||||
@@ -144,7 +150,7 @@ Returns:
|
||||
//
|
||||
// Copyright declaration
|
||||
//
|
||||
fprintf (stdout, "Copyright (c) 2007, Intel Corporation. All rights reserved.\n\n");
|
||||
fprintf (stdout, "Copyright (c) 2007 - 2010, Intel Corporation. All rights reserved.\n\n");
|
||||
|
||||
//
|
||||
// Details Option
|
||||
@@ -180,6 +186,10 @@ Returns:
|
||||
fprintf (stdout, " -j Number, --buildnumber Number\n\
|
||||
Number is an integer value between 0000 and 9999\n\
|
||||
used in Ver section.\n");
|
||||
fprintf (stdout, " --sectionalign SectionAlign\n\
|
||||
SectionAlign points to section alignment, which support\n\
|
||||
the alignment scope 1~64K. It is specified in same\n\
|
||||
order that the section file is input.\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");
|
||||
@@ -329,9 +339,50 @@ Done:
|
||||
return Status;
|
||||
}
|
||||
|
||||
STATIC
|
||||
EFI_STATUS
|
||||
StringtoAlignment (
|
||||
IN CHAR8 *AlignBuffer,
|
||||
OUT UINT32 *AlignNumber
|
||||
)
|
||||
/*++
|
||||
|
||||
Routine Description:
|
||||
|
||||
Converts Align String to align value (1~64K).
|
||||
|
||||
Arguments:
|
||||
|
||||
AlignBuffer - Pointer to Align string.
|
||||
AlignNumber - Pointer to Align value.
|
||||
|
||||
Returns:
|
||||
|
||||
EFI_SUCCESS Successfully convert align string to align value.
|
||||
EFI_INVALID_PARAMETER Align string is invalid or align value is not in scope.
|
||||
|
||||
--*/
|
||||
{
|
||||
UINT32 Index = 0;
|
||||
//
|
||||
// Check AlignBuffer
|
||||
//
|
||||
if (AlignBuffer == NULL) {
|
||||
return EFI_INVALID_PARAMETER;
|
||||
}
|
||||
for (Index = 0; Index < sizeof (mAlignName) / sizeof (CHAR8 *); Index ++) {
|
||||
if (stricmp (AlignBuffer, mAlignName [Index]) == 0) {
|
||||
*AlignNumber = 1 << Index;
|
||||
return EFI_SUCCESS;
|
||||
}
|
||||
}
|
||||
return EFI_INVALID_PARAMETER;
|
||||
}
|
||||
|
||||
EFI_STATUS
|
||||
GetSectionContents (
|
||||
CHAR8 **InputFileName,
|
||||
UINT32 *InputFileAlign,
|
||||
UINT32 InputFileNum,
|
||||
UINT8 *FileBuffer,
|
||||
UINT32 *BufferLength
|
||||
@@ -346,7 +397,9 @@ Routine Description:
|
||||
Arguments:
|
||||
|
||||
InputFileName - Name of the input file.
|
||||
|
||||
|
||||
InputFileAlign - Alignment required by the input file data.
|
||||
|
||||
InputFileNum - Number of input files. Should be at least 1.
|
||||
|
||||
FileBuffer - Output buffer to contain data
|
||||
@@ -362,10 +415,17 @@ Returns:
|
||||
EFI_BUFFER_TOO_SMALL FileBuffer is not enough to contain all file data.
|
||||
--*/
|
||||
{
|
||||
UINT32 Size;
|
||||
UINT32 FileSize;
|
||||
UINT32 Index;
|
||||
FILE *InFile;
|
||||
UINT32 Size;
|
||||
UINT32 Offset;
|
||||
UINT32 FileSize;
|
||||
UINT32 Index;
|
||||
FILE *InFile;
|
||||
EFI_COMMON_SECTION_HEADER *SectHeader;
|
||||
EFI_COMMON_SECTION_HEADER TempSectHeader;
|
||||
EFI_TE_IMAGE_HEADER TeHeader;
|
||||
UINT32 TeOffset;
|
||||
EFI_GUID_DEFINED_SECTION GuidSectHeader;
|
||||
UINT32 HeaderSize;
|
||||
|
||||
if (InputFileNum < 1) {
|
||||
Error (NULL, 0, 2000, "Invalid paramter", "must specify at least one input file");
|
||||
@@ -377,7 +437,9 @@ Returns:
|
||||
return EFI_INVALID_PARAMETER;
|
||||
}
|
||||
|
||||
Size = 0;
|
||||
Size = 0;
|
||||
Offset = 0;
|
||||
TeOffset = 0;
|
||||
//
|
||||
// Go through our array of file names and copy their contents
|
||||
// to the output buffer.
|
||||
@@ -406,11 +468,66 @@ Returns:
|
||||
FileSize = ftell (InFile);
|
||||
fseek (InFile, 0, SEEK_SET);
|
||||
DebugMsg (NULL, 0, 9, "Input files", "the input file name is %s and the size is %u bytes", InputFileName[Index], (unsigned) FileSize);
|
||||
//
|
||||
// Adjust section buffer when section alignment is required.
|
||||
//
|
||||
if (InputFileAlign != NULL) {
|
||||
//
|
||||
// Check this section is Te/Pe section, and Calculate the numbers of Te/Pe section.
|
||||
//
|
||||
TeOffset = 0;
|
||||
HeaderSize = sizeof (EFI_COMMON_SECTION_HEADER);
|
||||
fread (&TempSectHeader, 1, sizeof (TempSectHeader), InFile);
|
||||
if (TempSectHeader.Type == EFI_SECTION_TE) {
|
||||
fread (&TeHeader, 1, sizeof (TeHeader), InFile);
|
||||
if (TeHeader.Signature == EFI_TE_IMAGE_HEADER_SIGNATURE) {
|
||||
TeOffset = TeHeader.StrippedSize - sizeof (TeHeader);
|
||||
}
|
||||
} else if (TempSectHeader.Type == EFI_SECTION_GUID_DEFINED) {
|
||||
fseek (InFile, 0, SEEK_SET);
|
||||
fread (&GuidSectHeader, 1, sizeof (GuidSectHeader), InFile);
|
||||
if ((GuidSectHeader.Attributes & EFI_GUIDED_SECTION_PROCESSING_REQUIRED) == 0) {
|
||||
HeaderSize = GuidSectHeader.DataOffset;
|
||||
}
|
||||
}
|
||||
|
||||
fseek (InFile, 0, SEEK_SET);
|
||||
|
||||
//
|
||||
// Revert TeOffset to the converse value relative to Alignment
|
||||
// This is to assure the original PeImage Header at Alignment.
|
||||
//
|
||||
if (TeOffset != 0) {
|
||||
TeOffset = InputFileAlign [Index] - (TeOffset % InputFileAlign [Index]);
|
||||
TeOffset = TeOffset % InputFileAlign [Index];
|
||||
}
|
||||
|
||||
//
|
||||
// make sure section data meet its alignment requirement by adding one raw pad section.
|
||||
//
|
||||
if ((InputFileAlign [Index] != 0) && (((Size + HeaderSize + TeOffset) % InputFileAlign [Index]) != 0)) {
|
||||
Offset = (Size + sizeof (EFI_COMMON_SECTION_HEADER) + HeaderSize + TeOffset + InputFileAlign [Index] - 1) & ~(InputFileAlign [Index] - 1);
|
||||
Offset = Offset - Size - HeaderSize - TeOffset;
|
||||
|
||||
if (FileBuffer != NULL && ((Size + Offset) < *BufferLength)) {
|
||||
memset (FileBuffer + Size, 0, Offset);
|
||||
SectHeader = (EFI_COMMON_SECTION_HEADER *) (FileBuffer + Size);
|
||||
SectHeader->Type = EFI_SECTION_RAW;
|
||||
SectHeader->Size[0] = (UINT8) (Offset & 0xff);
|
||||
SectHeader->Size[1] = (UINT8) ((Offset & 0xff00) >> 8);
|
||||
SectHeader->Size[2] = (UINT8) ((Offset & 0xff0000) >> 16);
|
||||
}
|
||||
DebugMsg (NULL, 0, 9, "Pad raw section for section data alignment", "Pad Raw section size is %u", (unsigned) Offset);
|
||||
|
||||
Size = Size + Offset;
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
// Now read the contents of the file into the buffer
|
||||
// Buffer must be enough to contain the file content.
|
||||
//
|
||||
if (FileSize > 0 && FileBuffer != NULL && (Size + FileSize) <= *BufferLength) {
|
||||
if ((FileSize > 0) && (FileBuffer != NULL) && ((Size + FileSize) <= *BufferLength)) {
|
||||
if (fread (FileBuffer + Size, (size_t) FileSize, 1, InFile) != 1) {
|
||||
Error (NULL, 0, 0004, "Error reading file", InputFileName[Index]);
|
||||
fclose (InFile);
|
||||
@@ -437,6 +554,7 @@ Returns:
|
||||
EFI_STATUS
|
||||
GenSectionCompressionSection (
|
||||
CHAR8 **InputFileName,
|
||||
UINT32 *InputFileAlign,
|
||||
UINT32 InputFileNum,
|
||||
UINT8 SectCompSubType,
|
||||
UINT8 **OutFileBuffer
|
||||
@@ -453,7 +571,9 @@ Routine Description:
|
||||
Arguments:
|
||||
|
||||
InputFileName - Name of the input file.
|
||||
|
||||
|
||||
InputFileAlign - Alignment required by the input file data.
|
||||
|
||||
InputFileNum - Number of input files. Should be at least 1.
|
||||
|
||||
SectCompSubType - Specify the compression algorithm requested.
|
||||
@@ -487,6 +607,7 @@ Returns:
|
||||
//
|
||||
Status = GetSectionContents (
|
||||
InputFileName,
|
||||
InputFileAlign,
|
||||
InputFileNum,
|
||||
FileBuffer,
|
||||
&InputLength
|
||||
@@ -503,6 +624,7 @@ Returns:
|
||||
//
|
||||
Status = GetSectionContents (
|
||||
InputFileName,
|
||||
InputFileAlign,
|
||||
InputFileNum,
|
||||
FileBuffer,
|
||||
&InputLength
|
||||
@@ -524,6 +646,16 @@ Returns:
|
||||
switch (SectCompSubType) {
|
||||
case EFI_NOT_COMPRESSED:
|
||||
CompressedLength = InputLength;
|
||||
//
|
||||
// Copy file buffer to the none compressed data.
|
||||
//
|
||||
OutputBuffer = malloc (CompressedLength + sizeof (EFI_COMPRESSION_SECTION));
|
||||
if (OutputBuffer == NULL) {
|
||||
free (FileBuffer);
|
||||
return EFI_OUT_OF_RESOURCES;
|
||||
}
|
||||
memcpy (OutputBuffer + sizeof (EFI_COMPRESSION_SECTION), FileBuffer, CompressedLength);
|
||||
FileBuffer = OutputBuffer;
|
||||
break;
|
||||
|
||||
case EFI_STANDARD_COMPRESSION:
|
||||
@@ -599,6 +731,7 @@ Returns:
|
||||
EFI_STATUS
|
||||
GenSectionGuidDefinedSection (
|
||||
CHAR8 **InputFileName,
|
||||
UINT32 *InputFileAlign,
|
||||
UINT32 InputFileNum,
|
||||
EFI_GUID *VendorGuid,
|
||||
UINT16 DataAttribute,
|
||||
@@ -618,6 +751,8 @@ Arguments:
|
||||
|
||||
InputFileName - Name of the input file.
|
||||
|
||||
InputFileAlign - Alignment required by the input file data.
|
||||
|
||||
InputFileNum - Number of input files. Should be at least 1.
|
||||
|
||||
VendorGuid - Specify vendor guid value.
|
||||
@@ -662,6 +797,7 @@ Returns:
|
||||
//
|
||||
Status = GetSectionContents (
|
||||
InputFileName,
|
||||
InputFileAlign,
|
||||
InputFileNum,
|
||||
FileBuffer,
|
||||
&InputLength
|
||||
@@ -678,6 +814,7 @@ Returns:
|
||||
//
|
||||
Status = GetSectionContents (
|
||||
InputFileName,
|
||||
InputFileAlign,
|
||||
InputFileNum,
|
||||
FileBuffer + Offset,
|
||||
&InputLength
|
||||
@@ -797,7 +934,11 @@ Returns:
|
||||
UINT8 *OutFileBuffer;
|
||||
EFI_STATUS Status;
|
||||
UINT64 LogLevel;
|
||||
|
||||
UINT32 *InputFileAlign;
|
||||
UINT32 InputFileAlignNum;
|
||||
|
||||
InputFileAlign = NULL;
|
||||
InputFileAlignNum = 0;
|
||||
InputFileName = NULL;
|
||||
OutputFileName = NULL;
|
||||
SectionName = NULL;
|
||||
@@ -809,7 +950,7 @@ Returns:
|
||||
InputFileNum = 0;
|
||||
SectType = EFI_SECTION_ALL;
|
||||
SectCompSubType = 0;
|
||||
SectGuidAttribute = 0;
|
||||
SectGuidAttribute = EFI_GUIDED_SECTION_NONE;
|
||||
OutFileBuffer = NULL;
|
||||
InputLength = 0;
|
||||
Status = STATUS_SUCCESS;
|
||||
@@ -983,6 +1124,41 @@ Returns:
|
||||
continue;
|
||||
}
|
||||
|
||||
//
|
||||
// Section File alignment requirement
|
||||
//
|
||||
if (stricmp (argv[0], "--sectionalign") == 0) {
|
||||
if (InputFileAlignNum == 0) {
|
||||
InputFileAlign = (UINT32 *) malloc (MAXIMUM_INPUT_FILE_NUM * sizeof (UINT32));
|
||||
if (InputFileAlign == NULL) {
|
||||
Error (NULL, 0, 4001, "Resource", "memory cannot be allocated!");
|
||||
return 1;
|
||||
}
|
||||
memset (InputFileAlign, 1, MAXIMUM_INPUT_FILE_NUM * sizeof (UINT32));
|
||||
} else if (InputFileAlignNum % MAXIMUM_INPUT_FILE_NUM == 0) {
|
||||
InputFileAlign = (UINT32 *) realloc (
|
||||
InputFileAlign,
|
||||
(InputFileNum + MAXIMUM_INPUT_FILE_NUM) * sizeof (UINT32)
|
||||
);
|
||||
|
||||
if (InputFileAlign == NULL) {
|
||||
Error (NULL, 0, 4001, "Resource", "memory cannot be allocated!");
|
||||
return 1;
|
||||
}
|
||||
memset (&(InputFileAlign[InputFileNum]), 1, (MAXIMUM_INPUT_FILE_NUM * sizeof (UINT32)));
|
||||
}
|
||||
|
||||
Status = StringtoAlignment (argv[1], &(InputFileAlign[InputFileAlignNum]));
|
||||
if (EFI_ERROR (Status)) {
|
||||
Error (NULL, 0, 1003, "Invalid option value", "%s = %s", argv[0], argv[1]);
|
||||
goto Finish;
|
||||
}
|
||||
argc -= 2;
|
||||
argv += 2;
|
||||
InputFileAlignNum ++;
|
||||
continue;
|
||||
}
|
||||
|
||||
//
|
||||
// Get Input file name
|
||||
//
|
||||
@@ -992,7 +1168,6 @@ Returns:
|
||||
Error (NULL, 0, 4001, "Resource", "memory cannot be allcoated");
|
||||
return 1;
|
||||
}
|
||||
|
||||
memset (InputFileName, 0, (MAXIMUM_INPUT_FILE_NUM * sizeof (CHAR8 *)));
|
||||
} else if (InputFileNum % MAXIMUM_INPUT_FILE_NUM == 0) {
|
||||
//
|
||||
@@ -1007,7 +1182,6 @@ Returns:
|
||||
Error (NULL, 0, 4001, "Resource", "memory cannot be allcoated");
|
||||
return 1;
|
||||
}
|
||||
|
||||
memset (&(InputFileName[InputFileNum]), 0, (MAXIMUM_INPUT_FILE_NUM * sizeof (CHAR8 *)));
|
||||
}
|
||||
|
||||
@@ -1016,6 +1190,11 @@ Returns:
|
||||
argv ++;
|
||||
}
|
||||
|
||||
if (InputFileAlignNum > 0 && InputFileAlignNum != InputFileNum) {
|
||||
Error (NULL, 0, 1003, "Invalid option", "section alignment must be set for each section");
|
||||
goto Finish;
|
||||
}
|
||||
|
||||
VerboseMsg ("%s tool start.", UTILITY_NAME);
|
||||
|
||||
//
|
||||
@@ -1050,14 +1229,11 @@ Returns:
|
||||
memcpy (&VendorGuid, &mEfiCrc32SectionGuid, sizeof (EFI_GUID));
|
||||
}
|
||||
|
||||
if (SectGuidAttribute == 0) {
|
||||
SectGuidAttribute = EFI_GUIDED_SECTION_PROCESSING_REQUIRED;
|
||||
}
|
||||
if ((SectGuidAttribute & EFI_GUIDED_SECTION_NONE) != 0) {
|
||||
//
|
||||
// NONE attribute, clear attribute value.
|
||||
//
|
||||
SectGuidAttribute = 0;
|
||||
SectGuidAttribute = SectGuidAttribute & ~EFI_GUIDED_SECTION_NONE;
|
||||
}
|
||||
VerboseMsg ("Vendor Guid is %08X-%04X-%04X-%02X%02X-%02X%02X%02X%02X%02X%02X",
|
||||
(unsigned) VendorGuid.Data1,
|
||||
@@ -1161,8 +1337,13 @@ Returns:
|
||||
//
|
||||
switch (SectType) {
|
||||
case EFI_SECTION_COMPRESSION:
|
||||
if (InputFileAlign != NULL) {
|
||||
free (InputFileAlign);
|
||||
InputFileAlign = NULL;
|
||||
}
|
||||
Status = GenSectionCompressionSection (
|
||||
InputFileName,
|
||||
InputFileAlign,
|
||||
InputFileNum,
|
||||
SectCompSubType,
|
||||
&OutFileBuffer
|
||||
@@ -1170,8 +1351,17 @@ Returns:
|
||||
break;
|
||||
|
||||
case EFI_SECTION_GUID_DEFINED:
|
||||
if (InputFileAlign != NULL && (CompareGuid (&VendorGuid, &mEfiCrc32SectionGuid) != 0)) {
|
||||
//
|
||||
// Only process alignment for the default known CRC32 guided section.
|
||||
// For the unknown guided section, the alignment is processed when the dummy all section (EFI_SECTION_ALL) is generated.
|
||||
//
|
||||
free (InputFileAlign);
|
||||
InputFileAlign = NULL;
|
||||
}
|
||||
Status = GenSectionGuidDefinedSection (
|
||||
InputFileName,
|
||||
InputFileAlign,
|
||||
InputFileNum,
|
||||
&VendorGuid,
|
||||
SectGuidAttribute,
|
||||
@@ -1232,6 +1422,7 @@ Returns:
|
||||
//
|
||||
Status = GetSectionContents (
|
||||
InputFileName,
|
||||
InputFileAlign,
|
||||
InputFileNum,
|
||||
OutFileBuffer,
|
||||
&InputLength
|
||||
@@ -1248,6 +1439,7 @@ Returns:
|
||||
//
|
||||
Status = GetSectionContents (
|
||||
InputFileName,
|
||||
InputFileAlign,
|
||||
InputFileNum,
|
||||
OutFileBuffer,
|
||||
&InputLength
|
||||
@@ -1296,6 +1488,10 @@ Finish:
|
||||
free (InputFileName);
|
||||
}
|
||||
|
||||
if (InputFileAlign != NULL) {
|
||||
free (InputFileAlign);
|
||||
}
|
||||
|
||||
if (OutFileBuffer != NULL) {
|
||||
free (OutFileBuffer);
|
||||
}
|
||||
|
@@ -1,6 +1,6 @@
|
||||
/**
|
||||
|
||||
Copyright (c) 1999-2008 Intel Corporation. All rights reserved
|
||||
Copyright (c) 1999-2010 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
|
||||
@@ -342,7 +342,6 @@ Returns:
|
||||
VtfInfo->LocationType = SECOND_VTF;
|
||||
} else {
|
||||
VtfInfo->LocationType = NONE;
|
||||
Warning(UTILITY_NAME, 0, 0001, "Unknown location for component.", VtfInfo->CompName);
|
||||
}
|
||||
} else if (strnicmp (*TokenStr, "COMP_TYPE", 9) == 0) {
|
||||
TokenStr++;
|
||||
@@ -2408,7 +2407,7 @@ Returns:
|
||||
//
|
||||
// Copyright declaration
|
||||
//
|
||||
fprintf (stdout, "Copyright (c) 2007 - 2009, Intel Corporation. All rights reserved.\n\n");
|
||||
fprintf (stdout, "Copyright (c) 2007 - 2010, Intel Corporation. All rights reserved.\n\n");
|
||||
//
|
||||
// Details Option
|
||||
//
|
||||
|
@@ -1,6 +1,6 @@
|
||||
/** @file
|
||||
|
||||
Copyright 2006 - 2009, Intel Corporation
|
||||
Copyright 2006 - 2010, 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
|
||||
@@ -273,7 +273,7 @@ Version (
|
||||
)
|
||||
{
|
||||
printf ("%s v%d.%d -Utility to retrieve and update the boot sector or MBR.\n", UTILITY_NAME, UTILITY_MAJOR_VERSION, UTILITY_MINOR_VERSION);
|
||||
printf ("Copyright (c) 2007-2009 Intel Corporation. All rights reserved.\n");
|
||||
printf ("Copyright (c) 2007-2010 Intel Corporation. All rights reserved.\n");
|
||||
}
|
||||
|
||||
|
||||
|
@@ -68,12 +68,10 @@ typedef UINT8 EFI_FFS_FILE_STATE;
|
||||
#define FFS_ATTRIB_DATA_ALIGNMENT 0x38
|
||||
#define FFS_ATTRIB_CHECKSUM 0x40
|
||||
//
|
||||
// FFS_FIXED_CHECKSUM is the default checksum value used when the
|
||||
// FFS_FIXED_CHECKSUM is the checksum value used when the
|
||||
// FFS_ATTRIB_CHECKSUM attribute bit is clear
|
||||
// note this is NOT an architecturally defined value, but is in this file for
|
||||
// implementation convenience
|
||||
//
|
||||
#define FFS_FIXED_CHECKSUM 0x5A
|
||||
#define FFS_FIXED_CHECKSUM 0xAA
|
||||
|
||||
//
|
||||
// FFS File State Bits.
|
||||
|
@@ -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 - 2009, Intel Corporation All rights reserved.
|
||||
Copyright (c) 2006 - 2010, 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
|
||||
@@ -618,6 +618,7 @@ typedef union {
|
||||
#define EFI_IFR_DISABLE_IF_OP 0x1E
|
||||
#define EFI_IFR_TO_LOWER_OP 0x20
|
||||
#define EFI_IFR_TO_UPPER_OP 0x21
|
||||
#define EFI_IFR_MAP_OP 0x22
|
||||
#define EFI_IFR_ORDERED_LIST_OP 0x23
|
||||
#define EFI_IFR_VARSTORE_OP 0x24
|
||||
#define EFI_IFR_VARSTORE_NAME_VALUE_OP 0x25
|
||||
@@ -626,6 +627,10 @@ typedef union {
|
||||
#define EFI_IFR_VERSION_OP 0x28
|
||||
#define EFI_IFR_END_OP 0x29
|
||||
#define EFI_IFR_MATCH_OP 0x2A
|
||||
#define EFI_IFR_GET_OP 0x2B
|
||||
#define EFI_IFR_SET_OP 0x2C
|
||||
#define EFI_IFR_READ_OP 0x2D
|
||||
#define EFI_IFR_WRITE_OP 0x2E
|
||||
#define EFI_IFR_EQUAL_OP 0x2F
|
||||
#define EFI_IFR_NOT_EQUAL_OP 0x30
|
||||
#define EFI_IFR_GREATER_THAN_OP 0x31
|
||||
@@ -672,6 +677,7 @@ typedef union {
|
||||
#define EFI_IFR_VALUE_OP 0x5A
|
||||
#define EFI_IFR_DEFAULT_OP 0x5B
|
||||
#define EFI_IFR_DEFAULTSTORE_OP 0x5C
|
||||
#define EFI_IFR_FORM_MAP_OP 0x5D
|
||||
#define EFI_IFR_CATENATE_OP 0x5E
|
||||
#define EFI_IFR_GUID_OP 0x5F
|
||||
#define EFI_IFR_SECURITY_OP 0x60
|
||||
@@ -730,14 +736,14 @@ typedef struct _EFI_IFR_VARSTORE {
|
||||
|
||||
typedef struct _EFI_IFR_VARSTORE_EFI {
|
||||
EFI_IFR_OP_HEADER Header;
|
||||
UINT16 VarStoreId;
|
||||
EFI_VARSTORE_ID VarStoreId;
|
||||
EFI_GUID Guid;
|
||||
UINT32 Attributes;
|
||||
} EFI_IFR_VARSTORE_EFI;
|
||||
|
||||
typedef struct _EFI_IFR_VARSTORE_NAME_VALUE {
|
||||
EFI_IFR_OP_HEADER Header;
|
||||
UINT16 VarStoreId;
|
||||
EFI_VARSTORE_ID VarStoreId;
|
||||
EFI_GUID Guid;
|
||||
} EFI_IFR_VARSTORE_NAME_VALUE;
|
||||
|
||||
@@ -747,7 +753,7 @@ typedef struct _EFI_IFR_FORM_SET {
|
||||
EFI_STRING_ID FormSetTitle;
|
||||
EFI_STRING_ID Help;
|
||||
UINT8 Flags;
|
||||
EFI_GUID ClassGuid[1];
|
||||
// EFI_GUID ClassGuid[];
|
||||
} EFI_IFR_FORM_SET;
|
||||
|
||||
typedef struct _EFI_IFR_END {
|
||||
@@ -1009,6 +1015,9 @@ typedef struct _EFI_IFR_ONE_OF_OPTION {
|
||||
#define EFI_IFR_TYPE_DATE 0x06
|
||||
#define EFI_IFR_TYPE_STRING 0x07
|
||||
#define EFI_IFR_TYPE_OTHER 0x08
|
||||
#define EFI_IFR_TYPE_UNDEFINED 0x09
|
||||
#define EFI_IFR_TYPE_ACTION 0x0A
|
||||
#define EFI_IFR_TYPE_BUFFER 0x0B
|
||||
|
||||
#define EFI_IFR_OPTION_DEFAULT 0x10
|
||||
#define EFI_IFR_OPTION_DEFAULT_MFG 0x20
|
||||
@@ -1288,6 +1297,100 @@ typedef struct _EFI_IFR_SECURITY {
|
||||
EFI_GUID Permissions;
|
||||
} EFI_IFR_SECURITY;
|
||||
|
||||
typedef struct _EFI_IFR_FORM_MAP_METHOD {
|
||||
///
|
||||
/// The string identifier which provides the human-readable name of
|
||||
/// the configuration method for this standards map form.
|
||||
///
|
||||
EFI_STRING_ID MethodTitle;
|
||||
///
|
||||
/// Identifier which uniquely specifies the configuration methods
|
||||
/// associated with this standards map form.
|
||||
///
|
||||
EFI_GUID MethodIdentifier;
|
||||
} EFI_IFR_FORM_MAP_METHOD;
|
||||
|
||||
typedef struct _EFI_IFR_FORM_MAP {
|
||||
///
|
||||
/// The sequence that defines the type of opcode as well as the length
|
||||
/// of the opcode being defined. Header.OpCode = EFI_IFR_FORM_MAP_OP.
|
||||
///
|
||||
EFI_IFR_OP_HEADER Header;
|
||||
///
|
||||
/// The unique identifier for this particular form.
|
||||
///
|
||||
EFI_FORM_ID FormId;
|
||||
///
|
||||
/// One or more configuration method's name and unique identifier.
|
||||
///
|
||||
// EFI_IFR_FORM_MAP_METHOD Methods[];
|
||||
} EFI_IFR_FORM_MAP;
|
||||
|
||||
typedef struct _EFI_IFR_SET {
|
||||
///
|
||||
/// The sequence that defines the type of opcode as well as the length
|
||||
/// of the opcode being defined. Header.OpCode = EFI_IFR_SET_OP.
|
||||
///
|
||||
EFI_IFR_OP_HEADER Header;
|
||||
///
|
||||
/// Specifies the identifier of a previously declared variable store to
|
||||
/// use when storing the question's value.
|
||||
///
|
||||
EFI_VARSTORE_ID VarStoreId;
|
||||
union {
|
||||
///
|
||||
/// A 16-bit Buffer Storage offset.
|
||||
///
|
||||
EFI_STRING_ID VarName;
|
||||
///
|
||||
/// A Name Value or EFI Variable name (VarName).
|
||||
///
|
||||
UINT16 VarOffset;
|
||||
} VarStoreInfo;
|
||||
///
|
||||
/// Specifies the type used for storage.
|
||||
///
|
||||
UINT8 VarStoreType;
|
||||
} EFI_IFR_SET;
|
||||
|
||||
typedef struct _EFI_IFR_GET {
|
||||
///
|
||||
/// The sequence that defines the type of opcode as well as the length
|
||||
/// of the opcode being defined. Header.OpCode = EFI_IFR_GET_OP.
|
||||
///
|
||||
EFI_IFR_OP_HEADER Header;
|
||||
///
|
||||
/// Specifies the identifier of a previously declared variable store to
|
||||
/// use when retrieving the value.
|
||||
///
|
||||
EFI_VARSTORE_ID VarStoreId;
|
||||
union {
|
||||
///
|
||||
/// A 16-bit Buffer Storage offset.
|
||||
///
|
||||
EFI_STRING_ID VarName;
|
||||
///
|
||||
/// A Name Value or EFI Variable name (VarName).
|
||||
///
|
||||
UINT16 VarOffset;
|
||||
} VarStoreInfo;
|
||||
///
|
||||
/// Specifies the type used for storage.
|
||||
///
|
||||
UINT8 VarStoreType;
|
||||
} EFI_IFR_GET;
|
||||
|
||||
typedef struct _EFI_IFR_READ {
|
||||
EFI_IFR_OP_HEADER Header;
|
||||
} EFI_IFR_READ;
|
||||
|
||||
typedef struct _EFI_IFR_WRITE {
|
||||
EFI_IFR_OP_HEADER Header;
|
||||
} EFI_IFR_WRITE;
|
||||
|
||||
typedef struct _EFI_IFR_MAP {
|
||||
EFI_IFR_OP_HEADER Header;
|
||||
} EFI_IFR_MAP;
|
||||
//
|
||||
// Keyboard Package
|
||||
//
|
||||
|
@@ -1,3 +1,15 @@
|
||||
@REM ## @file
|
||||
@REM #
|
||||
@REM # Copyright (c) 2007 - 2010, Intel Corporation
|
||||
@REM # All rights reserved. This program and the accompanying materials
|
||||
@REM # are licensed and made available under the terms and conditions of the BSD License
|
||||
@REM # which accompanies this distribution. The full text of the license may be found at
|
||||
@REM # http://opensource.org/licenses/bsd-license.php
|
||||
@REM #
|
||||
@REM # THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
|
||||
@REM # WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
|
||||
|
||||
|
||||
@echo off
|
||||
setlocal
|
||||
SET NMAKE_COMMAND=%1
|
||||
|
@@ -1,3 +1,15 @@
|
||||
## @file
|
||||
#
|
||||
# Copyright (c) 2007 - 2010, 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
|
||||
# http://opensource.org/licenses/bsd-license.php
|
||||
#
|
||||
# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
|
||||
#
|
||||
|
||||
MAKEROOT ?= ../..
|
||||
|
||||
include $(MAKEROOT)/Makefiles/header.makefile
|
||||
|
@@ -1,3 +1,14 @@
|
||||
## @file
|
||||
#
|
||||
# Copyright (c) 2007 - 2010, 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
|
||||
# http://opensource.org/licenses/bsd-license.php
|
||||
#
|
||||
# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
|
||||
|
||||
DEPFILES = $(OBJECTS:%.o=%.d)
|
||||
|
||||
$(MAKEROOT)/libs-$(ARCH):
|
||||
|
@@ -1,8 +1,19 @@
|
||||
## @file
|
||||
#
|
||||
# The makefile can be invoked with
|
||||
# ARCH = x86_64 or x64 for EM64T build
|
||||
# ARCH = ia32 or IA32 for IA32 build
|
||||
# ARCH = ia64 or IA64 for IA64 build
|
||||
#
|
||||
# Copyright (c) 2007 - 2010, 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
|
||||
# http://opensource.org/licenses/bsd-license.php
|
||||
#
|
||||
# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
|
||||
|
||||
ARCH ?= IA32
|
||||
|
||||
CYGWIN:=$(findstring CYGWIN, $(shell uname -s))
|
||||
|
@@ -1,3 +1,14 @@
|
||||
## @file
|
||||
#
|
||||
# Copyright (c) 2007 - 2010, 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
|
||||
# http://opensource.org/licenses/bsd-license.php
|
||||
#
|
||||
# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
|
||||
|
||||
include $(MAKEROOT)/Makefiles/header.makefile
|
||||
|
||||
LIBRARY = $(MAKEROOT)/libs/lib$(LIBNAME).a
|
||||
|
@@ -1,3 +1,14 @@
|
||||
## @file
|
||||
#
|
||||
# Copyright (c) 2007 - 2010, 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
|
||||
# http://opensource.org/licenses/bsd-license.php
|
||||
#
|
||||
# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
|
||||
|
||||
!INCLUDE ..\Makefiles\ms.common
|
||||
|
||||
APPLICATION = $(BIN_PATH)\$(APPNAME).exe
|
||||
|
@@ -1,3 +1,14 @@
|
||||
## @file
|
||||
#
|
||||
# Copyright (c) 2007 - 2010, 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
|
||||
# http://opensource.org/licenses/bsd-license.php
|
||||
#
|
||||
# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
|
||||
|
||||
!IFNDEF EDK_TOOLS_PATH
|
||||
!ERROR "Please set your EDK_TOOLS_PATH!"
|
||||
!ENDIF
|
||||
|
@@ -1,3 +1,14 @@
|
||||
## @file
|
||||
#
|
||||
# Copyright (c) 2007 - 2010, 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
|
||||
# http://opensource.org/licenses/bsd-license.php
|
||||
#
|
||||
# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
|
||||
|
||||
!INCLUDE ..\Makefiles\ms.common
|
||||
|
||||
LIBRARY = $(LIB_PATH)\$(LIBNAME).lib
|
||||
|
@@ -1,3 +1,14 @@
|
||||
## @file
|
||||
#
|
||||
# Copyright (c) 2007 - 2010, 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
|
||||
# http://opensource.org/licenses/bsd-license.php
|
||||
#
|
||||
# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
|
||||
|
||||
#DEPFILES = $(OBJECTS:%.o=%.d)
|
||||
|
||||
.c.obj :
|
||||
|
@@ -1,3 +1,16 @@
|
||||
/** @file
|
||||
|
||||
Copyright (c) 2009 - 2010 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
|
||||
http://opensource.org/licenses/bsd-license.php
|
||||
|
||||
THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
|
||||
|
||||
**/
|
||||
|
||||
#include <Python.h>
|
||||
#include <Decompress.h>
|
||||
|
||||
|
@@ -1,3 +1,14 @@
|
||||
## @file
|
||||
#
|
||||
# Copyright (c) 2007 - 2010, 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
|
||||
# http://opensource.org/licenses/bsd-license.php
|
||||
#
|
||||
# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
|
||||
|
||||
!INCLUDE ..\Makefiles\ms.common
|
||||
|
||||
APPNAME = GenSec
|
||||
|
@@ -1,3 +1,14 @@
|
||||
## @file
|
||||
#
|
||||
# Copyright (c) 2007 - 2010, 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
|
||||
# http://opensource.org/licenses/bsd-license.php
|
||||
#
|
||||
# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
|
||||
|
||||
!INCLUDE ..\Makefiles\ms.common
|
||||
|
||||
APPNAME = GenSec
|
||||
|
@@ -1,3 +1,16 @@
|
||||
/** @file
|
||||
|
||||
Copyright (c) 2009 - 2010 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
|
||||
http://opensource.org/licenses/bsd-license.php
|
||||
|
||||
THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
|
||||
|
||||
**/
|
||||
|
||||
#include <Python.h>
|
||||
#include <Windows.h>
|
||||
#include <Common/UefiBaseTypes.h>
|
||||
|
@@ -2,7 +2,7 @@
|
||||
|
||||
Split a file into two pieces at the request offset.
|
||||
|
||||
Copyright (c) 1999-2008 Intel Corporation. All rights reserved
|
||||
Copyright (c) 1999-2010 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
|
||||
@@ -58,7 +58,7 @@ Returns:
|
||||
--*/
|
||||
{
|
||||
printf ("%s v%d.%d -Utility to break a file into two pieces at the request offset.\n", UTILITY_NAME, UTILITY_MAJOR_VERSION, UTILITY_MINOR_VERSION);
|
||||
printf ("Copyright (c) 1999-2007 Intel Corporation. All rights reserved.\n");
|
||||
printf ("Copyright (c) 1999-2010 Intel Corporation. All rights reserved.\n");
|
||||
}
|
||||
|
||||
void
|
||||
|
@@ -1,6 +1,6 @@
|
||||
/** @file
|
||||
|
||||
Copyright (c) 2007 - 2008, Intel Corporation
|
||||
Copyright (c) 2007 - 2010, 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
|
||||
@@ -1695,7 +1695,7 @@ Returns:
|
||||
//
|
||||
// Copyright declaration
|
||||
//
|
||||
fprintf (stdout, "Copyright (c) 2007, Intel Corporation. All rights reserved.\n\n");
|
||||
fprintf (stdout, "Copyright (c) 2007 - 2010, Intel Corporation. All rights reserved.\n\n");
|
||||
|
||||
//
|
||||
// Details Option
|
||||
|
@@ -1,6 +1,6 @@
|
||||
/** @file
|
||||
|
||||
Copyright (c) 2004 - 2008, Intel Corporation
|
||||
Copyright (c) 2004 - 2010, 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
|
||||
@@ -31,6 +31,7 @@ Abstract:
|
||||
#define MAX_VFR_LINE_LEN 4096
|
||||
|
||||
#define EFI_IFR_MAX_LENGTH 0xFF
|
||||
#define MAX_IFR_EXPRESSION_DEPTH 0x9
|
||||
|
||||
#define EFI_VARSTORE_ID_INVALID 0
|
||||
#define EFI_VAROFFSET_INVALID 0xFFFF
|
||||
|
@@ -2,7 +2,7 @@
|
||||
|
||||
VfrCompiler main class and main function.
|
||||
|
||||
Copyright (c) 2004 - 2008, Intel Corporation
|
||||
Copyright (c) 2004 - 2010, 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
|
||||
@@ -24,9 +24,19 @@ PACKAGE_DATA gCBuffer;
|
||||
PACKAGE_DATA gRBuffer;
|
||||
|
||||
VOID
|
||||
CVfrCompiler::DebugError () {
|
||||
Error (NULL, 0, 0001, "Error parsing vfr file", " %s", mOptions.VfrFileName);
|
||||
//_asm int 3;
|
||||
CVfrCompiler::DebugError (
|
||||
IN CHAR8 *FileName,
|
||||
IN UINT32 LineNumber,
|
||||
IN UINT32 MessageCode,
|
||||
IN CONST CHAR8 *Text,
|
||||
IN CONST CHAR8 *MsgFmt,
|
||||
...
|
||||
)
|
||||
{
|
||||
va_list List;
|
||||
va_start (List, MsgFmt);
|
||||
PrintMessage ((CHAR8 *) "ERROR", FileName, LineNumber, MessageCode, (CHAR8 *) Text, (CHAR8 *) MsgFmt, List);
|
||||
va_end (List);
|
||||
}
|
||||
|
||||
VOID
|
||||
@@ -53,7 +63,7 @@ CVfrCompiler::OptionInitialization (
|
||||
{
|
||||
INT32 Index;
|
||||
|
||||
SetUtilityName (PROGRAM_NAME);
|
||||
SetUtilityName ((CHAR8*) PROGRAM_NAME);
|
||||
|
||||
mOptions.VfrFileName[0] = '\0';
|
||||
mOptions.RecordListFile[0] = '\0';
|
||||
@@ -84,11 +94,9 @@ CVfrCompiler::OptionInitialization (
|
||||
mOptions.CreateRecordListFile = TRUE;
|
||||
gCIfrRecordInfoDB.TurnOn ();
|
||||
} else if (stricmp(Argv[Index], "-i") == 0) {
|
||||
Error (NULL, 0, 1000, "Unknown option", "unrecognized option %s", Argv[Index]);
|
||||
goto Fail;
|
||||
Index++;
|
||||
if ((Index >= Argc) || (Argv[Index][0] == '-')) {
|
||||
Error (NULL, 0, 1001, "Missing option", "-i missing path argument");
|
||||
DebugError (NULL, 0, 1001, "Missing option", "-i missing path argument");
|
||||
goto Fail;
|
||||
}
|
||||
|
||||
@@ -96,7 +104,7 @@ CVfrCompiler::OptionInitialization (
|
||||
} else if (stricmp(Argv[Index], "-o") == 0 || stricmp(Argv[Index], "--output-directory") == 0 || stricmp(Argv[Index], "-od") == 0) {
|
||||
Index++;
|
||||
if ((Index >= Argc) || (Argv[Index][0] == '-')) {
|
||||
Error (NULL, 0, 1001, "Missing option", "-o missing output directory name");
|
||||
DebugError (NULL, 0, 1001, "Missing option", "-o missing output directory name");
|
||||
goto Fail;
|
||||
}
|
||||
strcpy (mOptions.OutputDirectory, Argv[Index]);
|
||||
@@ -109,17 +117,15 @@ CVfrCompiler::OptionInitialization (
|
||||
strcat (mOptions.OutputDirectory, "\\");
|
||||
}
|
||||
}
|
||||
DebugMsg (NULL, 0, 9, "Output Directory", mOptions.OutputDirectory);
|
||||
DebugMsg (NULL, 0, 9, (CHAR8 *) "Output Directory", mOptions.OutputDirectory);
|
||||
} else if (stricmp(Argv[Index], "-b") == 0 || stricmp(Argv[Index], "--create-ifr-package") == 0 || stricmp(Argv[Index], "-ibin") == 0) {
|
||||
mOptions.CreateIfrPkgFile = TRUE;
|
||||
} else if (stricmp(Argv[Index], "-n") == 0 || stricmp(Argv[Index], "--no-pre-processing") == 0 || stricmp(Argv[Index], "-nopp") == 0) {
|
||||
mOptions.SkipCPreprocessor = TRUE;
|
||||
} else if (stricmp(Argv[Index], "-f") == 0 || stricmp(Argv[Index], "--pre-processing-flag") == 0 || stricmp(Argv[Index], "-ppflag") == 0) {
|
||||
Error (NULL, 0, 1000, "Unknown option", "unrecognized option %s", Argv[Index]);
|
||||
goto Fail;
|
||||
Index++;
|
||||
if ((Index >= Argc) || (Argv[Index][0] == '-')) {
|
||||
Error (NULL, 0, 1001, "Missing option", "-od - missing C-preprocessor argument");
|
||||
DebugError (NULL, 0, 1001, "Missing option", "-od - missing C-preprocessor argument");
|
||||
goto Fail;
|
||||
}
|
||||
|
||||
@@ -127,13 +133,13 @@ CVfrCompiler::OptionInitialization (
|
||||
} else if (stricmp(Argv[Index], "-c") == 0 || stricmp(Argv[Index], "--compatible-framework") == 0) {
|
||||
mOptions.CompatibleMode = TRUE;
|
||||
} else {
|
||||
Error (NULL, 0, 1000, "Unknown option", "unrecognized option %s", Argv[Index]);
|
||||
DebugError (NULL, 0, 1000, "Unknown option", "unrecognized option %s", Argv[Index]);
|
||||
goto Fail;
|
||||
}
|
||||
}
|
||||
|
||||
if (Index != Argc - 1) {
|
||||
Error (NULL, 0, 1001, "Missing option", "VFR file name is not specified.");
|
||||
DebugError (NULL, 0, 1001, "Missing option", "VFR file name is not specified.");
|
||||
goto Fail;
|
||||
} else {
|
||||
strcpy (mOptions.VfrFileName, Argv[Index]);
|
||||
@@ -192,7 +198,7 @@ CVfrCompiler::AppendIncludePath (
|
||||
}
|
||||
IncludePaths = new CHAR8[Len];
|
||||
if (IncludePaths == NULL) {
|
||||
Error (NULL, 0, 4001, "Resource: memory can't be allocated", NULL);
|
||||
DebugError (NULL, 0, 4001, "Resource: memory can't be allocated", NULL);
|
||||
return;
|
||||
}
|
||||
IncludePaths[0] = '\0';
|
||||
@@ -221,7 +227,7 @@ CVfrCompiler::AppendCPreprocessorOptions (
|
||||
}
|
||||
Opt = new CHAR8[Len];
|
||||
if (Opt == NULL) {
|
||||
Error (NULL, 0, 4001, "Resource: memory can't be allocated", NULL);
|
||||
DebugError (NULL, 0, 4001, "Resource: memory can't be allocated", NULL);
|
||||
return;
|
||||
}
|
||||
Opt[0] = 0;
|
||||
@@ -339,8 +345,8 @@ CVfrCompiler::CVfrCompiler (
|
||||
IN CHAR8 **Argv
|
||||
)
|
||||
{
|
||||
mPreProcessCmd = PREPROCESSOR_COMMAND;
|
||||
mPreProcessOpt = PREPROCESSOR_OPTIONS;
|
||||
mPreProcessCmd = (CHAR8 *) PREPROCESSOR_COMMAND;
|
||||
mPreProcessOpt = (CHAR8 *) PREPROCESSOR_OPTIONS;
|
||||
|
||||
OptionInitialization(Argc, Argv);
|
||||
|
||||
@@ -377,6 +383,7 @@ CVfrCompiler::Usage (
|
||||
CONST CHAR8 *Help[] = {
|
||||
" ",
|
||||
"VfrCompile version " VFR_COMPILER_VERSION VFR_COMPILER_UPDATE_TIME,
|
||||
"Copyright (c) 2004-2010 Intel Corporation. All rights reserved.",
|
||||
" ",
|
||||
"Usage: VfrCompile [options] VfrFile",
|
||||
" ",
|
||||
@@ -417,7 +424,7 @@ CVfrCompiler::PreProcess (
|
||||
}
|
||||
|
||||
if ((pVfrFile = fopen (mOptions.VfrFileName, "r")) == NULL) {
|
||||
Error (NULL, 0, 0001, "Error opening the input VFR file", mOptions.VfrFileName);
|
||||
DebugError (NULL, 0, 0001, "Error opening the input VFR file", mOptions.VfrFileName);
|
||||
goto Fail;
|
||||
}
|
||||
fclose (pVfrFile);
|
||||
@@ -433,7 +440,7 @@ CVfrCompiler::PreProcess (
|
||||
|
||||
PreProcessCmd = new CHAR8[CmdLen + 10];
|
||||
if (PreProcessCmd == NULL) {
|
||||
Error (NULL, 0, 4001, "Resource: memory can't be allocated", NULL);
|
||||
DebugError (NULL, 0, 4001, "Resource: memory can't be allocated", NULL);
|
||||
goto Fail;
|
||||
}
|
||||
strcpy (PreProcessCmd, mPreProcessCmd), strcat (PreProcessCmd, " ");
|
||||
@@ -448,7 +455,7 @@ CVfrCompiler::PreProcess (
|
||||
strcat (PreProcessCmd, mOptions.PreprocessorOutputFileName);
|
||||
|
||||
if (system (PreProcessCmd) != 0) {
|
||||
Error (NULL, 0, 0003, "Error parsing file", "failed to spawn C preprocessor on VFR file %s\n", PreProcessCmd);
|
||||
DebugError (NULL, 0, 0003, "Error parsing file", "failed to spawn C preprocessor on VFR file %s\n", PreProcessCmd);
|
||||
goto Fail;
|
||||
}
|
||||
|
||||
@@ -484,7 +491,7 @@ CVfrCompiler::Compile (
|
||||
gCVfrErrorHandle.SetInputFile (InFileName);
|
||||
|
||||
if ((pInFile = fopen (InFileName, "r")) == NULL) {
|
||||
Error (NULL, 0, 0001, "Error opening the input file", InFileName);
|
||||
DebugError (NULL, 0, 0001, "Error opening the input file", InFileName);
|
||||
goto Fail;
|
||||
}
|
||||
|
||||
@@ -504,7 +511,7 @@ CVfrCompiler::Compile (
|
||||
|
||||
Fail:
|
||||
if (!IS_RUN_STATUS(STATUS_DEAD)) {
|
||||
Error (NULL, 0, 0003, "Error parsing", "compile error in file %s", InFileName);
|
||||
DebugError (NULL, 0, 0003, "Error parsing", "compile error in file %s", InFileName);
|
||||
SET_RUN_STATUS (STATUS_FAILED);
|
||||
}
|
||||
if (pInFile != NULL) {
|
||||
@@ -534,7 +541,7 @@ CVfrCompiler::AdjustBin (
|
||||
if (gCBuffer.Buffer != NULL && gRBuffer.Buffer != NULL) {
|
||||
UINT32 Index;
|
||||
if (gCBuffer.Size != gRBuffer.Size) {
|
||||
Error (NULL, 0, 0001, "Error parsing vfr file", " %s. FormBinary Size 0x%X is not same to RecordBuffer Size 0x%X", mOptions.VfrFileName, gCBuffer.Size, gRBuffer.Size);
|
||||
DebugError (NULL, 0, 0001, "Error parsing vfr file", " %s. FormBinary Size 0x%X is not same to RecordBuffer Size 0x%X", mOptions.VfrFileName, gCBuffer.Size, gRBuffer.Size);
|
||||
}
|
||||
for (Index = 0; Index < gCBuffer.Size; Index ++) {
|
||||
if (gCBuffer.Buffer[Index] != gRBuffer.Buffer[Index]) {
|
||||
@@ -542,13 +549,13 @@ CVfrCompiler::AdjustBin (
|
||||
}
|
||||
}
|
||||
if (Index != gCBuffer.Size) {
|
||||
Error (NULL, 0, 0001, "Error parsing vfr file", " %s. the 0x%X byte is different between Form and Record", mOptions.VfrFileName, Index);
|
||||
DebugError (NULL, 0, 0001, "Error parsing vfr file", " %s. the 0x%X byte is different between Form and Record", mOptions.VfrFileName, Index);
|
||||
}
|
||||
DebugMsg (NULL, 0, 9, "IFR Buffer", "Form Buffer same to Record Buffer and Size is 0x%X", Index);
|
||||
DebugMsg (NULL, 0, 9, (CHAR8 *) "IFR Buffer", (CHAR8 *) "Form Buffer same to Record Buffer and Size is 0x%X", Index);
|
||||
} else if (gCBuffer.Buffer == NULL && gRBuffer.Buffer == NULL) {
|
||||
//ok
|
||||
} else {
|
||||
Error (NULL, 0, 0001, "Error parsing vfr file", " %s.Buffer not allocated.", mOptions.VfrFileName);
|
||||
DebugError (NULL, 0, 0001, "Error parsing vfr file", " %s.Buffer not allocated.", mOptions.VfrFileName);
|
||||
}
|
||||
|
||||
//
|
||||
@@ -588,7 +595,7 @@ CVfrCompiler::GenBinary (
|
||||
|
||||
if (mOptions.CreateIfrPkgFile == TRUE) {
|
||||
if ((pFile = fopen (mOptions.PkgOutputFileName, "wb")) == NULL) {
|
||||
Error (NULL, 0, 0001, "Error opening file", mOptions.PkgOutputFileName);
|
||||
DebugError (NULL, 0, 0001, "Error opening file", mOptions.PkgOutputFileName);
|
||||
goto Fail;
|
||||
}
|
||||
if (gCFormPkg.BuildPkg (pFile, &gRBuffer) != VFR_RETURN_SUCCESS) {
|
||||
@@ -631,7 +638,7 @@ CVfrCompiler::GenCFile (
|
||||
|
||||
if (!mOptions.CreateIfrPkgFile || mOptions.CompatibleMode) {
|
||||
if ((pFile = fopen (mOptions.COutputFileName, "w")) == NULL) {
|
||||
Error (NULL, 0, 0001, "Error opening output C file", mOptions.COutputFileName);
|
||||
DebugError (NULL, 0, 0001, "Error opening output C file", mOptions.COutputFileName);
|
||||
goto Fail;
|
||||
}
|
||||
|
||||
@@ -678,12 +685,12 @@ CVfrCompiler::GenRecordListFile (
|
||||
}
|
||||
|
||||
if ((pInFile = fopen (InFileName, "r")) == NULL) {
|
||||
Error (NULL, 0, 0001, "Error opening the input VFR preprocessor output file", InFileName);
|
||||
DebugError (NULL, 0, 0001, "Error opening the input VFR preprocessor output file", InFileName);
|
||||
return;
|
||||
}
|
||||
|
||||
if ((pOutFile = fopen (mOptions.RecordListFile, "w")) == NULL) {
|
||||
Error (NULL, 0, 0001, "Error opening the record list file", mOptions.RecordListFile);
|
||||
DebugError (NULL, 0, 0001, "Error opening the record list file", mOptions.RecordListFile);
|
||||
goto Err1;
|
||||
}
|
||||
|
||||
@@ -713,8 +720,8 @@ Err1:
|
||||
|
||||
int
|
||||
main (
|
||||
IN INT32 Argc,
|
||||
IN CHAR8 **Argv
|
||||
IN int Argc,
|
||||
IN char **Argv
|
||||
)
|
||||
{
|
||||
COMPILER_RUN_STATUS Status;
|
||||
@@ -743,3 +750,4 @@ main (
|
||||
return GetUtilityStatus ();
|
||||
}
|
||||
|
||||
|
||||
|
@@ -102,7 +102,7 @@ public:
|
||||
VOID GenBinary (VOID);
|
||||
VOID GenCFile (VOID);
|
||||
VOID GenRecordListFile (VOID);
|
||||
VOID DebugError (VOID);
|
||||
VOID DebugError (IN CHAR8*, IN UINT32, IN UINT32, IN CONST CHAR8*, IN CONST CHAR8*, ...);
|
||||
};
|
||||
|
||||
#endif
|
||||
|
@@ -135,7 +135,6 @@ CVfrErrorHandle::ParseFileScopeRecord (
|
||||
IN UINT32 WholeScopeLine
|
||||
)
|
||||
{
|
||||
CHAR8 *FullPathName = NULL;
|
||||
SVfrFileScopeRecord *pNode = NULL;
|
||||
|
||||
if (Record == NULL) {
|
||||
@@ -195,19 +194,19 @@ VOID
|
||||
CVfrErrorHandle::PrintMsg (
|
||||
IN UINT32 LineNum,
|
||||
IN CHAR8 *TokName,
|
||||
IN CHAR8 *MsgType,
|
||||
IN CHAR8 *ErrorMsg
|
||||
IN CONST CHAR8 *MsgType,
|
||||
IN CONST CHAR8 *ErrorMsg
|
||||
)
|
||||
{
|
||||
CHAR8 *FileName = NULL;
|
||||
UINT32 FileLine;
|
||||
|
||||
if (strncmp ("Warning", MsgType, strlen ("Warning")) == 0) {
|
||||
VerboseMsg (ErrorMsg);
|
||||
VerboseMsg ((CHAR8 *) ErrorMsg);
|
||||
return;
|
||||
}
|
||||
GetFileNameLineNum (LineNum, &FileName, &FileLine);
|
||||
Error (FileName, FileLine, 0x3000, TokName, "\t%s\n", ErrorMsg);
|
||||
Error (FileName, FileLine, 0x3000, TokName, (CHAR8 *) "\t%s\n", (CHAR8 *) ErrorMsg);
|
||||
}
|
||||
|
||||
UINT8
|
||||
@@ -220,7 +219,7 @@ CVfrErrorHandle::HandleError (
|
||||
UINT32 Index;
|
||||
CHAR8 *FileName = NULL;
|
||||
UINT32 FileLine;
|
||||
CHAR8 *ErrorMsg = NULL;
|
||||
CONST CHAR8 *ErrorMsg = NULL;
|
||||
|
||||
if (mVfrErrorHandleTable == NULL) {
|
||||
return 1;
|
||||
@@ -235,7 +234,7 @@ CVfrErrorHandle::HandleError (
|
||||
|
||||
if (ErrorMsg != NULL) {
|
||||
GetFileNameLineNum (LineNum, &FileName, &FileLine);
|
||||
Error (FileName, FileLine, 0x3000, TokName, "\t%s\n", ErrorMsg);
|
||||
Error (FileName, FileLine, 0x3000, TokName, (CHAR8 *) "\t%s\n", (CHAR8 *) ErrorMsg);
|
||||
return 1;
|
||||
} else {
|
||||
return 0;
|
||||
|
@@ -47,7 +47,7 @@ typedef enum {
|
||||
|
||||
typedef struct _SVFR_ERROR_HANDLE {
|
||||
EFI_VFR_RETURN_CODE mErrorCode;
|
||||
CHAR8 *mErrorMsg;
|
||||
CONST CHAR8 *mErrorMsg;
|
||||
} SVFR_ERROR_HANDLE;
|
||||
|
||||
struct SVfrFileScopeRecord {
|
||||
@@ -74,8 +74,8 @@ public:
|
||||
VOID SetInputFile (IN CHAR8 *);
|
||||
VOID ParseFileScopeRecord (IN CHAR8 *, IN UINT32);
|
||||
VOID GetFileNameLineNum (IN UINT32, OUT CHAR8 **, OUT UINT32 *);
|
||||
UINT8 HandleError (IN EFI_VFR_RETURN_CODE, IN UINT32 LineNum = 0, IN CHAR8 *TokName = "\0");
|
||||
VOID PrintMsg (IN UINT32 LineNum = 0, IN CHAR8 *TokName = "\0", IN CHAR8 *MsgType = "Error", IN CHAR8 *ErrorMsg = "\0");
|
||||
UINT8 HandleError (IN EFI_VFR_RETURN_CODE, IN UINT32 LineNum = 0, IN CHAR8 *TokName = NULL);
|
||||
VOID PrintMsg (IN UINT32 LineNum = 0, IN CHAR8 *TokName = NULL, IN CONST CHAR8 *MsgType = "Error", IN CONST CHAR8 *ErrorMsg = "");
|
||||
};
|
||||
|
||||
#define CHECK_ERROR_RETURN(f, v) do { EFI_VFR_RETURN_CODE r; if ((r = (f)) != (v)) { return r; } } while (0)
|
||||
|
@@ -2,7 +2,7 @@
|
||||
|
||||
The definition of CFormPkg's member function
|
||||
|
||||
Copyright (c) 2004 - 2009, Intel Corporation
|
||||
Copyright (c) 2004 - 2010, 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
|
||||
@@ -25,7 +25,7 @@ SPendingAssign::SPendingAssign (
|
||||
IN VOID *Addr,
|
||||
IN UINT32 Len,
|
||||
IN UINT32 LineNo,
|
||||
IN CHAR8 *Msg
|
||||
IN CONST CHAR8 *Msg
|
||||
)
|
||||
{
|
||||
mKey = NULL;
|
||||
@@ -352,11 +352,11 @@ CFormPkg::BuildPkg (
|
||||
|
||||
VOID
|
||||
CFormPkg::_WRITE_PKG_LINE (
|
||||
IN FILE *pFile,
|
||||
IN UINT32 LineBytes,
|
||||
IN CHAR8 *LineHeader,
|
||||
IN CHAR8 *BlkBuf,
|
||||
IN UINT32 BlkSize
|
||||
IN FILE *pFile,
|
||||
IN UINT32 LineBytes,
|
||||
IN CONST CHAR8 *LineHeader,
|
||||
IN CHAR8 *BlkBuf,
|
||||
IN UINT32 BlkSize
|
||||
)
|
||||
{
|
||||
UINT32 Index;
|
||||
@@ -375,11 +375,11 @@ CFormPkg::_WRITE_PKG_LINE (
|
||||
|
||||
VOID
|
||||
CFormPkg::_WRITE_PKG_END (
|
||||
IN FILE *pFile,
|
||||
IN UINT32 LineBytes,
|
||||
IN CHAR8 *LineHeader,
|
||||
IN CHAR8 *BlkBuf,
|
||||
IN UINT32 BlkSize
|
||||
IN FILE *pFile,
|
||||
IN UINT32 LineBytes,
|
||||
IN CONST CHAR8 *LineHeader,
|
||||
IN CHAR8 *BlkBuf,
|
||||
IN UINT32 BlkSize
|
||||
)
|
||||
{
|
||||
UINT32 Index;
|
||||
@@ -483,7 +483,7 @@ CFormPkg::AssignPending (
|
||||
IN VOID *ValAddr,
|
||||
IN UINT32 ValLen,
|
||||
IN UINT32 LineNo,
|
||||
IN CHAR8 *Msg
|
||||
IN CONST CHAR8 *Msg
|
||||
)
|
||||
{
|
||||
SPendingAssign *pNew;
|
||||
@@ -1242,7 +1242,7 @@ static struct {
|
||||
{ 0, 0 }, // 0x1F
|
||||
{ sizeof (EFI_IFR_TO_LOWER), 0 }, // EFI_IFR_TO_LOWER_OP - 0x20
|
||||
{ sizeof (EFI_IFR_TO_UPPER), 0 }, // EFI_IFR_TO_UPPER_OP - 0x21
|
||||
{ 0, 0 }, // 0x22
|
||||
{ sizeof (EFI_IFR_MAP), 1 }, // EFI_IFR_MAP - 0x22
|
||||
{ sizeof (EFI_IFR_ORDERED_LIST), 1 }, // EFI_IFR_ORDERED_LIST_OP - 0x23
|
||||
{ sizeof (EFI_IFR_VARSTORE), 0 }, // EFI_IFR_VARSTORE_OP
|
||||
{ sizeof (EFI_IFR_VARSTORE_NAME_VALUE), 0 }, // EFI_IFR_VARSTORE_NAME_VALUE_OP
|
||||
@@ -1250,8 +1250,11 @@ static struct {
|
||||
{ sizeof (EFI_IFR_VARSTORE_DEVICE), 1 }, // EFI_IFR_VARSTORE_DEVICE_OP
|
||||
{ sizeof (EFI_IFR_VERSION), 0 }, // EFI_IFR_VERSION_OP - 0x28
|
||||
{ sizeof (EFI_IFR_END), 0 }, // EFI_IFR_END_OP
|
||||
{ sizeof (EFI_IFR_MATCH), 1 }, // EFI_IFR_MATCH_OP - 0x2A
|
||||
{ 0, 0 }, { 0, 0} , { 0, 0} , { 0, 0} , // 0x2B ~ 0x2E
|
||||
{ sizeof (EFI_IFR_MATCH), 0 }, // EFI_IFR_MATCH_OP - 0x2A
|
||||
{ sizeof (EFI_IFR_GET), 0 }, // EFI_IFR_GET - 0x2B
|
||||
{ sizeof (EFI_IFR_SET), 0 }, // EFI_IFR_SET - 0x2C
|
||||
{ sizeof (EFI_IFR_READ), 0 }, // EFI_IFR_READ - 0x2D
|
||||
{ sizeof (EFI_IFR_WRITE), 0 }, // EFI_IFR_WRITE - 0x2E
|
||||
{ sizeof (EFI_IFR_EQUAL), 0 }, // EFI_IFR_EQUAL_OP - 0x2F
|
||||
{ sizeof (EFI_IFR_NOT_EQUAL), 0 }, // EFI_IFR_NOT_EQUAL_OP
|
||||
{ sizeof (EFI_IFR_GREATER_THAN), 0 }, // EFI_IFR_GREATER_THAN_OP
|
||||
@@ -1298,7 +1301,7 @@ static struct {
|
||||
{ sizeof (EFI_IFR_VALUE), 1 }, // EFI_IFR_VALUE_OP
|
||||
{ sizeof (EFI_IFR_DEFAULT), 0 }, // EFI_IFR_DEFAULT_OP
|
||||
{ sizeof (EFI_IFR_DEFAULTSTORE), 0 }, // EFI_IFR_DEFAULTSTORE_OP - 0x5C
|
||||
{ 0, 0}, // 0x5D
|
||||
{ sizeof (EFI_IFR_FORM_MAP), 1}, // EFI_IFR_FORM_MAP_OP - 0x5D
|
||||
{ sizeof (EFI_IFR_CATENATE), 0 }, // EFI_IFR_CATENATE_OP
|
||||
{ sizeof (EFI_IFR_GUID), 0 }, // EFI_IFR_GUID_OP
|
||||
{ sizeof (EFI_IFR_SECURITY), 0 }, // EFI_IFR_SECURITY_OP - 0x60
|
||||
@@ -1313,9 +1316,9 @@ static struct {
|
||||
"EFI_IFR_ACTION", "EFI_IFR_RESET_BUTTON", "EFI_IFR_FORM_SET", "EFI_IFR_REF", "EFI_IFR_NO_SUBMIT_IF", "EFI_IFR_INCONSISTENT_IF",
|
||||
"EFI_IFR_EQ_ID_VAL", "EFI_IFR_EQ_ID_ID", "EFI_IFR_EQ_ID_LIST", "EFI_IFR_AND", "EFI_IFR_OR", "EFI_IFR_NOT",
|
||||
"EFI_IFR_RULE", "EFI_IFR_GRAY_OUT_IF", "EFI_IFR_DATE", "EFI_IFR_TIME", "EFI_IFR_STRING", "EFI_IFR_REFRESH",
|
||||
"EFI_IFR_DISABLE_IF", "EFI_IFR_INVALID", "EFI_IFR_TO_LOWER", "EFI_IFR_TO_UPPER", "EFI_IFR_INVALID", "EFI_IFR_ORDERED_LIST",
|
||||
"EFI_IFR_DISABLE_IF", "EFI_IFR_INVALID", "EFI_IFR_TO_LOWER", "EFI_IFR_TO_UPPER", "EFI_IFR_MAP", "EFI_IFR_ORDERED_LIST",
|
||||
"EFI_IFR_VARSTORE", "EFI_IFR_VARSTORE_NAME_VALUE", "EFI_IFR_VARSTORE_EFI", "EFI_IFR_VARSTORE_DEVICE", "EFI_IFR_VERSION", "EFI_IFR_END",
|
||||
"EFI_IFR_MATCH", "EFI_IFR_INVALID", "EFI_IFR_INVALID", "EFI_IFR_INVALID", "EFI_IFR_INVALID", "EFI_IFR_EQUAL",
|
||||
"EFI_IFR_MATCH", "EFI_IFR_GET", "EFI_IFR_SET", "EFI_IFR_READ", "EFI_IFR_WRITE", "EFI_IFR_EQUAL",
|
||||
"EFI_IFR_NOT_EQUAL", "EFI_IFR_GREATER_THAN", "EFI_IFR_GREATER_EQUAL", "EFI_IFR_LESS_THAN", "EFI_IFR_LESS_EQUAL", "EFI_IFR_BITWISE_AND",
|
||||
"EFI_IFR_BITWISE_OR", "EFI_IFR_BITWISE_NOT", "EFI_IFR_SHIFT_LEFT", "EFI_IFR_SHIFT_RIGHT", "EFI_IFR_ADD", "EFI_IFR_SUBTRACT",
|
||||
"EFI_IFR_MULTIPLY", "EFI_IFR_DIVIDE", "EFI_IFR_MODULO", "EFI_IFR_RULE_REF", "EFI_IFR_QUESTION_REF1", "EFI_IFR_QUESTION_REF2",
|
||||
@@ -1323,7 +1326,7 @@ static struct {
|
||||
"EFI_IFR_TO_UINT", "EFI_IFR_TO_STRING", "EFI_IFR_TO_BOOLEAN", "EFI_IFR_MID", "EFI_IFR_FIND", "EFI_IFR_TOKEN",
|
||||
"EFI_IFR_STRING_REF1","EFI_IFR_STRING_REF2", "EFI_IFR_CONDITIONAL", "EFI_IFR_QUESTION_REF3", "EFI_IFR_ZERO", "EFI_IFR_ONE",
|
||||
"EFI_IFR_ONES", "EFI_IFR_UNDEFINED", "EFI_IFR_LENGTH", "EFI_IFR_DUP", "EFI_IFR_THIS", "EFI_IFR_SPAN",
|
||||
"EFI_IFR_VALUE", "EFI_IFR_DEFAULT", "EFI_IFR_DEFAULTSTORE", "EFI_IFR_INVALID", "EFI_IFR_CATENATE", "EFI_IFR_GUID",
|
||||
"EFI_IFR_VALUE", "EFI_IFR_DEFAULT", "EFI_IFR_DEFAULTSTORE", "EFI_IFR_FORM_MAP", "EFI_IFR_CATENATE", "EFI_IFR_GUID",
|
||||
"EFI_IFR_SECURITY",
|
||||
};
|
||||
|
||||
@@ -1340,7 +1343,7 @@ CIFROBJ_DEBUG_PRINT (
|
||||
|
||||
#endif
|
||||
|
||||
bool gCreateOp = TRUE;
|
||||
BOOLEAN gCreateOp = TRUE;
|
||||
|
||||
CIfrObj::CIfrObj (
|
||||
IN UINT8 OpCode,
|
||||
@@ -1396,4 +1399,4 @@ CIfrOpHeader::CIfrOpHeader (
|
||||
mHeader = OpHdr.mHeader;
|
||||
}
|
||||
|
||||
UINT32 CIfrForm::FormIdBitMap[EFI_FREE_FORM_ID_BITMAP_SIZE] = {0, };
|
||||
UINT32 CIfrFormId::FormIdBitMap[EFI_FREE_FORM_ID_BITMAP_SIZE] = {0, };
|
||||
|
@@ -2,7 +2,7 @@
|
||||
|
||||
The definition of CFormPkg's member function
|
||||
|
||||
Copyright (c) 2004 - 2009, Intel Corporation
|
||||
Copyright (c) 2004 - 2010, 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
|
||||
@@ -81,7 +81,7 @@ struct SPendingAssign {
|
||||
CHAR8 *mMsg;
|
||||
struct SPendingAssign *mNext;
|
||||
|
||||
SPendingAssign (IN CHAR8 *, IN VOID *, IN UINT32, IN UINT32, IN CHAR8 *);
|
||||
SPendingAssign (IN CHAR8 *, IN VOID *, IN UINT32, IN UINT32, IN CONST CHAR8 *);
|
||||
~SPendingAssign ();
|
||||
|
||||
VOID SetAddrAndLen (IN VOID *, IN UINT32);
|
||||
@@ -108,8 +108,8 @@ private:
|
||||
|
||||
UINT32 mPkgLength;
|
||||
|
||||
VOID _WRITE_PKG_LINE (IN FILE *, IN UINT32 , IN CHAR8 *, IN CHAR8 *, IN UINT32);
|
||||
VOID _WRITE_PKG_END (IN FILE *, IN UINT32 , IN CHAR8 *, IN CHAR8 *, IN UINT32);
|
||||
VOID _WRITE_PKG_LINE (IN FILE *, IN UINT32 , IN CONST CHAR8 *, IN CHAR8 *, IN UINT32);
|
||||
VOID _WRITE_PKG_END (IN FILE *, IN UINT32 , IN CONST CHAR8 *, IN CHAR8 *, IN UINT32);
|
||||
|
||||
private:
|
||||
SPendingAssign *PendingAssignList;
|
||||
@@ -131,7 +131,7 @@ public:
|
||||
EFI_VFR_RETURN_CODE GenCFile (IN CHAR8 *, IN FILE *, IN PACKAGE_DATA *PkgData = NULL);
|
||||
|
||||
public:
|
||||
EFI_VFR_RETURN_CODE AssignPending (IN CHAR8 *, IN VOID *, IN UINT32, IN UINT32, IN CHAR8 *Msg = NULL);
|
||||
EFI_VFR_RETURN_CODE AssignPending (IN CHAR8 *, IN VOID *, IN UINT32, IN UINT32, IN CONST CHAR8 *Msg = NULL);
|
||||
VOID DoPendingAssign (IN CHAR8 *, IN VOID *, IN UINT32);
|
||||
bool HavePendingUnassigned (VOID);
|
||||
VOID PendingAssignPrintAll (VOID);
|
||||
@@ -195,11 +195,11 @@ extern CIfrRecordInfoDB gCIfrRecordInfoDB;
|
||||
/*
|
||||
* The definition of CIfrObj
|
||||
*/
|
||||
extern bool gCreateOp;
|
||||
extern BOOLEAN gCreateOp;
|
||||
|
||||
class CIfrObj {
|
||||
private:
|
||||
bool mDelayEmit;
|
||||
BOOLEAN mDelayEmit;
|
||||
|
||||
CHAR8 *mObjBinBuf;
|
||||
UINT8 mObjBinLen;
|
||||
@@ -227,7 +227,7 @@ public:
|
||||
|
||||
inline bool ExpendObjBin (IN UINT8 Size) {
|
||||
if ((mDelayEmit == TRUE) && ((mObjBinLen + Size) > mObjBinLen)) {
|
||||
mObjBinLen += Size;
|
||||
mObjBinLen = mObjBinLen + Size;
|
||||
return TRUE;
|
||||
} else {
|
||||
return FALSE;
|
||||
@@ -248,7 +248,7 @@ public:
|
||||
|
||||
VOID IncLength (UINT8 Size) {
|
||||
if ((mHeader->Length + Size) > mHeader->Length) {
|
||||
mHeader->Length += Size;
|
||||
mHeader->Length = mHeader->Length + Size;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -557,6 +557,7 @@ static CIfrMinMaxStepData *gCurrentMinMaxData = NULL;
|
||||
class CIfrFormSet : public CIfrObj, public CIfrOpHeader {
|
||||
private:
|
||||
EFI_IFR_FORM_SET *mFormSet;
|
||||
EFI_GUID *mClassGuid;
|
||||
|
||||
public:
|
||||
CIfrFormSet (UINT8 Size) : CIfrObj (EFI_IFR_FORM_SET_OP, (CHAR8 **)&mFormSet, Size),
|
||||
@@ -565,6 +566,7 @@ public:
|
||||
mFormSet->FormSetTitle = EFI_STRING_ID_INVALID;
|
||||
mFormSet->Flags = 0;
|
||||
memset (&mFormSet->Guid, 0, sizeof (EFI_GUID));
|
||||
mClassGuid = (EFI_GUID *) (mFormSet + 1);
|
||||
}
|
||||
|
||||
VOID SetGuid (IN EFI_GUID *Guid) {
|
||||
@@ -580,7 +582,7 @@ public:
|
||||
}
|
||||
|
||||
VOID SetClassGuid (IN EFI_GUID *Guid) {
|
||||
memcpy (&(mFormSet->ClassGuid[mFormSet->Flags++]), Guid, sizeof (EFI_GUID));
|
||||
memcpy (&(mClassGuid[mFormSet->Flags++]), Guid, sizeof (EFI_GUID));
|
||||
}
|
||||
|
||||
UINT8 GetFlags() {
|
||||
@@ -620,10 +622,8 @@ public:
|
||||
#define EFI_FORM_ID_MAX 0xFFFF
|
||||
#define EFI_FREE_FORM_ID_BITMAP_SIZE ((EFI_FORM_ID_MAX + 1) / EFI_BITS_PER_UINT32)
|
||||
|
||||
class CIfrForm : public CIfrObj, public CIfrOpHeader {
|
||||
private:
|
||||
EFI_IFR_FORM *mForm;
|
||||
|
||||
class CIfrFormId {
|
||||
public:
|
||||
STATIC UINT32 FormIdBitMap[EFI_FREE_FORM_ID_BITMAP_SIZE];
|
||||
|
||||
STATIC BOOLEAN ChekFormIdFree (IN EFI_FORM_ID FormId) {
|
||||
@@ -639,6 +639,11 @@ private:
|
||||
|
||||
FormIdBitMap[Index] |= (0x80000000 >> Offset);
|
||||
}
|
||||
};
|
||||
|
||||
class CIfrForm : public CIfrObj, public CIfrOpHeader {
|
||||
private:
|
||||
EFI_IFR_FORM *mForm;
|
||||
|
||||
public:
|
||||
CIfrForm () : CIfrObj (EFI_IFR_FORM_OP, (CHAR8 **)&mForm),
|
||||
@@ -654,11 +659,11 @@ public:
|
||||
//
|
||||
return VFR_RETURN_INVALID_PARAMETER;
|
||||
}
|
||||
if (CIfrForm::ChekFormIdFree (FormId) == FALSE) {
|
||||
if (CIfrFormId::ChekFormIdFree (FormId) == FALSE) {
|
||||
return VFR_RETURN_FORMID_REDEFINED;
|
||||
}
|
||||
mForm->FormId = FormId;
|
||||
CIfrForm::MarkFormIdUsed (FormId);
|
||||
CIfrFormId::MarkFormIdUsed (FormId);
|
||||
return VFR_RETURN_SUCCESS;
|
||||
}
|
||||
|
||||
@@ -667,6 +672,44 @@ public:
|
||||
}
|
||||
};
|
||||
|
||||
class CIfrFormMap : public CIfrObj, public CIfrOpHeader {
|
||||
private:
|
||||
EFI_IFR_FORM_MAP *mFormMap;
|
||||
EFI_IFR_FORM_MAP_METHOD *mMethodMap;
|
||||
|
||||
public:
|
||||
CIfrFormMap () : CIfrObj (EFI_IFR_FORM_MAP_OP, (CHAR8 **)&mFormMap, sizeof (EFI_IFR_FORM_MAP), TRUE),
|
||||
CIfrOpHeader (EFI_IFR_FORM_MAP_OP, &mFormMap->Header) {
|
||||
mFormMap->FormId = 0;
|
||||
mMethodMap = (EFI_IFR_FORM_MAP_METHOD *) (mFormMap + 1);
|
||||
}
|
||||
|
||||
EFI_VFR_RETURN_CODE SetFormId (IN EFI_FORM_ID FormId) {
|
||||
if (FormId == 0) {
|
||||
//
|
||||
// FormId can't be 0.
|
||||
//
|
||||
return VFR_RETURN_INVALID_PARAMETER;
|
||||
}
|
||||
if (CIfrFormId::ChekFormIdFree (FormId) == FALSE) {
|
||||
return VFR_RETURN_FORMID_REDEFINED;
|
||||
}
|
||||
mFormMap->FormId = FormId;
|
||||
CIfrFormId::MarkFormIdUsed (FormId);
|
||||
return VFR_RETURN_SUCCESS;
|
||||
}
|
||||
|
||||
VOID SetFormMapMethod (IN EFI_STRING_ID MethodTitle, IN EFI_GUID *MethodGuid) {
|
||||
if (ExpendObjBin (sizeof (EFI_IFR_FORM_MAP_METHOD))) {
|
||||
IncLength (sizeof (EFI_IFR_FORM_MAP_METHOD));
|
||||
|
||||
mMethodMap->MethodTitle = MethodTitle;
|
||||
memcpy (&(mMethodMap->MethodIdentifier), MethodGuid, sizeof (EFI_GUID));
|
||||
mMethodMap ++;
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
class CIfrVarStore : public CIfrObj, public CIfrOpHeader {
|
||||
private:
|
||||
EFI_IFR_VARSTORE *mVarStore;
|
||||
@@ -696,7 +739,7 @@ public:
|
||||
UINT8 Len;
|
||||
|
||||
if (Name != NULL) {
|
||||
Len = strlen (Name);
|
||||
Len = (UINT8) strlen (Name);
|
||||
if (Len != 0) {
|
||||
if (ExpendObjBin (Len) == TRUE) {
|
||||
IncLength (Len);
|
||||
@@ -832,6 +875,66 @@ public:
|
||||
|
||||
};
|
||||
|
||||
class CIfrRead : public CIfrObj, public CIfrOpHeader{
|
||||
private:
|
||||
EFI_IFR_READ *mRead;
|
||||
|
||||
public:
|
||||
CIfrRead () : CIfrObj (EFI_IFR_READ_OP, (CHAR8 **)&mRead),
|
||||
CIfrOpHeader (EFI_IFR_READ_OP, &mRead->Header) {}
|
||||
|
||||
};
|
||||
|
||||
class CIfrWrite : public CIfrObj, public CIfrOpHeader{
|
||||
private:
|
||||
EFI_IFR_WRITE *mWrite;
|
||||
|
||||
public:
|
||||
CIfrWrite () : CIfrObj (EFI_IFR_WRITE_OP, (CHAR8 **)&mWrite),
|
||||
CIfrOpHeader (EFI_IFR_WRITE_OP, &mWrite->Header) {}
|
||||
|
||||
};
|
||||
|
||||
class CIfrGet : public CIfrObj, public CIfrOpHeader{
|
||||
private:
|
||||
EFI_IFR_GET *mGet;
|
||||
|
||||
public:
|
||||
CIfrGet (
|
||||
IN UINT32 LineNo
|
||||
) : CIfrObj (EFI_IFR_GET_OP, (CHAR8 **)&mGet),
|
||||
CIfrOpHeader (EFI_IFR_GET_OP, &mGet->Header) {
|
||||
SetLineNo (LineNo);
|
||||
}
|
||||
|
||||
VOID SetVarInfo (IN EFI_VARSTORE_INFO *Info) {
|
||||
mGet->VarStoreId = Info->mVarStoreId;
|
||||
mGet->VarStoreInfo.VarName = Info->mInfo.mVarName;
|
||||
mGet->VarStoreInfo.VarOffset = Info->mInfo.mVarOffset;
|
||||
mGet->VarStoreType = Info->mVarType;
|
||||
}
|
||||
};
|
||||
|
||||
class CIfrSet : public CIfrObj, public CIfrOpHeader{
|
||||
private:
|
||||
EFI_IFR_SET *mSet;
|
||||
|
||||
public:
|
||||
CIfrSet (
|
||||
IN UINT32 LineNo
|
||||
) : CIfrObj (EFI_IFR_SET_OP, (CHAR8 **)&mSet),
|
||||
CIfrOpHeader (EFI_IFR_SET_OP, &mSet->Header) {
|
||||
SetLineNo (LineNo);
|
||||
}
|
||||
|
||||
VOID SetVarInfo (IN EFI_VARSTORE_INFO *Info) {
|
||||
mSet->VarStoreId = Info->mVarStoreId;
|
||||
mSet->VarStoreInfo.VarName = Info->mInfo.mVarName;
|
||||
mSet->VarStoreInfo.VarOffset = Info->mInfo.mVarOffset;
|
||||
mSet->VarStoreType = Info->mVarType;
|
||||
}
|
||||
};
|
||||
|
||||
class CIfrSubtitle : public CIfrObj, public CIfrOpHeader, public CIfrStatementHeader {
|
||||
private:
|
||||
EFI_IFR_SUBTITLE *mSubtitle;
|
||||
@@ -2310,6 +2413,19 @@ public:
|
||||
}
|
||||
};
|
||||
|
||||
class CIfrMap : public CIfrObj, public CIfrOpHeader{
|
||||
private:
|
||||
EFI_IFR_MAP *mMap;
|
||||
|
||||
public:
|
||||
CIfrMap (
|
||||
IN UINT32 LineNo
|
||||
) : CIfrObj (EFI_IFR_MAP_OP, (CHAR8 **)&mMap),
|
||||
CIfrOpHeader (EFI_IFR_MAP_OP, &mMap->Header) {
|
||||
SetLineNo (LineNo);
|
||||
}
|
||||
};
|
||||
|
||||
class CIfrMatch : public CIfrObj, public CIfrOpHeader {
|
||||
private:
|
||||
EFI_IFR_MATCH *mMatch;
|
||||
|
@@ -1,5 +1,5 @@
|
||||
/*++
|
||||
Copyright (c) 2004 - 2009, Intel Corporation
|
||||
Copyright (c) 2004 - 2010, 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
|
||||
@@ -131,6 +131,9 @@ VfrParserStart (
|
||||
#token EndList("endlist") "endlist"
|
||||
#token EndForm("endform") "endform"
|
||||
#token Form("form") "form"
|
||||
#token FormMap("formmap") "formmap"
|
||||
#token MapTitle("maptitle") "maptitle"
|
||||
#token MapGuid("mapguid") "mapguid"
|
||||
#token Subtitle("subtitle") "subtitle"
|
||||
#token Help("help") "help"
|
||||
#token Text("text") "text"
|
||||
@@ -214,6 +217,8 @@ VfrParserStart (
|
||||
#token Rule("rule") "rule"
|
||||
#token EndRule("endrule") "endrule"
|
||||
#token Value("value") "value"
|
||||
#token Read("read") "read"
|
||||
#token Write("write") "write"
|
||||
#token ResetButton("resetbutton") "resetbutton"
|
||||
#token EndResetButton("endresetbutton") "endresetbutton"
|
||||
#token DefaultStore("defaultstore") "defaultstore"
|
||||
@@ -250,7 +255,8 @@ VfrParserStart (
|
||||
|
||||
vfrProgram > [UINT8 Return] :
|
||||
<<
|
||||
mParserStatus = 0;
|
||||
mParserStatus = 0;
|
||||
mCIfrOpHdrIndex = 0;
|
||||
mConstantOnlyInExpression = FALSE;
|
||||
>>
|
||||
(
|
||||
@@ -335,82 +341,84 @@ vfrDataStructFields :
|
||||
|
||||
dataStructField64 :
|
||||
<< UINT32 ArrayNum = 0; >>
|
||||
"UINT64"
|
||||
D:"UINT64"
|
||||
N:StringIdentifier
|
||||
{
|
||||
OpenBracket I:Number CloseBracket << ArrayNum = _STOU32(I->getText()); >>
|
||||
}
|
||||
";" << _PCATCH(gCVfrVarDataTypeDB.DataTypeAddField (N->getText(), "UINT64", ArrayNum), N); >>
|
||||
";" << _PCATCH(gCVfrVarDataTypeDB.DataTypeAddField (N->getText(), D->getText(), ArrayNum), N); >>
|
||||
;
|
||||
|
||||
dataStructField32 :
|
||||
<< UINT32 ArrayNum = 0; >>
|
||||
"UINT32"
|
||||
D:"UINT32"
|
||||
N:StringIdentifier
|
||||
{
|
||||
OpenBracket I:Number CloseBracket << ArrayNum = _STOU32(I->getText()); >>
|
||||
}
|
||||
";" << _PCATCH(gCVfrVarDataTypeDB.DataTypeAddField (N->getText(), "UINT32", ArrayNum), N); >>
|
||||
";" << _PCATCH(gCVfrVarDataTypeDB.DataTypeAddField (N->getText(), D->getText(), ArrayNum), N); >>
|
||||
;
|
||||
|
||||
dataStructField16 :
|
||||
<< UINT32 ArrayNum = 0; >>
|
||||
<<
|
||||
UINT32 ArrayNum = 0;
|
||||
>>
|
||||
("UINT16" | "CHAR16")
|
||||
N:StringIdentifier
|
||||
{
|
||||
OpenBracket I:Number CloseBracket << ArrayNum = _STOU32(I->getText()); >>
|
||||
}
|
||||
";" << _PCATCH(gCVfrVarDataTypeDB.DataTypeAddField (N->getText(), "UINT16", ArrayNum), N); >>
|
||||
";" << _PCATCH(gCVfrVarDataTypeDB.DataTypeAddField (N->getText(), (CHAR8 *) "UINT16", ArrayNum), N); >>
|
||||
;
|
||||
|
||||
dataStructField8 :
|
||||
<< UINT32 ArrayNum = 0; >>
|
||||
"UINT8"
|
||||
D:"UINT8"
|
||||
N:StringIdentifier
|
||||
{
|
||||
OpenBracket I:Number CloseBracket << ArrayNum = _STOU32(I->getText()); >>
|
||||
}
|
||||
";" << _PCATCH(gCVfrVarDataTypeDB.DataTypeAddField (N->getText(), "UINT8", ArrayNum), N); >>
|
||||
";" << _PCATCH(gCVfrVarDataTypeDB.DataTypeAddField (N->getText(), D->getText(), ArrayNum), N); >>
|
||||
;
|
||||
|
||||
dataStructFieldBool :
|
||||
<< UINT32 ArrayNum = 0; >>
|
||||
"BOOLEAN"
|
||||
D:"BOOLEAN"
|
||||
N:StringIdentifier
|
||||
{
|
||||
OpenBracket I:Number CloseBracket << ArrayNum = _STOU32(I->getText()); >>
|
||||
}
|
||||
";" << _PCATCH(gCVfrVarDataTypeDB.DataTypeAddField (N->getText(), "BOOLEAN", ArrayNum), N); >>
|
||||
";" << _PCATCH(gCVfrVarDataTypeDB.DataTypeAddField (N->getText(), D->getText(), ArrayNum), N); >>
|
||||
;
|
||||
|
||||
dataStructFieldString :
|
||||
<< UINT32 ArrayNum = 0; >>
|
||||
"EFI_STRING_ID"
|
||||
D:"EFI_STRING_ID"
|
||||
N:StringIdentifier
|
||||
{
|
||||
OpenBracket I:Number CloseBracket << ArrayNum = _STOU32(I->getText()); >>
|
||||
}
|
||||
";" << _PCATCH(gCVfrVarDataTypeDB.DataTypeAddField (N->getText(), "EFI_STRING_ID", ArrayNum), N); >>
|
||||
";" << _PCATCH(gCVfrVarDataTypeDB.DataTypeAddField (N->getText(), D->getText(), ArrayNum), N); >>
|
||||
;
|
||||
|
||||
dataStructFieldDate :
|
||||
<< UINT32 ArrayNum = 0; >>
|
||||
"EFI_HII_DATE"
|
||||
D:"EFI_HII_DATE"
|
||||
N:StringIdentifier
|
||||
{
|
||||
OpenBracket I:Number CloseBracket << ArrayNum = _STOU32(I->getText()); >>
|
||||
}
|
||||
";" << _PCATCH(gCVfrVarDataTypeDB.DataTypeAddField (N->getText(), "EFI_HII_DATE", ArrayNum), N); >>
|
||||
";" << _PCATCH(gCVfrVarDataTypeDB.DataTypeAddField (N->getText(), D->getText(), ArrayNum), N); >>
|
||||
;
|
||||
|
||||
dataStructFieldTime :
|
||||
<< UINT32 ArrayNum = 0; >>
|
||||
"EFI_HII_TIME"
|
||||
D:"EFI_HII_TIME"
|
||||
N:StringIdentifier
|
||||
{
|
||||
OpenBracket I:Number CloseBracket << ArrayNum = _STOU32(I->getText()); >>
|
||||
}
|
||||
";" << _PCATCH(gCVfrVarDataTypeDB.DataTypeAddField (N->getText(), "EFI_HII_TIME", ArrayNum), N); >>
|
||||
";" << _PCATCH(gCVfrVarDataTypeDB.DataTypeAddField (N->getText(), D->getText(), ArrayNum), N); >>
|
||||
;
|
||||
|
||||
dataStructFieldUser :
|
||||
@@ -486,24 +494,26 @@ vfrFormSetDefinition :
|
||||
<<
|
||||
switch (ClassGuidNum) {
|
||||
case 0:
|
||||
FSObj = new CIfrFormSet(sizeof(EFI_IFR_FORM_SET));
|
||||
FSObj = new CIfrFormSet(sizeof(EFI_IFR_FORM_SET) + sizeof(EFI_GUID));
|
||||
FSObj->SetClassGuid(&DefaultClassGuid);
|
||||
break;
|
||||
case 1:
|
||||
FSObj = new CIfrFormSet(sizeof(EFI_IFR_FORM_SET));
|
||||
FSObj = new CIfrFormSet(sizeof(EFI_IFR_FORM_SET) + ClassGuidNum * sizeof(EFI_GUID));
|
||||
FSObj->SetClassGuid(&ClassGuid1);
|
||||
break;
|
||||
case 2:
|
||||
FSObj = new CIfrFormSet(sizeof(EFI_IFR_FORM_SET) + sizeof(EFI_GUID));
|
||||
FSObj = new CIfrFormSet(sizeof(EFI_IFR_FORM_SET) + ClassGuidNum * sizeof(EFI_GUID));
|
||||
FSObj->SetClassGuid(&ClassGuid1);
|
||||
FSObj->SetClassGuid(&ClassGuid2);
|
||||
break;
|
||||
default:
|
||||
FSObj = new CIfrFormSet(sizeof(EFI_IFR_FORM_SET) + 2 * sizeof(EFI_GUID));
|
||||
case 3:
|
||||
FSObj = new CIfrFormSet(sizeof(EFI_IFR_FORM_SET) + ClassGuidNum * sizeof(EFI_GUID));
|
||||
FSObj->SetClassGuid(&ClassGuid1);
|
||||
FSObj->SetClassGuid(&ClassGuid2);
|
||||
FSObj->SetClassGuid(&ClassGuid3);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
SET_LINE_INFO (*FSObj, L);
|
||||
@@ -542,6 +552,7 @@ vfrFormSetDefinition :
|
||||
vfrFormSetList :
|
||||
(
|
||||
vfrFormDefinition |
|
||||
vfrFormMapDefinition |
|
||||
vfrStatementImage |
|
||||
vfrStatementVarStoreLinear |
|
||||
vfrStatementVarStoreEfi |
|
||||
@@ -586,12 +597,13 @@ vfrStatementVarStoreLinear :
|
||||
V:Varstore << VSObj.SetLineNo(V->getLine()); >>
|
||||
(
|
||||
TN:StringIdentifier "," << TypeName = TN->getText(); LineNum = TN->getLine(); >>
|
||||
| U8:"UINT8" "," << TypeName = "UINT8"; LineNum = U8->getLine(); >>
|
||||
| U16:"UINT16" "," << TypeName = "UINT16"; LineNum = U16->getLine(); >>
|
||||
| U32:"UINT32" "," << TypeName = "UINT32"; LineNum = U32->getLine(); >>
|
||||
| U64:"UINT64" "," << TypeName = "UINT64"; LineNum = U64->getLine(); >>
|
||||
| D:"EFI_HII_DATE" "," << TypeName = "EFI_HII_DATE"; LineNum = D->getLine(); >>
|
||||
| T:"EFI_HII_TIME" "," << TypeName = "EFI_HII_TIME"; LineNum = T->getLine(); >>
|
||||
| U8:"UINT8" "," << TypeName = U8->getText(); LineNum = U8->getLine(); >>
|
||||
| U16:"UINT16" "," << TypeName = U16->getText(); LineNum = U16->getLine(); >>
|
||||
| C16:"CHAR16" "," << TypeName = (CHAR8 *) "UINT16"; LineNum = C16->getLine(); >>
|
||||
| U32:"UINT32" "," << TypeName = U32->getText(); LineNum = U32->getLine(); >>
|
||||
| U64:"UINT64" "," << TypeName = U64->getText(); LineNum = U64->getLine(); >>
|
||||
| D:"EFI_HII_DATE" "," << TypeName = D->getText(); LineNum = D->getLine(); >>
|
||||
| T:"EFI_HII_TIME" "," << TypeName = T->getText(); LineNum = T->getLine(); >>
|
||||
)
|
||||
{ Key "=" FID:Number "," << // Key is used to assign Varid in Framework VFR but no use in UEFI2.1 VFR
|
||||
if (mCompatibleMode) {
|
||||
@@ -628,7 +640,7 @@ vfrStatementVarStoreLinear :
|
||||
_PCATCH(mCVfrDataStorage.GetVarStoreId(StoreName, &VarStoreId), SN);
|
||||
VSObj.SetVarStoreId (VarStoreId);
|
||||
_PCATCH(gCVfrVarDataTypeDB.GetDataTypeSize(TypeName, &Size), LineNum);
|
||||
VSObj.SetSize (Size);
|
||||
VSObj.SetSize ((UINT16) Size);
|
||||
VSObj.SetName (SN->getText());
|
||||
>>
|
||||
";"
|
||||
@@ -771,11 +783,11 @@ vfrQuestionHeader[CIfrQuestionHeader & QHObj, EFI_QUESION_TYPE QType = QUESTION_
|
||||
mCVfrQuestionDB.RegisterQuestion (QName, VarIdStr, QId);
|
||||
break;
|
||||
case QUESTION_DATE:
|
||||
mCVfrQuestionDB.RegisterNewDateQuestion (QName, VarIdStr, QId);
|
||||
break;
|
||||
mCVfrQuestionDB.RegisterNewDateQuestion (QName, VarIdStr, QId);
|
||||
break;
|
||||
case QUESTION_TIME:
|
||||
mCVfrQuestionDB.RegisterNewTimeQuestion (QName, VarIdStr, QId);
|
||||
break;
|
||||
mCVfrQuestionDB.RegisterNewTimeQuestion (QName, VarIdStr, QId);
|
||||
break;
|
||||
default:
|
||||
_PCATCH(VFR_RETURN_FATAL_ERROR);
|
||||
}
|
||||
@@ -820,7 +832,7 @@ questionheaderFlagsField[UINT8 & Flags] :
|
||||
| LateCheckFlag
|
||||
;
|
||||
|
||||
vfrStorageVarId[EFI_VARSTORE_INFO & Info, CHAR8 *&QuestVarIdStr] :
|
||||
vfrStorageVarId[EFI_VARSTORE_INFO & Info, CHAR8 *&QuestVarIdStr, BOOLEAN CheckFlag = TRUE] :
|
||||
<<
|
||||
UINT32 Idx;
|
||||
UINT32 LineNo;
|
||||
@@ -853,9 +865,11 @@ vfrStorageVarId[EFI_VARSTORE_INFO & Info, CHAR8 *&QuestVarIdStr] :
|
||||
);
|
||||
VfrReturnCode = mCVfrDataStorage.GetVarStoreType (SName, VarStoreType);
|
||||
}
|
||||
_PCATCH(VfrReturnCode, SN1);
|
||||
_PCATCH(mCVfrDataStorage.GetVarStoreId (SName, &$Info.mVarStoreId), SN1);
|
||||
_PCATCH(mCVfrDataStorage.GetNameVarStoreInfo (&$Info, Idx), SN1);
|
||||
if (CheckFlag || VfrReturnCode == VFR_RETURN_SUCCESS) {
|
||||
_PCATCH(VfrReturnCode, SN1);
|
||||
_PCATCH(mCVfrDataStorage.GetVarStoreId (SName, &$Info.mVarStoreId), SN1);
|
||||
_PCATCH(mCVfrDataStorage.GetNameVarStoreInfo (&$Info, Idx), SN1);
|
||||
}
|
||||
>>
|
||||
)
|
||||
|
|
||||
@@ -874,17 +888,21 @@ vfrStorageVarId[EFI_VARSTORE_INFO & Info, CHAR8 *&QuestVarIdStr] :
|
||||
);
|
||||
VfrReturnCode = mCVfrDataStorage.GetVarStoreType (SName, VarStoreType);
|
||||
}
|
||||
_PCATCH(VfrReturnCode, SN2);
|
||||
_PCATCH(mCVfrDataStorage.GetVarStoreId (SName, &$Info.mVarStoreId), SN2);
|
||||
if (VarStoreType == EFI_VFR_VARSTORE_BUFFER) {
|
||||
_PCATCH(mCVfrDataStorage.GetBufferVarStoreDataTypeName(SName, &TName), SN2);
|
||||
_STRCAT(&VarStr, TName);
|
||||
if (CheckFlag || VfrReturnCode == VFR_RETURN_SUCCESS) {
|
||||
_PCATCH(VfrReturnCode, SN2);
|
||||
_PCATCH(mCVfrDataStorage.GetVarStoreId (SName, &$Info.mVarStoreId), SN2);
|
||||
if (VarStoreType == EFI_VFR_VARSTORE_BUFFER) {
|
||||
_PCATCH(mCVfrDataStorage.GetBufferVarStoreDataTypeName(SName, &TName), SN2);
|
||||
_STRCAT(&VarStr, TName);
|
||||
}
|
||||
}
|
||||
>>
|
||||
|
||||
(
|
||||
"." <<
|
||||
_PCATCH(((VarStoreType != EFI_VFR_VARSTORE_BUFFER) ? VFR_RETURN_EFIVARSTORE_USE_ERROR : VFR_RETURN_SUCCESS), SN2);
|
||||
if (CheckFlag || VfrReturnCode == VFR_RETURN_SUCCESS) {
|
||||
_PCATCH(((VarStoreType != EFI_VFR_VARSTORE_BUFFER) ? VFR_RETURN_EFIVARSTORE_USE_ERROR : VFR_RETURN_SUCCESS), SN2);
|
||||
}
|
||||
_STRCAT(&VarIdStr, "."); _STRCAT(&VarStr, ".");
|
||||
>>
|
||||
SF:StringIdentifier << _STRCAT(&VarIdStr, SF->getText()); _STRCAT(&VarStr, SF->getText()); >>
|
||||
@@ -1079,6 +1097,33 @@ vfrFormDefinition :
|
||||
";"
|
||||
;
|
||||
|
||||
vfrFormMapDefinition :
|
||||
<<
|
||||
CIfrFormMap *FMapObj = NULL;
|
||||
UINT32 FormMapMethodNumber = 0;
|
||||
EFI_GUID Guid;
|
||||
>>
|
||||
F:FormMap << FMapObj = new CIfrFormMap(); FMapObj->SetLineNo(F->getLine()); >>
|
||||
FormId "=" S1:Number "," << _PCATCH(FMapObj->SetFormId (_STOFID(S1->getText())), S1); >>
|
||||
(
|
||||
MapTitle "=" "STRING_TOKEN" "\(" S2:Number "\)" ";"
|
||||
MapGuid "=" guidDefinition[Guid] ";" << FMapObj->SetFormMapMethod (_STOFID(S2->getText()), &Guid); FormMapMethodNumber ++; >>
|
||||
)* << if (FormMapMethodNumber == 0) {_PCATCH (VFR_RETURN_INVALID_PARAMETER, F->getLine(), "No MapMethod is set for FormMap!");} delete FMapObj;>>
|
||||
(
|
||||
vfrStatementImage |
|
||||
vfrStatementLocked |
|
||||
vfrStatementRules |
|
||||
vfrStatementDefault |
|
||||
vfrStatementStat |
|
||||
vfrStatementQuestions |
|
||||
vfrStatementConditional |
|
||||
vfrStatementLabel |
|
||||
vfrStatementBanner
|
||||
)*
|
||||
E:EndForm << CRT_END_OP (E); >>
|
||||
";"
|
||||
;
|
||||
|
||||
vfrStatementRules :
|
||||
<< CIfrRule RObj; >>
|
||||
R:Rule << RObj.SetLineNo(R->getLine()); >>
|
||||
@@ -1194,6 +1239,18 @@ vfrStatementValue :
|
||||
"=" vfrStatementExpression[0] << {CIfrEnd EndObj; EndObj.SetLineNo(V->getLine());} >>
|
||||
;
|
||||
|
||||
vfrStatementRead :
|
||||
<< CIfrRead RObj; >>
|
||||
R:Read << RObj.SetLineNo(R->getLine()); >>
|
||||
vfrStatementExpression[0] ";"
|
||||
;
|
||||
|
||||
vfrStatementWrite :
|
||||
<< CIfrWrite WObj; >>
|
||||
W:Write << WObj.SetLineNo(W->getLine()); >>
|
||||
vfrStatementExpression[0] ";"
|
||||
;
|
||||
|
||||
vfrStatementSubTitle :
|
||||
<< CIfrSubtitle SObj; >>
|
||||
L:Subtitle << SObj.SetLineNo(L->getLine()); >>
|
||||
@@ -1268,8 +1325,8 @@ vfrStatementCrossReference :
|
||||
vfrStatementGoto :
|
||||
<<
|
||||
UINT8 RefType = 1;
|
||||
EFI_STRING_ID DevPath;
|
||||
EFI_GUID FSId;
|
||||
EFI_STRING_ID DevPath = EFI_STRING_ID_INVALID;
|
||||
EFI_GUID FSId = {0,};
|
||||
EFI_FORM_ID FId;
|
||||
EFI_QUESTION_ID QId = EFI_QUESTION_ID_INVALID;
|
||||
UINT32 BitMask;
|
||||
@@ -2046,6 +2103,8 @@ vfrStatementQuestionOptionTag :
|
||||
vfrStatementGrayOutIfQuest |
|
||||
vfrStatementValue |
|
||||
vfrStatementDefault |
|
||||
vfrStatementRead |
|
||||
vfrStatementWrite |
|
||||
vfrStatementOptions
|
||||
;
|
||||
|
||||
@@ -2479,6 +2538,7 @@ vfrStatementInvalidSaveRestoreDefaults :
|
||||
#token StringRef("stringref") "stringref"
|
||||
#token PushThis("pushthis") "pushthis"
|
||||
#token Security("security") "security"
|
||||
#token Get("get") "get"
|
||||
#token True("TRUE") "TRUE"
|
||||
#token False("FALSE") "FALSE"
|
||||
#token One("ONE") "ONE"
|
||||
@@ -2490,6 +2550,7 @@ vfrStatementInvalidSaveRestoreDefaults :
|
||||
#token AND("AND") "AND"
|
||||
#token OR("OR") "OR"
|
||||
#token NOT("NOT") "NOT"
|
||||
#token Set("set") "set"
|
||||
#token BitWiseNot("~") "\~"
|
||||
#token BoolVal("boolval") "boolval"
|
||||
#token StringVal("stringval") "stringval"
|
||||
@@ -2500,12 +2561,13 @@ vfrStatementInvalidSaveRestoreDefaults :
|
||||
#token Catenate("catenate") "catenate"
|
||||
#token QuestionRefVal("questionrefval") "questionrefval"
|
||||
#token StringRefVal("stringrefval") "stringrefval"
|
||||
#token Map("map") "map"
|
||||
|
||||
//
|
||||
// Root expression extension function called by other function.
|
||||
//
|
||||
vfrStatementExpression [UINT32 RootLevel, UINT32 ExpOpCount = 0] :
|
||||
<< if ($RootLevel == 0) {_CLEAR_SAVED_OPHDR ();} >>
|
||||
<< if ($RootLevel == 0) {mCIfrOpHdrIndex ++; if (mCIfrOpHdrIndex >= MAX_IFR_EXPRESSION_DEPTH) _PCATCH (VFR_RETURN_INVALID_PARAMETER, 0, "The depth of expression exceeds the max supported level 8!"); _CLEAR_SAVED_OPHDR ();} >>
|
||||
andTerm[$RootLevel, $ExpOpCount]
|
||||
(
|
||||
L:OR andTerm[$RootLevel, $ExpOpCount] << $ExpOpCount++; CIfrOr OObj(L->getLine()); >>
|
||||
@@ -2517,11 +2579,15 @@ vfrStatementExpression [UINT32 RootLevel, UINT32 ExpOpCount = 0] :
|
||||
if ($ExpOpCount > 1 && $RootLevel == 0) {
|
||||
if (_SET_SAVED_OPHDR_SCOPE()) {
|
||||
CIfrEnd EObj;
|
||||
if (mCIfrOpHdrLineNo != 0) {
|
||||
EObj.SetLineNo (mCIfrOpHdrLineNo);
|
||||
if (mCIfrOpHdrLineNo[mCIfrOpHdrIndex] != 0) {
|
||||
EObj.SetLineNo (mCIfrOpHdrLineNo[mCIfrOpHdrIndex]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if ($RootLevel == 0) {
|
||||
mCIfrOpHdrIndex --;
|
||||
}
|
||||
>>
|
||||
;
|
||||
|
||||
@@ -2664,6 +2730,7 @@ atomTerm [UINT32 & RootLevel, UINT32 & ExpOpCount]:
|
||||
| vfrExpressionConstant[$RootLevel, $ExpOpCount]
|
||||
| vfrExpressionUnaryOp[$RootLevel, $ExpOpCount]
|
||||
| vfrExpressionTernaryOp[$RootLevel, $ExpOpCount]
|
||||
| vfrExpressionMap[$RootLevel, $ExpOpCount]
|
||||
| (
|
||||
L:NOT
|
||||
atomTerm[$RootLevel, $ExpOpCount] << { CIfrNot NObj(L->getLine()); $ExpOpCount++; } >>
|
||||
@@ -2705,6 +2772,7 @@ vfrExpressionBuildInFunction [UINT32 & RootLevel, UINT32 & ExpOpCount] :
|
||||
| stringref1Exp[$RootLevel, $ExpOpCount]
|
||||
| pushthisExp[$RootLevel, $ExpOpCount]
|
||||
| securityExp[$RootLevel, $ExpOpCount]
|
||||
| getExp[$RootLevel, $ExpOpCount]
|
||||
;
|
||||
|
||||
dupExp [UINT32 & RootLevel, UINT32 & ExpOpCount] :
|
||||
@@ -2937,8 +3005,8 @@ ideqvallistExp[UINT32 & RootLevel, UINT32 & ExpOpCount] :
|
||||
questionref13Exp[UINT32 & RootLevel, UINT32 & ExpOpCount] :
|
||||
<<
|
||||
UINT8 Type = 0x1;
|
||||
EFI_STRING_ID DevPath;
|
||||
EFI_GUID Guid;
|
||||
EFI_STRING_ID DevPath = EFI_STRING_ID_INVALID;
|
||||
EFI_GUID Guid = {0,};
|
||||
EFI_QUESTION_ID QId = EFI_QUESTION_ID_INVALID;
|
||||
UINT32 BitMask;
|
||||
CHAR8 *QName = NULL;
|
||||
@@ -2990,8 +3058,19 @@ rulerefExp[UINT32 & RootLevel, UINT32 & ExpOpCount] :
|
||||
// stringref (STR_FORM_SET_TITLE)
|
||||
//
|
||||
stringref1Exp[UINT32 & RootLevel, UINT32 & ExpOpCount] :
|
||||
<<
|
||||
EFI_STRING_ID RefStringId = EFI_STRING_ID_INVALID;
|
||||
>>
|
||||
L:StringRef
|
||||
"\(" S:Number "\)" << { CIfrStringRef1 SR1Obj(L->getLine()); _SAVE_OPHDR_COND (SR1Obj, ($ExpOpCount == 0), L->getLine()); SR1Obj.SetStringId (_STOSID(S->getText())); $ExpOpCount++; } >>
|
||||
"\("
|
||||
(
|
||||
"STRING_TOKEN"
|
||||
"\("
|
||||
S:Number << RefStringId = _STOSID(S->getText()); >>
|
||||
"\)"
|
||||
| I:Number << RefStringId = _STOSID(I->getText()); >>
|
||||
)
|
||||
"\)" << { CIfrStringRef1 SR1Obj(L->getLine()); _SAVE_OPHDR_COND (SR1Obj, ($ExpOpCount == 0), L->getLine()); SR1Obj.SetStringId (RefStringId); $ExpOpCount++; } >>
|
||||
;
|
||||
|
||||
pushthisExp[UINT32 & RootLevel, UINT32 & ExpOpCount] :
|
||||
@@ -3006,6 +3085,84 @@ securityExp[UINT32 & RootLevel, UINT32 & ExpOpCount] :
|
||||
"\(" guidDefinition[Guid] "\)" << { CIfrSecurity SObj(L->getLine()); _SAVE_OPHDR_COND (SObj, ($ExpOpCount == 0), L->getLine()); SObj.SetPermissions (&Guid); } $ExpOpCount++; >>
|
||||
;
|
||||
|
||||
numericVarStoreType [UINT8 & VarType] :
|
||||
"NUMERIC_SIZE_1" << $VarType = EFI_IFR_NUMERIC_SIZE_1; >>
|
||||
| "NUMERIC_SIZE_2" << $VarType = EFI_IFR_NUMERIC_SIZE_2; >>
|
||||
| "NUMERIC_SIZE_4" << $VarType = EFI_IFR_NUMERIC_SIZE_4; >>
|
||||
| "NUMERIC_SIZE_8" << $VarType = EFI_IFR_NUMERIC_SIZE_8; >>
|
||||
;
|
||||
|
||||
getExp[UINT32 & RootLevel, UINT32 & ExpOpCount] :
|
||||
<<
|
||||
EFI_VARSTORE_INFO Info;
|
||||
CHAR8 *VarIdStr = NULL;
|
||||
EFI_QUESTION_ID QId = EFI_QUESTION_ID_INVALID;
|
||||
UINT32 Mask = 0;
|
||||
EFI_QUESION_TYPE QType = QUESTION_NORMAL;
|
||||
UINT8 VarType = EFI_IFR_TYPE_UNDEFINED;
|
||||
UINT32 VarSize = 0;
|
||||
Info.mVarStoreId = 0;
|
||||
>>
|
||||
L:Get
|
||||
"\("
|
||||
vfrStorageVarId[Info, VarIdStr, FALSE]
|
||||
{"\|" FLAGS "=" numericVarStoreType [VarType] }
|
||||
"\)" <<
|
||||
{
|
||||
if (Info.mVarStoreId == 0) {
|
||||
// support Date/Time question
|
||||
mCVfrQuestionDB.GetQuestionId (NULL, VarIdStr, QId, Mask, &QType);
|
||||
if (QId == EFI_QUESTION_ID_INVALID || Mask == 0 || QType == QUESTION_NORMAL) {
|
||||
_PCATCH(VFR_RETURN_UNSUPPORTED, L->getLine(), "Get/Set opcode can't get the enough varstore information");
|
||||
}
|
||||
if (QType == QUESTION_DATE) {
|
||||
Info.mVarType = EFI_IFR_TYPE_DATE;
|
||||
} else if (QType == QUESTION_TIME) {
|
||||
Info.mVarType = EFI_IFR_TYPE_TIME;
|
||||
}
|
||||
switch (Mask) {
|
||||
case DATE_YEAR_BITMASK:
|
||||
Info.mInfo.mVarOffset = 0;
|
||||
break;
|
||||
case DATE_DAY_BITMASK:
|
||||
Info.mInfo.mVarOffset = 3;
|
||||
break;
|
||||
case TIME_HOUR_BITMASK:
|
||||
Info.mInfo.mVarOffset = 0;
|
||||
break;
|
||||
case TIME_MINUTE_BITMASK:
|
||||
Info.mInfo.mVarOffset = 1;
|
||||
break;
|
||||
case TIME_SECOND_BITMASK:
|
||||
Info.mInfo.mVarOffset = 2;
|
||||
break;
|
||||
default:
|
||||
_PCATCH(VFR_RETURN_UNSUPPORTED, L->getLine(), "Get/Set opcode can't get the enough varstore information");
|
||||
break;
|
||||
}
|
||||
} else {
|
||||
if ((mCVfrDataStorage.GetVarStoreType(Info.mVarStoreId) == EFI_VFR_VARSTORE_NAME) && (VarType == EFI_IFR_TYPE_UNDEFINED)) {
|
||||
_PCATCH(VFR_RETURN_UNSUPPORTED, L->getLine(), "Get/Set opcode don't support name string");
|
||||
}
|
||||
if (VarType != EFI_IFR_TYPE_UNDEFINED) {
|
||||
Info.mVarType = VarType;
|
||||
_PCATCH(gCVfrVarDataTypeDB.GetDataTypeSize (Info.mVarType, &VarSize), L->getLine(), "Get/Set opcode can't get var type size");
|
||||
Info.mVarTotalSize = VarSize;
|
||||
}
|
||||
_PCATCH(gCVfrVarDataTypeDB.GetDataTypeSize (Info.mVarType, &VarSize), L->getLine(), "Get/Set opcode can't get var type size");
|
||||
if (VarSize != Info.mVarTotalSize) {
|
||||
_PCATCH(VFR_RETURN_UNSUPPORTED, L->getLine(), "Get/Set opcode don't support data array");
|
||||
}
|
||||
}
|
||||
CIfrGet GObj(L->getLine());
|
||||
_SAVE_OPHDR_COND (GObj, ($ExpOpCount == 0), L->getLine());
|
||||
GObj.SetVarInfo (&Info);
|
||||
delete VarIdStr;
|
||||
$ExpOpCount++;
|
||||
}
|
||||
>>
|
||||
;
|
||||
|
||||
vfrExpressionConstant[UINT32 & RootLevel, UINT32 & ExpOpCount] :
|
||||
L1:True << CIfrTrue TObj(L1->getLine()); _SAVE_OPHDR_COND (TObj, ($ExpOpCount == 0), L1->getLine()); $ExpOpCount++; >>
|
||||
| L2:False << CIfrFalse FObj(L2->getLine()); _SAVE_OPHDR_COND (FObj, ($ExpOpCount == 0), L2->getLine()); $ExpOpCount++; >>
|
||||
@@ -3026,6 +3183,7 @@ vfrExpressionUnaryOp[UINT32 & RootLevel, UINT32 & ExpOpCount] :
|
||||
| unintExp[$RootLevel, $ExpOpCount]
|
||||
| toupperExp[$RootLevel, $ExpOpCount]
|
||||
| tolwerExp[$RootLevel, $ExpOpCount]
|
||||
| setExp[$RootLevel, $ExpOpCount]
|
||||
;
|
||||
|
||||
lengthExp[UINT32 & RootLevel, UINT32 & ExpOpCount] :
|
||||
@@ -3086,6 +3244,78 @@ tolwerExp[UINT32 & RootLevel, UINT32 & ExpOpCount] :
|
||||
<< { CIfrToLower TLObj(L->getLine()); $ExpOpCount++; } >>
|
||||
;
|
||||
|
||||
setExp[UINT32 & RootLevel, UINT32 & ExpOpCount] :
|
||||
<<
|
||||
EFI_VARSTORE_INFO Info;
|
||||
CHAR8 *VarIdStr = NULL;
|
||||
EFI_QUESTION_ID QId = EFI_QUESTION_ID_INVALID;
|
||||
UINT32 Mask = 0;
|
||||
EFI_QUESION_TYPE QType = QUESTION_NORMAL;
|
||||
UINT8 VarType = EFI_IFR_TYPE_UNDEFINED;
|
||||
UINT32 VarSize = 0;
|
||||
Info.mVarStoreId = 0;
|
||||
>>
|
||||
L:Set
|
||||
"\("
|
||||
vfrStorageVarId[Info, VarIdStr, FALSE]
|
||||
{"\|" FLAG "=" numericVarStoreType [VarType] }
|
||||
"," vfrStatementExpressionSub[$RootLevel + 1, $ExpOpCount]
|
||||
"\)"
|
||||
<<
|
||||
{
|
||||
if (Info.mVarStoreId == 0) {
|
||||
// support Date/Time question
|
||||
mCVfrQuestionDB.GetQuestionId (NULL, VarIdStr, QId, Mask, &QType);
|
||||
if (QId == EFI_QUESTION_ID_INVALID || Mask == 0 || QType == QUESTION_NORMAL) {
|
||||
_PCATCH(VFR_RETURN_UNSUPPORTED, L->getLine(), "Get/Set opcode can't get the enough varstore information");
|
||||
}
|
||||
if (QType == QUESTION_DATE) {
|
||||
Info.mVarType = EFI_IFR_TYPE_DATE;
|
||||
} else if (QType == QUESTION_TIME) {
|
||||
Info.mVarType = EFI_IFR_TYPE_TIME;
|
||||
}
|
||||
switch (Mask) {
|
||||
case DATE_YEAR_BITMASK:
|
||||
Info.mInfo.mVarOffset = 0;
|
||||
break;
|
||||
case DATE_DAY_BITMASK:
|
||||
Info.mInfo.mVarOffset = 3;
|
||||
break;
|
||||
case TIME_HOUR_BITMASK:
|
||||
Info.mInfo.mVarOffset = 0;
|
||||
break;
|
||||
case TIME_MINUTE_BITMASK:
|
||||
Info.mInfo.mVarOffset = 1;
|
||||
break;
|
||||
case TIME_SECOND_BITMASK:
|
||||
Info.mInfo.mVarOffset = 2;
|
||||
break;
|
||||
default:
|
||||
_PCATCH(VFR_RETURN_UNSUPPORTED, L->getLine(), "Get/Set opcode can't get the enough varstore information");
|
||||
break;
|
||||
}
|
||||
} else {
|
||||
if ((mCVfrDataStorage.GetVarStoreType(Info.mVarStoreId) == EFI_VFR_VARSTORE_NAME) && (VarType == EFI_IFR_TYPE_UNDEFINED)) {
|
||||
_PCATCH(VFR_RETURN_UNSUPPORTED, L->getLine(), "Get/Set opcode don't support name string");
|
||||
}
|
||||
if (VarType != EFI_IFR_TYPE_UNDEFINED) {
|
||||
Info.mVarType = VarType;
|
||||
_PCATCH(gCVfrVarDataTypeDB.GetDataTypeSize (Info.mVarType, &VarSize), L->getLine(), "Get/Set opcode can't get var type size");
|
||||
Info.mVarTotalSize = VarSize;
|
||||
}
|
||||
_PCATCH(gCVfrVarDataTypeDB.GetDataTypeSize (Info.mVarType, &VarSize), L->getLine(), "Get/Set opcode can't get var type size");
|
||||
if (VarSize != Info.mVarTotalSize) {
|
||||
_PCATCH(VFR_RETURN_UNSUPPORTED, L->getLine(), "Get/Set opcode don't support data array");
|
||||
}
|
||||
}
|
||||
CIfrSet TSObj(L->getLine());
|
||||
TSObj.SetVarInfo (&Info);
|
||||
delete VarIdStr;
|
||||
$ExpOpCount++;
|
||||
}
|
||||
>>
|
||||
;
|
||||
|
||||
vfrExpressionTernaryOp[UINT32 & RootLevel, UINT32 & ExpOpCount] :
|
||||
conditionalExp[$RootLevel, $ExpOpCount]
|
||||
| findExp[$RootLevel, $ExpOpCount]
|
||||
@@ -3161,6 +3391,20 @@ spanExp[UINT32 & RootLevel, UINT32 & ExpOpCount] :
|
||||
"\)" << { CIfrSpan SObj(S->getLine()); SObj.SetFlags(Flags); $ExpOpCount++; } >>
|
||||
;
|
||||
|
||||
vfrExpressionMap [UINT32 & RootLevel, UINT32 & ExpOpCount]:
|
||||
L:Map
|
||||
"\("
|
||||
vfrStatementExpressionSub[$RootLevel + 1, $ExpOpCount]
|
||||
":" << { CIfrMap MObj(L->getLine()); } >>
|
||||
(
|
||||
vfrStatementExpression[0]
|
||||
","
|
||||
vfrStatementExpression[0]
|
||||
";"
|
||||
) *
|
||||
E:"\)" << { CIfrEnd EObj; EObj.SetLineNo(E->getLine()); $ExpOpCount++; } >>
|
||||
;
|
||||
|
||||
spanFlags [UINT8 & Flags] :
|
||||
N:Number << $Flags |= _STOU8(N->getText()); >>
|
||||
| "LAST_NON_MATCH" << $Flags |= 0x00; >>
|
||||
@@ -3185,8 +3429,9 @@ private:
|
||||
CVfrQuestionDB mCVfrQuestionDB;
|
||||
CVfrRulesDB mCVfrRulesDB;
|
||||
|
||||
CIfrOpHeader *mCIfrOpHdr;
|
||||
UINT32 mCIfrOpHdrLineNo;
|
||||
CIfrOpHeader * mCIfrOpHdr[MAX_IFR_EXPRESSION_DEPTH];
|
||||
UINT32 mCIfrOpHdrLineNo[MAX_IFR_EXPRESSION_DEPTH];
|
||||
UINT8 mCIfrOpHdrIndex;
|
||||
VOID _SAVE_OPHDR_COND (IN CIfrOpHeader &, IN BOOLEAN, UINT32 LineNo = 0);
|
||||
VOID _CLEAR_SAVED_OPHDR (VOID);
|
||||
BOOLEAN _SET_SAVED_OPHDR_SCOPE (VOID);
|
||||
@@ -3210,11 +3455,11 @@ private:
|
||||
UINT32 _GET_CURRQEST_ARRAY_SIZE();
|
||||
|
||||
public:
|
||||
VOID _PCATCH (IN INTN, IN INTN, IN ANTLRTokenPtr, IN CHAR8 *);
|
||||
VOID _PCATCH (IN INTN, IN INTN, IN ANTLRTokenPtr, IN CONST CHAR8 *);
|
||||
VOID _PCATCH (IN EFI_VFR_RETURN_CODE);
|
||||
VOID _PCATCH (IN EFI_VFR_RETURN_CODE, IN ANTLRTokenPtr);
|
||||
VOID _PCATCH (IN EFI_VFR_RETURN_CODE, IN UINT32);
|
||||
VOID _PCATCH (IN EFI_VFR_RETURN_CODE, IN UINT32, IN CHAR8 *);
|
||||
VOID _PCATCH (IN EFI_VFR_RETURN_CODE, IN UINT32, IN CONST CHAR8 *);
|
||||
|
||||
VOID syn (ANTLRAbstractToken *, ANTLRChar *, SetWordType *, ANTLRTokenType, INT32);
|
||||
|
||||
@@ -3231,7 +3476,7 @@ public:
|
||||
EFI_FORM_ID _STOFID (IN CHAR8 *);
|
||||
EFI_QUESTION_ID _STOQID (IN CHAR8 *);
|
||||
|
||||
VOID _STRCAT (IN OUT CHAR8 **, IN CHAR8 *);
|
||||
VOID _STRCAT (IN OUT CHAR8 **, IN CONST CHAR8 *);
|
||||
|
||||
VOID _DeclareDefaultLinearVarStore (IN UINT32);
|
||||
VOID _DeclareStandardDefaultStorage (IN UINT32);
|
||||
@@ -3259,11 +3504,11 @@ EfiVfrParser::_SAVE_OPHDR_COND (
|
||||
)
|
||||
{
|
||||
if (Cond == TRUE) {
|
||||
if (mCIfrOpHdr != NULL) {
|
||||
if (mCIfrOpHdr[mCIfrOpHdrIndex] != NULL) {
|
||||
return ;
|
||||
}
|
||||
mCIfrOpHdr = new CIfrOpHeader(OpHdr);
|
||||
mCIfrOpHdrLineNo = LineNo;
|
||||
mCIfrOpHdr[mCIfrOpHdrIndex] = new CIfrOpHeader(OpHdr);
|
||||
mCIfrOpHdrLineNo[mCIfrOpHdrIndex] = LineNo;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3272,8 +3517,8 @@ EfiVfrParser::_CLEAR_SAVED_OPHDR (
|
||||
VOID
|
||||
)
|
||||
{
|
||||
mCIfrOpHdr = NULL;
|
||||
mCIfrOpHdrLineNo = 0;
|
||||
mCIfrOpHdr[mCIfrOpHdrIndex] = NULL;
|
||||
mCIfrOpHdrLineNo[mCIfrOpHdrIndex] = 0;
|
||||
}
|
||||
|
||||
BOOLEAN
|
||||
@@ -3281,10 +3526,11 @@ EfiVfrParser::_SET_SAVED_OPHDR_SCOPE (
|
||||
VOID
|
||||
)
|
||||
{
|
||||
if (mCIfrOpHdr != NULL) {
|
||||
mCIfrOpHdr->SetScope (1);
|
||||
if (mCIfrOpHdr[mCIfrOpHdrIndex] != NULL) {
|
||||
mCIfrOpHdr[mCIfrOpHdrIndex]->SetScope (1);
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
//
|
||||
// IfrOpHdr is not set, FALSE is return.
|
||||
//
|
||||
@@ -3367,7 +3613,7 @@ EfiVfrParser::_PCATCH (
|
||||
IN INTN ReturnCode,
|
||||
IN INTN ExpectCode,
|
||||
IN ANTLRTokenPtr Tok,
|
||||
IN CHAR8 *ErrorMsg
|
||||
IN CONST CHAR8 *ErrorMsg
|
||||
)
|
||||
{
|
||||
if (ReturnCode != ExpectCode) {
|
||||
@@ -3381,7 +3627,7 @@ EfiVfrParser::_PCATCH (
|
||||
IN EFI_VFR_RETURN_CODE ReturnCode
|
||||
)
|
||||
{
|
||||
mParserStatus += gCVfrErrorHandle.HandleError (ReturnCode);
|
||||
mParserStatus = mParserStatus + gCVfrErrorHandle.HandleError (ReturnCode);
|
||||
}
|
||||
|
||||
VOID
|
||||
@@ -3390,7 +3636,7 @@ EfiVfrParser::_PCATCH (
|
||||
IN ANTLRTokenPtr Tok
|
||||
)
|
||||
{
|
||||
mParserStatus += gCVfrErrorHandle.HandleError (ReturnCode, Tok->getLine(), Tok->getText());
|
||||
mParserStatus = mParserStatus + gCVfrErrorHandle.HandleError (ReturnCode, Tok->getLine(), Tok->getText());
|
||||
}
|
||||
|
||||
VOID
|
||||
@@ -3399,17 +3645,17 @@ EfiVfrParser::_PCATCH (
|
||||
IN UINT32 LineNum
|
||||
)
|
||||
{
|
||||
mParserStatus += gCVfrErrorHandle.HandleError (ReturnCode, LineNum);
|
||||
mParserStatus = mParserStatus + gCVfrErrorHandle.HandleError (ReturnCode, LineNum);
|
||||
}
|
||||
|
||||
VOID
|
||||
EfiVfrParser::_PCATCH (
|
||||
IN EFI_VFR_RETURN_CODE ReturnCode,
|
||||
IN UINT32 LineNum,
|
||||
IN CHAR8 *ErrorMsg
|
||||
IN CONST CHAR8 *ErrorMsg
|
||||
)
|
||||
{
|
||||
mParserStatus += gCVfrErrorHandle.HandleError (ReturnCode, LineNum, ErrorMsg);
|
||||
mParserStatus = mParserStatus + gCVfrErrorHandle.HandleError (ReturnCode, LineNum, (CHAR8 *) ErrorMsg);
|
||||
}
|
||||
|
||||
VOID
|
||||
@@ -3638,7 +3884,7 @@ EfiVfrParser::_STOQID (
|
||||
VOID
|
||||
EfiVfrParser::_STRCAT (
|
||||
IN OUT CHAR8 **Dest,
|
||||
IN CHAR8 *Src
|
||||
IN CONST CHAR8 *Src
|
||||
)
|
||||
{
|
||||
CHAR8 *NewStr;
|
||||
@@ -3674,6 +3920,7 @@ EfiVfrParser::_DeclareDefaultFrameworkVarStore (
|
||||
SVfrVarStorageNode *pNode;
|
||||
UINT32 TypeSize;
|
||||
BOOLEAN FirstNode;
|
||||
CONST CHAR8 VarName[] = "Setup";
|
||||
|
||||
FirstNode = TRUE;
|
||||
pNode = mCVfrDataStorage.GetBufferVarStoreList();
|
||||
@@ -3686,9 +3933,9 @@ EfiVfrParser::_DeclareDefaultFrameworkVarStore (
|
||||
CIfrVarStore VSObj;
|
||||
VSObj.SetLineNo (LineNo);
|
||||
VSObj.SetVarStoreId (0x1); //the first and only one Buffer Var Store
|
||||
VSObj.SetSize (TypeSize);
|
||||
VSObj.SetSize ((UINT16) TypeSize);
|
||||
//VSObj.SetName (gCVfrVarDataTypeDB.mFirstNewDataTypeName);
|
||||
VSObj.SetName ("Setup");
|
||||
VSObj.SetName ((CHAR8 *) VarName);
|
||||
VSObj.SetGuid (&mFormsetGuid);
|
||||
#ifdef VFREXP_DEBUG
|
||||
printf ("Create the default VarStoreName is %s\n", gCVfrVarDataTypeDB.mFirstNewDataTypeName);
|
||||
@@ -3703,9 +3950,9 @@ EfiVfrParser::_DeclareDefaultFrameworkVarStore (
|
||||
CIfrVarStore VSObj;
|
||||
VSObj.SetLineNo (LineNo);
|
||||
VSObj.SetVarStoreId (pNode->mVarStoreId);
|
||||
VSObj.SetSize (pNode->mStorageInfo.mDataType->mTotalSize);
|
||||
VSObj.SetSize ((UINT16) pNode->mStorageInfo.mDataType->mTotalSize);
|
||||
if (FirstNode) {
|
||||
VSObj.SetName ("Setup");
|
||||
VSObj.SetName ((CHAR8 *) VarName);
|
||||
FirstNode = FALSE;
|
||||
} else {
|
||||
VSObj.SetName (pNode->mVarStoreName);
|
||||
@@ -3745,6 +3992,10 @@ EfiVfrParser::_DeclareDefaultLinearVarStore (
|
||||
UINT32 Index;
|
||||
CHAR8 **TypeNameList;
|
||||
UINT32 ListSize;
|
||||
CONST CHAR8 DateName[] = "Date";
|
||||
CONST CHAR8 TimeName[] = "Time";
|
||||
CONST CHAR8 DateType[] = "EFI_HII_DATE";
|
||||
CONST CHAR8 TimeType[] = "EFI_HII_TIME";
|
||||
|
||||
gCVfrVarDataTypeDB.GetUserDefinedTypeNameList (&TypeNameList, &ListSize);
|
||||
|
||||
@@ -3764,7 +4015,7 @@ EfiVfrParser::_DeclareDefaultLinearVarStore (
|
||||
mCVfrDataStorage.GetVarStoreId(TypeNameList[Index], &VarStoreId);
|
||||
VSObj.SetVarStoreId (VarStoreId);
|
||||
gCVfrVarDataTypeDB.GetDataTypeSize(TypeNameList[Index], &Size);
|
||||
VSObj.SetSize (Size);
|
||||
VSObj.SetSize ((UINT16) Size);
|
||||
VSObj.SetName (TypeNameList[Index]);
|
||||
VSObj.SetGuid (&mFormsetGuid);
|
||||
}
|
||||
@@ -3773,45 +4024,45 @@ EfiVfrParser::_DeclareDefaultLinearVarStore (
|
||||
// not required to declare Date and Time VarStore,
|
||||
// because code to support old format Data and Time
|
||||
//
|
||||
if (gCVfrVarDataTypeDB.IsTypeNameDefined ("Date") == FALSE) {
|
||||
if (gCVfrVarDataTypeDB.IsTypeNameDefined ((CHAR8 *) DateName) == FALSE) {
|
||||
UINT32 Size;
|
||||
EFI_VARSTORE_ID VarStoreId;
|
||||
CIfrVarStore VSObj;
|
||||
|
||||
VSObj.SetLineNo (LineNo);
|
||||
mCVfrDataStorage.DeclareBufferVarStore (
|
||||
"Date",
|
||||
(CHAR8 *) DateName,
|
||||
&mFormsetGuid,
|
||||
&gCVfrVarDataTypeDB,
|
||||
"EFI_HII_DATE",
|
||||
(CHAR8 *) DateType,
|
||||
EFI_VARSTORE_ID_INVALID
|
||||
);
|
||||
mCVfrDataStorage.GetVarStoreId("Date", &VarStoreId);
|
||||
mCVfrDataStorage.GetVarStoreId((CHAR8 *) DateName, &VarStoreId);
|
||||
VSObj.SetVarStoreId (VarStoreId);
|
||||
gCVfrVarDataTypeDB.GetDataTypeSize("EFI_HII_DATE", &Size);
|
||||
VSObj.SetSize (Size);
|
||||
VSObj.SetName ("Date");
|
||||
gCVfrVarDataTypeDB.GetDataTypeSize((CHAR8 *) DateType, &Size);
|
||||
VSObj.SetSize ((UINT16) Size);
|
||||
VSObj.SetName ((CHAR8 *) DateName);
|
||||
VSObj.SetGuid (&mFormsetGuid);
|
||||
}
|
||||
|
||||
if (gCVfrVarDataTypeDB.IsTypeNameDefined ("Time") == FALSE) {
|
||||
if (gCVfrVarDataTypeDB.IsTypeNameDefined ((CHAR8 *) TimeName) == FALSE) {
|
||||
UINT32 Size;
|
||||
EFI_VARSTORE_ID VarStoreId;
|
||||
CIfrVarStore VSObj;
|
||||
|
||||
VSObj.SetLineNo (LineNo);
|
||||
mCVfrDataStorage.DeclareBufferVarStore (
|
||||
"Time",
|
||||
(CHAR8 *) TimeName,
|
||||
&mFormsetGuid,
|
||||
&gCVfrVarDataTypeDB,
|
||||
"EFI_HII_TIME",
|
||||
(CHAR8 *) TimeType,
|
||||
EFI_VARSTORE_ID_INVALID
|
||||
);
|
||||
mCVfrDataStorage.GetVarStoreId("Time", &VarStoreId);
|
||||
mCVfrDataStorage.GetVarStoreId((CHAR8 *) TimeName, &VarStoreId);
|
||||
VSObj.SetVarStoreId (VarStoreId);
|
||||
gCVfrVarDataTypeDB.GetDataTypeSize("EFI_HII_TIME", &Size);
|
||||
VSObj.SetSize (Size);
|
||||
VSObj.SetName ("Time");
|
||||
gCVfrVarDataTypeDB.GetDataTypeSize((CHAR8 *) TimeType, &Size);
|
||||
VSObj.SetSize ((UINT16) Size);
|
||||
VSObj.SetName ((CHAR8 *) TimeName);
|
||||
VSObj.SetGuid (&mFormsetGuid);
|
||||
}
|
||||
}
|
||||
@@ -3826,7 +4077,7 @@ EfiVfrParser::_DeclareStandardDefaultStorage (
|
||||
//
|
||||
CIfrDefaultStore DSObj;
|
||||
|
||||
mCVfrDefaultStore.RegisterDefaultStore (DSObj.GetObjBinAddr(), "Standard Defaults", EFI_STRING_ID_INVALID, EFI_HII_DEFAULT_CLASS_STANDARD);
|
||||
mCVfrDefaultStore.RegisterDefaultStore (DSObj.GetObjBinAddr(), (CHAR8 *) "Standard Defaults", EFI_STRING_ID_INVALID, EFI_HII_DEFAULT_CLASS_STANDARD);
|
||||
DSObj.SetLineNo (LineNo);
|
||||
DSObj.SetDefaultName (EFI_STRING_ID_INVALID);
|
||||
DSObj.SetDefaultId (EFI_HII_DEFAULT_CLASS_STANDARD);
|
||||
@@ -3836,7 +4087,7 @@ EfiVfrParser::_DeclareStandardDefaultStorage (
|
||||
//
|
||||
CIfrDefaultStore DSObjMF;
|
||||
|
||||
mCVfrDefaultStore.RegisterDefaultStore (DSObjMF.GetObjBinAddr(), "Standard ManuFacturing", EFI_STRING_ID_INVALID, EFI_HII_DEFAULT_CLASS_MANUFACTURING);
|
||||
mCVfrDefaultStore.RegisterDefaultStore (DSObjMF.GetObjBinAddr(), (CHAR8 *) "Standard ManuFacturing", EFI_STRING_ID_INVALID, EFI_HII_DEFAULT_CLASS_MANUFACTURING);
|
||||
DSObjMF.SetLineNo (LineNo);
|
||||
DSObjMF.SetDefaultName (EFI_STRING_ID_INVALID);
|
||||
DSObjMF.SetDefaultId (EFI_HII_DEFAULT_CLASS_MANUFACTURING);
|
||||
|
@@ -20,11 +20,11 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
|
||||
|
||||
VOID
|
||||
CVfrBinaryOutput::WriteLine (
|
||||
IN FILE *pFile,
|
||||
IN UINT32 LineBytes,
|
||||
IN CHAR8 *LineHeader,
|
||||
IN CHAR8 *BlkBuf,
|
||||
IN UINT32 BlkSize
|
||||
IN FILE *pFile,
|
||||
IN UINT32 LineBytes,
|
||||
IN CONST CHAR8 *LineHeader,
|
||||
IN CHAR8 *BlkBuf,
|
||||
IN UINT32 BlkSize
|
||||
)
|
||||
{
|
||||
UINT32 Index;
|
||||
@@ -43,11 +43,11 @@ CVfrBinaryOutput::WriteLine (
|
||||
|
||||
VOID
|
||||
CVfrBinaryOutput::WriteEnd (
|
||||
IN FILE *pFile,
|
||||
IN UINT32 LineBytes,
|
||||
IN CHAR8 *LineHeader,
|
||||
IN CHAR8 *BlkBuf,
|
||||
IN UINT32 BlkSize
|
||||
IN FILE *pFile,
|
||||
IN UINT32 LineBytes,
|
||||
IN CONST CHAR8 *LineHeader,
|
||||
IN CHAR8 *BlkBuf,
|
||||
IN UINT32 BlkSize
|
||||
)
|
||||
{
|
||||
UINT32 Index;
|
||||
@@ -287,7 +287,7 @@ CVfrBufferConfig::Write (
|
||||
switch (Mode) {
|
||||
case 'a' : // add
|
||||
if (Select (Name, Id) != 0) {
|
||||
if ((pItem = new SConfigItem (Name, Id, Type, Offset, Width, Value)) == NULL) {
|
||||
if ((pItem = new SConfigItem (Name, Id, Type, Offset, (UINT16) Width, Value)) == NULL) {
|
||||
return 2;
|
||||
}
|
||||
if (mItemListHead == NULL) {
|
||||
@@ -455,7 +455,7 @@ CVfrBufferConfig::~CVfrBufferConfig (
|
||||
CVfrBufferConfig gCVfrBufferConfig;
|
||||
|
||||
static struct {
|
||||
CHAR8 *mTypeName;
|
||||
CONST CHAR8 *mTypeName;
|
||||
UINT8 mType;
|
||||
UINT32 mSize;
|
||||
UINT32 mAlign;
|
||||
@@ -744,20 +744,20 @@ CVfrVarDataTypeDB::InternalTypesListInit (
|
||||
SVfrDataField *pDayField = new SVfrDataField;
|
||||
|
||||
strcpy (pYearField->mFieldName, "Year");
|
||||
GetDataType ("UINT8", &pYearField->mFieldType);
|
||||
GetDataType ((CHAR8 *)"UINT16", &pYearField->mFieldType);
|
||||
pYearField->mOffset = 0;
|
||||
pYearField->mNext = pMonthField;
|
||||
pYearField->mArrayNum = 0;
|
||||
|
||||
strcpy (pMonthField->mFieldName, "Month");
|
||||
GetDataType ("UINT8", &pMonthField->mFieldType);
|
||||
pMonthField->mOffset = 1;
|
||||
GetDataType ((CHAR8 *)"UINT8", &pMonthField->mFieldType);
|
||||
pMonthField->mOffset = 2;
|
||||
pMonthField->mNext = pDayField;
|
||||
pMonthField->mArrayNum = 0;
|
||||
|
||||
strcpy (pDayField->mFieldName, "Day");
|
||||
GetDataType ("UINT8", &pDayField->mFieldType);
|
||||
pDayField->mOffset = 2;
|
||||
GetDataType ((CHAR8 *)"UINT8", &pDayField->mFieldType);
|
||||
pDayField->mOffset = 3;
|
||||
pDayField->mNext = NULL;
|
||||
pDayField->mArrayNum = 0;
|
||||
|
||||
@@ -768,19 +768,19 @@ CVfrVarDataTypeDB::InternalTypesListInit (
|
||||
SVfrDataField *pSecondsField = new SVfrDataField;
|
||||
|
||||
strcpy (pHoursField->mFieldName, "Hours");
|
||||
GetDataType ("UINT8", &pHoursField->mFieldType);
|
||||
GetDataType ((CHAR8 *)"UINT8", &pHoursField->mFieldType);
|
||||
pHoursField->mOffset = 0;
|
||||
pHoursField->mNext = pMinutesField;
|
||||
pHoursField->mArrayNum = 0;
|
||||
|
||||
strcpy (pMinutesField->mFieldName, "Minutes");
|
||||
GetDataType ("UINT8", &pMinutesField->mFieldType);
|
||||
GetDataType ((CHAR8 *)"UINT8", &pMinutesField->mFieldType);
|
||||
pMinutesField->mOffset = 1;
|
||||
pMinutesField->mNext = pSecondsField;
|
||||
pMinutesField->mArrayNum = 0;
|
||||
|
||||
strcpy (pSecondsField->mFieldName, "Seconds");
|
||||
GetDataType ("UINT8", &pSecondsField->mFieldType);
|
||||
GetDataType ((CHAR8 *)"UINT8", &pSecondsField->mFieldType);
|
||||
pSecondsField->mOffset = 2;
|
||||
pSecondsField->mNext = NULL;
|
||||
pSecondsField->mArrayNum = 0;
|
||||
@@ -853,7 +853,7 @@ CVfrVarDataTypeDB::Pack (
|
||||
|
||||
if (Action & VFR_PACK_SHOW) {
|
||||
sprintf (Msg, "value of pragma pack(show) == %d", mPackAlign);
|
||||
gCVfrErrorHandle.PrintMsg (LineNum, "", "Warning", Msg);
|
||||
gCVfrErrorHandle.PrintMsg (LineNum, NULL, "Warning", Msg);
|
||||
}
|
||||
|
||||
if (Action & VFR_PACK_PUSH) {
|
||||
@@ -870,7 +870,7 @@ CVfrVarDataTypeDB::Pack (
|
||||
SVfrPackStackNode *pNode = NULL;
|
||||
|
||||
if (mPackStack == NULL) {
|
||||
gCVfrErrorHandle.PrintMsg (LineNum, "", "Error", "#pragma pack(pop...) : more pops than pushes");
|
||||
gCVfrErrorHandle.PrintMsg (LineNum, NULL, "Error", "#pragma pack(pop...) : more pops than pushes");
|
||||
}
|
||||
|
||||
for (pNode = mPackStack; pNode != NULL; pNode = pNode->mNext) {
|
||||
@@ -884,7 +884,7 @@ CVfrVarDataTypeDB::Pack (
|
||||
if (Action & VFR_PACK_ASSIGN) {
|
||||
PackAlign = (Number > 1) ? Number + Number % 2 : Number;
|
||||
if ((PackAlign == 0) || (PackAlign > 16)) {
|
||||
gCVfrErrorHandle.PrintMsg (LineNum, "", "Error", "expected pragma parameter to be '1', '2', '4', '8', or '16'");
|
||||
gCVfrErrorHandle.PrintMsg (LineNum, NULL, "Error", "expected pragma parameter to be '1', '2', '4', '8', or '16'");
|
||||
} else {
|
||||
mPackAlign = PackAlign;
|
||||
}
|
||||
@@ -1127,7 +1127,7 @@ CVfrVarDataTypeDB::GetDataFieldInfo (
|
||||
CHECK_ERROR_RETURN(GetTypeField (FName, pType, pField), VFR_RETURN_SUCCESS);
|
||||
pType = pField->mFieldType;
|
||||
CHECK_ERROR_RETURN(GetFieldOffset (pField, ArrayIdx, Tmp), VFR_RETURN_SUCCESS);
|
||||
Offset += Tmp;
|
||||
Offset = (UINT16) (Offset + Tmp);
|
||||
Type = GetFieldWidth (pField);
|
||||
Size = GetFieldSize (pField, ArrayIdx);
|
||||
}
|
||||
@@ -1386,6 +1386,7 @@ CVfrDataStorage::GetFreeVarStoreId (
|
||||
//
|
||||
// Assign the different ID range for the different type VarStore to support Framework Vfr
|
||||
//
|
||||
Index = 0;
|
||||
if ((!VfrCompatibleMode) || (VarType == EFI_VFR_VARSTORE_BUFFER)) {
|
||||
Index = 0;
|
||||
} else if (VarType == EFI_VFR_VARSTORE_EFI) {
|
||||
@@ -1838,13 +1839,11 @@ CVfrDataStorage::BufferVarStoreRequestElementAdd (
|
||||
IN EFI_VARSTORE_INFO &Info
|
||||
)
|
||||
{
|
||||
CHAR8 NewReqElt[128] = {'\0',};
|
||||
CHAR8 *OldReqElt = NULL;
|
||||
SVfrVarStorageNode *pNode = NULL;
|
||||
EFI_IFR_TYPE_VALUE Value = gZeroEfiIfrTypeValue;
|
||||
|
||||
for (pNode = mBufferVarStoreList; pNode != NULL; pNode = pNode->mNext) {
|
||||
if (strcmp (pNode->mVarStoreName, StoreName) == NULL) {
|
||||
if (strcmp (pNode->mVarStoreName, StoreName) == 0) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
@@ -2024,85 +2023,6 @@ CVfrDefaultStore::GetDefaultId (
|
||||
return VFR_RETURN_UNDEFINED;
|
||||
}
|
||||
|
||||
STATIC
|
||||
EFI_VFR_RETURN_CODE
|
||||
AltCfgItemPrintToBuffer (
|
||||
IN CHAR8 *NewAltCfg,
|
||||
IN EFI_VARSTORE_INFO Info,
|
||||
IN UINT8 Type,
|
||||
IN EFI_IFR_TYPE_VALUE Value
|
||||
)
|
||||
{
|
||||
UINT32 Index;
|
||||
UINT8 *BufChar = NULL;
|
||||
UINT32 Count = 0;
|
||||
|
||||
if (NewAltCfg != NULL) {
|
||||
Count = sprintf (
|
||||
NewAltCfg,
|
||||
"&OFFSET=%x&WIDTH=%x&VALUE=",
|
||||
Info.mInfo.mVarOffset,
|
||||
Info.mVarTotalSize
|
||||
);
|
||||
NewAltCfg += Count;
|
||||
|
||||
switch (Type) {
|
||||
case EFI_IFR_TYPE_NUM_SIZE_8 :
|
||||
Count = sprintf (NewAltCfg, "%x", Value.u8);
|
||||
NewAltCfg += Count;
|
||||
break;
|
||||
case EFI_IFR_TYPE_NUM_SIZE_16 :
|
||||
Count = sprintf (NewAltCfg, "%x", Value.u16);
|
||||
NewAltCfg += Count;
|
||||
break;
|
||||
case EFI_IFR_TYPE_NUM_SIZE_32 :
|
||||
Count = sprintf (NewAltCfg, "%x", Value.u32);
|
||||
NewAltCfg += Count;
|
||||
break;
|
||||
case EFI_IFR_TYPE_NUM_SIZE_64 :
|
||||
Count = sprintf (NewAltCfg, "%x", Value.u64);
|
||||
NewAltCfg += Count;
|
||||
break;
|
||||
case EFI_IFR_TYPE_BOOLEAN :
|
||||
Count = sprintf (NewAltCfg, "%x", Value.b);
|
||||
NewAltCfg += Count;
|
||||
break;
|
||||
case EFI_IFR_TYPE_TIME :
|
||||
#if 1
|
||||
Count = sprintf (NewAltCfg, "%x", *((UINT32 *)(&Value.time)));
|
||||
NewAltCfg += Count;
|
||||
#else
|
||||
BufChar = (UINT8 *)&Value.time;
|
||||
for (Index = 0; Index < sizeof(EFI_HII_TIME); Index++) {
|
||||
Count = sprintf (NewAltCfg, "%02x", (UINT8)BufChar[Index]);
|
||||
NewAltCfg += Count;
|
||||
}
|
||||
#endif
|
||||
break;
|
||||
case EFI_IFR_TYPE_DATE :
|
||||
#if 1
|
||||
Count = sprintf (NewAltCfg, "%x", *((UINT32 *)(&Value.date)));
|
||||
NewAltCfg += Count;
|
||||
#else
|
||||
BufChar = (UINT8 *)&Value.date;
|
||||
for (Index = 0; Index < sizeof(EFI_HII_DATE); Index++) {
|
||||
Count = sprintf (NewAltCfg, "%02x", (UINT8)BufChar[Index]);
|
||||
NewAltCfg += Count;
|
||||
}
|
||||
#endif
|
||||
break;
|
||||
case EFI_IFR_TYPE_STRING :
|
||||
Count = sprintf (NewAltCfg, "%x", Value.string);
|
||||
NewAltCfg += Count;
|
||||
break;
|
||||
case EFI_IFR_TYPE_OTHER :
|
||||
return VFR_RETURN_UNSUPPORTED;
|
||||
}
|
||||
}
|
||||
|
||||
return VFR_RETURN_FATAL_ERROR;
|
||||
}
|
||||
|
||||
EFI_VFR_RETURN_CODE
|
||||
CVfrDefaultStore::BufferVarStoreAltConfigAdd (
|
||||
IN EFI_VARSTORE_ID DefaultId,
|
||||
@@ -2340,6 +2260,7 @@ SVfrQuestionNode::SVfrQuestionNode (
|
||||
mQuestionId = EFI_QUESTION_ID_INVALID;
|
||||
mBitMask = BitMask;
|
||||
mNext = NULL;
|
||||
mQtype = QUESTION_NORMAL;
|
||||
|
||||
if (Name == NULL) {
|
||||
mName = new CHAR8[strlen ("$DEFAULT") + 1];
|
||||
@@ -2509,6 +2430,9 @@ CVfrQuestionDB::RegisterOldDateQuestion (
|
||||
pNode[0]->mQuestionId = QuestionId;
|
||||
pNode[1]->mQuestionId = QuestionId;
|
||||
pNode[2]->mQuestionId = QuestionId;
|
||||
pNode[0]->mQtype = QUESTION_DATE;
|
||||
pNode[1]->mQtype = QUESTION_DATE;
|
||||
pNode[2]->mQtype = QUESTION_DATE;
|
||||
pNode[0]->mNext = pNode[1];
|
||||
pNode[1]->mNext = pNode[2];
|
||||
pNode[2]->mNext = mQuestionList;
|
||||
@@ -2585,6 +2509,9 @@ CVfrQuestionDB::RegisterNewDateQuestion (
|
||||
pNode[0]->mQuestionId = QuestionId;
|
||||
pNode[1]->mQuestionId = QuestionId;
|
||||
pNode[2]->mQuestionId = QuestionId;
|
||||
pNode[0]->mQtype = QUESTION_DATE;
|
||||
pNode[1]->mQtype = QUESTION_DATE;
|
||||
pNode[2]->mQtype = QUESTION_DATE;
|
||||
pNode[0]->mNext = pNode[1];
|
||||
pNode[1]->mNext = pNode[2];
|
||||
pNode[2]->mNext = mQuestionList;
|
||||
@@ -2651,6 +2578,9 @@ CVfrQuestionDB::RegisterOldTimeQuestion (
|
||||
pNode[0]->mQuestionId = QuestionId;
|
||||
pNode[1]->mQuestionId = QuestionId;
|
||||
pNode[2]->mQuestionId = QuestionId;
|
||||
pNode[0]->mQtype = QUESTION_TIME;
|
||||
pNode[1]->mQtype = QUESTION_TIME;
|
||||
pNode[2]->mQtype = QUESTION_TIME;
|
||||
pNode[0]->mNext = pNode[1];
|
||||
pNode[1]->mNext = pNode[2];
|
||||
pNode[2]->mNext = mQuestionList;
|
||||
@@ -2727,6 +2657,9 @@ CVfrQuestionDB::RegisterNewTimeQuestion (
|
||||
pNode[0]->mQuestionId = QuestionId;
|
||||
pNode[1]->mQuestionId = QuestionId;
|
||||
pNode[2]->mQuestionId = QuestionId;
|
||||
pNode[0]->mQtype = QUESTION_TIME;
|
||||
pNode[1]->mQtype = QUESTION_TIME;
|
||||
pNode[2]->mQtype = QUESTION_TIME;
|
||||
pNode[0]->mNext = pNode[1];
|
||||
pNode[1]->mNext = pNode[2];
|
||||
pNode[2]->mNext = mQuestionList;
|
||||
@@ -2800,13 +2733,17 @@ CVfrQuestionDB::GetQuestionId (
|
||||
IN CHAR8 *Name,
|
||||
IN CHAR8 *VarIdStr,
|
||||
OUT EFI_QUESTION_ID &QuestionId,
|
||||
OUT UINT32 &BitMask
|
||||
OUT UINT32 &BitMask,
|
||||
OUT EFI_QUESION_TYPE *QType
|
||||
)
|
||||
{
|
||||
SVfrQuestionNode *pNode;
|
||||
|
||||
QuestionId = EFI_QUESTION_ID_INVALID;
|
||||
BitMask = 0x00000000;
|
||||
if (QType != NULL) {
|
||||
*QType = QUESTION_NORMAL;
|
||||
}
|
||||
|
||||
if ((Name == NULL) && (VarIdStr == NULL)) {
|
||||
return ;
|
||||
@@ -2827,6 +2764,9 @@ CVfrQuestionDB::GetQuestionId (
|
||||
|
||||
QuestionId = pNode->mQuestionId;
|
||||
BitMask = pNode->mBitMask;
|
||||
if (QType != NULL) {
|
||||
*QType = pNode->mQtype;
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -2877,3 +2817,4 @@ BOOLEAN VfrCompatibleMode = FALSE;
|
||||
|
||||
CVfrVarDataTypeDB gCVfrVarDataTypeDB;
|
||||
|
||||
|
||||
|
@@ -2,7 +2,7 @@
|
||||
|
||||
Vfr common library functions.
|
||||
|
||||
Copyright (c) 2004 - 2009, Intel Corporation
|
||||
Copyright (c) 2004 - 2010, 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
|
||||
@@ -36,8 +36,8 @@ extern BOOLEAN VfrCompatibleMode;
|
||||
|
||||
class CVfrBinaryOutput {
|
||||
public:
|
||||
virtual VOID WriteLine (IN FILE *, IN UINT32, IN CHAR8 *, IN CHAR8 *, IN UINT32);
|
||||
virtual VOID WriteEnd (IN FILE *, IN UINT32, IN CHAR8 *, IN CHAR8 *, IN UINT32);
|
||||
virtual VOID WriteLine (IN FILE *, IN UINT32, IN CONST CHAR8 *, IN CHAR8 *, IN UINT32);
|
||||
virtual VOID WriteEnd (IN FILE *, IN UINT32, IN CONST CHAR8 *, IN CHAR8 *, IN UINT32);
|
||||
};
|
||||
|
||||
UINT32
|
||||
@@ -332,6 +332,7 @@ struct SVfrQuestionNode {
|
||||
EFI_QUESTION_ID mQuestionId;
|
||||
UINT32 mBitMask;
|
||||
SVfrQuestionNode *mNext;
|
||||
EFI_QUESION_TYPE mQtype;
|
||||
|
||||
SVfrQuestionNode (IN CHAR8 *, IN CHAR8 *, IN UINT32 BitMask = 0);
|
||||
~SVfrQuestionNode ();
|
||||
@@ -358,7 +359,7 @@ public:
|
||||
VOID RegisterOldTimeQuestion (IN CHAR8 *, IN CHAR8 *, IN CHAR8 *, IN OUT EFI_QUESTION_ID &);
|
||||
VOID RegisterNewTimeQuestion (IN CHAR8 *, IN CHAR8 *, IN OUT EFI_QUESTION_ID &);
|
||||
EFI_VFR_RETURN_CODE UpdateQuestionId (IN EFI_QUESTION_ID, IN EFI_QUESTION_ID);
|
||||
VOID GetQuestionId (IN CHAR8 *, IN CHAR8 *, OUT EFI_QUESTION_ID &, OUT UINT32 &);
|
||||
VOID GetQuestionId (IN CHAR8 *, IN CHAR8 *, OUT EFI_QUESTION_ID &, OUT UINT32 &, OUT EFI_QUESION_TYPE *QType = NULL);
|
||||
EFI_VFR_RETURN_CODE FindQuestion (IN EFI_QUESTION_ID);
|
||||
EFI_VFR_RETURN_CODE FindQuestion (IN CHAR8 *);
|
||||
VOID PrintAllQuestion (IN VOID);
|
||||
|
@@ -1,6 +1,6 @@
|
||||
/** @file
|
||||
|
||||
Copyright (c) 1999 - 2008, Intel Corporation
|
||||
Copyright (c) 1999 - 2010, 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
|
||||
@@ -1801,7 +1801,7 @@ Returns:
|
||||
//
|
||||
// Copyright declaration
|
||||
//
|
||||
fprintf (stdout, "Copyright (c) 2007, Intel Corporation. All rights reserved.\n\n");
|
||||
fprintf (stdout, "Copyright (c) 2007 - 2010, Intel Corporation. All rights reserved.\n\n");
|
||||
|
||||
//
|
||||
// Details Option
|
||||
|
File diff suppressed because it is too large
Load Diff
@@ -1,7 +1,7 @@
|
||||
## @file
|
||||
# Routines for generating AutoGen.h and AutoGen.c
|
||||
#
|
||||
# Copyright (c) 2007, Intel Corporation
|
||||
# Copyright (c) 2007 - 2010, 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
|
||||
@@ -162,7 +162,7 @@ ${END}
|
||||
GUID GuidTable[${PHASE}_GUID_TABLE_SIZE];
|
||||
${BEGIN} STRING_HEAD ${STRING_HEAD_CNAME_DECL}_${STRING_HEAD_GUID_DECL}[${STRING_HEAD_NUMSKUS_DECL}];
|
||||
${END}
|
||||
${BEGIN} VARIABLE_HEAD ${VARIABLE_HEAD_CNAME_DECL}_${VARIABLE_HEAD_GUID_DECL}[${VARIABLE_HEAD_NUMSKUS_DECL}];
|
||||
${BEGIN} VARIABLE_HEAD ${VARIABLE_HEAD_CNAME_DECL}_${VARIABLE_HEAD_GUID_DECL}_Variable_Header[${VARIABLE_HEAD_NUMSKUS_DECL}];
|
||||
${END}
|
||||
${BEGIN} UINT8 StringTable${STRING_TABLE_INDEX}[${STRING_TABLE_LENGTH}]; /* ${STRING_TABLE_CNAME}_${STRING_TABLE_GUID} */
|
||||
${END}
|
||||
@@ -253,7 +253,7 @@ ${END}
|
||||
},
|
||||
/* LocalTokenNumberTable */
|
||||
{
|
||||
${BEGIN} offsetof(${PHASE}_PCD_DATABASE, ${TOKEN_INIT}.${TOKEN_CNAME}_${TOKEN_GUID}) | ${TOKEN_TYPE},
|
||||
${BEGIN} offsetof(${PHASE}_PCD_DATABASE, ${TOKEN_INIT}.${TOKEN_CNAME}_${TOKEN_GUID}${VARDEF_HEADER}) | ${TOKEN_TYPE},
|
||||
${END}
|
||||
},
|
||||
/* GuidTable */
|
||||
@@ -263,7 +263,7 @@ ${END}
|
||||
},
|
||||
${BEGIN} { ${STRING_HEAD_VALUE} }, /* ${STRING_HEAD_CNAME_DECL}_${STRING_HEAD_GUID_DECL}[${STRING_HEAD_NUMSKUS_DECL}] */
|
||||
${END}
|
||||
${BEGIN} /* ${VARIABLE_HEAD_CNAME_DECL}_${VARIABLE_HEAD_GUID_DECL}[${VARIABLE_HEAD_NUMSKUS_DECL}] */
|
||||
${BEGIN} /* ${VARIABLE_HEAD_CNAME_DECL}_${VARIABLE_HEAD_GUID_DECL}_Variable_Header[${VARIABLE_HEAD_NUMSKUS_DECL}] */
|
||||
{
|
||||
${VARIABLE_HEAD_VALUE}
|
||||
},
|
||||
@@ -453,7 +453,7 @@ ${END}
|
||||
|
||||
gSmmCoreEntryPointString = TemplateString("""
|
||||
${BEGIN}
|
||||
const UINT32 _gUefiDriverRevision = ${EfiSpecVersion};
|
||||
const UINT32 _gUefiDriverRevision = ${UefiSpecVersion};
|
||||
const UINT32 _gDxeRevision = ${PiSpecVersion};
|
||||
|
||||
EFI_STATUS
|
||||
@@ -482,7 +482,7 @@ ${END}
|
||||
|
||||
gDxeSmmEntryPointString = [
|
||||
TemplateString("""
|
||||
const UINT32 _gUefiDriverRevision = ${EfiSpecVersion};
|
||||
const UINT32 _gUefiDriverRevision = ${UefiSpecVersion};
|
||||
const UINT32 _gDxeRevision = ${PiSpecVersion};
|
||||
|
||||
EFI_STATUS
|
||||
@@ -497,11 +497,11 @@ ProcessModuleEntryPointList (
|
||||
}
|
||||
"""),
|
||||
TemplateString("""
|
||||
const UINT32 _gUefiDriverRevision = ${EfiSpecVersion};
|
||||
const UINT32 _gUefiDriverRevision = ${UefiSpecVersion};
|
||||
const UINT32 _gDxeRevision = ${PiSpecVersion};
|
||||
|
||||
static BASE_LIBRARY_JUMP_BUFFER mJumpContext;
|
||||
static EFI_STATUS mDriverEntryPointStatus = EFI_LOAD_ERROR;
|
||||
static EFI_STATUS mDriverEntryPointStatus;
|
||||
|
||||
VOID
|
||||
EFIAPI
|
||||
@@ -522,8 +522,9 @@ ProcessModuleEntryPointList (
|
||||
IN EFI_HANDLE ImageHandle,
|
||||
IN EFI_SYSTEM_TABLE *SystemTable
|
||||
)
|
||||
|
||||
{
|
||||
mDriverEntryPointStatus = EFI_LOAD_ERROR;
|
||||
|
||||
${BEGIN}
|
||||
if (SetJump (&mJumpContext) == 0) {
|
||||
ExitDriver (${Function} (ImageHandle, SystemTable));
|
||||
@@ -550,7 +551,7 @@ ${END}
|
||||
|
||||
gUefiDriverEntryPointString = [
|
||||
TemplateString("""
|
||||
const UINT32 _gUefiDriverRevision = ${EfiSpecVersion};
|
||||
const UINT32 _gUefiDriverRevision = ${UefiSpecVersion};
|
||||
const UINT32 _gDxeRevision = ${PiSpecVersion};
|
||||
|
||||
EFI_STATUS
|
||||
@@ -564,7 +565,7 @@ ProcessModuleEntryPointList (
|
||||
}
|
||||
"""),
|
||||
TemplateString("""
|
||||
const UINT32 _gUefiDriverRevision = ${EfiSpecVersion};
|
||||
const UINT32 _gUefiDriverRevision = ${UefiSpecVersion};
|
||||
const UINT32 _gDxeRevision = ${PiSpecVersion};
|
||||
|
||||
${BEGIN}
|
||||
@@ -592,17 +593,20 @@ ExitDriver (
|
||||
}
|
||||
"""),
|
||||
TemplateString("""
|
||||
const UINT32 _gUefiDriverRevision = ${EfiSpecVersion};
|
||||
const UINT32 _gUefiDriverRevision = ${UefiSpecVersion};
|
||||
const UINT32 _gDxeRevision = ${PiSpecVersion};
|
||||
|
||||
static BASE_LIBRARY_JUMP_BUFFER mJumpContext;
|
||||
static EFI_STATUS mDriverEntryPointStatus;
|
||||
|
||||
EFI_STATUS
|
||||
EFIAPI
|
||||
ProcessModuleEntryPointList (
|
||||
IN EFI_HANDLE ImageHandle,
|
||||
IN EFI_SYSTEM_TABLE *SystemTable
|
||||
)
|
||||
|
||||
{
|
||||
mDriverEntryPointStatus = EFI_LOAD_ERROR;
|
||||
${BEGIN}
|
||||
if (SetJump (&mJumpContext) == 0) {
|
||||
ExitDriver (${Function} (ImageHandle, SystemTable));
|
||||
@@ -612,9 +616,6 @@ ProcessModuleEntryPointList (
|
||||
return mDriverEntryPointStatus;
|
||||
}
|
||||
|
||||
static BASE_LIBRARY_JUMP_BUFFER mJumpContext;
|
||||
static EFI_STATUS mDriverEntryPointStatus = EFI_LOAD_ERROR;
|
||||
|
||||
VOID
|
||||
EFIAPI
|
||||
ExitDriver (
|
||||
@@ -645,7 +646,7 @@ ${END}
|
||||
|
||||
gUefiApplicationEntryPointString = [
|
||||
TemplateString("""
|
||||
const UINT32 _gUefiDriverRevision = ${EfiSpecVersion};
|
||||
const UINT32 _gUefiDriverRevision = ${UefiSpecVersion};
|
||||
|
||||
EFI_STATUS
|
||||
EFIAPI
|
||||
@@ -658,7 +659,7 @@ ProcessModuleEntryPointList (
|
||||
}
|
||||
"""),
|
||||
TemplateString("""
|
||||
const UINT32 _gUefiDriverRevision = ${EfiSpecVersion};
|
||||
const UINT32 _gUefiDriverRevision = ${UefiSpecVersion};
|
||||
|
||||
${BEGIN}
|
||||
EFI_STATUS
|
||||
@@ -685,7 +686,7 @@ ExitDriver (
|
||||
}
|
||||
"""),
|
||||
TemplateString("""
|
||||
const UINT32 _gUefiDriverRevision = ${EfiSpecVersion};
|
||||
const UINT32 _gUefiDriverRevision = ${UefiSpecVersion};
|
||||
|
||||
EFI_STATUS
|
||||
EFIAPI
|
||||
@@ -876,13 +877,6 @@ ${FunctionCall}${END}
|
||||
"""),
|
||||
}
|
||||
|
||||
gSpecificationString = TemplateString("""
|
||||
${BEGIN}
|
||||
#undef ${SpecificationName}
|
||||
#define ${SpecificationName} ${SpecificationValue}
|
||||
${END}
|
||||
""")
|
||||
|
||||
gBasicHeaderFile = "Base.h"
|
||||
|
||||
gModuleTypeHeaderFile = {
|
||||
@@ -959,11 +953,57 @@ def CreateModulePcdCode(Info, AutoGenC, AutoGenH, Pcd):
|
||||
Const = ''
|
||||
Type = ''
|
||||
Array = ''
|
||||
Value = Pcd.DefaultValue
|
||||
Value = Pcd.DefaultValue
|
||||
Unicode = False
|
||||
if Pcd.DatumType == 'UINT64':
|
||||
if not Value.endswith('ULL'):
|
||||
Value += 'ULL'
|
||||
ValueNumber = 0
|
||||
if Pcd.DatumType in ['UINT64', 'UINT32', 'UINT16', 'UINT8']:
|
||||
try:
|
||||
if Value.upper().startswith('0X'):
|
||||
ValueNumber = int (Value, 16)
|
||||
else:
|
||||
ValueNumber = int (Value)
|
||||
except:
|
||||
EdkLogger.error("build", AUTOGEN_ERROR,
|
||||
"PCD value is not valid dec or hex number for datum type [%s] of PCD %s.%s" % (Pcd.DatumType, Pcd.TokenSpaceGuidCName, Pcd.TokenCName),
|
||||
ExtraData="[%s]" % str(Info))
|
||||
if Pcd.DatumType == 'UINT64':
|
||||
if ValueNumber < 0:
|
||||
EdkLogger.error("build", AUTOGEN_ERROR,
|
||||
"PCD can't be set to negative value for datum type [%s] of PCD %s.%s" % (Pcd.DatumType, Pcd.TokenSpaceGuidCName, Pcd.TokenCName),
|
||||
ExtraData="[%s]" % str(Info))
|
||||
elif ValueNumber >= 0x10000000000000000:
|
||||
EdkLogger.error("build", AUTOGEN_ERROR,
|
||||
"Too large PCD value for datum type [%s] of PCD %s.%s" % (Pcd.DatumType, Pcd.TokenSpaceGuidCName, Pcd.TokenCName),
|
||||
ExtraData="[%s]" % str(Info))
|
||||
if not Value.endswith('ULL'):
|
||||
Value += 'ULL'
|
||||
elif Pcd.DatumType == 'UINT32':
|
||||
if ValueNumber < 0:
|
||||
EdkLogger.error("build", AUTOGEN_ERROR,
|
||||
"PCD can't be set to negative value for datum type [%s] of PCD %s.%s" % (Pcd.DatumType, Pcd.TokenSpaceGuidCName, Pcd.TokenCName),
|
||||
ExtraData="[%s]" % str(Info))
|
||||
elif ValueNumber >= 0x100000000:
|
||||
EdkLogger.error("build", AUTOGEN_ERROR,
|
||||
"Too large PCD value for datum type [%s] of PCD %s.%s" % (Pcd.DatumType, Pcd.TokenSpaceGuidCName, Pcd.TokenCName),
|
||||
ExtraData="[%s]" % str(Info))
|
||||
elif Pcd.DatumType == 'UINT16':
|
||||
if ValueNumber < 0:
|
||||
EdkLogger.error("build", AUTOGEN_ERROR,
|
||||
"PCD can't be set to negative value for datum type [%s] of PCD %s.%s" % (Pcd.DatumType, Pcd.TokenSpaceGuidCName, Pcd.TokenCName),
|
||||
ExtraData="[%s]" % str(Info))
|
||||
elif ValueNumber >= 0x10000:
|
||||
EdkLogger.error("build", AUTOGEN_ERROR,
|
||||
"Too large PCD value for datum type [%s] of PCD %s.%s" % (Pcd.DatumType, Pcd.TokenSpaceGuidCName, Pcd.TokenCName),
|
||||
ExtraData="[%s]" % str(Info))
|
||||
elif Pcd.DatumType == 'UINT8':
|
||||
if ValueNumber < 0:
|
||||
EdkLogger.error("build", AUTOGEN_ERROR,
|
||||
"PCD can't be set to negative value for datum type [%s] of PCD %s.%s" % (Pcd.DatumType, Pcd.TokenSpaceGuidCName, Pcd.TokenCName),
|
||||
ExtraData="[%s]" % str(Info))
|
||||
elif ValueNumber >= 0x100:
|
||||
EdkLogger.error("build", AUTOGEN_ERROR,
|
||||
"Too large PCD value for datum type [%s] of PCD %s.%s" % (Pcd.DatumType, Pcd.TokenSpaceGuidCName, Pcd.TokenCName),
|
||||
ExtraData="[%s]" % str(Info))
|
||||
if Pcd.DatumType == 'VOID*':
|
||||
if Pcd.MaxDatumSize == None or Pcd.MaxDatumSize == '':
|
||||
EdkLogger.error("build", AUTOGEN_ERROR,
|
||||
@@ -973,7 +1013,7 @@ def CreateModulePcdCode(Info, AutoGenC, AutoGenH, Pcd):
|
||||
ArraySize = int(Pcd.MaxDatumSize, 0)
|
||||
if Value[0] == '{':
|
||||
Type = '(VOID *)'
|
||||
else:
|
||||
else:
|
||||
if Value[0] == 'L':
|
||||
Unicode = True
|
||||
Value = Value.lstrip('L') #.strip('"')
|
||||
@@ -981,15 +1021,15 @@ def CreateModulePcdCode(Info, AutoGenC, AutoGenH, Pcd):
|
||||
NewValue = '{'
|
||||
for Index in range(0,len(Value)):
|
||||
if Unicode:
|
||||
NewValue = NewValue + str(ord(Value[Index]) % 0x10000) + ', '
|
||||
else:
|
||||
NewValue = NewValue + str(ord(Value[Index]) % 0x10000) + ', '
|
||||
else:
|
||||
NewValue = NewValue + str(ord(Value[Index]) % 0x100) + ', '
|
||||
if Unicode:
|
||||
ArraySize = ArraySize / 2;
|
||||
|
||||
if Unicode:
|
||||
ArraySize = ArraySize / 2;
|
||||
|
||||
if ArraySize < (len(Value) + 1):
|
||||
ArraySize = len(Value) + 1
|
||||
Value = NewValue + '0 }'
|
||||
Value = NewValue + '0 }'
|
||||
Array = '[%d]' % ArraySize
|
||||
#
|
||||
# skip casting for fixed at build since it breaks ARM assembly.
|
||||
@@ -1003,16 +1043,16 @@ def CreateModulePcdCode(Info, AutoGenC, AutoGenH, Pcd):
|
||||
else:
|
||||
PcdValueName = '_PCD_VALUE_' + Pcd.TokenCName
|
||||
|
||||
if Pcd.DatumType == 'VOID*':
|
||||
#
|
||||
# For unicode, UINT16 array will be generated, so the alignment of unicode is guaranteed.
|
||||
#
|
||||
if Unicode:
|
||||
AutoGenH.Append('#define _PCD_PATCHABLE_%s_SIZE %s\n' % (Pcd.TokenCName, Pcd.MaxDatumSize))
|
||||
AutoGenH.Append('#define %s %s%s\n' %(PcdValueName, Type, PcdVariableName))
|
||||
AutoGenC.Append('GLOBAL_REMOVE_IF_UNREFERENCED %s UINT16 %s%s = %s;\n' % (Const, PcdVariableName, Array, Value))
|
||||
AutoGenH.Append('extern %s UINT16 %s%s;\n' %(Const, PcdVariableName, Array))
|
||||
AutoGenH.Append('#define %s %s%s\n' %(GetModeName, Type, PcdVariableName))
|
||||
if Pcd.DatumType == 'VOID*':
|
||||
#
|
||||
# For unicode, UINT16 array will be generated, so the alignment of unicode is guaranteed.
|
||||
#
|
||||
if Unicode:
|
||||
AutoGenH.Append('#define _PCD_PATCHABLE_%s_SIZE %s\n' % (Pcd.TokenCName, Pcd.MaxDatumSize))
|
||||
AutoGenH.Append('#define %s %s%s\n' %(PcdValueName, Type, PcdVariableName))
|
||||
AutoGenC.Append('GLOBAL_REMOVE_IF_UNREFERENCED %s UINT16 %s%s = %s;\n' % (Const, PcdVariableName, Array, Value))
|
||||
AutoGenH.Append('extern %s UINT16 %s%s;\n' %(Const, PcdVariableName, Array))
|
||||
AutoGenH.Append('#define %s %s%s\n' %(GetModeName, Type, PcdVariableName))
|
||||
else:
|
||||
AutoGenH.Append('#define _PCD_PATCHABLE_%s_SIZE %s\n' % (Pcd.TokenCName, Pcd.MaxDatumSize))
|
||||
AutoGenH.Append('#define %s %s%s\n' %(PcdValueName, Type, PcdVariableName))
|
||||
@@ -1021,7 +1061,7 @@ def CreateModulePcdCode(Info, AutoGenC, AutoGenH, Pcd):
|
||||
AutoGenH.Append('#define %s %s%s\n' %(GetModeName, Type, PcdVariableName))
|
||||
elif Pcd.Type == TAB_PCDS_PATCHABLE_IN_MODULE:
|
||||
AutoGenH.Append('#define %s %s\n' %(PcdValueName, Value))
|
||||
AutoGenC.Append('GLOBAL_REMOVE_IF_UNREFERENCED volatile %s %s %s = %s;\n' %(Const, Pcd.DatumType, PcdVariableName, PcdValueName))
|
||||
AutoGenC.Append('volatile %s %s %s = %s;\n' %(Const, Pcd.DatumType, PcdVariableName, PcdValueName))
|
||||
AutoGenH.Append('extern volatile %s %s %s%s;\n' % (Const, Pcd.DatumType, PcdVariableName, Array))
|
||||
AutoGenH.Append('#define %s %s%s\n' % (GetModeName, Type, PcdVariableName))
|
||||
else:
|
||||
@@ -1139,7 +1179,7 @@ def CreatePcdDatabasePhaseSpecificAutoGen (Platform, Phase):
|
||||
'SYSTEM_SKU_ID_VALUE' : '0'
|
||||
}
|
||||
|
||||
for DatumType in ['UINT64','UINT32','UINT16','UINT8','BOOLEAN']:
|
||||
for DatumType in ['UINT64','UINT32','UINT16','UINT8','BOOLEAN', "VOID*"]:
|
||||
Dict['VARDEF_CNAME_' + DatumType] = []
|
||||
Dict['VARDEF_GUID_' + DatumType] = []
|
||||
Dict['VARDEF_SKUID_' + DatumType] = []
|
||||
@@ -1174,7 +1214,7 @@ def CreatePcdDatabasePhaseSpecificAutoGen (Platform, Phase):
|
||||
Dict['GUID_STRUCTURE'] = []
|
||||
|
||||
Dict['SKUID_VALUE'] = []
|
||||
|
||||
Dict['VARDEF_HEADER'] = []
|
||||
if Phase == 'DXE':
|
||||
Dict['SYSTEM_SKU_ID'] = ''
|
||||
Dict['SYSTEM_SKU_ID_VALUE'] = ''
|
||||
@@ -1223,7 +1263,7 @@ def CreatePcdDatabasePhaseSpecificAutoGen (Platform, Phase):
|
||||
Pcd.InitString = 'UNINIT'
|
||||
|
||||
if Pcd.DatumType == 'VOID*':
|
||||
Pcd.TokenTypeList = ['PCD_DATUM_TYPE_POINTER']
|
||||
Pcd.TokenTypeList = ['PCD_TYPE_STRING']
|
||||
elif Pcd.DatumType == 'BOOLEAN':
|
||||
Pcd.TokenTypeList = ['PCD_DATUM_TYPE_UINT8']
|
||||
else:
|
||||
@@ -1270,53 +1310,65 @@ def CreatePcdDatabasePhaseSpecificAutoGen (Platform, Phase):
|
||||
Dict['GUID_STRUCTURE'].append(VariableGuidStructure)
|
||||
VariableHeadGuidIndex = GuidList.index(VariableGuid)
|
||||
|
||||
VariableHeadValueList.append('%d, %d, %s, offsetof(%s_PCD_DATABASE, Init.%s_%s_VariableDefault_%s)' %
|
||||
(VariableHeadGuidIndex, VariableHeadStringIndex, Sku.VariableOffset,
|
||||
Phase, CName, TokenSpaceGuid, SkuIdIndex))
|
||||
if "PCD_TYPE_STRING" in Pcd.TokenTypeList:
|
||||
VariableHeadValueList.append('%d, %d, %s, offsetof(%s_PCD_DATABASE, Init.%s_%s)' %
|
||||
(VariableHeadGuidIndex, VariableHeadStringIndex, Sku.VariableOffset,
|
||||
Phase, CName, TokenSpaceGuid))
|
||||
else:
|
||||
VariableHeadValueList.append('%d, %d, %s, offsetof(%s_PCD_DATABASE, Init.%s_%s_VariableDefault_%s)' %
|
||||
(VariableHeadGuidIndex, VariableHeadStringIndex, Sku.VariableOffset,
|
||||
Phase, CName, TokenSpaceGuid, SkuIdIndex))
|
||||
Dict['VARDEF_CNAME_'+Pcd.DatumType].append(CName)
|
||||
Dict['VARDEF_GUID_'+Pcd.DatumType].append(TokenSpaceGuid)
|
||||
Dict['VARDEF_SKUID_'+Pcd.DatumType].append(SkuIdIndex)
|
||||
Dict['VARDEF_VALUE_'+Pcd.DatumType].append(Sku.HiiDefaultValue)
|
||||
if "PCD_TYPE_STRING" in Pcd.TokenTypeList:
|
||||
Dict['VARDEF_VALUE_' + Pcd.DatumType].append("%s_%s[%d]" % (Pcd.TokenCName, TokenSpaceGuid, SkuIdIndex))
|
||||
else:
|
||||
Dict['VARDEF_VALUE_'+Pcd.DatumType].append(Sku.HiiDefaultValue)
|
||||
elif Sku.VpdOffset != '':
|
||||
Pcd.TokenTypeList += ['PCD_TYPE_VPD']
|
||||
Pcd.InitString = 'INIT'
|
||||
VpdHeadOffsetList.append(Sku.VpdOffset)
|
||||
|
||||
|
||||
if Pcd.DatumType == 'VOID*':
|
||||
Pcd.TokenTypeList += ['PCD_TYPE_STRING']
|
||||
Pcd.InitString = 'INIT'
|
||||
if Sku.HiiDefaultValue != '' and Sku.DefaultValue == '':
|
||||
Sku.DefaultValue = Sku.HiiDefaultValue
|
||||
if Sku.DefaultValue != '':
|
||||
NumberOfSizeItems += 1
|
||||
Dict['STRING_TABLE_CNAME'].append(CName)
|
||||
Dict['STRING_TABLE_GUID'].append(TokenSpaceGuid)
|
||||
|
||||
if StringTableIndex == 0:
|
||||
Dict['STRING_TABLE_INDEX'].append('')
|
||||
else:
|
||||
Dict['STRING_TABLE_INDEX'].append('_%d' % StringTableIndex)
|
||||
if Sku.DefaultValue[0] == 'L':
|
||||
Size = (len(Sku.DefaultValue) - 3 + 1) * 2
|
||||
Dict['STRING_TABLE_VALUE'].append(StringToArray(Sku.DefaultValue))
|
||||
elif Sku.DefaultValue[0] == '"':
|
||||
Size = len(Sku.DefaultValue) - 2 + 1
|
||||
Dict['STRING_TABLE_VALUE'].append(StringToArray(Sku.DefaultValue))
|
||||
elif Sku.DefaultValue[0] == '{':
|
||||
Size = len(Sku.DefaultValue.replace(',',' ').split())
|
||||
Dict['STRING_TABLE_VALUE'].append(Sku.DefaultValue)
|
||||
|
||||
StringHeadOffsetList.append(str(StringTableSize))
|
||||
Dict['SIZE_TABLE_CNAME'].append(CName)
|
||||
Dict['SIZE_TABLE_GUID'].append(TokenSpaceGuid)
|
||||
Dict['SIZE_TABLE_CURRENT_LENGTH'].append(Size)
|
||||
Dict['SIZE_TABLE_MAXIMUM_LENGTH'].append(Pcd.MaxDatumSize)
|
||||
if Pcd.MaxDatumSize != '':
|
||||
MaxDatumSize = int(Pcd.MaxDatumSize, 0)
|
||||
if MaxDatumSize > Size:
|
||||
Size = MaxDatumSize
|
||||
Dict['STRING_TABLE_LENGTH'].append(Size)
|
||||
StringTableIndex += 1
|
||||
StringTableSize += (Size)
|
||||
else:
|
||||
if Pcd.DatumType == 'VOID*':
|
||||
Pcd.TokenTypeList += ['PCD_TYPE_STRING']
|
||||
Pcd.InitString = 'INIT'
|
||||
if Sku.DefaultValue != '':
|
||||
NumberOfSizeItems += 1
|
||||
Dict['STRING_TABLE_CNAME'].append(CName)
|
||||
Dict['STRING_TABLE_GUID'].append(TokenSpaceGuid)
|
||||
|
||||
if StringTableIndex == 0:
|
||||
Dict['STRING_TABLE_INDEX'].append('')
|
||||
else:
|
||||
Dict['STRING_TABLE_INDEX'].append('_%d' % StringTableIndex)
|
||||
if Sku.DefaultValue[0] == 'L':
|
||||
Size = (len(Sku.DefaultValue) - 3 + 1) * 2
|
||||
Dict['STRING_TABLE_VALUE'].append(StringToArray(Sku.DefaultValue))
|
||||
elif Sku.DefaultValue[0] == '"':
|
||||
Size = len(Sku.DefaultValue) - 2 + 1
|
||||
Dict['STRING_TABLE_VALUE'].append(StringToArray(Sku.DefaultValue))
|
||||
elif Sku.DefaultValue[0] == '{':
|
||||
Size = len(Sku.DefaultValue.replace(',',' ').split())
|
||||
Dict['STRING_TABLE_VALUE'].append(Sku.DefaultValue)
|
||||
|
||||
StringHeadOffsetList.append(str(StringTableSize))
|
||||
Dict['SIZE_TABLE_CNAME'].append(CName)
|
||||
Dict['SIZE_TABLE_GUID'].append(TokenSpaceGuid)
|
||||
Dict['SIZE_TABLE_CURRENT_LENGTH'].append(Size)
|
||||
Dict['SIZE_TABLE_MAXIMUM_LENGTH'].append(Pcd.MaxDatumSize)
|
||||
if Pcd.MaxDatumSize != '':
|
||||
MaxDatumSize = int(Pcd.MaxDatumSize, 0)
|
||||
if MaxDatumSize > Size:
|
||||
Size = MaxDatumSize
|
||||
Dict['STRING_TABLE_LENGTH'].append(Size)
|
||||
StringTableIndex += 1
|
||||
StringTableSize += (Size)
|
||||
else:
|
||||
if "PCD_TYPE_HII" not in Pcd.TokenTypeList:
|
||||
Pcd.TokenTypeList += ['PCD_TYPE_DATA']
|
||||
if Sku.DefaultValue == 'TRUE':
|
||||
Pcd.InitString = 'INIT'
|
||||
@@ -1326,23 +1378,27 @@ def CreatePcdDatabasePhaseSpecificAutoGen (Platform, Phase):
|
||||
Pcd.InitString = 'INIT'
|
||||
except:
|
||||
pass
|
||||
|
||||
#
|
||||
# For UNIT64 type PCD's value, ULL should be append to avoid
|
||||
# warning under linux building environment.
|
||||
#
|
||||
if Pcd.DatumType == "UINT64":
|
||||
ValueList.append(Sku.DefaultValue + "ULL")
|
||||
else:
|
||||
ValueList.append(Sku.DefaultValue)
|
||||
|
||||
#
|
||||
# For UNIT64 type PCD's value, ULL should be append to avoid
|
||||
# warning under linux building environment.
|
||||
#
|
||||
if Pcd.DatumType == "UINT64":
|
||||
ValueList.append(Sku.DefaultValue + "ULL")
|
||||
else:
|
||||
ValueList.append(Sku.DefaultValue)
|
||||
|
||||
Pcd.TokenTypeList = list(set(Pcd.TokenTypeList))
|
||||
|
||||
|
||||
if 'PCD_TYPE_HII' in Pcd.TokenTypeList:
|
||||
Dict['VARIABLE_HEAD_CNAME_DECL'].append(CName)
|
||||
Dict['VARIABLE_HEAD_GUID_DECL'].append(TokenSpaceGuid)
|
||||
Dict['VARIABLE_HEAD_NUMSKUS_DECL'].append(len(Pcd.SkuInfoList))
|
||||
Dict['VARIABLE_HEAD_VALUE'].append('{ %s }\n' % ' },\n { '.join(VariableHeadValueList))
|
||||
Dict['VARDEF_HEADER'].append('_Variable_Header')
|
||||
else:
|
||||
Dict['VARDEF_HEADER'].append('')
|
||||
if 'PCD_TYPE_VPD' in Pcd.TokenTypeList:
|
||||
Dict['VPD_HEAD_CNAME_DECL'].append(CName)
|
||||
Dict['VPD_HEAD_GUID_DECL'].append(TokenSpaceGuid)
|
||||
@@ -1371,7 +1427,7 @@ def CreatePcdDatabasePhaseSpecificAutoGen (Platform, Phase):
|
||||
Dict['TOKEN_CNAME'] = ['' for x in range(NumberOfLocalTokens)]
|
||||
Dict['TOKEN_GUID'] = ['' for x in range(NumberOfLocalTokens)]
|
||||
Dict['TOKEN_TYPE'] = ['' for x in range(NumberOfLocalTokens)]
|
||||
|
||||
|
||||
for Pcd in Platform.DynamicPcdList:
|
||||
CName = Pcd.TokenCName
|
||||
TokenSpaceGuidCName = Pcd.TokenSpaceGuidCName
|
||||
@@ -1614,14 +1670,14 @@ def CreateModuleEntryPointCode(Info, AutoGenC, AutoGenH):
|
||||
PiSpecVersion = Info.Module.Specification['PI_SPECIFICATION_VERSION']
|
||||
else:
|
||||
PiSpecVersion = 0
|
||||
if 'EFI_SPECIFICATION_VERSION' in Info.Module.Specification:
|
||||
EfiSpecVersion = Info.Module.Specification['EFI_SPECIFICATION_VERSION']
|
||||
if 'UEFI_SPECIFICATION_VERSION' in Info.Module.Specification:
|
||||
UefiSpecVersion = Info.Module.Specification['UEFI_SPECIFICATION_VERSION']
|
||||
else:
|
||||
EfiSpecVersion = 0
|
||||
UefiSpecVersion = 0
|
||||
Dict = {
|
||||
'Function' : Info.Module.ModuleEntryPointList,
|
||||
'PiSpecVersion' : PiSpecVersion,
|
||||
'EfiSpecVersion': EfiSpecVersion
|
||||
'Function' : Info.Module.ModuleEntryPointList,
|
||||
'PiSpecVersion' : PiSpecVersion,
|
||||
'UefiSpecVersion': UefiSpecVersion
|
||||
}
|
||||
|
||||
if Info.ModuleType in ['PEI_CORE', 'DXE_CORE', 'SMM_CORE']:
|
||||
@@ -1853,9 +1909,6 @@ def CreateHeaderCode(Info, AutoGenC, AutoGenH):
|
||||
# header file Prologue
|
||||
AutoGenH.Append(gAutoGenHPrologueString.Replace({'File':'AUTOGENH','Guid':Info.Guid.replace('-','_')}))
|
||||
if Info.AutoGenVersion >= 0x00010005:
|
||||
# specification macros
|
||||
AutoGenH.Append(gSpecificationString.Replace({'SpecificationName':Info.Specification.keys(),
|
||||
'SpecificationValue':Info.Specification.values()}))
|
||||
# header files includes
|
||||
AutoGenH.Append("#include <%s>\n" % gBasicHeaderFile)
|
||||
if Info.ModuleType in gModuleTypeHeaderFile \
|
||||
|
@@ -1,7 +1,7 @@
|
||||
## @file
|
||||
# This file is used to generate DEPEX file for module's dependency expression
|
||||
#
|
||||
# Copyright (c) 2007, Intel Corporation
|
||||
# Copyright (c) 2007 - 2010, 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
|
||||
@@ -356,7 +356,7 @@ class DependencyExpression:
|
||||
|
||||
versionNumber = "0.04"
|
||||
__version__ = "%prog Version " + versionNumber
|
||||
__copyright__ = "Copyright (c) 2007-2008, Intel Corporation All rights reserved."
|
||||
__copyright__ = "Copyright (c) 2007-2010, Intel Corporation All rights reserved."
|
||||
__usage__ = "%prog [options] [dependency_expression_file]"
|
||||
|
||||
## Parse command line options
|
||||
|
@@ -406,18 +406,10 @@ class UniFileClassObject(object):
|
||||
#
|
||||
# Load multiple .uni files
|
||||
#
|
||||
def LoadUniFiles(self, FileList = []):
|
||||
def LoadUniFiles(self, FileList):
|
||||
if len(FileList) > 0:
|
||||
if len(FileList) > 1:
|
||||
NewList = [];
|
||||
for File in FileList:
|
||||
NewList.append (File)
|
||||
NewList.sort()
|
||||
for File in NewList:
|
||||
self.LoadUniFile(File)
|
||||
else:
|
||||
for File in FileList:
|
||||
self.LoadUniFile(File)
|
||||
for File in FileList:
|
||||
self.LoadUniFile(File)
|
||||
|
||||
#
|
||||
# Add a string to list
|
||||
@@ -488,7 +480,6 @@ class UniFileClassObject(object):
|
||||
EdkLogger.debug(EdkLogger.DEBUG_5, Name)
|
||||
Token = len(self.OrderedStringList[LangFind])
|
||||
self.AddStringToList(Name, LangFind, Value, Token, Referenced, LangKey, Index)
|
||||
|
||||
#
|
||||
# Retoken
|
||||
#
|
||||
@@ -497,7 +488,17 @@ class UniFileClassObject(object):
|
||||
ReferencedStringList = []
|
||||
NotReferencedStringList = []
|
||||
Token = 0
|
||||
|
||||
#
|
||||
# Order UNI token by their String Name
|
||||
#
|
||||
StringNameList = []
|
||||
for Item in self.OrderedStringList[LangName]:
|
||||
StringNameList.append (Item.StringName)
|
||||
StringNameList.sort()
|
||||
|
||||
for Name in StringNameList:
|
||||
Item = self.FindStringValue (Name, LangName)
|
||||
if Item.Referenced == True:
|
||||
Item.Token = Token
|
||||
ReferencedStringList.append(Item)
|
||||
|
@@ -1,4 +1,10 @@
|
||||
# Copyright (c) 2007, Intel Corporation
|
||||
## @file
|
||||
# Python 'AutoGen' package initialization file.
|
||||
#
|
||||
# This file is required to make Python interpreter treat the directory
|
||||
# as containing package.
|
||||
#
|
||||
# Copyright (c) 2007 - 2010, Intel Corporation<BR>
|
||||
# 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
|
||||
@@ -6,5 +12,6 @@
|
||||
#
|
||||
# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
|
||||
#
|
||||
|
||||
__all__ = ["AutoGen"]
|
||||
|
@@ -84,7 +84,7 @@ UNKNOWN_ERROR = 0xFFFF
|
||||
|
||||
## Error message of each error code
|
||||
gErrorMessage = {
|
||||
FILE_NOT_FOUND : "File/directory not found",
|
||||
FILE_NOT_FOUND : "File/directory not found in workspace",
|
||||
FILE_OPEN_FAILURE : "File open failure",
|
||||
FILE_WRITE_FAILURE : "File write failure",
|
||||
FILE_PARSE_FAILURE : "File parse failure",
|
||||
|
@@ -73,6 +73,8 @@ EDK_COMPONENT_TYPE_BS_DRIVER = 'BS_DRIVER'
|
||||
EDK_COMPONENT_TYPE_RT_DRIVER = 'RT_DRIVER'
|
||||
EDK_COMPONENT_TYPE_SAL_RT_DRIVER = 'SAL_RT_DRIVER'
|
||||
EDK_COMPONENT_TYPE_APPLICATION = 'APPLICATION'
|
||||
EDK_NAME = 'EDK'
|
||||
EDKII_NAME = 'EDKII'
|
||||
|
||||
BINARY_FILE_TYPE_FW = 'FW'
|
||||
BINARY_FILE_TYPE_GUID = 'GUID'
|
||||
@@ -230,6 +232,19 @@ TAB_PCDS_DYNAMIC_EBC = TAB_PCDS + TAB_PCDS_DYNAMIC + TAB_SPLIT + TAB_ARCH_EBC
|
||||
TAB_PCD_DYNAMIC_TYPE_LIST = [TAB_PCDS_DYNAMIC_DEFAULT_NULL, TAB_PCDS_DYNAMIC_VPD_NULL, TAB_PCDS_DYNAMIC_HII_NULL]
|
||||
TAB_PCD_DYNAMIC_EX_TYPE_LIST = [TAB_PCDS_DYNAMIC_EX_DEFAULT_NULL, TAB_PCDS_DYNAMIC_EX_VPD_NULL, TAB_PCDS_DYNAMIC_EX_HII_NULL]
|
||||
|
||||
TAB_PCDS_PATCHABLE_LOAD_FIX_ADDRESS_PEI_PAGE_SIZE = 'PcdLoadFixAddressPeiCodePageNumber'
|
||||
TAB_PCDS_PATCHABLE_LOAD_FIX_ADDRESS_PEI_PAGE_SIZE_DATA_TYPE = 'UINT32'
|
||||
TAB_PCDS_PATCHABLE_LOAD_FIX_ADDRESS_DXE_PAGE_SIZE = 'PcdLoadFixAddressBootTimeCodePageNumber'
|
||||
TAB_PCDS_PATCHABLE_LOAD_FIX_ADDRESS_DXE_PAGE_SIZE_DATA_TYPE = 'UINT32'
|
||||
TAB_PCDS_PATCHABLE_LOAD_FIX_ADDRESS_RUNTIME_PAGE_SIZE = 'PcdLoadFixAddressRuntimeCodePageNumber'
|
||||
TAB_PCDS_PATCHABLE_LOAD_FIX_ADDRESS_RUNTIME_PAGE_SIZE_DATA_TYPE = 'UINT32'
|
||||
TAB_PCDS_PATCHABLE_LOAD_FIX_ADDRESS_SMM_PAGE_SIZE = 'PcdLoadFixAddressSmmCodePageNumber'
|
||||
TAB_PCDS_PATCHABLE_LOAD_FIX_ADDRESS_SMM_PAGE_SIZE_DATA_TYPE = 'UINT32'
|
||||
TAB_PCDS_PATCHABLE_LOAD_FIX_ADDRESS_LIST = [TAB_PCDS_PATCHABLE_LOAD_FIX_ADDRESS_PEI_PAGE_SIZE, \
|
||||
TAB_PCDS_PATCHABLE_LOAD_FIX_ADDRESS_DXE_PAGE_SIZE, \
|
||||
TAB_PCDS_PATCHABLE_LOAD_FIX_ADDRESS_RUNTIME_PAGE_SIZE, \
|
||||
TAB_PCDS_PATCHABLE_LOAD_FIX_ADDRESS_SMM_PAGE_SIZE]
|
||||
|
||||
TAB_DEPEX = 'Depex'
|
||||
TAB_DEPEX_COMMON = TAB_DEPEX + TAB_SPLIT + TAB_ARCH_COMMON
|
||||
TAB_DEPEX_IA32 = TAB_DEPEX + TAB_SPLIT + TAB_ARCH_IA32
|
||||
@@ -338,6 +353,7 @@ TAB_DSC_DEFINES_MAKEFILE_NAME = 'MAKEFILE_NAME'
|
||||
TAB_DSC_DEFINES_BS_BASE_ADDRESS = 'BsBaseAddress'
|
||||
TAB_DSC_DEFINES_RT_BASE_ADDRESS = 'RtBaseAddress'
|
||||
TAB_DSC_DEFINES_DEFINE = 'DEFINE'
|
||||
TAB_FIX_LOAD_TOP_MEMORY_ADDRESS = 'FIX_LOAD_TOP_MEMORY_ADDRESS'
|
||||
|
||||
#
|
||||
# TargetTxt Definitions
|
||||
|
@@ -1,7 +1,7 @@
|
||||
## @file
|
||||
# This file is used to define each component of the build database
|
||||
#
|
||||
# Copyright (c) 2007 ~ 2008, Intel Corporation
|
||||
# Copyright (c) 2007 - 2010, 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
|
||||
@@ -748,7 +748,8 @@ class WorkspaceBuild(object):
|
||||
#
|
||||
Pb.Specification = ModuleHeader.Specification
|
||||
Pb.Specification[TAB_INF_DEFINES_EDK_RELEASE_VERSION] = ModuleHeader.EdkReleaseVersion
|
||||
Pb.Specification[TAB_INF_DEFINES_EFI_SPECIFICATION_VERSION] = ModuleHeader.EfiSpecificationVersion
|
||||
Pb.Specification[TAB_INF_DEFINES_EFI_SPECIFICATION_VERSION] = ModuleHeader.UefiSpecificationVersion
|
||||
Pb.Specification[TAB_INF_DEFINES_UEFI_SPECIFICATION_VERSION] = ModuleHeader.UefiSpecificationVersion
|
||||
Pb.AutoGenVersion = int(ModuleHeader.InfVersion, 0)
|
||||
|
||||
#
|
||||
|
@@ -1439,10 +1439,17 @@ class FdfParser(object):
|
||||
def __GetBlockStatements(self, Obj):
|
||||
|
||||
if not self.__GetBlockStatement(Obj):
|
||||
raise Warning("expected block statement At Line ", self.FileName, self.CurrentLineNumber)
|
||||
|
||||
#set default block size is 1
|
||||
Obj.BlockSizeList.append((1, Obj.Size, None))
|
||||
return True
|
||||
|
||||
while self.__GetBlockStatement(Obj):
|
||||
pass
|
||||
|
||||
for Item in Obj.BlockSizeList:
|
||||
if Item[0] == None or Item[1] == None:
|
||||
raise Warning("expected block statement for Fd Section", self.FileName, self.CurrentLineNumber)
|
||||
|
||||
return True
|
||||
|
||||
## __GetBlockStatement() method
|
||||
@@ -2329,6 +2336,8 @@ class FdfParser(object):
|
||||
|
||||
AlignValue = None
|
||||
if self.__GetAlignment():
|
||||
if self.__Token not in ("Auto", "8", "16", "32", "64", "128", "512", "1K", "4K", "32K" ,"64K"):
|
||||
raise Warning("Incorrect alignment '%s'" % self.__Token, self.FileName, self.CurrentLineNumber)
|
||||
AlignValue = self.__Token
|
||||
|
||||
BuildNum = None
|
||||
@@ -2342,6 +2351,8 @@ class FdfParser(object):
|
||||
BuildNum = self.__Token
|
||||
|
||||
if self.__IsKeyword( "VERSION"):
|
||||
if AlignValue == 'Auto':
|
||||
raise Warning("Auto alignment can only be used in PE32 or TE section ", self.FileName, self.CurrentLineNumber)
|
||||
if not self.__IsToken( "="):
|
||||
raise Warning("expected '=' At Line ", self.FileName, self.CurrentLineNumber)
|
||||
if not self.__GetNextToken():
|
||||
@@ -2356,6 +2367,8 @@ class FdfParser(object):
|
||||
Obj.SectionList.append(VerSectionObj)
|
||||
|
||||
elif self.__IsKeyword( "UI"):
|
||||
if AlignValue == 'Auto':
|
||||
raise Warning("Auto alignment can only be used in PE32 or TE section ", self.FileName, self.CurrentLineNumber)
|
||||
if not self.__IsToken( "="):
|
||||
raise Warning("expected '=' At Line ", self.FileName, self.CurrentLineNumber)
|
||||
if not self.__GetNextToken():
|
||||
@@ -2369,6 +2382,8 @@ class FdfParser(object):
|
||||
Obj.SectionList.append(UiSectionObj)
|
||||
|
||||
elif self.__IsKeyword( "FV_IMAGE"):
|
||||
if AlignValue == 'Auto':
|
||||
raise Warning("Auto alignment can only be used in PE32 or TE section ", self.FileName, self.CurrentLineNumber)
|
||||
if not self.__IsToken( "="):
|
||||
raise Warning("expected '=' At Line ", self.FileName, self.CurrentLineNumber)
|
||||
if not self.__GetNextWord():
|
||||
@@ -2409,6 +2424,8 @@ class FdfParser(object):
|
||||
Obj.SectionList.append(FvImageSectionObj)
|
||||
|
||||
elif self.__IsKeyword("PEI_DEPEX_EXP") or self.__IsKeyword("DXE_DEPEX_EXP") or self.__IsKeyword("SMM_DEPEX_EXP"):
|
||||
if AlignValue == 'Auto':
|
||||
raise Warning("Auto alignment can only be used in PE32 or TE section ", self.FileName, self.CurrentLineNumber)
|
||||
DepexSectionObj = CommonDataClass.FdfClass.DepexSectionClassObject()
|
||||
DepexSectionObj.Alignment = AlignValue
|
||||
DepexSectionObj.DepexType = self.__Token
|
||||
@@ -2436,6 +2453,8 @@ class FdfParser(object):
|
||||
if self.__Token not in ("COMPAT16", "PE32", "PIC", "TE", "FV_IMAGE", "RAW", "DXE_DEPEX",\
|
||||
"UI", "VERSION", "PEI_DEPEX", "SUBTYPE_GUID", "SMM_DEPEX"):
|
||||
raise Warning("Unknown section type '%s'" % self.__Token, self.FileName, self.CurrentLineNumber)
|
||||
if AlignValue == 'Auto'and (not self.__Token == 'PE32') and (not self.__Token == 'TE'):
|
||||
raise Warning("Auto alignment can only be used in PE32 or TE section ", self.FileName, self.CurrentLineNumber)
|
||||
# DataSection
|
||||
DataSectionObj = CommonDataClass.FdfClass.DataSectionClassObject()
|
||||
DataSectionObj.Alignment = AlignValue
|
||||
@@ -2585,6 +2604,8 @@ class FdfParser(object):
|
||||
|
||||
AlignValue = None
|
||||
if self.__GetAlignment():
|
||||
if self.__Token not in ("8", "16", "32", "64", "128", "512", "1K", "4K", "32K" ,"64K"):
|
||||
raise Warning("Incorrect alignment '%s'" % self.__Token, self.FileName, self.CurrentLineNumber)
|
||||
AlignValue = self.__Token
|
||||
|
||||
if not self.__GetCglSection(FfsFileObj, AlignValue):
|
||||
@@ -2899,7 +2920,7 @@ class FdfParser(object):
|
||||
|
||||
AlignValue = ""
|
||||
if self.__GetAlignment():
|
||||
if self.__Token not in ("8", "16", "32", "64", "128", "512", "1K", "4K", "32K" ,"64K"):
|
||||
if self.__Token not in ("Auto", "8", "16", "32", "64", "128", "512", "1K", "4K", "32K" ,"64K"):
|
||||
raise Warning("Incorrect alignment At Line ", self.FileName, self.CurrentLineNumber)
|
||||
AlignValue = self.__Token
|
||||
|
||||
@@ -2963,8 +2984,10 @@ class FdfParser(object):
|
||||
CheckSum = True
|
||||
|
||||
if self.__GetAlignment():
|
||||
if self.__Token not in ("8", "16", "32", "64", "128", "512", "1K", "4K", "32K" ,"64K"):
|
||||
if self.__Token not in ("Auto", "8", "16", "32", "64", "128", "512", "1K", "4K", "32K" ,"64K"):
|
||||
raise Warning("Incorrect alignment At Line ", self.FileName, self.CurrentLineNumber)
|
||||
if self.__Token == 'Auto' and (not SectionName == 'PE32') and (not SectionName == 'TE'):
|
||||
raise Warning("Auto alignment can only be used in PE32 or TE section ", self.FileName, self.CurrentLineNumber)
|
||||
AlignValue = self.__Token
|
||||
|
||||
if not self.__GetNextToken():
|
||||
@@ -3039,14 +3062,6 @@ class FdfParser(object):
|
||||
raise Warning("Incorrect alignment At Line ", self.FileName, self.CurrentLineNumber)
|
||||
FvImageSectionObj.Alignment = self.__Token
|
||||
|
||||
if self.__IsKeyword("FV"):
|
||||
FvImageSectionObj.FvFileType = self.__Token
|
||||
|
||||
if self.__GetAlignment():
|
||||
if self.__Token not in ("8", "16", "32", "64", "128", "512", "1K", "4K", "32K" ,"64K"):
|
||||
raise Warning("Incorrect alignment At Line ", self.FileName, self.CurrentLineNumber)
|
||||
FvImageSectionObj.Alignment = self.__Token
|
||||
|
||||
if self.__IsToken('|'):
|
||||
FvImageSectionObj.FvFileExtension = self.__GetFileExtension()
|
||||
elif self.__GetNextToken():
|
||||
@@ -3110,6 +3125,10 @@ class FdfParser(object):
|
||||
EfiSectionObj.BuildNum = self.__Token
|
||||
|
||||
if self.__GetAlignment():
|
||||
if self.__Token not in ("Auto", "8", "16", "32", "64", "128", "512", "1K", "4K", "32K" ,"64K"):
|
||||
raise Warning("Incorrect alignment '%s'" % self.__Token, self.FileName, self.CurrentLineNumber)
|
||||
if self.__Token == 'Auto' and (not SectionName == 'PE32') and (not SectionName == 'TE'):
|
||||
raise Warning("Auto alignment can only be used in PE32 or TE section ", self.FileName, self.CurrentLineNumber)
|
||||
EfiSectionObj.Alignment = self.__Token
|
||||
|
||||
if self.__IsKeyword('RELOCS_STRIPPED') or self.__IsKeyword('RELOCS_RETAINED'):
|
||||
|
@@ -1,7 +1,7 @@
|
||||
## @file
|
||||
# This file is used to define each component of INF file
|
||||
#
|
||||
# Copyright (c) 2007, Intel Corporation
|
||||
# Copyright (c) 2007 - 2010, 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
|
||||
@@ -85,7 +85,8 @@ class InfHeader(ModuleHeaderClass):
|
||||
TAB_INF_DEFINES_BASE_NAME : "Name",
|
||||
TAB_INF_DEFINES_FILE_GUID : "Guid",
|
||||
TAB_INF_DEFINES_MODULE_TYPE : "ModuleType",
|
||||
TAB_INF_DEFINES_EFI_SPECIFICATION_VERSION : "EfiSpecificationVersion",
|
||||
TAB_INF_DEFINES_EFI_SPECIFICATION_VERSION : "UefiSpecificationVersion",
|
||||
TAB_INF_DEFINES_UEFI_SPECIFICATION_VERSION : "UefiSpecificationVersion",
|
||||
TAB_INF_DEFINES_EDK_RELEASE_VERSION : "EdkReleaseVersion",
|
||||
#
|
||||
# Optional Fields
|
||||
@@ -452,7 +453,7 @@ class Inf(InfObject):
|
||||
print 'Guid =', M.Header[Arch].Guid
|
||||
print 'Version =', M.Header[Arch].Version
|
||||
print 'InfVersion =', M.Header[Arch].InfVersion
|
||||
print 'EfiSpecificationVersion =', M.Header[Arch].EfiSpecificationVersion
|
||||
print 'UefiSpecificationVersion =', M.Header[Arch].UefiSpecificationVersion
|
||||
print 'EdkReleaseVersion =', M.Header[Arch].EdkReleaseVersion
|
||||
print 'ModuleType =', M.Header[Arch].ModuleType
|
||||
print 'BinaryModule =', M.Header[Arch].BinaryModule
|
||||
|
@@ -1,7 +1,7 @@
|
||||
## @file
|
||||
# This file is used to define each component of INF file
|
||||
#
|
||||
# Copyright (c) 2007, Intel Corporation
|
||||
# Copyright (c) 2007 - 2010, 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
|
||||
@@ -71,7 +71,8 @@ class InfHeader(ModuleHeaderClass):
|
||||
TAB_INF_DEFINES_BASE_NAME : "Name",
|
||||
TAB_INF_DEFINES_FILE_GUID : "Guid",
|
||||
TAB_INF_DEFINES_MODULE_TYPE : "ModuleType",
|
||||
TAB_INF_DEFINES_EFI_SPECIFICATION_VERSION : "EfiSpecificationVersion",
|
||||
TAB_INF_DEFINES_EFI_SPECIFICATION_VERSION : "UefiSpecificationVersion",
|
||||
TAB_INF_DEFINES_UEFI_SPECIFICATION_VERSION : "UefiSpecificationVersion",
|
||||
TAB_INF_DEFINES_EDK_RELEASE_VERSION : "EdkReleaseVersion",
|
||||
|
||||
# Optional Fields
|
||||
@@ -583,7 +584,7 @@ class Inf(InfObject):
|
||||
ModuleHeader.PcdIsDriver = Value
|
||||
elif Name == TAB_INF_DEFINES_MODULE_TYPE:
|
||||
ModuleHeader.ModuleType = Value
|
||||
elif Name == TAB_INF_DEFINES_UEFI_SPECIFICATION_VERSION:
|
||||
elif Name in (TAB_INF_DEFINES_UEFI_SPECIFICATION_VERSION, TAB_INF_DEFINES_UEFI_SPECIFICATION_VERSION):
|
||||
ModuleHeader.UefiSpecificationVersion = Value
|
||||
elif Name == TAB_INF_DEFINES_PI_SPECIFICATION_VERSION:
|
||||
ModuleHeader.PiSpecificationVersion = Value
|
||||
|
@@ -22,6 +22,7 @@ import threading
|
||||
import time
|
||||
import re
|
||||
import cPickle
|
||||
import array
|
||||
from UserDict import IterableUserDict
|
||||
from UserList import UserList
|
||||
|
||||
@@ -1343,6 +1344,90 @@ class PathClass(object):
|
||||
|
||||
Key = property(_GetFileKey)
|
||||
|
||||
## Parse PE image to get the required PE informaion.
|
||||
#
|
||||
class PeImageClass():
|
||||
## Constructor
|
||||
#
|
||||
# @param File FilePath of PeImage
|
||||
#
|
||||
def __init__(self, PeFile):
|
||||
self.FileName = PeFile
|
||||
self.IsValid = False
|
||||
self.Size = 0
|
||||
self.EntryPoint = 0
|
||||
self.SectionAlignment = 0
|
||||
self.SectionHeaderList = []
|
||||
self.ErrorInfo = ''
|
||||
try:
|
||||
PeObject = open(PeFile, 'rb')
|
||||
except:
|
||||
self.ErrorInfo = self.FileName + ' can not be found\n'
|
||||
return
|
||||
# Read DOS header
|
||||
ByteArray = array.array('B')
|
||||
ByteArray.fromfile(PeObject, 0x3E)
|
||||
ByteList = ByteArray.tolist()
|
||||
# DOS signature should be 'MZ'
|
||||
if self._ByteListToStr (ByteList[0x0:0x2]) != 'MZ':
|
||||
self.ErrorInfo = self.FileName + ' has no valid DOS signature MZ'
|
||||
return
|
||||
|
||||
# Read 4 byte PE Signature
|
||||
PeOffset = self._ByteListToInt(ByteList[0x3C:0x3E])
|
||||
PeObject.seek(PeOffset)
|
||||
ByteArray = array.array('B')
|
||||
ByteArray.fromfile(PeObject, 4)
|
||||
# PE signature should be 'PE\0\0'
|
||||
if ByteArray.tostring() != 'PE\0\0':
|
||||
self.ErrorInfo = self.FileName + ' has no valid PE signature PE00'
|
||||
return
|
||||
|
||||
# Read PE file header
|
||||
ByteArray = array.array('B')
|
||||
ByteArray.fromfile(PeObject, 0x14)
|
||||
ByteList = ByteArray.tolist()
|
||||
SecNumber = self._ByteListToInt(ByteList[0x2:0x4])
|
||||
if SecNumber == 0:
|
||||
self.ErrorInfo = self.FileName + ' has no section header'
|
||||
return
|
||||
|
||||
# Read PE optional header
|
||||
OptionalHeaderSize = self._ByteListToInt(ByteArray[0x10:0x12])
|
||||
ByteArray = array.array('B')
|
||||
ByteArray.fromfile(PeObject, OptionalHeaderSize)
|
||||
ByteList = ByteArray.tolist()
|
||||
self.EntryPoint = self._ByteListToInt(ByteList[0x10:0x14])
|
||||
self.SectionAlignment = self._ByteListToInt(ByteList[0x20:0x24])
|
||||
self.Size = self._ByteListToInt(ByteList[0x38:0x3C])
|
||||
|
||||
# Read each Section Header
|
||||
for Index in range(SecNumber):
|
||||
ByteArray = array.array('B')
|
||||
ByteArray.fromfile(PeObject, 0x28)
|
||||
ByteList = ByteArray.tolist()
|
||||
SecName = self._ByteListToStr(ByteList[0:8])
|
||||
SecVirtualSize = self._ByteListToInt(ByteList[8:12])
|
||||
SecRawAddress = self._ByteListToInt(ByteList[20:24])
|
||||
SecVirtualAddress = self._ByteListToInt(ByteList[12:16])
|
||||
self.SectionHeaderList.append((SecName, SecVirtualAddress, SecRawAddress, SecVirtualSize))
|
||||
self.IsValid = True
|
||||
PeObject.close()
|
||||
|
||||
def _ByteListToStr(self, ByteList):
|
||||
String = ''
|
||||
for index in range(len(ByteList)):
|
||||
if ByteList[index] == 0:
|
||||
break
|
||||
String += chr(ByteList[index])
|
||||
return String
|
||||
|
||||
def _ByteListToInt(self, ByteList):
|
||||
Value = 0
|
||||
for index in range(len(ByteList) - 1, -1, -1):
|
||||
Value = (Value << 8) | int(ByteList[index])
|
||||
return Value
|
||||
|
||||
##
|
||||
#
|
||||
# This acts like the main() function for the script, unless it is 'import'ed into another
|
||||
|
@@ -1,7 +1,7 @@
|
||||
## @file
|
||||
# This file is used to define common parsing related functions used in parsing INF/DEC/DSC process
|
||||
# This file is used to define common parsing related functions used in parsing INF/DEC/DSC process
|
||||
#
|
||||
# Copyright (c) 2008, Intel Corporation
|
||||
# Copyright (c) 2008 ~ 2010, 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
|
||||
@@ -31,7 +31,7 @@ def ParseContent(Lines, ):
|
||||
Line = CleanString(Line)
|
||||
if Line == '':
|
||||
continue
|
||||
|
||||
|
||||
#
|
||||
# Find a new section tab
|
||||
# First insert previous section items
|
||||
@@ -48,7 +48,7 @@ def ParseContent(Lines, ):
|
||||
SectionItemList = []
|
||||
ArchList = []
|
||||
ThirdList = []
|
||||
|
||||
|
||||
LineList = GetSplitValueList(Line[len(TAB_SECTION_START):len(Line) - len(TAB_SECTION_END)], TAB_COMMA_SPLIT)
|
||||
for Item in LineList:
|
||||
ItemList = GetSplitValueList(Item, TAB_SPLIT)
|
||||
@@ -66,7 +66,7 @@ def ParseContent(Lines, ):
|
||||
ThirdList.append(ItemList[2])
|
||||
|
||||
continue
|
||||
|
||||
|
||||
#
|
||||
# Not in any defined section
|
||||
#
|
||||
@@ -97,13 +97,13 @@ def ParseDefineMacro2(Table, RecordSets, GlobalMacro):
|
||||
RecordSet = Table.Exec(SqlCommand)
|
||||
for Record in RecordSet:
|
||||
Macros[Record[0]] = Record[1]
|
||||
|
||||
|
||||
#
|
||||
# Overrided by Global Macros
|
||||
#
|
||||
for Key in GlobalMacro.keys():
|
||||
Macros[Key] = GlobalMacro[Key]
|
||||
|
||||
|
||||
#
|
||||
# Replace the Macros
|
||||
#
|
||||
@@ -111,7 +111,7 @@ def ParseDefineMacro2(Table, RecordSets, GlobalMacro):
|
||||
if RecordSets[Key] != []:
|
||||
for Item in RecordSets[Key]:
|
||||
Item[0] = ReplaceMacro(Item[0], Macros)
|
||||
|
||||
|
||||
## ParseDefineMacro
|
||||
#
|
||||
# Search whole table to find all defined Macro and replaced them with the real values
|
||||
@@ -130,22 +130,22 @@ def ParseDefineMacro(Table, GlobalMacro):
|
||||
# The follow SqlCommand (expr replace) is not supported in Sqlite 3.3.4 which is used in Python 2.5 *
|
||||
# Reserved Only *
|
||||
# SqlCommand = """update %s set Value1 = replace(Value1, '%s', '%s') *
|
||||
# where ID in (select ID from %s *
|
||||
# where ID in (select ID from %s *
|
||||
# where Model = %s *
|
||||
# and Value1 like '%%%s%%' *
|
||||
# and StartLine > %s *
|
||||
# and Enabled > -1 *
|
||||
# and Arch = '%s')""" % \ *
|
||||
# and Arch = '%s')""" % \ *
|
||||
# (self.TblDsc.Table, Record[0], Record[1], self.TblDsc.Table, Record[2], Record[1], Record[3], Record[4]) *
|
||||
#***************************************************************************************************************************************************
|
||||
Macros[Record[0]] = Record[1]
|
||||
|
||||
|
||||
#
|
||||
# Overrided by Global Macros
|
||||
#
|
||||
for Key in GlobalMacro.keys():
|
||||
Macros[Key] = GlobalMacro[Key]
|
||||
|
||||
|
||||
#
|
||||
# Found all defined macro and replaced
|
||||
#
|
||||
@@ -228,7 +228,7 @@ def QueryDefinesItem2(Table, Arch, BelongsToFile):
|
||||
and BelongsToFile = %s
|
||||
and Enabled > -1""" % (Table.Table, MODEL_META_DATA_HEADER, ConvertToSqlString2(TAB_ARCH_COMMON), BelongsToFile)
|
||||
RecordSet = Table.Exec(SqlCommand)
|
||||
|
||||
|
||||
return RecordSet
|
||||
|
||||
##QueryDscItem
|
||||
@@ -307,7 +307,7 @@ def GetBuildOption(String, File, LineNo = -1):
|
||||
## Get Library Class
|
||||
#
|
||||
# Get Library of Dsc as <LibraryClassKeyWord>|<LibraryInstance>
|
||||
#
|
||||
#
|
||||
# @param Item: String as <LibraryClassKeyWord>|<LibraryInstance>
|
||||
# @param ContainerFile: The file which describes the library class, used for error report
|
||||
#
|
||||
@@ -329,7 +329,7 @@ def GetLibraryClass(Item, ContainerFile, WorkspaceDir, LineNo = -1):
|
||||
## Get Library Class
|
||||
#
|
||||
# Get Library of Dsc as <LibraryClassKeyWord>[|<LibraryInstance>][|<TokenSpaceGuidCName>.<PcdCName>]
|
||||
#
|
||||
#
|
||||
# @param Item: String as <LibraryClassKeyWord>|<LibraryInstance>
|
||||
# @param ContainerFile: The file which describes the library class, used for error report
|
||||
#
|
||||
@@ -349,7 +349,7 @@ def GetLibraryClassOfInf(Item, ContainerFile, WorkspaceDir, LineNo = -1):
|
||||
if Item[1] != '':
|
||||
SupMod = Item[1]
|
||||
|
||||
return (ItemList[0], ItemList[1], ItemList[2], SupMod)
|
||||
return (ItemList[0], ItemList[1], ItemList[2], SupMod)
|
||||
|
||||
## CheckPcdTokenInfo
|
||||
#
|
||||
@@ -373,7 +373,7 @@ def CheckPcdTokenInfo(TokenInfoString, Section, File, LineNo = -1):
|
||||
## Get Pcd
|
||||
#
|
||||
# Get Pcd of Dsc as <PcdTokenSpaceGuidCName>.<TokenCName>|<Value>[|<Type>|<MaximumDatumSize>]
|
||||
#
|
||||
#
|
||||
# @param Item: String as <PcdTokenSpaceGuidCName>.<TokenCName>|<Value>[|<Type>|<MaximumDatumSize>]
|
||||
# @param ContainerFile: The file which describes the pcd, used for error report
|
||||
#
|
||||
@@ -382,23 +382,23 @@ def CheckPcdTokenInfo(TokenInfoString, Section, File, LineNo = -1):
|
||||
def GetPcd(Item, Type, ContainerFile, LineNo = -1):
|
||||
TokenGuid, TokenName, Value, MaximumDatumSize, Token = '', '', '', '', ''
|
||||
List = GetSplitValueList(Item + TAB_VALUE_SPLIT * 2)
|
||||
|
||||
|
||||
if len(List) < 4 or len(List) > 6:
|
||||
RaiseParserError(Item, 'Pcds' + Type, ContainerFile, '<PcdTokenSpaceGuidCName>.<TokenCName>|<Value>[|<Type>|<MaximumDatumSize>]', LineNo)
|
||||
else:
|
||||
Value = List[1]
|
||||
MaximumDatumSize = List[2]
|
||||
Token = List[3]
|
||||
|
||||
|
||||
if CheckPcdTokenInfo(List[0], 'Pcds' + Type, ContainerFile, LineNo):
|
||||
(TokenGuid, TokenName) = GetSplitValueList(List[0], TAB_SPLIT)
|
||||
|
||||
|
||||
return (TokenName, TokenGuid, Value, MaximumDatumSize, Token, Type)
|
||||
|
||||
## Get FeatureFlagPcd
|
||||
#
|
||||
# Get FeatureFlagPcd of Dsc as <PcdTokenSpaceGuidCName>.<TokenCName>|TRUE/FALSE
|
||||
#
|
||||
#
|
||||
# @param Item: String as <PcdTokenSpaceGuidCName>.<TokenCName>|TRUE/FALSE
|
||||
# @param ContainerFile: The file which describes the pcd, used for error report
|
||||
#
|
||||
@@ -413,13 +413,13 @@ def GetFeatureFlagPcd(Item, Type, ContainerFile, LineNo = -1):
|
||||
Value = List[1]
|
||||
if CheckPcdTokenInfo(List[0], 'Pcds' + Type, ContainerFile, LineNo):
|
||||
(TokenGuid, TokenName) = GetSplitValueList(List[0], DataType.TAB_SPLIT)
|
||||
|
||||
|
||||
return (TokenName, TokenGuid, Value, Type)
|
||||
|
||||
## Get DynamicDefaultPcd
|
||||
#
|
||||
# Get DynamicDefaultPcd of Dsc as <PcdTokenSpaceGuidCName>.<TokenCName>|<Value>[|<DatumTyp>[|<MaxDatumSize>]]
|
||||
#
|
||||
#
|
||||
# @param Item: String as <PcdTokenSpaceGuidCName>.<TokenCName>|TRUE/FALSE
|
||||
# @param ContainerFile: The file which describes the pcd, used for error report
|
||||
#
|
||||
@@ -436,13 +436,13 @@ def GetDynamicDefaultPcd(Item, Type, ContainerFile, LineNo = -1):
|
||||
MaxDatumSize = List[3]
|
||||
if CheckPcdTokenInfo(List[0], 'Pcds' + Type, ContainerFile, LineNo):
|
||||
(TokenGuid, TokenName) = GetSplitValueList(List[0], TAB_SPLIT)
|
||||
|
||||
|
||||
return (TokenName, TokenGuid, Value, DatumTyp, MaxDatumSize, Type)
|
||||
|
||||
## Get DynamicHiiPcd
|
||||
#
|
||||
# Get DynamicHiiPcd of Dsc as <PcdTokenSpaceGuidCName>.<TokenCName>|<String>|<VariableGuidCName>|<VariableOffset>[|<DefaultValue>[|<MaximumDatumSize>]]
|
||||
#
|
||||
#
|
||||
# @param Item: String as <PcdTokenSpaceGuidCName>.<TokenCName>|TRUE/FALSE
|
||||
# @param ContainerFile: The file which describes the pcd, used for error report
|
||||
#
|
||||
@@ -457,13 +457,13 @@ def GetDynamicHiiPcd(Item, Type, ContainerFile, LineNo = -1):
|
||||
L1, L2, L3, L4, L5 = List[1], List[2], List[3], List[4], List[5]
|
||||
if CheckPcdTokenInfo(List[0], 'Pcds' + Type, ContainerFile, LineNo):
|
||||
(TokenGuid, TokenName) = GetSplitValueList(List[0], DataType.TAB_SPLIT)
|
||||
|
||||
|
||||
return (TokenName, TokenGuid, L1, L2, L3, L4, L5, Type)
|
||||
|
||||
## Get DynamicVpdPcd
|
||||
#
|
||||
# Get DynamicVpdPcd of Dsc as <PcdTokenSpaceGuidCName>.<TokenCName>|<VpdOffset>[|<MaximumDatumSize>]
|
||||
#
|
||||
#
|
||||
# @param Item: String as <PcdTokenSpaceGuidCName>.<TokenCName>|TRUE/FALSE
|
||||
# @param ContainerFile: The file which describes the pcd, used for error report
|
||||
#
|
||||
@@ -478,7 +478,7 @@ def GetDynamicVpdPcd(Item, Type, ContainerFile, LineNo = -1):
|
||||
L1, L2 = List[1], List[2]
|
||||
if CheckPcdTokenInfo(List[0], 'Pcds' + Type, ContainerFile, LineNo):
|
||||
(TokenGuid, TokenName) = GetSplitValueList(List[0], DataType.TAB_SPLIT)
|
||||
|
||||
|
||||
return (TokenName, TokenGuid, L1, L2, Type)
|
||||
|
||||
## GetComponent
|
||||
@@ -500,13 +500,13 @@ def GetComponent(Lines, KeyValues):
|
||||
|
||||
for Line in Lines:
|
||||
Line = Line[0]
|
||||
|
||||
|
||||
#
|
||||
# Ignore !include statement
|
||||
#
|
||||
if Line.upper().find(TAB_INCLUDE.upper() + ' ') > -1 or Line.upper().find(TAB_DEFINE + ' ') > -1:
|
||||
continue
|
||||
|
||||
|
||||
if findBlock == False:
|
||||
ListItem = Line
|
||||
#
|
||||
@@ -596,7 +596,7 @@ def GetExec(String):
|
||||
# Set KeyValues as [ ['component name', [lib1, lib2, lib3], [bo1, bo2, bo3], [pcd1, pcd2, pcd3]], ...]
|
||||
#
|
||||
# @param Lines: The content to be parsed
|
||||
# @param Key: Reserved
|
||||
# @param Key: Reserved
|
||||
# @param KeyValues: To store data after parsing
|
||||
# @param CommentCharacter: Comment char, used to ignore comment content
|
||||
#
|
||||
@@ -683,7 +683,7 @@ def GetComponents(Lines, Key, KeyValues, CommentCharacter):
|
||||
## Get Source
|
||||
#
|
||||
# Get Source of Inf as <Filename>[|<Family>[|<TagName>[|<ToolCode>[|<PcdFeatureFlag>]]]]
|
||||
#
|
||||
#
|
||||
# @param Item: String as <Filename>[|<Family>[|<TagName>[|<ToolCode>[|<PcdFeatureFlag>]]]]
|
||||
# @param ContainerFile: The file which describes the library class, used for error report
|
||||
#
|
||||
@@ -704,11 +704,12 @@ def GetSource(Item, ContainerFile, FileRelativePath, LineNo = -1):
|
||||
## Get Binary
|
||||
#
|
||||
# Get Binary of Inf as <Filename>[|<Family>[|<TagName>[|<ToolCode>[|<PcdFeatureFlag>]]]]
|
||||
#
|
||||
#
|
||||
# @param Item: String as <Filename>[|<Family>[|<TagName>[|<ToolCode>[|<PcdFeatureFlag>]]]]
|
||||
# @param ContainerFile: The file which describes the library class, used for error report
|
||||
#
|
||||
# @retval (List[0], List[1], List[2], List[3])
|
||||
# @retval List
|
||||
#
|
||||
def GetBinary(Item, ContainerFile, FileRelativePath, LineNo = -1):
|
||||
ItemNew = Item + DataType.TAB_VALUE_SPLIT
|
||||
@@ -718,15 +719,22 @@ def GetBinary(Item, ContainerFile, FileRelativePath, LineNo = -1):
|
||||
else:
|
||||
if List[3] != '':
|
||||
CheckPcdTokenInfo(List[3], 'Binaries', ContainerFile, LineNo)
|
||||
|
||||
return (List[0], List[1], List[2], List[3])
|
||||
|
||||
if len(List) == 4:
|
||||
return (List[0], List[1], List[2], List[3])
|
||||
elif len(List) == 3:
|
||||
return (List[0], List[1], List[2], '')
|
||||
elif len(List) == 2:
|
||||
return (List[0], List[1], '', '')
|
||||
elif len(List) == 1:
|
||||
return (List[0], '', '', '')
|
||||
|
||||
## Get Guids/Protocols/Ppis
|
||||
#
|
||||
# Get Guids/Protocols/Ppis of Inf as <GuidCName>[|<PcdFeatureFlag>]
|
||||
#
|
||||
# @param Item: String as <GuidCName>[|<PcdFeatureFlag>]
|
||||
# @param Type: Type of parsing string
|
||||
# @param Type: Type of parsing string
|
||||
# @param ContainerFile: The file which describes the library class, used for error report
|
||||
#
|
||||
# @retval (List[0], List[1])
|
||||
@@ -736,7 +744,7 @@ def GetGuidsProtocolsPpisOfInf(Item, Type, ContainerFile, LineNo = -1):
|
||||
List = GetSplitValueList(ItemNew)
|
||||
if List[1] != '':
|
||||
CheckPcdTokenInfo(List[1], Type, ContainerFile, LineNo)
|
||||
|
||||
|
||||
return (List[0], List[1])
|
||||
|
||||
## Get Guids/Protocols/Ppis
|
||||
@@ -744,7 +752,7 @@ def GetGuidsProtocolsPpisOfInf(Item, Type, ContainerFile, LineNo = -1):
|
||||
# Get Guids/Protocols/Ppis of Dec as <GuidCName>=<GuidValue>
|
||||
#
|
||||
# @param Item: String as <GuidCName>=<GuidValue>
|
||||
# @param Type: Type of parsing string
|
||||
# @param Type: Type of parsing string
|
||||
# @param ContainerFile: The file which describes the library class, used for error report
|
||||
#
|
||||
# @retval (List[0], List[1])
|
||||
@@ -753,7 +761,7 @@ def GetGuidsProtocolsPpisOfDec(Item, Type, ContainerFile, LineNo = -1):
|
||||
List = GetSplitValueList(Item, DataType.TAB_EQUAL_SPLIT)
|
||||
if len(List) != 2:
|
||||
RaiseParserError(Item, Type, ContainerFile, '<CName>=<GuidValue>', LineNo)
|
||||
|
||||
|
||||
return (List[0], List[1])
|
||||
|
||||
## GetPackage
|
||||
@@ -761,7 +769,7 @@ def GetGuidsProtocolsPpisOfDec(Item, Type, ContainerFile, LineNo = -1):
|
||||
# Get Package of Inf as <PackagePath>[|<PcdFeatureFlag>]
|
||||
#
|
||||
# @param Item: String as <PackagePath>[|<PcdFeatureFlag>]
|
||||
# @param Type: Type of parsing string
|
||||
# @param Type: Type of parsing string
|
||||
# @param ContainerFile: The file which describes the library class, used for error report
|
||||
#
|
||||
# @retval (List[0], List[1])
|
||||
@@ -771,10 +779,10 @@ def GetPackage(Item, ContainerFile, FileRelativePath, LineNo = -1):
|
||||
List = GetSplitValueList(ItemNew)
|
||||
CheckFileType(List[0], '.Dec', ContainerFile, 'package', List[0], LineNo)
|
||||
CheckFileExist(FileRelativePath, List[0], ContainerFile, 'Packages', List[0], LineNo)
|
||||
|
||||
|
||||
if List[1] != '':
|
||||
CheckPcdTokenInfo(List[1], 'Packages', ContainerFile, LineNo)
|
||||
|
||||
|
||||
return (List[0], List[1])
|
||||
|
||||
## Get Pcd Values of Inf
|
||||
@@ -790,15 +798,15 @@ def GetPackage(Item, ContainerFile, FileRelativePath, LineNo = -1):
|
||||
def GetPcdOfInf(Item, Type, File, LineNo):
|
||||
Format = '<TokenSpaceGuidCName>.<PcdCName>[|<Value>]'
|
||||
TokenGuid, TokenName, Value, InfType = '', '', '', ''
|
||||
|
||||
|
||||
if Type == TAB_PCDS_FIXED_AT_BUILD:
|
||||
InfType = TAB_INF_FIXED_PCD
|
||||
elif Type == TAB_PCDS_PATCHABLE_IN_MODULE:
|
||||
InfType = TAB_INF_PATCH_PCD
|
||||
elif Type == TAB_PCDS_FEATURE_FLAG:
|
||||
InfType = TAB_INF_FEATURE_PCD
|
||||
InfType = TAB_INF_FEATURE_PCD
|
||||
elif Type == TAB_PCDS_DYNAMIC_EX:
|
||||
InfType = TAB_INF_PCD_EX
|
||||
InfType = TAB_INF_PCD_EX
|
||||
elif Type == TAB_PCDS_DYNAMIC:
|
||||
InfType = TAB_INF_PCD
|
||||
List = GetSplitValueList(Item + DataType.TAB_VALUE_SPLIT)
|
||||
@@ -815,7 +823,7 @@ def GetPcdOfInf(Item, Type, File, LineNo):
|
||||
|
||||
return (TokenGuid, TokenName, Value, Type)
|
||||
|
||||
|
||||
|
||||
## Get Pcd Values of Dec
|
||||
#
|
||||
# Get Pcd of Dec as <TokenSpcCName>.<TokenCName>|<Value>|<DatumType>|<Token>
|
||||
@@ -837,7 +845,7 @@ def GetPcdOfDec(Item, Type, File, LineNo = -1):
|
||||
else:
|
||||
TokenGuid = TokenInfo[0]
|
||||
TokenName = TokenInfo[1]
|
||||
|
||||
|
||||
return (TokenGuid, TokenName, Value, DatumType, Token, Type)
|
||||
|
||||
## Parse DEFINE statement
|
||||
@@ -854,7 +862,7 @@ def ParseDefine(LineValue, StartLine, Table, FileID, Filename, SectionName, Sect
|
||||
Table.Insert(MODEL_META_DATA_DEFINE, Define[0], Define[1], '', '', '', Arch, SectionModel, FileID, StartLine, -1, StartLine, -1, 0)
|
||||
|
||||
## InsertSectionItems
|
||||
#
|
||||
#
|
||||
# Insert item data of a section to a dict
|
||||
#
|
||||
def InsertSectionItems(Model, CurrentSection, SectionItemList, ArchList, ThirdList, RecordSet):
|
||||
@@ -869,23 +877,23 @@ def InsertSectionItems(Model, CurrentSection, SectionItemList, ArchList, ThirdLi
|
||||
for SectionItem in SectionItemList:
|
||||
BelongsToItem, EndLine, EndColumn = -1, -1, -1
|
||||
LineValue, StartLine, EndLine, Comment = SectionItem[0], SectionItem[1], SectionItem[1], SectionItem[2]
|
||||
|
||||
|
||||
EdkLogger.debug(4, "Parsing %s ..." %LineValue)
|
||||
# And then parse DEFINE statement
|
||||
if LineValue.upper().find(DataType.TAB_DEFINE.upper() + ' ') > -1:
|
||||
continue
|
||||
|
||||
|
||||
# At last parse other sections
|
||||
ID = -1
|
||||
Records.append([LineValue, Arch, StartLine, ID, Third, Comment])
|
||||
|
||||
|
||||
if RecordSet != {}:
|
||||
RecordSet[Model] = Records
|
||||
|
||||
## Insert records to database
|
||||
#
|
||||
#
|
||||
# Insert item data of a section to database
|
||||
# @param Table: The Table to be inserted
|
||||
# @param Table: The Table to be inserted
|
||||
# @param FileID: The ID of belonging file
|
||||
# @param Filename: The name of belonging file
|
||||
# @param CurrentSection: The name of currect section
|
||||
@@ -893,7 +901,7 @@ def InsertSectionItems(Model, CurrentSection, SectionItemList, ArchList, ThirdLi
|
||||
# @param ArchList: A list of arches
|
||||
# @param ThirdList: A list of third parameters, ModuleType for LibraryClass and SkuId for Dynamic Pcds
|
||||
# @param IfDefList: A list of all conditional statements
|
||||
# @param RecordSet: A dict of all parsed records
|
||||
# @param RecordSet: A dict of all parsed records
|
||||
#
|
||||
def InsertSectionItemsIntoDatabase(Table, FileID, Filename, Model, CurrentSection, SectionItemList, ArchList, ThirdList, IfDefList, RecordSet):
|
||||
#
|
||||
@@ -909,7 +917,7 @@ def InsertSectionItemsIntoDatabase(Table, FileID, Filename, Model, CurrentSectio
|
||||
for SectionItem in SectionItemList:
|
||||
BelongsToItem, EndLine, EndColumn = -1, -1, -1
|
||||
LineValue, StartLine, EndLine = SectionItem[0], SectionItem[1], SectionItem[1]
|
||||
|
||||
|
||||
EdkLogger.debug(4, "Parsing %s ..." %LineValue)
|
||||
#
|
||||
# And then parse DEFINE statement
|
||||
@@ -917,13 +925,13 @@ def InsertSectionItemsIntoDatabase(Table, FileID, Filename, Model, CurrentSectio
|
||||
if LineValue.upper().find(DataType.TAB_DEFINE.upper() + ' ') > -1:
|
||||
ParseDefine(LineValue, StartLine, Table, FileID, Filename, CurrentSection, Model, Arch)
|
||||
continue
|
||||
|
||||
|
||||
#
|
||||
# At last parse other sections
|
||||
#
|
||||
ID = Table.Insert(Model, LineValue, Third, Third, '', '', Arch, -1, FileID, StartLine, -1, StartLine, -1, 0)
|
||||
Records.append([LineValue, Arch, StartLine, ID, Third])
|
||||
|
||||
|
||||
if RecordSet != {}:
|
||||
RecordSet[Model] = Records
|
||||
|
||||
@@ -932,4 +940,4 @@ def GenMetaDatSectionItem(Key, Value, List):
|
||||
if Key not in List:
|
||||
List[Key] = [Value]
|
||||
else:
|
||||
List[Key].append(Value)
|
||||
List[Key].append(Value)
|
@@ -0,0 +1,15 @@
|
||||
## @file
|
||||
# Python 'Common' package initialization file.
|
||||
#
|
||||
# This file is required to make Python interpreter treat the directory
|
||||
# as containing package.
|
||||
#
|
||||
# Copyright (c) 2007 - 2010, Intel Corporation<BR>
|
||||
# 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
|
||||
# http://opensource.org/licenses/bsd-license.php
|
||||
#
|
||||
# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
|
||||
#
|
||||
|
@@ -1,7 +1,7 @@
|
||||
## @file
|
||||
# classes represent data in FDF
|
||||
#
|
||||
# Copyright (c) 2007, Intel Corporation
|
||||
# Copyright (c) 2007 - 2010, 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
|
||||
@@ -168,6 +168,7 @@ class DepexSectionClassObject (SectionClassObject):
|
||||
def __init__(self):
|
||||
self.DepexType = None
|
||||
self.Expression = None
|
||||
self.ExpressionProcessed = False
|
||||
|
||||
## Compress section data in FDF
|
||||
#
|
||||
@@ -231,6 +232,7 @@ class FvImageSectionClassObject (SectionClassObject):
|
||||
self.FvFileType = None
|
||||
self.FvFileName = None
|
||||
self.FvFileExtension = None
|
||||
self.FvAddr = None
|
||||
|
||||
## GUIDed section data in FDF
|
||||
#
|
||||
@@ -247,6 +249,9 @@ class GuidSectionClassObject (SectionClassObject) :
|
||||
self.SectionType = None
|
||||
self.ProcessRequired = False
|
||||
self.AuthStatusValid = False
|
||||
self.FvAddr = []
|
||||
self.FvParentAddr = None
|
||||
self.IncludeFvSection = False
|
||||
|
||||
## UI section data in FDF
|
||||
#
|
||||
@@ -290,6 +295,7 @@ class RuleClassObject :
|
||||
self.NameGuid = None
|
||||
self.Fixed = False
|
||||
self.Alignment = None
|
||||
self.SectAlignment = None
|
||||
self.CheckSum = False
|
||||
self.FvFileType = None # for Ffs File Type
|
||||
self.KeyStringList = []
|
||||
@@ -399,4 +405,4 @@ class OptionRomClassObject:
|
||||
def __init__(self):
|
||||
self.DriverName = None
|
||||
self.FfsList = []
|
||||
|
||||
|
||||
|
@@ -1,7 +1,7 @@
|
||||
## @file
|
||||
# This file is used to define a class object to describe a module
|
||||
#
|
||||
# Copyright (c) 2007, Intel Corporation
|
||||
# Copyright (c) 2007 - 2010, 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
|
||||
@@ -34,7 +34,7 @@ from CommonClass import *
|
||||
# PEI_PCD_DRIVER | DXE_PCD_DRIVER
|
||||
# @var TianoR8FlashMap_h: To store value for TianoR8FlashMap_h
|
||||
# @var InfVersion: To store value for InfVersion
|
||||
# @var EfiSpecificationVersion: To store value for EfiSpecificationVersion
|
||||
# @var UefiSpecificationVersion: To store value for UefiSpecificationVersion
|
||||
# @var EdkReleaseVersion: To store value for EdkReleaseVersion
|
||||
# @var LibraryClass: To store value for LibraryClass, it is a set structure as
|
||||
# [ LibraryClassClass, ...]
|
||||
@@ -65,7 +65,6 @@ class ModuleHeaderClass(IdentificationClass, CommonHeaderClass, DefineClass):
|
||||
self.PcdIsDriver = ''
|
||||
self.TianoR8FlashMap_h = False
|
||||
self.InfVersion = ''
|
||||
self.EfiSpecificationVersion = ''
|
||||
self.PiSpecificationVersion = ''
|
||||
self.UefiSpecificationVersion = ''
|
||||
self.EdkReleaseVersion = ''
|
||||
|
@@ -0,0 +1,15 @@
|
||||
## @file
|
||||
# Python 'CommonDataClass' package initialization file.
|
||||
#
|
||||
# This file is required to make Python interpreter treat the directory
|
||||
# as containing package.
|
||||
#
|
||||
# Copyright (c) 2007 - 2010, Intel Corporation<BR>
|
||||
# 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
|
||||
# http://opensource.org/licenses/bsd-license.php
|
||||
#
|
||||
# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
|
||||
#
|
||||
|
@@ -1,3 +1,15 @@
|
||||
/* @file
|
||||
This file is used to be the grammar file of ECC tool
|
||||
|
||||
Copyright (c) 2009 - 2010, 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
|
||||
http://opensource.org/licenses/bsd-license.php
|
||||
|
||||
THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
|
||||
*/
|
||||
|
||||
grammar C;
|
||||
options {
|
||||
@@ -7,9 +19,49 @@ options {
|
||||
k=2;
|
||||
}
|
||||
|
||||
@lexer::header{
|
||||
## @file
|
||||
# The file defines the Lexer for C source files.
|
||||
#
|
||||
# THIS FILE IS AUTO-GENENERATED. PLEASE DON NOT MODIFY THIS FILE.
|
||||
# This file is generated by running:
|
||||
# java org.antlr.Tool C.g
|
||||
#
|
||||
# Copyright (c) 2009 - 2010, 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:
|
||||
# http://opensource.org/licenses/bsd-license.php
|
||||
#
|
||||
# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
|
||||
#
|
||||
##
|
||||
}
|
||||
|
||||
@header {
|
||||
import CodeFragment
|
||||
import FileProfile
|
||||
## @file
|
||||
# The file defines the parser for C source files.
|
||||
#
|
||||
# THIS FILE IS AUTO-GENENERATED. PLEASE DON NOT MODIFY THIS FILE.
|
||||
# This file is generated by running:
|
||||
# java org.antlr.Tool C.g
|
||||
#
|
||||
# Copyright (c) 2009 - 2010, 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:
|
||||
# http://opensource.org/licenses/bsd-license.php
|
||||
#
|
||||
# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
|
||||
#
|
||||
##
|
||||
|
||||
import CodeFragment
|
||||
import FileProfile
|
||||
}
|
||||
|
||||
@members {
|
||||
@@ -238,6 +290,7 @@ type_qualifier
|
||||
| 'EFIAPI'
|
||||
| 'EFI_BOOTSERVICE'
|
||||
| 'EFI_RUNTIMESERVICE'
|
||||
| 'PACKED'
|
||||
;
|
||||
|
||||
declarator
|
||||
|
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@@ -1,7 +1,7 @@
|
||||
## @file
|
||||
# This file is used to define checkpoints used by ECC tool
|
||||
#
|
||||
# Copyright (c) 2008, Intel Corporation
|
||||
# Copyright (c) 2008 - 2010, 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
|
||||
@@ -298,7 +298,11 @@ class Check(object):
|
||||
for Key in RecordDict:
|
||||
if len(RecordDict[Key]) > 1:
|
||||
for Item in RecordDict[Key]:
|
||||
EccGlobalData.gDb.TblReport.Insert(ERROR_INCLUDE_FILE_CHECK_NAME, OtherMsg = "The file name for '%s' is duplicate" % (Item[1]), BelongsToTable = 'File', BelongsToItem = Item[0])
|
||||
Path = Item[1].replace(EccGlobalData.gWorkspace, '')
|
||||
if Path.startswith('\\') or Path.startswith('/'):
|
||||
Path = Path[1:]
|
||||
if not EccGlobalData.gException.IsException(ERROR_INCLUDE_FILE_CHECK_NAME, Path):
|
||||
EccGlobalData.gDb.TblReport.Insert(ERROR_INCLUDE_FILE_CHECK_NAME, OtherMsg = "The file name for [%s] is duplicate" % Path, BelongsToTable = 'File', BelongsToItem = Item[0])
|
||||
|
||||
# Check whether all include file contents is guarded by a #ifndef statement.
|
||||
def IncludeFileCheckIfndef(self):
|
||||
@@ -527,7 +531,7 @@ class Check(object):
|
||||
if EccGlobalData.gConfig.MetaDataFileCheckPcdDuplicate == '1' or EccGlobalData.gConfig.MetaDataFileCheckAll == '1' or EccGlobalData.gConfig.CheckAll == '1':
|
||||
EdkLogger.quiet("Checking for duplicate PCDs defined in both DSC and FDF files ...")
|
||||
SqlCommand = """
|
||||
select A.ID, A.Value2, B.ID, B.Value2 from Dsc as A, Fdf as B
|
||||
select A.ID, A.Value2, A.BelongsToFile, B.ID, B.Value2, B.BelongsToFile from Dsc as A, Fdf as B
|
||||
where A.Model >= %s and A.Model < %s
|
||||
and B.Model >= %s and B.Model < %s
|
||||
and A.Value2 = B.Value2
|
||||
@@ -537,10 +541,17 @@ class Check(object):
|
||||
"""% (MODEL_PCD, MODEL_META_DATA_HEADER, MODEL_PCD, MODEL_META_DATA_HEADER)
|
||||
RecordSet = EccGlobalData.gDb.TblDsc.Exec(SqlCommand)
|
||||
for Record in RecordSet:
|
||||
SqlCommand1 = """select Name from File where ID = %s""" %Record[2]
|
||||
SqlCommand2 = """select Name from File where ID = %s""" %Record[5]
|
||||
DscFileName = os.path.splitext(EccGlobalData.gDb.TblDsc.Exec(SqlCommand1)[0][0])[0]
|
||||
FdfFileName = os.path.splitext(EccGlobalData.gDb.TblDsc.Exec(SqlCommand2)[0][0])[0]
|
||||
print DscFileName, 111, FdfFileName
|
||||
if DscFileName != FdfFileName:
|
||||
continue
|
||||
if not EccGlobalData.gException.IsException(ERROR_META_DATA_FILE_CHECK_PCD_DUPLICATE, Record[1]):
|
||||
EccGlobalData.gDb.TblReport.Insert(ERROR_META_DATA_FILE_CHECK_PCD_DUPLICATE, OtherMsg = "The PCD [%s] is defined in both FDF file and DSC file" % (Record[1]), BelongsToTable = 'Dsc', BelongsToItem = Record[0])
|
||||
if not EccGlobalData.gException.IsException(ERROR_META_DATA_FILE_CHECK_PCD_DUPLICATE, Record[3]):
|
||||
EccGlobalData.gDb.TblReport.Insert(ERROR_META_DATA_FILE_CHECK_PCD_DUPLICATE, OtherMsg = "The PCD [%s] is defined in both FDF file and DSC file" % (Record[3]), BelongsToTable = 'Fdf', BelongsToItem = Record[2])
|
||||
EccGlobalData.gDb.TblReport.Insert(ERROR_META_DATA_FILE_CHECK_PCD_DUPLICATE, OtherMsg = "The PCD [%s] is defined in both FDF file and DSC file" % (Record[4]), BelongsToTable = 'Fdf', BelongsToItem = Record[3])
|
||||
|
||||
EdkLogger.quiet("Checking for duplicate PCDs defined in DEC files ...")
|
||||
SqlCommand = """
|
||||
@@ -664,7 +675,7 @@ class Check(object):
|
||||
for Tbl in TableSet:
|
||||
TblName = 'Identifier' + str(Tbl[0])
|
||||
SqlCommand = """
|
||||
select Name, ID from %s where value like '%%%s%%' and Model = %s
|
||||
select Name, ID from %s where value like '%s' and Model = %s
|
||||
""" % (TblName, PcdName, MODEL_IDENTIFIER_FUNCTION_CALLING)
|
||||
RecordSet = EccGlobalData.gDb.TblInf.Exec(SqlCommand)
|
||||
TblNumber = TblName.replace('Identifier', '')
|
||||
@@ -726,29 +737,35 @@ class Check(object):
|
||||
|
||||
# Naming Convention Check
|
||||
def NamingConventionCheck(self):
|
||||
|
||||
for Dirpath, Dirnames, Filenames in self.WalkTree():
|
||||
for F in Filenames:
|
||||
if os.path.splitext(F)[1] in ('.h', '.c'):
|
||||
FullName = os.path.join(Dirpath, F)
|
||||
Id = c.GetTableID(FullName)
|
||||
if Id < 0:
|
||||
continue
|
||||
FileTable = 'Identifier' + str(Id)
|
||||
self.NamingConventionCheckDefineStatement(FileTable)
|
||||
self.NamingConventionCheckTypedefStatement(FileTable)
|
||||
self.NamingConventionCheckIfndefStatement(FileTable)
|
||||
self.NamingConventionCheckVariableName(FileTable)
|
||||
self.NamingConventionCheckSingleCharacterVariable(FileTable)
|
||||
if EccGlobalData.gConfig.NamingConventionCheckDefineStatement == '1' \
|
||||
or EccGlobalData.gConfig.NamingConventionCheckTypedefStatement == '1' \
|
||||
or EccGlobalData.gConfig.NamingConventionCheckIfndefStatement == '1' \
|
||||
or EccGlobalData.gConfig.NamingConventionCheckVariableName == '1' \
|
||||
or EccGlobalData.gConfig.NamingConventionCheckSingleCharacterVariable == '1' \
|
||||
or EccGlobalData.gConfig.NamingConventionCheckAll == '1'\
|
||||
or EccGlobalData.gConfig.CheckAll == '1':
|
||||
for Dirpath, Dirnames, Filenames in self.WalkTree():
|
||||
for F in Filenames:
|
||||
if os.path.splitext(F)[1] in ('.h', '.c'):
|
||||
FullName = os.path.join(Dirpath, F)
|
||||
Id = c.GetTableID(FullName)
|
||||
if Id < 0:
|
||||
continue
|
||||
FileTable = 'Identifier' + str(Id)
|
||||
self.NamingConventionCheckDefineStatement(FileTable)
|
||||
self.NamingConventionCheckTypedefStatement(FileTable)
|
||||
self.NamingConventionCheckIfndefStatement(FileTable)
|
||||
self.NamingConventionCheckVariableName(FileTable)
|
||||
self.NamingConventionCheckSingleCharacterVariable(FileTable)
|
||||
|
||||
self.NamingConventionCheckPathName()
|
||||
self.NamingConventionCheckFunctionName()
|
||||
|
||||
|
||||
# Check whether only capital letters are used for #define declarations
|
||||
def NamingConventionCheckDefineStatement(self, FileTable):
|
||||
if EccGlobalData.gConfig.NamingConventionCheckDefineStatement == '1' or EccGlobalData.gConfig.NamingConventionCheckAll == '1' or EccGlobalData.gConfig.CheckAll == '1':
|
||||
EdkLogger.quiet("Checking naming covention of #define statement ...")
|
||||
|
||||
|
||||
SqlCommand = """select ID, Value from %s where Model = %s""" %(FileTable, MODEL_IDENTIFIER_MACRO_DEFINE)
|
||||
RecordSet = EccGlobalData.gDb.TblFile.Exec(SqlCommand)
|
||||
for Record in RecordSet:
|
||||
@@ -763,7 +780,7 @@ class Check(object):
|
||||
def NamingConventionCheckTypedefStatement(self, FileTable):
|
||||
if EccGlobalData.gConfig.NamingConventionCheckTypedefStatement == '1' or EccGlobalData.gConfig.NamingConventionCheckAll == '1' or EccGlobalData.gConfig.CheckAll == '1':
|
||||
EdkLogger.quiet("Checking naming covention of #typedef statement ...")
|
||||
|
||||
|
||||
SqlCommand = """select ID, Name from %s where Model = %s""" %(FileTable, MODEL_IDENTIFIER_TYPEDEF)
|
||||
RecordSet = EccGlobalData.gDb.TblFile.Exec(SqlCommand)
|
||||
for Record in RecordSet:
|
||||
@@ -783,7 +800,7 @@ class Check(object):
|
||||
def NamingConventionCheckIfndefStatement(self, FileTable):
|
||||
if EccGlobalData.gConfig.NamingConventionCheckTypedefStatement == '1' or EccGlobalData.gConfig.NamingConventionCheckAll == '1' or EccGlobalData.gConfig.CheckAll == '1':
|
||||
EdkLogger.quiet("Checking naming covention of #ifndef statement ...")
|
||||
|
||||
|
||||
SqlCommand = """select ID, Value from %s where Model = %s""" %(FileTable, MODEL_IDENTIFIER_MACRO_IFNDEF)
|
||||
RecordSet = EccGlobalData.gDb.TblFile.Exec(SqlCommand)
|
||||
for Record in RecordSet:
|
||||
@@ -818,7 +835,7 @@ class Check(object):
|
||||
if EccGlobalData.gConfig.NamingConventionCheckVariableName == '1' or EccGlobalData.gConfig.NamingConventionCheckAll == '1' or EccGlobalData.gConfig.CheckAll == '1':
|
||||
EdkLogger.quiet("Checking naming covention of variable name ...")
|
||||
Pattern = re.compile(r'^[A-Zgm]+\S*[a-z]\S*$')
|
||||
|
||||
|
||||
SqlCommand = """select ID, Name from %s where Model = %s""" %(FileTable, MODEL_IDENTIFIER_VARIABLE)
|
||||
RecordSet = EccGlobalData.gDb.TblFile.Exec(SqlCommand)
|
||||
for Record in RecordSet:
|
||||
@@ -846,7 +863,7 @@ class Check(object):
|
||||
def NamingConventionCheckSingleCharacterVariable(self, FileTable):
|
||||
if EccGlobalData.gConfig.NamingConventionCheckSingleCharacterVariable == '1' or EccGlobalData.gConfig.NamingConventionCheckAll == '1' or EccGlobalData.gConfig.CheckAll == '1':
|
||||
EdkLogger.quiet("Checking naming covention of single character variable name ...")
|
||||
|
||||
|
||||
SqlCommand = """select ID, Name from %s where Model = %s""" %(FileTable, MODEL_IDENTIFIER_VARIABLE)
|
||||
RecordSet = EccGlobalData.gDb.TblFile.Exec(SqlCommand)
|
||||
for Record in RecordSet:
|
||||
|
@@ -1,7 +1,7 @@
|
||||
## @file
|
||||
# This file is used to be the main entrance of ECC tool
|
||||
#
|
||||
# Copyright (c) 2009, Intel Corporation
|
||||
# Copyright (c) 2009 - 2010, 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
|
||||
@@ -43,7 +43,7 @@ class Ecc(object):
|
||||
# Version and Copyright
|
||||
self.VersionNumber = "0.01"
|
||||
self.Version = "%prog Version " + self.VersionNumber
|
||||
self.Copyright = "Copyright (c) 2009, Intel Corporation All rights reserved."
|
||||
self.Copyright = "Copyright (c) 2009 - 2010, Intel Corporation All rights reserved."
|
||||
|
||||
self.InitDefaultConfigIni()
|
||||
self.OutputFile = 'output.txt'
|
||||
@@ -225,6 +225,9 @@ class Ecc(object):
|
||||
EdkLogger.quiet("Loading ECC configuration ... done")
|
||||
(Options, Target) = self.EccOptionParser()
|
||||
|
||||
if Options.Workspace:
|
||||
os.environ["WORKSPACE"] = Options.Workspace
|
||||
|
||||
# Check workspace envirnoment
|
||||
if "WORKSPACE" not in os.environ:
|
||||
EdkLogger.error("ECC", BuildToolError.ATTRIBUTE_NOT_AVAILABLE, "Environment variable not found",
|
||||
@@ -244,6 +247,8 @@ class Ecc(object):
|
||||
self.OutputFile = Options.OutputFile
|
||||
if Options.ReportFile != None:
|
||||
self.ReportFile = Options.ReportFile
|
||||
if Options.ExceptionFile != None:
|
||||
self.ExceptionFile = Options.ExceptionFile
|
||||
if Options.Target != None:
|
||||
if not os.path.isdir(Options.Target):
|
||||
EdkLogger.error("ECC", BuildToolError.OPTION_VALUE_INVALID, ExtraData="Target [%s] does NOT exist" % Options.Target)
|
||||
@@ -294,6 +299,8 @@ class Ecc(object):
|
||||
help="Specify the name of an output file, if and only if one filename was specified.")
|
||||
Parser.add_option("-r", "--reportfile filename", action="store", type="string", dest="ReportFile",
|
||||
help="Specify the name of an report file, if and only if one filename was specified.")
|
||||
Parser.add_option("-e", "--exceptionfile filename", action="store", type="string", dest="ExceptionFile",
|
||||
help="Specify the name of an exception file, if and only if one filename was specified.")
|
||||
Parser.add_option("-m", "--metadata", action="store_true", type=None, help="Only scan meta-data files information if this option is specified.")
|
||||
Parser.add_option("-s", "--sourcecode", action="store_true", type=None, help="Only scan source code files information if this option is specified.")
|
||||
Parser.add_option("-k", "--keepdatabase", action="store_true", type=None, help="The existing Ecc database will not be cleaned except report information if this option is specified.")
|
||||
@@ -307,6 +314,7 @@ class Ecc(object):
|
||||
"including library instances selected, final dependency expression, "\
|
||||
"and warning messages, etc.")
|
||||
Parser.add_option("-d", "--debug", action="store", type="int", help="Enable debug messages at specified level.")
|
||||
Parser.add_option("-w", "--workspace", action="store", type="string", dest='Workspace', help="Specify workspace.")
|
||||
|
||||
(Opt, Args)=Parser.parse_args()
|
||||
|
||||
|
@@ -1,7 +1,7 @@
|
||||
## @file
|
||||
# Standardized Error Hanlding infrastructures.
|
||||
#
|
||||
# Copyright (c) 20087, Intel Corporation
|
||||
# Copyright (c) 2008 - 2010, 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
|
||||
@@ -40,6 +40,8 @@ ERROR_C_FUNCTION_LAYOUT_CHECK_FUNCTION_BODY = 5005
|
||||
ERROR_C_FUNCTION_LAYOUT_CHECK_DATA_DECLARATION = 5006
|
||||
ERROR_C_FUNCTION_LAYOUT_CHECK_NO_INIT_OF_VARIABLE = 5007
|
||||
ERROR_C_FUNCTION_LAYOUT_CHECK_NO_STATIC = 5008
|
||||
ERROR_C_FUNCTION_LAYOUT_CHECK_FUNCTION_PROTO_TYPE_2 = 5009
|
||||
ERROR_C_FUNCTION_LAYOUT_CHECK_FUNCTION_PROTO_TYPE_3 = 5010
|
||||
|
||||
ERROR_INCLUDE_FILE_CHECK_ALL = 6000
|
||||
ERROR_INCLUDE_FILE_CHECK_IFNDEF_STATEMENT_1 = 6001
|
||||
@@ -102,35 +104,37 @@ gEccErrorMessage = {
|
||||
ERROR_GENERAL_CHECK_NO_PROGMA : """There should be no use of "#progma" in source file except "#pragma pack(#)\"""",
|
||||
ERROR_GENERAL_CHECK_CARRIAGE_RETURN : "There should be a carriage return at the end of the file",
|
||||
ERROR_GENERAL_CHECK_FILE_EXISTENCE : "File not found",
|
||||
|
||||
|
||||
ERROR_SPACE_CHECK_ALL : "",
|
||||
|
||||
|
||||
ERROR_PREDICATE_EXPRESSION_CHECK_ALL : "",
|
||||
ERROR_PREDICATE_EXPRESSION_CHECK_BOOLEAN_VALUE : "Boolean values and variable type BOOLEAN should not use explicit comparisons to TRUE or FALSE",
|
||||
ERROR_PREDICATE_EXPRESSION_CHECK_NO_BOOLEAN_OPERATOR : "Non-Boolean comparisons should use a compare operator (==, !=, >, < >=, <=)",
|
||||
ERROR_PREDICATE_EXPRESSION_CHECK_COMPARISON_NULL_TYPE : "A comparison of any pointer to zero must be done via the NULL type",
|
||||
|
||||
|
||||
ERROR_HEADER_CHECK_ALL : "",
|
||||
ERROR_HEADER_CHECK_FILE : "File header doesn't exist",
|
||||
ERROR_HEADER_CHECK_FUNCTION : "Function header doesn't exist",
|
||||
|
||||
|
||||
ERROR_C_FUNCTION_LAYOUT_CHECK_ALL : "",
|
||||
ERROR_C_FUNCTION_LAYOUT_CHECK_RETURN_TYPE : "Return type of a function should exist and in the first line",
|
||||
ERROR_C_FUNCTION_LAYOUT_CHECK_OPTIONAL_FUNCTIONAL_MODIFIER : "Any optional functional modifiers should exist and next to the return type",
|
||||
ERROR_C_FUNCTION_LAYOUT_CHECK_FUNCTION_NAME : """Function name should be left justified, followed by the beginning of the parameter list, with the closing parenthesis on its own line, indented two spaces""",
|
||||
ERROR_C_FUNCTION_LAYOUT_CHECK_FUNCTION_PROTO_TYPE : "Function prototypes in include files have the same form as function definitions",
|
||||
ERROR_C_FUNCTION_LAYOUT_CHECK_FUNCTION_PROTO_TYPE_2 : "Function prototypes in include files have different parameter number with function definitions",
|
||||
ERROR_C_FUNCTION_LAYOUT_CHECK_FUNCTION_PROTO_TYPE_3 : "Function prototypes in include files have different parameter modifier with function definitions",
|
||||
ERROR_C_FUNCTION_LAYOUT_CHECK_FUNCTION_BODY : "The body of a function should be contained by open and close braces that must be in the first column",
|
||||
ERROR_C_FUNCTION_LAYOUT_CHECK_DATA_DECLARATION : "The data declarations should be the first code in a module",
|
||||
ERROR_C_FUNCTION_LAYOUT_CHECK_NO_INIT_OF_VARIABLE : "There should be no initialization of a variable as part of its declaration",
|
||||
ERROR_C_FUNCTION_LAYOUT_CHECK_NO_STATIC : "There should be no use of STATIC for functions",
|
||||
|
||||
|
||||
ERROR_INCLUDE_FILE_CHECK_ALL : "",
|
||||
ERROR_INCLUDE_FILE_CHECK_IFNDEF_STATEMENT_1 : "All include file contents should be guarded by a #ifndef statement.",
|
||||
ERROR_INCLUDE_FILE_CHECK_IFNDEF_STATEMENT_2 : "The #ifndef must be the first line of code following the file header comment",
|
||||
ERROR_INCLUDE_FILE_CHECK_IFNDEF_STATEMENT_3 : "The #endif must appear on the last line in the file",
|
||||
ERROR_INCLUDE_FILE_CHECK_DATA : "Include files should contain only public or only private data and cannot contain code or define data variables",
|
||||
ERROR_INCLUDE_FILE_CHECK_NAME : "No permission for the inlcude file with same names",
|
||||
|
||||
|
||||
ERROR_DECLARATION_DATA_TYPE_CHECK_ALL : "",
|
||||
ERROR_DECLARATION_DATA_TYPE_CHECK_NO_USE_C_TYPE : "There should be no use of int, unsigned, char, void, static, long in any .c, .h or .asl files",
|
||||
ERROR_DECLARATION_DATA_TYPE_CHECK_IN_OUT_MODIFIER : """The modifiers IN, OUT, OPTIONAL, and UNALIGNED should be used only to qualify arguments to a function and should not appear in a data type declaration""",
|
||||
@@ -140,7 +144,7 @@ gEccErrorMessage = {
|
||||
ERROR_DECLARATION_DATA_TYPE_CHECK_SAME_STRUCTURE : "No permission for the structure with same names",
|
||||
ERROR_DECLARATION_DATA_TYPE_CHECK_UNION_TYPE : "Union Type should have a 'typedef' and the name must be in capital letters",
|
||||
ERROR_DECLARATION_DATA_TYPE_CHECK_NESTED_STRUCTURE : "Complex types should be typedef-ed",
|
||||
|
||||
|
||||
ERROR_NAMING_CONVENTION_CHECK_ALL : "",
|
||||
ERROR_NAMING_CONVENTION_CHECK_DEFINE_STATEMENT : "Only capital letters are allowed to be used for #define declarations",
|
||||
ERROR_NAMING_CONVENTION_CHECK_TYPEDEF_STATEMENT : "Only capital letters are allowed to be used for typedef declarations",
|
||||
@@ -149,17 +153,17 @@ gEccErrorMessage = {
|
||||
ERROR_NAMING_CONVENTION_CHECK_VARIABLE_NAME : """Variable name does not follow the rules: 1. First character should be upper case 2. Must contain lower case characters 3. No white space characters 4. Global variable name must start with a 'g'""",
|
||||
ERROR_NAMING_CONVENTION_CHECK_FUNCTION_NAME : """Function name does not follow the rules: 1. First character should be upper case 2. Must contain lower case characters 3. No white space characters""",
|
||||
ERROR_NAMING_CONVENTION_CHECK_SINGLE_CHARACTER_VARIABLE : "There should be no use of short (single character) variable names",
|
||||
|
||||
|
||||
ERROR_DOXYGEN_CHECK_ALL : "",
|
||||
ERROR_DOXYGEN_CHECK_FILE_HEADER : "The file headers should follow Doxygen special documentation blocks in section 2.3.5",
|
||||
ERROR_DOXYGEN_CHECK_FUNCTION_HEADER : "The function headers should follow Doxygen special documentation blocks in section 2.3.5",
|
||||
ERROR_DOXYGEN_CHECK_COMMENT_DESCRIPTION : """The first line of text in a comment block should be a brief description of the element being documented and the brief description must end with a period.""",
|
||||
ERROR_DOXYGEN_CHECK_COMMENT_FORMAT : "For comment line with '///< ... text ...' format, if it is used, it should be after the code section",
|
||||
ERROR_DOXYGEN_CHECK_COMMAND : "Only Doxygen commands @bug and @todo are allowed to mark the code",
|
||||
|
||||
ERROR_DOXYGEN_CHECK_COMMAND : "Only Doxygen commands '@bug', '@todo', '@example', '@file', '@attention', '@param', '@post', '@pre', '@retval', '@return', '@sa', '@since', '@test', '@note', '@par' are allowed to mark the code",
|
||||
|
||||
ERROR_META_DATA_FILE_CHECK_ALL : "",
|
||||
ERROR_META_DATA_FILE_CHECK_PATH_NAME : "The file defined in meta-data does not exist",
|
||||
ERROR_META_DATA_FILE_CHECK_LIBRARY_INSTANCE_1 : "A library instances defined for a given module (or dependent library instance) doesn't match the module's type.",
|
||||
ERROR_META_DATA_FILE_CHECK_LIBRARY_INSTANCE_1 : "A library instances defined for a given module (or dependent library instance) doesn't match the module's type.",
|
||||
ERROR_META_DATA_FILE_CHECK_LIBRARY_INSTANCE_2 : "A library instance must specify the Supported Module Types in its INF file",
|
||||
ERROR_META_DATA_FILE_CHECK_LIBRARY_INSTANCE_DEPENDENT : "A library instance must be defined for all dependent library classes",
|
||||
ERROR_META_DATA_FILE_CHECK_LIBRARY_INSTANCE_ORDER : "The library Instances specified by the LibraryClasses sections should be listed in order of dependencies",
|
||||
@@ -171,9 +175,9 @@ gEccErrorMessage = {
|
||||
ERROR_META_DATA_FILE_CHECK_DUPLICATE_GUID : "Duplicate GUID found",
|
||||
ERROR_META_DATA_FILE_CHECK_DUPLICATE_PROTOCOL : "Duplicate PROTOCOL found",
|
||||
ERROR_META_DATA_FILE_CHECK_DUPLICATE_PPI : "Duplicate PPI found",
|
||||
ERROR_META_DATA_FILE_CHECK_MODULE_FILE_NO_USE : "No used module files found",
|
||||
ERROR_META_DATA_FILE_CHECK_MODULE_FILE_NO_USE : "No used module files found",
|
||||
ERROR_META_DATA_FILE_CHECK_PCD_TYPE : "Wrong C code function used for this kind of PCD",
|
||||
|
||||
|
||||
ERROR_SPELLING_CHECK_ALL : "",
|
||||
}
|
||||
|
||||
|
@@ -1,3 +1,16 @@
|
||||
## @file
|
||||
# This file is used to be the warning class of ECC tool
|
||||
#
|
||||
# Copyright (c) 2009 - 2010, 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
|
||||
# http://opensource.org/licenses/bsd-license.php
|
||||
#
|
||||
# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
|
||||
#
|
||||
|
||||
## The exception class that used to report error messages when preprocessing
|
||||
#
|
||||
# Currently the "ToolName" is set to be "ECC PP".
|
||||
|
@@ -0,0 +1,15 @@
|
||||
## @file
|
||||
# Python 'Ecc' package initialization file.
|
||||
#
|
||||
# This file is required to make Python interpreter treat the directory
|
||||
# as containing package.
|
||||
#
|
||||
# Copyright (c) 2007 - 2010, Intel Corporation<BR>
|
||||
# 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
|
||||
# http://opensource.org/licenses/bsd-license.php
|
||||
#
|
||||
# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
|
||||
#
|
||||
|
File diff suppressed because it is too large
Load Diff
@@ -1,4 +1,14 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<ExceptionList xmlns="http://www.uefi.org/2008/2.1" xmlns:xsi="http:/www.w3.org/2001/XMLSchema-instance">
|
||||
<Copyright>Copyright (c) 2009 - 2010, Intel Corporation.</Copyright>
|
||||
<License>
|
||||
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 http://opensource.org/licenses/bsd-license.php
|
||||
THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, WITHOUT WARRANTIES
|
||||
OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
|
||||
</License>
|
||||
<Exception>
|
||||
<KeyWord>__debugbreak</KeyWord>
|
||||
<ErrorID>4002</ErrorID>
|
||||
|
4947
BaseTools/Source/Python/Eot/CLexer.py
Normal file
4947
BaseTools/Source/Python/Eot/CLexer.py
Normal file
File diff suppressed because it is too large
Load Diff
18844
BaseTools/Source/Python/Eot/CParser.py
Normal file
18844
BaseTools/Source/Python/Eot/CParser.py
Normal file
File diff suppressed because it is too large
Load Diff
185
BaseTools/Source/Python/Eot/CodeFragment.py
Normal file
185
BaseTools/Source/Python/Eot/CodeFragment.py
Normal file
@@ -0,0 +1,185 @@
|
||||
## @file
|
||||
# fragments of source file
|
||||
#
|
||||
# Copyright (c) 2007 ~ 2010, 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
|
||||
# http://opensource.org/licenses/bsd-license.php
|
||||
#
|
||||
# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
|
||||
#
|
||||
|
||||
|
||||
## The description of comment contents and start & end position
|
||||
#
|
||||
#
|
||||
class Comment :
|
||||
## The constructor
|
||||
#
|
||||
# @param self The object pointer
|
||||
# @param Str The message to record
|
||||
# @param Begin The start position tuple.
|
||||
# @param End The end position tuple.
|
||||
# @param CommentType The type of comment (T_COMMENT_TWO_SLASH or T_COMMENT_SLASH_STAR).
|
||||
#
|
||||
def __init__(self, Str, Begin, End, CommentType):
|
||||
self.Content = Str
|
||||
self.StartPos = Begin
|
||||
self.EndPos = End
|
||||
self.Type = CommentType
|
||||
|
||||
## The description of preprocess directives and start & end position
|
||||
#
|
||||
#
|
||||
class PP_Directive :
|
||||
## The constructor
|
||||
#
|
||||
# @param self The object pointer
|
||||
# @param Str The message to record
|
||||
# @param Begin The start position tuple.
|
||||
# @param End The end position tuple.
|
||||
#
|
||||
def __init__(self, Str, Begin, End):
|
||||
self.Content = Str
|
||||
self.StartPos = Begin
|
||||
self.EndPos = End
|
||||
|
||||
## The description of assignment expression and start & end position
|
||||
#
|
||||
#
|
||||
class AssignmentExpression :
|
||||
## The constructor
|
||||
#
|
||||
# @param self The object pointer
|
||||
# @param Str The message to record
|
||||
# @param Begin The start position tuple.
|
||||
# @param End The end position tuple.
|
||||
#
|
||||
def __init__(self, Lvalue, Op, Exp, Begin, End):
|
||||
self.Name = Lvalue
|
||||
self.Operator = Op
|
||||
self.Value = Exp
|
||||
self.StartPos = Begin
|
||||
self.EndPos = End
|
||||
|
||||
## The description of predicate expression and start & end position
|
||||
#
|
||||
#
|
||||
class PredicateExpression :
|
||||
## The constructor
|
||||
#
|
||||
# @param self The object pointer
|
||||
# @param Str The message to record
|
||||
# @param Begin The start position tuple.
|
||||
# @param End The end position tuple.
|
||||
#
|
||||
def __init__(self, Str, Begin, End):
|
||||
self.Content = Str
|
||||
self.StartPos = Begin
|
||||
self.EndPos = End
|
||||
|
||||
## The description of function definition and start & end position
|
||||
#
|
||||
#
|
||||
class FunctionDefinition :
|
||||
## The constructor
|
||||
#
|
||||
# @param self The object pointer
|
||||
# @param Str The message to record
|
||||
# @param Begin The start position tuple.
|
||||
# @param End The end position tuple.
|
||||
# @param LBPos The left brace position tuple.
|
||||
#
|
||||
def __init__(self, ModifierStr, DeclStr, Begin, End, LBPos, NamePos):
|
||||
self.Modifier = ModifierStr
|
||||
self.Declarator = DeclStr
|
||||
self.StartPos = Begin
|
||||
self.EndPos = End
|
||||
self.LeftBracePos = LBPos
|
||||
self.NamePos = NamePos
|
||||
|
||||
## The description of variable declaration and start & end position
|
||||
#
|
||||
#
|
||||
class VariableDeclaration :
|
||||
## The constructor
|
||||
#
|
||||
# @param self The object pointer
|
||||
# @param Str The message to record
|
||||
# @param Begin The start position tuple.
|
||||
# @param End The end position tuple.
|
||||
#
|
||||
def __init__(self, ModifierStr, DeclStr, Begin, End):
|
||||
self.Modifier = ModifierStr
|
||||
self.Declarator = DeclStr
|
||||
self.StartPos = Begin
|
||||
self.EndPos = End
|
||||
|
||||
## The description of enum definition and start & end position
|
||||
#
|
||||
#
|
||||
class EnumerationDefinition :
|
||||
## The constructor
|
||||
#
|
||||
# @param self The object pointer
|
||||
# @param Str The message to record
|
||||
# @param Begin The start position tuple.
|
||||
# @param End The end position tuple.
|
||||
#
|
||||
def __init__(self, Str, Begin, End):
|
||||
self.Content = Str
|
||||
self.StartPos = Begin
|
||||
self.EndPos = End
|
||||
|
||||
## The description of struct/union definition and start & end position
|
||||
#
|
||||
#
|
||||
class StructUnionDefinition :
|
||||
## The constructor
|
||||
#
|
||||
# @param self The object pointer
|
||||
# @param Str The message to record
|
||||
# @param Begin The start position tuple.
|
||||
# @param End The end position tuple.
|
||||
#
|
||||
def __init__(self, Str, Begin, End):
|
||||
self.Content = Str
|
||||
self.StartPos = Begin
|
||||
self.EndPos = End
|
||||
|
||||
## The description of 'Typedef' definition and start & end position
|
||||
#
|
||||
#
|
||||
class TypedefDefinition :
|
||||
## The constructor
|
||||
#
|
||||
# @param self The object pointer
|
||||
# @param Str The message to record
|
||||
# @param Begin The start position tuple.
|
||||
# @param End The end position tuple.
|
||||
#
|
||||
def __init__(self, FromStr, ToStr, Begin, End):
|
||||
self.FromType = FromStr
|
||||
self.ToType = ToStr
|
||||
self.StartPos = Begin
|
||||
self.EndPos = End
|
||||
|
||||
## The description of function calling definition and start & end position
|
||||
#
|
||||
#
|
||||
class FunctionCalling:
|
||||
## The constructor
|
||||
#
|
||||
# @param self The object pointer
|
||||
# @param Str The message to record
|
||||
# @param Begin The start position tuple.
|
||||
# @param End The end position tuple.
|
||||
#
|
||||
def __init__(self, Name, Param, Begin, End):
|
||||
self.FuncName = Name
|
||||
self.ParamList = Param
|
||||
self.StartPos = Begin
|
||||
self.EndPos = End
|
467
BaseTools/Source/Python/Eot/CodeFragmentCollector.py
Normal file
467
BaseTools/Source/Python/Eot/CodeFragmentCollector.py
Normal file
@@ -0,0 +1,467 @@
|
||||
## @file
|
||||
# preprocess source file
|
||||
#
|
||||
# Copyright (c) 2007 ~ 2010, 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
|
||||
# http://opensource.org/licenses/bsd-license.php
|
||||
#
|
||||
# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
|
||||
#
|
||||
|
||||
##
|
||||
# Import Modules
|
||||
#
|
||||
import re
|
||||
import os
|
||||
import sys
|
||||
|
||||
import antlr3
|
||||
from CLexer import CLexer
|
||||
from CParser import CParser
|
||||
|
||||
import FileProfile
|
||||
from CodeFragment import PP_Directive
|
||||
from ParserWarning import Warning
|
||||
|
||||
|
||||
##define T_CHAR_SPACE ' '
|
||||
##define T_CHAR_NULL '\0'
|
||||
##define T_CHAR_CR '\r'
|
||||
##define T_CHAR_TAB '\t'
|
||||
##define T_CHAR_LF '\n'
|
||||
##define T_CHAR_SLASH '/'
|
||||
##define T_CHAR_BACKSLASH '\\'
|
||||
##define T_CHAR_DOUBLE_QUOTE '\"'
|
||||
##define T_CHAR_SINGLE_QUOTE '\''
|
||||
##define T_CHAR_STAR '*'
|
||||
##define T_CHAR_HASH '#'
|
||||
|
||||
(T_CHAR_SPACE, T_CHAR_NULL, T_CHAR_CR, T_CHAR_TAB, T_CHAR_LF, T_CHAR_SLASH, \
|
||||
T_CHAR_BACKSLASH, T_CHAR_DOUBLE_QUOTE, T_CHAR_SINGLE_QUOTE, T_CHAR_STAR, T_CHAR_HASH) = \
|
||||
(' ', '\0', '\r', '\t', '\n', '/', '\\', '\"', '\'', '*', '#')
|
||||
|
||||
SEPERATOR_TUPLE = ('=', '|', ',', '{', '}')
|
||||
|
||||
(T_COMMENT_TWO_SLASH, T_COMMENT_SLASH_STAR) = (0, 1)
|
||||
|
||||
(T_PP_INCLUDE, T_PP_DEFINE, T_PP_OTHERS) = (0, 1, 2)
|
||||
|
||||
## The collector for source code fragments.
|
||||
#
|
||||
# PreprocessFile method should be called prior to ParseFile
|
||||
#
|
||||
# GetNext*** procedures mean these procedures will get next token first, then make judgement.
|
||||
# Get*** procedures mean these procedures will make judgement on current token only.
|
||||
#
|
||||
class CodeFragmentCollector:
|
||||
## The constructor
|
||||
#
|
||||
# @param self The object pointer
|
||||
# @param FileName The file that to be parsed
|
||||
#
|
||||
def __init__(self, FileName):
|
||||
self.Profile = FileProfile.FileProfile(FileName)
|
||||
self.Profile.FileLinesList.append(T_CHAR_LF)
|
||||
self.FileName = FileName
|
||||
self.CurrentLineNumber = 1
|
||||
self.CurrentOffsetWithinLine = 0
|
||||
|
||||
self.__Token = ""
|
||||
self.__SkippedChars = ""
|
||||
|
||||
## __IsWhiteSpace() method
|
||||
#
|
||||
# Whether char at current FileBufferPos is whitespace
|
||||
#
|
||||
# @param self The object pointer
|
||||
# @param Char The char to test
|
||||
# @retval True The char is a kind of white space
|
||||
# @retval False The char is NOT a kind of white space
|
||||
#
|
||||
def __IsWhiteSpace(self, Char):
|
||||
if Char in (T_CHAR_NULL, T_CHAR_CR, T_CHAR_SPACE, T_CHAR_TAB, T_CHAR_LF):
|
||||
return True
|
||||
else:
|
||||
return False
|
||||
|
||||
## __SkipWhiteSpace() method
|
||||
#
|
||||
# Skip white spaces from current char, return number of chars skipped
|
||||
#
|
||||
# @param self The object pointer
|
||||
# @retval Count The number of chars skipped
|
||||
#
|
||||
def __SkipWhiteSpace(self):
|
||||
Count = 0
|
||||
while not self.__EndOfFile():
|
||||
Count += 1
|
||||
if self.__CurrentChar() in (T_CHAR_NULL, T_CHAR_CR, T_CHAR_LF, T_CHAR_SPACE, T_CHAR_TAB):
|
||||
self.__SkippedChars += str(self.__CurrentChar())
|
||||
self.__GetOneChar()
|
||||
|
||||
else:
|
||||
Count = Count - 1
|
||||
return Count
|
||||
|
||||
## __EndOfFile() method
|
||||
#
|
||||
# Judge current buffer pos is at file end
|
||||
#
|
||||
# @param self The object pointer
|
||||
# @retval True Current File buffer position is at file end
|
||||
# @retval False Current File buffer position is NOT at file end
|
||||
#
|
||||
def __EndOfFile(self):
|
||||
NumberOfLines = len(self.Profile.FileLinesList)
|
||||
SizeOfLastLine = len(self.Profile.FileLinesList[-1])
|
||||
if self.CurrentLineNumber == NumberOfLines and self.CurrentOffsetWithinLine >= SizeOfLastLine - 1:
|
||||
return True
|
||||
elif self.CurrentLineNumber > NumberOfLines:
|
||||
return True
|
||||
else:
|
||||
return False
|
||||
|
||||
## __EndOfLine() method
|
||||
#
|
||||
# Judge current buffer pos is at line end
|
||||
#
|
||||
# @param self The object pointer
|
||||
# @retval True Current File buffer position is at line end
|
||||
# @retval False Current File buffer position is NOT at line end
|
||||
#
|
||||
def __EndOfLine(self):
|
||||
SizeOfCurrentLine = len(self.Profile.FileLinesList[self.CurrentLineNumber - 1])
|
||||
if self.CurrentOffsetWithinLine >= SizeOfCurrentLine - 1:
|
||||
return True
|
||||
else:
|
||||
return False
|
||||
|
||||
## Rewind() method
|
||||
#
|
||||
# Reset file data buffer to the initial state
|
||||
#
|
||||
# @param self The object pointer
|
||||
#
|
||||
def Rewind(self):
|
||||
self.CurrentLineNumber = 1
|
||||
self.CurrentOffsetWithinLine = 0
|
||||
|
||||
## __UndoOneChar() method
|
||||
#
|
||||
# Go back one char in the file buffer
|
||||
#
|
||||
# @param self The object pointer
|
||||
# @retval True Successfully go back one char
|
||||
# @retval False Not able to go back one char as file beginning reached
|
||||
#
|
||||
def __UndoOneChar(self):
|
||||
|
||||
if self.CurrentLineNumber == 1 and self.CurrentOffsetWithinLine == 0:
|
||||
return False
|
||||
elif self.CurrentOffsetWithinLine == 0:
|
||||
self.CurrentLineNumber -= 1
|
||||
self.CurrentOffsetWithinLine = len(self.__CurrentLine()) - 1
|
||||
else:
|
||||
self.CurrentOffsetWithinLine -= 1
|
||||
return True
|
||||
|
||||
## __GetOneChar() method
|
||||
#
|
||||
# Move forward one char in the file buffer
|
||||
#
|
||||
# @param self The object pointer
|
||||
#
|
||||
def __GetOneChar(self):
|
||||
if self.CurrentOffsetWithinLine == len(self.Profile.FileLinesList[self.CurrentLineNumber - 1]) - 1:
|
||||
self.CurrentLineNumber += 1
|
||||
self.CurrentOffsetWithinLine = 0
|
||||
else:
|
||||
self.CurrentOffsetWithinLine += 1
|
||||
|
||||
## __CurrentChar() method
|
||||
#
|
||||
# Get the char pointed to by the file buffer pointer
|
||||
#
|
||||
# @param self The object pointer
|
||||
# @retval Char Current char
|
||||
#
|
||||
def __CurrentChar(self):
|
||||
CurrentChar = self.Profile.FileLinesList[self.CurrentLineNumber - 1][self.CurrentOffsetWithinLine]
|
||||
|
||||
return CurrentChar
|
||||
|
||||
## __NextChar() method
|
||||
#
|
||||
# Get the one char pass the char pointed to by the file buffer pointer
|
||||
#
|
||||
# @param self The object pointer
|
||||
# @retval Char Next char
|
||||
#
|
||||
def __NextChar(self):
|
||||
if self.CurrentOffsetWithinLine == len(self.Profile.FileLinesList[self.CurrentLineNumber - 1]) - 1:
|
||||
return self.Profile.FileLinesList[self.CurrentLineNumber][0]
|
||||
else:
|
||||
return self.Profile.FileLinesList[self.CurrentLineNumber - 1][self.CurrentOffsetWithinLine + 1]
|
||||
|
||||
## __SetCurrentCharValue() method
|
||||
#
|
||||
# Modify the value of current char
|
||||
#
|
||||
# @param self The object pointer
|
||||
# @param Value The new value of current char
|
||||
#
|
||||
def __SetCurrentCharValue(self, Value):
|
||||
self.Profile.FileLinesList[self.CurrentLineNumber - 1][self.CurrentOffsetWithinLine] = Value
|
||||
|
||||
## __SetCharValue() method
|
||||
#
|
||||
# Modify the value of current char
|
||||
#
|
||||
# @param self The object pointer
|
||||
# @param Value The new value of current char
|
||||
#
|
||||
def __SetCharValue(self, Line, Offset, Value):
|
||||
self.Profile.FileLinesList[Line - 1][Offset] = Value
|
||||
|
||||
## __CurrentLine() method
|
||||
#
|
||||
# Get the list that contains current line contents
|
||||
#
|
||||
# @param self The object pointer
|
||||
# @retval List current line contents
|
||||
#
|
||||
def __CurrentLine(self):
|
||||
return self.Profile.FileLinesList[self.CurrentLineNumber - 1]
|
||||
|
||||
## __InsertComma() method
|
||||
#
|
||||
# Insert ',' to replace PP
|
||||
#
|
||||
# @param self The object pointer
|
||||
# @retval List current line contents
|
||||
#
|
||||
def __InsertComma(self, Line):
|
||||
|
||||
|
||||
if self.Profile.FileLinesList[Line - 1][0] != T_CHAR_HASH:
|
||||
BeforeHashPart = str(self.Profile.FileLinesList[Line - 1]).split(T_CHAR_HASH)[0]
|
||||
if BeforeHashPart.rstrip().endswith(T_CHAR_COMMA) or BeforeHashPart.rstrip().endswith(';'):
|
||||
return
|
||||
|
||||
if Line - 2 >= 0 and str(self.Profile.FileLinesList[Line - 2]).rstrip().endswith(','):
|
||||
return
|
||||
|
||||
if Line - 2 >= 0 and str(self.Profile.FileLinesList[Line - 2]).rstrip().endswith(';'):
|
||||
return
|
||||
|
||||
if str(self.Profile.FileLinesList[Line]).lstrip().startswith(',') or str(self.Profile.FileLinesList[Line]).lstrip().startswith(';'):
|
||||
return
|
||||
|
||||
self.Profile.FileLinesList[Line - 1].insert(self.CurrentOffsetWithinLine, ',')
|
||||
|
||||
## PreprocessFileWithClear() method
|
||||
#
|
||||
# Run a preprocess for the file to clean all comments
|
||||
#
|
||||
# @param self The object pointer
|
||||
#
|
||||
def PreprocessFileWithClear(self):
|
||||
|
||||
self.Rewind()
|
||||
InComment = False
|
||||
DoubleSlashComment = False
|
||||
HashComment = False
|
||||
PPExtend = False
|
||||
PPDirectiveObj = None
|
||||
# HashComment in quoted string " " is ignored.
|
||||
InString = False
|
||||
InCharLiteral = False
|
||||
|
||||
self.Profile.FileLinesList = [list(s) for s in self.Profile.FileLinesListFromFile]
|
||||
while not self.__EndOfFile():
|
||||
|
||||
if not InComment and self.__CurrentChar() == T_CHAR_DOUBLE_QUOTE:
|
||||
InString = not InString
|
||||
|
||||
if not InComment and self.__CurrentChar() == T_CHAR_SINGLE_QUOTE:
|
||||
InCharLiteral = not InCharLiteral
|
||||
# meet new line, then no longer in a comment for // and '#'
|
||||
if self.__CurrentChar() == T_CHAR_LF:
|
||||
if HashComment and PPDirectiveObj != None:
|
||||
if PPDirectiveObj.Content.rstrip(T_CHAR_CR).endswith(T_CHAR_BACKSLASH):
|
||||
PPDirectiveObj.Content += T_CHAR_LF
|
||||
PPExtend = True
|
||||
else:
|
||||
PPExtend = False
|
||||
|
||||
EndLinePos = (self.CurrentLineNumber, self.CurrentOffsetWithinLine)
|
||||
|
||||
if InComment and DoubleSlashComment:
|
||||
InComment = False
|
||||
DoubleSlashComment = False
|
||||
|
||||
if InComment and HashComment and not PPExtend:
|
||||
InComment = False
|
||||
HashComment = False
|
||||
PPDirectiveObj.Content += T_CHAR_LF
|
||||
PPDirectiveObj.EndPos = EndLinePos
|
||||
FileProfile.PPDirectiveList.append(PPDirectiveObj)
|
||||
PPDirectiveObj = None
|
||||
|
||||
if InString or InCharLiteral:
|
||||
CurrentLine = "".join(self.__CurrentLine())
|
||||
if CurrentLine.rstrip(T_CHAR_LF).rstrip(T_CHAR_CR).endswith(T_CHAR_BACKSLASH):
|
||||
SlashIndex = CurrentLine.rindex(T_CHAR_BACKSLASH)
|
||||
self.__SetCharValue(self.CurrentLineNumber, SlashIndex, T_CHAR_SPACE)
|
||||
|
||||
self.CurrentLineNumber += 1
|
||||
self.CurrentOffsetWithinLine = 0
|
||||
# check for */ comment end
|
||||
elif InComment and not DoubleSlashComment and not HashComment and self.__CurrentChar() == T_CHAR_STAR and self.__NextChar() == T_CHAR_SLASH:
|
||||
|
||||
self.__SetCurrentCharValue(T_CHAR_SPACE)
|
||||
self.__GetOneChar()
|
||||
self.__SetCurrentCharValue(T_CHAR_SPACE)
|
||||
self.__GetOneChar()
|
||||
InComment = False
|
||||
# set comments to spaces
|
||||
elif InComment:
|
||||
if HashComment:
|
||||
# // follows hash PP directive
|
||||
if self.__CurrentChar() == T_CHAR_SLASH and self.__NextChar() == T_CHAR_SLASH:
|
||||
InComment = False
|
||||
HashComment = False
|
||||
PPDirectiveObj.EndPos = (self.CurrentLineNumber, self.CurrentOffsetWithinLine - 1)
|
||||
FileProfile.PPDirectiveList.append(PPDirectiveObj)
|
||||
PPDirectiveObj = None
|
||||
continue
|
||||
else:
|
||||
PPDirectiveObj.Content += self.__CurrentChar()
|
||||
|
||||
self.__SetCurrentCharValue(T_CHAR_SPACE)
|
||||
self.__GetOneChar()
|
||||
# check for // comment
|
||||
elif self.__CurrentChar() == T_CHAR_SLASH and self.__NextChar() == T_CHAR_SLASH:
|
||||
InComment = True
|
||||
DoubleSlashComment = True
|
||||
|
||||
# check for '#' comment
|
||||
elif self.__CurrentChar() == T_CHAR_HASH and not InString and not InCharLiteral:
|
||||
InComment = True
|
||||
HashComment = True
|
||||
PPDirectiveObj = PP_Directive('', (self.CurrentLineNumber, self.CurrentOffsetWithinLine), None)
|
||||
# check for /* comment start
|
||||
elif self.__CurrentChar() == T_CHAR_SLASH and self.__NextChar() == T_CHAR_STAR:
|
||||
|
||||
self.__SetCurrentCharValue( T_CHAR_SPACE)
|
||||
self.__GetOneChar()
|
||||
self.__SetCurrentCharValue( T_CHAR_SPACE)
|
||||
self.__GetOneChar()
|
||||
InComment = True
|
||||
else:
|
||||
self.__GetOneChar()
|
||||
|
||||
EndLinePos = (self.CurrentLineNumber, self.CurrentOffsetWithinLine)
|
||||
|
||||
if InComment and HashComment and not PPExtend:
|
||||
PPDirectiveObj.EndPos = EndLinePos
|
||||
FileProfile.PPDirectiveList.append(PPDirectiveObj)
|
||||
self.Rewind()
|
||||
|
||||
## ParseFile() method
|
||||
#
|
||||
# Parse the file profile buffer to extract fd, fv ... information
|
||||
# Exception will be raised if syntax error found
|
||||
#
|
||||
# @param self The object pointer
|
||||
#
|
||||
def ParseFile(self):
|
||||
self.PreprocessFileWithClear()
|
||||
# restore from ListOfList to ListOfString
|
||||
self.Profile.FileLinesList = ["".join(list) for list in self.Profile.FileLinesList]
|
||||
FileStringContents = ''
|
||||
for fileLine in self.Profile.FileLinesList:
|
||||
FileStringContents += fileLine
|
||||
cStream = antlr3.StringStream(FileStringContents)
|
||||
lexer = CLexer(cStream)
|
||||
tStream = antlr3.CommonTokenStream(lexer)
|
||||
parser = CParser(tStream)
|
||||
parser.translation_unit()
|
||||
|
||||
## CleanFileProfileBuffer() method
|
||||
#
|
||||
# Reset all contents of the profile of a file
|
||||
#
|
||||
def CleanFileProfileBuffer(self):
|
||||
|
||||
FileProfile.PPDirectiveList = []
|
||||
FileProfile.AssignmentExpressionList = []
|
||||
FileProfile.FunctionDefinitionList = []
|
||||
FileProfile.VariableDeclarationList = []
|
||||
FileProfile.EnumerationDefinitionList = []
|
||||
FileProfile.StructUnionDefinitionList = []
|
||||
FileProfile.TypedefDefinitionList = []
|
||||
FileProfile.FunctionCallingList = []
|
||||
|
||||
## PrintFragments() method
|
||||
#
|
||||
# Print the contents of the profile of a file
|
||||
#
|
||||
def PrintFragments(self):
|
||||
|
||||
print '################# ' + self.FileName + '#####################'
|
||||
|
||||
print '/****************************************/'
|
||||
print '/*************** ASSIGNMENTS ***************/'
|
||||
print '/****************************************/'
|
||||
for asign in FileProfile.AssignmentExpressionList:
|
||||
print str(asign.StartPos) + asign.Name + asign.Operator + asign.Value
|
||||
|
||||
print '/****************************************/'
|
||||
print '/********* PREPROCESS DIRECTIVES ********/'
|
||||
print '/****************************************/'
|
||||
for pp in FileProfile.PPDirectiveList:
|
||||
print str(pp.StartPos) + pp.Content
|
||||
|
||||
print '/****************************************/'
|
||||
print '/********* VARIABLE DECLARATIONS ********/'
|
||||
print '/****************************************/'
|
||||
for var in FileProfile.VariableDeclarationList:
|
||||
print str(var.StartPos) + var.Modifier + ' '+ var.Declarator
|
||||
|
||||
print '/****************************************/'
|
||||
print '/********* FUNCTION DEFINITIONS *********/'
|
||||
print '/****************************************/'
|
||||
for func in FileProfile.FunctionDefinitionList:
|
||||
print str(func.StartPos) + func.Modifier + ' '+ func.Declarator + ' ' + str(func.NamePos)
|
||||
|
||||
print '/****************************************/'
|
||||
print '/************ ENUMERATIONS **************/'
|
||||
print '/****************************************/'
|
||||
for enum in FileProfile.EnumerationDefinitionList:
|
||||
print str(enum.StartPos) + enum.Content
|
||||
|
||||
print '/****************************************/'
|
||||
print '/*********** STRUCTS/UNIONS *************/'
|
||||
print '/****************************************/'
|
||||
for su in FileProfile.StructUnionDefinitionList:
|
||||
print str(su.StartPos) + su.Content
|
||||
|
||||
print '/****************************************/'
|
||||
print '/************** TYPEDEFS ****************/'
|
||||
print '/****************************************/'
|
||||
for typedef in FileProfile.TypedefDefinitionList:
|
||||
print str(typedef.StartPos) + typedef.ToType
|
||||
|
||||
##
|
||||
#
|
||||
# This acts like the main() function for the script, unless it is 'import'ed into another
|
||||
# script.
|
||||
#
|
||||
if __name__ == "__main__":
|
||||
|
||||
print "For Test."
|
255
BaseTools/Source/Python/Eot/Database.py
Normal file
255
BaseTools/Source/Python/Eot/Database.py
Normal file
@@ -0,0 +1,255 @@
|
||||
## @file
|
||||
# This file is used to create a database used by EOT tool
|
||||
#
|
||||
# Copyright (c) 2007 - 2010, 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
|
||||
# http://opensource.org/licenses/bsd-license.php
|
||||
#
|
||||
# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
|
||||
#
|
||||
|
||||
##
|
||||
# Import Modules
|
||||
#
|
||||
import sqlite3
|
||||
import os, time
|
||||
|
||||
import Common.EdkLogger as EdkLogger
|
||||
import CommonDataClass.DataClass as DataClass
|
||||
|
||||
from Table.TableDataModel import TableDataModel
|
||||
from Table.TableFile import TableFile
|
||||
from Table.TableFunction import TableFunction
|
||||
from Table.TableIdentifier import TableIdentifier
|
||||
from Table.TableEotReport import TableEotReport
|
||||
from Table.TableInf import TableInf
|
||||
from Table.TableDec import TableDec
|
||||
from Table.TableDsc import TableDsc
|
||||
from Table.TableFdf import TableFdf
|
||||
from Table.TableQuery import TableQuery
|
||||
|
||||
##
|
||||
# Static definitions
|
||||
#
|
||||
DATABASE_PATH = "Eot.db"
|
||||
|
||||
## Database class
|
||||
#
|
||||
# This class defined the EOT databse
|
||||
# During the phase of initialization, the database will create all tables and
|
||||
# insert all records of table DataModel
|
||||
#
|
||||
class Database(object):
|
||||
## The constructor
|
||||
#
|
||||
# @param self: The object pointer
|
||||
# @param DbPath: The file path of the database
|
||||
#
|
||||
def __init__(self, DbPath):
|
||||
self.DbPath = DbPath
|
||||
self.Conn = None
|
||||
self.Cur = None
|
||||
self.TblDataModel = None
|
||||
self.TblFile = None
|
||||
self.TblFunction = None
|
||||
self.TblIdentifier = None
|
||||
self.TblReport = None
|
||||
self.TblInf = None
|
||||
self.TblDec = None
|
||||
self.TblDsc = None
|
||||
self.TblFdf = None
|
||||
self.TblQuery = None
|
||||
self.TblQuery2 = None
|
||||
|
||||
## InitDatabase() method
|
||||
# 1. Delete all old existing tables
|
||||
# 2. Create new tables
|
||||
# 3. Initialize table DataModel
|
||||
#
|
||||
# @param self: The object pointer
|
||||
# @param NewDatabase: Check if it needs to create a new database
|
||||
#
|
||||
def InitDatabase(self, NewDatabase = True):
|
||||
EdkLogger.verbose("\nInitialize EOT database started ...")
|
||||
#
|
||||
# Drop all old existing tables
|
||||
#
|
||||
if NewDatabase:
|
||||
if os.path.exists(self.DbPath):
|
||||
os.remove(self.DbPath)
|
||||
self.Conn = sqlite3.connect(self.DbPath, isolation_level = 'DEFERRED')
|
||||
self.Conn.execute("PRAGMA page_size=8192")
|
||||
self.Conn.execute("PRAGMA synchronous=OFF")
|
||||
# to avoid non-ascii charater conversion error
|
||||
self.Conn.text_factory = str
|
||||
self.Cur = self.Conn.cursor()
|
||||
|
||||
self.TblDataModel = TableDataModel(self.Cur)
|
||||
self.TblFile = TableFile(self.Cur)
|
||||
self.TblFunction = TableFunction(self.Cur)
|
||||
self.TblIdentifier = TableIdentifier(self.Cur)
|
||||
self.TblReport = TableEotReport(self.Cur)
|
||||
self.TblInf = TableInf(self.Cur)
|
||||
self.TblDec = TableDec(self.Cur)
|
||||
self.TblDsc = TableDsc(self.Cur)
|
||||
self.TblFdf = TableFdf(self.Cur)
|
||||
self.TblQuery = TableQuery(self.Cur)
|
||||
self.TblQuery2 = TableQuery(self.Cur)
|
||||
self.TblQuery2.Table = 'Query2'
|
||||
|
||||
# Create new tables
|
||||
if NewDatabase:
|
||||
self.TblDataModel.Create()
|
||||
self.TblFile.Create()
|
||||
self.TblFunction.Create()
|
||||
self.TblReport.Create()
|
||||
self.TblInf.Create()
|
||||
self.TblDec.Create()
|
||||
self.TblDsc.Create()
|
||||
self.TblFdf.Create()
|
||||
self.TblQuery.Create()
|
||||
self.TblQuery2.Create()
|
||||
|
||||
# Init each table's ID
|
||||
self.TblDataModel.InitID()
|
||||
self.TblFile.InitID()
|
||||
self.TblFunction.InitID()
|
||||
self.TblReport.InitID()
|
||||
self.TblInf.InitID()
|
||||
self.TblDec.InitID()
|
||||
self.TblDsc.InitID()
|
||||
self.TblFdf.InitID()
|
||||
self.TblQuery.Drop()
|
||||
self.TblQuery.Create()
|
||||
self.TblQuery.InitID()
|
||||
self.TblQuery2.Drop()
|
||||
self.TblQuery2.Create()
|
||||
self.TblQuery2.InitID()
|
||||
|
||||
# Initialize table DataModel
|
||||
if NewDatabase:
|
||||
self.TblDataModel.InitTable()
|
||||
|
||||
EdkLogger.verbose("Initialize EOT database ... DONE!")
|
||||
|
||||
## QueryTable() method
|
||||
#
|
||||
# Query a table
|
||||
#
|
||||
# @param self: The object pointer
|
||||
# @param Table: The instance of the table to be queried
|
||||
#
|
||||
def QueryTable(self, Table):
|
||||
Table.Query()
|
||||
|
||||
## Close() method
|
||||
#
|
||||
# Commit all first
|
||||
# Close the connection and cursor
|
||||
#
|
||||
def Close(self):
|
||||
# Commit to file
|
||||
self.Conn.commit()
|
||||
|
||||
# Close connection and cursor
|
||||
self.Cur.close()
|
||||
self.Conn.close()
|
||||
|
||||
## InsertOneFile() method
|
||||
#
|
||||
# Insert one file's information to the database
|
||||
# 1. Create a record in TableFile
|
||||
# 2. Create functions one by one
|
||||
# 2.1 Create variables of function one by one
|
||||
# 2.2 Create pcds of function one by one
|
||||
# 3. Create variables one by one
|
||||
# 4. Create pcds one by one
|
||||
#
|
||||
# @param self: The object pointer
|
||||
# @param File: The object of the file to be inserted
|
||||
#
|
||||
def InsertOneFile(self, File):
|
||||
# Insert a record for file
|
||||
FileID = self.TblFile.Insert(File.Name, File.ExtName, File.Path, File.FullPath, Model = File.Model, TimeStamp = File.TimeStamp)
|
||||
IdTable = TableIdentifier(self.Cur)
|
||||
IdTable.Table = "Identifier%s" % FileID
|
||||
IdTable.Create()
|
||||
|
||||
# Insert function of file
|
||||
for Function in File.FunctionList:
|
||||
FunctionID = self.TblFunction.Insert(Function.Header, Function.Modifier, Function.Name, Function.ReturnStatement, \
|
||||
Function.StartLine, Function.StartColumn, Function.EndLine, Function.EndColumn, \
|
||||
Function.BodyStartLine, Function.BodyStartColumn, FileID, \
|
||||
Function.FunNameStartLine, Function.FunNameStartColumn)
|
||||
|
||||
# Insert Identifier of function
|
||||
for Identifier in Function.IdentifierList:
|
||||
IdentifierID = IdTable.Insert(Identifier.Modifier, Identifier.Type, Identifier.Name, Identifier.Value, Identifier.Model, \
|
||||
FileID, FunctionID, Identifier.StartLine, Identifier.StartColumn, Identifier.EndLine, Identifier.EndColumn)
|
||||
# Insert Identifier of file
|
||||
for Identifier in File.IdentifierList:
|
||||
IdentifierID = IdTable.Insert(Identifier.Modifier, Identifier.Type, Identifier.Name, Identifier.Value, Identifier.Model, \
|
||||
FileID, -1, Identifier.StartLine, Identifier.StartColumn, Identifier.EndLine, Identifier.EndColumn)
|
||||
|
||||
EdkLogger.verbose("Insert information from file %s ... DONE!" % File.FullPath)
|
||||
|
||||
## UpdateIdentifierBelongsToFunction() method
|
||||
#
|
||||
# Update the field "BelongsToFunction" for each Indentifier
|
||||
#
|
||||
# @param self: The object pointer
|
||||
#
|
||||
def UpdateIdentifierBelongsToFunction(self):
|
||||
EdkLogger.verbose("Update 'BelongsToFunction' for Identifiers started ...")
|
||||
|
||||
SqlCommand = """select ID, BelongsToFile, StartLine, EndLine from Function"""
|
||||
Records = self.TblFunction.Exec(SqlCommand)
|
||||
Data1 = []
|
||||
Data2 = []
|
||||
for Record in Records:
|
||||
FunctionID = Record[0]
|
||||
BelongsToFile = Record[1]
|
||||
StartLine = Record[2]
|
||||
EndLine = Record[3]
|
||||
|
||||
SqlCommand = """Update Identifier%s set BelongsToFunction = %s where BelongsToFile = %s and StartLine > %s and EndLine < %s""" % \
|
||||
(BelongsToFile, FunctionID, BelongsToFile, StartLine, EndLine)
|
||||
self.TblIdentifier.Exec(SqlCommand)
|
||||
|
||||
SqlCommand = """Update Identifier%s set BelongsToFunction = %s, Model = %s where BelongsToFile = %s and Model = %s and EndLine = %s""" % \
|
||||
(BelongsToFile, FunctionID, DataClass.MODEL_IDENTIFIER_FUNCTION_HEADER, BelongsToFile, DataClass.MODEL_IDENTIFIER_COMMENT, StartLine - 1)
|
||||
self.TblIdentifier.Exec(SqlCommand)
|
||||
|
||||
|
||||
##
|
||||
#
|
||||
# This acts like the main() function for the script, unless it is 'import'ed into another
|
||||
# script.
|
||||
#
|
||||
if __name__ == '__main__':
|
||||
EdkLogger.Initialize()
|
||||
EdkLogger.SetLevel(EdkLogger.DEBUG_0)
|
||||
EdkLogger.verbose("Start at " + time.strftime('%H:%M:%S', time.localtime()))
|
||||
|
||||
Db = Database(DATABASE_PATH)
|
||||
Db.InitDatabase()
|
||||
Db.QueryTable(Db.TblDataModel)
|
||||
|
||||
identifier1 = DataClass.IdentifierClass(-1, '', '', "i''1", 'aaa', DataClass.MODEL_IDENTIFIER_COMMENT, 1, -1, 32, 43, 54, 43)
|
||||
identifier2 = DataClass.IdentifierClass(-1, '', '', 'i1', 'aaa', DataClass.MODEL_IDENTIFIER_COMMENT, 1, -1, 15, 43, 20, 43)
|
||||
identifier3 = DataClass.IdentifierClass(-1, '', '', 'i1', 'aaa', DataClass.MODEL_IDENTIFIER_COMMENT, 1, -1, 55, 43, 58, 43)
|
||||
identifier4 = DataClass.IdentifierClass(-1, '', '', "i1'", 'aaa', DataClass.MODEL_IDENTIFIER_COMMENT, 1, -1, 77, 43, 88, 43)
|
||||
fun1 = DataClass.FunctionClass(-1, '', '', 'fun1', '', 21, 2, 60, 45, 1, 23, 0, [], [])
|
||||
file = DataClass.FileClass(-1, 'F1', 'c', 'C:\\', 'C:\\F1.exe', DataClass.MODEL_FILE_C, '2007-12-28', [fun1], [identifier1, identifier2, identifier3, identifier4], [])
|
||||
Db.InsertOneFile(file)
|
||||
|
||||
Db.QueryTable(Db.TblFile)
|
||||
Db.QueryTable(Db.TblFunction)
|
||||
Db.QueryTable(Db.TblIdentifier)
|
||||
|
||||
Db.Close()
|
||||
EdkLogger.verbose("End at " + time.strftime('%H:%M:%S', time.localtime()))
|
||||
|
BIN
BaseTools/Source/Python/Eot/EfiCompressor.pyd
Normal file
BIN
BaseTools/Source/Python/Eot/EfiCompressor.pyd
Normal file
Binary file not shown.
647
BaseTools/Source/Python/Eot/Eot.py
Normal file
647
BaseTools/Source/Python/Eot/Eot.py
Normal file
@@ -0,0 +1,647 @@
|
||||
## @file
|
||||
# This file is used to be the main entrance of EOT tool
|
||||
#
|
||||
# Copyright (c) 2008 - 2010, 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
|
||||
# http://opensource.org/licenses/bsd-license.php
|
||||
#
|
||||
# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
|
||||
#
|
||||
|
||||
##
|
||||
# Import Modules
|
||||
#
|
||||
import os, time, glob
|
||||
import Common.EdkLogger as EdkLogger
|
||||
import EotGlobalData
|
||||
from optparse import OptionParser
|
||||
from Common.String import NormPath
|
||||
from Common import BuildToolError
|
||||
from Common.Misc import GuidStructureStringToGuidString
|
||||
from InfParserLite import *
|
||||
import c
|
||||
import Database
|
||||
from FvImage import *
|
||||
from array import array
|
||||
from Report import Report
|
||||
from Common.Misc import ParseConsoleLog
|
||||
from Parser import ConvertGuid
|
||||
|
||||
## Class Eot
|
||||
#
|
||||
# This class is used to define Eot main entrance
|
||||
#
|
||||
# @param object: Inherited from object class
|
||||
#
|
||||
class Eot(object):
|
||||
## The constructor
|
||||
#
|
||||
# @param self: The object pointer
|
||||
#
|
||||
def __init__(self, CommandLineOption=True, IsInit=True, SourceFileList=None, \
|
||||
IncludeDirList=None, DecFileList=None, GuidList=None, LogFile=None,
|
||||
FvFileList="", MapFileList="", Report='Report.html', Dispatch=None):
|
||||
# Version and Copyright
|
||||
self.VersionNumber = "0.02"
|
||||
self.Version = "%prog Version " + self.VersionNumber
|
||||
self.Copyright = "Copyright (c) 2008 - 2010, Intel Corporation All rights reserved."
|
||||
self.Report = Report
|
||||
|
||||
self.IsInit = IsInit
|
||||
self.SourceFileList = SourceFileList
|
||||
self.IncludeDirList = IncludeDirList
|
||||
self.DecFileList = DecFileList
|
||||
self.GuidList = GuidList
|
||||
self.LogFile = LogFile
|
||||
self.FvFileList = FvFileList
|
||||
self.MapFileList = MapFileList
|
||||
self.Dispatch = Dispatch
|
||||
|
||||
# Check workspace environment
|
||||
if "EFI_SOURCE" not in os.environ:
|
||||
if "EDK_SOURCE" not in os.environ:
|
||||
pass
|
||||
else:
|
||||
EotGlobalData.gEDK_SOURCE = os.path.normpath(os.getenv("EDK_SOURCE"))
|
||||
else:
|
||||
EotGlobalData.gEFI_SOURCE = os.path.normpath(os.getenv("EFI_SOURCE"))
|
||||
EotGlobalData.gEDK_SOURCE = os.path.join(EotGlobalData.gEFI_SOURCE, 'Edk')
|
||||
|
||||
if "WORKSPACE" not in os.environ:
|
||||
EdkLogger.error("EOT", BuildToolError.ATTRIBUTE_NOT_AVAILABLE, "Environment variable not found",
|
||||
ExtraData="WORKSPACE")
|
||||
else:
|
||||
EotGlobalData.gWORKSPACE = os.path.normpath(os.getenv("WORKSPACE"))
|
||||
|
||||
EotGlobalData.gMACRO['WORKSPACE'] = EotGlobalData.gWORKSPACE
|
||||
EotGlobalData.gMACRO['EFI_SOURCE'] = EotGlobalData.gEFI_SOURCE
|
||||
EotGlobalData.gMACRO['EDK_SOURCE'] = EotGlobalData.gEDK_SOURCE
|
||||
|
||||
# Parse the options and args
|
||||
if CommandLineOption:
|
||||
self.ParseOption()
|
||||
|
||||
if self.FvFileList:
|
||||
for FvFile in GetSplitValueList(self.FvFileList, ' '):
|
||||
FvFile = os.path.normpath(FvFile)
|
||||
if not os.path.isfile(FvFile):
|
||||
EdkLogger.error("Eot", EdkLogger.EOT_ERROR, "Can not find file %s " % FvFile)
|
||||
EotGlobalData.gFV_FILE.append(FvFile)
|
||||
else:
|
||||
EdkLogger.error("Eot", EdkLogger.EOT_ERROR, "The fv file list of target platform was not specified")
|
||||
|
||||
if self.MapFileList:
|
||||
for MapFile in GetSplitValueList(self.MapFileList, ' '):
|
||||
MapFile = os.path.normpath(MapFile)
|
||||
if not os.path.isfile(MapFile):
|
||||
EdkLogger.error("Eot", EdkLogger.EOT_ERROR, "Can not find file %s " % MapFile)
|
||||
EotGlobalData.gMAP_FILE.append(MapFile)
|
||||
|
||||
# Generate source file list
|
||||
self.GenerateSourceFileList(self.SourceFileList, self.IncludeDirList)
|
||||
|
||||
# Generate guid list of dec file list
|
||||
self.ParseDecFile(self.DecFileList)
|
||||
|
||||
# Generate guid list from GUID list file
|
||||
self.ParseGuidList(self.GuidList)
|
||||
|
||||
# Init Eot database
|
||||
EotGlobalData.gDb = Database.Database(Database.DATABASE_PATH)
|
||||
EotGlobalData.gDb.InitDatabase(self.IsInit)
|
||||
|
||||
# Build ECC database
|
||||
self.BuildDatabase()
|
||||
|
||||
# Parse Ppi/Protocol
|
||||
self.ParseExecutionOrder()
|
||||
|
||||
# Merge Identifier tables
|
||||
self.GenerateQueryTable()
|
||||
|
||||
# Generate report database
|
||||
self.GenerateReportDatabase()
|
||||
|
||||
# Load Fv Info
|
||||
self.LoadFvInfo()
|
||||
|
||||
# Load Map Info
|
||||
self.LoadMapInfo()
|
||||
|
||||
# Generate Report
|
||||
self.GenerateReport()
|
||||
|
||||
# Convert log file
|
||||
self.ConvertLogFile(self.LogFile)
|
||||
|
||||
# DONE
|
||||
EdkLogger.quiet("EOT FINISHED!")
|
||||
|
||||
# Close Database
|
||||
EotGlobalData.gDb.Close()
|
||||
|
||||
## ParseDecFile() method
|
||||
#
|
||||
# parse DEC file and get all GUID names with GUID values as {GuidName : GuidValue}
|
||||
# The Dict is stored in EotGlobalData.gGuidDict
|
||||
#
|
||||
# @param self: The object pointer
|
||||
# @param DecFileList: A list of all DEC files
|
||||
#
|
||||
def ParseDecFile(self, DecFileList):
|
||||
if DecFileList:
|
||||
path = os.path.normpath(DecFileList)
|
||||
lfr = open(path, 'rb')
|
||||
for line in lfr:
|
||||
path = os.path.normpath(os.path.join(EotGlobalData.gWORKSPACE, line.strip()))
|
||||
if os.path.exists(path):
|
||||
dfr = open(path, 'rb')
|
||||
for line in dfr:
|
||||
line = CleanString(line)
|
||||
list = line.split('=')
|
||||
if len(list) == 2:
|
||||
EotGlobalData.gGuidDict[list[0].strip()] = GuidStructureStringToGuidString(list[1].strip())
|
||||
|
||||
|
||||
## ParseGuidList() method
|
||||
#
|
||||
# Parse Guid list and get all GUID names with GUID values as {GuidName : GuidValue}
|
||||
# The Dict is stored in EotGlobalData.gGuidDict
|
||||
#
|
||||
# @param self: The object pointer
|
||||
# @param GuidList: A list of all GUID and its value
|
||||
#
|
||||
def ParseGuidList(self, GuidList):
|
||||
Path = os.path.join(EotGlobalData.gWORKSPACE, GuidList)
|
||||
if os.path.isfile(Path):
|
||||
for Line in open(Path):
|
||||
(GuidName, GuidValue) = Line.split()
|
||||
EotGlobalData.gGuidDict[GuidName] = GuidValue
|
||||
|
||||
## ConvertLogFile() method
|
||||
#
|
||||
# Parse a real running log file to get real dispatch order
|
||||
# The result is saved to old file name + '.new'
|
||||
#
|
||||
# @param self: The object pointer
|
||||
# @param LogFile: A real running log file name
|
||||
#
|
||||
def ConvertLogFile(self, LogFile):
|
||||
newline = []
|
||||
lfr = None
|
||||
lfw = None
|
||||
if LogFile:
|
||||
lfr = open(LogFile, 'rb')
|
||||
lfw = open(LogFile + '.new', 'wb')
|
||||
for line in lfr:
|
||||
line = line.strip()
|
||||
line = line.replace('.efi', '')
|
||||
index = line.find("Loading PEIM at ")
|
||||
if index > -1:
|
||||
newline.append(line[index + 55 : ])
|
||||
continue
|
||||
index = line.find("Loading driver at ")
|
||||
if index > -1:
|
||||
newline.append(line[index + 57 : ])
|
||||
continue
|
||||
|
||||
for line in newline:
|
||||
lfw.write(line + '\r\n')
|
||||
|
||||
if lfr:
|
||||
lfr.close()
|
||||
if lfw:
|
||||
lfw.close()
|
||||
|
||||
## GenerateSourceFileList() method
|
||||
#
|
||||
# Generate a list of all source files
|
||||
# 1. Search the file list one by one
|
||||
# 2. Store inf file name with source file names under it like
|
||||
# { INF file name: [source file1, source file2, ...]}
|
||||
# 3. Search the include list to find all .h files
|
||||
# 4. Store source file list to EotGlobalData.gSOURCE_FILES
|
||||
# 5. Store INF file list to EotGlobalData.gINF_FILES
|
||||
#
|
||||
# @param self: The object pointer
|
||||
# @param SourceFileList: A list of all source files
|
||||
# @param IncludeFileList: A list of all include files
|
||||
#
|
||||
def GenerateSourceFileList(self, SourceFileList, IncludeFileList):
|
||||
EdkLogger.quiet("Generating source files list ... ")
|
||||
mSourceFileList = []
|
||||
mInfFileList = []
|
||||
mDecFileList = []
|
||||
mFileList = {}
|
||||
mCurrentInfFile = ''
|
||||
mCurrentSourceFileList = []
|
||||
|
||||
if SourceFileList:
|
||||
sfl = open(SourceFileList, 'rb')
|
||||
for line in sfl:
|
||||
line = os.path.normpath(os.path.join(EotGlobalData.gWORKSPACE, line.strip()))
|
||||
if line[-2:].upper() == '.C' or line[-2:].upper() == '.H':
|
||||
if line not in mCurrentSourceFileList:
|
||||
mCurrentSourceFileList.append(line)
|
||||
mSourceFileList.append(line)
|
||||
EotGlobalData.gOP_SOURCE_FILES.write('%s\n' % line)
|
||||
if line[-4:].upper() == '.INF':
|
||||
if mCurrentInfFile != '':
|
||||
mFileList[mCurrentInfFile] = mCurrentSourceFileList
|
||||
mCurrentSourceFileList = []
|
||||
mCurrentInfFile = os.path.normpath(os.path.join(EotGlobalData.gWORKSPACE, line))
|
||||
EotGlobalData.gOP_INF.write('%s\n' % mCurrentInfFile)
|
||||
if mCurrentInfFile not in mFileList:
|
||||
mFileList[mCurrentInfFile] = mCurrentSourceFileList
|
||||
|
||||
# Get all include files from packages
|
||||
if IncludeFileList:
|
||||
ifl = open(IncludeFileList, 'rb')
|
||||
for line in ifl:
|
||||
if not line.strip():
|
||||
continue
|
||||
newline = os.path.normpath(os.path.join(EotGlobalData.gWORKSPACE, line.strip()))
|
||||
for Root, Dirs, Files in os.walk(str(newline)):
|
||||
for File in Files:
|
||||
FullPath = os.path.normpath(os.path.join(Root, File))
|
||||
if FullPath not in mSourceFileList and File[-2:].upper() == '.H':
|
||||
mSourceFileList.append(FullPath)
|
||||
EotGlobalData.gOP_SOURCE_FILES.write('%s\n' % FullPath)
|
||||
if FullPath not in mDecFileList and File.upper().find('.DEC') > -1:
|
||||
mDecFileList.append(FullPath)
|
||||
|
||||
EotGlobalData.gSOURCE_FILES = mSourceFileList
|
||||
EotGlobalData.gOP_SOURCE_FILES.close()
|
||||
|
||||
EotGlobalData.gINF_FILES = mFileList
|
||||
EotGlobalData.gOP_INF.close()
|
||||
|
||||
EotGlobalData.gDEC_FILES = mDecFileList
|
||||
|
||||
|
||||
## GenerateReport() method
|
||||
#
|
||||
# Generate final HTML report
|
||||
#
|
||||
# @param self: The object pointer
|
||||
#
|
||||
def GenerateReport(self):
|
||||
EdkLogger.quiet("Generating report file ... ")
|
||||
Rep = Report(self.Report, EotGlobalData.gFV, self.Dispatch)
|
||||
Rep.GenerateReport()
|
||||
|
||||
## LoadMapInfo() method
|
||||
#
|
||||
# Load map files and parse them
|
||||
#
|
||||
# @param self: The object pointer
|
||||
#
|
||||
def LoadMapInfo(self):
|
||||
if EotGlobalData.gMAP_FILE != []:
|
||||
EdkLogger.quiet("Parsing Map file ... ")
|
||||
EotGlobalData.gMap = ParseMapFile(EotGlobalData.gMAP_FILE)
|
||||
|
||||
## LoadFvInfo() method
|
||||
#
|
||||
# Load FV binary files and parse them
|
||||
#
|
||||
# @param self: The object pointer
|
||||
#
|
||||
def LoadFvInfo(self):
|
||||
EdkLogger.quiet("Parsing FV file ... ")
|
||||
EotGlobalData.gFV = MultipleFv(EotGlobalData.gFV_FILE)
|
||||
EotGlobalData.gFV.Dispatch(EotGlobalData.gDb)
|
||||
|
||||
for Protocol in EotGlobalData.gProtocolList:
|
||||
EotGlobalData.gOP_UN_MATCHED_IN_LIBRARY_CALLING.write('%s\n' %Protocol)
|
||||
|
||||
## GenerateReportDatabase() method
|
||||
#
|
||||
# Generate data for the information needed by report
|
||||
# 1. Update name, macro and value of all found PPI/PROTOCOL GUID
|
||||
# 2. Install hard coded PPI/PROTOCOL
|
||||
#
|
||||
# @param self: The object pointer
|
||||
#
|
||||
def GenerateReportDatabase(self):
|
||||
EdkLogger.quiet("Generating the cross-reference table of GUID for Ppi/Protocol ... ")
|
||||
|
||||
# Update Protocol/Ppi Guid
|
||||
SqlCommand = """select DISTINCT GuidName from Report"""
|
||||
RecordSet = EotGlobalData.gDb.TblReport.Exec(SqlCommand)
|
||||
for Record in RecordSet:
|
||||
GuidName = Record[0]
|
||||
GuidMacro = ''
|
||||
GuidMacro2 = ''
|
||||
GuidValue = ''
|
||||
|
||||
# Find value for hardcode guid macro
|
||||
if GuidName in EotGlobalData.gGuidMacroDict:
|
||||
GuidMacro = EotGlobalData.gGuidMacroDict[GuidName][0]
|
||||
GuidValue = EotGlobalData.gGuidMacroDict[GuidName][1]
|
||||
SqlCommand = """update Report set GuidMacro = '%s', GuidValue = '%s' where GuidName = '%s'""" %(GuidMacro, GuidValue, GuidName)
|
||||
EotGlobalData.gDb.TblReport.Exec(SqlCommand)
|
||||
continue
|
||||
|
||||
# Find guid value defined in Dec file
|
||||
if GuidName in EotGlobalData.gGuidDict:
|
||||
GuidValue = EotGlobalData.gGuidDict[GuidName]
|
||||
SqlCommand = """update Report set GuidMacro = '%s', GuidValue = '%s' where GuidName = '%s'""" %(GuidMacro, GuidValue, GuidName)
|
||||
EotGlobalData.gDb.TblReport.Exec(SqlCommand)
|
||||
continue
|
||||
|
||||
# Search defined Macros for guid name
|
||||
SqlCommand ="""select DISTINCT Value, Modifier from Query where Name like '%s'""" % GuidName
|
||||
GuidMacroSet = EotGlobalData.gDb.TblReport.Exec(SqlCommand)
|
||||
# Ignore NULL result
|
||||
if not GuidMacroSet:
|
||||
continue
|
||||
GuidMacro = GuidMacroSet[0][0].strip()
|
||||
if not GuidMacro:
|
||||
continue
|
||||
# Find Guid value of Guid Macro
|
||||
SqlCommand ="""select DISTINCT Value from Query2 where Value like '%%%s%%' and Model = %s""" % (GuidMacro, MODEL_IDENTIFIER_MACRO_DEFINE)
|
||||
GuidValueSet = EotGlobalData.gDb.TblReport.Exec(SqlCommand)
|
||||
if GuidValueSet != []:
|
||||
GuidValue = GuidValueSet[0][0]
|
||||
GuidValue = GuidValue[GuidValue.find(GuidMacro) + len(GuidMacro) :]
|
||||
GuidValue = GuidValue.lower().replace('\\', '').replace('\r', '').replace('\n', '').replace('l', '').strip()
|
||||
GuidValue = GuidStructureStringToGuidString(GuidValue)
|
||||
SqlCommand = """update Report set GuidMacro = '%s', GuidValue = '%s' where GuidName = '%s'""" %(GuidMacro, GuidValue, GuidName)
|
||||
EotGlobalData.gDb.TblReport.Exec(SqlCommand)
|
||||
continue
|
||||
|
||||
# Update Hard Coded Ppi/Protocol
|
||||
SqlCommand = """select DISTINCT GuidValue, ItemType from Report where ModuleID = -2 and ItemMode = 'Produced'"""
|
||||
RecordSet = EotGlobalData.gDb.TblReport.Exec(SqlCommand)
|
||||
for Record in RecordSet:
|
||||
if Record[1] == 'Ppi':
|
||||
EotGlobalData.gPpiList[Record[0].lower()] = -2
|
||||
if Record[1] == 'Protocol':
|
||||
EotGlobalData.gProtocolList[Record[0].lower()] = -2
|
||||
|
||||
## GenerateQueryTable() method
|
||||
#
|
||||
# Generate two tables improve query performance
|
||||
#
|
||||
# @param self: The object pointer
|
||||
#
|
||||
def GenerateQueryTable(self):
|
||||
EdkLogger.quiet("Generating temp query table for analysis ... ")
|
||||
for Identifier in EotGlobalData.gIdentifierTableList:
|
||||
SqlCommand = """insert into Query (Name, Modifier, Value, Model)
|
||||
select Name, Modifier, Value, Model from %s where (Model = %s or Model = %s)""" \
|
||||
% (Identifier[0], MODEL_IDENTIFIER_VARIABLE, MODEL_IDENTIFIER_ASSIGNMENT_EXPRESSION)
|
||||
EotGlobalData.gDb.TblReport.Exec(SqlCommand)
|
||||
SqlCommand = """insert into Query2 (Name, Modifier, Value, Model)
|
||||
select Name, Modifier, Value, Model from %s where Model = %s""" \
|
||||
% (Identifier[0], MODEL_IDENTIFIER_MACRO_DEFINE)
|
||||
EotGlobalData.gDb.TblReport.Exec(SqlCommand)
|
||||
|
||||
## ParseExecutionOrder() method
|
||||
#
|
||||
# Get final execution order
|
||||
# 1. Search all PPI
|
||||
# 2. Search all PROTOCOL
|
||||
#
|
||||
# @param self: The object pointer
|
||||
#
|
||||
def ParseExecutionOrder(self):
|
||||
EdkLogger.quiet("Searching Ppi/Protocol ... ")
|
||||
for Identifier in EotGlobalData.gIdentifierTableList:
|
||||
ModuleID, ModuleName, ModuleGuid, SourceFileID, SourceFileFullPath, ItemName, ItemType, ItemMode, GuidName, GuidMacro, GuidValue, BelongsToFunction, Enabled = \
|
||||
-1, '', '', -1, '', '', '', '', '', '', '', '', 0
|
||||
|
||||
SourceFileID = Identifier[0].replace('Identifier', '')
|
||||
SourceFileFullPath = Identifier[1]
|
||||
Identifier = Identifier[0]
|
||||
|
||||
# Find Ppis
|
||||
ItemMode = 'Produced'
|
||||
SqlCommand = """select Value, Name, BelongsToFile, StartLine, EndLine from %s
|
||||
where (Name like '%%%s%%' or Name like '%%%s%%' or Name like '%%%s%%') and Model = %s""" \
|
||||
% (Identifier, '.InstallPpi', '->InstallPpi', 'PeiInstallPpi', MODEL_IDENTIFIER_FUNCTION_CALLING)
|
||||
SearchPpi(SqlCommand, Identifier, SourceFileID, SourceFileFullPath, ItemMode)
|
||||
|
||||
ItemMode = 'Produced'
|
||||
SqlCommand = """select Value, Name, BelongsToFile, StartLine, EndLine from %s
|
||||
where (Name like '%%%s%%' or Name like '%%%s%%') and Model = %s""" \
|
||||
% (Identifier, '.ReInstallPpi', '->ReInstallPpi', MODEL_IDENTIFIER_FUNCTION_CALLING)
|
||||
SearchPpi(SqlCommand, Identifier, SourceFileID, SourceFileFullPath, ItemMode, 2)
|
||||
|
||||
SearchPpiCallFunction(Identifier, SourceFileID, SourceFileFullPath, ItemMode)
|
||||
|
||||
ItemMode = 'Consumed'
|
||||
SqlCommand = """select Value, Name, BelongsToFile, StartLine, EndLine from %s
|
||||
where (Name like '%%%s%%' or Name like '%%%s%%') and Model = %s""" \
|
||||
% (Identifier, '.LocatePpi', '->LocatePpi', MODEL_IDENTIFIER_FUNCTION_CALLING)
|
||||
SearchPpi(SqlCommand, Identifier, SourceFileID, SourceFileFullPath, ItemMode)
|
||||
|
||||
SearchFunctionCalling(Identifier, SourceFileID, SourceFileFullPath, 'Ppi', ItemMode)
|
||||
|
||||
ItemMode = 'Callback'
|
||||
SqlCommand = """select Value, Name, BelongsToFile, StartLine, EndLine from %s
|
||||
where (Name like '%%%s%%' or Name like '%%%s%%') and Model = %s""" \
|
||||
% (Identifier, '.NotifyPpi', '->NotifyPpi', MODEL_IDENTIFIER_FUNCTION_CALLING)
|
||||
SearchPpi(SqlCommand, Identifier, SourceFileID, SourceFileFullPath, ItemMode)
|
||||
|
||||
# Find Procotols
|
||||
ItemMode = 'Produced'
|
||||
SqlCommand = """select Value, Name, BelongsToFile, StartLine, EndLine from %s
|
||||
where (Name like '%%%s%%' or Name like '%%%s%%' or Name like '%%%s%%' or Name like '%%%s%%') and Model = %s""" \
|
||||
% (Identifier, '.InstallProtocolInterface', '.ReInstallProtocolInterface', '->InstallProtocolInterface', '->ReInstallProtocolInterface', MODEL_IDENTIFIER_FUNCTION_CALLING)
|
||||
SearchProtocols(SqlCommand, Identifier, SourceFileID, SourceFileFullPath, ItemMode, 1)
|
||||
|
||||
SqlCommand = """select Value, Name, BelongsToFile, StartLine, EndLine from %s
|
||||
where (Name like '%%%s%%' or Name like '%%%s%%') and Model = %s""" \
|
||||
% (Identifier, '.InstallMultipleProtocolInterfaces', '->InstallMultipleProtocolInterfaces', MODEL_IDENTIFIER_FUNCTION_CALLING)
|
||||
SearchProtocols(SqlCommand, Identifier, SourceFileID, SourceFileFullPath, ItemMode, 2)
|
||||
|
||||
SearchFunctionCalling(Identifier, SourceFileID, SourceFileFullPath, 'Protocol', ItemMode)
|
||||
|
||||
ItemMode = 'Consumed'
|
||||
SqlCommand = """select Value, Name, BelongsToFile, StartLine, EndLine from %s
|
||||
where (Name like '%%%s%%' or Name like '%%%s%%') and Model = %s""" \
|
||||
% (Identifier, '.LocateProtocol', '->LocateProtocol', MODEL_IDENTIFIER_FUNCTION_CALLING)
|
||||
SearchProtocols(SqlCommand, Identifier, SourceFileID, SourceFileFullPath, ItemMode, 0)
|
||||
|
||||
SqlCommand = """select Value, Name, BelongsToFile, StartLine, EndLine from %s
|
||||
where (Name like '%%%s%%' or Name like '%%%s%%') and Model = %s""" \
|
||||
% (Identifier, '.HandleProtocol', '->HandleProtocol', MODEL_IDENTIFIER_FUNCTION_CALLING)
|
||||
SearchProtocols(SqlCommand, Identifier, SourceFileID, SourceFileFullPath, ItemMode, 1)
|
||||
|
||||
SearchFunctionCalling(Identifier, SourceFileID, SourceFileFullPath, 'Protocol', ItemMode)
|
||||
|
||||
ItemMode = 'Callback'
|
||||
SqlCommand = """select Value, Name, BelongsToFile, StartLine, EndLine from %s
|
||||
where (Name like '%%%s%%' or Name like '%%%s%%') and Model = %s""" \
|
||||
% (Identifier, '.RegisterProtocolNotify', '->RegisterProtocolNotify', MODEL_IDENTIFIER_FUNCTION_CALLING)
|
||||
SearchProtocols(SqlCommand, Identifier, SourceFileID, SourceFileFullPath, ItemMode, 0)
|
||||
|
||||
SearchFunctionCalling(Identifier, SourceFileID, SourceFileFullPath, 'Protocol', ItemMode)
|
||||
|
||||
# Hard Code
|
||||
EotGlobalData.gDb.TblReport.Insert(-2, '', '', -1, '', '', 'Ppi', 'Produced', 'gEfiSecPlatformInformationPpiGuid', '', '', '', 0)
|
||||
EotGlobalData.gDb.TblReport.Insert(-2, '', '', -1, '', '', 'Ppi', 'Produced', 'gEfiNtLoadAsDllPpiGuid', '', '', '', 0)
|
||||
EotGlobalData.gDb.TblReport.Insert(-2, '', '', -1, '', '', 'Ppi', 'Produced', 'gNtPeiLoadFileGuid', '', '', '', 0)
|
||||
EotGlobalData.gDb.TblReport.Insert(-2, '', '', -1, '', '', 'Ppi', 'Produced', 'gPeiNtAutoScanPpiGuid', '', '', '', 0)
|
||||
EotGlobalData.gDb.TblReport.Insert(-2, '', '', -1, '', '', 'Ppi', 'Produced', 'gNtFwhPpiGuid', '', '', '', 0)
|
||||
EotGlobalData.gDb.TblReport.Insert(-2, '', '', -1, '', '', 'Ppi', 'Produced', 'gPeiNtThunkPpiGuid', '', '', '', 0)
|
||||
EotGlobalData.gDb.TblReport.Insert(-2, '', '', -1, '', '', 'Ppi', 'Produced', 'gPeiPlatformTypePpiGuid', '', '', '', 0)
|
||||
EotGlobalData.gDb.TblReport.Insert(-2, '', '', -1, '', '', 'Ppi', 'Produced', 'gPeiFrequencySelectionCpuPpiGuid', '', '', '', 0)
|
||||
EotGlobalData.gDb.TblReport.Insert(-2, '', '', -1, '', '', 'Ppi', 'Produced', 'gPeiCachePpiGuid', '', '', '', 0)
|
||||
|
||||
EotGlobalData.gDb.Conn.commit()
|
||||
|
||||
|
||||
## BuildDatabase() methoc
|
||||
#
|
||||
# Build the database for target
|
||||
#
|
||||
# @param self: The object pointer
|
||||
#
|
||||
def BuildDatabase(self):
|
||||
# Clean report table
|
||||
EotGlobalData.gDb.TblReport.Drop()
|
||||
EotGlobalData.gDb.TblReport.Create()
|
||||
|
||||
# Build database
|
||||
if self.IsInit:
|
||||
self.BuildMetaDataFileDatabase(EotGlobalData.gINF_FILES)
|
||||
EdkLogger.quiet("Building database for source code ...")
|
||||
c.CreateCCodeDB(EotGlobalData.gSOURCE_FILES)
|
||||
EdkLogger.quiet("Building database for source code done!")
|
||||
|
||||
EotGlobalData.gIdentifierTableList = GetTableList((MODEL_FILE_C, MODEL_FILE_H), 'Identifier', EotGlobalData.gDb)
|
||||
|
||||
## BuildMetaDataFileDatabase() method
|
||||
#
|
||||
# Build the database for meta data files
|
||||
#
|
||||
# @param self: The object pointer
|
||||
# @param Inf_Files: A list for all INF files
|
||||
#
|
||||
def BuildMetaDataFileDatabase(self, Inf_Files):
|
||||
EdkLogger.quiet("Building database for meta data files ...")
|
||||
for InfFile in Inf_Files:
|
||||
EdkLogger.quiet("Parsing %s ..." % str(InfFile))
|
||||
EdkInfParser(InfFile, EotGlobalData.gDb, Inf_Files[InfFile], '')
|
||||
|
||||
EotGlobalData.gDb.Conn.commit()
|
||||
EdkLogger.quiet("Building database for meta data files done!")
|
||||
|
||||
## ParseOption() method
|
||||
#
|
||||
# Parse command line options
|
||||
#
|
||||
# @param self: The object pointer
|
||||
#
|
||||
def ParseOption(self):
|
||||
(Options, Target) = self.EotOptionParser()
|
||||
|
||||
# Set log level
|
||||
self.SetLogLevel(Options)
|
||||
|
||||
if Options.FvFileList:
|
||||
self.FvFileList = Options.FvFileList
|
||||
|
||||
if Options.MapFileList:
|
||||
self.MapFileList = Options.FvMapFileList
|
||||
|
||||
if Options.SourceFileList:
|
||||
self.SourceFileList = Options.SourceFileList
|
||||
|
||||
if Options.IncludeDirList:
|
||||
self.IncludeDirList = Options.IncludeDirList
|
||||
|
||||
if Options.DecFileList:
|
||||
self.DecFileList = Options.DecFileList
|
||||
|
||||
if Options.GuidList:
|
||||
self.GuidList = Options.GuidList
|
||||
|
||||
if Options.LogFile:
|
||||
self.LogFile = Options.LogFile
|
||||
|
||||
if Options.keepdatabase:
|
||||
self.IsInit = False
|
||||
|
||||
## SetLogLevel() method
|
||||
#
|
||||
# Set current log level of the tool based on args
|
||||
#
|
||||
# @param self: The object pointer
|
||||
# @param Option: The option list including log level setting
|
||||
#
|
||||
def SetLogLevel(self, Option):
|
||||
if Option.verbose != None:
|
||||
EdkLogger.SetLevel(EdkLogger.VERBOSE)
|
||||
elif Option.quiet != None:
|
||||
EdkLogger.SetLevel(EdkLogger.QUIET)
|
||||
elif Option.debug != None:
|
||||
EdkLogger.SetLevel(Option.debug + 1)
|
||||
else:
|
||||
EdkLogger.SetLevel(EdkLogger.INFO)
|
||||
|
||||
## EotOptionParser() method
|
||||
#
|
||||
# Using standard Python module optparse to parse command line option of this tool.
|
||||
#
|
||||
# @param self: The object pointer
|
||||
#
|
||||
# @retval Opt A optparse.Values object containing the parsed options
|
||||
# @retval Args Target of build command
|
||||
#
|
||||
def EotOptionParser(self):
|
||||
Parser = OptionParser(description = self.Copyright, version = self.Version, prog = "Eot.exe", usage = "%prog [options]")
|
||||
Parser.add_option("-m", "--makefile filename", action="store", type="string", dest='MakeFile',
|
||||
help="Specify a makefile for the platform.")
|
||||
Parser.add_option("-c", "--dsc filename", action="store", type="string", dest="DscFile",
|
||||
help="Specify a dsc file for the platform.")
|
||||
Parser.add_option("-f", "--fv filename", action="store", type="string", dest="FvFileList",
|
||||
help="Specify fv file list, quoted by \"\".")
|
||||
Parser.add_option("-a", "--map filename", action="store", type="string", dest="MapFileList",
|
||||
help="Specify map file list, quoted by \"\".")
|
||||
Parser.add_option("-s", "--source files", action="store", type="string", dest="SourceFileList",
|
||||
help="Specify source file list by a file")
|
||||
Parser.add_option("-i", "--include dirs", action="store", type="string", dest="IncludeDirList",
|
||||
help="Specify include dir list by a file")
|
||||
Parser.add_option("-e", "--dec files", action="store", type="string", dest="DecFileList",
|
||||
help="Specify dec file list by a file")
|
||||
Parser.add_option("-g", "--guid list", action="store", type="string", dest="GuidList",
|
||||
help="Specify guid file list by a file")
|
||||
Parser.add_option("-l", "--log filename", action="store", type="string", dest="LogFile",
|
||||
help="Specify real execution log file")
|
||||
|
||||
Parser.add_option("-k", "--keepdatabase", action="store_true", type=None, help="The existing Eot database will not be cleaned except report information if this option is specified.")
|
||||
|
||||
Parser.add_option("-q", "--quiet", action="store_true", type=None, help="Disable all messages except FATAL ERRORS.")
|
||||
Parser.add_option("-v", "--verbose", action="store_true", type=None, help="Turn on verbose output with informational messages printed, "\
|
||||
"including library instances selected, final dependency expression, "\
|
||||
"and warning messages, etc.")
|
||||
Parser.add_option("-d", "--debug", action="store", type="int", help="Enable debug messages at specified level.")
|
||||
|
||||
(Opt, Args)=Parser.parse_args()
|
||||
|
||||
return (Opt, Args)
|
||||
|
||||
##
|
||||
#
|
||||
# This acts like the main() function for the script, unless it is 'import'ed into another
|
||||
# script.
|
||||
#
|
||||
if __name__ == '__main__':
|
||||
# Initialize log system
|
||||
EdkLogger.Initialize()
|
||||
EdkLogger.IsRaiseError = False
|
||||
EdkLogger.quiet(time.strftime("%H:%M:%S, %b.%d %Y ", time.localtime()) + "[00:00]" + "\n")
|
||||
|
||||
StartTime = time.clock()
|
||||
Eot = Eot()
|
||||
FinishTime = time.clock()
|
||||
|
||||
BuildDuration = time.strftime("%M:%S", time.gmtime(int(round(FinishTime - StartTime))))
|
||||
EdkLogger.quiet("\n%s [%s]" % (time.strftime("%H:%M:%S, %b.%d %Y", time.localtime()), BuildDuration))
|
138
BaseTools/Source/Python/Eot/EotGlobalData.py
Normal file
138
BaseTools/Source/Python/Eot/EotGlobalData.py
Normal file
@@ -0,0 +1,138 @@
|
||||
## @file
|
||||
# This file is used to save global datas
|
||||
#
|
||||
# Copyright (c) 2008 - 2010, 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
|
||||
# http://opensource.org/licenses/bsd-license.php
|
||||
#
|
||||
# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
|
||||
#
|
||||
|
||||
from Common.Misc import sdict
|
||||
|
||||
gEFI_SOURCE = ''
|
||||
gEDK_SOURCE = ''
|
||||
gWORKSPACE = ''
|
||||
gSHELL_INF = 'Application\Shell'
|
||||
gMAKE_FILE = ''
|
||||
gDSC_FILE = ''
|
||||
gFV_FILE = []
|
||||
gFV = []
|
||||
gMAP_FILE = []
|
||||
gMap = {}
|
||||
|
||||
|
||||
gDb = ''
|
||||
gIdentifierTableList = []
|
||||
|
||||
# Global macro
|
||||
gMACRO = {}
|
||||
gMACRO['EFI_SOURCE'] = gEFI_SOURCE
|
||||
gMACRO['EDK_SOURCE'] = gEDK_SOURCE
|
||||
gMACRO['SHELL_INF'] = gSHELL_INF
|
||||
gMACRO['CAPSULE_INF'] = ''
|
||||
|
||||
gNOT_FOUND_FILES = []
|
||||
gSOURCE_FILES = []
|
||||
gINF_FILES = {}
|
||||
gDEC_FILES = []
|
||||
|
||||
# Log file for unmatched variables
|
||||
gUN_MATCHED_LOG = 'Log_UnMatched.log'
|
||||
gOP_UN_MATCHED = open(gUN_MATCHED_LOG, 'w+')
|
||||
|
||||
# Log file for all INF files
|
||||
gINF_FILES = 'Log_Inf_File.log'
|
||||
gOP_INF = open(gINF_FILES, 'w+')
|
||||
|
||||
# Log file for not dispatched PEIM/DRIVER
|
||||
gUN_DISPATCHED_LOG = 'Log_UnDispatched.log'
|
||||
gOP_UN_DISPATCHED = open(gUN_DISPATCHED_LOG, 'w+')
|
||||
|
||||
# Log file for unmatched variables in function calling
|
||||
gUN_MATCHED_IN_LIBRARY_CALLING_LOG = 'Log_UnMatchedInLibraryCalling.log'
|
||||
gOP_UN_MATCHED_IN_LIBRARY_CALLING = open(gUN_MATCHED_IN_LIBRARY_CALLING_LOG, 'w+')
|
||||
|
||||
# Log file for order of dispatched PEIM/DRIVER
|
||||
gDISPATCH_ORDER_LOG = 'Log_DispatchOrder.log'
|
||||
gOP_DISPATCH_ORDER = open(gDISPATCH_ORDER_LOG, 'w+')
|
||||
|
||||
# Log file for source files not found
|
||||
gUN_FOUND_FILES = 'Log_UnFoundSourceFiles.log'
|
||||
gOP_UN_FOUND_FILES = open(gUN_FOUND_FILES, 'w+')
|
||||
|
||||
# Log file for found source files
|
||||
gSOURCE_FILES = 'Log_SourceFiles.log'
|
||||
gOP_SOURCE_FILES = open(gSOURCE_FILES, 'w+')
|
||||
|
||||
# Dict for GUID found in DEC files
|
||||
gGuidDict = sdict()
|
||||
|
||||
# Dict for hard coded GUID Macros
|
||||
# {GuidName : [GuidMacro : GuidValue]}
|
||||
gGuidMacroDict = sdict()
|
||||
|
||||
# Dict for PPI
|
||||
gPpiList = {}
|
||||
|
||||
# Dict for PROTOCOL
|
||||
gProtocolList = {}
|
||||
|
||||
# Dict for consumed PPI function calling
|
||||
gConsumedPpiLibrary = sdict()
|
||||
gConsumedPpiLibrary['EfiCommonLocateInterface'] = 0
|
||||
gConsumedPpiLibrary['PeiServicesLocatePpi'] = 0
|
||||
|
||||
# Dict for produced PROTOCOL function calling
|
||||
gProducedProtocolLibrary = sdict()
|
||||
gProducedProtocolLibrary['RegisterEsalClass'] = 0
|
||||
gProducedProtocolLibrary['CoreInstallProtocolInterface'] = 1
|
||||
gProducedProtocolLibrary['CoreInstallMultipleProtocolInterfaces'] = -1
|
||||
gProducedProtocolLibrary['EfiInstallProtocolInterface'] = 1
|
||||
gProducedProtocolLibrary['EfiReinstallProtocolInterface'] = 1
|
||||
gProducedProtocolLibrary['EfiLibNamedEventSignal'] = 0
|
||||
gProducedProtocolLibrary['LibInstallProtocolInterfaces'] = 1
|
||||
gProducedProtocolLibrary['LibReinstallProtocolInterfaces'] = 1
|
||||
|
||||
# Dict for consumed PROTOCOL function calling
|
||||
gConsumedProtocolLibrary = sdict()
|
||||
gConsumedProtocolLibrary['EfiHandleProtocol'] = 0
|
||||
gConsumedProtocolLibrary['EfiLocateProtocolHandleBuffers'] = 0
|
||||
gConsumedProtocolLibrary['EfiLocateProtocolInterface'] = 0
|
||||
gConsumedProtocolLibrary['EfiHandleProtocol'] = 1
|
||||
|
||||
# Dict for callback PROTOCOL function callling
|
||||
gCallbackProtocolLibrary = sdict()
|
||||
gCallbackProtocolLibrary['EfiRegisterProtocolCallback'] = 2
|
||||
|
||||
# Dict for ARCH PROTOCOL
|
||||
gArchProtocols = ['gEfiBdsArchProtocolGuid',
|
||||
'gEfiCapsuleArchProtocolGuid',
|
||||
'gEfiCpuArchProtocolGuid', #5053697e-2cbc-4819-90d9-0580deee5754
|
||||
'gEfiMetronomeArchProtocolGuid',
|
||||
'gEfiMonotonicCounterArchProtocolGuid',
|
||||
'gEfiRealTimeClockArchProtocolGuid',
|
||||
'gEfiResetArchProtocolGuid',
|
||||
'gEfiRuntimeArchProtocolGuid',
|
||||
'gEfiSecurityArchProtocolGuid',
|
||||
'gEfiStatusCodeRuntimeProtocolGuid',
|
||||
'gEfiTimerArchProtocolGuid',
|
||||
'gEfiVariableArchProtocolGuid',
|
||||
'gEfiVariableWriteArchProtocolGuid',
|
||||
'gEfiWatchdogTimerArchProtocolGuid']
|
||||
gArchProtocolGuids = ['665e3ff6-46cc-11d4-9a38-0090273fc14d',
|
||||
'26baccb1-6f42-11d4-bce7-0080c73c8881',
|
||||
'26baccb2-6f42-11d4-bce7-0080c73c8881',
|
||||
'1da97072-bddc-4b30-99f1-72a0b56fff2a',
|
||||
'27cfac87-46cc-11d4-9a38-0090273fc14d',
|
||||
'27cfac88-46cc-11d4-9a38-0090273fc14d',
|
||||
'b7dfb4e1-052f-449f-87be-9818fc91b733',
|
||||
'a46423e3-4617-49f1-b9ff-d1bfa9115839',
|
||||
'd2b2b828-0826-48a7-b3df-983c006024f0',
|
||||
'26baccb3-6f42-11d4-bce7-0080c73c8881',
|
||||
'1e5668e2-8481-11d4-bcf1-0080c73c8881',
|
||||
'6441f818-6362-4e44-b570-7dba31dd2453',
|
||||
'665e3ff5-46cc-11d4-9a38-0090273fc14d']
|
21
BaseTools/Source/Python/Eot/EotToolError.py
Normal file
21
BaseTools/Source/Python/Eot/EotToolError.py
Normal file
@@ -0,0 +1,21 @@
|
||||
## @file
|
||||
# Standardized Error Handling infrastructures.
|
||||
#
|
||||
# Copyright (c) 2008 - 2010, 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
|
||||
# http://opensource.org/licenses/bsd-license.php
|
||||
#
|
||||
# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
|
||||
#
|
||||
|
||||
# Error id
|
||||
ERROR_1 = 1000
|
||||
|
||||
# Error message
|
||||
gEccErrorMessage = {
|
||||
ERROR_1 : "RESERVED"
|
||||
}
|
||||
|
58
BaseTools/Source/Python/Eot/FileProfile.py
Normal file
58
BaseTools/Source/Python/Eot/FileProfile.py
Normal file
@@ -0,0 +1,58 @@
|
||||
## @file
|
||||
# fragments of source file
|
||||
#
|
||||
# Copyright (c) 2007 - 2010, 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
|
||||
# http://opensource.org/licenses/bsd-license.php
|
||||
#
|
||||
# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
|
||||
#
|
||||
|
||||
##
|
||||
# Import Modules
|
||||
#
|
||||
|
||||
import re
|
||||
import os
|
||||
from ParserWarning import Warning
|
||||
|
||||
# Profile contents of a file
|
||||
PPDirectiveList = []
|
||||
AssignmentExpressionList = []
|
||||
PredicateExpressionList = []
|
||||
FunctionDefinitionList = []
|
||||
VariableDeclarationList = []
|
||||
EnumerationDefinitionList = []
|
||||
StructUnionDefinitionList = []
|
||||
TypedefDefinitionList = []
|
||||
FunctionCallingList = []
|
||||
|
||||
## Class FileProfile
|
||||
#
|
||||
# record file data when parsing source
|
||||
#
|
||||
# May raise Exception when opening file.
|
||||
#
|
||||
class FileProfile :
|
||||
|
||||
## The constructor
|
||||
#
|
||||
# @param self: The object pointer
|
||||
# @param FileName: The file that to be parsed
|
||||
#
|
||||
def __init__(self, FileName):
|
||||
self.FileLinesList = []
|
||||
self.FileLinesListFromFile = []
|
||||
try:
|
||||
fsock = open(FileName, "rb", 0)
|
||||
try:
|
||||
self.FileLinesListFromFile = fsock.readlines()
|
||||
finally:
|
||||
fsock.close()
|
||||
|
||||
except IOError:
|
||||
raise Warning("Error when opening file %s" % FileName)
|
1453
BaseTools/Source/Python/Eot/FvImage.py
Normal file
1453
BaseTools/Source/Python/Eot/FvImage.py
Normal file
File diff suppressed because it is too large
Load Diff
171
BaseTools/Source/Python/Eot/InfParserLite.py
Normal file
171
BaseTools/Source/Python/Eot/InfParserLite.py
Normal file
@@ -0,0 +1,171 @@
|
||||
## @file
|
||||
# This file is used to parse INF file of EDK project
|
||||
#
|
||||
# Copyright (c) 2008 - 2010 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
|
||||
# http://opensource.org/licenses/bsd-license.php
|
||||
#
|
||||
# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
|
||||
#
|
||||
|
||||
##
|
||||
# Import Modules
|
||||
#
|
||||
import os
|
||||
import Common.EdkLogger as EdkLogger
|
||||
from Common.DataType import *
|
||||
from CommonDataClass.DataClass import *
|
||||
from Common.Identification import *
|
||||
from Common.String import *
|
||||
from Parser import *
|
||||
import Database
|
||||
|
||||
## EdkInfParser() class
|
||||
#
|
||||
# This class defined basic INF object which is used by inheriting
|
||||
#
|
||||
# @param object: Inherited from object class
|
||||
#
|
||||
class EdkInfParser(object):
|
||||
## The constructor
|
||||
#
|
||||
# @param self: The object pointer
|
||||
# @param Filename: INF file name
|
||||
# @param Database: Eot database
|
||||
# @param SourceFileList: A list for all source file belonging this INF file
|
||||
# @param SourceOverridePath: Override path for source file
|
||||
# @param Edk_Source: Envirnoment variable EDK_SOURCE
|
||||
# @param Efi_Source: Envirnoment variable EFI_SOURCE
|
||||
#
|
||||
def __init__(self, Filename = None, Database = None, SourceFileList = None, SourceOverridePath = None, Edk_Source = None, Efi_Source = None):
|
||||
self.Identification = Identification()
|
||||
self.Sources = []
|
||||
self.Macros = {}
|
||||
|
||||
self.Cur = Database.Cur
|
||||
self.TblFile = Database.TblFile
|
||||
self.TblInf = Database.TblInf
|
||||
self.FileID = -1
|
||||
self.SourceOverridePath = SourceOverridePath
|
||||
|
||||
# Load Inf file if filename is not None
|
||||
if Filename != None:
|
||||
self.LoadInfFile(Filename)
|
||||
|
||||
if SourceFileList:
|
||||
for Item in SourceFileList:
|
||||
self.TblInf.Insert(MODEL_EFI_SOURCE_FILE, Item, '', '', '', '', 'COMMON', -1, self.FileID, -1, -1, -1, -1, 0)
|
||||
|
||||
|
||||
## LoadInffile() method
|
||||
#
|
||||
# Load INF file and insert a record in database
|
||||
#
|
||||
# @param self: The object pointer
|
||||
# @param Filename: Input value for filename of Inf file
|
||||
#
|
||||
def LoadInfFile(self, Filename = None):
|
||||
# Insert a record for file
|
||||
Filename = NormPath(Filename)
|
||||
self.Identification.FileFullPath = Filename
|
||||
(self.Identification.FileRelativePath, self.Identification.FileName) = os.path.split(Filename)
|
||||
|
||||
self.FileID = self.TblFile.InsertFile(Filename, MODEL_FILE_INF)
|
||||
|
||||
self.ParseInf(PreProcess(Filename, False), self.Identification.FileRelativePath, Filename)
|
||||
|
||||
## ParserSource() method
|
||||
#
|
||||
# Parse Source section and insert records in database
|
||||
#
|
||||
# @param self: The object pointer
|
||||
# @param CurrentSection: current section name
|
||||
# @param SectionItemList: the item belonging current section
|
||||
# @param ArchList: A list for arch for this section
|
||||
# @param ThirdList: A list for third item for this section
|
||||
#
|
||||
def ParserSource(self, CurrentSection, SectionItemList, ArchList, ThirdList):
|
||||
for Index in range(0, len(ArchList)):
|
||||
Arch = ArchList[Index]
|
||||
Third = ThirdList[Index]
|
||||
if Arch == '':
|
||||
Arch = TAB_ARCH_COMMON
|
||||
|
||||
for Item in SectionItemList:
|
||||
if CurrentSection.upper() == 'defines'.upper():
|
||||
(Name, Value) = AddToSelfMacro(self.Macros, Item[0])
|
||||
self.TblInf.Insert(MODEL_META_DATA_HEADER, Name, Value, Third, '', '', Arch, -1, self.FileID, Item[1], -1, Item[1], -1, 0)
|
||||
|
||||
## ParseInf() method
|
||||
#
|
||||
# Parse INF file and get sections information
|
||||
#
|
||||
# @param self: The object pointer
|
||||
# @param Lines: contents of INF file
|
||||
# @param FileRelativePath: relative path of the file
|
||||
# @param Filename: file name of INF file
|
||||
#
|
||||
def ParseInf(self, Lines = [], FileRelativePath = '', Filename = ''):
|
||||
IfDefList, SectionItemList, CurrentSection, ArchList, ThirdList, IncludeFiles = \
|
||||
[], [], TAB_UNKNOWN, [], [], []
|
||||
LineNo = 0
|
||||
|
||||
for Line in Lines:
|
||||
LineNo = LineNo + 1
|
||||
if Line == '':
|
||||
continue
|
||||
if Line.startswith(TAB_SECTION_START) and Line.endswith(TAB_SECTION_END):
|
||||
self.ParserSource(CurrentSection, SectionItemList, ArchList, ThirdList)
|
||||
|
||||
# Parse the new section
|
||||
SectionItemList = []
|
||||
ArchList = []
|
||||
ThirdList = []
|
||||
# Parse section name
|
||||
CurrentSection = ''
|
||||
LineList = GetSplitValueList(Line[len(TAB_SECTION_START):len(Line) - len(TAB_SECTION_END)], TAB_COMMA_SPLIT)
|
||||
for Item in LineList:
|
||||
ItemList = GetSplitValueList(Item, TAB_SPLIT)
|
||||
if CurrentSection == '':
|
||||
CurrentSection = ItemList[0]
|
||||
else:
|
||||
if CurrentSection != ItemList[0]:
|
||||
EdkLogger.error("Parser", PARSER_ERROR, "Different section names '%s' and '%s' are found in one section definition, this is not allowed." % (CurrentSection, ItemList[0]), File=Filename, Line=LineNo)
|
||||
ItemList.append('')
|
||||
ItemList.append('')
|
||||
if len(ItemList) > 5:
|
||||
RaiseParserError(Line, CurrentSection, Filename, '', LineNo)
|
||||
else:
|
||||
ArchList.append(ItemList[1].upper())
|
||||
ThirdList.append(ItemList[2])
|
||||
|
||||
continue
|
||||
|
||||
# Add a section item
|
||||
SectionItemList.append([Line, LineNo])
|
||||
# End of parse
|
||||
|
||||
self.ParserSource(CurrentSection, SectionItemList, ArchList, ThirdList)
|
||||
#End of For
|
||||
|
||||
##
|
||||
#
|
||||
# This acts like the main() function for the script, unless it is 'import'ed into another
|
||||
# script.
|
||||
#
|
||||
if __name__ == '__main__':
|
||||
EdkLogger.Initialize()
|
||||
EdkLogger.SetLevel(EdkLogger.QUIET)
|
||||
|
||||
Db = Database.Database('Inf.db')
|
||||
Db.InitDatabase()
|
||||
P = EdkInfParser(os.path.normpath("C:\Framework\Edk\Sample\Platform\Nt32\Dxe\PlatformBds\PlatformBds.inf"), Db, '', '')
|
||||
for Inf in P.Sources:
|
||||
print Inf
|
||||
for Item in P.Macros:
|
||||
print Item, P.Macros[Item]
|
||||
|
||||
Db.Close()
|
BIN
BaseTools/Source/Python/Eot/LzmaCompressor.pyd
Normal file
BIN
BaseTools/Source/Python/Eot/LzmaCompressor.pyd
Normal file
Binary file not shown.
848
BaseTools/Source/Python/Eot/Parser.py
Normal file
848
BaseTools/Source/Python/Eot/Parser.py
Normal file
@@ -0,0 +1,848 @@
|
||||
## @file
|
||||
# This file is used to define common parsing related functions used in parsing
|
||||
# Inf/Dsc/Makefile process
|
||||
#
|
||||
# Copyright (c) 2008 - 2010, 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
|
||||
# http://opensource.org/licenses/bsd-license.php
|
||||
#
|
||||
# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
|
||||
#
|
||||
|
||||
##
|
||||
# Import Modules
|
||||
#
|
||||
import os, re
|
||||
import Common.EdkLogger as EdkLogger
|
||||
from Common.DataType import *
|
||||
from CommonDataClass.DataClass import *
|
||||
from Common.String import CleanString, GetSplitValueList, ReplaceMacro
|
||||
import EotGlobalData
|
||||
from Common.Misc import sdict
|
||||
|
||||
## PreProcess() method
|
||||
#
|
||||
# Pre process a file
|
||||
#
|
||||
# 1. Remove all comments
|
||||
# 2. Merge multiple lines code to one line
|
||||
#
|
||||
# @param Filename: Name of the file to be parsed
|
||||
# @param MergeMultipleLines: Switch for if merge multiple lines
|
||||
# @param LineNo: Default line no
|
||||
#
|
||||
# @return Lines: The file contents after remvoing comments
|
||||
#
|
||||
def PreProcess(Filename, MergeMultipleLines = True, LineNo = -1):
|
||||
Lines = []
|
||||
Filename = os.path.normpath(Filename)
|
||||
if not os.path.isfile(Filename):
|
||||
EdkLogger.error("Eot", EdkLogger.FILE_NOT_FOUND, ExtraData=Filename)
|
||||
|
||||
IsFindBlockComment = False
|
||||
IsFindBlockCode = False
|
||||
ReservedLine = ''
|
||||
ReservedLineLength = 0
|
||||
for Line in open(Filename, 'r'):
|
||||
Line = Line.strip()
|
||||
# Remove comment block
|
||||
if Line.find(TAB_COMMENT_R8_START) > -1:
|
||||
ReservedLine = GetSplitValueList(Line, TAB_COMMENT_R8_START, 1)[0]
|
||||
IsFindBlockComment = True
|
||||
if Line.find(TAB_COMMENT_R8_END) > -1:
|
||||
Line = ReservedLine + GetSplitValueList(Line, TAB_COMMENT_R8_END, 1)[1]
|
||||
ReservedLine = ''
|
||||
IsFindBlockComment = False
|
||||
if IsFindBlockComment:
|
||||
Lines.append('')
|
||||
continue
|
||||
|
||||
# Remove comments at tail and remove spaces again
|
||||
Line = CleanString(Line)
|
||||
if Line == '':
|
||||
Lines.append('')
|
||||
continue
|
||||
|
||||
if MergeMultipleLines:
|
||||
# Add multiple lines to one line
|
||||
if IsFindBlockCode and Line[-1] != TAB_SLASH:
|
||||
ReservedLine = (ReservedLine + TAB_SPACE_SPLIT + Line).strip()
|
||||
Lines.append(ReservedLine)
|
||||
for Index in (0, ReservedLineLength):
|
||||
Lines.append('')
|
||||
ReservedLine = ''
|
||||
ReservedLineLength = 0
|
||||
IsFindBlockCode = False
|
||||
continue
|
||||
if Line[-1] == TAB_SLASH:
|
||||
ReservedLine = ReservedLine + TAB_SPACE_SPLIT + Line[0:-1].strip()
|
||||
ReservedLineLength = ReservedLineLength + 1
|
||||
IsFindBlockCode = True
|
||||
continue
|
||||
|
||||
Lines.append(Line)
|
||||
|
||||
return Lines
|
||||
|
||||
## AddToGlobalMacro() method
|
||||
#
|
||||
# Add a macro to EotGlobalData.gMACRO
|
||||
#
|
||||
# @param Name: Name of the macro
|
||||
# @param Value: Value of the macro
|
||||
#
|
||||
def AddToGlobalMacro(Name, Value):
|
||||
Value = ReplaceMacro(Value, EotGlobalData.gMACRO, True)
|
||||
EotGlobalData.gMACRO[Name] = Value
|
||||
|
||||
## AddToSelfMacro() method
|
||||
#
|
||||
# Parse a line of macro definition and add it to a macro set
|
||||
#
|
||||
# @param SelfMacro: The self macro set
|
||||
# @param Line: The line of a macro definition
|
||||
#
|
||||
# @return Name: Name of macro
|
||||
# @return Value: Value of macro
|
||||
#
|
||||
def AddToSelfMacro(SelfMacro, Line):
|
||||
Name, Value = '', ''
|
||||
List = GetSplitValueList(Line, TAB_EQUAL_SPLIT, 1)
|
||||
if len(List) == 2:
|
||||
Name = List[0]
|
||||
Value = List[1]
|
||||
Value = ReplaceMacro(Value, EotGlobalData.gMACRO, True)
|
||||
Value = ReplaceMacro(Value, SelfMacro, True)
|
||||
SelfMacro[Name] = Value
|
||||
|
||||
return (Name, Value)
|
||||
|
||||
## GetIncludeListOfFile() method
|
||||
#
|
||||
# Get the include path list for a source file
|
||||
#
|
||||
# 1. Find the source file belongs to which INF file
|
||||
# 2. Find the inf's package
|
||||
# 3. Return the include path list of the package
|
||||
#
|
||||
# @param WorkSpace: WORKSPACE path
|
||||
# @param Filepath: File path
|
||||
# @param Db: Eot database
|
||||
#
|
||||
# @return IncludeList: A list of include directories
|
||||
#
|
||||
def GetIncludeListOfFile(WorkSpace, Filepath, Db):
|
||||
IncludeList = []
|
||||
Filepath = os.path.normpath(Filepath)
|
||||
SqlCommand = """
|
||||
select Value1 from Inf where Model = %s and BelongsToFile in(
|
||||
select distinct B.BelongsToFile from File as A left join Inf as B
|
||||
where A.ID = B.BelongsToFile and B.Model = %s and (A.Path || '%s' || B.Value1) = '%s')""" \
|
||||
% (MODEL_META_DATA_PACKAGE, MODEL_EFI_SOURCE_FILE, '\\', Filepath)
|
||||
RecordSet = Db.TblFile.Exec(SqlCommand)
|
||||
for Record in RecordSet:
|
||||
DecFullPath = os.path.normpath(os.path.join(WorkSpace, Record[0]))
|
||||
(DecPath, DecName) = os.path.split(DecFullPath)
|
||||
SqlCommand = """select Value1 from Dec where BelongsToFile =
|
||||
(select ID from File where FullPath = '%s') and Model = %s""" \
|
||||
% (DecFullPath, MODEL_EFI_INCLUDE)
|
||||
NewRecordSet = Db.TblDec.Exec(SqlCommand)
|
||||
for NewRecord in NewRecordSet:
|
||||
IncludePath = os.path.normpath(os.path.join(DecPath, NewRecord[0]))
|
||||
if IncludePath not in IncludeList:
|
||||
IncludeList.append(IncludePath)
|
||||
|
||||
return IncludeList
|
||||
|
||||
## GetTableList() method
|
||||
#
|
||||
# Search table file and find all small tables
|
||||
#
|
||||
# @param FileModelList: Model code for the file list
|
||||
# @param Table: Table to insert records
|
||||
# @param Db: Eot database
|
||||
#
|
||||
# @return TableList: A list of tables
|
||||
#
|
||||
def GetTableList(FileModelList, Table, Db):
|
||||
TableList = []
|
||||
SqlCommand = """select ID, FullPath from File where Model in %s""" % str(FileModelList)
|
||||
RecordSet = Db.TblFile.Exec(SqlCommand)
|
||||
for Record in RecordSet:
|
||||
TableName = Table + str(Record[0])
|
||||
TableList.append([TableName, Record[1]])
|
||||
|
||||
return TableList
|
||||
|
||||
## GetAllIncludeDir() method
|
||||
#
|
||||
# Find all Include directories
|
||||
#
|
||||
# @param Db: Eot database
|
||||
#
|
||||
# @return IncludeList: A list of include directories
|
||||
#
|
||||
def GetAllIncludeDirs(Db):
|
||||
IncludeList = []
|
||||
SqlCommand = """select distinct Value1 from Inf where Model = %s order by Value1""" % MODEL_EFI_INCLUDE
|
||||
RecordSet = Db.TblInf.Exec(SqlCommand)
|
||||
|
||||
for Record in RecordSet:
|
||||
IncludeList.append(Record[0])
|
||||
|
||||
return IncludeList
|
||||
|
||||
## GetAllIncludeFiles() method
|
||||
#
|
||||
# Find all Include files
|
||||
#
|
||||
# @param Db: Eot database
|
||||
#
|
||||
# @return IncludeFileList: A list of include files
|
||||
#
|
||||
def GetAllIncludeFiles(Db):
|
||||
IncludeList = GetAllIncludeDirs(Db)
|
||||
IncludeFileList = []
|
||||
|
||||
for Dir in IncludeList:
|
||||
if os.path.isdir(Dir):
|
||||
SubDir = os.listdir(Dir)
|
||||
for Item in SubDir:
|
||||
if os.path.isfile(Item):
|
||||
IncludeFileList.append(Item)
|
||||
|
||||
return IncludeFileList
|
||||
|
||||
## GetAllSourceFiles() method
|
||||
#
|
||||
# Find all source files
|
||||
#
|
||||
# @param Db: Eot database
|
||||
#
|
||||
# @return SourceFileList: A list of source files
|
||||
#
|
||||
def GetAllSourceFiles(Db):
|
||||
SourceFileList = []
|
||||
SqlCommand = """select distinct Value1 from Inf where Model = %s order by Value1""" % MODEL_EFI_SOURCE_FILE
|
||||
RecordSet = Db.TblInf.Exec(SqlCommand)
|
||||
|
||||
for Record in RecordSet:
|
||||
SourceFileList.append(Record[0])
|
||||
|
||||
return SourceFileList
|
||||
|
||||
## GetAllFiles() method
|
||||
#
|
||||
# Find all files, both source files and include files
|
||||
#
|
||||
# @param Db: Eot database
|
||||
#
|
||||
# @return FileList: A list of files
|
||||
#
|
||||
def GetAllFiles(Db):
|
||||
FileList = []
|
||||
IncludeFileList = GetAllIncludeFiles(Db)
|
||||
SourceFileList = GetAllSourceFiles(Db)
|
||||
for Item in IncludeFileList:
|
||||
if os.path.isfile(Item) and Item not in FileList:
|
||||
FileList.append(Item)
|
||||
for Item in SourceFileList:
|
||||
if os.path.isfile(Item) and Item not in FileList:
|
||||
FileList.append(Item)
|
||||
|
||||
return FileList
|
||||
|
||||
## ParseConditionalStatement() method
|
||||
#
|
||||
# Parse conditional statement
|
||||
#
|
||||
# @param Line: One line to be parsed
|
||||
# @param Macros: A set of all macro
|
||||
# @param StatusSet: A set of all status
|
||||
#
|
||||
# @retval True: Find keyword of conditional statement
|
||||
# @retval False: Not find keyword of conditional statement
|
||||
#
|
||||
def ParseConditionalStatement(Line, Macros, StatusSet):
|
||||
NewLine = Line.upper()
|
||||
if NewLine.find(TAB_IF_EXIST.upper()) > -1:
|
||||
IfLine = Line[NewLine.find(TAB_IF_EXIST) + len(TAB_IF_EXIST) + 1:].strip()
|
||||
IfLine = ReplaceMacro(IfLine, EotGlobalData.gMACRO, True)
|
||||
IfLine = ReplaceMacro(IfLine, Macros, True)
|
||||
IfLine = IfLine.replace("\"", '')
|
||||
IfLine = IfLine.replace("(", '')
|
||||
IfLine = IfLine.replace(")", '')
|
||||
Status = os.path.exists(os.path.normpath(IfLine))
|
||||
StatusSet.append([Status])
|
||||
return True
|
||||
if NewLine.find(TAB_IF_DEF.upper()) > -1:
|
||||
IfLine = Line[NewLine.find(TAB_IF_DEF) + len(TAB_IF_DEF) + 1:].strip()
|
||||
Status = False
|
||||
if IfLine in Macros or IfLine in EotGlobalData.gMACRO:
|
||||
Status = True
|
||||
StatusSet.append([Status])
|
||||
return True
|
||||
if NewLine.find(TAB_IF_N_DEF.upper()) > -1:
|
||||
IfLine = Line[NewLine.find(TAB_IF_N_DEF) + len(TAB_IF_N_DEF) + 1:].strip()
|
||||
Status = False
|
||||
if IfLine not in Macros and IfLine not in EotGlobalData.gMACRO:
|
||||
Status = True
|
||||
StatusSet.append([Status])
|
||||
return True
|
||||
if NewLine.find(TAB_IF.upper()) > -1:
|
||||
IfLine = Line[NewLine.find(TAB_IF) + len(TAB_IF) + 1:].strip()
|
||||
Status = ParseConditionalStatementMacros(IfLine, Macros)
|
||||
StatusSet.append([Status])
|
||||
return True
|
||||
if NewLine.find(TAB_ELSE_IF.upper()) > -1:
|
||||
IfLine = Line[NewLine.find(TAB_ELSE_IF) + len(TAB_ELSE_IF) + 1:].strip()
|
||||
Status = ParseConditionalStatementMacros(IfLine, Macros)
|
||||
StatusSet[-1].append(Status)
|
||||
return True
|
||||
if NewLine.find(TAB_ELSE.upper()) > -1:
|
||||
Status = False
|
||||
for Item in StatusSet[-1]:
|
||||
Status = Status or Item
|
||||
StatusSet[-1].append(not Status)
|
||||
return True
|
||||
if NewLine.find(TAB_END_IF.upper()) > -1:
|
||||
StatusSet.pop()
|
||||
return True
|
||||
|
||||
return False
|
||||
|
||||
## ParseConditionalStatement() method
|
||||
#
|
||||
# Parse conditional statement with Macros
|
||||
#
|
||||
# @param Line: One line to be parsed
|
||||
# @param Macros: A set of macros
|
||||
#
|
||||
# @return Line: New line after replacing macros
|
||||
#
|
||||
def ParseConditionalStatementMacros(Line, Macros):
|
||||
if Line.upper().find('DEFINED(') > -1 or Line.upper().find('EXIST') > -1:
|
||||
return False
|
||||
Line = ReplaceMacro(Line, EotGlobalData.gMACRO, True)
|
||||
Line = ReplaceMacro(Line, Macros, True)
|
||||
Line = Line.replace("&&", "and")
|
||||
Line = Line.replace("||", "or")
|
||||
return eval(Line)
|
||||
|
||||
## GetConditionalStatementStatus() method
|
||||
#
|
||||
# 1. Assume the latest status as True
|
||||
# 2. Pop the top status of status set, previous status
|
||||
# 3. Compare the latest one and the previous one and get new status
|
||||
#
|
||||
# @param StatusSet: A set of all status
|
||||
#
|
||||
# @return Status: The final status
|
||||
#
|
||||
def GetConditionalStatementStatus(StatusSet):
|
||||
Status = True
|
||||
for Item in StatusSet:
|
||||
Status = Status and Item[-1]
|
||||
|
||||
return Status
|
||||
|
||||
## SearchBelongsToFunction() method
|
||||
#
|
||||
# Search all functions belong to the file
|
||||
#
|
||||
# @param BelongsToFile: File id
|
||||
# @param StartLine: Start line of search scope
|
||||
# @param EndLine: End line of search scope
|
||||
#
|
||||
# @return: The found function
|
||||
#
|
||||
def SearchBelongsToFunction(BelongsToFile, StartLine, EndLine):
|
||||
SqlCommand = """select ID, Name from Function where BelongsToFile = %s and StartLine <= %s and EndLine >= %s""" %(BelongsToFile, StartLine, EndLine)
|
||||
RecordSet = EotGlobalData.gDb.TblFunction.Exec(SqlCommand)
|
||||
if RecordSet != []:
|
||||
return RecordSet[0][0], RecordSet[0][1]
|
||||
else:
|
||||
return -1, ''
|
||||
|
||||
## SearchPpiCallFunction() method
|
||||
#
|
||||
# Search all used PPI calling function 'PeiServicesReInstallPpi' and 'PeiServicesInstallPpi'
|
||||
# Store the result to database
|
||||
#
|
||||
# @param Identifier: Table id
|
||||
# @param SourceFileID: Source file id
|
||||
# @param SourceFileFullPath: Source file full path
|
||||
# @param ItemMode: Mode of the item
|
||||
#
|
||||
def SearchPpiCallFunction(Identifier, SourceFileID, SourceFileFullPath, ItemMode):
|
||||
ItemName, ItemType, GuidName, GuidMacro, GuidValue = '', 'Ppi', '', '', ''
|
||||
SqlCommand = """select Value, Name, BelongsToFile, StartLine, EndLine from %s
|
||||
where (Name like '%%%s%%' and Model = %s)""" \
|
||||
% (Identifier, 'PeiServicesReInstallPpi', MODEL_IDENTIFIER_FUNCTION_CALLING)
|
||||
BelongsToFunctionID, BelongsToFunction = -1, ''
|
||||
Db = EotGlobalData.gDb.TblReport
|
||||
RecordSet = Db.Exec(SqlCommand)
|
||||
for Record in RecordSet:
|
||||
Index = 0
|
||||
BelongsToFile, StartLine, EndLine = Record[2], Record[3], Record[4]
|
||||
BelongsToFunctionID, BelongsToFunction = SearchBelongsToFunction(BelongsToFile, StartLine, EndLine)
|
||||
VariableList = Record[0].split(',')
|
||||
for Variable in VariableList:
|
||||
Variable = Variable.strip()
|
||||
# Get index of the variable
|
||||
if Variable.find('[') > -1:
|
||||
Index = int(Variable[Variable.find('[') + 1 : Variable.find(']')])
|
||||
Variable = Variable[:Variable.find('[')]
|
||||
# Get variable name
|
||||
if Variable.startswith('&'):
|
||||
Variable = Variable[1:]
|
||||
# Get variable value
|
||||
SqlCommand = """select Value from %s where (Name like '%%%s%%') and Model = %s""" \
|
||||
% (Identifier, Variable, MODEL_IDENTIFIER_VARIABLE)
|
||||
NewRecordSet = Db.Exec(SqlCommand)
|
||||
if NewRecordSet:
|
||||
NewRecord = NewRecordSet[0][0]
|
||||
VariableValueList = NewRecord.split('},')
|
||||
if len(VariableValueList) > Index:
|
||||
VariableValue = VariableValueList[Index]
|
||||
NewVariableValueList = VariableValue.split(',')
|
||||
if len(NewVariableValueList) > 1:
|
||||
NewVariableValue = NewVariableValueList[1].strip()
|
||||
if NewVariableValue.startswith('&'):
|
||||
Db.Insert(-1, '', '', SourceFileID, SourceFileFullPath, ItemName, ItemType, ItemMode, NewVariableValue[1:], GuidMacro, GuidValue, BelongsToFunction, 0)
|
||||
continue
|
||||
else:
|
||||
EotGlobalData.gOP_UN_MATCHED.write('%s, %s, %s, %s, %s, %s\n' % (ItemType, ItemMode, SourceFileID, SourceFileFullPath, StartLine, NewParameter))
|
||||
|
||||
ItemName, ItemType, GuidName, GuidMacro, GuidValue = '', 'Ppi', '', '', ''
|
||||
SqlCommand = """select Value, Name, BelongsToFile, StartLine, EndLine from %s
|
||||
where (Value like '%%%s%%' and Model = %s)""" \
|
||||
% (Identifier, 'PeiServicesInstallPpi', MODEL_IDENTIFIER_ASSIGNMENT_EXPRESSION)
|
||||
BelongsToFunctionID, BelongsToFunction = -1, ''
|
||||
Db = EotGlobalData.gDb.TblReport
|
||||
RecordSet = Db.Exec(SqlCommand)
|
||||
|
||||
SqlCommand = """select Value, Name, BelongsToFile, StartLine, EndLine from %s
|
||||
where (Name like '%%%s%%' and Model = %s)""" \
|
||||
% (Identifier, 'PeiServicesInstallPpi', MODEL_IDENTIFIER_FUNCTION_CALLING)
|
||||
Db = EotGlobalData.gDb.TblReport
|
||||
RecordSet2 = Db.Exec(SqlCommand)
|
||||
|
||||
for Record in RecordSet + RecordSet2:
|
||||
if Record == []:
|
||||
continue
|
||||
Index = 0
|
||||
BelongsToFile, StartLine, EndLine = Record[2], Record[3], Record[4]
|
||||
BelongsToFunctionID, BelongsToFunction = SearchBelongsToFunction(BelongsToFile, StartLine, EndLine)
|
||||
Variable = Record[0].replace('PeiServicesInstallPpi', '').replace('(', '').replace(')', '').replace('&', '').strip()
|
||||
Variable = Variable[Variable.find(',') + 1:].strip()
|
||||
# Get index of the variable
|
||||
if Variable.find('[') > -1:
|
||||
Index = int(Variable[Variable.find('[') + 1 : Variable.find(']')])
|
||||
Variable = Variable[:Variable.find('[')]
|
||||
# Get variable name
|
||||
if Variable.startswith('&'):
|
||||
Variable = Variable[1:]
|
||||
# Get variable value
|
||||
SqlCommand = """select Value from %s where (Name like '%%%s%%') and Model = %s""" \
|
||||
% (Identifier, Variable, MODEL_IDENTIFIER_VARIABLE)
|
||||
NewRecordSet = Db.Exec(SqlCommand)
|
||||
if NewRecordSet:
|
||||
NewRecord = NewRecordSet[0][0]
|
||||
VariableValueList = NewRecord.split('},')
|
||||
if len(VariableValueList) > Index:
|
||||
VariableValue = VariableValueList[Index]
|
||||
NewVariableValueList = VariableValue.split(',')
|
||||
if len(NewVariableValueList) > 1:
|
||||
NewVariableValue = NewVariableValueList[1].strip()
|
||||
if NewVariableValue.startswith('&'):
|
||||
Db.Insert(-1, '', '', SourceFileID, SourceFileFullPath, ItemName, ItemType, ItemMode, NewVariableValue[1:], GuidMacro, GuidValue, BelongsToFunction, 0)
|
||||
continue
|
||||
else:
|
||||
EotGlobalData.gOP_UN_MATCHED.write('%s, %s, %s, %s, %s, %s\n' % (ItemType, ItemMode, SourceFileID, SourceFileFullPath, StartLine, NewParameter))
|
||||
|
||||
## SearchPpis() method
|
||||
#
|
||||
# Search all used PPI calling function
|
||||
# Store the result to database
|
||||
#
|
||||
# @param SqlCommand: SQL command statement
|
||||
# @param Table: Table id
|
||||
# @param SourceFileID: Source file id
|
||||
# @param SourceFileFullPath: Source file full path
|
||||
# @param ItemMode: Mode of the item
|
||||
# @param PpiMode: Mode of PPI
|
||||
#
|
||||
def SearchPpi(SqlCommand, Table, SourceFileID, SourceFileFullPath, ItemMode, PpiMode = 1):
|
||||
ItemName, ItemType, GuidName, GuidMacro, GuidValue = '', 'Ppi', '', '', ''
|
||||
BelongsToFunctionID, BelongsToFunction = -1, ''
|
||||
Db = EotGlobalData.gDb.TblReport
|
||||
RecordSet = Db.Exec(SqlCommand)
|
||||
for Record in RecordSet:
|
||||
Parameter = GetPpiParameter(Record[0], PpiMode)
|
||||
BelongsToFile, StartLine, EndLine = Record[2], Record[3], Record[4]
|
||||
# Get BelongsToFunction
|
||||
BelongsToFunctionID, BelongsToFunction = SearchBelongsToFunction(BelongsToFile, StartLine, EndLine)
|
||||
|
||||
# Default is Not Found
|
||||
IsFound = False
|
||||
|
||||
# For Consumed Ppi
|
||||
if ItemMode == 'Consumed':
|
||||
if Parameter.startswith('g'):
|
||||
Db.Insert(-1, '', '', SourceFileID, SourceFileFullPath, ItemName, ItemType, ItemMode, Parameter, GuidMacro, GuidValue, BelongsToFunction, 0)
|
||||
else:
|
||||
EotGlobalData.gOP_UN_MATCHED.write('%s, %s, %s, %s, %s, %s\n' % (ItemType, ItemMode, SourceFileID, SourceFileFullPath, StartLine, Parameter))
|
||||
continue
|
||||
|
||||
# Direct Parameter.Guid
|
||||
SqlCommand = """select Value from %s where (Name like '%%%s.Guid%%' or Name like '%%%s->Guid%%') and Model = %s""" % (Table, Parameter, Parameter, MODEL_IDENTIFIER_ASSIGNMENT_EXPRESSION)
|
||||
NewRecordSet = Db.Exec(SqlCommand)
|
||||
for NewRecord in NewRecordSet:
|
||||
GuidName = GetParameterName(NewRecord[0])
|
||||
Db.Insert(-1, '', '', SourceFileID, SourceFileFullPath, ItemName, ItemType, ItemMode, GuidName, GuidMacro, GuidValue, BelongsToFunction, 0)
|
||||
IsFound = True
|
||||
|
||||
# Defined Parameter
|
||||
if not IsFound:
|
||||
Key = Parameter
|
||||
if Key.rfind(' ') > -1:
|
||||
Key = Key[Key.rfind(' ') : ].strip().replace('&', '')
|
||||
Value = FindKeyValue(EotGlobalData.gDb.TblFile, Table, Key)
|
||||
List = GetSplitValueList(Value.replace('\n', ''), TAB_COMMA_SPLIT)
|
||||
if len(List) > 1:
|
||||
GuidName = GetParameterName(List[1])
|
||||
Db.Insert(-1, '', '', SourceFileID, SourceFileFullPath, ItemName, ItemType, ItemMode, GuidName, GuidMacro, GuidValue, BelongsToFunction, 0)
|
||||
IsFound = True
|
||||
|
||||
# A list Parameter
|
||||
if not IsFound:
|
||||
Start = Parameter.find('[')
|
||||
End = Parameter.find(']')
|
||||
if Start > -1 and End > -1 and Start < End:
|
||||
try:
|
||||
Index = int(Parameter[Start + 1 : End])
|
||||
Parameter = Parameter[0 : Start]
|
||||
SqlCommand = """select Value from %s where Name = '%s' and Model = %s""" % (Table, Parameter, MODEL_IDENTIFIER_VARIABLE)
|
||||
NewRecordSet = Db.Exec(SqlCommand)
|
||||
for NewRecord in NewRecordSet:
|
||||
NewParameter = GetSplitValueList(NewRecord[0], '}')[Index]
|
||||
GuidName = GetPpiParameter(NewParameter[NewParameter.find('{') : ])
|
||||
Db.Insert(-1, '', '', SourceFileID, SourceFileFullPath, ItemName, ItemType, ItemMode, GuidName, GuidMacro, GuidValue, BelongsToFunction, 0)
|
||||
IsFound = True
|
||||
except Exception:
|
||||
pass
|
||||
|
||||
# A External Parameter
|
||||
if not IsFound:
|
||||
SqlCommand = """select File.ID from Inf, File
|
||||
where BelongsToFile = (select BelongsToFile from Inf where Value1 = '%s')
|
||||
and Inf.Model = %s and Inf.Value1 = File.FullPath and File.Model = %s""" % (SourceFileFullPath, MODEL_EFI_SOURCE_FILE, MODEL_FILE_C)
|
||||
NewRecordSet = Db.Exec(SqlCommand)
|
||||
for NewRecord in NewRecordSet:
|
||||
Table = 'Identifier' + str(NewRecord[0])
|
||||
SqlCommand = """select Value from %s where Name = '%s' and Modifier = 'EFI_PEI_PPI_DESCRIPTOR' and Model = %s""" % (Table, Parameter, MODEL_IDENTIFIER_VARIABLE)
|
||||
PpiSet = Db.Exec(SqlCommand)
|
||||
if PpiSet != []:
|
||||
GuidName = GetPpiParameter(PpiSet[0][0])
|
||||
if GuidName != '':
|
||||
Db.Insert(-1, '', '', SourceFileID, SourceFileFullPath, ItemName, ItemType, ItemMode, GuidName, GuidMacro, GuidValue, BelongsToFunction, 0)
|
||||
IsFound = True
|
||||
break
|
||||
|
||||
if not IsFound:
|
||||
EotGlobalData.gOP_UN_MATCHED.write('%s, %s, %s, %s, %s, %s\n' % (ItemType, ItemMode, SourceFileID, SourceFileFullPath, StartLine, Parameter))
|
||||
|
||||
## SearchProtocols() method
|
||||
#
|
||||
# Search all used PROTOCOL calling function
|
||||
# Store the result to database
|
||||
#
|
||||
# @param SqlCommand: SQL command statement
|
||||
# @param Table: Table id
|
||||
# @param SourceFileID: Source file id
|
||||
# @param SourceFileFullPath: Source file full path
|
||||
# @param ItemMode: Mode of the item
|
||||
# @param ProtocolMode: Mode of PROTOCOL
|
||||
#
|
||||
def SearchProtocols(SqlCommand, Table, SourceFileID, SourceFileFullPath, ItemMode, ProtocolMode):
|
||||
ItemName, ItemType, GuidName, GuidMacro, GuidValue = '', 'Protocol', '', '', ''
|
||||
BelongsToFunctionID, BelongsToFunction = -1, ''
|
||||
Db = EotGlobalData.gDb.TblReport
|
||||
RecordSet = Db.Exec(SqlCommand)
|
||||
for Record in RecordSet:
|
||||
Parameter = ''
|
||||
BelongsToFile, StartLine, EndLine = Record[2], Record[3], Record[4]
|
||||
# Get BelongsToFunction
|
||||
BelongsToFunctionID, BelongsToFunction = SearchBelongsToFunction(BelongsToFile, StartLine, EndLine)
|
||||
|
||||
# Default is Not Found
|
||||
IsFound = False
|
||||
|
||||
if ProtocolMode == 0 or ProtocolMode == 1:
|
||||
Parameter = GetProtocolParameter(Record[0], ProtocolMode)
|
||||
if Parameter.startswith('g') or Parameter.endswith('Guid') or Parameter == 'ShellEnvProtocol' or Parameter == 'ShellInterfaceProtocol':
|
||||
GuidName = GetParameterName(Parameter)
|
||||
Db.Insert(-1, '', '', SourceFileID, SourceFileFullPath, ItemName, ItemType, ItemMode, GuidName, GuidMacro, GuidValue, BelongsToFunction, 0)
|
||||
IsFound = True
|
||||
|
||||
if ProtocolMode == 2:
|
||||
Protocols = GetSplitValueList(Record[0], TAB_COMMA_SPLIT)
|
||||
for Protocol in Protocols:
|
||||
if Protocol.startswith('&') and Protocol.endswith('Guid'):
|
||||
GuidName = GetParameterName(Protocol)
|
||||
Db.Insert(-1, '', '', SourceFileID, SourceFileFullPath, ItemName, ItemType, ItemMode, GuidName, GuidMacro, GuidValue, BelongsToFunction, 0)
|
||||
IsFound = True
|
||||
else:
|
||||
NewValue = FindKeyValue(EotGlobalData.gDb.TblFile, Table, Protocol)
|
||||
if Protocol != NewValue and NewValue.endswith('Guid'):
|
||||
GuidName = GetParameterName(NewValue)
|
||||
Db.Insert(-1, '', '', SourceFileID, SourceFileFullPath, ItemName, ItemType, ItemMode, GuidName, GuidMacro, GuidValue, BelongsToFunction, 0)
|
||||
IsFound = True
|
||||
|
||||
if not IsFound:
|
||||
if BelongsToFunction in EotGlobalData.gProducedProtocolLibrary or BelongsToFunction in EotGlobalData.gConsumedProtocolLibrary:
|
||||
EotGlobalData.gOP_UN_MATCHED_IN_LIBRARY_CALLING.write('%s, %s, %s, %s, %s, %s, %s\n' % (ItemType, ItemMode, SourceFileID, SourceFileFullPath, StartLine, Parameter, BelongsToFunction))
|
||||
else:
|
||||
EotGlobalData.gOP_UN_MATCHED.write('%s, %s, %s, %s, %s, %s\n' % (ItemType, ItemMode, SourceFileID, SourceFileFullPath, StartLine, Parameter))
|
||||
|
||||
## SearchFunctionCalling() method
|
||||
#
|
||||
# Search all used PPI/PROTOCOL calling function by library
|
||||
# Store the result to database
|
||||
#
|
||||
# @param SqlCommand: SQL command statement
|
||||
# @param Table: Table id
|
||||
# @param SourceFileID: Source file id
|
||||
# @param SourceFileFullPath: Source file full path
|
||||
# @param ItemType: Type of the item, PPI or PROTOCOL
|
||||
# @param ItemMode: Mode of item
|
||||
#
|
||||
def SearchFunctionCalling(Table, SourceFileID, SourceFileFullPath, ItemType, ItemMode):
|
||||
LibraryList = sdict()
|
||||
Db = EotGlobalData.gDb.TblReport
|
||||
Parameters, ItemName, GuidName, GuidMacro, GuidValue, BelongsToFunction = [], '', '', '', '', ''
|
||||
if ItemType == 'Protocol' and ItemMode == 'Produced':
|
||||
LibraryList = EotGlobalData.gProducedProtocolLibrary
|
||||
elif ItemType == 'Protocol' and ItemMode == 'Consumed':
|
||||
LibraryList = EotGlobalData.gConsumedProtocolLibrary
|
||||
elif ItemType == 'Protocol' and ItemMode == 'Callback':
|
||||
LibraryList = EotGlobalData.gCallbackProtocolLibrary
|
||||
elif ItemType == 'Ppi' and ItemMode == 'Produced':
|
||||
LibraryList = EotGlobalData.gProducedPpiLibrary
|
||||
elif ItemType == 'Ppi' and ItemMode == 'Consumed':
|
||||
LibraryList = EotGlobalData.gConsumedPpiLibrary
|
||||
|
||||
for Library in LibraryList:
|
||||
Index = LibraryList[Library]
|
||||
SqlCommand = """select Value, StartLine from %s
|
||||
where Name like '%%%s%%' and Model = %s""" \
|
||||
% (Table, Library, MODEL_IDENTIFIER_FUNCTION_CALLING)
|
||||
RecordSet = Db.Exec(SqlCommand)
|
||||
for Record in RecordSet:
|
||||
IsFound = False
|
||||
if Index == -1:
|
||||
ParameterList = GetSplitValueList(Record[0], TAB_COMMA_SPLIT)
|
||||
for Parameter in ParameterList:
|
||||
Parameters.append(GetParameterName(Parameter))
|
||||
else:
|
||||
Parameters = [GetProtocolParameter(Record[0], Index)]
|
||||
StartLine = Record[1]
|
||||
for Parameter in Parameters:
|
||||
if Parameter.startswith('g') or Parameter.endswith('Guid') or Parameter == 'ShellEnvProtocol' or Parameter == 'ShellInterfaceProtocol':
|
||||
GuidName = GetParameterName(Parameter)
|
||||
Db.Insert(-1, '', '', SourceFileID, SourceFileFullPath, ItemName, ItemType, ItemMode, GuidName, GuidMacro, GuidValue, BelongsToFunction, 0)
|
||||
IsFound = True
|
||||
|
||||
if not IsFound:
|
||||
EotGlobalData.gOP_UN_MATCHED.write('%s, %s, %s, %s, %s, %s\n' % (ItemType, ItemMode, SourceFileID, SourceFileFullPath, StartLine, Parameter))
|
||||
|
||||
## FindProtocols() method
|
||||
#
|
||||
# Find defined protocols
|
||||
#
|
||||
# @param SqlCommand: SQL command statement
|
||||
# @param Table: Table id
|
||||
# @param SourceFileID: Source file id
|
||||
# @param SourceFileFullPath: Source file full path
|
||||
# @param ItemName: String of protocol definition
|
||||
# @param ItemType: Type of the item, PPI or PROTOCOL
|
||||
# @param ItemMode: Mode of item
|
||||
#
|
||||
#def FindProtocols(Db, SqlCommand, Table, SourceFileID, SourceFileFullPath, ItemName, ItemType, ItemMode, GuidName, GuidMacro, GuidValue):
|
||||
# BelongsToFunction = ''
|
||||
# RecordSet = Db.Exec(SqlCommand)
|
||||
# for Record in RecordSet:
|
||||
# IsFound = True
|
||||
# Parameter = GetProtocolParameter(Record[0])
|
||||
|
||||
## GetProtocolParameter() method
|
||||
#
|
||||
# Parse string of protocol and find parameters
|
||||
#
|
||||
# @param Parameter: Parameter to be parsed
|
||||
# @param Index: The index of the parameter
|
||||
#
|
||||
# @return: call common GetParameter
|
||||
#
|
||||
def GetProtocolParameter(Parameter, Index = 1):
|
||||
return GetParameter(Parameter, Index)
|
||||
|
||||
## GetPpiParameter() method
|
||||
#
|
||||
# Parse string of ppi and find parameters
|
||||
#
|
||||
# @param Parameter: Parameter to be parsed
|
||||
# @param Index: The index of the parameter
|
||||
#
|
||||
# @return: call common GetParameter
|
||||
#
|
||||
def GetPpiParameter(Parameter, Index = 1):
|
||||
return GetParameter(Parameter, Index)
|
||||
|
||||
## GetParameter() method
|
||||
#
|
||||
# Get a parameter by index
|
||||
#
|
||||
# @param Parameter: Parameter to be parsed
|
||||
# @param Index: The index of the parameter
|
||||
#
|
||||
# @return Parameter: The found parameter
|
||||
#
|
||||
def GetParameter(Parameter, Index = 1):
|
||||
ParameterList = GetSplitValueList(Parameter, TAB_COMMA_SPLIT)
|
||||
if len(ParameterList) > Index:
|
||||
Parameter = GetParameterName(ParameterList[Index])
|
||||
|
||||
return Parameter
|
||||
|
||||
return ''
|
||||
|
||||
## GetParameterName() method
|
||||
#
|
||||
# Get a parameter name
|
||||
#
|
||||
# @param Parameter: Parameter to be parsed
|
||||
#
|
||||
# @return: The name of parameter
|
||||
#
|
||||
def GetParameterName(Parameter):
|
||||
if type(Parameter) == type('') and Parameter.startswith('&'):
|
||||
return Parameter[1:].replace('{', '').replace('}', '').replace('\r', '').replace('\n', '').strip()
|
||||
else:
|
||||
return Parameter.strip()
|
||||
|
||||
## FindKeyValue() method
|
||||
#
|
||||
# Find key value of a variable
|
||||
#
|
||||
# @param Db: Database to be searched
|
||||
# @param Table: Table to be searched
|
||||
# @param Key: The keyword
|
||||
#
|
||||
# @return Value: The value of the the keyword
|
||||
#
|
||||
def FindKeyValue(Db, Table, Key):
|
||||
SqlCommand = """select Value from %s where Name = '%s' and (Model = %s or Model = %s)""" % (Table, Key, MODEL_IDENTIFIER_VARIABLE, MODEL_IDENTIFIER_ASSIGNMENT_EXPRESSION)
|
||||
RecordSet = Db.Exec(SqlCommand)
|
||||
Value = ''
|
||||
for Record in RecordSet:
|
||||
if Record[0] != 'NULL':
|
||||
Value = FindKeyValue(Db, Table, GetParameterName(Record[0]))
|
||||
|
||||
if Value != '':
|
||||
return Value
|
||||
else:
|
||||
return Key
|
||||
|
||||
## ParseMapFile() method
|
||||
#
|
||||
# Parse map files to get a dict of 'ModuleName' : {FunName : FunAddress}
|
||||
#
|
||||
# @param Files: A list of map files
|
||||
#
|
||||
# @return AllMaps: An object of all map files
|
||||
#
|
||||
def ParseMapFile(Files):
|
||||
AllMaps = {}
|
||||
CurrentModule = ''
|
||||
CurrentMaps = {}
|
||||
for File in Files:
|
||||
Content = open(File, 'r').readlines()
|
||||
for Line in Content:
|
||||
Line = CleanString(Line)
|
||||
# skip empty line
|
||||
if Line == '':
|
||||
continue
|
||||
|
||||
if Line.find('(') > -1 and Line.find(')') > -1:
|
||||
if CurrentModule != '' and CurrentMaps != {}:
|
||||
AllMaps[CurrentModule] = CurrentMaps
|
||||
CurrentModule = Line[:Line.find('(')]
|
||||
CurrentMaps = {}
|
||||
continue
|
||||
else:
|
||||
Name = ''
|
||||
Address = ''
|
||||
List = Line.split()
|
||||
Address = List[0]
|
||||
if List[1] == 'F' or List[1] == 'FS':
|
||||
Name = List[2]
|
||||
else:
|
||||
Name = List[1]
|
||||
CurrentMaps[Name] = Address
|
||||
continue
|
||||
|
||||
return AllMaps
|
||||
|
||||
## ConvertGuid
|
||||
#
|
||||
# Convert a GUID to a GUID with all upper letters
|
||||
#
|
||||
# @param guid: The GUID to be converted
|
||||
#
|
||||
# @param newGuid: The GUID with all upper letters.
|
||||
#
|
||||
def ConvertGuid(guid):
|
||||
numList = ['0', '1', '2', '3', '4', '5', '6', '7', '8', '9']
|
||||
newGuid = ''
|
||||
if guid.startswith('g'):
|
||||
guid = guid[1:]
|
||||
for i in guid:
|
||||
if i.upper() == i and i not in numList:
|
||||
newGuid = newGuid + ('_' + i)
|
||||
else:
|
||||
newGuid = newGuid + i.upper()
|
||||
if newGuid.startswith('_'):
|
||||
newGuid = newGuid[1:]
|
||||
if newGuid.endswith('_'):
|
||||
newGuid = newGuid[:-1]
|
||||
|
||||
return newGuid
|
||||
|
||||
## ConvertGuid2() method
|
||||
#
|
||||
# Convert a GUID to a GUID with new string instead of old string
|
||||
#
|
||||
# @param guid: The GUID to be converted
|
||||
# @param old: Old string to be replaced
|
||||
# @param new: New string to replace the old one
|
||||
#
|
||||
# @param newGuid: The GUID after replacement
|
||||
#
|
||||
def ConvertGuid2(guid, old, new):
|
||||
newGuid = ConvertGuid(guid)
|
||||
newGuid = newGuid.replace(old, new)
|
||||
|
||||
return newGuid
|
||||
|
||||
##
|
||||
#
|
||||
# This acts like the main() function for the script, unless it is 'import'ed into another
|
||||
# script.
|
||||
#
|
||||
if __name__ == '__main__':
|
||||
pass
|
26
BaseTools/Source/Python/Eot/ParserWarning.py
Normal file
26
BaseTools/Source/Python/Eot/ParserWarning.py
Normal file
@@ -0,0 +1,26 @@
|
||||
## @file
|
||||
# Warning information of Eot
|
||||
#
|
||||
# Copyright (c) 2007 - 2010, 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
|
||||
# http://opensource.org/licenses/bsd-license.php
|
||||
#
|
||||
# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
|
||||
#
|
||||
class Warning (Exception):
|
||||
## The constructor
|
||||
#
|
||||
# @param self The object pointer
|
||||
# @param Str The message to record
|
||||
# @param File The FDF name
|
||||
# @param Line The Line number that error occurs
|
||||
#
|
||||
def __init__(self, Str, File = None, Line = None):
|
||||
self.message = Str
|
||||
self.FileName = File
|
||||
self.LineNumber = Line
|
||||
self.ToolName = 'EOT'
|
472
BaseTools/Source/Python/Eot/Report.py
Normal file
472
BaseTools/Source/Python/Eot/Report.py
Normal file
@@ -0,0 +1,472 @@
|
||||
## @file
|
||||
# This file is used to create report for Eot tool
|
||||
#
|
||||
# Copyright (c) 2008 - 2010, 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
|
||||
# http://opensource.org/licenses/bsd-license.php
|
||||
#
|
||||
# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
|
||||
#
|
||||
|
||||
##
|
||||
# Import Modules
|
||||
#
|
||||
import os
|
||||
import EotGlobalData
|
||||
|
||||
## Report() class
|
||||
#
|
||||
# This class defined Report
|
||||
#
|
||||
# @param object: Inherited from object class
|
||||
#
|
||||
class Report(object):
|
||||
## The constructor
|
||||
#
|
||||
# @param self: The object pointer
|
||||
# @param ReportName: name of the report
|
||||
# @param FvObj: FV object after parsing FV images
|
||||
#
|
||||
def __init__(self, ReportName = 'Report.html', FvObj = None, DispatchName=None):
|
||||
self.ReportName = ReportName
|
||||
self.Op = open(ReportName, 'w+')
|
||||
self.DispatchList = None
|
||||
if DispatchName:
|
||||
self.DispatchList = open(DispatchName, 'w+')
|
||||
self.FvObj = FvObj
|
||||
self.FfsIndex = 0
|
||||
self.PpiIndex = 0
|
||||
self.ProtocolIndex = 0
|
||||
if EotGlobalData.gMACRO['EFI_SOURCE'] == '':
|
||||
EotGlobalData.gMACRO['EFI_SOURCE'] = EotGlobalData.gMACRO['EDK_SOURCE']
|
||||
|
||||
## WriteLn() method
|
||||
#
|
||||
# Write a line in the report
|
||||
#
|
||||
# @param self: The object pointer
|
||||
# @param Line: The lint to be written into
|
||||
#
|
||||
def WriteLn(self, Line):
|
||||
self.Op.write('%s\n' % Line)
|
||||
|
||||
## GenerateReport() method
|
||||
#
|
||||
# A caller to generate report
|
||||
#
|
||||
# @param self: The object pointer
|
||||
#
|
||||
def GenerateReport(self):
|
||||
self.GenerateHeader()
|
||||
self.GenerateFv()
|
||||
self.GenerateTail()
|
||||
self.Op.close()
|
||||
self.GenerateUnDispatchedList()
|
||||
|
||||
## GenerateUnDispatchedList() method
|
||||
#
|
||||
# Create a list for not dispatched items
|
||||
#
|
||||
# @param self: The object pointer
|
||||
#
|
||||
def GenerateUnDispatchedList(self):
|
||||
FvObj = self.FvObj
|
||||
EotGlobalData.gOP_UN_DISPATCHED.write('%s\n' % FvObj.Name)
|
||||
for Item in FvObj.UnDispatchedFfsDict:
|
||||
EotGlobalData.gOP_UN_DISPATCHED.write('%s\n' % FvObj.UnDispatchedFfsDict[Item])
|
||||
|
||||
## GenerateFv() method
|
||||
#
|
||||
# Generate FV information
|
||||
#
|
||||
# @param self: The object pointer
|
||||
#
|
||||
def GenerateFv(self):
|
||||
FvObj = self.FvObj
|
||||
Content = """ <tr>
|
||||
<td width="20%%"><strong>Name</strong></td>
|
||||
<td width="60%%"><strong>Guid</strong></td>
|
||||
<td width="20%%"><strong>Size</strong></td>
|
||||
</tr>"""
|
||||
self.WriteLn(Content)
|
||||
|
||||
for Info in FvObj.BasicInfo:
|
||||
FvName = Info[0]
|
||||
FvGuid = Info[1]
|
||||
FvSize = Info[2]
|
||||
|
||||
Content = """ <tr>
|
||||
<td>%s</td>
|
||||
<td>%s</td>
|
||||
<td>%s</td>
|
||||
</tr>""" % (FvName, FvGuid, FvSize)
|
||||
self.WriteLn(Content)
|
||||
|
||||
Content = """ <td colspan="3"><table width="100%%" border="1">
|
||||
<tr>"""
|
||||
self.WriteLn(Content)
|
||||
|
||||
EotGlobalData.gOP_DISPATCH_ORDER.write('Dispatched:\n')
|
||||
for FfsId in FvObj.OrderedFfsDict:
|
||||
self.GenerateFfs(FvObj.OrderedFfsDict[FfsId])
|
||||
Content = """ </table></td>
|
||||
</tr>"""
|
||||
self.WriteLn(Content)
|
||||
|
||||
# For UnDispatched
|
||||
Content = """ <td colspan="3"><table width="100%%" border="1">
|
||||
<tr>
|
||||
<tr><strong>UnDispatched</strong></tr>"""
|
||||
self.WriteLn(Content)
|
||||
|
||||
EotGlobalData.gOP_DISPATCH_ORDER.write('\nUnDispatched:\n')
|
||||
for FfsId in FvObj.UnDispatchedFfsDict:
|
||||
self.GenerateFfs(FvObj.UnDispatchedFfsDict[FfsId])
|
||||
Content = """ </table></td>
|
||||
</tr>"""
|
||||
self.WriteLn(Content)
|
||||
|
||||
## GenerateDepex() method
|
||||
#
|
||||
# Generate Depex information
|
||||
#
|
||||
# @param self: The object pointer
|
||||
# @param DepexString: A DEPEX string needed to be parsed
|
||||
#
|
||||
def GenerateDepex(self, DepexString):
|
||||
NonGuidList = ['AND', 'OR', 'NOT', 'BEFORE', 'AFTER', 'TRUE', 'FALSE']
|
||||
ItemList = DepexString.split(' ')
|
||||
DepexString = ''
|
||||
for Item in ItemList:
|
||||
if Item not in NonGuidList:
|
||||
SqlCommand = """select DISTINCT GuidName from Report where GuidValue like '%s' and ItemMode = 'Produced' group by GuidName""" % (Item)
|
||||
RecordSet = EotGlobalData.gDb.TblReport.Exec(SqlCommand)
|
||||
if RecordSet != []:
|
||||
Item = RecordSet[0][0]
|
||||
DepexString = DepexString + Item + ' '
|
||||
Content = """ <tr>
|
||||
<td width="5%%"></td>
|
||||
<td width="95%%">%s</td>
|
||||
</tr>""" % (DepexString)
|
||||
self.WriteLn(Content)
|
||||
|
||||
## GeneratePpi() method
|
||||
#
|
||||
# Generate PPI information
|
||||
#
|
||||
# @param self: The object pointer
|
||||
# @param Name: CName of a GUID
|
||||
# @param Guid: Value of a GUID
|
||||
# @param Type: Type of a GUID
|
||||
#
|
||||
def GeneratePpi(self, Name, Guid, Type):
|
||||
self.GeneratePpiProtocol('Ppi', Name, Guid, Type, self.PpiIndex)
|
||||
|
||||
## GenerateProtocol() method
|
||||
#
|
||||
# Generate PROTOCOL information
|
||||
#
|
||||
# @param self: The object pointer
|
||||
# @param Name: CName of a GUID
|
||||
# @param Guid: Value of a GUID
|
||||
# @param Type: Type of a GUID
|
||||
#
|
||||
def GenerateProtocol(self, Name, Guid, Type):
|
||||
self.GeneratePpiProtocol('Protocol', Name, Guid, Type, self.ProtocolIndex)
|
||||
|
||||
## GeneratePpiProtocol() method
|
||||
#
|
||||
# Generate PPI/PROTOCOL information
|
||||
#
|
||||
# @param self: The object pointer
|
||||
# @param Model: Model of a GUID, PPI or PROTOCOL
|
||||
# @param Name: Name of a GUID
|
||||
# @param Guid: Value of a GUID
|
||||
# @param Type: Type of a GUID
|
||||
# @param CName: CName(Index) of a GUID
|
||||
#
|
||||
def GeneratePpiProtocol(self, Model, Name, Guid, Type, CName):
|
||||
Content = """ <tr>
|
||||
<td width="5%%"></td>
|
||||
<td width="10%%">%s</td>
|
||||
<td width="85%%" colspan="3">%s</td>
|
||||
<!-- %s -->
|
||||
</tr>""" % (Model, Name, Guid)
|
||||
self.WriteLn(Content)
|
||||
if Type == 'Produced':
|
||||
SqlCommand = """select DISTINCT SourceFileFullPath, BelongsToFunction from Report where GuidName like '%s' and ItemMode = 'Callback'""" % Name
|
||||
RecordSet = EotGlobalData.gDb.TblReport.Exec(SqlCommand)
|
||||
for Record in RecordSet:
|
||||
SqlCommand = """select FullPath from File
|
||||
where ID = (
|
||||
select DISTINCT BelongsToFile from Inf
|
||||
where Value1 like '%s')""" % Record[0]
|
||||
ModuleSet = EotGlobalData.gDb.TblReport.Exec(SqlCommand)
|
||||
Inf = ModuleSet[0][0].replace(EotGlobalData.gMACRO['WORKSPACE'], '.')
|
||||
Function = Record[1]
|
||||
Address = ''
|
||||
for Item in EotGlobalData.gMap:
|
||||
if Function in EotGlobalData.gMap[Item]:
|
||||
Address = EotGlobalData.gMap[Item][Function]
|
||||
break
|
||||
if '_' + Function in EotGlobalData.gMap[Item]:
|
||||
Address = EotGlobalData.gMap[Item]['_' + Function]
|
||||
break
|
||||
Content = """ <tr>
|
||||
<td width="5%%"></td>
|
||||
<td width="10%%">%s</td>
|
||||
<td width="40%%">%s</td>
|
||||
<td width="35%%">%s</td>
|
||||
<td width="10%%">%s</td>
|
||||
</tr>""" % ('Callback', Inf, Function, Address)
|
||||
self.WriteLn(Content)
|
||||
|
||||
## GenerateFfs() method
|
||||
#
|
||||
# Generate FFS information
|
||||
#
|
||||
# @param self: The object pointer
|
||||
# @param FfsObj: FFS object after FV image is parsed
|
||||
#
|
||||
def GenerateFfs(self, FfsObj):
|
||||
self.FfsIndex = self.FfsIndex + 1
|
||||
if FfsObj != None and FfsObj.Type in [0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0xA]:
|
||||
FfsGuid = FfsObj.Guid
|
||||
FfsOffset = FfsObj._OFF_
|
||||
FfsName = 'Unknown-Module'
|
||||
FfsPath = FfsGuid
|
||||
FfsType = FfsObj._TypeName[FfsObj.Type]
|
||||
|
||||
# Hard code for Binary INF
|
||||
if FfsGuid.upper() == '7BB28B99-61BB-11D5-9A5D-0090273FC14D':
|
||||
FfsName = 'Logo'
|
||||
|
||||
if FfsGuid.upper() == '7E374E25-8E01-4FEE-87F2-390C23C606CD':
|
||||
FfsName = 'AcpiTables'
|
||||
|
||||
if FfsGuid.upper() == '961578FE-B6B7-44C3-AF35-6BC705CD2B1F':
|
||||
FfsName = 'Fat'
|
||||
|
||||
# Find FFS Path and Name
|
||||
SqlCommand = """select Value2 from Inf
|
||||
where BelongsToFile = (select BelongsToFile from Inf where Value1 = 'FILE_GUID' and lower(Value2) = lower('%s') and Model = %s)
|
||||
and Model = %s and Value1='BASE_NAME'""" % (FfsGuid, 5001, 5001)
|
||||
RecordSet = EotGlobalData.gDb.TblReport.Exec(SqlCommand)
|
||||
if RecordSet != []:
|
||||
FfsName = RecordSet[0][0]
|
||||
|
||||
SqlCommand = """select FullPath from File
|
||||
where ID = (select BelongsToFile from Inf where Value1 = 'FILE_GUID' and lower(Value2) = lower('%s') and Model = %s)
|
||||
and Model = %s""" % (FfsGuid, 5001, 1011)
|
||||
RecordSet = EotGlobalData.gDb.TblReport.Exec(SqlCommand)
|
||||
if RecordSet != []:
|
||||
FfsPath = RecordSet[0][0]
|
||||
|
||||
Content = """ <tr>
|
||||
<tr class='styleFfs' id='FfsHeader%s'>
|
||||
<td width="55%%"><span onclick="Display('FfsHeader%s', 'Ffs%s')" onMouseOver="funOnMouseOver()" onMouseOut="funOnMouseOut()">%s</span></td>
|
||||
<td width="15%%">%s</td>
|
||||
<!--<td width="20%%">%s</td>-->
|
||||
<!--<td width="20%%">%s</td>-->
|
||||
<td width="10%%">%s</td>
|
||||
</tr>
|
||||
<tr id='Ffs%s' style='display:none;'>
|
||||
<td colspan="4"><table width="100%%" border="1">""" % (self.FfsIndex, self.FfsIndex, self.FfsIndex, FfsPath, FfsName, FfsGuid, FfsOffset, FfsType, self.FfsIndex)
|
||||
|
||||
if self.DispatchList:
|
||||
if FfsObj.Type in [0x04, 0x06]:
|
||||
self.DispatchList.write("%s %s %s %s\n" % (FfsGuid, "P", FfsName, FfsPath))
|
||||
if FfsObj.Type in [0x05, 0x07, 0x08, 0x0A]:
|
||||
self.DispatchList.write("%s %s %s %s\n" % (FfsGuid, "D", FfsName, FfsPath))
|
||||
|
||||
self.WriteLn(Content)
|
||||
|
||||
EotGlobalData.gOP_DISPATCH_ORDER.write('%s\n' %FfsName)
|
||||
|
||||
if FfsObj.Depex != '':
|
||||
Content = """ <tr>
|
||||
<td><span id='DepexHeader%s' class="styleDepex" onclick="Display('DepexHeader%s', 'Depex%s')" onMouseOver="funOnMouseOver()" onMouseOut="funOnMouseOut()">  DEPEX expression</span></td>
|
||||
</tr>
|
||||
<tr id='Depex%s' style='display:none;'>
|
||||
<td><table width="100%%" border="1">""" % (self.FfsIndex, self.FfsIndex, self.FfsIndex, self.FfsIndex)
|
||||
self.WriteLn(Content)
|
||||
self.GenerateDepex(FfsObj.Depex)
|
||||
Content = """ </table></td>
|
||||
</tr>"""
|
||||
self.WriteLn(Content)
|
||||
# End of DEPEX
|
||||
|
||||
# Find Consumed Ppi/Protocol
|
||||
SqlCommand = """select ModuleName, ItemType, GuidName, GuidValue, GuidMacro from Report
|
||||
where SourceFileFullPath in
|
||||
(select Value1 from Inf where BelongsToFile =
|
||||
(select BelongsToFile from Inf
|
||||
where Value1 = 'FILE_GUID' and Value2 like '%s' and Model = %s)
|
||||
and Model = %s)
|
||||
and ItemMode = 'Consumed' group by GuidName order by ItemType""" \
|
||||
% (FfsGuid, 5001, 3007)
|
||||
|
||||
RecordSet = EotGlobalData.gDb.TblReport.Exec(SqlCommand)
|
||||
if RecordSet != []:
|
||||
Count = len(RecordSet)
|
||||
Content = """ <tr>
|
||||
<td><span id='ConsumedHeader%s' class="styleConsumed" onclick="Display('ConsumedHeader%s', 'Consumed%s')" onMouseOver="funOnMouseOver()" onMouseOut="funOnMouseOut()">  Consumed Ppis/Protocols List (%s)</span></td>
|
||||
</tr>
|
||||
<tr id='Consumed%s' style='display:none;'>
|
||||
<td><table width="100%%" border="1">""" % (self.FfsIndex, self.FfsIndex, self.FfsIndex, Count, self.FfsIndex)
|
||||
self.WriteLn(Content)
|
||||
self.ProtocolIndex = 0
|
||||
for Record in RecordSet:
|
||||
self.ProtocolIndex = self.ProtocolIndex + 1
|
||||
Name = Record[2]
|
||||
CName = Record[4]
|
||||
Guid = Record[3]
|
||||
Type = Record[1]
|
||||
self.GeneratePpiProtocol(Type, Name, Guid, 'Consumed', CName)
|
||||
|
||||
Content = """ </table></td>
|
||||
</tr>"""
|
||||
self.WriteLn(Content)
|
||||
#End of Consumed Ppi/Portocol
|
||||
|
||||
# Find Produced Ppi/Protocol
|
||||
SqlCommand = """select ModuleName, ItemType, GuidName, GuidValue, GuidMacro from Report
|
||||
where SourceFileFullPath in
|
||||
(select Value1 from Inf where BelongsToFile =
|
||||
(select BelongsToFile from Inf
|
||||
where Value1 = 'FILE_GUID' and Value2 like '%s' and Model = %s)
|
||||
and Model = %s)
|
||||
and ItemMode = 'Produced' group by GuidName order by ItemType""" \
|
||||
% (FfsGuid, 5001, 3007)
|
||||
|
||||
RecordSet = EotGlobalData.gDb.TblReport.Exec(SqlCommand)
|
||||
if RecordSet != []:
|
||||
Count = len(RecordSet)
|
||||
Content = """ <tr>
|
||||
<td><span id='ProducedHeader%s' class="styleProduced" onclick="Display('ProducedHeader%s', 'Produced%s')" onMouseOver="funOnMouseOver()" onMouseOut="funOnMouseOut()">  Produced Ppis/Protocols List (%s)</span></td>
|
||||
</tr>
|
||||
<tr id='Produced%s' style='display:none;'>
|
||||
<td><table width="100%%" border="1">""" % (self.FfsIndex, self.FfsIndex, self.FfsIndex, Count, self.FfsIndex)
|
||||
self.WriteLn(Content)
|
||||
self.PpiIndex = 0
|
||||
for Record in RecordSet:
|
||||
self.PpiIndex = self.PpiIndex + 1
|
||||
Name = Record[2]
|
||||
CName = Record[4]
|
||||
Guid = Record[3]
|
||||
Type = Record[1]
|
||||
self.GeneratePpiProtocol(Type, Name, Guid, 'Produced', CName)
|
||||
|
||||
Content = """ </table></td>
|
||||
</tr>"""
|
||||
self.WriteLn(Content)
|
||||
RecordSet = None
|
||||
# End of Produced Ppi/Protocol
|
||||
|
||||
Content = """ </table></td>
|
||||
</tr>"""
|
||||
self.WriteLn(Content)
|
||||
|
||||
## GenerateTail() method
|
||||
#
|
||||
# Generate end tags of HTML report
|
||||
#
|
||||
# @param self: The object pointer
|
||||
#
|
||||
def GenerateTail(self):
|
||||
Tail = """</table>
|
||||
</body>
|
||||
</html>"""
|
||||
self.WriteLn(Tail)
|
||||
|
||||
## GenerateHeader() method
|
||||
#
|
||||
# Generate start tags of HTML report
|
||||
#
|
||||
# @param self: The object pointer
|
||||
#
|
||||
def GenerateHeader(self):
|
||||
Header = """<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
|
||||
"http://www.w3.org/TR/html4/loose.dtd">
|
||||
<html>
|
||||
<head>
|
||||
<title>Execution Order Tool Report</title>
|
||||
<meta http-equiv="Content-Type" content="text/html">
|
||||
<style type="text/css">
|
||||
<!--
|
||||
.styleFfs {
|
||||
color: #006600;
|
||||
font-weight: bold;
|
||||
}
|
||||
.styleDepex {
|
||||
color: #FF0066;
|
||||
font-weight: bold;
|
||||
}
|
||||
.styleProduced {
|
||||
color: #0000FF;
|
||||
font-weight: bold;
|
||||
}
|
||||
.styleConsumed {
|
||||
color: #FF00FF;
|
||||
font-weight: bold;
|
||||
}
|
||||
-->
|
||||
</style>
|
||||
<Script type="text/javascript">
|
||||
function Display(ParentID, SubID)
|
||||
{
|
||||
SubItem = document.getElementById(SubID);
|
||||
ParentItem = document.getElementById(ParentID);
|
||||
if (SubItem.style.display == 'none')
|
||||
{
|
||||
SubItem.style.display = ''
|
||||
ParentItem.style.fontWeight = 'normal'
|
||||
}
|
||||
else
|
||||
{
|
||||
SubItem.style.display = 'none'
|
||||
ParentItem.style.fontWeight = 'bold'
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
function funOnMouseOver()
|
||||
{
|
||||
document.body.style.cursor = "hand";
|
||||
}
|
||||
|
||||
function funOnMouseOut()
|
||||
{
|
||||
document.body.style.cursor = "";
|
||||
}
|
||||
|
||||
</Script>
|
||||
</head>
|
||||
|
||||
<body>
|
||||
<table width="100%%" border="1">"""
|
||||
self.WriteLn(Header)
|
||||
|
||||
##
|
||||
#
|
||||
# This acts like the main() function for the script, unless it is 'import'ed into another
|
||||
# script.
|
||||
#
|
||||
if __name__ == '__main__':
|
||||
# Initialize log system
|
||||
FilePath = 'FVRECOVERYFLOPPY.fv'
|
||||
if FilePath.lower().endswith(".fv"):
|
||||
fd = open(FilePath, 'rb')
|
||||
buf = array('B')
|
||||
try:
|
||||
buf.fromfile(fd, os.path.getsize(FilePath))
|
||||
except EOFError:
|
||||
pass
|
||||
|
||||
fv = FirmwareVolume("FVRECOVERY", buf, 0)
|
||||
|
||||
report = Report('Report.html', fv)
|
||||
report.GenerateReport()
|
15
BaseTools/Source/Python/Eot/__init__.py
Normal file
15
BaseTools/Source/Python/Eot/__init__.py
Normal file
@@ -0,0 +1,15 @@
|
||||
## @file
|
||||
# Python 'Eot' package initialization file.
|
||||
#
|
||||
# This file is required to make Python interpreter treat the directory
|
||||
# as containing package.
|
||||
#
|
||||
# Copyright (c) 2010, Intel Corporation<BR>
|
||||
# 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
|
||||
# http://opensource.org/licenses/bsd-license.php
|
||||
#
|
||||
# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
|
||||
#
|
394
BaseTools/Source/Python/Eot/c.py
Normal file
394
BaseTools/Source/Python/Eot/c.py
Normal file
@@ -0,0 +1,394 @@
|
||||
## @file
|
||||
# preprocess source file
|
||||
#
|
||||
# Copyright (c) 2007 - 2010, 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
|
||||
# http://opensource.org/licenses/bsd-license.php
|
||||
#
|
||||
# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
|
||||
#
|
||||
|
||||
##
|
||||
# Import Modules
|
||||
#
|
||||
import sys
|
||||
import os
|
||||
import re
|
||||
import CodeFragmentCollector
|
||||
import FileProfile
|
||||
from CommonDataClass import DataClass
|
||||
from Common import EdkLogger
|
||||
from EotToolError import *
|
||||
import EotGlobalData
|
||||
|
||||
# Global Dicts
|
||||
IncludeFileListDict = {}
|
||||
IncludePathListDict = {}
|
||||
ComplexTypeDict = {}
|
||||
SUDict = {}
|
||||
|
||||
## GetIgnoredDirListPattern() method
|
||||
#
|
||||
# Get the pattern of ignored direction list
|
||||
#
|
||||
# @return p: the pattern of ignored direction list
|
||||
#
|
||||
def GetIgnoredDirListPattern():
|
||||
p = re.compile(r'.*[\\/](?:BUILD|INTELRESTRICTEDTOOLS|INTELRESTRICTEDPKG|PCCTS)[\\/].*')
|
||||
return p
|
||||
|
||||
## GetFuncDeclPattern() method
|
||||
#
|
||||
# Get the pattern of function declaration
|
||||
#
|
||||
# @return p: the pattern of function declaration
|
||||
#
|
||||
def GetFuncDeclPattern():
|
||||
p = re.compile(r'(EFIAPI|EFI_BOOT_SERVICE|EFI_RUNTIME_SERVICE)?\s*[_\w]+\s*\(.*\).*', re.DOTALL)
|
||||
return p
|
||||
|
||||
## GetArrayPattern() method
|
||||
#
|
||||
# Get the pattern of array
|
||||
#
|
||||
# @return p: the pattern of array
|
||||
#
|
||||
def GetArrayPattern():
|
||||
p = re.compile(r'[_\w]*\s*[\[.*\]]+')
|
||||
return p
|
||||
|
||||
## GetTypedefFuncPointerPattern() method
|
||||
#
|
||||
# Get the pattern of function pointer
|
||||
#
|
||||
# @return p: the pattern of function pointer
|
||||
#
|
||||
def GetTypedefFuncPointerPattern():
|
||||
p = re.compile('[_\w\s]*\([\w\s]*\*+\s*[_\w]+\s*\)\s*\(.*\)', re.DOTALL)
|
||||
return p
|
||||
|
||||
## GetDB() method
|
||||
#
|
||||
# Get global database instance
|
||||
#
|
||||
# @return EotGlobalData.gDb: the global database instance
|
||||
#
|
||||
def GetDB():
|
||||
return EotGlobalData.gDb
|
||||
|
||||
## PrintErrorMsg() method
|
||||
#
|
||||
# print error message
|
||||
#
|
||||
# @param ErrorType: Type of error
|
||||
# @param Msg: Error message
|
||||
# @param TableName: table name of error found
|
||||
# @param ItemId: id of item
|
||||
#
|
||||
def PrintErrorMsg(ErrorType, Msg, TableName, ItemId):
|
||||
Msg = Msg.replace('\n', '').replace('\r', '')
|
||||
MsgPartList = Msg.split()
|
||||
Msg = ''
|
||||
for Part in MsgPartList:
|
||||
Msg += Part
|
||||
Msg += ' '
|
||||
GetDB().TblReport.Insert(ErrorType, OtherMsg = Msg, BelongsToTable = TableName, BelongsToItem = ItemId)
|
||||
|
||||
## GetIdType() method
|
||||
#
|
||||
# Find type of input string
|
||||
#
|
||||
# @param Str: String to be parsed
|
||||
#
|
||||
# @return Type: The type of the string
|
||||
#
|
||||
def GetIdType(Str):
|
||||
Type = DataClass.MODEL_UNKNOWN
|
||||
Str = Str.replace('#', '# ')
|
||||
List = Str.split()
|
||||
if List[1] == 'include':
|
||||
Type = DataClass.MODEL_IDENTIFIER_INCLUDE
|
||||
elif List[1] == 'define':
|
||||
Type = DataClass.MODEL_IDENTIFIER_MACRO_DEFINE
|
||||
elif List[1] == 'ifdef':
|
||||
Type = DataClass.MODEL_IDENTIFIER_MACRO_IFDEF
|
||||
elif List[1] == 'ifndef':
|
||||
Type = DataClass.MODEL_IDENTIFIER_MACRO_IFNDEF
|
||||
elif List[1] == 'endif':
|
||||
Type = DataClass.MODEL_IDENTIFIER_MACRO_ENDIF
|
||||
elif List[1] == 'pragma':
|
||||
Type = DataClass.MODEL_IDENTIFIER_MACRO_PROGMA
|
||||
else:
|
||||
Type = DataClass.MODEL_UNKNOWN
|
||||
return Type
|
||||
|
||||
## GetIdentifierList() method
|
||||
#
|
||||
# Get id of all files
|
||||
#
|
||||
# @return IdList: The list of all id of files
|
||||
#
|
||||
def GetIdentifierList():
|
||||
IdList = []
|
||||
|
||||
for pp in FileProfile.PPDirectiveList:
|
||||
Type = GetIdType(pp.Content)
|
||||
IdPP = DataClass.IdentifierClass(-1, '', '', '', pp.Content, Type, -1, -1, pp.StartPos[0],pp.StartPos[1],pp.EndPos[0],pp.EndPos[1])
|
||||
IdList.append(IdPP)
|
||||
|
||||
for ae in FileProfile.AssignmentExpressionList:
|
||||
IdAE = DataClass.IdentifierClass(-1, ae.Operator, '', ae.Name, ae.Value, DataClass.MODEL_IDENTIFIER_ASSIGNMENT_EXPRESSION, -1, -1, ae.StartPos[0],ae.StartPos[1],ae.EndPos[0],ae.EndPos[1])
|
||||
IdList.append(IdAE)
|
||||
|
||||
FuncDeclPattern = GetFuncDeclPattern()
|
||||
ArrayPattern = GetArrayPattern()
|
||||
for var in FileProfile.VariableDeclarationList:
|
||||
DeclText = var.Declarator.strip()
|
||||
while DeclText.startswith('*'):
|
||||
var.Modifier += '*'
|
||||
DeclText = DeclText.lstrip('*').strip()
|
||||
var.Declarator = DeclText
|
||||
if FuncDeclPattern.match(var.Declarator):
|
||||
DeclSplitList = var.Declarator.split('(')
|
||||
FuncName = DeclSplitList[0]
|
||||
FuncNamePartList = FuncName.split()
|
||||
if len(FuncNamePartList) > 1:
|
||||
FuncName = FuncNamePartList[-1]
|
||||
Index = 0
|
||||
while Index < len(FuncNamePartList) - 1:
|
||||
var.Modifier += ' ' + FuncNamePartList[Index]
|
||||
var.Declarator = var.Declarator.lstrip().lstrip(FuncNamePartList[Index])
|
||||
Index += 1
|
||||
IdVar = DataClass.IdentifierClass(-1, var.Modifier, '', var.Declarator, '', DataClass.MODEL_IDENTIFIER_FUNCTION_DECLARATION, -1, -1, var.StartPos[0],var.StartPos[1],var.EndPos[0],var.EndPos[1])
|
||||
IdList.append(IdVar)
|
||||
continue
|
||||
|
||||
if var.Declarator.find('{') == -1:
|
||||
for decl in var.Declarator.split(','):
|
||||
DeclList = decl.split('=')
|
||||
Name = DeclList[0].strip()
|
||||
if ArrayPattern.match(Name):
|
||||
LSBPos = var.Declarator.find('[')
|
||||
var.Modifier += ' ' + Name[LSBPos:]
|
||||
Name = Name[0:LSBPos]
|
||||
|
||||
IdVar = DataClass.IdentifierClass(-1, var.Modifier, '', Name, (len(DeclList) > 1 and [DeclList[1]]or [''])[0], DataClass.MODEL_IDENTIFIER_VARIABLE, -1, -1, var.StartPos[0],var.StartPos[1],var.EndPos[0],var.EndPos[1])
|
||||
IdList.append(IdVar)
|
||||
else:
|
||||
DeclList = var.Declarator.split('=')
|
||||
Name = DeclList[0].strip()
|
||||
if ArrayPattern.match(Name):
|
||||
LSBPos = var.Declarator.find('[')
|
||||
var.Modifier += ' ' + Name[LSBPos:]
|
||||
Name = Name[0:LSBPos]
|
||||
IdVar = DataClass.IdentifierClass(-1, var.Modifier, '', Name, (len(DeclList) > 1 and [DeclList[1]]or [''])[0], DataClass.MODEL_IDENTIFIER_VARIABLE, -1, -1, var.StartPos[0],var.StartPos[1],var.EndPos[0],var.EndPos[1])
|
||||
IdList.append(IdVar)
|
||||
|
||||
for enum in FileProfile.EnumerationDefinitionList:
|
||||
LBPos = enum.Content.find('{')
|
||||
RBPos = enum.Content.find('}')
|
||||
Name = enum.Content[4:LBPos].strip()
|
||||
Value = enum.Content[LBPos+1:RBPos]
|
||||
IdEnum = DataClass.IdentifierClass(-1, '', '', Name, Value, DataClass.MODEL_IDENTIFIER_ENUMERATE, -1, -1, enum.StartPos[0],enum.StartPos[1],enum.EndPos[0],enum.EndPos[1])
|
||||
IdList.append(IdEnum)
|
||||
|
||||
for su in FileProfile.StructUnionDefinitionList:
|
||||
Type = DataClass.MODEL_IDENTIFIER_STRUCTURE
|
||||
SkipLen = 6
|
||||
if su.Content.startswith('union'):
|
||||
Type = DataClass.MODEL_IDENTIFIER_UNION
|
||||
SkipLen = 5
|
||||
LBPos = su.Content.find('{')
|
||||
RBPos = su.Content.find('}')
|
||||
if LBPos == -1 or RBPos == -1:
|
||||
Name = su.Content[SkipLen:].strip()
|
||||
Value = ''
|
||||
else:
|
||||
Name = su.Content[SkipLen:LBPos].strip()
|
||||
Value = su.Content[LBPos+1:RBPos]
|
||||
IdPE = DataClass.IdentifierClass(-1, '', '', Name, Value, Type, -1, -1, su.StartPos[0],su.StartPos[1],su.EndPos[0],su.EndPos[1])
|
||||
IdList.append(IdPE)
|
||||
|
||||
TdFuncPointerPattern = GetTypedefFuncPointerPattern()
|
||||
for td in FileProfile.TypedefDefinitionList:
|
||||
Modifier = ''
|
||||
Name = td.ToType
|
||||
Value = td.FromType
|
||||
if TdFuncPointerPattern.match(td.ToType):
|
||||
Modifier = td.FromType
|
||||
LBPos = td.ToType.find('(')
|
||||
TmpStr = td.ToType[LBPos+1:].strip()
|
||||
StarPos = TmpStr.find('*')
|
||||
if StarPos != -1:
|
||||
Modifier += ' ' + TmpStr[0:StarPos]
|
||||
while TmpStr[StarPos] == '*':
|
||||
Modifier += ' ' + '*'
|
||||
StarPos += 1
|
||||
TmpStr = TmpStr[StarPos:].strip()
|
||||
RBPos = TmpStr.find(')')
|
||||
Name = TmpStr[0:RBPos]
|
||||
Value = 'FP' + TmpStr[RBPos + 1:]
|
||||
|
||||
IdTd = DataClass.IdentifierClass(-1, Modifier, '', Name, Value, DataClass.MODEL_IDENTIFIER_TYPEDEF, -1, -1, td.StartPos[0],td.StartPos[1],td.EndPos[0],td.EndPos[1])
|
||||
IdList.append(IdTd)
|
||||
|
||||
for funcCall in FileProfile.FunctionCallingList:
|
||||
IdFC = DataClass.IdentifierClass(-1, '', '', funcCall.FuncName, funcCall.ParamList, DataClass.MODEL_IDENTIFIER_FUNCTION_CALLING, -1, -1, funcCall.StartPos[0],funcCall.StartPos[1],funcCall.EndPos[0],funcCall.EndPos[1])
|
||||
IdList.append(IdFC)
|
||||
return IdList
|
||||
|
||||
## GetParamList() method
|
||||
#
|
||||
# Get a list of parameters
|
||||
#
|
||||
# @param FuncDeclarator: Function declarator
|
||||
# @param FuncNameLine: Line number of function name
|
||||
# @param FuncNameOffset: Offset of function name
|
||||
#
|
||||
# @return ParamIdList: A list of parameters
|
||||
#
|
||||
def GetParamList(FuncDeclarator, FuncNameLine = 0, FuncNameOffset = 0):
|
||||
ParamIdList = []
|
||||
DeclSplitList = FuncDeclarator.split('(')
|
||||
if len(DeclSplitList) < 2:
|
||||
return ParamIdList
|
||||
FuncName = DeclSplitList[0]
|
||||
ParamStr = DeclSplitList[1].rstrip(')')
|
||||
LineSkipped = 0
|
||||
OffsetSkipped = 0
|
||||
Start = 0
|
||||
while FuncName.find('\n', Start) != -1:
|
||||
LineSkipped += 1
|
||||
OffsetSkipped = 0
|
||||
Start += FuncName.find('\n', Start)
|
||||
Start += 1
|
||||
OffsetSkipped += len(FuncName[Start:])
|
||||
OffsetSkipped += 1 #skip '('
|
||||
ParamBeginLine = FuncNameLine + LineSkipped
|
||||
ParamBeginOffset = OffsetSkipped
|
||||
for p in ParamStr.split(','):
|
||||
ListP = p.split()
|
||||
if len(ListP) == 0:
|
||||
continue
|
||||
ParamName = ListP[-1]
|
||||
DeclText = ParamName.strip()
|
||||
RightSpacePos = p.rfind(ParamName)
|
||||
ParamModifier = p[0:RightSpacePos]
|
||||
if ParamName == 'OPTIONAL':
|
||||
if ParamModifier == '':
|
||||
ParamModifier += ' ' + 'OPTIONAL'
|
||||
DeclText = ''
|
||||
else:
|
||||
ParamName = ListP[-2]
|
||||
DeclText = ParamName.strip()
|
||||
RightSpacePos = p.rfind(ParamName)
|
||||
ParamModifier = p[0:RightSpacePos]
|
||||
ParamModifier += 'OPTIONAL'
|
||||
while DeclText.startswith('*'):
|
||||
ParamModifier += ' ' + '*'
|
||||
DeclText = DeclText.lstrip('*').strip()
|
||||
ParamName = DeclText
|
||||
|
||||
Start = 0
|
||||
while p.find('\n', Start) != -1:
|
||||
LineSkipped += 1
|
||||
OffsetSkipped = 0
|
||||
Start += p.find('\n', Start)
|
||||
Start += 1
|
||||
OffsetSkipped += len(p[Start:])
|
||||
|
||||
ParamEndLine = ParamBeginLine + LineSkipped
|
||||
ParamEndOffset = OffsetSkipped
|
||||
IdParam = DataClass.IdentifierClass(-1, ParamModifier, '', ParamName, '', DataClass.MODEL_IDENTIFIER_PARAMETER, -1, -1, ParamBeginLine, ParamBeginOffset, ParamEndLine, ParamEndOffset)
|
||||
ParamIdList.append(IdParam)
|
||||
ParamBeginLine = ParamEndLine
|
||||
ParamBeginOffset = OffsetSkipped + 1 #skip ','
|
||||
|
||||
return ParamIdList
|
||||
|
||||
## GetFunctionList()
|
||||
#
|
||||
# Get a list of functions
|
||||
#
|
||||
# @return FuncObjList: A list of function objects
|
||||
#
|
||||
def GetFunctionList():
|
||||
FuncObjList = []
|
||||
for FuncDef in FileProfile.FunctionDefinitionList:
|
||||
ParamIdList = []
|
||||
DeclText = FuncDef.Declarator.strip()
|
||||
while DeclText.startswith('*'):
|
||||
FuncDef.Modifier += '*'
|
||||
DeclText = DeclText.lstrip('*').strip()
|
||||
|
||||
FuncDef.Declarator = FuncDef.Declarator.lstrip('*')
|
||||
DeclSplitList = FuncDef.Declarator.split('(')
|
||||
if len(DeclSplitList) < 2:
|
||||
continue
|
||||
|
||||
FuncName = DeclSplitList[0]
|
||||
FuncNamePartList = FuncName.split()
|
||||
if len(FuncNamePartList) > 1:
|
||||
FuncName = FuncNamePartList[-1]
|
||||
Index = 0
|
||||
while Index < len(FuncNamePartList) - 1:
|
||||
FuncDef.Modifier += ' ' + FuncNamePartList[Index]
|
||||
Index += 1
|
||||
|
||||
FuncObj = DataClass.FunctionClass(-1, FuncDef.Declarator, FuncDef.Modifier, FuncName.strip(), '', FuncDef.StartPos[0],FuncDef.StartPos[1],FuncDef.EndPos[0],FuncDef.EndPos[1], FuncDef.LeftBracePos[0], FuncDef.LeftBracePos[1], -1, ParamIdList, [])
|
||||
FuncObjList.append(FuncObj)
|
||||
|
||||
return FuncObjList
|
||||
|
||||
## CreateCCodeDB() method
|
||||
#
|
||||
# Create database for all c code
|
||||
#
|
||||
# @param FileNameList: A list of all c code file names
|
||||
#
|
||||
def CreateCCodeDB(FileNameList):
|
||||
FileObjList = []
|
||||
ParseErrorFileList = []
|
||||
|
||||
for FullName in FileNameList:
|
||||
if os.path.splitext(FullName)[1] in ('.h', '.c'):
|
||||
EdkLogger.info("Parsing " + FullName)
|
||||
model = FullName.endswith('c') and DataClass.MODEL_FILE_C or DataClass.MODEL_FILE_H
|
||||
collector = CodeFragmentCollector.CodeFragmentCollector(FullName)
|
||||
try:
|
||||
collector.ParseFile()
|
||||
except UnicodeError:
|
||||
ParseErrorFileList.append(FullName)
|
||||
BaseName = os.path.basename(FullName)
|
||||
DirName = os.path.dirname(FullName)
|
||||
Ext = os.path.splitext(BaseName)[1].lstrip('.')
|
||||
ModifiedTime = os.path.getmtime(FullName)
|
||||
FileObj = DataClass.FileClass(-1, BaseName, Ext, DirName, FullName, model, ModifiedTime, GetFunctionList(), GetIdentifierList(), [])
|
||||
FileObjList.append(FileObj)
|
||||
collector.CleanFileProfileBuffer()
|
||||
|
||||
if len(ParseErrorFileList) > 0:
|
||||
EdkLogger.info("Found unrecoverable error during parsing:\n\t%s\n" % "\n\t".join(ParseErrorFileList))
|
||||
|
||||
Db = EotGlobalData.gDb
|
||||
for file in FileObjList:
|
||||
Db.InsertOneFile(file)
|
||||
|
||||
Db.UpdateIdentifierBelongsToFunction()
|
||||
|
||||
##
|
||||
#
|
||||
# This acts like the main() function for the script, unless it is 'import'ed into another
|
||||
# script.
|
||||
#
|
||||
if __name__ == '__main__':
|
||||
|
||||
EdkLogger.Initialize()
|
||||
EdkLogger.SetLevel(EdkLogger.QUIET)
|
||||
CollectSourceCodeDataIntoDB(sys.argv[1])
|
||||
|
||||
print 'Done!'
|
@@ -0,0 +1,15 @@
|
||||
## @file
|
||||
# Python 'Fdb' package initialization file.
|
||||
#
|
||||
# This file is required to make Python interpreter treat the directory
|
||||
# as containing package.
|
||||
#
|
||||
# Copyright (c) 2007 - 2010, Intel Corporation<BR>
|
||||
# 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
|
||||
# http://opensource.org/licenses/bsd-license.php
|
||||
#
|
||||
# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
|
||||
#
|
||||
|
@@ -0,0 +1,15 @@
|
||||
## @file
|
||||
# Python 'FixFlash' package initialization file.
|
||||
#
|
||||
# This file is required to make Python interpreter treat the directory
|
||||
# as containing package.
|
||||
#
|
||||
# Copyright (c) 2007 - 2010, Intel Corporation<BR>
|
||||
# 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
|
||||
# http://opensource.org/licenses/bsd-license.php
|
||||
#
|
||||
# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
|
||||
#
|
||||
|
@@ -29,8 +29,8 @@ class CompressSection (CompressSectionClassObject) :
|
||||
|
||||
## compress types: PI standard and non PI standard
|
||||
CompTypeDict = {
|
||||
'PI_STD' : 'PI_STD',
|
||||
'NON_PI_STD' : 'NON_PI_STD'
|
||||
'PI_STD' : 'PI_STD',
|
||||
'PI_NONE' : 'PI_NONE'
|
||||
}
|
||||
|
||||
## The constructor
|
||||
|
@@ -62,24 +62,27 @@ class DepexSection (DepexSectionClassObject):
|
||||
# @retval tuple (Generated file name list, section alignment)
|
||||
#
|
||||
def GenSection(self, OutputPath, ModuleName, SecNum, keyStringList, FfsFile = None, Dict = {}):
|
||||
|
||||
if self.ExpressionProcessed == False:
|
||||
self.Expression = self.Expression.replace("\n", " ").replace("\r", " ")
|
||||
ExpList = self.Expression.split()
|
||||
ExpGuidDict = {}
|
||||
|
||||
self.Expression = self.Expression.replace("\n", " ").replace("\r", " ")
|
||||
ExpList = self.Expression.split()
|
||||
ExpGuidDict = {}
|
||||
for Exp in ExpList:
|
||||
if Exp.upper() not in ('AND', 'OR', 'NOT', 'TRUE', 'FALSE', 'SOR', 'BEFORE', 'AFTER', 'END'):
|
||||
GuidStr = self.__FindGuidValue(Exp)
|
||||
if GuidStr == None:
|
||||
EdkLogger.error("GenFds", RESOURCE_NOT_AVAILABLE,
|
||||
"Depex GUID %s could not be found in build DB! (ModuleName: %s)" % (Exp, ModuleName))
|
||||
|
||||
for Exp in ExpList:
|
||||
if Exp.upper() not in ('AND', 'OR', 'NOT', 'TRUE', 'FALSE', 'SOR', 'BEFORE', 'AFTER', 'END'):
|
||||
GuidStr = self.__FindGuidValue(Exp)
|
||||
if GuidStr == None:
|
||||
EdkLogger.error("GenFds", RESOURCE_NOT_AVAILABLE,
|
||||
"Depex GUID %s could not be found in build DB! (ModuleName: %s)" % (Exp, ModuleName))
|
||||
ExpGuidDict[Exp] = GuidStr
|
||||
|
||||
ExpGuidDict[Exp] = GuidStr
|
||||
for Item in ExpGuidDict:
|
||||
self.Expression = self.Expression.replace(Item, ExpGuidDict[Item])
|
||||
|
||||
for Item in ExpGuidDict:
|
||||
self.Expression = self.Expression.replace(Item, ExpGuidDict[Item])
|
||||
self.Expression = self.Expression.strip()
|
||||
self.ExpressionProcessed = True
|
||||
|
||||
self.Expression = self.Expression.strip()
|
||||
if self.DepexType == 'PEI_DEPEX_EXP':
|
||||
ModuleType = 'PEIM'
|
||||
SecType = 'PEI_DEPEX'
|
||||
|
@@ -15,6 +15,7 @@
|
||||
##
|
||||
# Import Modules
|
||||
#
|
||||
from struct import *
|
||||
import Section
|
||||
from GenFdsGlobalVariable import GenFdsGlobalVariable
|
||||
import subprocess
|
||||
@@ -24,6 +25,7 @@ from CommonDataClass.FdfClass import EfiSectionClassObject
|
||||
import shutil
|
||||
from Common import EdkLogger
|
||||
from Common.BuildToolError import *
|
||||
from Common.Misc import PeImageClass
|
||||
|
||||
## generate rule section
|
||||
#
|
||||
@@ -78,6 +80,12 @@ class EfiSection (EfiSectionClassObject):
|
||||
FileList = []
|
||||
if Filename != None:
|
||||
Filename = GenFdsGlobalVariable.MacroExtend(Filename, Dict)
|
||||
# check if the path is absolute or relative
|
||||
if os.path.isabs(Filename):
|
||||
Filename = os.path.normpath(Filename)
|
||||
else:
|
||||
Filename = os.path.normpath(os.path.join(FfsInf.EfiOutputPath, Filename))
|
||||
|
||||
if not self.Optional:
|
||||
FileList.append(Filename)
|
||||
elif os.path.exists(Filename):
|
||||
@@ -121,7 +129,6 @@ class EfiSection (EfiSectionClassObject):
|
||||
f = open(File, 'r')
|
||||
VerString = f.read()
|
||||
f.close()
|
||||
# VerTuple = ('-n', '"' + VerString + '"')
|
||||
BuildNum = VerString
|
||||
if BuildNum != None and BuildNum != '':
|
||||
BuildNumTuple = ('-j', BuildNum)
|
||||
@@ -131,11 +138,6 @@ class EfiSection (EfiSectionClassObject):
|
||||
OutputFileList.append(OutputFile)
|
||||
|
||||
else:
|
||||
# if StringData != None and len(StringData) > 0:
|
||||
# VerTuple = ('-n', '"' + StringData + '"')
|
||||
# else:
|
||||
# VerTuple = tuple()
|
||||
# VerString = ' ' + ' '.join(VerTuple)
|
||||
BuildNum = StringData
|
||||
if BuildNum != None and BuildNum != '':
|
||||
BuildNumTuple = ('-j', BuildNum)
|
||||
@@ -221,6 +223,15 @@ class EfiSection (EfiSectionClassObject):
|
||||
Num = '%s.%d' %(SecNum , Index)
|
||||
OutputFile = os.path.join( OutputPath, ModuleName + 'SEC' + Num + Ffs.SectionSuffix.get(SectionType))
|
||||
File = GenFdsGlobalVariable.MacroExtend(File, Dict)
|
||||
|
||||
#Get PE Section alignment when align is set to AUTO
|
||||
if self.Alignment == 'Auto' and (SectionType == 'PE32' or SectionType == 'TE'):
|
||||
ImageObj = PeImageClass (File)
|
||||
if ImageObj.SectionAlignment < 0x400:
|
||||
self.Alignment = str (ImageObj.SectionAlignment)
|
||||
else:
|
||||
self.Alignment = str (ImageObj.SectionAlignment / 0x400) + 'K'
|
||||
|
||||
if File[(len(File)-4):] == '.efi':
|
||||
MapFile = File.replace('.efi', '.map')
|
||||
if os.path.exists(MapFile):
|
||||
@@ -237,24 +248,25 @@ class EfiSection (EfiSectionClassObject):
|
||||
StrippedFile = os.path.join(OutputPath, ModuleName + '.stripped')
|
||||
GenFdsGlobalVariable.GenerateFirmwareImage(
|
||||
StrippedFile,
|
||||
[GenFdsGlobalVariable.MacroExtend(File, Dict)],
|
||||
[File],
|
||||
Strip=True
|
||||
)
|
||||
File = StrippedFile
|
||||
|
||||
"""For TE Section call GenFw to generate TE image"""
|
||||
|
||||
if SectionType == 'TE':
|
||||
TeFile = os.path.join( OutputPath, ModuleName + 'Te.raw')
|
||||
GenFdsGlobalVariable.GenerateFirmwareImage(
|
||||
TeFile,
|
||||
[GenFdsGlobalVariable.MacroExtend(File, Dict)],
|
||||
[File],
|
||||
Type='te'
|
||||
)
|
||||
File = TeFile
|
||||
|
||||
"""Call GenSection"""
|
||||
GenFdsGlobalVariable.GenerateSection(OutputFile,
|
||||
[GenFdsGlobalVariable.MacroExtend(File)],
|
||||
[File],
|
||||
Section.Section.SectionType.get (SectionType)
|
||||
)
|
||||
OutputFileList.append(OutputFile)
|
||||
|
@@ -40,6 +40,7 @@ import OptionRom
|
||||
import OptRomInfStatement
|
||||
import OptRomFileStatement
|
||||
|
||||
from GenFdsGlobalVariable import GenFdsGlobalVariable
|
||||
from Common.BuildToolError import *
|
||||
from Common import EdkLogger
|
||||
|
||||
@@ -172,6 +173,7 @@ class FileProfile :
|
||||
self.InfList = []
|
||||
|
||||
self.FdDict = {}
|
||||
self.FdNameNotSet = False
|
||||
self.FvDict = {}
|
||||
self.CapsuleDict = {}
|
||||
self.VtfList = []
|
||||
@@ -1300,7 +1302,16 @@ class FdfParser:
|
||||
raise Warning("expected [FD.]", self.FileName, self.CurrentLineNumber)
|
||||
|
||||
FdName = self.__GetUiName()
|
||||
if FdName == "":
|
||||
if len (self.Profile.FdDict) == 0:
|
||||
FdName = GenFdsGlobalVariable.PlatformName
|
||||
self.Profile.FdNameNotSet = True
|
||||
else:
|
||||
raise Warning("expected FdName in [FD.] section", self.FileName, self.CurrentLineNumber)
|
||||
self.CurrentFdName = FdName.upper()
|
||||
|
||||
if self.CurrentFdName in self.Profile.FdDict:
|
||||
raise Warning("Unexpected the same FD name", self.FileName, self.CurrentLineNumber)
|
||||
|
||||
if not self.__IsToken( "]"):
|
||||
raise Warning("expected ']'", self.FileName, self.CurrentLineNumber)
|
||||
@@ -1308,12 +1319,15 @@ class FdfParser:
|
||||
FdObj = Fd.FD()
|
||||
FdObj.FdUiName = self.CurrentFdName
|
||||
self.Profile.FdDict[self.CurrentFdName] = FdObj
|
||||
|
||||
if len (self.Profile.FdDict) > 1 and self.Profile.FdNameNotSet:
|
||||
raise Warning("expected all FDs have their name", self.FileName, self.CurrentLineNumber)
|
||||
|
||||
Status = self.__GetCreateFile(FdObj)
|
||||
if not Status:
|
||||
raise Warning("FD name error", self.FileName, self.CurrentLineNumber)
|
||||
|
||||
if not self.__GetTokenStatements(FdObj):
|
||||
return False
|
||||
self.__GetTokenStatements(FdObj)
|
||||
|
||||
self.__GetDefineStatements(FdObj)
|
||||
|
||||
@@ -1368,8 +1382,6 @@ class FdfParser:
|
||||
#
|
||||
# @param self The object pointer
|
||||
# @param Obj for whom token statement is got
|
||||
# @retval True Successfully find a token statement
|
||||
# @retval False Not able to find a token statement
|
||||
#
|
||||
def __GetTokenStatements(self, Obj):
|
||||
if not self.__IsKeyword( "BaseAddress"):
|
||||
@@ -1419,8 +1431,7 @@ class FdfParser:
|
||||
|
||||
Obj.ErasePolarity = self.__Token
|
||||
|
||||
Status = self.__GetBlockStatements(Obj)
|
||||
return Status
|
||||
self.__GetBlockStatements(Obj)
|
||||
|
||||
## __GetAddressStatements() method
|
||||
#
|
||||
@@ -1459,17 +1470,20 @@ class FdfParser:
|
||||
#
|
||||
# @param self The object pointer
|
||||
# @param Obj for whom block statement is got
|
||||
# @retval True Successfully find
|
||||
# @retval False Not able to find
|
||||
#
|
||||
def __GetBlockStatements(self, Obj):
|
||||
|
||||
if not self.__GetBlockStatement(Obj):
|
||||
raise Warning("expected block statement", self.FileName, self.CurrentLineNumber)
|
||||
#set default block size is 1
|
||||
Obj.BlockSizeList.append((1, Obj.Size, None))
|
||||
return
|
||||
|
||||
while self.__GetBlockStatement(Obj):
|
||||
pass
|
||||
return True
|
||||
|
||||
for Item in Obj.BlockSizeList:
|
||||
if Item[0] == None or Item[1] == None:
|
||||
raise Warning("expected block statement for Fd Section", self.FileName, self.CurrentLineNumber)
|
||||
|
||||
## __GetBlockStatement() method
|
||||
#
|
||||
@@ -1496,7 +1510,7 @@ class FdfParser:
|
||||
PcdPair = self.__GetNextPcdName()
|
||||
BlockSizePcd = PcdPair
|
||||
self.Profile.PcdDict[PcdPair] = BlockSize
|
||||
BlockSize = long(self.__Token, 0)
|
||||
BlockSize = long(BlockSize, 0)
|
||||
|
||||
BlockNumber = None
|
||||
if self.__IsKeyword( "NumBlocks"):
|
||||
@@ -2113,9 +2127,6 @@ class FdfParser:
|
||||
raise Warning("expected INF file path", self.FileName, self.CurrentLineNumber)
|
||||
ffsInf.InfFileName = self.__Token
|
||||
|
||||
# if ffsInf.InfFileName.find('$') >= 0:
|
||||
# ffsInf.InfFileName = GenFdsGlobalVariable.GenFdsGlobalVariable.MacroExtend(ffsInf.InfFileName, MacroDict)
|
||||
|
||||
if not ffsInf.InfFileName in self.Profile.InfList:
|
||||
self.Profile.InfList.append(ffsInf.InfFileName)
|
||||
|
||||
@@ -2427,6 +2438,8 @@ class FdfParser:
|
||||
|
||||
AlignValue = None
|
||||
if self.__GetAlignment():
|
||||
if self.__Token not in ("Auto", "8", "16", "32", "64", "128", "512", "1K", "4K", "32K" ,"64K"):
|
||||
raise Warning("Incorrect alignment '%s'" % self.__Token, self.FileName, self.CurrentLineNumber)
|
||||
AlignValue = self.__Token
|
||||
|
||||
BuildNum = None
|
||||
@@ -2440,6 +2453,8 @@ class FdfParser:
|
||||
BuildNum = self.__Token
|
||||
|
||||
if self.__IsKeyword( "VERSION"):
|
||||
if AlignValue == 'Auto':
|
||||
raise Warning("Auto alignment can only be used in PE32 or TE section ", self.FileName, self.CurrentLineNumber)
|
||||
if not self.__IsToken( "="):
|
||||
raise Warning("expected '='", self.FileName, self.CurrentLineNumber)
|
||||
if not self.__GetNextToken():
|
||||
@@ -2452,8 +2467,10 @@ class FdfParser:
|
||||
else:
|
||||
VerSectionObj.FileName = self.__Token
|
||||
Obj.SectionList.append(VerSectionObj)
|
||||
|
||||
|
||||
elif self.__IsKeyword( "UI"):
|
||||
if AlignValue == 'Auto':
|
||||
raise Warning("Auto alignment can only be used in PE32 or TE section ", self.FileName, self.CurrentLineNumber)
|
||||
if not self.__IsToken( "="):
|
||||
raise Warning("expected '='", self.FileName, self.CurrentLineNumber)
|
||||
if not self.__GetNextToken():
|
||||
@@ -2467,6 +2484,8 @@ class FdfParser:
|
||||
Obj.SectionList.append(UiSectionObj)
|
||||
|
||||
elif self.__IsKeyword( "FV_IMAGE"):
|
||||
if AlignValue == 'Auto':
|
||||
raise Warning("Auto alignment can only be used in PE32 or TE section ", self.FileName, self.CurrentLineNumber)
|
||||
if not self.__IsToken( "="):
|
||||
raise Warning("expected '='", self.FileName, self.CurrentLineNumber)
|
||||
if not self.__GetNextToken():
|
||||
@@ -2508,6 +2527,8 @@ class FdfParser:
|
||||
Obj.SectionList.append(FvImageSectionObj)
|
||||
|
||||
elif self.__IsKeyword("PEI_DEPEX_EXP") or self.__IsKeyword("DXE_DEPEX_EXP") or self.__IsKeyword("SMM_DEPEX_EXP"):
|
||||
if AlignValue == 'Auto':
|
||||
raise Warning("Auto alignment can only be used in PE32 or TE section ", self.FileName, self.CurrentLineNumber)
|
||||
DepexSectionObj = DepexSection.DepexSection()
|
||||
DepexSectionObj.Alignment = AlignValue
|
||||
DepexSectionObj.DepexType = self.__Token
|
||||
@@ -2523,7 +2544,6 @@ class FdfParser:
|
||||
Obj.SectionList.append(DepexSectionObj)
|
||||
|
||||
else:
|
||||
|
||||
if not self.__GetNextWord():
|
||||
raise Warning("expected section type", self.FileName, self.CurrentLineNumber)
|
||||
|
||||
@@ -2535,6 +2555,9 @@ class FdfParser:
|
||||
if self.__Token not in ("COMPAT16", "PE32", "PIC", "TE", "FV_IMAGE", "RAW", "DXE_DEPEX",\
|
||||
"UI", "VERSION", "PEI_DEPEX", "SUBTYPE_GUID", "SMM_DEPEX"):
|
||||
raise Warning("Unknown section type '%s'" % self.__Token, self.FileName, self.CurrentLineNumber)
|
||||
if AlignValue == 'Auto'and (not self.__Token == 'PE32') and (not self.__Token == 'TE'):
|
||||
raise Warning("Auto alignment can only be used in PE32 or TE section ", self.FileName, self.CurrentLineNumber)
|
||||
|
||||
# DataSection
|
||||
DataSectionObj = DataSection.DataSection()
|
||||
DataSectionObj.Alignment = AlignValue
|
||||
@@ -2684,6 +2707,8 @@ class FdfParser:
|
||||
|
||||
AlignValue = None
|
||||
if self.__GetAlignment():
|
||||
if self.__Token not in ("8", "16", "32", "64", "128", "512", "1K", "4K", "32K" ,"64K"):
|
||||
raise Warning("Incorrect alignment '%s'" % self.__Token, self.FileName, self.CurrentLineNumber)
|
||||
AlignValue = self.__Token
|
||||
|
||||
if not self.__GetCglSection(FfsFileObj, AlignValue):
|
||||
@@ -3013,9 +3038,11 @@ class FdfParser:
|
||||
|
||||
AlignValue = ""
|
||||
if self.__GetAlignment():
|
||||
if self.__Token not in ("8", "16", "32", "64", "128", "512", "1K", "4K", "32K" ,"64K"):
|
||||
if self.__Token not in ("Auto", "8", "16", "32", "64", "128", "512", "1K", "4K", "32K" ,"64K"):
|
||||
raise Warning("Incorrect alignment '%s'" % self.__Token, self.FileName, self.CurrentLineNumber)
|
||||
AlignValue = self.__Token
|
||||
#For FFS, Auto is default option same to ""
|
||||
if not self.__Token == "Auto":
|
||||
AlignValue = self.__Token
|
||||
|
||||
if self.__IsToken("{"):
|
||||
# Complex file rule expected
|
||||
@@ -3040,24 +3067,6 @@ class FdfParser:
|
||||
|
||||
return Rule
|
||||
|
||||
elif self.__IsToken("|"):
|
||||
# Ext rule expected
|
||||
Ext = self.__GetFileExtension()
|
||||
|
||||
Rule = RuleSimpleFile.RuleSimpleFile()
|
||||
|
||||
Rule.FvFileType = Type
|
||||
Rule.NameGuid = NameGuid
|
||||
Rule.Alignment = AlignValue
|
||||
Rule.CheckSum = CheckSum
|
||||
Rule.Fixed = Fixed
|
||||
Rule.FileExtension = Ext
|
||||
Rule.KeyStringList = KeyStringList
|
||||
if KeepReloc != None:
|
||||
Rule.KeepReloc = KeepReloc
|
||||
|
||||
return Rule
|
||||
|
||||
else:
|
||||
# Simple file rule expected
|
||||
if not self.__GetNextWord():
|
||||
@@ -3076,12 +3085,18 @@ class FdfParser:
|
||||
if self.__IsKeyword("CheckSum", True):
|
||||
CheckSum = True
|
||||
|
||||
SectAlignment = ""
|
||||
if self.__GetAlignment():
|
||||
if self.__Token not in ("8", "16", "32", "64", "128", "512", "1K", "4K", "32K" ,"64K"):
|
||||
if self.__Token not in ("Auto", "8", "16", "32", "64", "128", "512", "1K", "4K", "32K" ,"64K"):
|
||||
raise Warning("Incorrect alignment '%s'" % self.__Token, self.FileName, self.CurrentLineNumber)
|
||||
AlignValue = self.__Token
|
||||
if self.__Token == 'Auto' and (not SectionName == 'PE32') and (not SectionName == 'TE'):
|
||||
raise Warning("Auto alignment can only be used in PE32 or TE section ", self.FileName, self.CurrentLineNumber)
|
||||
SectAlignment = self.__Token
|
||||
|
||||
if not self.__GetNextToken():
|
||||
Ext = None
|
||||
if self.__IsToken('|'):
|
||||
Ext = self.__GetFileExtension()
|
||||
elif not self.__GetNextToken():
|
||||
raise Warning("expected File name", self.FileName, self.CurrentLineNumber)
|
||||
|
||||
Rule = RuleSimpleFile.RuleSimpleFile()
|
||||
@@ -3089,12 +3104,14 @@ class FdfParser:
|
||||
Rule.FvFileType = Type
|
||||
Rule.NameGuid = NameGuid
|
||||
Rule.Alignment = AlignValue
|
||||
Rule.SectAlignment = SectAlignment
|
||||
Rule.CheckSum = CheckSum
|
||||
Rule.Fixed = Fixed
|
||||
Rule.FileName = self.__Token
|
||||
Rule.KeyStringList = KeyStringList
|
||||
if KeepReloc != None:
|
||||
Rule.KeepReloc = KeepReloc
|
||||
Rule.FileExtension = Ext
|
||||
Rule.FileName = self.__Token
|
||||
return Rule
|
||||
|
||||
## __GetEfiSection() method
|
||||
@@ -3148,14 +3165,6 @@ class FdfParser:
|
||||
raise Warning("expected 'FV'", self.FileName, self.CurrentLineNumber)
|
||||
FvImageSectionObj.FvFileType = self.__Token
|
||||
|
||||
if self.__GetAlignment():
|
||||
if self.__Token not in ("8", "16", "32", "64", "128", "512", "1K", "4K", "32K" ,"64K"):
|
||||
raise Warning("Incorrect alignment '%s'" % self.__Token, self.FileName, self.CurrentLineNumber)
|
||||
FvImageSectionObj.Alignment = self.__Token
|
||||
|
||||
if self.__IsKeyword("FV"):
|
||||
FvImageSectionObj.FvFileType = self.__Token
|
||||
|
||||
if self.__GetAlignment():
|
||||
if self.__Token not in ("8", "16", "32", "64", "128", "512", "1K", "4K", "32K" ,"64K"):
|
||||
raise Warning("Incorrect alignment '%s'" % self.__Token, self.FileName, self.CurrentLineNumber)
|
||||
@@ -3224,6 +3233,10 @@ class FdfParser:
|
||||
EfiSectionObj.BuildNum = self.__Token
|
||||
|
||||
if self.__GetAlignment():
|
||||
if self.__Token not in ("Auto", "8", "16", "32", "64", "128", "512", "1K", "4K", "32K" ,"64K"):
|
||||
raise Warning("Incorrect alignment '%s'" % self.__Token, self.FileName, self.CurrentLineNumber)
|
||||
if self.__Token == 'Auto' and (not SectionName == 'PE32') and (not SectionName == 'TE'):
|
||||
raise Warning("Auto alignment can only be used in PE32 or TE section ", self.FileName, self.CurrentLineNumber)
|
||||
EfiSectionObj.Alignment = self.__Token
|
||||
|
||||
if self.__IsKeyword('RELOCS_STRIPPED') or self.__IsKeyword('RELOCS_RETAINED'):
|
||||
|
@@ -1,7 +1,7 @@
|
||||
## @file
|
||||
# process FFS generation from FILE statement
|
||||
#
|
||||
# Copyright (c) 2007, Intel Corporation
|
||||
# Copyright (c) 2007 - 2010, 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
|
||||
@@ -17,14 +17,17 @@
|
||||
#
|
||||
import Ffs
|
||||
import Rule
|
||||
from GenFdsGlobalVariable import GenFdsGlobalVariable
|
||||
import os
|
||||
import StringIO
|
||||
import subprocess
|
||||
|
||||
from GenFdsGlobalVariable import GenFdsGlobalVariable
|
||||
from CommonDataClass.FdfClass import FileStatementClassObject
|
||||
from Common import EdkLogger
|
||||
from Common.BuildToolError import *
|
||||
from Common.Misc import GuidStructureByteArrayToGuidString
|
||||
from GuidSection import GuidSection
|
||||
from FvImageSection import FvImageSection
|
||||
|
||||
## generate FFS from FILE
|
||||
#
|
||||
@@ -41,11 +44,13 @@ class FileStatement (FileStatementClassObject) :
|
||||
#
|
||||
# Generate FFS
|
||||
#
|
||||
# @param self The object pointer
|
||||
# @param Dict dictionary contains macro and value pair
|
||||
# @retval string Generated FFS file name
|
||||
# @param self The object pointer
|
||||
# @param Dict dictionary contains macro and value pair
|
||||
# @param FvChildAddr Array of the inside FvImage base address
|
||||
# @param FvParentAddr Parent Fv base address
|
||||
# @retval string Generated FFS file name
|
||||
#
|
||||
def GenFfs(self, Dict = {}):
|
||||
def GenFfs(self, Dict = {}, FvChildAddr=[], FvParentAddr=None):
|
||||
|
||||
if self.NameGuid != None and self.NameGuid.startswith('PCD('):
|
||||
PcdValue = GenFdsGlobalVariable.GetPcdValue(self.NameGuid)
|
||||
@@ -92,6 +97,15 @@ class FileStatement (FileStatementClassObject) :
|
||||
for section in self.SectionList :
|
||||
Index = Index + 1
|
||||
SecIndex = '%d' %Index
|
||||
# process the inside FvImage from FvSection or GuidSection
|
||||
if FvChildAddr != []:
|
||||
if isinstance(section, FvImageSection):
|
||||
section.FvAddr = FvChildAddr.pop(0)
|
||||
elif isinstance(section, GuidSection):
|
||||
section.FvAddr = FvChildAddr
|
||||
if FvParentAddr != None and isinstance(section, GuidSection):
|
||||
section.FvParentAddr = FvParentAddr
|
||||
|
||||
sectList, align = section.GenSection(OutputDir, self.NameGuid, SecIndex, self.KeyStringList, None, Dict)
|
||||
if sectList != []:
|
||||
for sect in sectList:
|
||||
|
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user