]> git.proxmox.com Git - mirror_edk2.git/blob - BaseTools/Source/Python/GenFds/DepexSection.py
SecurityPkg: Change TPM MMIO range attribute
[mirror_edk2.git] / BaseTools / Source / Python / GenFds / DepexSection.py
1 ## @file
2 # process depex section generation
3 #
4 # Copyright (c) 2007 - 2014, Intel Corporation. All rights reserved.<BR>
5 #
6 # This program and the accompanying materials
7 # are licensed and made available under the terms and conditions of the BSD License
8 # which accompanies this distribution. The full text of the license may be found at
9 # http://opensource.org/licenses/bsd-license.php
10 #
11 # THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
12 # WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
13 #
14
15 ##
16 # Import Modules
17 #
18 import Section
19 from GenFdsGlobalVariable import GenFdsGlobalVariable
20 import subprocess
21 from Ffs import Ffs
22 import Common.LongFilePathOs as os
23 from CommonDataClass.FdfClass import DepexSectionClassObject
24 from AutoGen.GenDepex import DependencyExpression
25 from Common import EdkLogger
26 from Common.BuildToolError import *
27 from Common.Misc import PathClass
28
29 ## generate data section
30 #
31 #
32 class DepexSection (DepexSectionClassObject):
33 ## The constructor
34 #
35 # @param self The object pointer
36 #
37 def __init__(self):
38 DepexSectionClassObject.__init__(self)
39
40 def __FindGuidValue(self, CName):
41 for Arch in GenFdsGlobalVariable.ArchList:
42 PkgList = GenFdsGlobalVariable.WorkSpace.GetPackageList(GenFdsGlobalVariable.ActivePlatform,
43 Arch,
44 GenFdsGlobalVariable.TargetName,
45 GenFdsGlobalVariable.ToolChainTag)
46 for Inf in GenFdsGlobalVariable.FdfParser.Profile.InfList:
47 ModuleFile = PathClass(Inf, GenFdsGlobalVariable.WorkSpaceDir)
48 ModuleData = GenFdsGlobalVariable.WorkSpace.BuildObject[
49 ModuleFile,
50 Arch,
51 GenFdsGlobalVariable.TargetName,
52 GenFdsGlobalVariable.ToolChainTag
53 ]
54 for Pkg in ModuleData.Packages:
55 if Pkg not in PkgList:
56 PkgList.append(Pkg)
57 for PkgDb in PkgList:
58 if CName in PkgDb.Ppis:
59 return PkgDb.Ppis[CName]
60 if CName in PkgDb.Protocols:
61 return PkgDb.Protocols[CName]
62 if CName in PkgDb.Guids:
63 return PkgDb.Guids[CName]
64 return None
65
66 ## GenSection() method
67 #
68 # Generate compressed section
69 #
70 # @param self The object pointer
71 # @param OutputPath Where to place output file
72 # @param ModuleName Which module this section belongs to
73 # @param SecNum Index of section
74 # @param KeyStringList Filter for inputs of section generation
75 # @param FfsInf FfsInfStatement object that contains this section data
76 # @param Dict dictionary contains macro and its value
77 # @retval tuple (Generated file name list, section alignment)
78 #
79 def GenSection(self, OutputPath, ModuleName, SecNum, keyStringList, FfsFile = None, Dict = {}):
80
81 if self.ExpressionProcessed == False:
82 self.Expression = self.Expression.replace("\n", " ").replace("\r", " ")
83 ExpList = self.Expression.split()
84 ExpGuidDict = {}
85
86 for Exp in ExpList:
87 if Exp.upper() not in ('AND', 'OR', 'NOT', 'TRUE', 'FALSE', 'SOR', 'BEFORE', 'AFTER', 'END'):
88 GuidStr = self.__FindGuidValue(Exp)
89 if GuidStr == None:
90 EdkLogger.error("GenFds", RESOURCE_NOT_AVAILABLE,
91 "Depex GUID %s could not be found in build DB! (ModuleName: %s)" % (Exp, ModuleName))
92
93 ExpGuidDict[Exp] = GuidStr
94
95 for Item in ExpGuidDict:
96 self.Expression = self.Expression.replace(Item, ExpGuidDict[Item])
97
98 self.Expression = self.Expression.strip()
99 self.ExpressionProcessed = True
100
101 if self.DepexType == 'PEI_DEPEX_EXP':
102 ModuleType = 'PEIM'
103 SecType = 'PEI_DEPEX'
104 elif self.DepexType == 'DXE_DEPEX_EXP':
105 ModuleType = 'DXE_DRIVER'
106 SecType = 'DXE_DEPEX'
107 elif self.DepexType == 'SMM_DEPEX_EXP':
108 ModuleType = 'DXE_SMM_DRIVER'
109 SecType = 'SMM_DEPEX'
110 else:
111 EdkLogger.error("GenFds", FORMAT_INVALID,
112 "Depex type %s is not valid for module %s" % (self.DepexType, ModuleName))
113
114 InputFile = os.path.join (OutputPath, ModuleName + 'SEC' + SecNum + '.depex')
115 InputFile = os.path.normpath(InputFile)
116 Depex = DependencyExpression(self.Expression, ModuleType)
117 Depex.Generate(InputFile)
118
119 OutputFile = os.path.join (OutputPath, ModuleName + 'SEC' + SecNum + '.dpx')
120 OutputFile = os.path.normpath(OutputFile)
121
122 GenFdsGlobalVariable.GenerateSection(OutputFile, [InputFile], Section.Section.SectionType.get (SecType))
123 FileList = [OutputFile]
124 return FileList, self.Alignment