]>
git.proxmox.com Git - mirror_edk2.git/blob - BaseTools/Source/Python/GenFds/OptRomInfStatement.py
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 __future__
import absolute_import
19 from . import RuleSimpleFile
20 from . import RuleComplexFile
22 import Common
.GlobalData
as GlobalData
24 from Common
.DataType
import *
25 from Common
.StringUtils
import *
26 from .FfsInfStatement
import FfsInfStatement
27 from .GenFdsGlobalVariable
import GenFdsGlobalVariable
32 class OptRomInfStatement (FfsInfStatement
):
35 # @param self The object pointer
38 FfsInfStatement
.__init
__(self
)
39 self
.OverrideAttribs
= None
41 ## __GetOptRomParams() method
43 # Parse inf file to get option ROM related parameters
45 # @param self The object pointer
47 def __GetOptRomParams(self
):
48 if self
.OverrideAttribs
is None:
49 self
.OverrideAttribs
= OverrideAttribs()
51 if self
.OverrideAttribs
.NeedCompress
is None:
52 self
.OverrideAttribs
.NeedCompress
= self
.OptRomDefs
.get ('PCI_COMPRESS')
53 if self
.OverrideAttribs
.NeedCompress
is not None:
54 if self
.OverrideAttribs
.NeedCompress
.upper() not in ('TRUE', 'FALSE'):
55 GenFdsGlobalVariable
.ErrorLogger( "Expected TRUE/FALSE for PCI_COMPRESS: %s" %self
.InfFileName
)
56 self
.OverrideAttribs
.NeedCompress
= \
57 self
.OverrideAttribs
.NeedCompress
.upper() == 'TRUE'
59 if self
.OverrideAttribs
.PciVendorId
is None:
60 self
.OverrideAttribs
.PciVendorId
= self
.OptRomDefs
.get ('PCI_VENDOR_ID')
62 if self
.OverrideAttribs
.PciClassCode
is None:
63 self
.OverrideAttribs
.PciClassCode
= self
.OptRomDefs
.get ('PCI_CLASS_CODE')
65 if self
.OverrideAttribs
.PciDeviceId
is None:
66 self
.OverrideAttribs
.PciDeviceId
= self
.OptRomDefs
.get ('PCI_DEVICE_ID')
68 if self
.OverrideAttribs
.PciRevision
is None:
69 self
.OverrideAttribs
.PciRevision
= self
.OptRomDefs
.get ('PCI_REVISION')
71 # InfObj = GenFdsGlobalVariable.WorkSpace.BuildObject[self.PathClassObj, self.CurrentArch]
72 # RecordList = InfObj._RawData[MODEL_META_DATA_HEADER, InfObj._Arch, InfObj._Platform]
73 # for Record in RecordList:
74 # Record = ReplaceMacros(Record, GlobalData.gEdkGlobal, False)
80 # @param self The object pointer
81 # @retval string Generated .efi file name
83 def GenFfs(self
, IsMakefile
=False):
85 # Parse Inf file get Module related information
89 self
.__GetOptRomParams
()
91 # Get the rule of how to generate Ffs file
93 Rule
= self
.__GetRule
__()
94 GenFdsGlobalVariable
.VerboseLogger( "Packing binaries from inf file : %s" %self
.InfFileName
)
96 # For the rule only has simpleFile
98 if isinstance (Rule
, RuleSimpleFile
.RuleSimpleFile
) :
99 EfiOutputList
= self
.__GenSimpleFileSection
__(Rule
, IsMakefile
=IsMakefile
)
102 # For Rule has ComplexFile
104 elif isinstance(Rule
, RuleComplexFile
.RuleComplexFile
):
105 EfiOutputList
= self
.__GenComplexFileSection
__(Rule
, IsMakefile
=IsMakefile
)
108 ## __GenSimpleFileSection__() method
110 # Get .efi files according to simple rule.
112 # @param self The object pointer
113 # @param Rule The rule object used to generate section
114 # @retval string File name of the generated section file
116 def __GenSimpleFileSection__(self
, Rule
, IsMakefile
= False):
118 # Prepare the parameter of GenSection
122 if Rule
.FileName
is not None:
123 GenSecInputFile
= self
.__ExtendMacro
__(Rule
.FileName
)
124 OutputFileList
.append(GenSecInputFile
)
126 OutputFileList
, IsSect
= Section
.Section
.GetFileList(self
, '', Rule
.FileExtension
)
128 return OutputFileList
131 ## __GenComplexFileSection__() method
133 # Get .efi by sections in complex Rule
135 # @param self The object pointer
136 # @param Rule The rule object used to generate section
137 # @retval string File name of the generated section file
139 def __GenComplexFileSection__(self
, Rule
, IsMakefile
=False):
142 for Sect
in Rule
.SectionList
:
143 if Sect
.SectionType
== BINARY_FILE_TYPE_PE32
:
144 if Sect
.FileName
is not None:
145 GenSecInputFile
= self
.__ExtendMacro
__(Sect
.FileName
)
146 OutputFileList
.append(GenSecInputFile
)
148 FileList
, IsSect
= Section
.Section
.GetFileList(self
, '', Sect
.FileExtension
)
149 OutputFileList
.extend(FileList
)
151 return OutputFileList
153 class OverrideAttribs
:
157 # @param self The object pointer
161 self
.PciVendorId
= None
162 self
.PciClassCode
= None
163 self
.PciDeviceId
= None
164 self
.PciRevision
= None
165 self
.NeedCompress
= None