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:
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:
|
||||
|
@@ -1,7 +1,7 @@
|
||||
## @file
|
||||
# process FFS generation from INF 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
|
||||
@@ -31,6 +31,9 @@ from Common.Misc import PathClass
|
||||
from Common.Misc import GuidStructureByteArrayToGuidString
|
||||
from Common import EdkLogger
|
||||
from Common.BuildToolError import *
|
||||
from GuidSection import GuidSection
|
||||
from FvImageSection import FvImageSection
|
||||
from Common.Misc import PeImageClass
|
||||
|
||||
## generate FFS from INF
|
||||
#
|
||||
@@ -90,7 +93,7 @@ class FfsInfStatement(FfsInfStatementClassObject):
|
||||
self.BaseName = Inf.BaseName
|
||||
self.ModuleGuid = Inf.Guid
|
||||
self.ModuleType = Inf.ModuleType
|
||||
if Inf.Specification != None and 'PI_SPECIFICATION_VERSION' in Inf.Specification:
|
||||
if Inf.Specification != None and 'PI_SPECIFICATION_VERSION' in Inf.Specification:
|
||||
self.PiSpecVersion = Inf.Specification['PI_SPECIFICATION_VERSION']
|
||||
if Inf.AutoGenVersion < 0x00010005:
|
||||
self.ModuleType = Inf.ComponentType
|
||||
@@ -105,7 +108,7 @@ class FfsInfStatement(FfsInfStatementClassObject):
|
||||
self.BaseName = Inf.BaseName
|
||||
self.ModuleGuid = Inf.Guid
|
||||
self.ModuleType = Inf.ModuleType
|
||||
if Inf.Specification != None and 'PI_SPECIFICATION_VERSION' in Inf.Specification:
|
||||
if Inf.Specification != None and 'PI_SPECIFICATION_VERSION' in Inf.Specification:
|
||||
self.PiSpecVersion = Inf.Specification['PI_SPECIFICATION_VERSION']
|
||||
self.VersionString = Inf.Version
|
||||
self.BinFileList = Inf.Binaries
|
||||
@@ -118,7 +121,7 @@ class FfsInfStatement(FfsInfStatementClassObject):
|
||||
if len(self.SourceFileList) != 0 and not self.InDsc:
|
||||
EdkLogger.warn("GenFds", GENFDS_ERROR, "Module %s NOT found in DSC file; Is it really a binary module?" % (self.InfFileName))
|
||||
|
||||
if self.ModuleType == 'SMM_CORE' and self.PiSpecVersion < 0x0001000A:
|
||||
if self.ModuleType == 'SMM_CORE' and self.PiSpecVersion < 0x0001000A:
|
||||
EdkLogger.error("GenFds", FORMAT_NOT_SUPPORTED, "SMM_CORE module type can't be used in the module with PI_SPECIFICATION_VERSION less than 0x0001000A", File=self.InfFileName)
|
||||
|
||||
if Inf._Defs != None and len(Inf._Defs) > 0:
|
||||
@@ -146,11 +149,13 @@ class FfsInfStatement(FfsInfStatementClassObject):
|
||||
#
|
||||
# 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):
|
||||
#
|
||||
# Parse Inf file get Module related information
|
||||
#
|
||||
@@ -184,7 +189,7 @@ class FfsInfStatement(FfsInfStatementClassObject):
|
||||
# For Rule has ComplexFile
|
||||
#
|
||||
elif isinstance(Rule, RuleComplexFile.RuleComplexFile):
|
||||
InputSectList, InputSectAlignments = self.__GenComplexFileSection__(Rule)
|
||||
InputSectList, InputSectAlignments = self.__GenComplexFileSection__(Rule, FvChildAddr, FvParentAddr)
|
||||
FfsOutput = self.__GenComplexFileFfs__(Rule, InputSectList, InputSectAlignments)
|
||||
|
||||
return FfsOutput
|
||||
@@ -393,8 +398,13 @@ class FfsInfStatement(FfsInfStatementClassObject):
|
||||
#
|
||||
FileList = []
|
||||
OutputFileList = []
|
||||
GenSecInputFile = None
|
||||
if Rule.FileName != None:
|
||||
GenSecInputFile = self.__ExtendMacro__(Rule.FileName)
|
||||
if os.path.isabs(GenSecInputFile):
|
||||
GenSecInputFile = os.path.normpath(GenSecInputFile)
|
||||
else:
|
||||
GenSecInputFile = os.path.normpath(os.path.join(self.EfiOutputPath, GenSecInputFile))
|
||||
else:
|
||||
FileList, IsSect = Section.Section.GetFileList(self, '', Rule.FileExtension)
|
||||
|
||||
@@ -429,6 +439,15 @@ class FfsInfStatement(FfsInfStatementClassObject):
|
||||
Ffs.Ffs.SectionSuffix[SectionType] + 'SEC' + SecNum
|
||||
Index = Index + 1
|
||||
OutputFile = os.path.join(self.OutputPath, GenSecOutputFile)
|
||||
File = GenFdsGlobalVariable.MacroExtend(File, Dict, self.CurrentArch)
|
||||
|
||||
#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 not NoStrip:
|
||||
FileBeforeStrip = os.path.join(self.OutputPath, ModuleName + '.reloc')
|
||||
@@ -438,7 +457,7 @@ class FfsInfStatement(FfsInfStatementClassObject):
|
||||
StrippedFile = os.path.join(self.OutputPath, ModuleName + '.stipped')
|
||||
GenFdsGlobalVariable.GenerateFirmwareImage(
|
||||
StrippedFile,
|
||||
[GenFdsGlobalVariable.MacroExtend(File, Dict, self.CurrentArch)],
|
||||
[File],
|
||||
Strip=True
|
||||
)
|
||||
File = StrippedFile
|
||||
@@ -447,7 +466,7 @@ class FfsInfStatement(FfsInfStatementClassObject):
|
||||
TeFile = os.path.join( self.OutputPath, self.ModuleGuid + 'Te.raw')
|
||||
GenFdsGlobalVariable.GenerateFirmwareImage(
|
||||
TeFile,
|
||||
[GenFdsGlobalVariable.MacroExtend(File, Dict, self.CurrentArch)],
|
||||
[File],
|
||||
Type='te'
|
||||
)
|
||||
File = TeFile
|
||||
@@ -459,6 +478,15 @@ class FfsInfStatement(FfsInfStatementClassObject):
|
||||
GenSecOutputFile= self.__ExtendMacro__(Rule.NameGuid) + \
|
||||
Ffs.Ffs.SectionSuffix[SectionType] + 'SEC' + SecNum
|
||||
OutputFile = os.path.join(self.OutputPath, GenSecOutputFile)
|
||||
GenSecInputFile = GenFdsGlobalVariable.MacroExtend(GenSecInputFile, Dict, self.CurrentArch)
|
||||
|
||||
#Get PE Section alignment when align is set to AUTO
|
||||
if self.Alignment == 'Auto' and (SectionType == 'PE32' or SectionType == 'TE'):
|
||||
ImageObj = PeImageClass (GenSecInputFile)
|
||||
if ImageObj.SectionAlignment < 0x400:
|
||||
self.Alignment = str (ImageObj.SectionAlignment)
|
||||
else:
|
||||
self.Alignment = str (ImageObj.SectionAlignment / 0x400) + 'K'
|
||||
|
||||
if not NoStrip:
|
||||
FileBeforeStrip = os.path.join(self.OutputPath, ModuleName + '.reloc')
|
||||
@@ -468,7 +496,7 @@ class FfsInfStatement(FfsInfStatementClassObject):
|
||||
StrippedFile = os.path.join(self.OutputPath, ModuleName + '.stipped')
|
||||
GenFdsGlobalVariable.GenerateFirmwareImage(
|
||||
StrippedFile,
|
||||
[GenFdsGlobalVariable.MacroExtend(GenSecInputFile, Dict, self.CurrentArch)],
|
||||
[GenSecInputFile],
|
||||
Strip=True
|
||||
)
|
||||
GenSecInputFile = StrippedFile
|
||||
@@ -477,7 +505,7 @@ class FfsInfStatement(FfsInfStatementClassObject):
|
||||
TeFile = os.path.join( self.OutputPath, self.ModuleGuid + 'Te.raw')
|
||||
GenFdsGlobalVariable.GenerateFirmwareImage(
|
||||
TeFile,
|
||||
[GenFdsGlobalVariable.MacroExtend(File, Dict, self.CurrentArch)],
|
||||
[GenSecInputFile],
|
||||
Type='te'
|
||||
)
|
||||
GenSecInputFile = TeFile
|
||||
@@ -507,7 +535,7 @@ class FfsInfStatement(FfsInfStatementClassObject):
|
||||
SectionAlignments = []
|
||||
for InputFile in InputFileList:
|
||||
InputSection.append(InputFile)
|
||||
SectionAlignments.append(Rule.Alignment)
|
||||
SectionAlignments.append(Rule.SectAlignment)
|
||||
|
||||
if Rule.NameGuid != None and Rule.NameGuid.startswith('PCD('):
|
||||
PcdValue = GenFdsGlobalVariable.GetPcdValue(Rule.NameGuid)
|
||||
@@ -534,11 +562,13 @@ class FfsInfStatement(FfsInfStatementClassObject):
|
||||
#
|
||||
# Generate section by sections in Rule
|
||||
#
|
||||
# @param self The object pointer
|
||||
# @param Rule The rule object used to generate section
|
||||
# @retval string File name of the generated section file
|
||||
# @param self The object pointer
|
||||
# @param Rule The rule object used to generate section
|
||||
# @param FvChildAddr Array of the inside FvImage base address
|
||||
# @param FvParentAddr Parent Fv base address
|
||||
# @retval string File name of the generated section file
|
||||
#
|
||||
def __GenComplexFileSection__(self, Rule):
|
||||
def __GenComplexFileSection__(self, Rule, FvChildAddr, FvParentAddr):
|
||||
if self.ModuleType in ('SEC', 'PEI_CORE', 'PEIM'):
|
||||
if Rule.KeepReloc != None:
|
||||
self.KeepRelocFromRule = Rule.KeepReloc
|
||||
@@ -560,6 +590,17 @@ class FfsInfStatement(FfsInfStatementClassObject):
|
||||
if self.ModuleType == 'DXE_SMM_DRIVER' and self.PiSpecVersion < 0x0001000A:
|
||||
if Sect.SectionType == 'SMM_DEPEX':
|
||||
EdkLogger.error("GenFds", FORMAT_NOT_SUPPORTED, "Framework SMM module doesn't support SMM_DEPEX section type", File=self.InfFileName)
|
||||
#
|
||||
# process the inside FvImage from FvSection or GuidSection
|
||||
#
|
||||
if FvChildAddr != []:
|
||||
if isinstance(Sect, FvImageSection):
|
||||
Sect.FvAddr = FvChildAddr.pop(0)
|
||||
elif isinstance(Sect, GuidSection):
|
||||
Sect.FvAddr = FvChildAddr
|
||||
if FvParentAddr != None and isinstance(Sect, GuidSection):
|
||||
Sect.FvParentAddr = FvParentAddr
|
||||
|
||||
if Rule.KeyStringList != []:
|
||||
SectList, Align = Sect.GenSection(self.OutputPath , self.ModuleGuid, SecIndex, Rule.KeyStringList, self)
|
||||
else :
|
||||
|
@@ -1,7 +1,7 @@
|
||||
## @file
|
||||
# process FV generation
|
||||
#
|
||||
# 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
|
||||
@@ -63,7 +63,7 @@ class FV (FvClassObject):
|
||||
#
|
||||
def AddToBuffer (self, Buffer, BaseAddress=None, BlockSize= None, BlockNum=None, ErasePloarity='1', VtfDict=None, MacroDict = {}) :
|
||||
|
||||
if self.UiFvName.upper() + 'fv' in GenFds.ImageBinDict.keys():
|
||||
if BaseAddress == None and self.UiFvName.upper() + 'fv' in GenFds.ImageBinDict.keys():
|
||||
return GenFds.ImageBinDict[self.UiFvName.upper() + 'fv']
|
||||
|
||||
#
|
||||
@@ -103,7 +103,7 @@ class FV (FvClassObject):
|
||||
|
||||
# Process Modules in FfsList
|
||||
for FfsFile in self.FfsList :
|
||||
FileName = FfsFile.GenFfs(MacroDict)
|
||||
FileName = FfsFile.GenFfs(MacroDict, FvParentAddr=BaseAddress)
|
||||
FfsFileList.append(FileName)
|
||||
self.FvInfFile.writelines("EFI_FILE_NAME = " + \
|
||||
FileName + \
|
||||
@@ -122,6 +122,9 @@ class FV (FvClassObject):
|
||||
|
||||
FvInfoFileName = os.path.join(GenFdsGlobalVariable.FfsDir, self.UiFvName + '.inf')
|
||||
shutil.copy(GenFdsGlobalVariable.FvAddressFileName, FvInfoFileName)
|
||||
OrigFvInfo = None
|
||||
if os.path.exists (FvInfoFileName):
|
||||
OrigFvInfo = open(FvInfoFileName, 'r').read()
|
||||
GenFdsGlobalVariable.GenerateFirmwareVolume(
|
||||
FvOutputFile,
|
||||
[self.InfFileName],
|
||||
@@ -129,6 +132,35 @@ class FV (FvClassObject):
|
||||
FfsList=FfsFileList
|
||||
)
|
||||
|
||||
NewFvInfo = None
|
||||
if os.path.exists (FvInfoFileName):
|
||||
NewFvInfo = open(FvInfoFileName, 'r').read()
|
||||
if NewFvInfo != None and NewFvInfo != OrigFvInfo:
|
||||
FvChildAddr = []
|
||||
AddFileObj = open(FvInfoFileName, 'r')
|
||||
AddrStrings = AddFileObj.readlines()
|
||||
AddrKeyFound = False
|
||||
for AddrString in AddrStrings:
|
||||
if AddrKeyFound:
|
||||
#get base address for the inside FvImage
|
||||
FvChildAddr.append (AddrString)
|
||||
elif AddrString.find ("[FV_BASE_ADDRESS]") != -1:
|
||||
AddrKeyFound = True
|
||||
AddFileObj.close()
|
||||
|
||||
if FvChildAddr != []:
|
||||
# Update Ffs again
|
||||
for FfsFile in self.FfsList :
|
||||
FileName = FfsFile.GenFfs(MacroDict, FvChildAddr, BaseAddress)
|
||||
|
||||
#Update GenFv again
|
||||
GenFdsGlobalVariable.GenerateFirmwareVolume(
|
||||
FvOutputFile,
|
||||
[self.InfFileName],
|
||||
AddressFile=FvInfoFileName,
|
||||
FfsList=FfsFileList
|
||||
)
|
||||
|
||||
#
|
||||
# Write the Fv contents to Buffer
|
||||
#
|
||||
@@ -138,6 +170,21 @@ class FV (FvClassObject):
|
||||
GenFdsGlobalVariable.SharpCounter = 0
|
||||
|
||||
Buffer.write(FvFileObj.read())
|
||||
FvFileObj.seek(0)
|
||||
# PI FvHeader is 0x48 byte
|
||||
FvHeaderBuffer = FvFileObj.read(0x48)
|
||||
# FV alignment position.
|
||||
FvAlignmentValue = 1 << (ord (FvHeaderBuffer[0x2E]) & 0x1F)
|
||||
# FvAlignmentValue is larger than or equal to 1K
|
||||
if FvAlignmentValue >= 0x400:
|
||||
if FvAlignmentValue >= 0x10000:
|
||||
#The max alignment supported by FFS is 64K.
|
||||
self.FvAlignment = "64K"
|
||||
else:
|
||||
self.FvAlignment = str (FvAlignmentValue / 0x400) + "K"
|
||||
else:
|
||||
# FvAlignmentValue is less than 1K
|
||||
self.FvAlignment = str (FvAlignmentValue)
|
||||
FvFileObj.close()
|
||||
GenFds.ImageBinDict[self.UiFvName.upper() + 'fv'] = FvOutputFile
|
||||
return FvOutputFile
|
||||
@@ -179,6 +226,10 @@ class FV (FvClassObject):
|
||||
' 0x%X' %BlockNum + \
|
||||
T_CHAR_LF)
|
||||
else:
|
||||
if self.BlockSizeList == []:
|
||||
#set default block size is 1
|
||||
self.FvInfFile.writelines("EFI_BLOCK_SIZE = 0x1" + T_CHAR_LF)
|
||||
|
||||
for BlockSize in self.BlockSizeList :
|
||||
if BlockSize[0] != None:
|
||||
self.FvInfFile.writelines("EFI_BLOCK_SIZE = " + \
|
||||
|
@@ -73,7 +73,13 @@ class FvImageSection(FvImageSectionClassObject):
|
||||
Fv = GenFdsGlobalVariable.FdfParser.Profile.FvDict.get(self.FvName)
|
||||
if Fv != None:
|
||||
self.Fv = Fv
|
||||
FvFileName = self.Fv.AddToBuffer(Buffer, MacroDict = Dict)
|
||||
FvFileName = Fv.AddToBuffer(Buffer, self.FvAddr, MacroDict = Dict)
|
||||
if Fv.FvAlignment != None:
|
||||
if self.Alignment == None:
|
||||
self.Alignment = Fv.FvAlignment
|
||||
else:
|
||||
if GenFdsGlobalVariable.GetAlignment (Fv.FvAlignment) > GenFdsGlobalVariable.GetAlignment (self.Alignment):
|
||||
self.Alignment = Fv.FvAlignment
|
||||
else:
|
||||
if self.FvFileName != None:
|
||||
FvFileName = GenFdsGlobalVariable.ReplaceWorkspaceMacro(self.FvFileName)
|
||||
|
@@ -1,7 +1,7 @@
|
||||
## @file
|
||||
# generate flash image
|
||||
#
|
||||
# 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
|
||||
@@ -39,7 +39,7 @@ from Common.Misc import DirCache,PathClass
|
||||
## Version and Copyright
|
||||
versionNumber = "1.0"
|
||||
__version__ = "%prog Version " + versionNumber
|
||||
__copyright__ = "Copyright (c) 2007, Intel Corporation All rights reserved."
|
||||
__copyright__ = "Copyright (c) 2007 - 2010, Intel Corporation All rights reserved."
|
||||
|
||||
## Tool entrance method
|
||||
#
|
||||
@@ -94,6 +94,18 @@ def main():
|
||||
if (Options.filename):
|
||||
FdfFilename = Options.filename
|
||||
FdfFilename = GenFdsGlobalVariable.ReplaceWorkspaceMacro(FdfFilename)
|
||||
|
||||
if FdfFilename[0:2] == '..':
|
||||
FdfFilename = os.path.realpath(FdfFilename)
|
||||
if not os.path.isabs (FdfFilename):
|
||||
FdfFilename = os.path.join(GenFdsGlobalVariable.WorkSpaceDir, FdfFilename)
|
||||
if not os.path.exists(FdfFilename):
|
||||
EdkLogger.error("GenFds", FILE_NOT_FOUND, ExtraData=FdfFilename)
|
||||
if os.path.normcase (FdfFilename).find(Workspace) != 0:
|
||||
EdkLogger.error("GenFds", FILE_NOT_FOUND, "FdfFile doesn't exist in Workspace!")
|
||||
|
||||
GenFdsGlobalVariable.FdfFile = FdfFilename
|
||||
GenFdsGlobalVariable.FdfFileTimeStamp = os.path.getmtime(FdfFilename)
|
||||
else:
|
||||
EdkLogger.error("GenFds", OPTION_MISSING, "Missing FDF filename")
|
||||
|
||||
@@ -107,16 +119,6 @@ def main():
|
||||
else:
|
||||
EdkLogger.error("GenFds", OPTION_MISSING, "Missing tool chain tag")
|
||||
|
||||
if FdfFilename[0:2] == '..':
|
||||
FdfFilename = os.path.realpath(FdfFilename)
|
||||
if FdfFilename[1] != ':':
|
||||
FdfFilename = os.path.join(GenFdsGlobalVariable.WorkSpaceDir, FdfFilename)
|
||||
|
||||
if not os.path.exists(FdfFilename):
|
||||
EdkLogger.error("GenFds", FILE_NOT_FOUND, ExtraData=FdfFilename)
|
||||
GenFdsGlobalVariable.FdfFile = FdfFilename
|
||||
GenFdsGlobalVariable.FdfFileTimeStamp = os.path.getmtime(FdfFilename)
|
||||
|
||||
if (Options.activePlatform):
|
||||
ActivePlatform = Options.activePlatform
|
||||
ActivePlatform = GenFdsGlobalVariable.ReplaceWorkspaceMacro(ActivePlatform)
|
||||
@@ -124,22 +126,22 @@ def main():
|
||||
if ActivePlatform[0:2] == '..':
|
||||
ActivePlatform = os.path.realpath(ActivePlatform)
|
||||
|
||||
if ActivePlatform[1] != ':':
|
||||
if not os.path.isabs (ActivePlatform):
|
||||
ActivePlatform = os.path.join(GenFdsGlobalVariable.WorkSpaceDir, ActivePlatform)
|
||||
|
||||
if not os.path.exists(ActivePlatform) :
|
||||
EdkLogger.error("GenFds", FILE_NOT_FOUND, "ActivePlatform doesn't exist!")
|
||||
|
||||
if ActivePlatform.find(Workspace) == -1:
|
||||
if os.path.normcase (ActivePlatform).find(Workspace) != 0:
|
||||
EdkLogger.error("GenFds", FILE_NOT_FOUND, "ActivePlatform doesn't exist in Workspace!")
|
||||
|
||||
ActivePlatform = ActivePlatform.replace(Workspace, '')
|
||||
ActivePlatform = ActivePlatform[len(Workspace):]
|
||||
if len(ActivePlatform) > 0 :
|
||||
if ActivePlatform[0] == '\\' or ActivePlatform[0] == '/':
|
||||
ActivePlatform = ActivePlatform[1:]
|
||||
else:
|
||||
EdkLogger.error("GenFds", FILE_NOT_FOUND, "ActivePlatform doesn't exist!")
|
||||
else :
|
||||
else:
|
||||
EdkLogger.error("GenFds", OPTION_MISSING, "Missing active platform")
|
||||
|
||||
GenFdsGlobalVariable.ActivePlatform = PathClass(NormPath(ActivePlatform), Workspace)
|
||||
@@ -190,9 +192,14 @@ def main():
|
||||
|
||||
for Arch in ArchList:
|
||||
GenFdsGlobalVariable.OutputDirFromDscDict[Arch] = NormPath(BuildWorkSpace.BuildObject[GenFdsGlobalVariable.ActivePlatform, Arch].OutputDirectory)
|
||||
GenFdsGlobalVariable.PlatformName = BuildWorkSpace.BuildObject[GenFdsGlobalVariable.ActivePlatform, Arch].PlatformName
|
||||
|
||||
if (Options.outputDir):
|
||||
OutputDirFromCommandLine = GenFdsGlobalVariable.ReplaceWorkspaceMacro(Options.outputDir)
|
||||
if not os.path.isabs (Options.outputDir):
|
||||
Options.outputDir = os.path.join(GenFdsGlobalVariable.WorkSpaceDir, Options.outputDir)
|
||||
if os.path.normcase (Options.outputDir).find(Workspace) != 0:
|
||||
EdkLogger.error("GenFds", FILE_NOT_FOUND, "OutputDir doesn't exist in Workspace!")
|
||||
for Arch in ArchList:
|
||||
GenFdsGlobalVariable.OutputDirDict[Arch] = OutputDirFromCommandLine
|
||||
else:
|
||||
@@ -237,10 +244,13 @@ def main():
|
||||
GenFds.PreprocessImage(BuildWorkSpace, GenFdsGlobalVariable.ActivePlatform)
|
||||
"""Call GenFds"""
|
||||
GenFds.GenFd('', FdfParserObj, BuildWorkSpace, ArchList)
|
||||
|
||||
|
||||
"""Generate GUID cross reference file"""
|
||||
GenFds.GenerateGuidXRefFile(BuildWorkSpace, ArchList)
|
||||
|
||||
"""Display FV space info."""
|
||||
GenFds.DisplayFvSpaceInfo(FdfParserObj)
|
||||
|
||||
|
||||
except FdfParser.Warning, X:
|
||||
EdkLogger.error(X.ToolName, FORMAT_INVALID, File=X.FileName, Line=X.LineNumber, ExtraData=X.Message, RaiseError = False)
|
||||
ReturnCode = FORMAT_INVALID
|
||||
@@ -352,7 +362,7 @@ class GenFds :
|
||||
# Get FV base Address
|
||||
FvObj.AddToBuffer(Buffer, None, GenFds.GetFvBlockSize(FvObj))
|
||||
Buffer.close()
|
||||
|
||||
|
||||
if GenFds.OnlyGenerateThisFv == None and GenFds.OnlyGenerateThisFd == None:
|
||||
if GenFdsGlobalVariable.FdfParser.Profile.CapsuleDict != {}:
|
||||
GenFdsGlobalVariable.VerboseLogger("\n Generate other Capsule images!")
|
||||
@@ -372,7 +382,7 @@ class GenFds :
|
||||
# @retval int Block size value
|
||||
#
|
||||
def GetFvBlockSize(FvObj):
|
||||
DefaultBlockSize = 0x10000
|
||||
DefaultBlockSize = 0x1
|
||||
FdObj = None
|
||||
if GenFds.OnlyGenerateThisFd != None and GenFds.OnlyGenerateThisFd.upper() in GenFdsGlobalVariable.FdfParser.Profile.FdDict.keys():
|
||||
FdObj = GenFdsGlobalVariable.FdfParser.Profile.FdDict[GenFds.OnlyGenerateThisFd.upper()]
|
||||
@@ -476,11 +486,23 @@ class GenFds :
|
||||
ModuleObj = BuildDb.BuildObject[Key, 'COMMON']
|
||||
print ModuleObj.BaseName + ' ' + ModuleObj.ModuleType
|
||||
|
||||
def GenerateGuidXRefFile(BuildDb, ArchList):
|
||||
GuidXRefFileName = os.path.join(GenFdsGlobalVariable.FvDir, "Guid.xref")
|
||||
GuidXRefFile = open(GuidXRefFileName, "w+")
|
||||
for Arch in ArchList:
|
||||
PlatformDataBase = BuildDb.BuildObject[GenFdsGlobalVariable.ActivePlatform, Arch]
|
||||
for ModuleFile in PlatformDataBase.Modules:
|
||||
Module = BuildDb.BuildObject[ModuleFile, Arch]
|
||||
GuidXRefFile.write("%s %s\n" % (Module.Guid, Module.BaseName))
|
||||
GuidXRefFile.close()
|
||||
GenFdsGlobalVariable.InfLogger("\nGUID cross reference file saved to %s" % GuidXRefFileName)
|
||||
|
||||
##Define GenFd as static function
|
||||
GenFd = staticmethod(GenFd)
|
||||
GetFvBlockSize = staticmethod(GetFvBlockSize)
|
||||
DisplayFvSpaceInfo = staticmethod(DisplayFvSpaceInfo)
|
||||
PreprocessImage = staticmethod(PreprocessImage)
|
||||
GenerateGuidXRefFile = staticmethod(GenerateGuidXRefFile)
|
||||
|
||||
if __name__ == '__main__':
|
||||
r = main()
|
||||
|
@@ -1,7 +1,7 @@
|
||||
## @file
|
||||
# Global variables for GenFds
|
||||
#
|
||||
# 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
|
||||
@@ -54,6 +54,7 @@ class GenFdsGlobalVariable:
|
||||
FdfFile = ''
|
||||
FdfFileTimeStamp = 0
|
||||
FixedLoadAddress = False
|
||||
PlatformName = ''
|
||||
|
||||
SectionHeader = struct.Struct("3B 1B")
|
||||
|
||||
@@ -154,7 +155,7 @@ class GenFdsGlobalVariable:
|
||||
|
||||
@staticmethod
|
||||
def GenerateSection(Output, Input, Type=None, CompressionType=None, Guid=None,
|
||||
GuidHdrLen=None, GuidAttr=None, Ui=None, Ver=None):
|
||||
GuidHdrLen=None, GuidAttr=[], Ui=None, Ver=None, InputAlign=None):
|
||||
if not GenFdsGlobalVariable.NeedsUpdate(Output, Input):
|
||||
return
|
||||
GenFdsGlobalVariable.DebugLogger(EdkLogger.DEBUG_5, "%s needs update because of newer %s" % (Output, Input))
|
||||
@@ -168,8 +169,14 @@ class GenFdsGlobalVariable:
|
||||
Cmd += ["-g", Guid]
|
||||
if GuidHdrLen not in [None, '']:
|
||||
Cmd += ["-l", GuidHdrLen]
|
||||
if GuidAttr not in [None, '']:
|
||||
Cmd += ["-r", GuidAttr]
|
||||
if len(GuidAttr) != 0:
|
||||
#Add each guided attribute
|
||||
for Attr in GuidAttr:
|
||||
Cmd += ["-r", Attr]
|
||||
if InputAlign != None:
|
||||
#Section Align is only for dummy section without section type
|
||||
for SecAlign in InputAlign:
|
||||
Cmd += ["--sectionalign", SecAlign]
|
||||
|
||||
if Ui not in [None, '']:
|
||||
#Cmd += ["-n", '"' + Ui + '"']
|
||||
@@ -194,6 +201,15 @@ class GenFdsGlobalVariable:
|
||||
Cmd += Input
|
||||
GenFdsGlobalVariable.CallExternalTool(Cmd, "Failed to generate section")
|
||||
|
||||
@staticmethod
|
||||
def GetAlignment (AlignString):
|
||||
if AlignString == None:
|
||||
return 0
|
||||
if AlignString in ("1K", "2K", "4K", "8K", "16K", "32K", "64K"):
|
||||
return int (AlignString.rstrip('K')) * 1024
|
||||
else:
|
||||
return int (AlignString)
|
||||
|
||||
@staticmethod
|
||||
def GenerateFfs(Output, Input, Type, Guid, Fixed=False, CheckSum=False, Align=None,
|
||||
SectionAlign=None):
|
||||
@@ -331,18 +347,19 @@ class GenFdsGlobalVariable:
|
||||
GenFdsGlobalVariable.CallExternalTool(Cmd, "Failed to generate option rom")
|
||||
|
||||
@staticmethod
|
||||
def GuidTool(Output, Input, ToolPath, Options=''):
|
||||
def GuidTool(Output, Input, ToolPath, Options='', returnValue=[]):
|
||||
if not GenFdsGlobalVariable.NeedsUpdate(Output, Input):
|
||||
return
|
||||
GenFdsGlobalVariable.DebugLogger(EdkLogger.DEBUG_5, "%s needs update because of newer %s" % (Output, Input))
|
||||
|
||||
Cmd = [ToolPath, Options]
|
||||
Cmd = [ToolPath, ]
|
||||
Cmd += Options.split(' ')
|
||||
Cmd += ["-o", Output]
|
||||
Cmd += Input
|
||||
|
||||
GenFdsGlobalVariable.CallExternalTool(Cmd, "Failed to call " + ToolPath)
|
||||
GenFdsGlobalVariable.CallExternalTool(Cmd, "Failed to call " + ToolPath, returnValue)
|
||||
|
||||
def CallExternalTool (cmd, errorMess):
|
||||
def CallExternalTool (cmd, errorMess, returnValue=[]):
|
||||
|
||||
if type(cmd) not in (tuple, list):
|
||||
GenFdsGlobalVariable.ErrorLogger("ToolError! Invalid parameter type in call to CallExternalTool")
|
||||
@@ -369,6 +386,10 @@ class GenFdsGlobalVariable:
|
||||
|
||||
while PopenObject.returncode == None :
|
||||
PopenObject.wait()
|
||||
if returnValue != [] and returnValue[0] != 0:
|
||||
#get command return value
|
||||
returnValue[0] = PopenObject.returncode
|
||||
return
|
||||
if PopenObject.returncode != 0 or GenFdsGlobalVariable.VerboseMode or GenFdsGlobalVariable.DebugLevel != -1:
|
||||
GenFdsGlobalVariable.InfLogger ("Return Value = %d" %PopenObject.returncode)
|
||||
GenFdsGlobalVariable.InfLogger (out)
|
||||
|
@@ -1,7 +1,7 @@
|
||||
## @file
|
||||
# process GUIDed section generation
|
||||
#
|
||||
# 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
|
||||
@@ -25,6 +25,7 @@ from Common import ToolDefClassObject
|
||||
import sys
|
||||
from Common import EdkLogger
|
||||
from Common.BuildToolError import *
|
||||
from FvImageSection import FvImageSection
|
||||
|
||||
## generate GUIDed section
|
||||
#
|
||||
@@ -63,16 +64,57 @@ class GuidSection(GuidSectionClassObject) :
|
||||
self.SectionType = FfsInf.__ExtendMacro__(self.SectionType)
|
||||
self.CurrentArchList = [FfsInf.CurrentArch]
|
||||
|
||||
SectFile = tuple()
|
||||
SectFile = tuple()
|
||||
SectAlign = []
|
||||
Index = 0
|
||||
MaxAlign = None
|
||||
if self.FvAddr != []:
|
||||
FvAddrIsSet = True
|
||||
else:
|
||||
FvAddrIsSet = False
|
||||
|
||||
if self.ProcessRequired in ("TRUE", "1"):
|
||||
if self.FvAddr != []:
|
||||
#no use FvAddr when the image is processed.
|
||||
self.FvAddr = []
|
||||
if self.FvParentAddr != None:
|
||||
#no use Parent Addr when the image is processed.
|
||||
self.FvParentAddr = None
|
||||
|
||||
for Sect in self.SectionList:
|
||||
Index = Index + 1
|
||||
SecIndex = '%s.%d' %(SecNum,Index)
|
||||
# set base address for inside FvImage
|
||||
if isinstance(Sect, FvImageSection):
|
||||
if self.FvAddr != []:
|
||||
Sect.FvAddr = self.FvAddr.pop(0)
|
||||
self.IncludeFvSection = True
|
||||
elif isinstance(Sect, GuidSection):
|
||||
Sect.FvAddr = self.FvAddr
|
||||
Sect.FvParentAddr = self.FvParentAddr
|
||||
ReturnSectList, align = Sect.GenSection(OutputPath, ModuleName, SecIndex, KeyStringList,FfsInf, Dict)
|
||||
if isinstance(Sect, GuidSection):
|
||||
if Sect.IncludeFvSection:
|
||||
self.IncludeFvSection = Sect.IncludeFvSection
|
||||
|
||||
if align != None:
|
||||
if MaxAlign == None:
|
||||
MaxAlign = align
|
||||
if GenFdsGlobalVariable.GetAlignment (align) > GenFdsGlobalVariable.GetAlignment (MaxAlign):
|
||||
MaxAlign = align
|
||||
if ReturnSectList != []:
|
||||
if align == None:
|
||||
align = "1"
|
||||
for file in ReturnSectList:
|
||||
SectFile += (file,)
|
||||
SectAlign.append(align)
|
||||
|
||||
if MaxAlign != None:
|
||||
if self.Alignment == None:
|
||||
self.Alignment = MaxAlign
|
||||
else:
|
||||
if GenFdsGlobalVariable.GetAlignment (MaxAlign) > GenFdsGlobalVariable.GetAlignment (self.Alignment):
|
||||
self.Alignment = MaxAlign
|
||||
|
||||
OutputFile = OutputPath + \
|
||||
os.sep + \
|
||||
@@ -83,15 +125,17 @@ class GuidSection(GuidSectionClassObject) :
|
||||
OutputFile = os.path.normpath(OutputFile)
|
||||
|
||||
ExternalTool = None
|
||||
ExternalOption = None
|
||||
if self.NameGuid != None:
|
||||
ExternalTool = self.__FindExtendTool__()
|
||||
ExternalTool, ExternalOption = self.__FindExtendTool__()
|
||||
|
||||
#
|
||||
# If not have GUID , call default
|
||||
# GENCRC32 section
|
||||
#
|
||||
if self.NameGuid == None :
|
||||
GenFdsGlobalVariable.VerboseLogger( "Use GenSection function Generate CRC32 Section")
|
||||
GenFdsGlobalVariable.GenerateSection(OutputFile, SectFile, Section.Section.SectionType[self.SectionType])
|
||||
GenFdsGlobalVariable.GenerateSection(OutputFile, SectFile, Section.Section.SectionType[self.SectionType], InputAlign=SectAlign)
|
||||
OutputFileList = []
|
||||
OutputFileList.append(OutputFile)
|
||||
return OutputFileList, self.Alignment
|
||||
@@ -99,14 +143,14 @@ class GuidSection(GuidSectionClassObject) :
|
||||
elif ExternalTool == None:
|
||||
EdkLogger.error("GenFds", GENFDS_ERROR, "No tool found with GUID %s" % self.NameGuid)
|
||||
else:
|
||||
DummyFile = OutputFile+".dummy"
|
||||
#
|
||||
# Call GenSection with DUMMY section type.
|
||||
#
|
||||
GenFdsGlobalVariable.GenerateSection(OutputFile+".dummy", SectFile)
|
||||
GenFdsGlobalVariable.GenerateSection(DummyFile, SectFile, InputAlign=SectAlign)
|
||||
#
|
||||
# Use external tool process the Output
|
||||
#
|
||||
InputFile = OutputFile+".dummy"
|
||||
TempFile = OutputPath + \
|
||||
os.sep + \
|
||||
ModuleName + \
|
||||
@@ -115,30 +159,76 @@ class GuidSection(GuidSectionClassObject) :
|
||||
'.tmp'
|
||||
TempFile = os.path.normpath(TempFile)
|
||||
|
||||
ExternalToolCmd = (
|
||||
ExternalTool,
|
||||
'-e',
|
||||
'-o', TempFile,
|
||||
InputFile,
|
||||
)
|
||||
|
||||
FirstCall = False
|
||||
CmdOption = '-e'
|
||||
if ExternalOption != None:
|
||||
CmdOption = CmdOption + ' ' + ExternalOption
|
||||
if self.ProcessRequired not in ("TRUE", "1") and self.IncludeFvSection and not FvAddrIsSet and self.FvParentAddr != None:
|
||||
#FirstCall is only set for the encapsulated flash FV image without process required attribute.
|
||||
FirstCall = True
|
||||
#
|
||||
# Call external tool
|
||||
#
|
||||
GenFdsGlobalVariable.GuidTool(TempFile, [InputFile], ExternalTool, '-e')
|
||||
ReturnValue = [1]
|
||||
if FirstCall:
|
||||
#first try to call the guided tool with -z option and CmdOption for the no process required guided tool.
|
||||
GenFdsGlobalVariable.GuidTool(TempFile, [DummyFile], ExternalTool, '-z' + ' ' + CmdOption, ReturnValue)
|
||||
|
||||
#
|
||||
# Call Gensection Add Secntion Header
|
||||
# when no call or first call failed, ReturnValue are not 1.
|
||||
# Call the guided tool with CmdOption
|
||||
#
|
||||
Attribute = None
|
||||
if self.ProcessRequired == True:
|
||||
Attribute = 'PROCSSING_REQUIRED'
|
||||
if self.AuthStatusValid == True:
|
||||
Attribute = 'AUTH_STATUS_VALID'
|
||||
if ReturnValue[0] != 0:
|
||||
FirstCall = False
|
||||
ReturnValue[0] = 0
|
||||
GenFdsGlobalVariable.GuidTool(TempFile, [DummyFile], ExternalTool, CmdOption)
|
||||
|
||||
FileHandleIn = open(DummyFile,'rb')
|
||||
FileHandleIn.seek(0,2)
|
||||
InputFileSize = FileHandleIn.tell()
|
||||
|
||||
FileHandleOut = open(TempFile,'rb')
|
||||
FileHandleOut.seek(0,2)
|
||||
TempFileSize = FileHandleOut.tell()
|
||||
|
||||
Attribute = []
|
||||
HeaderLength = None
|
||||
if TempFileSize > InputFileSize and TempFileSize % 4 == 0:
|
||||
FileHandleIn.seek(0)
|
||||
BufferIn = FileHandleIn.read()
|
||||
FileHandleOut.seek(0)
|
||||
BufferOut = FileHandleOut.read()
|
||||
if BufferIn == BufferOut[TempFileSize - InputFileSize:]:
|
||||
HeaderLength = str(TempFileSize - InputFileSize)
|
||||
#auto sec guided attribute with process required
|
||||
if HeaderLength == None:
|
||||
Attribute.append('PROCESSING_REQUIRED')
|
||||
|
||||
FileHandleIn.close()
|
||||
FileHandleOut.close()
|
||||
|
||||
if FirstCall and 'PROCESSING_REQUIRED' in Attribute:
|
||||
# Guided data by -z option on first call is the process required data. Call the guided tool with the real option.
|
||||
GenFdsGlobalVariable.GuidTool(TempFile, [DummyFile], ExternalTool, CmdOption)
|
||||
|
||||
#
|
||||
# Call Gensection Add Section Header
|
||||
#
|
||||
if self.ProcessRequired in ("TRUE", "1"):
|
||||
if 'PROCESSING_REQUIRED' not in Attribute:
|
||||
Attribute.append('PROCESSING_REQUIRED')
|
||||
HeaderLength = None
|
||||
if self.AuthStatusValid in ("TRUE", "1"):
|
||||
Attribute.append('AUTH_STATUS_VALID')
|
||||
GenFdsGlobalVariable.GenerateSection(OutputFile, [TempFile], Section.Section.SectionType['GUIDED'],
|
||||
Guid=self.NameGuid, GuidAttr=Attribute)
|
||||
Guid=self.NameGuid, GuidAttr=Attribute, GuidHdrLen=HeaderLength)
|
||||
OutputFileList = []
|
||||
OutputFileList.append(OutputFile)
|
||||
if 'PROCESSING_REQUIRED' in Attribute:
|
||||
# reset guided section alignment to none for the processed required guided data
|
||||
self.Alignment = None
|
||||
self.IncludeFvSection = False
|
||||
self.ProcessRequired = "TRUE"
|
||||
return OutputFileList, self.Alignment
|
||||
|
||||
## __FindExtendTool()
|
||||
@@ -177,6 +267,12 @@ class GuidSection(GuidSectionClassObject) :
|
||||
KeyList[3] + \
|
||||
'_' + \
|
||||
'PATH')
|
||||
|
||||
ToolOption = ToolDefinition.get( Key + \
|
||||
'_' + \
|
||||
KeyList[3] + \
|
||||
'_' + \
|
||||
'FLAGS')
|
||||
if ToolPathTmp == None:
|
||||
ToolPathTmp = ToolPath
|
||||
else:
|
||||
@@ -184,7 +280,7 @@ class GuidSection(GuidSectionClassObject) :
|
||||
EdkLogger.error("GenFds", GENFDS_ERROR, "Don't know which tool to use, %s or %s ?" % (ToolPathTmp, ToolPath))
|
||||
|
||||
|
||||
return ToolPathTmp
|
||||
return ToolPathTmp, ToolOption
|
||||
|
||||
|
||||
|
||||
|
@@ -140,7 +140,6 @@ class Section (SectionClassObject):
|
||||
GenFdsGlobalVariable.InfLogger ("\nCurrent ARCH \'%s\' of File %s is not in the Support Arch Scope of %s specified by INF %s in FDF" %(FfsInf.CurrentArch, File.File, File.Arch, FfsInf.InfFileName))
|
||||
|
||||
if Suffix != None and os.path.exists(FfsInf.EfiOutputPath):
|
||||
# FileList.extend(glob.glob(os.path.join(FfsInf.EfiOutputPath, "*" + Suffix)))
|
||||
# Update to search files with suffix in all sub-dirs.
|
||||
Tuple = os.walk(FfsInf.EfiOutputPath)
|
||||
for Dirpath, Dirnames, Filenames in Tuple:
|
||||
@@ -149,5 +148,9 @@ class Section (SectionClassObject):
|
||||
FullName = os.path.join(Dirpath, F)
|
||||
FileList.append(FullName)
|
||||
|
||||
#Process the file lists is alphabetical for a same section type
|
||||
if len (FileList) > 1:
|
||||
FileList.sort()
|
||||
|
||||
return FileList, IsSect
|
||||
GetFileList = staticmethod(GetFileList)
|
||||
|
@@ -0,0 +1,15 @@
|
||||
## @file
|
||||
# Python 'GenFds' 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.
|
||||
#
|
||||
|
189
BaseTools/Source/Python/GenPatchPcdTable/GenPatchPcdTable.py
Normal file
189
BaseTools/Source/Python/GenPatchPcdTable/GenPatchPcdTable.py
Normal file
@@ -0,0 +1,189 @@
|
||||
## @file
|
||||
# Generate PCD table for 'Patchable In Module' type PCD with given .map file.
|
||||
# The Patch PCD table like:
|
||||
#
|
||||
# PCD Name Offset in binary
|
||||
# ======== ================
|
||||
#
|
||||
# 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.
|
||||
#
|
||||
#
|
||||
|
||||
#====================================== External Libraries ========================================
|
||||
import optparse
|
||||
import os
|
||||
import re
|
||||
import array
|
||||
|
||||
from Common.BuildToolError import *
|
||||
import Common.EdkLogger as EdkLogger
|
||||
from Common.Misc import PeImageClass
|
||||
|
||||
# Version and Copyright
|
||||
__version_number__ = "0.10"
|
||||
__version__ = "%prog Version " + __version_number__
|
||||
__copyright__ = "Copyright (c) 2008 - 2010, Intel Corporation. All rights reserved."
|
||||
|
||||
#====================================== Internal Libraries ========================================
|
||||
|
||||
#============================================== Code ===============================================
|
||||
secRe = re.compile('^([\da-fA-F]+):([\da-fA-F]+) +([\da-fA-F]+)[Hh]? +([.\w\$]+) +(\w+)', re.UNICODE)
|
||||
symRe = re.compile('^([\da-fA-F]+):([\da-fA-F]+) +([\.:\\\\\w\?@\$]+) +([\da-fA-F]+)', re.UNICODE)
|
||||
|
||||
def parsePcdInfoFromMapFile(mapfilepath, efifilepath):
|
||||
""" Parse map file to get binary patch pcd information
|
||||
@param path Map file absolution path
|
||||
|
||||
@return a list which element hold (PcdName, Offset, SectionName)
|
||||
"""
|
||||
lines = []
|
||||
try:
|
||||
f = open(mapfilepath, 'r')
|
||||
lines = f.readlines()
|
||||
f.close()
|
||||
except:
|
||||
return None
|
||||
|
||||
if len(lines) == 0: return None
|
||||
if lines[0].strip().find("Archive member included because of file (symbol)") != -1:
|
||||
return _parseForGCC(lines)
|
||||
return _parseGeneral(lines, efifilepath)
|
||||
|
||||
def _parseForGCC(lines):
|
||||
""" Parse map file generated by GCC linker """
|
||||
status = 0
|
||||
imageBase = -1
|
||||
lastSectionName = None
|
||||
pcds = []
|
||||
for line in lines:
|
||||
line = line.strip()
|
||||
# status machine transection
|
||||
if status == 0 and line == "Linker script and memory map":
|
||||
status = 1
|
||||
continue
|
||||
elif status == 1 and line == 'START GROUP':
|
||||
status = 2
|
||||
continue
|
||||
|
||||
# status handler:
|
||||
if status == 1:
|
||||
m = re.match('^[\da-fA-FxhH]+ +__image_base__ += +([\da-fA-FhxH]+)', line)
|
||||
if m != None:
|
||||
imageBase = int(m.groups(0)[0], 16)
|
||||
if status == 2:
|
||||
m = re.match('^([\w_\.]+) +([\da-fA-Fx]+) +([\da-fA-Fx]+)', line)
|
||||
if m != None:
|
||||
lastSectionName = m.groups(0)[0]
|
||||
if status == 2:
|
||||
m = re.match("^([\da-fA-Fx]+) +[_]+gPcd_BinaryPatch_([\w_\d]+)", line)
|
||||
if m != None:
|
||||
assert imageBase != -1, "Fail to get Binary PCD offsest for unknown image base address"
|
||||
pcds.append((m.groups(0)[1], int(m.groups(0)[0], 16) - imageBase, lastSectionName))
|
||||
return pcds
|
||||
|
||||
def _parseGeneral(lines, efifilepath):
|
||||
""" For MSFT, ICC, EBC
|
||||
@param lines line array for map file
|
||||
|
||||
@return a list which element hold (PcdName, Offset, SectionName)
|
||||
"""
|
||||
status = 0 #0 - beginning of file; 1 - PE section definition; 2 - symbol table
|
||||
secs = [] # key = section name
|
||||
bPcds = []
|
||||
|
||||
|
||||
for line in lines:
|
||||
line = line.strip()
|
||||
if re.match("^Start[' ']+Length[' ']+Name[' ']+Class", line):
|
||||
status = 1
|
||||
continue
|
||||
if re.match("^Address[' ']+Publics by Value[' ']+Rva\+Base", line):
|
||||
status = 2
|
||||
continue
|
||||
if re.match("^entry point at", line):
|
||||
status = 3
|
||||
continue
|
||||
if status == 1 and len(line) != 0:
|
||||
m = secRe.match(line)
|
||||
assert m != None, "Fail to parse the section in map file , line is %s" % line
|
||||
sec_no, sec_start, sec_length, sec_name, sec_class = m.groups(0)
|
||||
secs.append([int(sec_no, 16), int(sec_start, 16), int(sec_length, 16), sec_name, sec_class])
|
||||
if status == 2 and len(line) != 0:
|
||||
m = symRe.match(line)
|
||||
assert m != None, "Fail to parse the symbol in map file, line is %s" % line
|
||||
sec_no, sym_offset, sym_name, vir_addr = m.groups(0)
|
||||
sec_no = int(sec_no, 16)
|
||||
sym_offset = int(sym_offset, 16)
|
||||
vir_addr = int(vir_addr, 16)
|
||||
m2 = re.match('^[_]+gPcd_BinaryPatch_([\w]+)', sym_name)
|
||||
if m2 != None:
|
||||
# fond a binary pcd entry in map file
|
||||
for sec in secs:
|
||||
if sec[0] == sec_no and (sym_offset >= sec[1] and sym_offset < sec[1] + sec[2]):
|
||||
bPcds.append([m2.groups(0)[0], sec[3], sym_offset, vir_addr, sec_no])
|
||||
|
||||
if len(bPcds) == 0: return None
|
||||
|
||||
# get section information from efi file
|
||||
efisecs = PeImageClass(efifilepath).SectionHeaderList
|
||||
if efisecs == None or len(efisecs) == 0:
|
||||
return None
|
||||
|
||||
pcds = []
|
||||
for pcd in bPcds:
|
||||
index = 0
|
||||
for efisec in efisecs:
|
||||
index = index + 1
|
||||
if pcd[1].strip() == efisec[0].strip():
|
||||
pcds.append([pcd[0], efisec[2] + pcd[2], efisec[0]])
|
||||
elif pcd[4] == index:
|
||||
pcds.append([pcd[0], efisec[2] + pcd[2], efisec[0]])
|
||||
return pcds
|
||||
|
||||
def generatePcdTable(list, pcdpath):
|
||||
try:
|
||||
f = open(pcdpath, 'w')
|
||||
except:
|
||||
pass
|
||||
|
||||
f.write('PCD Name Offset Section Name\r\n')
|
||||
|
||||
for pcditem in list:
|
||||
f.write('%-30s 0x%-08X %-6s\r\n' % (pcditem[0], pcditem[1], pcditem[2]))
|
||||
f.close()
|
||||
|
||||
#print 'Success to generate Binary Patch PCD table at %s!' % pcdpath
|
||||
|
||||
if __name__ == '__main__':
|
||||
UsageString = "%prog -m <MapFile> -e <EfiFile> -o <OutFile>"
|
||||
AdditionalNotes = "\nPCD table is generated in file name with .BinaryPcdTable.txt postfix"
|
||||
parser = optparse.OptionParser(description=__copyright__, version=__version__, usage=UsageString)
|
||||
parser.add_option('-m', '--mapfile', action='store', dest='mapfile',
|
||||
help='Absolute path of module map file.')
|
||||
parser.add_option('-e', '--efifile', action='store', dest='efifile',
|
||||
help='Absolute path of EFI binary file.')
|
||||
parser.add_option('-o', '--outputfile', action='store', dest='outfile',
|
||||
help='Absolute path of output file to store the got patchable PCD table.')
|
||||
|
||||
(options, args) = parser.parse_args()
|
||||
|
||||
if options.mapfile == None or options.efifile == None:
|
||||
print parser.get_usage()
|
||||
elif os.path.exists(options.mapfile) and os.path.exists(options.efifile):
|
||||
list = parsePcdInfoFromMapFile(options.mapfile, options.efifile)
|
||||
if list != None:
|
||||
if options.outfile != None:
|
||||
generatePcdTable(list, options.outfile)
|
||||
else:
|
||||
generatePcdTable(list, options.mapfile.replace('.map', '.BinaryPcdTable.txt'))
|
||||
else:
|
||||
print 'Fail to generate Patch PCD Table based on map file and efi file'
|
||||
else:
|
||||
print 'Fail to generate Patch PCD Table for fail to find map file or efi file!'
|
15
BaseTools/Source/Python/GenPatchPcdTable/__init__.py
Normal file
15
BaseTools/Source/Python/GenPatchPcdTable/__init__.py
Normal file
@@ -0,0 +1,15 @@
|
||||
## @file
|
||||
# Python 'GenPatchPcdTable' 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.
|
||||
#
|
@@ -10,7 +10,7 @@ MODULES=encodings.cp437,encodings.gbk,encodings.utf_16,encodings.utf_8,encodings
|
||||
BIN_DIR=$(EDK_TOOLS_PATH)\Bin\Win32
|
||||
|
||||
|
||||
APPLICATIONS=$(BIN_DIR)\build.exe $(BIN_DIR)\GenFds.exe $(BIN_DIR)\Trim.exe $(BIN_DIR)\MigrationMsa2Inf.exe $(BIN_DIR)\Fpd2Dsc.exe $(BIN_DIR)\TargetTool.exe $(BIN_DIR)\spd2dec.exe $(BIN_DIR)\GenDepex.exe
|
||||
APPLICATIONS=$(BIN_DIR)\build.exe $(BIN_DIR)\GenFds.exe $(BIN_DIR)\Trim.exe $(BIN_DIR)\MigrationMsa2Inf.exe $(BIN_DIR)\Fpd2Dsc.exe $(BIN_DIR)\TargetTool.exe $(BIN_DIR)\spd2dec.exe $(BIN_DIR)\GenDepex.exe $(BIN_DIR)\GenPatchPcdTable.exe $(BIN_DIR)\PatchPcdValue.exe
|
||||
|
||||
COMMON_PYTHON=$(BASE_TOOLS_PATH)\Source\Python\Common\BuildToolError.py \
|
||||
$(BASE_TOOLS_PATH)\Source\Python\Common\Database.py \
|
||||
@@ -82,6 +82,12 @@ $(BIN_DIR)\GenDepex.exe: $(BASE_TOOLS_PATH)\Source\Python\AutoGen\GenDepex.py $(
|
||||
$(BIN_DIR)\TargetTool.exe: $(BASE_TOOLS_PATH)\Source\Python\TargetTool\TargetTool.py $(COMMON_PYTHON)
|
||||
@pushd . & @cd TargetTool & @$(FREEZE) --include-modules=$(MODULES) --install-dir=$(BIN_DIR) TargetTool.py & @popd
|
||||
|
||||
$(BIN_DIR)\GenPatchPcdTable.exe: $(BASE_TOOLS_PATH)\Source\Python\GenPatchPcdTable\GenPatchPcdTable.py $(COMMON_PYTHON)
|
||||
@pushd . & @cd GenPatchPcdTable & @$(FREEZE) --include-modules=$(MODULES) --install-dir=$(BIN_DIR) GenPatchPcdTable.py & @popd
|
||||
|
||||
$(BIN_DIR)\PatchPcdValue.exe: $(BASE_TOOLS_PATH)\Source\Python\PatchPcdValue\PatchPcdValue.py $(COMMON_PYTHON)
|
||||
@pushd . & @cd PatchPcdValue & @$(FREEZE) --include-modules=$(MODULES) --install-dir=$(BIN_DIR) PatchPcdValue.py & @popd
|
||||
|
||||
clean:
|
||||
cleanall:
|
||||
@del /f /q $(BIN_DIR)\*.pyd $(BIN_DIR)\*.dll
|
||||
|
@@ -1,7 +1,7 @@
|
||||
#!/usr/bin/env python
|
||||
#
|
||||
#
|
||||
# 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
|
||||
@@ -21,7 +21,7 @@ from Common.EdkIIWorkspace import *
|
||||
|
||||
versionNumber = "0.9"
|
||||
__version__ = "%prog Version " + versionNumber
|
||||
__copyright__ = "Copyright (c) 2007, Intel Corporation All rights reserved."
|
||||
__copyright__ = "Copyright (c) 2007 - 2010, Intel Corporation All rights reserved."
|
||||
|
||||
commonHeaderFilename = "CommonHeader.h"
|
||||
entryPointFilename = "EntryPoint.c"
|
||||
|
@@ -0,0 +1,15 @@
|
||||
## @file
|
||||
# Python 'MigrationMsa2Inf' 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 'MkBOM' 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.
|
||||
#
|
||||
|
@@ -288,7 +288,7 @@ def Main():
|
||||
"\nInstallPkg",
|
||||
CODE_ERROR,
|
||||
"Unknown fatal error when installing [%s]" % Options.PackageFile,
|
||||
ExtraData="\n(Please send email to dev@buildtools.tianocore.org for help, attaching following call stack trace!)\n",
|
||||
ExtraData="\n(Please send email to edk2-buildtools-devel@lists.sourceforge.net for help, attaching following call stack trace!)\n",
|
||||
RaiseError=False
|
||||
)
|
||||
EdkLogger.quiet("(Python %s on %s) " % (platform.python_version(), sys.platform) + traceback.format_exc())
|
||||
|
@@ -281,7 +281,7 @@ def Main():
|
||||
"\nMkPkg",
|
||||
CODE_ERROR,
|
||||
"Unknown fatal error when creating [%s]" % Options.DistributionFile,
|
||||
ExtraData="\n(Please send email to dev@buildtools.tianocore.org for help, attaching following call stack trace!)\n",
|
||||
ExtraData="\n(Please send email to edk2-buildtools-devel@lists.sourceforge.net for help, attaching following call stack trace!)\n",
|
||||
RaiseError=False
|
||||
)
|
||||
EdkLogger.quiet("(Python %s on %s) " % (platform.python_version(), sys.platform) + traceback.format_exc())
|
||||
|
@@ -206,7 +206,7 @@ def Main():
|
||||
"\nRmPkg",
|
||||
CODE_ERROR,
|
||||
"Unknown fatal error when removing package",
|
||||
ExtraData="\n(Please send email to dev@buildtools.tianocore.org for help, attaching following call stack trace!)\n",
|
||||
ExtraData="\n(Please send email to edk2-buildtools-devel@lists.sourceforge.net for help, attaching following call stack trace!)\n",
|
||||
RaiseError=False
|
||||
)
|
||||
EdkLogger.quiet("(Python %s on %s) " % (platform.python_version(), sys.platform) + traceback.format_exc())
|
||||
|
287
BaseTools/Source/Python/PatchPcdValue/PatchPcdValue.py
Normal file
287
BaseTools/Source/Python/PatchPcdValue/PatchPcdValue.py
Normal file
@@ -0,0 +1,287 @@
|
||||
## @file
|
||||
# Patch value into the binary file.
|
||||
#
|
||||
# Copyright (c) 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 sys
|
||||
import re
|
||||
|
||||
from optparse import OptionParser
|
||||
from optparse import make_option
|
||||
from Common.BuildToolError import *
|
||||
import Common.EdkLogger as EdkLogger
|
||||
import array
|
||||
|
||||
# Version and Copyright
|
||||
__version_number__ = "0.10"
|
||||
__version__ = "%prog Version " + __version_number__
|
||||
__copyright__ = "Copyright (c) 2010, Intel Corporation. All rights reserved."
|
||||
|
||||
## PatchBinaryFile method
|
||||
#
|
||||
# This method mainly patches the data into binary file.
|
||||
#
|
||||
# @param FileName File path of the binary file
|
||||
# @param ValueOffset Offset value
|
||||
# @param TypeName DataType Name
|
||||
# @param Value Value String
|
||||
# @param MaxSize MaxSize value
|
||||
#
|
||||
# @retval 0 File is updated successfully.
|
||||
# @retval not 0 File is updated failed.
|
||||
#
|
||||
def PatchBinaryFile(FileName, ValueOffset, TypeName, ValueString, MaxSize=0):
|
||||
#
|
||||
# Length of Binary File
|
||||
#
|
||||
FileHandle = open (FileName, 'rb')
|
||||
FileHandle.seek (0, 2)
|
||||
FileLength = FileHandle.tell()
|
||||
FileHandle.close()
|
||||
#
|
||||
# Unify string to upper string
|
||||
#
|
||||
TypeName = TypeName.upper()
|
||||
#
|
||||
# Get PCD value data length
|
||||
#
|
||||
ValueLength = 0
|
||||
if TypeName == 'BOOLEAN':
|
||||
ValueLength = 1
|
||||
elif TypeName == 'UINT8':
|
||||
ValueLength = 1
|
||||
elif TypeName == 'UINT16':
|
||||
ValueLength = 2
|
||||
elif TypeName == 'UINT32':
|
||||
ValueLength = 4
|
||||
elif TypeName == 'UINT64':
|
||||
ValueLength = 8
|
||||
elif TypeName == 'VOID*':
|
||||
if MaxSize == 0:
|
||||
return OPTION_MISSING, "PcdMaxSize is not specified for VOID* type PCD."
|
||||
ValueLength = MaxSize
|
||||
else:
|
||||
return PARAMETER_INVALID, "PCD type %s is not valid." %(CommandOptions.PcdTypeName)
|
||||
#
|
||||
# Check PcdValue is in the input binary file.
|
||||
#
|
||||
if ValueOffset + ValueLength > FileLength:
|
||||
return PARAMETER_INVALID, "PcdOffset + PcdMaxSize(DataType) is larger than the input file size."
|
||||
#
|
||||
# Read binary file into array
|
||||
#
|
||||
FileHandle = open (FileName, 'rb')
|
||||
ByteArray = array.array('B')
|
||||
ByteArray.fromfile(FileHandle, FileLength)
|
||||
FileHandle.close()
|
||||
OrigByteList = ByteArray.tolist()
|
||||
ByteList = ByteArray.tolist()
|
||||
#
|
||||
# Clear the data in file
|
||||
#
|
||||
for Index in range(ValueLength):
|
||||
ByteList[ValueOffset + Index] = 0
|
||||
#
|
||||
# Patch value into offset
|
||||
#
|
||||
ValueString = ValueString.upper()
|
||||
ValueNumber = 0
|
||||
if TypeName == 'BOOLEAN':
|
||||
#
|
||||
# Get PCD value for BOOLEAN data type
|
||||
#
|
||||
try:
|
||||
if ValueString == 'TRUE':
|
||||
ValueNumber = 1
|
||||
elif ValueString == 'FALSE':
|
||||
ValueNumber = 0
|
||||
elif ValueString.startswith('0X'):
|
||||
ValueNumber = int (Value, 16)
|
||||
else:
|
||||
ValueNumber = int (Value)
|
||||
if ValueNumber != 0:
|
||||
ValueNumber = 1
|
||||
except:
|
||||
return PARAMETER_INVALID, "PCD Value %s is not valid dec or hex string." %(ValueString)
|
||||
#
|
||||
# Set PCD value into binary data
|
||||
#
|
||||
ByteList[ValueOffset] = ValueNumber
|
||||
elif TypeName in ['UINT8', 'UINT16', 'UINT32', 'UINT64']:
|
||||
#
|
||||
# Get PCD value for UINT* data type
|
||||
#
|
||||
try:
|
||||
if ValueString.startswith('0X'):
|
||||
ValueNumber = int (ValueString, 16)
|
||||
else:
|
||||
ValueNumber = int (ValueString)
|
||||
except:
|
||||
return PARAMETER_INVALID, "PCD Value %s is not valid dec or hex string." %(ValueString)
|
||||
#
|
||||
# Set PCD value into binary data
|
||||
#
|
||||
for Index in range(ValueLength):
|
||||
ByteList[ValueOffset + Index] = ValueNumber % 0x100
|
||||
ValueNumber = ValueNumber / 0x100
|
||||
elif TypeName == 'VOID*':
|
||||
if ValueString.startswith("L "):
|
||||
#
|
||||
# Patch Unicode String
|
||||
#
|
||||
Index = 0
|
||||
for ByteString in ValueString[2:]:
|
||||
#
|
||||
# Reserve zero as unicode tail
|
||||
#
|
||||
if Index + 2 >= ValueLength:
|
||||
break
|
||||
#
|
||||
# Set string value one by one
|
||||
#
|
||||
ByteList[ValueOffset + Index] = ord(ByteString)
|
||||
Index = Index + 2
|
||||
elif ValueString.startswith("{") and ValueString.endswith("}"):
|
||||
#
|
||||
# Patch {0x1, 0x2, ...} byte by byte
|
||||
#
|
||||
ValueList = ValueString[1 : len(ValueString) - 1].split(', ')
|
||||
Index = 0
|
||||
try:
|
||||
for ByteString in ValueList:
|
||||
if ByteString.upper().startswith('0X'):
|
||||
ByteValue = int(ByteString, 16)
|
||||
else:
|
||||
ByteValue = int(ByteString)
|
||||
ByteList[ValueOffset + Index] = ByteValue % 0x100
|
||||
Index = Index + 1
|
||||
if Index >= ValueLength:
|
||||
break
|
||||
except:
|
||||
return PARAMETER_INVALID, "PCD Value %s is not valid dec or hex string array." %(ValueString)
|
||||
else:
|
||||
#
|
||||
# Patch ascii string
|
||||
#
|
||||
Index = 0
|
||||
for ByteString in ValueString:
|
||||
#
|
||||
# Reserve zero as string tail
|
||||
#
|
||||
if Index + 1 >= ValueLength:
|
||||
break
|
||||
#
|
||||
# Set string value one by one
|
||||
#
|
||||
ByteList[ValueOffset + Index] = ord(ByteString)
|
||||
Index = Index + 1
|
||||
#
|
||||
# Update new data into input file.
|
||||
#
|
||||
if ByteList != OrigByteList:
|
||||
ByteArray = array.array('B')
|
||||
ByteArray.fromlist(ByteList)
|
||||
FileHandle = open (FileName, 'wb')
|
||||
ByteArray.tofile(FileHandle)
|
||||
FileHandle.close()
|
||||
return 0, "Patch Value into File %s successfully." %(FileName)
|
||||
|
||||
## Parse command line options
|
||||
#
|
||||
# Using standard Python module optparse to parse command line option of this tool.
|
||||
#
|
||||
# @retval Options A optparse.Values object containing the parsed options
|
||||
# @retval InputFile Path of file to be trimmed
|
||||
#
|
||||
def Options():
|
||||
OptionList = [
|
||||
make_option("-f", "--offset", dest="PcdOffset", action="store", type="int",
|
||||
help="Start offset to the image is used to store PCD value."),
|
||||
make_option("-u", "--value", dest="PcdValue", action="store",
|
||||
help="PCD value will be updated into the image."),
|
||||
make_option("-t", "--type", dest="PcdTypeName", action="store",
|
||||
help="The name of PCD data type may be one of VOID*,BOOLEAN, UINT8, UINT16, UINT32, UINT64."),
|
||||
make_option("-s", "--maxsize", dest="PcdMaxSize", action="store", type="int",
|
||||
help="Max size of data buffer is taken by PCD value.It must be set when PCD type is VOID*."),
|
||||
make_option("-v", "--verbose", dest="LogLevel", action="store_const", const=EdkLogger.VERBOSE,
|
||||
help="Run verbosely"),
|
||||
make_option("-d", "--debug", dest="LogLevel", type="int",
|
||||
help="Run with debug information"),
|
||||
make_option("-q", "--quiet", dest="LogLevel", action="store_const", const=EdkLogger.QUIET,
|
||||
help="Run quietly"),
|
||||
make_option("-?", action="help", help="show this help message and exit"),
|
||||
]
|
||||
|
||||
# use clearer usage to override default usage message
|
||||
UsageString = "%prog -f Offset -u Value -t Type [-s MaxSize] <input_file>"
|
||||
|
||||
Parser = OptionParser(description=__copyright__, version=__version__, option_list=OptionList, usage=UsageString)
|
||||
Parser.set_defaults(LogLevel=EdkLogger.INFO)
|
||||
|
||||
Options, Args = Parser.parse_args()
|
||||
|
||||
# error check
|
||||
if len(Args) == 0:
|
||||
EdkLogger.error("PatchPcdValue", PARAMETER_INVALID, ExtraData=Parser.get_usage())
|
||||
|
||||
InputFile = Args[len(Args) - 1]
|
||||
return Options, InputFile
|
||||
|
||||
## Entrance method
|
||||
#
|
||||
# This method mainly dispatch specific methods per the command line options.
|
||||
# If no error found, return zero value so the caller of this tool can know
|
||||
# if it's executed successfully or not.
|
||||
#
|
||||
# @retval 0 Tool was successful
|
||||
# @retval 1 Tool failed
|
||||
#
|
||||
def Main():
|
||||
try:
|
||||
#
|
||||
# Check input parameter
|
||||
#
|
||||
EdkLogger.Initialize()
|
||||
CommandOptions, InputFile = Options()
|
||||
if CommandOptions.LogLevel < EdkLogger.DEBUG_9:
|
||||
EdkLogger.SetLevel(CommandOptions.LogLevel + 1)
|
||||
else:
|
||||
EdkLogger.SetLevel(CommandOptions.LogLevel)
|
||||
if not os.path.exists (InputFile):
|
||||
EdkLogger.error("PatchPcdValue", FILE_NOT_FOUND, ExtraData=InputFile)
|
||||
return 1
|
||||
if CommandOptions.PcdOffset == None or CommandOptions.PcdValue == None or CommandOptions.PcdTypeName == None:
|
||||
EdkLogger.error("PatchPcdValue", OPTION_MISSING, ExtraData="PcdOffset or PcdValue of PcdTypeName is not specified.")
|
||||
return 1
|
||||
if CommandOptions.PcdTypeName.upper() not in ["BOOLEAN", "UINT8", "UINT16", "UINT32", "UINT64", "VOID*"]:
|
||||
EdkLogger.error("PatchPcdValue", PARAMETER_INVALID, ExtraData="PCD type %s is not valid." %(CommandOptions.PcdTypeName))
|
||||
return 1
|
||||
if CommandOptions.PcdTypeName.upper() == "VOID*" and CommandOptions.PcdMaxSize == None:
|
||||
EdkLogger.error("PatchPcdValue", OPTION_MISSING, ExtraData="PcdMaxSize is not specified for VOID* type PCD.")
|
||||
return 1
|
||||
#
|
||||
# Patch value into binary image.
|
||||
#
|
||||
ReturnValue, ErrorInfo = PatchBinaryFile (InputFile, CommandOptions.PcdOffset, CommandOptions.PcdTypeName, CommandOptions.PcdValue, CommandOptions.PcdMaxSize)
|
||||
if ReturnValue != 0:
|
||||
EdkLogger.error("PatchPcdValue", ReturnValue, ExtraData=ErrorInfo)
|
||||
return 1
|
||||
return 0
|
||||
except:
|
||||
return 1
|
||||
|
||||
if __name__ == '__main__':
|
||||
r = Main()
|
||||
sys.exit(r)
|
15
BaseTools/Source/Python/PatchPcdValue/__init__.py
Normal file
15
BaseTools/Source/Python/PatchPcdValue/__init__.py
Normal file
@@ -0,0 +1,15 @@
|
||||
## @file
|
||||
# Python 'PatchPcdValue' 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.
|
||||
#
|
@@ -18,8 +18,8 @@ import Common.EdkLogger as EdkLogger
|
||||
import os, time
|
||||
from Table import Table
|
||||
from Common.String import ConvertToSqlString2
|
||||
import EotToolError as EotToolError
|
||||
import EotGlobalData as EotGlobalData
|
||||
import Eot.EotToolError as EotToolError
|
||||
import Eot.EotGlobalData as EotGlobalData
|
||||
|
||||
## TableReport
|
||||
#
|
||||
|
@@ -21,7 +21,7 @@ from Table import Table
|
||||
## TableQuery
|
||||
#
|
||||
# This class defined a table used for Query
|
||||
#
|
||||
#
|
||||
# @param object: Inherited from object class
|
||||
#
|
||||
#
|
||||
@@ -29,19 +29,21 @@ class TableQuery(Table):
|
||||
def __init__(self, Cursor):
|
||||
Table.__init__(self, Cursor)
|
||||
self.Table = 'Query'
|
||||
|
||||
|
||||
## Create table
|
||||
#
|
||||
# Create table Query
|
||||
#
|
||||
# @param ID: ID of a Query
|
||||
# @param Name: Modifier of a Query
|
||||
# @param Name: Name of a Query
|
||||
# @param Modifer: Modifier of a Query
|
||||
# @param Value: Type of a Query
|
||||
# @param Model: Model of a Query
|
||||
#
|
||||
def Create(self):
|
||||
SqlCommand = """create table IF NOT EXISTS %s(ID INTEGER PRIMARY KEY,
|
||||
Name TEXT DEFAULT '',
|
||||
Modifier TEXT DEFAULT '',
|
||||
Value TEXT DEFAULT '',
|
||||
Model INTEGER DEFAULT 0
|
||||
)""" % self.Table
|
||||
@@ -52,15 +54,15 @@ class TableQuery(Table):
|
||||
# Insert a record into table Query
|
||||
#
|
||||
# @param ID: ID of a Query
|
||||
# @param Name: Modifier of a Query
|
||||
# @param Value: Type of a Query
|
||||
# @param Name: Name of a Query
|
||||
# @param Modifier: Modifier of a Query
|
||||
# @param Value: Value of a Query
|
||||
# @param Model: Model of a Query
|
||||
#
|
||||
def Insert(self, Name, Value, Model):
|
||||
def Insert(self, Name, Modifier, Value, Model):
|
||||
self.ID = self.ID + 1
|
||||
SqlCommand = """insert into %s values(%s, '%s', '%s', %s)""" \
|
||||
% (self.Table, self.ID, Name, Value, Model)
|
||||
SqlCommand = """insert into %s values(%s, '%s', '%s', '%s', %s)""" \
|
||||
% (self.Table, self.ID, Name, Modifier, Value, Model)
|
||||
Table.Insert(self, SqlCommand)
|
||||
|
||||
return self.ID
|
||||
|
@@ -1,7 +1,7 @@
|
||||
## @file
|
||||
# This file is used to create/update/query/erase table for ECC reports
|
||||
#
|
||||
# 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
|
||||
@@ -114,7 +114,8 @@ class TableReport(Table):
|
||||
NewRecord = self.Exec(SqlCommand)
|
||||
if NewRecord != []:
|
||||
File.write("""%s,%s,"%s",%s,%s,"%s"\n""" % (Index, ErrorID, EccToolError.gEccErrorMessage[ErrorID], NewRecord[0][1], NewRecord[0][0], OtherMsg))
|
||||
|
||||
EdkLogger.quiet("%s(%s): [%s]%s %s" % (NewRecord[0][1], NewRecord[0][0], ErrorID, EccToolError.gEccErrorMessage[ErrorID], OtherMsg))
|
||||
|
||||
File.close()
|
||||
except IOError:
|
||||
NewFilename = 'Report_' + time.strftime("%Y%m%d_%H%M%S.csv", time.localtime())
|
||||
|
@@ -0,0 +1,15 @@
|
||||
## @file
|
||||
# Python 'Table' package initialization file.
|
||||
#
|
||||
# This file is required to make Python interpreter treat the directory
|
||||
# as containing package.
|
||||
#
|
||||
# Copyright (c) 2008 - 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,5 +1,5 @@
|
||||
#
|
||||
# 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
|
||||
@@ -175,7 +175,7 @@ def GetConfigureKeyValue(self, Key):
|
||||
|
||||
VersionNumber = "0.01"
|
||||
__version__ = "%prog Version " + VersionNumber
|
||||
__copyright__ = "Copyright (c) 2007, Intel Corporation All rights reserved."
|
||||
__copyright__ = "Copyright (c) 2007 - 2010, Intel Corporation All rights reserved."
|
||||
__usage__ = "%prog [options] {args} \
|
||||
\nArgs: \
|
||||
\n Clean clean the all default configuration of target.txt. \
|
||||
|
@@ -0,0 +1,15 @@
|
||||
## @file
|
||||
# Python 'TargetTool' 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
|
||||
# Trim files preprocessed by compiler
|
||||
#
|
||||
# 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
|
||||
@@ -28,7 +28,7 @@ import Common.EdkLogger as EdkLogger
|
||||
# Version and Copyright
|
||||
__version_number__ = "0.10"
|
||||
__version__ = "%prog Version " + __version_number__
|
||||
__copyright__ = "Copyright (c) 2007-2008, Intel Corporation. All rights reserved."
|
||||
__copyright__ = "Copyright (c) 2007-2010, Intel Corporation. All rights reserved."
|
||||
|
||||
## Regular expression for matching Line Control directive like "#line xxx"
|
||||
gLineControlDirective = re.compile('^\s*#(?:line)?\s+([0-9]+)\s+"*([^"]*)"')
|
||||
@@ -81,6 +81,21 @@ gImportCodePatterns = [
|
||||
'#include <FvLoadFile.h>'
|
||||
],
|
||||
|
||||
[
|
||||
re.compile('#include\s+EFI_GUID_DEFINITION\s*\(FirmwareFileSystem\)', re.MULTILINE),
|
||||
'#include EFI_GUID_DEFINITION (FirmwareFileSystem)\n#include EFI_GUID_DEFINITION (FirmwareFileSystem2)'
|
||||
],
|
||||
|
||||
[
|
||||
re.compile('gEfiFirmwareFileSystemGuid', re.MULTILINE),
|
||||
'gEfiFirmwareFileSystem2Guid'
|
||||
],
|
||||
|
||||
[
|
||||
re.compile('EFI_FVH_REVISION', re.MULTILINE),
|
||||
'EFI_FVH_PI_REVISION'
|
||||
],
|
||||
|
||||
[
|
||||
re.compile("(\s*)\S*CreateEvent\s*\([\s\n]*EFI_EVENT_SIGNAL_READY_TO_BOOT[^,]*,((?:[^;]+\n)+)(\s*\));", re.MULTILINE),
|
||||
'\\1EfiCreateEventReadyToBoot (\\2\\3;'
|
||||
@@ -504,7 +519,7 @@ def Main():
|
||||
"\nTrim",
|
||||
CODE_ERROR,
|
||||
"Unknown fatal error when trimming [%s]" % InputFile,
|
||||
ExtraData="\n(Please send email to dev@buildtools.tianocore.org for help, attaching following call stack trace!)\n",
|
||||
ExtraData="\n(Please send email to edk2-buildtools-devel@lists.sourceforge.net for help, attaching following call stack trace!)\n",
|
||||
RaiseError=False
|
||||
)
|
||||
EdkLogger.quiet("(Python %s on %s) " % (platform.python_version(), sys.platform) + traceback.format_exc())
|
||||
|
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,15 @@
|
||||
## @file
|
||||
# Python 'Workspace' package initialization file.
|
||||
#
|
||||
# This file is required to make Python interpreter treat the directory
|
||||
# as containing package.
|
||||
#
|
||||
# Copyright (c) 2008 - 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.
|
||||
#
|
||||
|
1423
BaseTools/Source/Python/build/BuildReport.py
Normal file
1423
BaseTools/Source/Python/build/BuildReport.py
Normal file
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,15 @@
|
||||
## @file
|
||||
# Python 'build' 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
@@ -0,0 +1,15 @@
|
||||
## @file
|
||||
# Python 'fpd2dsc' 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
|
||||
# Convert an XML-based FPD file to a text-based DSC 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
|
||||
@@ -22,7 +22,7 @@ from optparse import OptionParser
|
||||
# Version and Copyright
|
||||
__version_number__ = "1.0"
|
||||
__version__ = "%prog Version " + __version_number__
|
||||
__copyright__ = "Copyright (c) 2007, Intel Corporation All rights reserved."
|
||||
__copyright__ = "Copyright (c) 2007 - 2010, Intel Corporation All rights reserved."
|
||||
|
||||
## Parse command line options
|
||||
#
|
||||
|
@@ -2,7 +2,7 @@
|
||||
# Convert an MSA Module class object ot an INF Module class object by filling
|
||||
# several info required by 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
|
||||
@@ -35,7 +35,7 @@ def AddModuleMiscVersion(Module):
|
||||
Module.Header.InfVersion = Version
|
||||
|
||||
Version = Module.Header.Specification.get("EFI_SPECIFICATION_VERSION", "")
|
||||
Module.Header.EfiSpecificationVersion = Version
|
||||
Module.Header.UefiSpecificationVersion = Version
|
||||
|
||||
Version = Module.Header.Specification.get("EDK_RELEASE_VERSION", "")
|
||||
Module.Header.EdkReleaseVersion = Version
|
||||
|
@@ -64,8 +64,8 @@ def StoreModuleDefinesSection(InfFile, Module):
|
||||
if ModuleHeader.ModuleType != "":
|
||||
DefinesTupleList.append(("MODULE_TYPE", ModuleHeader.ModuleType))
|
||||
|
||||
if ModuleHeader.EfiSpecificationVersion != "":
|
||||
DefinesTupleList.append(("EFI_SPECIFICATION_VERSION", ModuleHeader.EfiSpecificationVersion))
|
||||
if ModuleHeader.UefiSpecificationVersion != "":
|
||||
DefinesTupleList.append(("UEFI_SPECIFICATION_VERSION", ModuleHeader.UefiSpecificationVersion))
|
||||
|
||||
if ModuleHeader.EdkReleaseVersion != "":
|
||||
DefinesTupleList.append(("EDK_RELEASE_VERSION", ModuleHeader.EdkReleaseVersion))
|
||||
|
@@ -0,0 +1,15 @@
|
||||
## @file
|
||||
# Python 'msa2inf' 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,13 @@
|
||||
#
|
||||
# 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.
|
||||
import sys
|
||||
import locale
|
||||
|
||||
|
@@ -0,0 +1,15 @@
|
||||
## @file
|
||||
# Python 'spd2dec' 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.
|
||||
#
|
||||
|
Reference in New Issue
Block a user