Sync BaseTool trunk (version r2610) into EDKII BaseTools.
Signed-off-by: Liming Gao <liming.gao@intel.com> git-svn-id: https://svn.code.sf.net/p/edk2/code/trunk/edk2@14856 6f19259b-4bc3-4df7-8a09-765794883524
This commit is contained in:
@ -1,7 +1,7 @@
|
||||
## @file
|
||||
# Generate AutoGen.h, AutoGen.c and *.depex files
|
||||
#
|
||||
# Copyright (c) 2007 - 2011, Intel Corporation. All rights reserved.<BR>
|
||||
# Copyright (c) 2007 - 2013, Intel Corporation. All rights reserved.<BR>
|
||||
# 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,9 +34,12 @@ import Common.GlobalData as GlobalData
|
||||
from GenFds.FdfParser import *
|
||||
from CommonDataClass.CommonClass import SkuInfoClass
|
||||
from Workspace.BuildClassObject import *
|
||||
from GenPatchPcdTable.GenPatchPcdTable import parsePcdInfoFromMapFile
|
||||
import Common.VpdInfoFile as VpdInfoFile
|
||||
from GenPcdDb import CreatePcdDatabaseCode
|
||||
from Workspace.MetaFileCommentParser import UsageList
|
||||
|
||||
## Regular expression for splitting Dependency Expression stirng into tokens
|
||||
## Regular expression for splitting Dependency Expression string into tokens
|
||||
gDepexTokenPattern = re.compile("(\(|\)|\w+| \S+\.inf)")
|
||||
|
||||
## Mapping Makefile type
|
||||
@ -59,13 +62,7 @@ gAutoGenDepexFileName = "%(module_name)s.depex"
|
||||
#
|
||||
# Template string to generic AsBuilt INF
|
||||
#
|
||||
gAsBuiltInfHeaderString = TemplateString("""## @file
|
||||
# ${module_name}
|
||||
#
|
||||
# DO NOT EDIT
|
||||
# FILE auto-generated Binary INF
|
||||
#
|
||||
##
|
||||
gAsBuiltInfHeaderString = TemplateString("""${header_comments}
|
||||
|
||||
[Defines]
|
||||
INF_VERSION = 0x00010016
|
||||
@ -73,6 +70,7 @@ gAsBuiltInfHeaderString = TemplateString("""## @file
|
||||
FILE_GUID = ${module_guid}
|
||||
MODULE_TYPE = ${module_module_type}
|
||||
VERSION_STRING = ${module_version_string}${BEGIN}
|
||||
PCD_IS_DRIVER = ${pcd_is_driver_string}${END}${BEGIN}
|
||||
UEFI_SPECIFICATION_VERSION = ${module_uefi_specification_version}${END}${BEGIN}
|
||||
PI_SPECIFICATION_VERSION = ${module_pi_specification_version}${END}
|
||||
|
||||
@ -82,8 +80,21 @@ gAsBuiltInfHeaderString = TemplateString("""## @file
|
||||
[Binaries.${module_arch}]${BEGIN}
|
||||
${binary_item}${END}
|
||||
|
||||
[PcdEx]${BEGIN}
|
||||
${pcd_item}${END}
|
||||
[PatchPcd.${module_arch}]${BEGIN}
|
||||
${patchablepcd_item}
|
||||
${END}
|
||||
[Protocols.${module_arch}]${BEGIN}
|
||||
${protocol_item}
|
||||
${END}
|
||||
[Ppis.${module_arch}]${BEGIN}
|
||||
${ppi_item}
|
||||
${END}
|
||||
[Guids.${module_arch}]${BEGIN}
|
||||
${guid_item}
|
||||
${END}
|
||||
[PcdEx.${module_arch}]${BEGIN}
|
||||
${pcd_item}
|
||||
${END}
|
||||
|
||||
## @AsBuilt${BEGIN}
|
||||
## ${flags_item}${END}
|
||||
@ -228,15 +239,6 @@ class WorkspaceAutoGen(AutoGen):
|
||||
ExtraData="Build target [%s] is not supported by the platform. [Valid target: %s]"
|
||||
% (self.BuildTarget, " ".join(self.Platform.BuildTargets)))
|
||||
|
||||
# Validate SKU ID
|
||||
if not self.SkuId:
|
||||
self.SkuId = 'DEFAULT'
|
||||
|
||||
if self.SkuId not in self.Platform.SkuIds:
|
||||
EdkLogger.error("build", PARAMETER_INVALID,
|
||||
ExtraData="SKU-ID [%s] is not supported by the platform. [Valid SKU-ID: %s]"
|
||||
% (self.SkuId, " ".join(self.Platform.SkuIds.keys())))
|
||||
|
||||
# parse FDF file to get PCDs in it, if any
|
||||
if not self.FdfFile:
|
||||
self.FdfFile = self.Platform.FlashDefinition
|
||||
@ -867,7 +869,7 @@ class PlatformAutoGen(AutoGen):
|
||||
|
||||
for PcdFromModule in M.ModulePcdList+M.LibraryPcdList:
|
||||
# make sure that the "VOID*" kind of datum has MaxDatumSize set
|
||||
if PcdFromModule.DatumType == "VOID*" and PcdFromModule.MaxDatumSize == None:
|
||||
if PcdFromModule.DatumType == "VOID*" and PcdFromModule.MaxDatumSize in [None, '']:
|
||||
NoDatumTypePcdList.add("%s.%s [%s]" % (PcdFromModule.TokenSpaceGuidCName, PcdFromModule.TokenCName, F))
|
||||
|
||||
if PcdFromModule.Type in GenC.gDynamicPcd or PcdFromModule.Type in GenC.gDynamicExPcd:
|
||||
@ -938,31 +940,19 @@ class PlatformAutoGen(AutoGen):
|
||||
# Add VPD type PCD into VpdFile and determine whether the VPD PCD need to be fixed up.
|
||||
#
|
||||
for PcdKey in PlatformPcds:
|
||||
Pcd = self.Platform.Pcds[PcdKey]
|
||||
if Pcd.Type in [TAB_PCDS_DYNAMIC_VPD, TAB_PCDS_DYNAMIC_EX_VPD]:
|
||||
Pcd = VpdPcdDict[PcdKey]
|
||||
Sku = Pcd.SkuInfoList[Pcd.SkuInfoList.keys()[0]]
|
||||
Sku.VpdOffset = Sku.VpdOffset.strip()
|
||||
#
|
||||
# Fix the optional data of VPD PCD.
|
||||
#
|
||||
if (Pcd.DatumType.strip() != "VOID*"):
|
||||
if Sku.DefaultValue == '':
|
||||
Pcd.SkuInfoList[Pcd.SkuInfoList.keys()[0]].DefaultValue = Pcd.MaxDatumSize
|
||||
Pcd.MaxDatumSize = None
|
||||
else:
|
||||
EdkLogger.error("build", AUTOGEN_ERROR, "PCD setting error",
|
||||
File=self.MetaFile,
|
||||
ExtraData="\n\tPCD: %s.%s format incorrect in DSC: %s\n\t\t\n"
|
||||
% (Pcd.TokenSpaceGuidCName, Pcd.TokenCName, self.Platform.MetaFile.Path))
|
||||
|
||||
VpdFile.Add(Pcd, Sku.VpdOffset)
|
||||
# if the offset of a VPD is *, then it need to be fixed up by third party tool.
|
||||
if not NeedProcessVpdMapFile and Sku.VpdOffset == "*":
|
||||
NeedProcessVpdMapFile = True
|
||||
if self.Platform.VpdToolGuid == None or self.Platform.VpdToolGuid == '':
|
||||
EdkLogger.error("Build", FILE_NOT_FOUND, \
|
||||
"Fail to find third-party BPDG tool to process VPD PCDs. BPDG Guid tool need to be defined in tools_def.txt and VPD_TOOL_GUID need to be provided in DSC file.")
|
||||
Pcd = self.Platform.Pcds[PcdKey]
|
||||
if Pcd.Type in [TAB_PCDS_DYNAMIC_VPD, TAB_PCDS_DYNAMIC_EX_VPD] and \
|
||||
PcdKey in VpdPcdDict:
|
||||
Pcd = VpdPcdDict[PcdKey]
|
||||
for (SkuName,Sku) in Pcd.SkuInfoList.items():
|
||||
Sku.VpdOffset = Sku.VpdOffset.strip()
|
||||
VpdFile.Add(Pcd, Sku.VpdOffset)
|
||||
# if the offset of a VPD is *, then it need to be fixed up by third party tool.
|
||||
if not NeedProcessVpdMapFile and Sku.VpdOffset == "*":
|
||||
NeedProcessVpdMapFile = True
|
||||
if self.Platform.VpdToolGuid == None or self.Platform.VpdToolGuid == '':
|
||||
EdkLogger.error("Build", FILE_NOT_FOUND, \
|
||||
"Fail to find third-party BPDG tool to process VPD PCDs. BPDG Guid tool need to be defined in tools_def.txt and VPD_TOOL_GUID need to be provided in DSC file.")
|
||||
|
||||
|
||||
#
|
||||
@ -983,32 +973,46 @@ class PlatformAutoGen(AutoGen):
|
||||
# Not found, it should be signature
|
||||
if not FoundFlag :
|
||||
# just pick the a value to determine whether is unicode string type
|
||||
Sku = DscPcdEntry.SkuInfoList[DscPcdEntry.SkuInfoList.keys()[0]]
|
||||
Sku.VpdOffset = Sku.VpdOffset.strip()
|
||||
|
||||
# Need to iterate DEC pcd information to get the value & datumtype
|
||||
for eachDec in self.PackageList:
|
||||
for DecPcd in eachDec.Pcds:
|
||||
DecPcdEntry = eachDec.Pcds[DecPcd]
|
||||
if (DecPcdEntry.TokenSpaceGuidCName == DscPcdEntry.TokenSpaceGuidCName) and \
|
||||
(DecPcdEntry.TokenCName == DscPcdEntry.TokenCName):
|
||||
# Print warning message to let the developer make a determine.
|
||||
EdkLogger.warn("build", "Unreferenced vpd pcd used!",
|
||||
File=self.MetaFile, \
|
||||
ExtraData = "PCD: %s.%s used in the DSC file %s is unreferenced." \
|
||||
%(DscPcdEntry.TokenSpaceGuidCName, DscPcdEntry.TokenCName, self.Platform.MetaFile.Path))
|
||||
|
||||
DscPcdEntry.DatumType = DecPcdEntry.DatumType
|
||||
DscPcdEntry.DefaultValue = DecPcdEntry.DefaultValue
|
||||
# Only fix the value while no value provided in DSC file.
|
||||
if (Sku.DefaultValue == "" or Sku.DefaultValue==None):
|
||||
DscPcdEntry.SkuInfoList[DscPcdEntry.SkuInfoList.keys()[0]].DefaultValue = DecPcdEntry.DefaultValue
|
||||
|
||||
for (SkuName,Sku) in DscPcdEntry.SkuInfoList.items():
|
||||
Sku.VpdOffset = Sku.VpdOffset.strip()
|
||||
|
||||
# Need to iterate DEC pcd information to get the value & datumtype
|
||||
for eachDec in self.PackageList:
|
||||
for DecPcd in eachDec.Pcds:
|
||||
DecPcdEntry = eachDec.Pcds[DecPcd]
|
||||
if (DecPcdEntry.TokenSpaceGuidCName == DscPcdEntry.TokenSpaceGuidCName) and \
|
||||
(DecPcdEntry.TokenCName == DscPcdEntry.TokenCName):
|
||||
# Print warning message to let the developer make a determine.
|
||||
EdkLogger.warn("build", "Unreferenced vpd pcd used!",
|
||||
File=self.MetaFile, \
|
||||
ExtraData = "PCD: %s.%s used in the DSC file %s is unreferenced." \
|
||||
%(DscPcdEntry.TokenSpaceGuidCName, DscPcdEntry.TokenCName, self.Platform.MetaFile.Path))
|
||||
|
||||
DscPcdEntry.DatumType = DecPcdEntry.DatumType
|
||||
DscPcdEntry.DefaultValue = DecPcdEntry.DefaultValue
|
||||
DscPcdEntry.TokenValue = DecPcdEntry.TokenValue
|
||||
DscPcdEntry.TokenSpaceGuidValue = eachDec.Guids[DecPcdEntry.TokenSpaceGuidCName]
|
||||
# Only fix the value while no value provided in DSC file.
|
||||
if (Sku.DefaultValue == "" or Sku.DefaultValue==None):
|
||||
DscPcdEntry.SkuInfoList[DscPcdEntry.SkuInfoList.keys()[0]].DefaultValue = DecPcdEntry.DefaultValue
|
||||
|
||||
if DscPcdEntry not in self._DynamicPcdList:
|
||||
self._DynamicPcdList.append(DscPcdEntry)
|
||||
# Sku = DscPcdEntry.SkuInfoList[DscPcdEntry.SkuInfoList.keys()[0]]
|
||||
Sku.VpdOffset = Sku.VpdOffset.strip()
|
||||
PcdValue = Sku.DefaultValue
|
||||
VpdFile.Add(DscPcdEntry, Sku.VpdOffset)
|
||||
if not NeedProcessVpdMapFile and Sku.VpdOffset == "*":
|
||||
NeedProcessVpdMapFile = True
|
||||
if DscPcdEntry.DatumType == 'VOID*' and PcdValue.startswith("L"):
|
||||
UnicodePcdArray.append(DscPcdEntry)
|
||||
elif len(Sku.VariableName) > 0:
|
||||
HiiPcdArray.append(DscPcdEntry)
|
||||
else:
|
||||
OtherPcdArray.append(DscPcdEntry)
|
||||
|
||||
# if the offset of a VPD is *, then it need to be fixed up by third party tool.
|
||||
|
||||
VpdFile.Add(DscPcdEntry, Sku.VpdOffset)
|
||||
# if the offset of a VPD is *, then it need to be fixed up by third party tool.
|
||||
if not NeedProcessVpdMapFile and Sku.VpdOffset == "*":
|
||||
NeedProcessVpdMapFile = True
|
||||
|
||||
|
||||
if (self.Platform.FlashDefinition == None or self.Platform.FlashDefinition == '') and \
|
||||
@ -1055,9 +1059,11 @@ class PlatformAutoGen(AutoGen):
|
||||
# Fixup "*" offset
|
||||
for Pcd in self._DynamicPcdList:
|
||||
# just pick the a value to determine whether is unicode string type
|
||||
Sku = Pcd.SkuInfoList[Pcd.SkuInfoList.keys()[0]]
|
||||
if Sku.VpdOffset == "*":
|
||||
Sku.VpdOffset = VpdFile.GetOffset(Pcd)[0].strip()
|
||||
i = 0
|
||||
for (SkuName,Sku) in Pcd.SkuInfoList.items():
|
||||
if Sku.VpdOffset == "*":
|
||||
Sku.VpdOffset = VpdFile.GetOffset(Pcd)[i].strip()
|
||||
i += 1
|
||||
else:
|
||||
EdkLogger.error("build", FILE_READ_FAILURE, "Can not find VPD map file %s to fix up VPD offset." % VpdMapFilePath)
|
||||
|
||||
@ -1605,13 +1611,13 @@ class PlatformAutoGen(AutoGen):
|
||||
% (ToPcd.TokenSpaceGuidCName, ToPcd.TokenCName))
|
||||
Value = ToPcd.DefaultValue
|
||||
if Value in [None, '']:
|
||||
ToPcd.MaxDatumSize = 1
|
||||
ToPcd.MaxDatumSize = '1'
|
||||
elif Value[0] == 'L':
|
||||
ToPcd.MaxDatumSize = str(len(Value) * 2)
|
||||
ToPcd.MaxDatumSize = str((len(Value) - 2) * 2)
|
||||
elif Value[0] == '{':
|
||||
ToPcd.MaxDatumSize = str(len(Value.split(',')))
|
||||
else:
|
||||
ToPcd.MaxDatumSize = str(len(Value))
|
||||
ToPcd.MaxDatumSize = str(len(Value) - 1)
|
||||
|
||||
# apply default SKU for dynamic PCDS if specified one is not available
|
||||
if (ToPcd.Type in PCD_DYNAMIC_TYPE_LIST or ToPcd.Type in PCD_DYNAMIC_EX_TYPE_LIST) \
|
||||
@ -2004,9 +2010,14 @@ class ModuleAutoGen(AutoGen):
|
||||
self._DerivedPackageList = None
|
||||
self._ModulePcdList = None
|
||||
self._LibraryPcdList = None
|
||||
self._PcdComments = sdict()
|
||||
self._GuidList = None
|
||||
self._GuidsUsedByPcd = None
|
||||
self._GuidComments = sdict()
|
||||
self._ProtocolList = None
|
||||
self._ProtocolComments = sdict()
|
||||
self._PpiList = None
|
||||
self._PpiComments = sdict()
|
||||
self._DepexList = None
|
||||
self._DepexExpressionList = None
|
||||
self._BuildOption = None
|
||||
@ -2107,6 +2118,10 @@ class ModuleAutoGen(AutoGen):
|
||||
self._LibraryFlag = False
|
||||
return self._LibraryFlag
|
||||
|
||||
## Check if the module is binary module or not
|
||||
def _IsBinaryModule(self):
|
||||
return self.Module.IsBinaryModule
|
||||
|
||||
## Return the directory to store intermediate files of the module
|
||||
def _GetBuildDir(self):
|
||||
if self._BuildDir == None:
|
||||
@ -2563,6 +2578,12 @@ class ModuleAutoGen(AutoGen):
|
||||
self._DependentLibraryList = self.PlatformInfo.ApplyLibraryInstance(self.Module)
|
||||
return self._DependentLibraryList
|
||||
|
||||
@staticmethod
|
||||
def UpdateComments(Recver, Src):
|
||||
for Key in Src:
|
||||
if Key not in Recver:
|
||||
Recver[Key] = []
|
||||
Recver[Key].extend(Src[Key])
|
||||
## Get the list of PCDs from current module
|
||||
#
|
||||
# @retval list The list of PCD
|
||||
@ -2571,6 +2592,7 @@ class ModuleAutoGen(AutoGen):
|
||||
if self._ModulePcdList == None:
|
||||
# apply PCD settings from platform
|
||||
self._ModulePcdList = self.PlatformInfo.ApplyPcdSetting(self.Module, self.Module.Pcds)
|
||||
self.UpdateComments(self._PcdComments, self.Module.PcdComments)
|
||||
return self._ModulePcdList
|
||||
|
||||
## Get the list of PCDs from dependent libraries
|
||||
@ -2583,6 +2605,7 @@ class ModuleAutoGen(AutoGen):
|
||||
if not self.IsLibrary:
|
||||
# get PCDs from dependent libraries
|
||||
for Library in self.DependentLibraryList:
|
||||
self.UpdateComments(self._PcdComments, Library.PcdComments)
|
||||
for Key in Library.Pcds:
|
||||
# skip duplicated PCDs
|
||||
if Key in self.Module.Pcds or Key in Pcds:
|
||||
@ -2603,8 +2626,17 @@ class ModuleAutoGen(AutoGen):
|
||||
self._GuidList = self.Module.Guids
|
||||
for Library in self.DependentLibraryList:
|
||||
self._GuidList.update(Library.Guids)
|
||||
self.UpdateComments(self._GuidComments, Library.GuidComments)
|
||||
self.UpdateComments(self._GuidComments, self.Module.GuidComments)
|
||||
return self._GuidList
|
||||
|
||||
def GetGuidsUsedByPcd(self):
|
||||
if self._GuidsUsedByPcd == None:
|
||||
self._GuidsUsedByPcd = sdict()
|
||||
self._GuidsUsedByPcd.update(self.Module.GetGuidsUsedByPcd())
|
||||
for Library in self.DependentLibraryList:
|
||||
self._GuidsUsedByPcd.update(Library.GetGuidsUsedByPcd())
|
||||
return self._GuidsUsedByPcd
|
||||
## Get the protocol value mapping
|
||||
#
|
||||
# @retval dict The mapping between protocol cname and its value
|
||||
@ -2614,6 +2646,8 @@ class ModuleAutoGen(AutoGen):
|
||||
self._ProtocolList = self.Module.Protocols
|
||||
for Library in self.DependentLibraryList:
|
||||
self._ProtocolList.update(Library.Protocols)
|
||||
self.UpdateComments(self._ProtocolComments, Library.ProtocolComments)
|
||||
self.UpdateComments(self._ProtocolComments, self.Module.ProtocolComments)
|
||||
return self._ProtocolList
|
||||
|
||||
## Get the PPI value mapping
|
||||
@ -2625,6 +2659,8 @@ class ModuleAutoGen(AutoGen):
|
||||
self._PpiList = self.Module.Ppis
|
||||
for Library in self.DependentLibraryList:
|
||||
self._PpiList.update(Library.Ppis)
|
||||
self.UpdateComments(self._PpiComments, Library.PpiComments)
|
||||
self.UpdateComments(self._PpiComments, self.Module.PpiComments)
|
||||
return self._PpiList
|
||||
|
||||
## Get the list of include search path
|
||||
@ -2681,38 +2717,74 @@ class ModuleAutoGen(AutoGen):
|
||||
|
||||
### TODO: How to handles mixed source and binary modules
|
||||
|
||||
# Find all DynamicEx PCDs used by this module and dependent libraries
|
||||
# Find all DynamicEx and PatchableInModule PCDs used by this module and dependent libraries
|
||||
# Also find all packages that the DynamicEx PCDs depend on
|
||||
Pcds = []
|
||||
PatchablePcds = {}
|
||||
Packages = []
|
||||
PcdCheckList = []
|
||||
PcdTokenSpaceList = []
|
||||
for Pcd in self.ModulePcdList + self.LibraryPcdList:
|
||||
if Pcd.Type in GenC.gDynamicExPcd:
|
||||
if Pcd not in Pcds:
|
||||
Pcds += [Pcd]
|
||||
for Package in self.DerivedPackageList:
|
||||
if Package not in Packages:
|
||||
if (Pcd.TokenCName, Pcd.TokenSpaceGuidCName, 'DynamicEx') in Package.Pcds:
|
||||
Packages += [Package]
|
||||
elif (Pcd.TokenCName, Pcd.TokenSpaceGuidCName, 'Dynamic') in Package.Pcds:
|
||||
Packages += [Package]
|
||||
if Pcd.Type == TAB_PCDS_PATCHABLE_IN_MODULE:
|
||||
PatchablePcds[Pcd.TokenCName] = Pcd
|
||||
PcdCheckList.append((Pcd.TokenCName, Pcd.TokenSpaceGuidCName, 'PatchableInModule'))
|
||||
elif Pcd.Type in GenC.gDynamicExPcd:
|
||||
if Pcd not in Pcds:
|
||||
Pcds += [Pcd]
|
||||
PcdCheckList.append((Pcd.TokenCName, Pcd.TokenSpaceGuidCName, 'DynamicEx'))
|
||||
PcdCheckList.append((Pcd.TokenCName, Pcd.TokenSpaceGuidCName, 'Dynamic'))
|
||||
PcdTokenSpaceList.append(Pcd.TokenSpaceGuidCName)
|
||||
GuidList = sdict()
|
||||
GuidList.update(self.GuidList)
|
||||
for TokenSpace in self.GetGuidsUsedByPcd():
|
||||
# If token space is not referred by patch PCD or Ex PCD, remove the GUID from GUID list
|
||||
# The GUIDs in GUIDs section should really be the GUIDs in source INF or referred by Ex an patch PCDs
|
||||
if TokenSpace not in PcdTokenSpaceList and TokenSpace in GuidList:
|
||||
GuidList.pop(TokenSpace)
|
||||
CheckList = (GuidList, self.PpiList, self.ProtocolList, PcdCheckList)
|
||||
for Package in self.DerivedPackageList:
|
||||
if Package in Packages:
|
||||
continue
|
||||
BeChecked = (Package.Guids, Package.Ppis, Package.Protocols, Package.Pcds)
|
||||
Found = False
|
||||
for Index in range(len(BeChecked)):
|
||||
for Item in CheckList[Index]:
|
||||
if Item in BeChecked[Index]:
|
||||
Packages += [Package]
|
||||
Found = True
|
||||
break
|
||||
if Found: break
|
||||
|
||||
ModuleType = self.ModuleType
|
||||
if ModuleType == 'UEFI_DRIVER' and self.DepexGenerated:
|
||||
ModuleType = 'DXE_DRIVER'
|
||||
ModuleType = 'DXE_DRIVER'
|
||||
|
||||
DriverType = ''
|
||||
if self.PcdIsDriver != '':
|
||||
DriverType = self.PcdIsDriver
|
||||
|
||||
AsBuiltInfDict = {
|
||||
'module_name' : self.Name,
|
||||
'module_guid' : self.Guid,
|
||||
'module_module_type' : ModuleType,
|
||||
'module_version_string' : self.Version,
|
||||
'pcd_is_driver_string' : [],
|
||||
'module_uefi_specification_version' : [],
|
||||
'module_pi_specification_version' : [],
|
||||
'module_arch' : self.Arch,
|
||||
'package_item' : ['%s' % (Package.MetaFile.File.replace('\\','/')) for Package in Packages],
|
||||
'binary_item' : [],
|
||||
'patchablepcd_item' : [],
|
||||
'pcd_item' : [],
|
||||
'flags_item' : []
|
||||
'protocol_item' : [],
|
||||
'ppi_item' : [],
|
||||
'guid_item' : [],
|
||||
'flags_item' : [],
|
||||
'libraryclasses_item' : []
|
||||
}
|
||||
AsBuiltInfDict['module_inf_version'] = '0x%08x' % self.AutoGenVersion
|
||||
if DriverType:
|
||||
AsBuiltInfDict['pcd_is_driver_string'] += [DriverType]
|
||||
|
||||
if 'UEFI_SPECIFICATION_VERSION' in self.Specification:
|
||||
AsBuiltInfDict['module_uefi_specification_version'] += [self.Specification['UEFI_SPECIFICATION_VERSION']]
|
||||
@ -2744,9 +2816,125 @@ class ModuleAutoGen(AutoGen):
|
||||
if self.ModuleType in ['DXE_SMM_DRIVER']:
|
||||
AsBuiltInfDict['binary_item'] += ['SMM_DEPEX|' + self.Name + '.depex']
|
||||
|
||||
for Root, Dirs, Files in os.walk(OutputDir):
|
||||
for File in Files:
|
||||
if File.lower().endswith('.pdb'):
|
||||
AsBuiltInfDict['binary_item'] += ['DISPOSABLE|' + File]
|
||||
HeaderComments = self.Module.HeaderComments
|
||||
StartPos = 0
|
||||
for Index in range(len(HeaderComments)):
|
||||
if HeaderComments[Index].find('@BinaryHeader') != -1:
|
||||
HeaderComments[Index] = HeaderComments[Index].replace('@BinaryHeader', '@file')
|
||||
StartPos = Index
|
||||
break
|
||||
AsBuiltInfDict['header_comments'] = '\n'.join(HeaderComments[StartPos:]).replace(':#', '://')
|
||||
GenList = [
|
||||
(self.ProtocolList, self._ProtocolComments, 'protocol_item'),
|
||||
(self.PpiList, self._PpiComments, 'ppi_item'),
|
||||
(GuidList, self._GuidComments, 'guid_item')
|
||||
]
|
||||
for Item in GenList:
|
||||
for CName in Item[0]:
|
||||
Comments = ''
|
||||
if CName in Item[1]:
|
||||
Comments = '\n '.join(Item[1][CName])
|
||||
Entry = CName
|
||||
if Comments:
|
||||
Entry = Comments + '\n ' + CName
|
||||
AsBuiltInfDict[Item[2]].append(Entry)
|
||||
PatchList = parsePcdInfoFromMapFile(
|
||||
os.path.join(self.OutputDir, self.Name + '.map'),
|
||||
os.path.join(self.OutputDir, self.Name + '.efi')
|
||||
)
|
||||
if PatchList:
|
||||
for PatchPcd in PatchList:
|
||||
if PatchPcd[0] not in PatchablePcds:
|
||||
continue
|
||||
Pcd = PatchablePcds[PatchPcd[0]]
|
||||
PcdValue = ''
|
||||
if Pcd.DatumType != 'VOID*':
|
||||
HexFormat = '0x%02x'
|
||||
if Pcd.DatumType == 'UINT16':
|
||||
HexFormat = '0x%04x'
|
||||
elif Pcd.DatumType == 'UINT32':
|
||||
HexFormat = '0x%08x'
|
||||
elif Pcd.DatumType == 'UINT64':
|
||||
HexFormat = '0x%016x'
|
||||
PcdValue = HexFormat % int(Pcd.DefaultValue, 0)
|
||||
else:
|
||||
if Pcd.MaxDatumSize == None or Pcd.MaxDatumSize == '':
|
||||
EdkLogger.error("build", AUTOGEN_ERROR,
|
||||
"Unknown [MaxDatumSize] of PCD [%s.%s]" % (Pcd.TokenSpaceGuidCName, Pcd.TokenCName)
|
||||
)
|
||||
ArraySize = int(Pcd.MaxDatumSize, 0)
|
||||
PcdValue = Pcd.DefaultValue
|
||||
if PcdValue[0] != '{':
|
||||
Unicode = False
|
||||
if PcdValue[0] == 'L':
|
||||
Unicode = True
|
||||
PcdValue = PcdValue.lstrip('L')
|
||||
PcdValue = eval(PcdValue)
|
||||
NewValue = '{'
|
||||
for Index in range(0, len(PcdValue)):
|
||||
if Unicode:
|
||||
CharVal = ord(PcdValue[Index])
|
||||
NewValue = NewValue + '0x%02x' % (CharVal & 0x00FF) + ', ' \
|
||||
+ '0x%02x' % (CharVal >> 8) + ', '
|
||||
else:
|
||||
NewValue = NewValue + '0x%02x' % (ord(PcdValue[Index]) % 0x100) + ', '
|
||||
Padding = '0x00, '
|
||||
if Unicode:
|
||||
Padding = Padding * 2
|
||||
ArraySize = ArraySize / 2
|
||||
if ArraySize < (len(PcdValue) + 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)
|
||||
)
|
||||
if ArraySize > len(PcdValue) + 1:
|
||||
NewValue = NewValue + Padding * (ArraySize - len(PcdValue) - 1)
|
||||
PcdValue = NewValue + Padding.strip().rstrip(',') + '}'
|
||||
elif len(PcdValue.split(',')) <= ArraySize:
|
||||
PcdValue = PcdValue.rstrip('}') + ', 0x00' * (ArraySize - len(PcdValue.split(',')))
|
||||
PcdValue += '}'
|
||||
else:
|
||||
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)
|
||||
)
|
||||
PcdItem = '%s.%s|%s|0x%X' % \
|
||||
(Pcd.TokenSpaceGuidCName, Pcd.TokenCName, PcdValue, PatchPcd[1])
|
||||
PcdComments = ''
|
||||
if (Pcd.TokenSpaceGuidCName, Pcd.TokenCName) in self._PcdComments:
|
||||
PcdComments = '\n '.join(self._PcdComments[Pcd.TokenSpaceGuidCName, Pcd.TokenCName])
|
||||
if PcdComments:
|
||||
PcdItem = PcdComments + '\n ' + PcdItem
|
||||
AsBuiltInfDict['patchablepcd_item'].append(PcdItem)
|
||||
for Pcd in Pcds:
|
||||
AsBuiltInfDict['pcd_item'] += [Pcd.TokenSpaceGuidCName + '.' + Pcd.TokenCName]
|
||||
|
||||
PcdComments = ''
|
||||
PcdCommentList = []
|
||||
HiiInfo = ''
|
||||
if Pcd.Type == TAB_PCDS_DYNAMIC_EX_HII:
|
||||
for SkuName in Pcd.SkuInfoList:
|
||||
SkuInfo = Pcd.SkuInfoList[SkuName]
|
||||
HiiInfo = '## %s|%s|%s' % (SkuInfo.VariableName, SkuInfo.VariableGuid, SkuInfo.VariableOffset)
|
||||
break
|
||||
if (Pcd.TokenSpaceGuidCName, Pcd.TokenCName) in self._PcdComments:
|
||||
PcdCommentList = self._PcdComments[Pcd.TokenSpaceGuidCName, Pcd.TokenCName][:]
|
||||
if HiiInfo:
|
||||
UsageIndex = -1
|
||||
for Index, Comment in enumerate(PcdCommentList):
|
||||
for Usage in UsageList:
|
||||
if Comment.find(Usage) != -1:
|
||||
UsageIndex = Index
|
||||
break
|
||||
if UsageIndex != -1:
|
||||
PcdCommentList[UsageIndex] = PcdCommentList[UsageIndex] + ' ' + HiiInfo
|
||||
else:
|
||||
PcdCommentList.append('## ' + HiiInfo)
|
||||
PcdComments = '\n '.join(PcdCommentList)
|
||||
PcdEntry = Pcd.TokenSpaceGuidCName + '.' + Pcd.TokenCName
|
||||
if PcdComments:
|
||||
PcdEntry = PcdComments + '\n ' + PcdEntry
|
||||
AsBuiltInfDict['pcd_item'] += [PcdEntry]
|
||||
for Item in self.BuildOption:
|
||||
if 'FLAGS' in self.BuildOption[Item]:
|
||||
AsBuiltInfDict['flags_item'] += ['%s:%s_%s_%s_%s_FLAGS = %s' % (self.ToolChainFamily, self.BuildTarget, self.ToolChain, self.Arch, Item, self.BuildOption[Item]['FLAGS'].strip())]
|
||||
@ -2793,6 +2981,11 @@ class ModuleAutoGen(AutoGen):
|
||||
if self.IsCodeFileCreated:
|
||||
return
|
||||
|
||||
# Need to generate PcdDatabase even PcdDriver is binarymodule
|
||||
if self.IsBinaryModule and self.PcdIsDriver != '':
|
||||
CreatePcdDatabaseCode(self, TemplateString(), TemplateString())
|
||||
return
|
||||
|
||||
if not self.IsLibrary and CreateLibraryCodeFile:
|
||||
for LibraryAutoGen in self.LibraryAutoGenList:
|
||||
LibraryAutoGen.CreateCodeFile()
|
||||
@ -2875,7 +3068,7 @@ class ModuleAutoGen(AutoGen):
|
||||
Specification = property(_GetSpecification)
|
||||
|
||||
IsLibrary = property(_IsLibrary)
|
||||
|
||||
IsBinaryModule = property(_IsBinaryModule)
|
||||
BuildDir = property(_GetBuildDir)
|
||||
OutputDir = property(_GetOutputDir)
|
||||
DebugDir = property(_GetDebugDir)
|
||||
|
@ -1,7 +1,7 @@
|
||||
## @file
|
||||
# Routines for generating AutoGen.h and AutoGen.c
|
||||
#
|
||||
# Copyright (c) 2007 - 2012, Intel Corporation. All rights reserved.<BR>
|
||||
# Copyright (c) 2007 - 2013, Intel Corporation. All rights reserved.<BR>
|
||||
# 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,6 +22,7 @@ from Common.DataType import *
|
||||
from Common.Misc import *
|
||||
from Common.String import StringToArray
|
||||
from StrGather import *
|
||||
from GenPcdDb import CreatePcdDatabaseCode
|
||||
|
||||
## PCD type string
|
||||
gItemTypeStringDatabase = {
|
||||
@ -49,252 +50,6 @@ gDatumSizeStringDatabase = {'UINT8':'8','UINT16':'16','UINT32':'32','UINT64':'64
|
||||
gDatumSizeStringDatabaseH = {'UINT8':'8','UINT16':'16','UINT32':'32','UINT64':'64','BOOLEAN':'BOOL','VOID*':'PTR'}
|
||||
gDatumSizeStringDatabaseLib = {'UINT8':'8','UINT16':'16','UINT32':'32','UINT64':'64','BOOLEAN':'Bool','VOID*':'Ptr'}
|
||||
|
||||
## Mapping between PCD driver type and EFI phase
|
||||
gPcdPhaseMap = {
|
||||
"PEI_PCD_DRIVER" : "PEI",
|
||||
"DXE_PCD_DRIVER" : "DXE"
|
||||
}
|
||||
|
||||
gPcdDatabaseCommonAutoGenH = """
|
||||
//
|
||||
// The following definition will be generated by build tool
|
||||
//
|
||||
|
||||
//
|
||||
// Common definitions
|
||||
//
|
||||
typedef UINT8 SKU_ID;
|
||||
|
||||
#define PCD_TYPE_SHIFT 28
|
||||
|
||||
#define PCD_TYPE_DATA (0x0U << PCD_TYPE_SHIFT)
|
||||
#define PCD_TYPE_HII (0x8U << PCD_TYPE_SHIFT)
|
||||
#define PCD_TYPE_VPD (0x4U << PCD_TYPE_SHIFT)
|
||||
#define PCD_TYPE_SKU_ENABLED (0x2U << PCD_TYPE_SHIFT)
|
||||
#define PCD_TYPE_STRING (0x1U << PCD_TYPE_SHIFT)
|
||||
|
||||
#define PCD_TYPE_ALL_SET (PCD_TYPE_DATA | PCD_TYPE_HII | PCD_TYPE_VPD | PCD_TYPE_SKU_ENABLED | PCD_TYPE_STRING)
|
||||
|
||||
#define PCD_DATUM_TYPE_SHIFT 24
|
||||
|
||||
#define PCD_DATUM_TYPE_POINTER (0x0U << PCD_DATUM_TYPE_SHIFT)
|
||||
#define PCD_DATUM_TYPE_UINT8 (0x1U << PCD_DATUM_TYPE_SHIFT)
|
||||
#define PCD_DATUM_TYPE_UINT16 (0x2U << PCD_DATUM_TYPE_SHIFT)
|
||||
#define PCD_DATUM_TYPE_UINT32 (0x4U << PCD_DATUM_TYPE_SHIFT)
|
||||
#define PCD_DATUM_TYPE_UINT64 (0x8U << PCD_DATUM_TYPE_SHIFT)
|
||||
|
||||
#define PCD_DATUM_TYPE_ALL_SET (PCD_DATUM_TYPE_POINTER | \\
|
||||
PCD_DATUM_TYPE_UINT8 | \\
|
||||
PCD_DATUM_TYPE_UINT16 | \\
|
||||
PCD_DATUM_TYPE_UINT32 | \\
|
||||
PCD_DATUM_TYPE_UINT64)
|
||||
|
||||
#define PCD_DATABASE_OFFSET_MASK (~(PCD_TYPE_ALL_SET | PCD_DATUM_TYPE_ALL_SET))
|
||||
|
||||
typedef struct {
|
||||
UINT32 ExTokenNumber;
|
||||
UINT16 LocalTokenNumber; // PCD Number of this particular platform build
|
||||
UINT16 ExGuidIndex; // Index of GuidTable
|
||||
} DYNAMICEX_MAPPING;
|
||||
|
||||
typedef struct {
|
||||
UINT32 SkuDataStartOffset; //We have to use offsetof MACRO as we don't know padding done by compiler
|
||||
UINT32 SkuIdTableOffset; //Offset from the PCD_DB
|
||||
} SKU_HEAD;
|
||||
|
||||
typedef struct {
|
||||
UINT32 StringIndex; // Offset in String Table in units of UINT32.
|
||||
UINT32 DefaultValueOffset; // Offset of the Default Value
|
||||
UINT16 GuidTableIndex; // Offset in Guid Table in units of GUID.
|
||||
UINT16 Offset; // Offset in Variable
|
||||
} VARIABLE_HEAD;
|
||||
|
||||
typedef struct {
|
||||
UINT32 Offset;
|
||||
} VPD_HEAD;
|
||||
|
||||
typedef UINT32 STRING_HEAD;
|
||||
|
||||
typedef UINT16 SIZE_INFO;
|
||||
|
||||
#define offsetof(s,m) (UINT32) (UINTN) &(((s *)0)->m)
|
||||
|
||||
"""
|
||||
|
||||
gPcdDatabaseEpilogueAutoGenH = """
|
||||
typedef struct {
|
||||
PEI_PCD_DATABASE PeiDb;
|
||||
DXE_PCD_DATABASE DxeDb;
|
||||
} PCD_DATABASE;
|
||||
|
||||
#define PCD_TOTAL_TOKEN_NUMBER (PEI_LOCAL_TOKEN_NUMBER + DXE_LOCAL_TOKEN_NUMBER)
|
||||
|
||||
"""
|
||||
|
||||
gPcdDatabaseAutoGenH = TemplateString("""
|
||||
#define ${PHASE}_GUID_TABLE_SIZE ${GUID_TABLE_SIZE}
|
||||
#define ${PHASE}_STRING_TABLE_SIZE ${STRING_TABLE_SIZE}
|
||||
#define ${PHASE}_SKUID_TABLE_SIZE ${SKUID_TABLE_SIZE}
|
||||
#define ${PHASE}_LOCAL_TOKEN_NUMBER_TABLE_SIZE ${LOCAL_TOKEN_NUMBER_TABLE_SIZE}
|
||||
#define ${PHASE}_LOCAL_TOKEN_NUMBER ${LOCAL_TOKEN_NUMBER}
|
||||
#define ${PHASE}_EXMAPPING_TABLE_SIZE ${EXMAPPING_TABLE_SIZE}
|
||||
#define ${PHASE}_EX_TOKEN_NUMBER ${EX_TOKEN_NUMBER}
|
||||
#define ${PHASE}_SIZE_TABLE_SIZE ${SIZE_TABLE_SIZE}
|
||||
#define ${PHASE}_GUID_TABLE_EMPTY ${GUID_TABLE_EMPTY}
|
||||
#define ${PHASE}_STRING_TABLE_EMPTY ${STRING_TABLE_EMPTY}
|
||||
#define ${PHASE}_SKUID_TABLE_EMPTY ${SKUID_TABLE_EMPTY}
|
||||
#define ${PHASE}_DATABASE_EMPTY ${DATABASE_EMPTY}
|
||||
#define ${PHASE}_EXMAP_TABLE_EMPTY ${EXMAP_TABLE_EMPTY}
|
||||
|
||||
typedef struct {
|
||||
${BEGIN} UINT64 ${INIT_CNAME_DECL_UINT64}_${INIT_GUID_DECL_UINT64}[${INIT_NUMSKUS_DECL_UINT64}];
|
||||
${END}
|
||||
${BEGIN} UINT64 ${VARDEF_CNAME_UINT64}_${VARDEF_GUID_UINT64}_VariableDefault_${VARDEF_SKUID_UINT64};
|
||||
${END}
|
||||
${BEGIN} UINT32 ${INIT_CNAME_DECL_UINT32}_${INIT_GUID_DECL_UINT32}[${INIT_NUMSKUS_DECL_UINT32}];
|
||||
${END}
|
||||
${BEGIN} UINT32 ${VARDEF_CNAME_UINT32}_${VARDEF_GUID_UINT32}_VariableDefault_${VARDEF_SKUID_UINT32};
|
||||
${END}
|
||||
${BEGIN} VPD_HEAD ${VPD_HEAD_CNAME_DECL}_${VPD_HEAD_GUID_DECL}[${VPD_HEAD_NUMSKUS_DECL}];
|
||||
${END}
|
||||
DYNAMICEX_MAPPING ExMapTable[${PHASE}_EXMAPPING_TABLE_SIZE];
|
||||
UINT32 LocalTokenNumberTable[${PHASE}_LOCAL_TOKEN_NUMBER_TABLE_SIZE];
|
||||
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_Header[${VARIABLE_HEAD_NUMSKUS_DECL}];
|
||||
${END}
|
||||
${BEGIN} UINT8 StringTable${STRING_TABLE_INDEX}[${STRING_TABLE_LENGTH}]; /* ${STRING_TABLE_CNAME}_${STRING_TABLE_GUID} */
|
||||
${END}
|
||||
SIZE_INFO SizeTable[${PHASE}_SIZE_TABLE_SIZE];
|
||||
${BEGIN} UINT16 ${INIT_CNAME_DECL_UINT16}_${INIT_GUID_DECL_UINT16}[${INIT_NUMSKUS_DECL_UINT16}];
|
||||
${END}
|
||||
${BEGIN} UINT16 ${VARDEF_CNAME_UINT16}_${VARDEF_GUID_UINT16}_VariableDefault_${VARDEF_SKUID_UINT16};
|
||||
${END}
|
||||
${BEGIN} UINT8 ${INIT_CNAME_DECL_UINT8}_${INIT_GUID_DECL_UINT8}[${INIT_NUMSKUS_DECL_UINT8}];
|
||||
${END}
|
||||
${BEGIN} UINT8 ${VARDEF_CNAME_UINT8}_${VARDEF_GUID_UINT8}_VariableDefault_${VARDEF_SKUID_UINT8};
|
||||
${END}
|
||||
${BEGIN} BOOLEAN ${INIT_CNAME_DECL_BOOLEAN}_${INIT_GUID_DECL_BOOLEAN}[${INIT_NUMSKUS_DECL_BOOLEAN}];
|
||||
${END}
|
||||
${BEGIN} BOOLEAN ${VARDEF_CNAME_BOOLEAN}_${VARDEF_GUID_BOOLEAN}_VariableDefault_${VARDEF_SKUID_BOOLEAN};
|
||||
${END}
|
||||
UINT8 SkuIdTable[${PHASE}_SKUID_TABLE_SIZE];
|
||||
${SYSTEM_SKU_ID}
|
||||
} ${PHASE}_PCD_DATABASE_INIT;
|
||||
|
||||
typedef struct {
|
||||
${PCD_DATABASE_UNINIT_EMPTY}
|
||||
${BEGIN} UINT64 ${UNINIT_CNAME_DECL_UINT64}_${UNINIT_GUID_DECL_UINT64}[${UNINIT_NUMSKUS_DECL_UINT64}];
|
||||
${END}
|
||||
${BEGIN} UINT32 ${UNINIT_CNAME_DECL_UINT32}_${UNINIT_GUID_DECL_UINT32}[${UNINIT_NUMSKUS_DECL_UINT32}];
|
||||
${END}
|
||||
${BEGIN} UINT16 ${UNINIT_CNAME_DECL_UINT16}_${UNINIT_GUID_DECL_UINT16}[${UNINIT_NUMSKUS_DECL_UINT16}];
|
||||
${END}
|
||||
${BEGIN} UINT8 ${UNINIT_CNAME_DECL_UINT8}_${UNINIT_GUID_DECL_UINT8}[${UNINIT_NUMSKUS_DECL_UINT8}];
|
||||
${END}
|
||||
${BEGIN} BOOLEAN ${UNINIT_CNAME_DECL_BOOLEAN}_${UNINIT_GUID_DECL_BOOLEAN}[${UNINIT_NUMSKUS_DECL_BOOLEAN}];
|
||||
${END}
|
||||
} ${PHASE}_PCD_DATABASE_UNINIT;
|
||||
|
||||
#define PCD_${PHASE}_SERVICE_DRIVER_VERSION 2
|
||||
|
||||
typedef struct {
|
||||
${PHASE}_PCD_DATABASE_INIT Init;
|
||||
${PHASE}_PCD_DATABASE_UNINIT Uninit;
|
||||
} ${PHASE}_PCD_DATABASE;
|
||||
|
||||
#define ${PHASE}_NEX_TOKEN_NUMBER (${PHASE}_LOCAL_TOKEN_NUMBER - ${PHASE}_EX_TOKEN_NUMBER)
|
||||
""")
|
||||
|
||||
gEmptyPcdDatabaseAutoGenC = TemplateString("""
|
||||
${PHASE}_PCD_DATABASE_INIT g${PHASE}PcdDbInit = {
|
||||
/* ExMapTable */
|
||||
{
|
||||
{0, 0, 0}
|
||||
},
|
||||
/* LocalTokenNumberTable */
|
||||
{
|
||||
0
|
||||
},
|
||||
/* GuidTable */
|
||||
{
|
||||
{0x00000000, 0x0000, 0x0000, {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}}
|
||||
},
|
||||
/* StringTable */
|
||||
{ 0 },
|
||||
/* SizeTable */
|
||||
{
|
||||
0, 0
|
||||
},
|
||||
/* SkuIdTable */
|
||||
{ 0 },
|
||||
${SYSTEM_SKU_ID_VALUE}
|
||||
};
|
||||
""")
|
||||
|
||||
gPcdDatabaseAutoGenC = TemplateString("""
|
||||
${PHASE}_PCD_DATABASE_INIT g${PHASE}PcdDbInit = {
|
||||
${BEGIN} { ${INIT_VALUE_UINT64} }, /* ${INIT_CNAME_DECL_UINT64}_${INIT_GUID_DECL_UINT64}[${INIT_NUMSKUS_DECL_UINT64}] */
|
||||
${END}
|
||||
${BEGIN} ${VARDEF_VALUE_UINT64}, /* ${VARDEF_CNAME_UINT64}_${VARDEF_GUID_UINT64}_VariableDefault_${VARDEF_SKUID_UINT64} */
|
||||
${END}
|
||||
${BEGIN} { ${INIT_VALUE_UINT32} }, /* ${INIT_CNAME_DECL_UINT32}_${INIT_GUID_DECL_UINT32}[${INIT_NUMSKUS_DECL_UINT32}] */
|
||||
${END}
|
||||
${BEGIN} ${VARDEF_VALUE_UINT32}, /* ${VARDEF_CNAME_UINT32}_${VARDEF_GUID_UINT32}_VariableDefault_${VARDEF_SKUID_UINT32} */
|
||||
${END}
|
||||
/* VPD */
|
||||
${BEGIN} { ${VPD_HEAD_VALUE} }, /* ${VPD_HEAD_CNAME_DECL}_${VPD_HEAD_GUID_DECL}[${VPD_HEAD_NUMSKUS_DECL}] */
|
||||
${END}
|
||||
/* ExMapTable */
|
||||
{
|
||||
${BEGIN} { ${EXMAPPING_TABLE_EXTOKEN}, ${EXMAPPING_TABLE_LOCAL_TOKEN}, ${EXMAPPING_TABLE_GUID_INDEX} },
|
||||
${END}
|
||||
},
|
||||
/* LocalTokenNumberTable */
|
||||
{
|
||||
${BEGIN} offsetof(${PHASE}_PCD_DATABASE, ${TOKEN_INIT}.${TOKEN_CNAME}_${TOKEN_GUID}${VARDEF_HEADER}) | ${TOKEN_TYPE},
|
||||
${END}
|
||||
},
|
||||
/* GuidTable */
|
||||
{
|
||||
${BEGIN} ${GUID_STRUCTURE},
|
||||
${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_Header[${VARIABLE_HEAD_NUMSKUS_DECL}] */
|
||||
{
|
||||
${VARIABLE_HEAD_VALUE}
|
||||
},
|
||||
${END}
|
||||
/* StringTable */
|
||||
${BEGIN} ${STRING_TABLE_VALUE}, /* ${STRING_TABLE_CNAME}_${STRING_TABLE_GUID} */
|
||||
${END}
|
||||
/* SizeTable */
|
||||
{
|
||||
${BEGIN} ${SIZE_TABLE_MAXIMUM_LENGTH}, ${SIZE_TABLE_CURRENT_LENGTH}, /* ${SIZE_TABLE_CNAME}_${SIZE_TABLE_GUID} */
|
||||
${END}
|
||||
},
|
||||
${BEGIN} { ${INIT_VALUE_UINT16} }, /* ${INIT_CNAME_DECL_UINT16}_${INIT_GUID_DECL_UINT16}[${INIT_NUMSKUS_DECL_UINT16}] */
|
||||
${END}
|
||||
${BEGIN} ${VARDEF_VALUE_UINT16}, /* ${VARDEF_CNAME_UINT16}_${VARDEF_GUID_UINT16}_VariableDefault_${VARDEF_SKUID_UINT16} */
|
||||
${END}
|
||||
${BEGIN} { ${INIT_VALUE_UINT8} }, /* ${INIT_CNAME_DECL_UINT8}_${INIT_GUID_DECL_UINT8}[${INIT_NUMSKUS_DECL_UINT8}] */
|
||||
${END}
|
||||
${BEGIN} ${VARDEF_VALUE_UINT8}, /* ${VARDEF_CNAME_UINT8}_${VARDEF_GUID_UINT8}_VariableDefault_${VARDEF_SKUID_UINT8} */
|
||||
${END}
|
||||
${BEGIN} { ${INIT_VALUE_BOOLEAN} }, /* ${INIT_CNAME_DECL_BOOLEAN}_${INIT_GUID_DECL_BOOLEAN}[${INIT_NUMSKUS_DECL_BOOLEAN}] */
|
||||
${END}
|
||||
${BEGIN} ${VARDEF_VALUE_BOOLEAN}, /* ${VARDEF_CNAME_BOOLEAN}_${VARDEF_GUID_BOOLEAN}_VariableDefault_${VARDEF_SKUID_BOOLEAN} */
|
||||
${END}
|
||||
/* SkuIdTable */
|
||||
{ ${BEGIN}${SKUID_VALUE}, ${END} },
|
||||
${SYSTEM_SKU_ID_VALUE}
|
||||
};
|
||||
""")
|
||||
|
||||
|
||||
## AutoGen File Header Templates
|
||||
gAutoGenHeaderString = TemplateString("""\
|
||||
/**
|
||||
@ -907,6 +662,76 @@ gModuleTypeHeaderFile = {
|
||||
"USER_DEFINED" : [gBasicHeaderFile]
|
||||
}
|
||||
|
||||
## 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
|
||||
# @param AutoGenH The TemplateString object for header file
|
||||
#
|
||||
#
|
||||
def DynExPcdTokenNumberMapping(Info, AutoGenH):
|
||||
ExTokenCNameList = []
|
||||
PcdExList = []
|
||||
if Info.IsLibrary:
|
||||
PcdList = Info.LibraryPcdList
|
||||
else:
|
||||
PcdList = Info.ModulePcdList
|
||||
for Pcd in PcdList:
|
||||
if Pcd.Type in gDynamicExPcd:
|
||||
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.
|
||||
# Use the Guid pointer to see if it matches any of the token space GUIDs.
|
||||
TokenCNameList = []
|
||||
for TokenCName in ExTokenCNameList:
|
||||
if TokenCName in TokenCNameList:
|
||||
continue
|
||||
Index = 0
|
||||
Count = ExTokenCNameList.count(TokenCName)
|
||||
for Pcd in PcdExList:
|
||||
if Pcd.TokenCName == TokenCName:
|
||||
Index = Index + 1
|
||||
if Index == 1:
|
||||
AutoGenH.Append('\n#define __PCD_%s_ADDR_CMP(GuidPtr) (' % (Pcd.TokenCName))
|
||||
AutoGenH.Append('\\\n (GuidPtr == &%s) ? _PCD_TOKEN_%s_%s:'
|
||||
% (Pcd.TokenSpaceGuidCName, Pcd.TokenSpaceGuidCName, Pcd.TokenCName))
|
||||
else:
|
||||
AutoGenH.Append('\\\n (GuidPtr == &%s) ? _PCD_TOKEN_%s_%s:'
|
||||
% (Pcd.TokenSpaceGuidCName, Pcd.TokenSpaceGuidCName, Pcd.TokenCName))
|
||||
if Index == Count:
|
||||
AutoGenH.Append('0 \\\n )\n')
|
||||
TokenCNameList.append(TokenCName)
|
||||
|
||||
TokenCNameList = []
|
||||
for TokenCName in ExTokenCNameList:
|
||||
if TokenCName in TokenCNameList:
|
||||
continue
|
||||
Index = 0
|
||||
Count = ExTokenCNameList.count(TokenCName)
|
||||
for Pcd in PcdExList:
|
||||
if Pcd.Type in gDynamicExPcd and Pcd.TokenCName == TokenCName:
|
||||
Index = Index + 1
|
||||
if Index == 1:
|
||||
AutoGenH.Append('\n#define __PCD_%s_VAL_CMP(GuidPtr) (' % (Pcd.TokenCName))
|
||||
AutoGenH.Append('\\\n COMPAREGUID (GuidPtr, &%s) ? _PCD_TOKEN_%s_%s:'
|
||||
% (Pcd.TokenSpaceGuidCName, Pcd.TokenSpaceGuidCName, Pcd.TokenCName))
|
||||
else:
|
||||
AutoGenH.Append('\\\n COMPAREGUID (GuidPtr, &%s) ? _PCD_TOKEN_%s_%s:'
|
||||
% (Pcd.TokenSpaceGuidCName, Pcd.TokenSpaceGuidCName, Pcd.TokenCName))
|
||||
if Index == Count:
|
||||
AutoGenH.Append('0 \\\n )\n')
|
||||
# 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.
|
||||
AutoGenH.Append('#define _PCD_TOKEN_EX_%s(GuidPtr) __PCD_%s_ADDR_CMP(GuidPtr) ? __PCD_%s_ADDR_CMP(GuidPtr) : __PCD_%s_VAL_CMP(GuidPtr) \n'
|
||||
% (Pcd.TokenCName, Pcd.TokenCName, Pcd.TokenCName, Pcd.TokenCName))
|
||||
TokenCNameList.append(TokenCName)
|
||||
|
||||
## Create code for module PCDs
|
||||
#
|
||||
# @param Info The ModuleAutoGen object
|
||||
@ -923,13 +748,29 @@ def CreateModulePcdCode(Info, AutoGenC, AutoGenH, Pcd):
|
||||
PcdTokenName = '_PCD_TOKEN_' + Pcd.TokenCName
|
||||
if Pcd.Type in gDynamicExPcd:
|
||||
TokenNumber = int(Pcd.TokenValue, 0)
|
||||
# Add TokenSpaceGuidValue value to PcdTokenName to discriminate the DynamicEx PCDs with
|
||||
# different Guids but same TokenCName
|
||||
PcdExTokenName = '_PCD_TOKEN_' + Pcd.TokenSpaceGuidCName + '_' + Pcd.TokenCName
|
||||
AutoGenH.Append('\n#define %s %dU\n' % (PcdExTokenName, TokenNumber))
|
||||
else:
|
||||
if (Pcd.TokenCName, Pcd.TokenSpaceGuidCName) not in PcdTokenNumber:
|
||||
EdkLogger.error("build", AUTOGEN_ERROR,
|
||||
"No generated token number for %s.%s\n" % (Pcd.TokenSpaceGuidCName, Pcd.TokenCName),
|
||||
ExtraData="[%s]" % str(Info))
|
||||
TokenNumber = PcdTokenNumber[Pcd.TokenCName, Pcd.TokenSpaceGuidCName]
|
||||
AutoGenH.Append('\n#define %s %dU\n' % (PcdTokenName, TokenNumber))
|
||||
# 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:
|
||||
TokenNumber = 0
|
||||
else:
|
||||
EdkLogger.error("build", AUTOGEN_ERROR,
|
||||
"No generated token number for %s.%s\n" % (Pcd.TokenSpaceGuidCName, Pcd.TokenCName),
|
||||
ExtraData="[%s]" % str(Info))
|
||||
else:
|
||||
TokenNumber = PcdTokenNumber[Pcd.TokenCName, Pcd.TokenSpaceGuidCName]
|
||||
AutoGenH.Append('\n#define %s %dU\n' % (PcdTokenName, TokenNumber))
|
||||
|
||||
EdkLogger.debug(EdkLogger.DEBUG_3, "Creating code for " + Pcd.TokenCName + "." + Pcd.TokenSpaceGuidCName)
|
||||
if Pcd.Type not in gItemTypeStringDatabase:
|
||||
@ -946,12 +787,33 @@ def CreateModulePcdCode(Info, AutoGenC, AutoGenH, Pcd):
|
||||
GetModeName = '_PCD_GET_MODE_' + gDatumSizeStringDatabaseH[Pcd.DatumType] + '_' + Pcd.TokenCName
|
||||
SetModeName = '_PCD_SET_MODE_' + gDatumSizeStringDatabaseH[Pcd.DatumType] + '_' + Pcd.TokenCName
|
||||
|
||||
PcdExCNameList = []
|
||||
if Pcd.Type in gDynamicExPcd:
|
||||
AutoGenH.Append('#define %s LibPcdGetEx%s(&%s, %s)\n' % (GetModeName, DatumSizeLib, Pcd.TokenSpaceGuidCName, PcdTokenName))
|
||||
if Pcd.DatumType == 'VOID*':
|
||||
AutoGenH.Append('#define %s(SizeOfBuffer, Buffer) LibPcdSetEx%s(&%s, %s, (SizeOfBuffer), (Buffer))\n' % (SetModeName, DatumSizeLib, Pcd.TokenSpaceGuidCName, PcdTokenName))
|
||||
if Info.IsLibrary:
|
||||
PcdList = Info.LibraryPcdList
|
||||
else:
|
||||
AutoGenH.Append('#define %s(Value) LibPcdSetEx%s(&%s, %s, (Value))\n' % (SetModeName, DatumSizeLib, Pcd.TokenSpaceGuidCName, PcdTokenName))
|
||||
PcdList = Info.ModulePcdList
|
||||
for PcdModule in PcdList:
|
||||
if PcdModule.Type in gDynamicExPcd:
|
||||
PcdExCNameList.append(PcdModule.TokenCName)
|
||||
# Be compatible with the current code which using PcdToken and PcdGet/Set for DynamicEx Pcd.
|
||||
# If only PcdToken and PcdGet/Set used in all Pcds with different CName, it should succeed to build.
|
||||
# If PcdToken and PcdGet/Set used in the Pcds with different Guids but same CName, it should failed to build.
|
||||
if PcdExCNameList.count(Pcd.TokenCName) > 1:
|
||||
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))
|
||||
if Pcd.DatumType == 'VOID*':
|
||||
AutoGenH.Append('// #define %s(SizeOfBuffer, Buffer) LibPcdSetEx%s(&%s, %s, (SizeOfBuffer), (Buffer))\n' % (SetModeName, DatumSizeLib, Pcd.TokenSpaceGuidCName, PcdTokenName))
|
||||
else:
|
||||
AutoGenH.Append('// #define %s(Value) LibPcdSetEx%s(&%s, %s, (Value))\n' % (SetModeName, DatumSizeLib, Pcd.TokenSpaceGuidCName, PcdTokenName))
|
||||
else:
|
||||
AutoGenH.Append('#define %s %s\n' % (PcdTokenName, PcdExTokenName))
|
||||
AutoGenH.Append('#define %s LibPcdGetEx%s(&%s, %s)\n' % (GetModeName, DatumSizeLib, Pcd.TokenSpaceGuidCName, PcdTokenName))
|
||||
if Pcd.DatumType == 'VOID*':
|
||||
AutoGenH.Append('#define %s(SizeOfBuffer, Buffer) LibPcdSetEx%s(&%s, %s, (SizeOfBuffer), (Buffer))\n' % (SetModeName, DatumSizeLib, Pcd.TokenSpaceGuidCName, PcdTokenName))
|
||||
else:
|
||||
AutoGenH.Append('#define %s(Value) LibPcdSetEx%s(&%s, %s, (Value))\n' % (SetModeName, DatumSizeLib, Pcd.TokenSpaceGuidCName, PcdTokenName))
|
||||
elif Pcd.Type in gDynamicPcd:
|
||||
AutoGenH.Append('#define %s LibPcdGet%s(%s)\n' % (GetModeName, DatumSizeLib, PcdTokenName))
|
||||
if Pcd.DatumType == 'VOID*':
|
||||
@ -1117,16 +979,30 @@ def CreateLibraryPcdCode(Info, AutoGenC, AutoGenH, Pcd):
|
||||
PcdTokenNumber = Info.PlatformInfo.PcdTokenNumber
|
||||
TokenSpaceGuidCName = Pcd.TokenSpaceGuidCName
|
||||
TokenCName = Pcd.TokenCName
|
||||
TokenSpaceGuidValue = Pcd.TokenSpaceGuidValue #Info.GuidList[TokenSpaceGuidCName]
|
||||
if (Pcd.TokenCName, Pcd.TokenSpaceGuidCName) not in PcdTokenNumber:
|
||||
EdkLogger.error("build", AUTOGEN_ERROR,
|
||||
"No generated token number for %s.%s\n" % (Pcd.TokenSpaceGuidCName, Pcd.TokenCName),
|
||||
ExtraData="[%s]" % str(Info))
|
||||
TokenNumber = PcdTokenNumber[TokenCName, TokenSpaceGuidCName]
|
||||
|
||||
# If PCD is DynamicEx, then use TokenNumber declared in DEC file
|
||||
PcdTokenName = '_PCD_TOKEN_' + TokenCName
|
||||
#
|
||||
# Write PCDs
|
||||
#
|
||||
if Pcd.Type in gDynamicExPcd:
|
||||
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.
|
||||
# In this case, just assign an invalid token number to make it pass build.
|
||||
if Pcd.Type in PCD_DYNAMIC_TYPE_LIST:
|
||||
TokenNumber = 0
|
||||
else:
|
||||
EdkLogger.error("build", AUTOGEN_ERROR,
|
||||
"No generated token number for %s.%s\n" % (Pcd.TokenSpaceGuidCName, Pcd.TokenCName),
|
||||
ExtraData="[%s]" % str(Info))
|
||||
else:
|
||||
TokenNumber = PcdTokenNumber[Pcd.TokenCName, Pcd.TokenSpaceGuidCName]
|
||||
|
||||
if Pcd.Type not in gItemTypeStringDatabase:
|
||||
EdkLogger.error("build", AUTOGEN_ERROR,
|
||||
@ -1148,23 +1024,40 @@ def CreateLibraryPcdCode(Info, AutoGenC, AutoGenH, Pcd):
|
||||
if Pcd.DatumType == 'VOID*':
|
||||
Type = '(VOID *)'
|
||||
Array = '[]'
|
||||
|
||||
AutoGenH.Append('#define _PCD_TOKEN_%s %dU\n' % (TokenCName, TokenNumber))
|
||||
|
||||
PcdItemType = Pcd.Type
|
||||
#if PcdItemType in gDynamicPcd:
|
||||
# PcdItemType = TAB_PCDS_FIXED_AT_BUILD
|
||||
# if (TokenCName, TokenSpaceGuidCName) in Info.PlatformInfo.Platform.Pcds:
|
||||
# PcdItemType = Info.PlatformInfo.Platform.Pcds[TokenCName, TokenSpaceGuidCName].Type
|
||||
PcdExCNameList = []
|
||||
if PcdItemType in gDynamicExPcd:
|
||||
PcdTokenName = '_PCD_TOKEN_' + TokenCName
|
||||
AutoGenH.Append('#define %s LibPcdGetEx%s(&%s, %s)\n' % (GetModeName, DatumSizeLib, TokenSpaceGuidCName, PcdTokenName))
|
||||
if DatumType == 'VOID*':
|
||||
AutoGenH.Append('#define %s(SizeOfBuffer, Buffer) LibPcdSetEx%s(&%s, %s, (SizeOfBuffer), (Buffer))\n' % (SetModeName,DatumSizeLib, TokenSpaceGuidCName, PcdTokenName))
|
||||
PcdExTokenName = '_PCD_TOKEN_' + TokenSpaceGuidCName + '_' + Pcd.TokenCName
|
||||
AutoGenH.Append('\n#define %s %dU\n' % (PcdExTokenName, TokenNumber))
|
||||
|
||||
if Info.IsLibrary:
|
||||
PcdList = Info.LibraryPcdList
|
||||
else:
|
||||
AutoGenH.Append('#define %s(Value) LibPcdSetEx%s(&%s, %s, (Value))\n' % (SetModeName, DatumSizeLib, TokenSpaceGuidCName, PcdTokenName))
|
||||
PcdList = Info.ModulePcdList
|
||||
for PcdModule in PcdList:
|
||||
if PcdModule.Type in gDynamicExPcd:
|
||||
PcdExCNameList.append(PcdModule.TokenCName)
|
||||
# Be compatible with the current code which using PcdGet/Set for DynamicEx Pcd.
|
||||
# If only PcdGet/Set used in all Pcds with different CName, it should succeed to build.
|
||||
# If PcdGet/Set used in the Pcds with different Guids but same CName, it should failed to build.
|
||||
if PcdExCNameList.count(Pcd.TokenCName) > 1:
|
||||
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))
|
||||
if Pcd.DatumType == 'VOID*':
|
||||
AutoGenH.Append('// #define %s(SizeOfBuffer, Buffer) LibPcdSetEx%s(&%s, %s, (SizeOfBuffer), (Buffer))\n' % (SetModeName, DatumSizeLib, Pcd.TokenSpaceGuidCName, PcdTokenName))
|
||||
else:
|
||||
AutoGenH.Append('// #define %s(Value) LibPcdSetEx%s(&%s, %s, (Value))\n' % (SetModeName, DatumSizeLib, Pcd.TokenSpaceGuidCName, PcdTokenName))
|
||||
else:
|
||||
AutoGenH.Append('#define %s %s\n' % (PcdTokenName, PcdExTokenName))
|
||||
AutoGenH.Append('#define %s LibPcdGetEx%s(&%s, %s)\n' % (GetModeName, DatumSizeLib, Pcd.TokenSpaceGuidCName, PcdTokenName))
|
||||
if Pcd.DatumType == 'VOID*':
|
||||
AutoGenH.Append('#define %s(SizeOfBuffer, Buffer) LibPcdSetEx%s(&%s, %s, (SizeOfBuffer), (Buffer))\n' % (SetModeName, DatumSizeLib, Pcd.TokenSpaceGuidCName, PcdTokenName))
|
||||
else:
|
||||
AutoGenH.Append('#define %s(Value) LibPcdSetEx%s(&%s, %s, (Value))\n' % (SetModeName, DatumSizeLib, Pcd.TokenSpaceGuidCName, PcdTokenName))
|
||||
else:
|
||||
AutoGenH.Append('#define _PCD_TOKEN_%s %dU\n' % (TokenCName, TokenNumber))
|
||||
if PcdItemType in gDynamicPcd:
|
||||
PcdTokenName = '_PCD_TOKEN_' + TokenCName
|
||||
AutoGenH.Append('#define %s LibPcdGet%s(%s)\n' % (GetModeName, DatumSizeLib, PcdTokenName))
|
||||
if DatumType == 'VOID*':
|
||||
AutoGenH.Append('#define %s(SizeOfBuffer, Buffer) LibPcdSet%s(%s, (SizeOfBuffer), (Buffer))\n' %(SetModeName, DatumSizeLib, PcdTokenName))
|
||||
@ -1172,468 +1065,15 @@ def CreateLibraryPcdCode(Info, AutoGenC, AutoGenH, Pcd):
|
||||
AutoGenH.Append('#define %s(Value) LibPcdSet%s(%s, (Value))\n' % (SetModeName, DatumSizeLib, PcdTokenName))
|
||||
if PcdItemType == TAB_PCDS_PATCHABLE_IN_MODULE:
|
||||
PcdVariableName = '_gPcd_' + gItemTypeStringDatabase[TAB_PCDS_PATCHABLE_IN_MODULE] + '_' + TokenCName
|
||||
AutoGenH.Append('extern %s _gPcd_BinaryPatch_%s%s;\n' %(DatumType, TokenCName, Array) )
|
||||
AutoGenH.Append('extern volatile %s _gPcd_BinaryPatch_%s%s;\n' %(DatumType, TokenCName, Array) )
|
||||
AutoGenH.Append('#define %s %s_gPcd_BinaryPatch_%s\n' %(GetModeName, Type, TokenCName))
|
||||
AutoGenH.Append('#define %s(Value) (%s = (Value))\n' % (SetModeName, PcdVariableName))
|
||||
if PcdItemType == TAB_PCDS_FIXED_AT_BUILD or PcdItemType == TAB_PCDS_FEATURE_FLAG:
|
||||
AutoGenH.Append('extern const %s _gPcd_FixedAtBuild_%s%s;\n' %(DatumType, TokenCName, Array))
|
||||
#AutoGenH.Append('#define _PCD_VALUE_%s _gPcd_FixedAtBuild_%s\n' %(TokenCName, TokenCName))
|
||||
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)
|
||||
|
||||
## Create code for PCD database in DXE or PEI phase
|
||||
#
|
||||
# @param Platform The platform object
|
||||
# @retval tuple Two TemplateString objects for C code and header file,
|
||||
# respectively
|
||||
#
|
||||
def CreatePcdDatabasePhaseSpecificAutoGen (Platform, Phase):
|
||||
AutoGenC = TemplateString()
|
||||
AutoGenH = TemplateString()
|
||||
|
||||
Dict = {
|
||||
'PHASE' : Phase,
|
||||
'GUID_TABLE_SIZE' : '1U',
|
||||
'STRING_TABLE_SIZE' : '1U',
|
||||
'SKUID_TABLE_SIZE' : '1U',
|
||||
'LOCAL_TOKEN_NUMBER_TABLE_SIZE' : '1U',
|
||||
'LOCAL_TOKEN_NUMBER' : '0U',
|
||||
'EXMAPPING_TABLE_SIZE' : '1U',
|
||||
'EX_TOKEN_NUMBER' : '0U',
|
||||
'SIZE_TABLE_SIZE' : '2U',
|
||||
'GUID_TABLE_EMPTY' : 'TRUE',
|
||||
'STRING_TABLE_EMPTY' : 'TRUE',
|
||||
'SKUID_TABLE_EMPTY' : 'TRUE',
|
||||
'DATABASE_EMPTY' : 'TRUE',
|
||||
'EXMAP_TABLE_EMPTY' : 'TRUE',
|
||||
'PCD_DATABASE_UNINIT_EMPTY' : ' UINT8 dummy; /* PCD_DATABASE_UNINIT is emptry */',
|
||||
'SYSTEM_SKU_ID' : ' SKU_ID SystemSkuId;',
|
||||
'SYSTEM_SKU_ID_VALUE' : '0U'
|
||||
}
|
||||
|
||||
for DatumType in ['UINT64','UINT32','UINT16','UINT8','BOOLEAN', "VOID*"]:
|
||||
Dict['VARDEF_CNAME_' + DatumType] = []
|
||||
Dict['VARDEF_GUID_' + DatumType] = []
|
||||
Dict['VARDEF_SKUID_' + DatumType] = []
|
||||
Dict['VARDEF_VALUE_' + DatumType] = []
|
||||
for Init in ['INIT','UNINIT']:
|
||||
Dict[Init+'_CNAME_DECL_' + DatumType] = []
|
||||
Dict[Init+'_GUID_DECL_' + DatumType] = []
|
||||
Dict[Init+'_NUMSKUS_DECL_' + DatumType] = []
|
||||
Dict[Init+'_VALUE_' + DatumType] = []
|
||||
|
||||
for Type in ['STRING_HEAD','VPD_HEAD','VARIABLE_HEAD']:
|
||||
Dict[Type + '_CNAME_DECL'] = []
|
||||
Dict[Type + '_GUID_DECL'] = []
|
||||
Dict[Type + '_NUMSKUS_DECL'] = []
|
||||
Dict[Type + '_VALUE'] = []
|
||||
|
||||
Dict['STRING_TABLE_INDEX'] = []
|
||||
Dict['STRING_TABLE_LENGTH'] = []
|
||||
Dict['STRING_TABLE_CNAME'] = []
|
||||
Dict['STRING_TABLE_GUID'] = []
|
||||
Dict['STRING_TABLE_VALUE'] = []
|
||||
|
||||
Dict['SIZE_TABLE_CNAME'] = []
|
||||
Dict['SIZE_TABLE_GUID'] = []
|
||||
Dict['SIZE_TABLE_CURRENT_LENGTH'] = []
|
||||
Dict['SIZE_TABLE_MAXIMUM_LENGTH'] = []
|
||||
|
||||
Dict['EXMAPPING_TABLE_EXTOKEN'] = []
|
||||
Dict['EXMAPPING_TABLE_LOCAL_TOKEN'] = []
|
||||
Dict['EXMAPPING_TABLE_GUID_INDEX'] = []
|
||||
|
||||
Dict['GUID_STRUCTURE'] = []
|
||||
|
||||
Dict['SKUID_VALUE'] = []
|
||||
Dict['VARDEF_HEADER'] = []
|
||||
if Phase == 'DXE':
|
||||
Dict['SYSTEM_SKU_ID'] = ''
|
||||
Dict['SYSTEM_SKU_ID_VALUE'] = ''
|
||||
|
||||
StringTableIndex = 0
|
||||
StringTableSize = 0
|
||||
NumberOfLocalTokens = 0
|
||||
NumberOfPeiLocalTokens = 0
|
||||
NumberOfDxeLocalTokens = 0
|
||||
NumberOfExTokens = 0
|
||||
NumberOfSizeItems = 0
|
||||
GuidList = []
|
||||
|
||||
for Pcd in Platform.DynamicPcdList:
|
||||
CName = Pcd.TokenCName
|
||||
TokenSpaceGuidCName = Pcd.TokenSpaceGuidCName
|
||||
|
||||
EdkLogger.debug(EdkLogger.DEBUG_3, "PCD: %s %s (%s : %s)" % (CName, TokenSpaceGuidCName, Pcd.Phase, Phase))
|
||||
if Pcd.DatumType not in gDatumSizeStringDatabase:
|
||||
EdkLogger.error("build", AUTOGEN_ERROR,
|
||||
"Unknown datum type [%s] of PCD %s.%s" % (Pcd.DatumType, Pcd.TokenSpaceGuidCName, Pcd.TokenCName),
|
||||
ExtraData="[%s]" % str(Platform))
|
||||
|
||||
if Pcd.Phase == 'PEI':
|
||||
NumberOfPeiLocalTokens += 1
|
||||
if Pcd.Phase == 'DXE':
|
||||
NumberOfDxeLocalTokens += 1
|
||||
if Pcd.Phase != Phase:
|
||||
continue
|
||||
|
||||
#
|
||||
# TODO: need GetGuidValue() definition
|
||||
#
|
||||
TokenSpaceGuidStructure = Pcd.TokenSpaceGuidValue
|
||||
TokenSpaceGuid = GuidStructureStringToGuidValueName(TokenSpaceGuidStructure)
|
||||
if Pcd.Type in gDynamicExPcd:
|
||||
if TokenSpaceGuid not in GuidList:
|
||||
GuidList += [TokenSpaceGuid]
|
||||
Dict['GUID_STRUCTURE'].append(TokenSpaceGuidStructure)
|
||||
NumberOfExTokens += 1
|
||||
|
||||
ValueList = []
|
||||
StringHeadOffsetList = []
|
||||
VpdHeadOffsetList = []
|
||||
VariableHeadValueList = []
|
||||
Pcd.InitString = 'UNINIT'
|
||||
|
||||
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:
|
||||
Pcd.TokenTypeList = ['PCD_DATUM_TYPE_' + Pcd.DatumType]
|
||||
|
||||
if len(Pcd.SkuInfoList) > 1:
|
||||
Pcd.TokenTypeList += ['PCD_TYPE_SKU_ENABLED']
|
||||
|
||||
for SkuName in Pcd.SkuInfoList:
|
||||
Sku = Pcd.SkuInfoList[SkuName]
|
||||
SkuId = Sku.SkuId
|
||||
if SkuId == None or SkuId == '':
|
||||
continue
|
||||
|
||||
if (SkuId + 'U') not in Dict['SKUID_VALUE']:
|
||||
Dict['SKUID_VALUE'].append(SkuId + 'U')
|
||||
|
||||
SkuIdIndex = Dict['SKUID_VALUE'].index(SkuId + 'U')
|
||||
if len(Sku.VariableName) > 0:
|
||||
Pcd.TokenTypeList += ['PCD_TYPE_HII']
|
||||
Pcd.InitString = 'INIT'
|
||||
VariableNameStructure = StringToArray(Sku.VariableName)
|
||||
if VariableNameStructure not in Dict['STRING_TABLE_VALUE']:
|
||||
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)
|
||||
|
||||
Dict['STRING_TABLE_LENGTH'].append((len(Sku.VariableName) - 3 + 1) * 2)
|
||||
Dict['STRING_TABLE_VALUE'].append(VariableNameStructure)
|
||||
StringTableIndex += 1
|
||||
StringTableSize += (len(Sku.VariableName) - 3 + 1) * 2
|
||||
|
||||
VariableHeadStringIndex = 0
|
||||
for Index in range(Dict['STRING_TABLE_VALUE'].index(VariableNameStructure)):
|
||||
VariableHeadStringIndex += Dict['STRING_TABLE_LENGTH'][Index]
|
||||
|
||||
VariableGuidStructure = Sku.VariableGuidValue
|
||||
VariableGuid = GuidStructureStringToGuidValueName(VariableGuidStructure)
|
||||
if VariableGuid not in GuidList:
|
||||
GuidList += [VariableGuid]
|
||||
Dict['GUID_STRUCTURE'].append(VariableGuidStructure)
|
||||
VariableHeadGuidIndex = GuidList.index(VariableGuid)
|
||||
|
||||
if "PCD_TYPE_STRING" in Pcd.TokenTypeList:
|
||||
VariableHeadValueList.append('%dU, offsetof(%s_PCD_DATABASE, Init.%s_%s), %dU, %sU' %
|
||||
(VariableHeadStringIndex, Phase, CName, TokenSpaceGuid,
|
||||
VariableHeadGuidIndex, Sku.VariableOffset))
|
||||
else:
|
||||
VariableHeadValueList.append('%dU, offsetof(%s_PCD_DATABASE, Init.%s_%s_VariableDefault_%s), %dU, %sU' %
|
||||
(VariableHeadStringIndex, Phase, CName, TokenSpaceGuid, SkuIdIndex,
|
||||
VariableHeadGuidIndex, Sku.VariableOffset))
|
||||
Dict['VARDEF_CNAME_'+Pcd.DatumType].append(CName)
|
||||
Dict['VARDEF_GUID_'+Pcd.DatumType].append(TokenSpaceGuid)
|
||||
Dict['VARDEF_SKUID_'+Pcd.DatumType].append(SkuIdIndex)
|
||||
if "PCD_TYPE_STRING" in Pcd.TokenTypeList:
|
||||
Dict['VARDEF_VALUE_' + Pcd.DatumType].append("%s_%s[%d]" % (Pcd.TokenCName, TokenSpaceGuid, SkuIdIndex))
|
||||
else:
|
||||
#
|
||||
# ULL (for UINT64) or U(other integer type) should be append to avoid
|
||||
# warning under linux building environment.
|
||||
#
|
||||
if Pcd.DatumType == "UINT64":
|
||||
Dict['VARDEF_VALUE_'+Pcd.DatumType].append(Sku.HiiDefaultValue + "ULL")
|
||||
elif Pcd.DatumType in ("UINT32", "UINT16", "UINT8"):
|
||||
Dict['VARDEF_VALUE_'+Pcd.DatumType].append(Sku.HiiDefaultValue + "U")
|
||||
elif Pcd.DatumType == "BOOLEAN":
|
||||
if Sku.HiiDefaultValue in ["1", "0"]:
|
||||
Dict['VARDEF_VALUE_'+Pcd.DatumType].append(Sku.HiiDefaultValue + "U")
|
||||
else:
|
||||
Dict['VARDEF_VALUE_'+Pcd.DatumType].append(Sku.HiiDefaultValue)
|
||||
|
||||
elif Sku.VpdOffset != '':
|
||||
Pcd.TokenTypeList += ['PCD_TYPE_VPD']
|
||||
Pcd.InitString = 'INIT'
|
||||
VpdHeadOffsetList.append(str(Sku.VpdOffset) + 'U')
|
||||
continue
|
||||
|
||||
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) + 'U')
|
||||
Dict['SIZE_TABLE_CNAME'].append(CName)
|
||||
Dict['SIZE_TABLE_GUID'].append(TokenSpaceGuid)
|
||||
Dict['SIZE_TABLE_CURRENT_LENGTH'].append(str(Size) + 'U')
|
||||
Dict['SIZE_TABLE_MAXIMUM_LENGTH'].append(str(Pcd.MaxDatumSize) + 'U')
|
||||
if Pcd.MaxDatumSize != '':
|
||||
MaxDatumSize = int(Pcd.MaxDatumSize, 0)
|
||||
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)
|
||||
else:
|
||||
if "PCD_TYPE_HII" not in Pcd.TokenTypeList:
|
||||
Pcd.TokenTypeList += ['PCD_TYPE_DATA']
|
||||
if Sku.DefaultValue == 'TRUE':
|
||||
Pcd.InitString = 'INIT'
|
||||
else:
|
||||
try:
|
||||
if int(Sku.DefaultValue, 0) != 0:
|
||||
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")
|
||||
elif Pcd.DatumType in ("UINT32", "UINT16", "UINT8"):
|
||||
ValueList.append(Sku.DefaultValue + "U")
|
||||
elif Pcd.DatumType == "BOOLEAN":
|
||||
if Sku.DefaultValue in ["1", "0"]:
|
||||
ValueList.append(Sku.DefaultValue + "U")
|
||||
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)
|
||||
Dict['VPD_HEAD_NUMSKUS_DECL'].append(len(Pcd.SkuInfoList))
|
||||
Dict['VPD_HEAD_VALUE'].append('{ %s }' % ' }, { '.join(VpdHeadOffsetList))
|
||||
if 'PCD_TYPE_STRING' in Pcd.TokenTypeList:
|
||||
Dict['STRING_HEAD_CNAME_DECL'].append(CName)
|
||||
Dict['STRING_HEAD_GUID_DECL'].append(TokenSpaceGuid)
|
||||
Dict['STRING_HEAD_NUMSKUS_DECL'].append(len(Pcd.SkuInfoList))
|
||||
Dict['STRING_HEAD_VALUE'].append(', '.join(StringHeadOffsetList))
|
||||
if 'PCD_TYPE_DATA' in Pcd.TokenTypeList:
|
||||
Dict[Pcd.InitString+'_CNAME_DECL_'+Pcd.DatumType].append(CName)
|
||||
Dict[Pcd.InitString+'_GUID_DECL_'+Pcd.DatumType].append(TokenSpaceGuid)
|
||||
Dict[Pcd.InitString+'_NUMSKUS_DECL_'+Pcd.DatumType].append(len(Pcd.SkuInfoList))
|
||||
if Pcd.InitString == 'UNINIT':
|
||||
Dict['PCD_DATABASE_UNINIT_EMPTY'] = ''
|
||||
else:
|
||||
Dict[Pcd.InitString+'_VALUE_'+Pcd.DatumType].append(', '.join(ValueList))
|
||||
|
||||
if Phase == 'PEI':
|
||||
NumberOfLocalTokens = NumberOfPeiLocalTokens
|
||||
if Phase == 'DXE':
|
||||
NumberOfLocalTokens = NumberOfDxeLocalTokens
|
||||
|
||||
Dict['TOKEN_INIT'] = ['' for x in range(NumberOfLocalTokens)]
|
||||
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
|
||||
if Pcd.Phase != Phase:
|
||||
continue
|
||||
|
||||
TokenSpaceGuid = GuidStructureStringToGuidValueName(Pcd.TokenSpaceGuidValue) #(Platform.PackageList, TokenSpaceGuidCName))
|
||||
GeneratedTokenNumber = Platform.PcdTokenNumber[CName, TokenSpaceGuidCName] - 1
|
||||
if Phase == 'DXE':
|
||||
GeneratedTokenNumber -= NumberOfPeiLocalTokens
|
||||
|
||||
EdkLogger.debug(EdkLogger.DEBUG_1, "PCD = %s.%s" % (CName, TokenSpaceGuidCName))
|
||||
EdkLogger.debug(EdkLogger.DEBUG_1, "phase = %s" % Phase)
|
||||
EdkLogger.debug(EdkLogger.DEBUG_1, "GeneratedTokenNumber = %s" % str(GeneratedTokenNumber))
|
||||
|
||||
Dict['TOKEN_INIT'][GeneratedTokenNumber] = 'Init'
|
||||
if Pcd.InitString == 'UNINIT':
|
||||
Dict['TOKEN_INIT'][GeneratedTokenNumber] = 'Uninit'
|
||||
Dict['TOKEN_CNAME'][GeneratedTokenNumber] = CName
|
||||
Dict['TOKEN_GUID'][GeneratedTokenNumber] = TokenSpaceGuid
|
||||
Dict['TOKEN_TYPE'][GeneratedTokenNumber] = ' | '.join(Pcd.TokenTypeList)
|
||||
|
||||
Pcd.TokenTypeList = list(set(Pcd.TokenTypeList))
|
||||
#
|
||||
# Update VARDEF_HEADER
|
||||
#
|
||||
if 'PCD_TYPE_HII' in Pcd.TokenTypeList:
|
||||
Dict['VARDEF_HEADER'][GeneratedTokenNumber] = '_Variable_Header'
|
||||
else:
|
||||
Dict['VARDEF_HEADER'][GeneratedTokenNumber] = ''
|
||||
|
||||
|
||||
if Pcd.Type in gDynamicExPcd:
|
||||
Dict['EXMAPPING_TABLE_EXTOKEN'].append(str(Pcd.TokenValue) + 'U')
|
||||
if Phase == 'DXE':
|
||||
GeneratedTokenNumber += NumberOfPeiLocalTokens
|
||||
#
|
||||
# Per, PCD architecture specification, PCD Token Number is 1 based and 0 is defined as invalid token number.
|
||||
# For each EX type PCD, a PCD Token Number is assigned. When the
|
||||
# PCD Driver/PEIM map EX_GUID and EX_TOKEN_NUMBER to the PCD Token Number,
|
||||
# the non-EX Protocol/PPI interface can be called to get/set the value. This assumption is made by
|
||||
# Pcd Driver/PEIM in MdeModulePkg.
|
||||
# Therefore, 1 is added to GeneratedTokenNumber to generate a PCD Token Number before being inserted
|
||||
# to the EXMAPPING_TABLE.
|
||||
#
|
||||
Dict['EXMAPPING_TABLE_LOCAL_TOKEN'].append(str(GeneratedTokenNumber + 1) + 'U')
|
||||
Dict['EXMAPPING_TABLE_GUID_INDEX'].append(str(GuidList.index(TokenSpaceGuid)) + 'U')
|
||||
|
||||
if GuidList != []:
|
||||
Dict['GUID_TABLE_EMPTY'] = 'FALSE'
|
||||
Dict['GUID_TABLE_SIZE'] = str(len(GuidList)) + 'U'
|
||||
else:
|
||||
Dict['GUID_STRUCTURE'] = [GuidStringToGuidStructureString('00000000-0000-0000-0000-000000000000')]
|
||||
|
||||
if StringTableIndex == 0:
|
||||
Dict['STRING_TABLE_INDEX'].append('')
|
||||
Dict['STRING_TABLE_LENGTH'].append(1)
|
||||
Dict['STRING_TABLE_CNAME'].append('')
|
||||
Dict['STRING_TABLE_GUID'].append('')
|
||||
Dict['STRING_TABLE_VALUE'].append('{ 0 }')
|
||||
else:
|
||||
Dict['STRING_TABLE_EMPTY'] = 'FALSE'
|
||||
Dict['STRING_TABLE_SIZE'] = str(StringTableSize) + 'U'
|
||||
|
||||
if Dict['SIZE_TABLE_CNAME'] == []:
|
||||
Dict['SIZE_TABLE_CNAME'].append('')
|
||||
Dict['SIZE_TABLE_GUID'].append('')
|
||||
Dict['SIZE_TABLE_CURRENT_LENGTH'].append('0U')
|
||||
Dict['SIZE_TABLE_MAXIMUM_LENGTH'].append('0U')
|
||||
|
||||
if NumberOfLocalTokens != 0:
|
||||
Dict['DATABASE_EMPTY'] = 'FALSE'
|
||||
Dict['LOCAL_TOKEN_NUMBER_TABLE_SIZE'] = NumberOfLocalTokens
|
||||
Dict['LOCAL_TOKEN_NUMBER'] = NumberOfLocalTokens
|
||||
|
||||
if NumberOfExTokens != 0:
|
||||
Dict['EXMAP_TABLE_EMPTY'] = 'FALSE'
|
||||
Dict['EXMAPPING_TABLE_SIZE'] = str(NumberOfExTokens) + 'U'
|
||||
Dict['EX_TOKEN_NUMBER'] = str(NumberOfExTokens) + 'U'
|
||||
else:
|
||||
Dict['EXMAPPING_TABLE_EXTOKEN'].append('0U')
|
||||
Dict['EXMAPPING_TABLE_LOCAL_TOKEN'].append('0U')
|
||||
Dict['EXMAPPING_TABLE_GUID_INDEX'].append('0U')
|
||||
|
||||
if NumberOfSizeItems != 0:
|
||||
Dict['SIZE_TABLE_SIZE'] = str(NumberOfSizeItems * 2) + 'U'
|
||||
|
||||
AutoGenH.Append(gPcdDatabaseAutoGenH.Replace(Dict))
|
||||
if NumberOfLocalTokens == 0:
|
||||
AutoGenC.Append(gEmptyPcdDatabaseAutoGenC.Replace(Dict))
|
||||
else:
|
||||
#
|
||||
# Update Size Table to the right order, it should be same with LocalTokenNumberTable
|
||||
#
|
||||
SizeCNameTempList = []
|
||||
SizeGuidTempList = []
|
||||
SizeCurLenTempList = []
|
||||
SizeMaxLenTempList = []
|
||||
ReOrderFlag = True
|
||||
|
||||
if len(Dict['SIZE_TABLE_CNAME']) == 1:
|
||||
if not (Dict['SIZE_TABLE_CNAME'][0] and Dict['SIZE_TABLE_GUID'][0]):
|
||||
ReOrderFlag = False
|
||||
|
||||
if ReOrderFlag:
|
||||
for Count in range(len(Dict['TOKEN_CNAME'])):
|
||||
for Count1 in range(len(Dict['SIZE_TABLE_CNAME'])):
|
||||
if Dict['TOKEN_CNAME'][Count] == Dict['SIZE_TABLE_CNAME'][Count1] and \
|
||||
Dict['TOKEN_GUID'][Count] == Dict['SIZE_TABLE_GUID'][Count1]:
|
||||
SizeCNameTempList.append(Dict['SIZE_TABLE_CNAME'][Count1])
|
||||
SizeGuidTempList.append(Dict['SIZE_TABLE_GUID'][Count1])
|
||||
SizeCurLenTempList.append(Dict['SIZE_TABLE_CURRENT_LENGTH'][Count1])
|
||||
SizeMaxLenTempList.append(Dict['SIZE_TABLE_MAXIMUM_LENGTH'][Count1])
|
||||
|
||||
for Count in range(len(Dict['SIZE_TABLE_CNAME'])):
|
||||
Dict['SIZE_TABLE_CNAME'][Count] = SizeCNameTempList[Count]
|
||||
Dict['SIZE_TABLE_GUID'][Count] = SizeGuidTempList[Count]
|
||||
Dict['SIZE_TABLE_CURRENT_LENGTH'][Count] = SizeCurLenTempList[Count]
|
||||
Dict['SIZE_TABLE_MAXIMUM_LENGTH'][Count] = SizeMaxLenTempList[Count]
|
||||
|
||||
AutoGenC.Append(gPcdDatabaseAutoGenC.Replace(Dict))
|
||||
|
||||
return AutoGenH, AutoGenC
|
||||
|
||||
## Create code for PCD database
|
||||
#
|
||||
# @param Info The ModuleAutoGen object
|
||||
# @param AutoGenC The TemplateString object for C code
|
||||
# @param AutoGenH The TemplateString object for header file
|
||||
#
|
||||
def CreatePcdDatabaseCode (Info, AutoGenC, AutoGenH):
|
||||
if Info.PcdIsDriver == "":
|
||||
return
|
||||
if Info.PcdIsDriver not in gPcdPhaseMap:
|
||||
EdkLogger.error("build", AUTOGEN_ERROR, "Not supported PcdIsDriver type:%s" % Info.PcdIsDriver,
|
||||
ExtraData="[%s]" % str(Info))
|
||||
|
||||
AutoGenH.Append(gPcdDatabaseCommonAutoGenH)
|
||||
AdditionalAutoGenH, AdditionalAutoGenC = CreatePcdDatabasePhaseSpecificAutoGen (Info.PlatformInfo, 'PEI')
|
||||
AutoGenH.Append(AdditionalAutoGenH.String)
|
||||
|
||||
Phase = gPcdPhaseMap[Info.PcdIsDriver]
|
||||
if Phase == 'PEI':
|
||||
AutoGenC.Append(AdditionalAutoGenC.String)
|
||||
|
||||
if Phase == 'DXE':
|
||||
AdditionalAutoGenH, AdditionalAutoGenC = CreatePcdDatabasePhaseSpecificAutoGen (Info.PlatformInfo, Phase)
|
||||
AutoGenH.Append(AdditionalAutoGenH.String)
|
||||
AutoGenC.Append(AdditionalAutoGenC.String)
|
||||
AutoGenH.Append(gPcdDatabaseEpilogueAutoGenH)
|
||||
|
||||
## Create code for library constructor
|
||||
#
|
||||
@ -1920,7 +1360,7 @@ 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:
|
||||
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
|
||||
@ -1938,13 +1378,14 @@ def CreatePcdCode(Info, AutoGenC, AutoGenH):
|
||||
AutoGenH.Append("\n// PCD definitions\n")
|
||||
for Pcd in Info.ModulePcdList:
|
||||
CreateLibraryPcdCode(Info, AutoGenC, AutoGenH, Pcd)
|
||||
DynExPcdTokenNumberMapping (Info, AutoGenH)
|
||||
else:
|
||||
if Info.ModulePcdList:
|
||||
AutoGenH.Append("\n// Definition of PCDs used in this module\n")
|
||||
AutoGenC.Append("\n// Definition of PCDs used in this module\n")
|
||||
for Pcd in Info.ModulePcdList:
|
||||
CreateModulePcdCode(Info, AutoGenC, AutoGenH, Pcd)
|
||||
|
||||
DynExPcdTokenNumberMapping (Info, AutoGenH)
|
||||
if Info.LibraryPcdList:
|
||||
AutoGenH.Append("\n// Definition of PCDs used in libraries is in AutoGen.c\n")
|
||||
AutoGenC.Append("\n// Definition of PCDs used in libraries\n")
|
||||
|
1566
BaseTools/Source/Python/AutoGen/GenPcdDb.py
Normal file
1566
BaseTools/Source/Python/AutoGen/GenPcdDb.py
Normal file
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user