]> git.proxmox.com Git - mirror_edk2.git/blob - BaseTools/Source/Python/GenFds/OptRomInfStatement.py
Check In tool source code based on Build tool project revision r1655.
[mirror_edk2.git] / BaseTools / Source / Python / GenFds / OptRomInfStatement.py
1 ## @file
2 # process OptionROM generation from INF statement
3 #
4 # Copyright (c) 2007, Intel Corporation
5 #
6 # All rights reserved. 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 RuleSimpleFile
19 import RuleComplexFile
20 import Section
21 import OptionRom
22 import Common.GlobalData as GlobalData
23
24 from Common.DataType import *
25 from Common.String import *
26 from FfsInfStatement import FfsInfStatement
27 from GenFdsGlobalVariable import GenFdsGlobalVariable
28
29 ##
30 #
31 #
32 class OptRomInfStatement (FfsInfStatement):
33 ## The constructor
34 #
35 # @param self The object pointer
36 #
37 def __init__(self):
38 FfsInfStatement.__init__(self)
39 self.OverrideAttribs = None
40
41 ## __GetOptRomParams() method
42 #
43 # Parse inf file to get option ROM related parameters
44 #
45 # @param self The object pointer
46 #
47 def __GetOptRomParams(self):
48
49 if self.OverrideAttribs == None:
50 self.OverrideAttribs = OptionRom.OverrideAttribs()
51
52 if self.OverrideAttribs.PciVendorId == None:
53 self.OverrideAttribs.PciVendorId = self.OptRomDefs.get ('PCI_VENDOR_ID')
54
55 if self.OverrideAttribs.PciClassCode == None:
56 self.OverrideAttribs.PciClassCode = self.OptRomDefs.get ('PCI_CLASS_CODE')
57
58 if self.OverrideAttribs.PciDeviceId == None:
59 self.OverrideAttribs.PciDeviceId = self.OptRomDefs.get ('PCI_DEVICE_ID')
60
61 if self.OverrideAttribs.PciRevision == None:
62 self.OverrideAttribs.PciRevision = self.OptRomDefs.get ('PCI_REVISION')
63
64 # InfObj = GenFdsGlobalVariable.WorkSpace.BuildObject[self.PathClassObj, self.CurrentArch]
65 # RecordList = InfObj._RawData[MODEL_META_DATA_HEADER, InfObj._Arch, InfObj._Platform]
66 # for Record in RecordList:
67 # Record = ReplaceMacros(Record, GlobalData.gEdkGlobal, False)
68 # Name = Record[0]
69 ## GenFfs() method
70 #
71 # Generate FFS
72 #
73 # @param self The object pointer
74 # @retval string Generated .efi file name
75 #
76 def GenFfs(self):
77 #
78 # Parse Inf file get Module related information
79 #
80
81 self.__InfParse__()
82 self.__GetOptRomParams()
83 #
84 # Get the rule of how to generate Ffs file
85 #
86 Rule = self.__GetRule__()
87 GenFdsGlobalVariable.VerboseLogger( "Packing binaries from inf file : %s" %self.InfFileName)
88 #FileType = Ffs.Ffs.ModuleTypeToFileType[Rule.ModuleType]
89 #
90 # For the rule only has simpleFile
91 #
92 if isinstance (Rule, RuleSimpleFile.RuleSimpleFile) :
93 EfiOutputList = self.__GenSimpleFileSection__(Rule)
94 return EfiOutputList
95 #
96 # For Rule has ComplexFile
97 #
98 elif isinstance(Rule, RuleComplexFile.RuleComplexFile):
99 EfiOutputList = self.__GenComplexFileSection__(Rule)
100 return EfiOutputList
101
102 ## __GenSimpleFileSection__() method
103 #
104 # Get .efi files according to simple rule.
105 #
106 # @param self The object pointer
107 # @param Rule The rule object used to generate section
108 # @retval string File name of the generated section file
109 #
110 def __GenSimpleFileSection__(self, Rule):
111 #
112 # Prepare the parameter of GenSection
113 #
114
115 OutputFileList = []
116 if Rule.FileName != None:
117 GenSecInputFile = self.__ExtendMacro__(Rule.FileName)
118 OutputFileList.append(GenSecInputFile)
119 else:
120 OutputFileList, IsSect = Section.Section.GetFileList(self, '', Rule.FileExtension)
121
122 return OutputFileList
123
124
125 ## __GenComplexFileSection__() method
126 #
127 # Get .efi by sections in complex Rule
128 #
129 # @param self The object pointer
130 # @param Rule The rule object used to generate section
131 # @retval string File name of the generated section file
132 #
133 def __GenComplexFileSection__(self, Rule):
134
135 OutputFileList = []
136 for Sect in Rule.SectionList:
137 if Sect.SectionType == 'PE32':
138 if Sect.FileName != None:
139 GenSecInputFile = self.__ExtendMacro__(Sect.FileName)
140 OutputFileList.append(GenSecInputFile)
141 else:
142 FileList, IsSect = Section.Section.GetFileList(self, '', Sect.FileExtension)
143 OutputFileList.extend(FileList)
144
145 return OutputFileList
146
147