X-Git-Url: https://git.proxmox.com/?a=blobdiff_plain;f=BaseTools%2FSource%2FPython%2FAutoGen%2FGenC.py;h=e224568db1ed14d76dead4be053ccc2dfdb7a3fa;hb=938cf4c33a0695ef1011b07e455a7ec2f87b5ad3;hp=aaa88f876aeb089d42f60f8e8030dadc9b78b7e3;hpb=549ae85ce1b00228c3abcf6a9e4022c4f4fba5ed;p=mirror_edk2.git diff --git a/BaseTools/Source/Python/AutoGen/GenC.py b/BaseTools/Source/Python/AutoGen/GenC.py index aaa88f876a..e224568db1 100644 --- a/BaseTools/Source/Python/AutoGen/GenC.py +++ b/BaseTools/Source/Python/AutoGen/GenC.py @@ -18,7 +18,7 @@ import string import collections import struct from Common import EdkLogger - +from Common import GlobalData from Common.BuildToolError import * from Common.DataType import * from Common.Misc import * @@ -937,7 +937,7 @@ def CreateModulePcdCode(Info, AutoGenC, AutoGenH, Pcd): if Info.IsLibrary: PcdList = Info.LibraryPcdList else: - PcdList = Info.ModulePcdList + PcdList = Info.ModulePcdList + Info.LibraryPcdList PcdExCNameTest = 0 for PcdModule in PcdList: if PcdModule.Type in PCD_DYNAMIC_EX_TYPE_SET and Pcd.TokenCName == PcdModule.TokenCName: @@ -1015,50 +1015,19 @@ def CreateModulePcdCode(Info, AutoGenC, AutoGenH, Pcd): 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, TokenCName), ExtraData="[%s]" % str(Info)) - if Pcd.DatumType == TAB_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, 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, TokenCName), - ExtraData="[%s]" % str(Info)) - if not Value.endswith('ULL'): - Value += 'ULL' - elif Pcd.DatumType == TAB_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, 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, TokenCName), - ExtraData="[%s]" % str(Info)) - if not Value.endswith('U'): - Value += 'U' - elif Pcd.DatumType == TAB_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, 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, TokenCName), - ExtraData="[%s]" % str(Info)) - if not Value.endswith('U'): - Value += 'U' - elif Pcd.DatumType == TAB_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, 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, TokenCName), - ExtraData="[%s]" % str(Info)) - if not Value.endswith('U'): - Value += 'U' + 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, TokenCName), + ExtraData="[%s]" % str(Info)) + elif ValueNumber > MAX_VAL_TYPE[Pcd.DatumType]: + EdkLogger.error("build", AUTOGEN_ERROR, + "Too large PCD value for datum type [%s] of PCD %s.%s" % (Pcd.DatumType, Pcd.TokenSpaceGuidCName, TokenCName), + ExtraData="[%s]" % str(Info)) + if Pcd.DatumType == TAB_UINT64 and not Value.endswith('ULL'): + Value += 'ULL' + elif Pcd.DatumType != TAB_UINT64 and not Value.endswith('U'): + Value += 'U' + if Pcd.DatumType not in TAB_PCD_NUMERIC_TYPES: if not Pcd.MaxDatumSize: EdkLogger.error("build", AUTOGEN_ERROR, @@ -1293,7 +1262,6 @@ def CreateLibraryPcdCode(Info, AutoGenC, AutoGenH, Pcd): AutoGenH.Append('#define %s(Value) LibPcdSet%s(%s, (Value))\n' % (SetModeName, DatumSizeLib, PcdTokenName)) AutoGenH.Append('#define %s(Value) LibPcdSet%sS(%s, (Value))\n' % (SetModeStatusName, DatumSizeLib, PcdTokenName)) if PcdItemType == TAB_PCDS_PATCHABLE_IN_MODULE: - GetModeMaxSizeName = '_PCD_GET_MODE_MAXSIZE' + '_' + TokenCName PcdVariableName = '_gPcd_' + gItemTypeStringDatabase[TAB_PCDS_PATCHABLE_IN_MODULE] + '_' + TokenCName if DatumType not in TAB_PCD_NUMERIC_TYPES: if DatumType == TAB_VOID and Array == '[]': @@ -1308,7 +1276,7 @@ def CreateLibraryPcdCode(Info, AutoGenC, AutoGenH, Pcd): 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)) - AutoGenH.Append('#define %s %s\n' % (GetModeMaxSizeName, PatchPcdMaxSizeVariable)) + AutoGenH.Append('#define %s %s\n' % (PatchPcdSizeTokenName, PatchPcdMaxSizeVariable)) AutoGenH.Append('extern const UINTN %s; \n' % PatchPcdMaxSizeVariable) else: AutoGenH.Append('#define %s(Value) (%s = (Value))\n' % (SetModeName, PcdVariableName)) @@ -1330,7 +1298,7 @@ def CreateLibraryPcdCode(Info, AutoGenC, AutoGenH, Pcd): 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)): + if PcdItemType == TAB_PCDS_FIXED_AT_BUILD and (key in Info.ConstPcd or (Info.IsLibrary and not Info.ReferenceModules)): ConstFixedPcd = True if key in Info.ConstPcd: Pcd.DefaultValue = Info.ConstPcd[key]