]> git.proxmox.com Git - mirror_edk2.git/blame - BaseTools/Source/Python/GenFds/OptionRom.py
BaseTools: skip updating temporary variable.
[mirror_edk2.git] / BaseTools / Source / Python / GenFds / OptionRom.py
CommitLineData
30fdf114
LG
1## @file\r
2# process OptionROM generation\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
1be2ed90 18import Common.LongFilePathOs as os\r
30fdf114
LG
19import subprocess\r
20import StringIO\r
21\r
22import OptRomInfStatement\r
23from GenFdsGlobalVariable import GenFdsGlobalVariable\r
24from GenFds import GenFds\r
25from CommonDataClass.FdfClass import OptionRomClassObject\r
26from Common.Misc import SaveFileOnChange\r
27from Common import EdkLogger\r
28from Common.BuildToolError import *\r
29\r
30T_CHAR_LF = '\n'\r
31\r
32## \r
33#\r
34#\r
35class OPTIONROM (OptionRomClassObject):\r
36 ## The constructor\r
37 #\r
38 # @param self The object pointer\r
39 #\r
40 def __init__(self):\r
41 OptionRomClassObject.__init__(self)\r
42\r
43\r
44 ## AddToBuffer()\r
45 #\r
46 # Generate Option ROM\r
47 #\r
48 # @param self The object pointer\r
49 # @param Buffer The buffer generated OptROM data will be put\r
50 # @retval string Generated OptROM file path\r
51 #\r
37de70b7
YZ
52 def AddToBuffer (self, Buffer, Flag=False) :\r
53 if not Flag:\r
54 GenFdsGlobalVariable.InfLogger( "\nGenerating %s Option ROM ..." %self.DriverName)\r
30fdf114
LG
55\r
56 EfiFileList = []\r
57 BinFileList = []\r
58\r
59 # Process Modules in FfsList\r
60 for FfsFile in self.FfsList :\r
61 \r
62 if isinstance(FfsFile, OptRomInfStatement.OptRomInfStatement):\r
37de70b7 63 FilePathNameList = FfsFile.GenFfs(IsMakefile=Flag)\r
30fdf114
LG
64 if len(FilePathNameList) == 0:\r
65 EdkLogger.error("GenFds", GENFDS_ERROR, "Module %s not produce .efi files, so NO file could be put into option ROM." % (FfsFile.InfFileName))\r
4231a819 66 if FfsFile.OverrideAttribs is None:\r
30fdf114
LG
67 EfiFileList.extend(FilePathNameList)\r
68 else:\r
69 FileName = os.path.basename(FilePathNameList[0])\r
2a6402d4 70 TmpOutputDir = os.path.join(GenFdsGlobalVariable.FvDir, self.DriverName, FfsFile.CurrentArch)\r
30fdf114
LG
71 if not os.path.exists(TmpOutputDir) :\r
72 os.makedirs(TmpOutputDir)\r
73 TmpOutputFile = os.path.join(TmpOutputDir, FileName+'.tmp')\r
74 \r
75 GenFdsGlobalVariable.GenerateOptionRom(TmpOutputFile, \r
76 FilePathNameList, \r
77 [], \r
78 FfsFile.OverrideAttribs.NeedCompress, \r
79 FfsFile.OverrideAttribs.PciClassCode, \r
80 FfsFile.OverrideAttribs.PciRevision, \r
81 FfsFile.OverrideAttribs.PciDeviceId, \r
37de70b7
YZ
82 FfsFile.OverrideAttribs.PciVendorId,\r
83 IsMakefile = Flag)\r
30fdf114
LG
84 BinFileList.append(TmpOutputFile)\r
85 else:\r
37de70b7 86 FilePathName = FfsFile.GenFfs(IsMakefile=Flag)\r
4231a819 87 if FfsFile.OverrideAttribs is not None:\r
30fdf114 88 FileName = os.path.basename(FilePathName)\r
2a6402d4 89 TmpOutputDir = os.path.join(GenFdsGlobalVariable.FvDir, self.DriverName, FfsFile.CurrentArch)\r
30fdf114
LG
90 if not os.path.exists(TmpOutputDir) :\r
91 os.makedirs(TmpOutputDir)\r
92 TmpOutputFile = os.path.join(TmpOutputDir, FileName+'.tmp')\r
93 \r
94 GenFdsGlobalVariable.GenerateOptionRom(TmpOutputFile, \r
95 [FilePathName], \r
96 [], \r
97 FfsFile.OverrideAttribs.NeedCompress, \r
98 FfsFile.OverrideAttribs.PciClassCode, \r
99 FfsFile.OverrideAttribs.PciRevision, \r
100 FfsFile.OverrideAttribs.PciDeviceId, \r
37de70b7
YZ
101 FfsFile.OverrideAttribs.PciVendorId,\r
102 IsMakefile=Flag)\r
30fdf114
LG
103 BinFileList.append(TmpOutputFile)\r
104 else:\r
105 if FfsFile.FileType == 'EFI':\r
106 EfiFileList.append(FilePathName)\r
107 else:\r
108 BinFileList.append(FilePathName)\r
109 \r
110 #\r
111 # Call EfiRom tool\r
112 #\r
113 OutputFile = os.path.join(GenFdsGlobalVariable.FvDir, self.DriverName)\r
114 OutputFile = OutputFile + '.rom'\r
115 \r
116 GenFdsGlobalVariable.GenerateOptionRom(\r
117 OutputFile,\r
118 EfiFileList,\r
37de70b7
YZ
119 BinFileList,\r
120 IsMakefile=Flag)\r
30fdf114 121\r
37de70b7
YZ
122 if not Flag:\r
123 GenFdsGlobalVariable.InfLogger( "\nGenerate %s Option ROM Successfully" %self.DriverName)\r
30fdf114
LG
124 GenFdsGlobalVariable.SharpCounter = 0\r
125 \r
126 return OutputFile\r
127\r
128class OverrideAttribs:\r
129 \r
130 ## The constructor\r
131 #\r
132 # @param self The object pointer\r
133 #\r
134 def __init__(self):\r
135 \r
136 self.PciVendorId = None\r
137 self.PciClassCode = None\r
138 self.PciDeviceId = None\r
139 self.PciRevision = None\r
fd171542 140 self.NeedCompress = None\r
30fdf114
LG
141 \r
142