X-Git-Url: https://git.proxmox.com/?p=mirror_edk2.git;a=blobdiff_plain;f=BaseTools%2FSource%2FPython%2FAutoGen%2FGenC.py;h=aaa88f876aeb089d42f60f8e8030dadc9b78b7e3;hp=89cf8e5b8b0c2c766cb227c2e8607032f5928c10;hb=549ae85ce1b00228c3abcf6a9e4022c4f4fba5ed;hpb=88c6c1b64ca51f67fa9c524f3ab5efcad2e6ba22 diff --git a/BaseTools/Source/Python/AutoGen/GenC.py b/BaseTools/Source/Python/AutoGen/GenC.py index 89cf8e5b8b..aaa88f876a 100644 --- a/BaseTools/Source/Python/AutoGen/GenC.py +++ b/BaseTools/Source/Python/AutoGen/GenC.py @@ -13,6 +13,7 @@ ## Import Modules # +from __future__ import absolute_import import string import collections import struct @@ -21,15 +22,15 @@ from Common import EdkLogger from Common.BuildToolError import * from Common.DataType import * from Common.Misc import * -from Common.String import StringToArray -from StrGather import * -from GenPcdDb import CreatePcdDatabaseCode -from IdfClassObject import * +from Common.StringUtils import StringToArray +from .StrGather import * +from .GenPcdDb import CreatePcdDatabaseCode +from .IdfClassObject import * ## PCD type string gItemTypeStringDatabase = { - TAB_PCDS_FEATURE_FLAG : 'FixedAtBuild', - TAB_PCDS_FIXED_AT_BUILD : 'FixedAtBuild', + TAB_PCDS_FEATURE_FLAG : TAB_PCDS_FIXED_AT_BUILD, + TAB_PCDS_FIXED_AT_BUILD : TAB_PCDS_FIXED_AT_BUILD, TAB_PCDS_PATCHABLE_IN_MODULE: 'BinaryPatch', TAB_PCDS_DYNAMIC : '', TAB_PCDS_DYNAMIC_DEFAULT : '', @@ -41,11 +42,6 @@ gItemTypeStringDatabase = { TAB_PCDS_DYNAMIC_EX_HII : '', } -## Dynamic PCD types -gDynamicPcd = [TAB_PCDS_DYNAMIC, TAB_PCDS_DYNAMIC_DEFAULT, TAB_PCDS_DYNAMIC_VPD, TAB_PCDS_DYNAMIC_HII] - -## Dynamic-ex PCD types -gDynamicExPcd = [TAB_PCDS_DYNAMIC_EX, TAB_PCDS_DYNAMIC_EX_DEFAULT, TAB_PCDS_DYNAMIC_EX_VPD, TAB_PCDS_DYNAMIC_EX_HII] ## Datum size gDatumSizeStringDatabase = {TAB_UINT8:'8',TAB_UINT16:'16',TAB_UINT32:'32',TAB_UINT64:'64','BOOLEAN':'BOOLEAN',TAB_VOID:'8'} @@ -270,7 +266,7 @@ EFI_STATUS EFIAPI ${Function} ( IN EFI_HANDLE ImageHandle, - IN EFI_SMM_SYSTEM_TABLE2 *MmSystemTable + IN EFI_MM_SYSTEM_TABLE *MmSystemTable ); ${END} """) @@ -283,7 +279,7 @@ EFI_STATUS EFIAPI ProcessModuleEntryPointList ( IN EFI_HANDLE ImageHandle, - IN EFI_SMM_SYSTEM_TABLE2 *MmSystemTable + IN EFI_MM_SYSTEM_TABLE *MmSystemTable ) { @@ -297,7 +293,7 @@ EFI_STATUS EFIAPI ProcessModuleEntryPointList ( IN EFI_HANDLE ImageHandle, - IN EFI_SMM_SYSTEM_TABLE2 *MmSystemTable + IN EFI_MM_SYSTEM_TABLE *MmSystemTable ) { @@ -312,7 +308,7 @@ EFI_STATUS EFIAPI ProcessModuleEntryPointList ( IN EFI_HANDLE ImageHandle, - IN EFI_SMM_SYSTEM_TABLE2 *MmSystemTable + IN EFI_MM_SYSTEM_TABLE *MmSystemTable ) { @@ -680,7 +676,7 @@ EFI_STATUS EFIAPI ${Function} ( IN EFI_HANDLE ImageHandle, - IN EFI_SMM_SYSTEM_TABLE2 *MmSystemTable + IN EFI_MM_SYSTEM_TABLE *MmSystemTable );${END} """), } @@ -760,7 +756,7 @@ VOID EFIAPI ProcessLibrary${Type}List ( IN EFI_HANDLE ImageHandle, - IN EFI_SMM_SYSTEM_TABLE2 *MmSystemTable + IN EFI_MM_SYSTEM_TABLE *MmSystemTable ) { ${BEGIN} EFI_STATUS Status; @@ -784,12 +780,12 @@ gModuleTypeHeaderFile = { SUP_MODULE_UEFI_DRIVER : ["Uefi.h", "Library/BaseLib.h", "Library/DebugLib.h", "Library/UefiBootServicesTableLib.h", "Library/UefiDriverEntryPoint.h"], SUP_MODULE_UEFI_APPLICATION : ["Uefi.h", "Library/BaseLib.h", "Library/DebugLib.h", "Library/UefiBootServicesTableLib.h", "Library/UefiApplicationEntryPoint.h"], SUP_MODULE_SMM_CORE : ["PiDxe.h", "Library/BaseLib.h", "Library/DebugLib.h", "Library/UefiDriverEntryPoint.h"], - SUP_MODULE_MM_STANDALONE : ["PiSmm.h", "Library/BaseLib.h", "Library/DebugLib.h", "Library/SmmDriverStandaloneEntryPoint.h"], - SUP_MODULE_MM_CORE_STANDALONE : ["PiSmm.h", "Library/BaseLib.h", "Library/DebugLib.h", "Library/SmmCoreStandaloneEntryPoint.h"], + SUP_MODULE_MM_STANDALONE : ["PiMm.h", "Library/BaseLib.h", "Library/DebugLib.h", "Library/StandaloneMmDriverEntryPoint.h"], + SUP_MODULE_MM_CORE_STANDALONE : ["PiMm.h", "Library/BaseLib.h", "Library/DebugLib.h", "Library/StandaloneMmCoreEntryPoint.h"], SUP_MODULE_USER_DEFINED : [gBasicHeaderFile] } -## Autogen internal worker macro to define DynamicEx PCD name includes both the TokenSpaceGuidName +## Autogen internal worker macro to define DynamicEx PCD name includes both the TokenSpaceGuidName # the TokenName and Guid comparison to avoid define name collisions. # # @param Info The ModuleAutoGen object @@ -802,14 +798,14 @@ def DynExPcdTokenNumberMapping(Info, AutoGenH): # Even it is the Library, the PCD is saved in the ModulePcdList PcdList = Info.ModulePcdList for Pcd in PcdList: - if Pcd.Type in gDynamicExPcd: + if Pcd.Type in PCD_DYNAMIC_EX_TYPE_SET: ExTokenCNameList.append(Pcd.TokenCName) PcdExList.append(Pcd) if len(ExTokenCNameList) == 0: return AutoGenH.Append('\n#define COMPAREGUID(Guid1, Guid2) (BOOLEAN)(*(CONST UINT64*)Guid1 == *(CONST UINT64*)Guid2 && *((CONST UINT64*)Guid1 + 1) == *((CONST UINT64*)Guid2 + 1))\n') # AutoGen for each PCD listed in a [PcdEx] section of a Module/Lib INF file. - # Auto generate a macro for each TokenName that takes a Guid pointer as a parameter. + # Auto generate a macro for each TokenName that takes a Guid pointer as a parameter. # Use the Guid pointer to see if it matches any of the token space GUIDs. TokenCNameList = set() for TokenCName in ExTokenCNameList: @@ -827,15 +823,15 @@ def DynExPcdTokenNumberMapping(Info, AutoGenH): Index = Index + 1 if Index == 1: AutoGenH.Append('\n#define __PCD_%s_ADDR_CMP(GuidPtr) (' % (RealTokenCName)) - AutoGenH.Append('\\\n (GuidPtr == &%s) ? _PCD_TOKEN_%s_%s:' + AutoGenH.Append('\\\n (GuidPtr == &%s) ? _PCD_TOKEN_%s_%s:' % (Pcd.TokenSpaceGuidCName, Pcd.TokenSpaceGuidCName, RealTokenCName)) else: - AutoGenH.Append('\\\n (GuidPtr == &%s) ? _PCD_TOKEN_%s_%s:' + AutoGenH.Append('\\\n (GuidPtr == &%s) ? _PCD_TOKEN_%s_%s:' % (Pcd.TokenSpaceGuidCName, Pcd.TokenSpaceGuidCName, RealTokenCName)) if Index == Count: AutoGenH.Append('0 \\\n )\n') TokenCNameList.add(TokenCName) - + TokenCNameList = set() for TokenCName in ExTokenCNameList: if TokenCName in TokenCNameList: @@ -848,19 +844,19 @@ def DynExPcdTokenNumberMapping(Info, AutoGenH): if (Pcd.TokenCName, Pcd.TokenSpaceGuidCName) in GlobalData.MixedPcd[PcdItem]: RealTokenCName = PcdItem[0] break - if Pcd.Type in gDynamicExPcd and Pcd.TokenCName == TokenCName: + if Pcd.Type in PCD_DYNAMIC_EX_TYPE_SET and Pcd.TokenCName == TokenCName: Index = Index + 1 if Index == 1: AutoGenH.Append('\n#define __PCD_%s_VAL_CMP(GuidPtr) (' % (RealTokenCName)) AutoGenH.Append('\\\n (GuidPtr == NULL) ? 0:') - AutoGenH.Append('\\\n COMPAREGUID (GuidPtr, &%s) ? _PCD_TOKEN_%s_%s:' + AutoGenH.Append('\\\n COMPAREGUID (GuidPtr, &%s) ? _PCD_TOKEN_%s_%s:' % (Pcd.TokenSpaceGuidCName, Pcd.TokenSpaceGuidCName, RealTokenCName)) else: - AutoGenH.Append('\\\n COMPAREGUID (GuidPtr, &%s) ? _PCD_TOKEN_%s_%s:' + AutoGenH.Append('\\\n COMPAREGUID (GuidPtr, &%s) ? _PCD_TOKEN_%s_%s:' % (Pcd.TokenSpaceGuidCName, Pcd.TokenSpaceGuidCName, RealTokenCName)) if Index == Count: AutoGenH.Append('0 \\\n )\n') - # Autogen internal worker macro to compare GUIDs. Guid1 is a pointer to a GUID. + # Autogen internal worker macro to compare GUIDs. Guid1 is a pointer to a GUID. # Guid2 is a C name for a GUID. Compare pointers first because optimizing compiler # can do this at build time on CONST GUID pointers and optimize away call to COMPAREGUID(). # COMPAREGUID() will only be used if the Guid passed in is local to the module. @@ -868,31 +864,6 @@ def DynExPcdTokenNumberMapping(Info, AutoGenH): % (RealTokenCName, RealTokenCName, RealTokenCName, RealTokenCName)) TokenCNameList.add(TokenCName) -def GetPcdSize(Pcd): - if Pcd.DatumType not in TAB_PCD_NUMERIC_TYPES: - Value = Pcd.DefaultValue - if Value in [None, '']: - return 1 - elif Value[0] == 'L': - return (len(Value) - 2) * 2 - elif Value[0] == '{': - return len(Value.split(',')) - else: - return len(Value) - 1 - if Pcd.DatumType == TAB_UINT64: - return 8 - if Pcd.DatumType == TAB_UINT32: - return 4 - if Pcd.DatumType == TAB_UINT16: - return 2 - if Pcd.DatumType == TAB_UINT8: - return 1 - if Pcd.DatumType == 'BOOLEAN': - return 1 - else: - return Pcd.MaxDatumSize - - ## Create code for module PCDs # # @param Info The ModuleAutoGen object @@ -920,24 +891,26 @@ def CreateModulePcdCode(Info, AutoGenC, AutoGenH, Pcd): if Pcd.PcdValueFromComm: Pcd.DefaultValue = Pcd.PcdValueFromComm - - if Pcd.Type in gDynamicExPcd: + elif Pcd.PcdValueFromFdf: + Pcd.DefaultValue = Pcd.PcdValueFromFdf + + if Pcd.Type in PCD_DYNAMIC_EX_TYPE_SET: TokenNumber = int(Pcd.TokenValue, 0) - # Add TokenSpaceGuidValue value to PcdTokenName to discriminate the DynamicEx PCDs with + # Add TokenSpaceGuidValue value to PcdTokenName to discriminate the DynamicEx PCDs with # different Guids but same TokenCName PcdExTokenName = '_PCD_TOKEN_' + Pcd.TokenSpaceGuidCName + '_' + TokenCName AutoGenH.Append('\n#define %s %dU\n' % (PcdExTokenName, TokenNumber)) else: if (Pcd.TokenCName, Pcd.TokenSpaceGuidCName) not in PcdTokenNumber: - # If one of the Source built modules listed in the DSC is not listed in FDF modules, - # and the INF lists a PCD can only use the PcdsDynamic access method (it is only - # listed in the DEC file that declares the PCD as PcdsDynamic), then build tool will - # report warning message notify the PI that they are attempting to build a module - # that must be included in a flash image in order to be functional. These Dynamic PCD - # will not be added into the Database unless it is used by other modules that are - # included in the FDF file. + # If one of the Source built modules listed in the DSC is not listed in FDF modules, + # and the INF lists a PCD can only use the PcdsDynamic access method (it is only + # listed in the DEC file that declares the PCD as PcdsDynamic), then build tool will + # report warning message notify the PI that they are attempting to build a module + # that must be included in a flash image in order to be functional. These Dynamic PCD + # will not be added into the Database unless it is used by other modules that are + # included in the FDF file. # In this case, just assign an invalid token number to make it pass build. - if Pcd.Type in PCD_DYNAMIC_TYPE_LIST: + if Pcd.Type in PCD_DYNAMIC_TYPE_SET: TokenNumber = 0 else: EdkLogger.error("build", AUTOGEN_ERROR, @@ -959,15 +932,15 @@ def CreateModulePcdCode(Info, AutoGenC, AutoGenH, Pcd): SetModeName = '_PCD_SET_MODE_' + gDatumSizeStringDatabaseH[Pcd.DatumType] + '_' + TokenCName if Pcd.DatumType in gDatumSizeStringDatabaseH else '_PCD_SET_MODE_' + gDatumSizeStringDatabaseH[TAB_VOID] + '_' + TokenCName SetModeStatusName = '_PCD_SET_MODE_' + gDatumSizeStringDatabaseH[Pcd.DatumType] + '_S_' + TokenCName if Pcd.DatumType in gDatumSizeStringDatabaseH else '_PCD_SET_MODE_' + gDatumSizeStringDatabaseH[TAB_VOID] + '_S_' + TokenCName GetModeSizeName = '_PCD_GET_MODE_SIZE' + '_' + TokenCName - - if Pcd.Type in gDynamicExPcd: + + if Pcd.Type in PCD_DYNAMIC_EX_TYPE_SET: if Info.IsLibrary: PcdList = Info.LibraryPcdList else: PcdList = Info.ModulePcdList PcdExCNameTest = 0 for PcdModule in PcdList: - if PcdModule.Type in gDynamicExPcd and Pcd.TokenCName == PcdModule.TokenCName: + if PcdModule.Type in PCD_DYNAMIC_EX_TYPE_SET and Pcd.TokenCName == PcdModule.TokenCName: PcdExCNameTest += 1 # get out early once we found > 1... if PcdExCNameTest > 1: @@ -979,7 +952,7 @@ def CreateModulePcdCode(Info, AutoGenC, AutoGenH, Pcd): AutoGenH.Append('// Disabled the macros, as PcdToken and PcdGet/Set are not allowed in the case that more than one DynamicEx Pcds are different Guids but same CName.\n') AutoGenH.Append('// #define %s %s\n' % (PcdTokenName, PcdExTokenName)) AutoGenH.Append('// #define %s LibPcdGetEx%s(&%s, %s)\n' % (GetModeName, DatumSizeLib, Pcd.TokenSpaceGuidCName, PcdTokenName)) - AutoGenH.Append('// #define %s LibPcdGetExSize(&%s, %s)\n' % (GetModeSizeName,Pcd.TokenSpaceGuidCName, PcdTokenName)) + AutoGenH.Append('// #define %s LibPcdGetExSize(&%s, %s)\n' % (GetModeSizeName, Pcd.TokenSpaceGuidCName, PcdTokenName)) if Pcd.DatumType not in TAB_PCD_NUMERIC_TYPES: AutoGenH.Append('// #define %s(SizeOfBuffer, Buffer) LibPcdSetEx%s(&%s, %s, (SizeOfBuffer), (Buffer))\n' % (SetModeName, DatumSizeLib, Pcd.TokenSpaceGuidCName, PcdTokenName)) AutoGenH.Append('// #define %s(SizeOfBuffer, Buffer) LibPcdSetEx%sS(&%s, %s, (SizeOfBuffer), (Buffer))\n' % (SetModeStatusName, DatumSizeLib, Pcd.TokenSpaceGuidCName, PcdTokenName)) @@ -989,17 +962,17 @@ def CreateModulePcdCode(Info, AutoGenC, AutoGenH, Pcd): else: AutoGenH.Append('#define %s %s\n' % (PcdTokenName, PcdExTokenName)) AutoGenH.Append('#define %s LibPcdGetEx%s(&%s, %s)\n' % (GetModeName, DatumSizeLib, Pcd.TokenSpaceGuidCName, PcdTokenName)) - AutoGenH.Append('#define %s LibPcdGetExSize(&%s, %s)\n' % (GetModeSizeName,Pcd.TokenSpaceGuidCName, PcdTokenName)) + AutoGenH.Append('#define %s LibPcdGetExSize(&%s, %s)\n' % (GetModeSizeName, Pcd.TokenSpaceGuidCName, PcdTokenName)) if Pcd.DatumType not in TAB_PCD_NUMERIC_TYPES: AutoGenH.Append('#define %s(SizeOfBuffer, Buffer) LibPcdSetEx%s(&%s, %s, (SizeOfBuffer), (Buffer))\n' % (SetModeName, DatumSizeLib, Pcd.TokenSpaceGuidCName, PcdTokenName)) AutoGenH.Append('#define %s(SizeOfBuffer, Buffer) LibPcdSetEx%sS(&%s, %s, (SizeOfBuffer), (Buffer))\n' % (SetModeStatusName, DatumSizeLib, Pcd.TokenSpaceGuidCName, PcdTokenName)) else: AutoGenH.Append('#define %s(Value) LibPcdSetEx%s(&%s, %s, (Value))\n' % (SetModeName, DatumSizeLib, Pcd.TokenSpaceGuidCName, PcdTokenName)) AutoGenH.Append('#define %s(Value) LibPcdSetEx%sS(&%s, %s, (Value))\n' % (SetModeStatusName, DatumSizeLib, Pcd.TokenSpaceGuidCName, PcdTokenName)) - elif Pcd.Type in gDynamicPcd: + elif Pcd.Type in PCD_DYNAMIC_TYPE_SET: PcdCNameTest = 0 for PcdModule in Info.LibraryPcdList + Info.ModulePcdList: - if PcdModule.Type in gDynamicPcd and Pcd.TokenCName == PcdModule.TokenCName: + if PcdModule.Type in PCD_DYNAMIC_TYPE_SET and Pcd.TokenCName == PcdModule.TokenCName: PcdCNameTest += 1 # get out early once we found > 1... if PcdCNameTest > 1: @@ -1074,7 +1047,7 @@ def CreateModulePcdCode(Info, AutoGenC, AutoGenH, Pcd): "Too large PCD value for datum type [%s] of PCD %s.%s" % (Pcd.DatumType, Pcd.TokenSpaceGuidCName, TokenCName), ExtraData="[%s]" % str(Info)) if not Value.endswith('U'): - Value += 'U' + Value += 'U' elif Pcd.DatumType == TAB_UINT8: if ValueNumber < 0: EdkLogger.error("build", AUTOGEN_ERROR, @@ -1087,7 +1060,7 @@ def CreateModulePcdCode(Info, AutoGenC, AutoGenH, Pcd): if not Value.endswith('U'): Value += 'U' if Pcd.DatumType not in TAB_PCD_NUMERIC_TYPES: - if Pcd.MaxDatumSize is None or Pcd.MaxDatumSize == '': + if not Pcd.MaxDatumSize: EdkLogger.error("build", AUTOGEN_ERROR, "Unknown [MaxDatumSize] of PCD [%s.%s]" % (Pcd.TokenSpaceGuidCName, TokenCName), ExtraData="[%s]" % str(Info)) @@ -1095,30 +1068,31 @@ def CreateModulePcdCode(Info, AutoGenC, AutoGenH, Pcd): ArraySize = int(Pcd.MaxDatumSize, 0) if Value[0] == '{': Type = '(VOID *)' + ValueSize = len(Value.split(',')) else: if Value[0] == 'L': Unicode = True Value = Value.lstrip('L') #.strip('"') Value = eval(Value) # translate escape character + ValueSize = len(Value) + 1 NewValue = '{' - for Index in range(0,len(Value)): + for Index in range(0, len(Value)): if Unicode: NewValue = NewValue + str(ord(Value[Index]) % 0x10000) + ', ' else: NewValue = NewValue + str(ord(Value[Index]) % 0x100) + ', ' if Unicode: - ArraySize = ArraySize / 2; - - if ArraySize < (len(Value) + 1): - if Pcd.MaxSizeUserSet: - EdkLogger.error("build", AUTOGEN_ERROR, - "The maximum size of VOID* type PCD '%s.%s' is less than its actual size occupied." % (Pcd.TokenSpaceGuidCName, TokenCName), - ExtraData="[%s]" % str(Info)) - else: - ArraySize = GetPcdSize(Pcd) - if Unicode: - ArraySize = ArraySize / 2 + ArraySize = ArraySize / 2 Value = NewValue + '0 }' + if ArraySize < ValueSize: + if Pcd.MaxSizeUserSet: + EdkLogger.error("build", AUTOGEN_ERROR, + "The maximum size of VOID* type PCD '%s.%s' is less than its actual size occupied." % (Pcd.TokenSpaceGuidCName, TokenCName), + ExtraData="[%s]" % str(Info)) + else: + ArraySize = Pcd.GetPcdSize() + if Unicode: + ArraySize = ArraySize / 2 Array = '[%d]' % ArraySize # # skip casting for fixed at build since it breaks ARM assembly. @@ -1127,21 +1101,11 @@ def CreateModulePcdCode(Info, AutoGenC, AutoGenH, Pcd): elif Pcd.Type != TAB_PCDS_FIXED_AT_BUILD and Pcd.DatumType in TAB_PCD_NUMERIC_TYPES_VOID: Value = "((%s)%s)" % (Pcd.DatumType, Value) - if Pcd.DatumType not in TAB_PCD_NUMERIC_TYPES_VOID: - # handle structure PCD - if Pcd.MaxDatumSize is None or Pcd.MaxDatumSize == '': - EdkLogger.error("build", AUTOGEN_ERROR, - "Unknown [MaxDatumSize] of PCD [%s.%s]" % (Pcd.TokenSpaceGuidCName, TokenCName), - ExtraData="[%s]" % str(Info)) - - ArraySize = int(Pcd.MaxDatumSize, 0) - Array = '[%d]' % ArraySize - if Pcd.Type == TAB_PCDS_PATCHABLE_IN_MODULE: PcdValueName = '_PCD_PATCHABLE_VALUE_' + TokenCName else: PcdValueName = '_PCD_VALUE_' + TokenCName - + if Pcd.DatumType not in TAB_PCD_NUMERIC_TYPES: # # For unicode, UINT16 array will be generated, so the alignment of unicode is guaranteed. @@ -1154,35 +1118,35 @@ def CreateModulePcdCode(Info, AutoGenC, AutoGenH, Pcd): AutoGenC.Append('GLOBAL_REMOVE_IF_UNREFERENCED %s UINT8 %s%s = %s;\n' % (Const, PcdVariableName, Array, Value)) AutoGenH.Append('extern %s UINT8 %s%s;\n' %(Const, PcdVariableName, Array)) AutoGenH.Append('#define %s %s%s\n' %(GetModeName, Type, PcdVariableName)) - - PcdDataSize = GetPcdSize(Pcd) + + PcdDataSize = Pcd.GetPcdSize() if Pcd.Type == TAB_PCDS_FIXED_AT_BUILD: AutoGenH.Append('#define %s %s\n' % (FixPcdSizeTokenName, PcdDataSize)) - AutoGenH.Append('#define %s %s \n' % (GetModeSizeName,FixPcdSizeTokenName)) - AutoGenC.Append('GLOBAL_REMOVE_IF_UNREFERENCED const UINTN %s = %s;\n' % (FixedPcdSizeVariableName,PcdDataSize)) + AutoGenH.Append('#define %s %s \n' % (GetModeSizeName, FixPcdSizeTokenName)) + AutoGenC.Append('GLOBAL_REMOVE_IF_UNREFERENCED const UINTN %s = %s;\n' % (FixedPcdSizeVariableName, PcdDataSize)) if Pcd.Type == TAB_PCDS_PATCHABLE_IN_MODULE: AutoGenH.Append('#define %s %s\n' % (PatchPcdSizeTokenName, Pcd.MaxDatumSize)) - AutoGenH.Append('#define %s %s \n' % (GetModeSizeName,PatchPcdSizeVariableName)) + AutoGenH.Append('#define %s %s \n' % (GetModeSizeName, PatchPcdSizeVariableName)) AutoGenH.Append('extern UINTN %s; \n' % PatchPcdSizeVariableName) - AutoGenC.Append('GLOBAL_REMOVE_IF_UNREFERENCED UINTN %s = %s;\n' % (PatchPcdSizeVariableName,PcdDataSize)) - AutoGenC.Append('GLOBAL_REMOVE_IF_UNREFERENCED const UINTN %s = %s;\n' % (PatchPcdMaxSizeVariable,Pcd.MaxDatumSize)) + AutoGenC.Append('GLOBAL_REMOVE_IF_UNREFERENCED UINTN %s = %s;\n' % (PatchPcdSizeVariableName, PcdDataSize)) + AutoGenC.Append('GLOBAL_REMOVE_IF_UNREFERENCED const UINTN %s = %s;\n' % (PatchPcdMaxSizeVariable, Pcd.MaxDatumSize)) elif Pcd.Type == TAB_PCDS_PATCHABLE_IN_MODULE: AutoGenH.Append('#define %s %s\n' %(PcdValueName, Value)) 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)) - - PcdDataSize = GetPcdSize(Pcd) + + PcdDataSize = Pcd.GetPcdSize() AutoGenH.Append('#define %s %s\n' % (PatchPcdSizeTokenName, PcdDataSize)) - - AutoGenH.Append('#define %s %s \n' % (GetModeSizeName,PatchPcdSizeVariableName)) + + AutoGenH.Append('#define %s %s \n' % (GetModeSizeName, PatchPcdSizeVariableName)) AutoGenH.Append('extern UINTN %s; \n' % PatchPcdSizeVariableName) - AutoGenC.Append('GLOBAL_REMOVE_IF_UNREFERENCED UINTN %s = %s;\n' % (PatchPcdSizeVariableName,PcdDataSize)) + AutoGenC.Append('GLOBAL_REMOVE_IF_UNREFERENCED UINTN %s = %s;\n' % (PatchPcdSizeVariableName, PcdDataSize)) else: - PcdDataSize = GetPcdSize(Pcd) + PcdDataSize = Pcd.GetPcdSize() AutoGenH.Append('#define %s %s\n' % (FixPcdSizeTokenName, PcdDataSize)) - AutoGenH.Append('#define %s %s \n' % (GetModeSizeName,FixPcdSizeTokenName)) - + AutoGenH.Append('#define %s %s \n' % (GetModeSizeName, FixPcdSizeTokenName)) + AutoGenH.Append('#define %s %s\n' %(PcdValueName, Value)) AutoGenC.Append('GLOBAL_REMOVE_IF_UNREFERENCED %s %s %s = %s;\n' %(Const, Pcd.DatumType, PcdVariableName, PcdValueName)) AutoGenH.Append('extern %s %s %s%s;\n' % (Const, Pcd.DatumType, PcdVariableName, Array)) @@ -1222,22 +1186,24 @@ def CreateLibraryPcdCode(Info, AutoGenC, AutoGenH, Pcd): if Pcd.PcdValueFromComm: Pcd.DefaultValue = Pcd.PcdValueFromComm + elif Pcd.PcdValueFromFdf: + Pcd.DefaultValue = Pcd.PcdValueFromFdf # # Write PCDs # - if Pcd.Type in gDynamicExPcd: + if Pcd.Type in PCD_DYNAMIC_EX_TYPE_SET: TokenNumber = int(Pcd.TokenValue, 0) else: if (Pcd.TokenCName, Pcd.TokenSpaceGuidCName) not in PcdTokenNumber: - # If one of the Source built modules listed in the DSC is not listed in FDF modules, - # and the INF lists a PCD can only use the PcdsDynamic access method (it is only - # listed in the DEC file that declares the PCD as PcdsDynamic), then build tool will - # report warning message notify the PI that they are attempting to build a module - # that must be included in a flash image in order to be functional. These Dynamic PCD - # will not be added into the Database unless it is used by other modules that are - # included in the FDF file. + # If one of the Source built modules listed in the DSC is not listed in FDF modules, + # and the INF lists a PCD can only use the PcdsDynamic access method (it is only + # listed in the DEC file that declares the PCD as PcdsDynamic), then build tool will + # report warning message notify the PI that they are attempting to build a module + # that must be included in a flash image in order to be functional. These Dynamic PCD + # will not be added into the Database unless it is used by other modules that are + # included in the FDF file. # In this case, just assign an invalid token number to make it pass build. - if Pcd.Type in PCD_DYNAMIC_TYPE_LIST: + if Pcd.Type in PCD_DYNAMIC_TYPE_SET: TokenNumber = 0 else: EdkLogger.error("build", AUTOGEN_ERROR, @@ -1266,17 +1232,17 @@ def CreateLibraryPcdCode(Info, AutoGenC, AutoGenH, Pcd): Type = '(VOID *)' Array = '[]' PcdItemType = Pcd.Type - if PcdItemType in gDynamicExPcd: + if PcdItemType in PCD_DYNAMIC_EX_TYPE_SET: PcdExTokenName = '_PCD_TOKEN_' + TokenSpaceGuidCName + '_' + TokenCName AutoGenH.Append('\n#define %s %dU\n' % (PcdExTokenName, TokenNumber)) - + if Info.IsLibrary: PcdList = Info.LibraryPcdList else: PcdList = Info.ModulePcdList PcdExCNameTest = 0 for PcdModule in PcdList: - if PcdModule.Type in gDynamicExPcd and Pcd.TokenCName == PcdModule.TokenCName: + if PcdModule.Type in PCD_DYNAMIC_EX_TYPE_SET and Pcd.TokenCName == PcdModule.TokenCName: PcdExCNameTest += 1 # get out early once we found > 1... if PcdExCNameTest > 1: @@ -1288,7 +1254,7 @@ def CreateLibraryPcdCode(Info, AutoGenC, AutoGenH, Pcd): AutoGenH.Append('// Disabled the macros, as PcdToken and PcdGet/Set are not allowed in the case that more than one DynamicEx Pcds are different Guids but same CName.\n') AutoGenH.Append('// #define %s %s\n' % (PcdTokenName, PcdExTokenName)) AutoGenH.Append('// #define %s LibPcdGetEx%s(&%s, %s)\n' % (GetModeName, DatumSizeLib, Pcd.TokenSpaceGuidCName, PcdTokenName)) - AutoGenH.Append('// #define %s LibPcdGetExSize(&%s, %s)\n' % (GetModeSizeName,Pcd.TokenSpaceGuidCName, PcdTokenName)) + AutoGenH.Append('// #define %s LibPcdGetExSize(&%s, %s)\n' % (GetModeSizeName, Pcd.TokenSpaceGuidCName, PcdTokenName)) if Pcd.DatumType not in TAB_PCD_NUMERIC_TYPES: AutoGenH.Append('// #define %s(SizeOfBuffer, Buffer) LibPcdSetEx%s(&%s, %s, (SizeOfBuffer), (Buffer))\n' % (SetModeName, DatumSizeLib, Pcd.TokenSpaceGuidCName, PcdTokenName)) AutoGenH.Append('// #define %s(SizeOfBuffer, Buffer) LibPcdSetEx%sS(&%s, %s, (SizeOfBuffer), (Buffer))\n' % (SetModeStatusName, DatumSizeLib, Pcd.TokenSpaceGuidCName, PcdTokenName)) @@ -1298,7 +1264,7 @@ def CreateLibraryPcdCode(Info, AutoGenC, AutoGenH, Pcd): else: AutoGenH.Append('#define %s %s\n' % (PcdTokenName, PcdExTokenName)) AutoGenH.Append('#define %s LibPcdGetEx%s(&%s, %s)\n' % (GetModeName, DatumSizeLib, Pcd.TokenSpaceGuidCName, PcdTokenName)) - AutoGenH.Append('#define %s LibPcdGetExSize(&%s, %s)\n' % (GetModeSizeName,Pcd.TokenSpaceGuidCName, PcdTokenName)) + AutoGenH.Append('#define %s LibPcdGetExSize(&%s, %s)\n' % (GetModeSizeName, Pcd.TokenSpaceGuidCName, PcdTokenName)) if Pcd.DatumType not in TAB_PCD_NUMERIC_TYPES: AutoGenH.Append('#define %s(SizeOfBuffer, Buffer) LibPcdSetEx%s(&%s, %s, (SizeOfBuffer), (Buffer))\n' % (SetModeName, DatumSizeLib, Pcd.TokenSpaceGuidCName, PcdTokenName)) AutoGenH.Append('#define %s(SizeOfBuffer, Buffer) LibPcdSetEx%sS(&%s, %s, (SizeOfBuffer), (Buffer))\n' % (SetModeStatusName, DatumSizeLib, Pcd.TokenSpaceGuidCName, PcdTokenName)) @@ -1307,13 +1273,13 @@ def CreateLibraryPcdCode(Info, AutoGenC, AutoGenH, Pcd): AutoGenH.Append('#define %s(Value) LibPcdSetEx%sS(&%s, %s, (Value))\n' % (SetModeStatusName, DatumSizeLib, Pcd.TokenSpaceGuidCName, PcdTokenName)) else: AutoGenH.Append('#define _PCD_TOKEN_%s %dU\n' % (TokenCName, TokenNumber)) - if PcdItemType in gDynamicPcd: + if PcdItemType in PCD_DYNAMIC_TYPE_SET: PcdList = [] PcdCNameList = [] PcdList.extend(Info.LibraryPcdList) PcdList.extend(Info.ModulePcdList) for PcdModule in PcdList: - if PcdModule.Type in gDynamicPcd: + if PcdModule.Type in PCD_DYNAMIC_TYPE_SET: PcdCNameList.append(PcdModule.TokenCName) if PcdCNameList.count(Pcd.TokenCName) > 1: EdkLogger.error("build", AUTOGEN_ERROR, "More than one Dynamic Pcds [%s] are different Guids but same CName.They need to be changed to DynamicEx type to avoid the confliction.\n" % (TokenCName), ExtraData="[%s]" % str(Info.MetaFile.Path)) @@ -1338,7 +1304,7 @@ def CreateLibraryPcdCode(Info, AutoGenC, AutoGenH, Pcd): else: AutoGenH.Append('extern volatile %s %s%s;\n' % (DatumType, PcdVariableName, Array)) AutoGenH.Append('#define %s %s_gPcd_BinaryPatch_%s\n' %(GetModeName, Type, TokenCName)) - PcdDataSize = GetPcdSize(Pcd) + PcdDataSize = Pcd.GetPcdSize() if Pcd.DatumType not in TAB_PCD_NUMERIC_TYPES: AutoGenH.Append('#define %s(SizeOfBuffer, Buffer) LibPatchPcdSetPtrAndSize((VOID *)_gPcd_BinaryPatch_%s, &%s, %s, (SizeOfBuffer), (Buffer))\n' % (SetModeName, TokenCName, PatchPcdSizeVariableName, PatchPcdMaxSizeVariable)) AutoGenH.Append('#define %s(SizeOfBuffer, Buffer) LibPatchPcdSetPtrAndSizeS((VOID *)_gPcd_BinaryPatch_%s, &%s, %s, (SizeOfBuffer), (Buffer))\n' % (SetModeStatusName, TokenCName, PatchPcdSizeVariableName, PatchPcdMaxSizeVariable)) @@ -1349,11 +1315,11 @@ def CreateLibraryPcdCode(Info, AutoGenC, AutoGenH, Pcd): AutoGenH.Append('#define %s(Value) ((%s = (Value)), RETURN_SUCCESS)\n' % (SetModeStatusName, PcdVariableName)) AutoGenH.Append('#define %s %s\n' % (PatchPcdSizeTokenName, PcdDataSize)) - AutoGenH.Append('#define %s %s\n' % (GetModeSizeName,PatchPcdSizeVariableName)) + AutoGenH.Append('#define %s %s\n' % (GetModeSizeName, PatchPcdSizeVariableName)) AutoGenH.Append('extern UINTN %s; \n' % PatchPcdSizeVariableName) - + if PcdItemType == TAB_PCDS_FIXED_AT_BUILD or PcdItemType == TAB_PCDS_FEATURE_FLAG: - key = ".".join((Pcd.TokenSpaceGuidCName,Pcd.TokenCName)) + key = ".".join((Pcd.TokenSpaceGuidCName, Pcd.TokenCName)) PcdVariableName = '_gPcd_' + gItemTypeStringDatabase[Pcd.Type] + '_' + TokenCName if DatumType == TAB_VOID and Array == '[]': DatumType = [TAB_UINT8, TAB_UINT16][Pcd.DefaultValue[0] == 'L'] @@ -1362,7 +1328,7 @@ def CreateLibraryPcdCode(Info, AutoGenC, AutoGenH, Pcd): AutoGenH.Append('extern const %s _gPcd_FixedAtBuild_%s%s;\n' %(DatumType, TokenCName, Array)) AutoGenH.Append('#define %s %s_gPcd_FixedAtBuild_%s\n' %(GetModeName, Type, TokenCName)) AutoGenH.Append('//#define %s ASSERT(FALSE) // It is not allowed to set value for a FIXED_AT_BUILD PCD\n' % SetModeName) - + ConstFixedPcd = False if PcdItemType == TAB_PCDS_FIXED_AT_BUILD and (key in Info.ConstPcd or (Info.IsLibrary and not Info._ReferenceModules)): ConstFixedPcd = True @@ -1372,19 +1338,19 @@ def CreateLibraryPcdCode(Info, AutoGenC, AutoGenH, Pcd): AutoGenH.Append('#define _PCD_VALUE_%s %s%s\n' %(TokenCName, Type, PcdVariableName)) else: AutoGenH.Append('#define _PCD_VALUE_%s %s\n' %(TokenCName, Pcd.DefaultValue)) - PcdDataSize = GetPcdSize(Pcd) + PcdDataSize = Pcd.GetPcdSize() if PcdItemType == TAB_PCDS_FIXED_AT_BUILD: if Pcd.DatumType not in TAB_PCD_NUMERIC_TYPES: if ConstFixedPcd: AutoGenH.Append('#define %s %s\n' % (FixPcdSizeTokenName, PcdDataSize)) - AutoGenH.Append('#define %s %s\n' % (GetModeSizeName,FixPcdSizeTokenName)) + AutoGenH.Append('#define %s %s\n' % (GetModeSizeName, FixPcdSizeTokenName)) else: - AutoGenH.Append('#define %s %s\n' % (GetModeSizeName,FixedPcdSizeVariableName)) - AutoGenH.Append('#define %s %s\n' % (FixPcdSizeTokenName,FixedPcdSizeVariableName)) + AutoGenH.Append('#define %s %s\n' % (GetModeSizeName, FixedPcdSizeVariableName)) + AutoGenH.Append('#define %s %s\n' % (FixPcdSizeTokenName, FixedPcdSizeVariableName)) AutoGenH.Append('extern const UINTN %s; \n' % FixedPcdSizeVariableName) else: AutoGenH.Append('#define %s %s\n' % (FixPcdSizeTokenName, PcdDataSize)) - AutoGenH.Append('#define %s %s\n' % (GetModeSizeName,FixPcdSizeTokenName)) + AutoGenH.Append('#define %s %s\n' % (GetModeSizeName, FixPcdSizeTokenName)) ## Create code for library constructor # @@ -1412,11 +1378,11 @@ def CreateLibraryConstructorCode(Info, AutoGenC, AutoGenH): elif Lib.ModuleType in SUP_MODULE_SET_PEI: ConstructorPrototypeString.Append(gLibraryStructorPrototype['PEI'].Replace(Dict)) ConstructorCallingString.Append(gLibraryStructorCall['PEI'].Replace(Dict)) - elif Lib.ModuleType in [SUP_MODULE_DXE_CORE,SUP_MODULE_DXE_DRIVER,SUP_MODULE_DXE_SMM_DRIVER,SUP_MODULE_DXE_RUNTIME_DRIVER, - SUP_MODULE_DXE_SAL_DRIVER,SUP_MODULE_UEFI_DRIVER,SUP_MODULE_UEFI_APPLICATION,SUP_MODULE_SMM_CORE]: + elif Lib.ModuleType in [SUP_MODULE_DXE_CORE, SUP_MODULE_DXE_DRIVER, SUP_MODULE_DXE_SMM_DRIVER, SUP_MODULE_DXE_RUNTIME_DRIVER, + SUP_MODULE_DXE_SAL_DRIVER, SUP_MODULE_UEFI_DRIVER, SUP_MODULE_UEFI_APPLICATION, SUP_MODULE_SMM_CORE]: ConstructorPrototypeString.Append(gLibraryStructorPrototype['DXE'].Replace(Dict)) ConstructorCallingString.Append(gLibraryStructorCall['DXE'].Replace(Dict)) - elif Lib.ModuleType in [SUP_MODULE_MM_STANDALONE,SUP_MODULE_MM_CORE_STANDALONE]: + elif Lib.ModuleType in [SUP_MODULE_MM_STANDALONE, SUP_MODULE_MM_CORE_STANDALONE]: ConstructorPrototypeString.Append(gLibraryStructorPrototype['MM'].Replace(Dict)) ConstructorCallingString.Append(gLibraryStructorCall['MM'].Replace(Dict)) @@ -1441,10 +1407,10 @@ def CreateLibraryConstructorCode(Info, AutoGenC, AutoGenH): AutoGenC.Append(gLibraryString[SUP_MODULE_BASE].Replace(Dict)) elif Info.ModuleType in SUP_MODULE_SET_PEI: AutoGenC.Append(gLibraryString['PEI'].Replace(Dict)) - elif Info.ModuleType in [SUP_MODULE_DXE_CORE,SUP_MODULE_DXE_DRIVER,SUP_MODULE_DXE_SMM_DRIVER,SUP_MODULE_DXE_RUNTIME_DRIVER, - SUP_MODULE_DXE_SAL_DRIVER,SUP_MODULE_UEFI_DRIVER,SUP_MODULE_UEFI_APPLICATION,SUP_MODULE_SMM_CORE]: + elif Info.ModuleType in [SUP_MODULE_DXE_CORE, SUP_MODULE_DXE_DRIVER, SUP_MODULE_DXE_SMM_DRIVER, SUP_MODULE_DXE_RUNTIME_DRIVER, + SUP_MODULE_DXE_SAL_DRIVER, SUP_MODULE_UEFI_DRIVER, SUP_MODULE_UEFI_APPLICATION, SUP_MODULE_SMM_CORE]: AutoGenC.Append(gLibraryString['DXE'].Replace(Dict)) - elif Info.ModuleType in [SUP_MODULE_MM_STANDALONE,SUP_MODULE_MM_CORE_STANDALONE]: + elif Info.ModuleType in [SUP_MODULE_MM_STANDALONE, SUP_MODULE_MM_CORE_STANDALONE]: AutoGenC.Append(gLibraryString['MM'].Replace(Dict)) ## Create code for library destructor @@ -1474,11 +1440,11 @@ def CreateLibraryDestructorCode(Info, AutoGenC, AutoGenH): elif Lib.ModuleType in SUP_MODULE_SET_PEI: DestructorPrototypeString.Append(gLibraryStructorPrototype['PEI'].Replace(Dict)) DestructorCallingString.Append(gLibraryStructorCall['PEI'].Replace(Dict)) - elif Lib.ModuleType in [SUP_MODULE_DXE_CORE,SUP_MODULE_DXE_DRIVER,SUP_MODULE_DXE_SMM_DRIVER,SUP_MODULE_DXE_RUNTIME_DRIVER, - SUP_MODULE_DXE_SAL_DRIVER,SUP_MODULE_UEFI_DRIVER,SUP_MODULE_UEFI_APPLICATION, SUP_MODULE_SMM_CORE]: + elif Lib.ModuleType in [SUP_MODULE_DXE_CORE, SUP_MODULE_DXE_DRIVER, SUP_MODULE_DXE_SMM_DRIVER, SUP_MODULE_DXE_RUNTIME_DRIVER, + SUP_MODULE_DXE_SAL_DRIVER, SUP_MODULE_UEFI_DRIVER, SUP_MODULE_UEFI_APPLICATION, SUP_MODULE_SMM_CORE]: DestructorPrototypeString.Append(gLibraryStructorPrototype['DXE'].Replace(Dict)) DestructorCallingString.Append(gLibraryStructorCall['DXE'].Replace(Dict)) - elif Lib.ModuleType in [SUP_MODULE_MM_STANDALONE,SUP_MODULE_MM_CORE_STANDALONE]: + elif Lib.ModuleType in [SUP_MODULE_MM_STANDALONE, SUP_MODULE_MM_CORE_STANDALONE]: DestructorPrototypeString.Append(gLibraryStructorPrototype['MM'].Replace(Dict)) DestructorCallingString.Append(gLibraryStructorCall['MM'].Replace(Dict)) @@ -1503,10 +1469,10 @@ def CreateLibraryDestructorCode(Info, AutoGenC, AutoGenH): AutoGenC.Append(gLibraryString[SUP_MODULE_BASE].Replace(Dict)) elif Info.ModuleType in SUP_MODULE_SET_PEI: AutoGenC.Append(gLibraryString['PEI'].Replace(Dict)) - elif Info.ModuleType in [SUP_MODULE_DXE_CORE,SUP_MODULE_DXE_DRIVER,SUP_MODULE_DXE_SMM_DRIVER,SUP_MODULE_DXE_RUNTIME_DRIVER, - SUP_MODULE_DXE_SAL_DRIVER,SUP_MODULE_UEFI_DRIVER,SUP_MODULE_UEFI_APPLICATION,SUP_MODULE_SMM_CORE]: + elif Info.ModuleType in [SUP_MODULE_DXE_CORE, SUP_MODULE_DXE_DRIVER, SUP_MODULE_DXE_SMM_DRIVER, SUP_MODULE_DXE_RUNTIME_DRIVER, + SUP_MODULE_DXE_SAL_DRIVER, SUP_MODULE_UEFI_DRIVER, SUP_MODULE_UEFI_APPLICATION, SUP_MODULE_SMM_CORE]: AutoGenC.Append(gLibraryString['DXE'].Replace(Dict)) - elif Info.ModuleType in [SUP_MODULE_MM_STANDALONE,SUP_MODULE_MM_CORE_STANDALONE]: + elif Info.ModuleType in [SUP_MODULE_MM_STANDALONE, SUP_MODULE_MM_CORE_STANDALONE]: AutoGenC.Append(gLibraryString['MM'].Replace(Dict)) @@ -1565,7 +1531,7 @@ def CreateModuleEntryPointCode(Info, AutoGenC, AutoGenH): else: AutoGenC.Append(gPeimEntryPointString[2].Replace(Dict)) AutoGenH.Append(gPeimEntryPointPrototype.Replace(Dict)) - elif Info.ModuleType in [SUP_MODULE_DXE_RUNTIME_DRIVER,SUP_MODULE_DXE_DRIVER,SUP_MODULE_DXE_SAL_DRIVER,SUP_MODULE_UEFI_DRIVER]: + elif Info.ModuleType in [SUP_MODULE_DXE_RUNTIME_DRIVER, SUP_MODULE_DXE_DRIVER, SUP_MODULE_DXE_SAL_DRIVER, SUP_MODULE_UEFI_DRIVER]: if NumEntryPoints < 2: AutoGenC.Append(gUefiDriverEntryPointString[NumEntryPoints].Replace(Dict)) else: @@ -1618,7 +1584,7 @@ def CreateModuleUnloadImageCode(Info, AutoGenC, AutoGenH): # def CreateGuidDefinitionCode(Info, AutoGenC, AutoGenH): if Info.ModuleType in [SUP_MODULE_USER_DEFINED, SUP_MODULE_BASE]: - GuidType = "GUID" + GuidType = TAB_GUID else: GuidType = "EFI_GUID" @@ -1642,7 +1608,7 @@ def CreateGuidDefinitionCode(Info, AutoGenC, AutoGenH): # def CreateProtocolDefinitionCode(Info, AutoGenC, AutoGenH): if Info.ModuleType in [SUP_MODULE_USER_DEFINED, SUP_MODULE_BASE]: - GuidType = "GUID" + GuidType = TAB_GUID else: GuidType = "EFI_GUID" @@ -1666,7 +1632,7 @@ def CreateProtocolDefinitionCode(Info, AutoGenC, AutoGenH): # def CreatePpiDefinitionCode(Info, AutoGenC, AutoGenH): if Info.ModuleType in [SUP_MODULE_USER_DEFINED, SUP_MODULE_BASE]: - GuidType = "GUID" + GuidType = TAB_GUID else: GuidType = "EFI_GUID" @@ -1693,9 +1659,9 @@ def CreatePcdCode(Info, AutoGenC, AutoGenH): # Collect Token Space GUIDs used by DynamicEc PCDs TokenSpaceList = [] for Pcd in Info.ModulePcdList: - if Pcd.Type in gDynamicExPcd and Pcd.TokenSpaceGuidCName not in TokenSpaceList: - TokenSpaceList += [Pcd.TokenSpaceGuidCName] - + if Pcd.Type in PCD_DYNAMIC_EX_TYPE_SET and Pcd.TokenSpaceGuidCName not in TokenSpaceList: + TokenSpaceList.append(Pcd.TokenSpaceGuidCName) + SkuMgr = Info.Workspace.Platform.SkuIdMgr AutoGenH.Append("\n// Definition of SkuId Array\n") AutoGenH.Append("extern UINT64 _gPcd_SkuId_Array[];\n") @@ -1703,9 +1669,9 @@ def CreatePcdCode(Info, AutoGenC, AutoGenH): if TokenSpaceList: AutoGenH.Append("\n// Definition of PCD Token Space GUIDs used in this module\n\n") if Info.ModuleType in [SUP_MODULE_USER_DEFINED, SUP_MODULE_BASE]: - GuidType = "GUID" + GuidType = TAB_GUID else: - GuidType = "EFI_GUID" + GuidType = "EFI_GUID" for Item in TokenSpaceList: AutoGenH.Append('extern %s %s;\n' % (GuidType, Item)) @@ -1964,7 +1930,7 @@ def BmpImageDecoder(File, Buffer, PaletteIndex, TransParent): ImageType, = struct.unpack('2s', Buffer[0:2]) if ImageType!= 'BM': # BMP file type is 'BM' EdkLogger.error("build", FILE_TYPE_MISMATCH, "The file %s is not a standard BMP file." % File.Path) - BMP_IMAGE_HEADER = collections.namedtuple('BMP_IMAGE_HEADER', ['bfSize','bfReserved1','bfReserved2','bfOffBits','biSize','biWidth','biHeight','biPlanes','biBitCount', 'biCompression', 'biSizeImage','biXPelsPerMeter','biYPelsPerMeter','biClrUsed','biClrImportant']) + BMP_IMAGE_HEADER = collections.namedtuple('BMP_IMAGE_HEADER', ['bfSize', 'bfReserved1', 'bfReserved2', 'bfOffBits', 'biSize', 'biWidth', 'biHeight', 'biPlanes', 'biBitCount', 'biCompression', 'biSizeImage', 'biXPelsPerMeter', 'biYPelsPerMeter', 'biClrUsed', 'biClrImportant']) BMP_IMAGE_HEADER_STRUCT = struct.Struct('IHHIIIIHHIIIIII') BmpHeader = BMP_IMAGE_HEADER._make(BMP_IMAGE_HEADER_STRUCT.unpack_from(Buffer[2:])) # @@ -2048,16 +2014,14 @@ def CreateHeaderCode(Info, AutoGenC, AutoGenH): # file header AutoGenH.Append(gAutoGenHeaderString.Replace({'FileName':'AutoGen.h'})) # header file Prologue - AutoGenH.Append(gAutoGenHPrologueString.Replace({'File':'AUTOGENH','Guid':Info.Guid.replace('-','_')})) + AutoGenH.Append(gAutoGenHPrologueString.Replace({'File':'AUTOGENH','Guid':Info.Guid.replace('-', '_')})) AutoGenH.Append(gAutoGenHCppPrologueString) if Info.AutoGenVersion >= 0x00010005: # header files includes - AutoGenH.Append("#include <%s>\n" % gBasicHeaderFile) - if Info.ModuleType in gModuleTypeHeaderFile \ - and gModuleTypeHeaderFile[Info.ModuleType][0] != gBasicHeaderFile: + if Info.ModuleType in gModuleTypeHeaderFile: AutoGenH.Append("#include <%s>\n" % gModuleTypeHeaderFile[Info.ModuleType][0]) # - # if either PcdLib in [LibraryClasses] sections or there exist Pcd section, add PcdLib.h + # if either PcdLib in [LibraryClasses] sections or there exist Pcd section, add PcdLib.h # As if modules only uses FixedPcd, then PcdLib is not needed in [LibraryClasses] section. # if 'PcdLib' in Info.Module.LibraryClasses or Info.Module.Pcds: @@ -2126,7 +2090,7 @@ def CreateCode(Info, AutoGenC, AutoGenH, StringH, UniGenCFlag, UniGenBinBuffer, if Info.UnicodeFileList: FileName = "%sStrDefs.h" % Info.Name StringH.Append(gAutoGenHeaderString.Replace({'FileName':FileName})) - StringH.Append(gAutoGenHPrologueString.Replace({'File':'STRDEFS', 'Guid':Info.Guid.replace('-','_')})) + StringH.Append(gAutoGenHPrologueString.Replace({'File':'STRDEFS', 'Guid':Info.Guid.replace('-', '_')})) CreateUnicodeStringCode(Info, AutoGenC, StringH, UniGenCFlag, UniGenBinBuffer) GuidMacros = [] @@ -2136,15 +2100,16 @@ def CreateCode(Info, AutoGenC, AutoGenH, StringH, UniGenCFlag, UniGenBinBuffer, GuidMacros.append('#define %s %s' % (Guid, Info.Module.Guids[Guid])) for Guid, Value in Info.Module.Protocols.items() + Info.Module.Ppis.items(): GuidMacros.append('#define %s %s' % (Guid, Value)) - # supports FixedAtBuild usage in VFR file + # supports FixedAtBuild and FeaturePcd usage in VFR file if Info.VfrFileList and Info.ModulePcdList: GuidMacros.append('#define %s %s' % ('FixedPcdGetBool(TokenName)', '_PCD_VALUE_##TokenName')) GuidMacros.append('#define %s %s' % ('FixedPcdGet8(TokenName)', '_PCD_VALUE_##TokenName')) GuidMacros.append('#define %s %s' % ('FixedPcdGet16(TokenName)', '_PCD_VALUE_##TokenName')) GuidMacros.append('#define %s %s' % ('FixedPcdGet32(TokenName)', '_PCD_VALUE_##TokenName')) GuidMacros.append('#define %s %s' % ('FixedPcdGet64(TokenName)', '_PCD_VALUE_##TokenName')) + GuidMacros.append('#define %s %s' % ('FeaturePcdGet(TokenName)', '_PCD_VALUE_##TokenName')) for Pcd in Info.ModulePcdList: - if Pcd.Type == TAB_PCDS_FIXED_AT_BUILD: + if Pcd.Type in [TAB_PCDS_FIXED_AT_BUILD, TAB_PCDS_FEATURE_FLAG]: TokenCName = Pcd.TokenCName Value = Pcd.DefaultValue if Pcd.DatumType == 'BOOLEAN': @@ -2171,7 +2136,7 @@ def CreateCode(Info, AutoGenC, AutoGenH, StringH, UniGenCFlag, UniGenBinBuffer, if Info.IdfFileList: FileName = "%sImgDefs.h" % Info.Name StringIdf.Append(gAutoGenHeaderString.Replace({'FileName':FileName})) - StringIdf.Append(gAutoGenHPrologueString.Replace({'File':'IMAGEDEFS', 'Guid':Info.Guid.replace('-','_')})) + StringIdf.Append(gAutoGenHPrologueString.Replace({'File':'IMAGEDEFS', 'Guid':Info.Guid.replace('-', '_')})) CreateIdfFileCode(Info, AutoGenC, StringIdf, IdfGenCFlag, IdfGenBinBuffer) StringIdf.Append("\n#endif\n")