CorebootPayloadPkg: Conditionally add DebugAgentLib for DXE drivers
[mirror_edk2.git] / BaseTools / Source / Python / GenFds / OptRomInfStatement.py
CommitLineData
30fdf114
LG
1## @file\r
2# process OptionROM generation from INF statement\r
3#\r
37de70b7 4# Copyright (c) 2007 - 2017, Intel Corporation. All rights reserved.<BR>\r
30fdf114 5#\r
40d841f6 6# This program and the accompanying materials\r
30fdf114
LG
7# are licensed and made available under the terms and conditions of the BSD License\r
8# which accompanies this distribution. The full text of the license may be found at\r
9# http://opensource.org/licenses/bsd-license.php\r
10#\r
11# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
12# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
13#\r
14\r
15##\r
16# Import Modules\r
17#\r
18import RuleSimpleFile\r
19import RuleComplexFile\r
20import Section\r
21import OptionRom\r
22import Common.GlobalData as GlobalData\r
23\r
24from Common.DataType import *\r
25from Common.String import *\r
26from FfsInfStatement import FfsInfStatement\r
27from GenFdsGlobalVariable import GenFdsGlobalVariable\r
28\r
29## \r
30#\r
31#\r
32class OptRomInfStatement (FfsInfStatement):\r
33 ## The constructor\r
34 #\r
35 # @param self The object pointer\r
36 #\r
37 def __init__(self):\r
38 FfsInfStatement.__init__(self)\r
39 self.OverrideAttribs = None\r
40\r
41 ## __GetOptRomParams() method\r
42 #\r
43 # Parse inf file to get option ROM related parameters\r
44 #\r
45 # @param self The object pointer\r
46 #\r
47 def __GetOptRomParams(self):\r
48 \r
49 if self.OverrideAttribs == None:\r
50 self.OverrideAttribs = OptionRom.OverrideAttribs()\r
fd171542 51\r
52 if self.OverrideAttribs.NeedCompress == None:\r
79b74a03 53 self.OverrideAttribs.NeedCompress = self.OptRomDefs.get ('PCI_COMPRESS')\r
fd171542 54 if self.OverrideAttribs.NeedCompress is not None:\r
55 if self.OverrideAttribs.NeedCompress.upper() not in ('TRUE', 'FALSE'):\r
79b74a03 56 GenFdsGlobalVariable.ErrorLogger( "Expected TRUE/FALSE for PCI_COMPRESS: %s" %self.InfFileName)\r
fd171542 57 self.OverrideAttribs.NeedCompress = \\r
58 self.OverrideAttribs.NeedCompress.upper() == 'TRUE'\r
59\r
30fdf114
LG
60 if self.OverrideAttribs.PciVendorId == None:\r
61 self.OverrideAttribs.PciVendorId = self.OptRomDefs.get ('PCI_VENDOR_ID')\r
62 \r
63 if self.OverrideAttribs.PciClassCode == None:\r
64 self.OverrideAttribs.PciClassCode = self.OptRomDefs.get ('PCI_CLASS_CODE')\r
65 \r
66 if self.OverrideAttribs.PciDeviceId == None:\r
67 self.OverrideAttribs.PciDeviceId = self.OptRomDefs.get ('PCI_DEVICE_ID')\r
68 \r
69 if self.OverrideAttribs.PciRevision == None:\r
70 self.OverrideAttribs.PciRevision = self.OptRomDefs.get ('PCI_REVISION')\r
71 \r
72# InfObj = GenFdsGlobalVariable.WorkSpace.BuildObject[self.PathClassObj, self.CurrentArch] \r
73# RecordList = InfObj._RawData[MODEL_META_DATA_HEADER, InfObj._Arch, InfObj._Platform]\r
74# for Record in RecordList:\r
75# Record = ReplaceMacros(Record, GlobalData.gEdkGlobal, False)\r
76# Name = Record[0] \r
77 ## GenFfs() method\r
78 #\r
79 # Generate FFS\r
80 #\r
81 # @param self The object pointer\r
82 # @retval string Generated .efi file name\r
83 #\r
37de70b7 84 def GenFfs(self, IsMakefile=False):\r
30fdf114
LG
85 #\r
86 # Parse Inf file get Module related information\r
87 #\r
88\r
89 self.__InfParse__()\r
90 self.__GetOptRomParams()\r
91 #\r
92 # Get the rule of how to generate Ffs file\r
93 #\r
94 Rule = self.__GetRule__()\r
95 GenFdsGlobalVariable.VerboseLogger( "Packing binaries from inf file : %s" %self.InfFileName)\r
96 #FileType = Ffs.Ffs.ModuleTypeToFileType[Rule.ModuleType]\r
97 #\r
98 # For the rule only has simpleFile\r
99 #\r
100 if isinstance (Rule, RuleSimpleFile.RuleSimpleFile) :\r
37de70b7 101 EfiOutputList = self.__GenSimpleFileSection__(Rule, IsMakefile=IsMakefile)\r
30fdf114
LG
102 return EfiOutputList\r
103 #\r
104 # For Rule has ComplexFile\r
105 #\r
106 elif isinstance(Rule, RuleComplexFile.RuleComplexFile):\r
37de70b7 107 EfiOutputList = self.__GenComplexFileSection__(Rule, IsMakefile=IsMakefile)\r
30fdf114
LG
108 return EfiOutputList\r
109\r
110 ## __GenSimpleFileSection__() method\r
111 #\r
112 # Get .efi files according to simple rule.\r
113 #\r
114 # @param self The object pointer\r
115 # @param Rule The rule object used to generate section\r
116 # @retval string File name of the generated section file\r
117 #\r
37de70b7 118 def __GenSimpleFileSection__(self, Rule, IsMakefile = False):\r
30fdf114
LG
119 #\r
120 # Prepare the parameter of GenSection\r
121 #\r
122\r
123 OutputFileList = []\r
124 if Rule.FileName != None:\r
125 GenSecInputFile = self.__ExtendMacro__(Rule.FileName)\r
126 OutputFileList.append(GenSecInputFile)\r
127 else:\r
128 OutputFileList, IsSect = Section.Section.GetFileList(self, '', Rule.FileExtension)\r
129\r
130 return OutputFileList\r
131\r
132\r
133 ## __GenComplexFileSection__() method\r
134 #\r
135 # Get .efi by sections in complex Rule\r
136 #\r
137 # @param self The object pointer\r
138 # @param Rule The rule object used to generate section\r
139 # @retval string File name of the generated section file\r
140 #\r
37de70b7 141 def __GenComplexFileSection__(self, Rule, IsMakefile=False):\r
30fdf114
LG
142\r
143 OutputFileList = []\r
144 for Sect in Rule.SectionList:\r
145 if Sect.SectionType == 'PE32':\r
146 if Sect.FileName != None:\r
147 GenSecInputFile = self.__ExtendMacro__(Sect.FileName)\r
148 OutputFileList.append(GenSecInputFile)\r
149 else:\r
150 FileList, IsSect = Section.Section.GetFileList(self, '', Sect.FileExtension)\r
151 OutputFileList.extend(FileList) \r
152 \r
153 return OutputFileList\r
154\r
155