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