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