X-Git-Url: https://git.proxmox.com/?p=mirror_edk2.git;a=blobdiff_plain;f=BaseTools%2FSource%2FPython%2FAutoGen%2FGenC.py;h=e6e884762340451ab492d01bbf2328ee4235094d;hp=1db68ebec5236c94623524585155bccc5fb2704b;hb=da92f27632d2c89fa8726948ac9b02461ca8b61e;hpb=756ad8f8e9d3e345f1883546e2a3125203e234aa diff --git a/BaseTools/Source/Python/AutoGen/GenC.py b/BaseTools/Source/Python/AutoGen/GenC.py index 1db68ebec5..e6e8847623 100644 --- a/BaseTools/Source/Python/AutoGen/GenC.py +++ b/BaseTools/Source/Python/AutoGen/GenC.py @@ -1,7 +1,7 @@ ## @file # Routines for generating AutoGen.h and AutoGen.c # -# Copyright (c) 2007 - 2010, Intel Corporation. All rights reserved.
+# Copyright (c) 2007 - 2011, 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 @@ -1028,7 +1028,9 @@ def CreateModulePcdCode(Info, AutoGenC, AutoGenH, Pcd): ArraySize = ArraySize / 2; if ArraySize < (len(Value) + 1): - ArraySize = len(Value) + 1 + EdkLogger.error("build", AUTOGEN_ERROR, + "The maximum size of VOID* type PCD '%s.%s' is less than its actual size occupied." % (Pcd.TokenSpaceGuidCName, Pcd.TokenCName), + ExtraData="[%s]" % str(Info)) Value = NewValue + '0 }' Array = '[%d]' % ArraySize # @@ -1096,6 +1098,10 @@ def CreateLibraryPcdCode(Info, AutoGenC, AutoGenH, Pcd): ExtraData="[%s]" % str(Info)) TokenNumber = PcdTokenNumber[TokenCName, TokenSpaceGuidCName] + # If PCD is DynamicEx, then use TokenNumber declared in DEC file + if Pcd.Type in gDynamicExPcd: + TokenNumber = int(Pcd.TokenValue, 0) + if Pcd.Type not in gItemTypeStringDatabase: EdkLogger.error("build", AUTOGEN_ERROR, "Unknown PCD type [%s] of PCD %s.%s" % (Pcd.Type, Pcd.TokenSpaceGuidCName, Pcd.TokenCName), @@ -1262,10 +1268,11 @@ def CreatePcdDatabasePhaseSpecificAutoGen (Platform, Phase): VariableHeadValueList = [] Pcd.InitString = 'UNINIT' - if Pcd.Type in ["DynamicVpd", "DynamicExVpd"]: - Pcd.TokenTypeList = ['PCD_TYPE_VPD'] - elif Pcd.DatumType == 'VOID*': - Pcd.TokenTypeList = ['PCD_TYPE_STRING'] + if Pcd.DatumType == 'VOID*': + if Pcd.Type not in ["DynamicVpd", "DynamicExVpd"]: + Pcd.TokenTypeList = ['PCD_TYPE_STRING'] + else: + Pcd.TokenTypeList = [] elif Pcd.DatumType == 'BOOLEAN': Pcd.TokenTypeList = ['PCD_DATUM_TYPE_UINT8'] else: @@ -1364,8 +1371,11 @@ def CreatePcdDatabasePhaseSpecificAutoGen (Platform, Phase): Dict['SIZE_TABLE_MAXIMUM_LENGTH'].append(Pcd.MaxDatumSize) if Pcd.MaxDatumSize != '': MaxDatumSize = int(Pcd.MaxDatumSize, 0) - if MaxDatumSize > Size: - Size = MaxDatumSize + if MaxDatumSize < Size: + EdkLogger.error("build", AUTOGEN_ERROR, + "The maximum size of VOID* type PCD '%s.%s' is less than its actual size occupied." % (Pcd.TokenSpaceGuidCName, Pcd.TokenCName), + ExtraData="[%s]" % str(Platform)) + Size = MaxDatumSize Dict['STRING_TABLE_LENGTH'].append(Size) StringTableIndex += 1 StringTableSize += (Size) @@ -1671,11 +1681,11 @@ def CreateModuleEntryPointCode(Info, AutoGenC, AutoGenH): if 'PI_SPECIFICATION_VERSION' in Info.Module.Specification: PiSpecVersion = Info.Module.Specification['PI_SPECIFICATION_VERSION'] else: - PiSpecVersion = 0 + PiSpecVersion = '0x00000000' if 'UEFI_SPECIFICATION_VERSION' in Info.Module.Specification: UefiSpecVersion = Info.Module.Specification['UEFI_SPECIFICATION_VERSION'] else: - UefiSpecVersion = 0 + UefiSpecVersion = '0x00000000' Dict = { 'Function' : Info.Module.ModuleEntryPointList, 'PiSpecVersion' : PiSpecVersion, @@ -1683,14 +1693,15 @@ def CreateModuleEntryPointCode(Info, AutoGenC, AutoGenH): } if Info.ModuleType in ['PEI_CORE', 'DXE_CORE', 'SMM_CORE']: - if NumEntryPoints != 1: - EdkLogger.error( - "build", - AUTOGEN_ERROR, - '%s must have exactly one entry point' % Info.ModuleType, - File=str(Info), - ExtraData= ", ".join(Info.Module.ModuleEntryPointList) - ) + if Info.SourceFileList <> None and Info.SourceFileList <> []: + if NumEntryPoints != 1: + EdkLogger.error( + "build", + AUTOGEN_ERROR, + '%s must have exactly one entry point' % Info.ModuleType, + File=str(Info), + ExtraData= ", ".join(Info.Module.ModuleEntryPointList) + ) if Info.ModuleType == 'PEI_CORE': AutoGenC.Append(gPeiCoreEntryPointString.Replace(Dict)) AutoGenH.Append(gPeiCoreEntryPointPrototype.Replace(Dict)) @@ -1821,6 +1832,23 @@ def CreatePpiDefinitionCode(Info, AutoGenC, AutoGenH): # @param AutoGenH The TemplateString object for header file # 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] + + # Add extern declarations to AutoGen.h if one or more Token Space GUIDs were found + if TokenSpaceList <> []: + AutoGenH.Append("\n// Definition of PCD Token Space GUIDs used in this module\n\n") + if Info.ModuleType in ["USER_DEFINED", "BASE"]: + GuidType = "GUID" + else: + GuidType = "EFI_GUID" + for Item in TokenSpaceList: + AutoGenH.Append('extern %s %s;\n' % (GuidType, Item)) + if Info.IsLibrary: if Info.ModulePcdList: AutoGenH.Append("\n// PCD definitions\n") @@ -1854,8 +1882,10 @@ def CreateUnicodeStringCode(Info, AutoGenC, AutoGenH, UniGenCFlag, UniGenBinBuff IncList = [Info.MetaFile.Dir] # Get all files under [Sources] section in inf file for EDK-II module + EDK2Module = True SrcList = [F for F in Info.SourceFileList] if Info.AutoGenVersion < 0x00010005: + EDK2Module = False # Get all files under the module directory for EDK-I module Cwd = os.getcwd() os.chdir(Info.MetaFile.Dir) @@ -1877,7 +1907,7 @@ def CreateUnicodeStringCode(Info, AutoGenC, AutoGenH, UniGenCFlag, UniGenBinBuff CompatibleMode = False # - # -s is a temporary option dedicated for building .UNI files with ISO 639-2 lanauge codes of EDK Shell in EDK2 + # -s is a temporary option dedicated for building .UNI files with ISO 639-2 language codes of EDK Shell in EDK2 # if 'BUILD' in Info.BuildOption and Info.BuildOption['BUILD']['FLAGS'].find('-s') > -1: if CompatibleMode: @@ -1888,7 +1918,12 @@ def CreateUnicodeStringCode(Info, AutoGenC, AutoGenH, UniGenCFlag, UniGenBinBuff else: ShellMode = False - Header, Code = GetStringFiles(Info.UnicodeFileList, SrcList, IncList, Info.IncludePathList, ['.uni', '.inf'], Info.Name, CompatibleMode, ShellMode, UniGenCFlag, UniGenBinBuffer) + #RFC4646 is only for EDKII modules and ISO639-2 for EDK modules + if EDK2Module: + FilterInfo = [EDK2Module] + [Info.PlatformInfo.Platform.RFCLanguages] + else: + FilterInfo = [EDK2Module] + [Info.PlatformInfo.Platform.ISOLanguages] + Header, Code = GetStringFiles(Info.UnicodeFileList, SrcList, IncList, Info.IncludePathList, ['.uni', '.inf'], Info.Name, CompatibleMode, ShellMode, UniGenCFlag, UniGenBinBuffer, FilterInfo) if CompatibleMode or UniGenCFlag: AutoGenC.Append("\n//\n//Unicode String Pack Definition\n//\n") AutoGenC.Append(Code)