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