]>
git.proxmox.com Git - mirror_edk2.git/blob - BaseTools/Source/Python/GenFds/OptRomInfStatement.py
c5d106fd85ee452d641f12ce7b45e85766049a69
2 # process OptionROM generation from INF statement
4 # Copyright (c) 2007 - 2018, Intel Corporation. All rights reserved.<BR>
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
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.
18 from . import RuleSimpleFile
19 from . import RuleComplexFile
21 import Common
.GlobalData
as GlobalData
23 from Common
.DataType
import *
24 from Common
.StringUtils
import *
25 from .FfsInfStatement
import FfsInfStatement
26 from .GenFdsGlobalVariable
import GenFdsGlobalVariable
31 class OptRomInfStatement (FfsInfStatement
):
34 # @param self The object pointer
37 FfsInfStatement
.__init
__(self
)
38 self
.OverrideAttribs
= None
40 ## __GetOptRomParams() method
42 # Parse inf file to get option ROM related parameters
44 # @param self The object pointer
46 def __GetOptRomParams(self
):
47 if self
.OverrideAttribs
is None:
48 self
.OverrideAttribs
= OverrideAttribs()
50 if self
.OverrideAttribs
.NeedCompress
is None:
51 self
.OverrideAttribs
.NeedCompress
= self
.OptRomDefs
.get ('PCI_COMPRESS')
52 if self
.OverrideAttribs
.NeedCompress
is not None:
53 if self
.OverrideAttribs
.NeedCompress
.upper() not in ('TRUE', 'FALSE'):
54 GenFdsGlobalVariable
.ErrorLogger( "Expected TRUE/FALSE for PCI_COMPRESS: %s" %self
.InfFileName
)
55 self
.OverrideAttribs
.NeedCompress
= \
56 self
.OverrideAttribs
.NeedCompress
.upper() == 'TRUE'
58 if self
.OverrideAttribs
.PciVendorId
is None:
59 self
.OverrideAttribs
.PciVendorId
= self
.OptRomDefs
.get ('PCI_VENDOR_ID')
61 if self
.OverrideAttribs
.PciClassCode
is None:
62 self
.OverrideAttribs
.PciClassCode
= self
.OptRomDefs
.get ('PCI_CLASS_CODE')
64 if self
.OverrideAttribs
.PciDeviceId
is None:
65 self
.OverrideAttribs
.PciDeviceId
= self
.OptRomDefs
.get ('PCI_DEVICE_ID')
67 if self
.OverrideAttribs
.PciRevision
is None:
68 self
.OverrideAttribs
.PciRevision
= self
.OptRomDefs
.get ('PCI_REVISION')
70 # InfObj = GenFdsGlobalVariable.WorkSpace.BuildObject[self.PathClassObj, self.CurrentArch]
71 # RecordList = InfObj._RawData[MODEL_META_DATA_HEADER, InfObj._Arch, InfObj._Platform]
72 # for Record in RecordList:
73 # Record = ReplaceMacros(Record, GlobalData.gEdkGlobal, False)
79 # @param self The object pointer
80 # @retval string Generated .efi file name
82 def GenFfs(self
, IsMakefile
=False):
84 # Parse Inf file get Module related information
88 self
.__GetOptRomParams
()
90 # Get the rule of how to generate Ffs file
92 Rule
= self
.__GetRule
__()
93 GenFdsGlobalVariable
.VerboseLogger( "Packing binaries from inf file : %s" %self
.InfFileName
)
95 # For the rule only has simpleFile
97 if isinstance (Rule
, RuleSimpleFile
.RuleSimpleFile
) :
98 EfiOutputList
= self
.__GenSimpleFileSection
__(Rule
, IsMakefile
=IsMakefile
)
101 # For Rule has ComplexFile
103 elif isinstance(Rule
, RuleComplexFile
.RuleComplexFile
):
104 EfiOutputList
= self
.__GenComplexFileSection
__(Rule
, IsMakefile
=IsMakefile
)
107 ## __GenSimpleFileSection__() method
109 # Get .efi files according to simple rule.
111 # @param self The object pointer
112 # @param Rule The rule object used to generate section
113 # @retval string File name of the generated section file
115 def __GenSimpleFileSection__(self
, Rule
, IsMakefile
= False):
117 # Prepare the parameter of GenSection
121 if Rule
.FileName
is not None:
122 GenSecInputFile
= self
.__ExtendMacro
__(Rule
.FileName
)
123 OutputFileList
.append(GenSecInputFile
)
125 OutputFileList
, IsSect
= Section
.Section
.GetFileList(self
, '', Rule
.FileExtension
)
127 return OutputFileList
130 ## __GenComplexFileSection__() method
132 # Get .efi by sections in complex Rule
134 # @param self The object pointer
135 # @param Rule The rule object used to generate section
136 # @retval string File name of the generated section file
138 def __GenComplexFileSection__(self
, Rule
, IsMakefile
=False):
141 for Sect
in Rule
.SectionList
:
142 if Sect
.SectionType
== BINARY_FILE_TYPE_PE32
:
143 if Sect
.FileName
is not None:
144 GenSecInputFile
= self
.__ExtendMacro
__(Sect
.FileName
)
145 OutputFileList
.append(GenSecInputFile
)
147 FileList
, IsSect
= Section
.Section
.GetFileList(self
, '', Sect
.FileExtension
)
148 OutputFileList
.extend(FileList
)
150 return OutputFileList
152 class OverrideAttribs
:
156 # @param self The object pointer
160 self
.PciVendorId
= None
161 self
.PciClassCode
= None
162 self
.PciDeviceId
= None
163 self
.PciRevision
= None
164 self
.NeedCompress
= None