]>
git.proxmox.com Git - mirror_edk2.git/blob - BaseTools/Source/Python/GenFds/OptionRom.py
2 # process OptionROM generation
4 # Copyright (c) 2007 - 2017, Intel Corporation. All rights reserved.<BR>
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
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.
18 import Common
.LongFilePathOs
as os
22 import OptRomInfStatement
23 from GenFdsGlobalVariable
import GenFdsGlobalVariable
24 from GenFds
import GenFds
25 from CommonDataClass
.FdfClass
import OptionRomClassObject
26 from Common
.Misc
import SaveFileOnChange
27 from Common
import EdkLogger
28 from Common
.BuildToolError
import *
35 class OPTIONROM (OptionRomClassObject
):
38 # @param self The object pointer
41 OptionRomClassObject
.__init
__(self
)
48 # @param self The object pointer
49 # @param Buffer The buffer generated OptROM data will be put
50 # @retval string Generated OptROM file path
52 def AddToBuffer (self
, Buffer
, Flag
=False) :
54 GenFdsGlobalVariable
.InfLogger( "\nGenerating %s Option ROM ..." %self
.DriverName
)
59 # Process Modules in FfsList
60 for FfsFile
in self
.FfsList
:
62 if isinstance(FfsFile
, OptRomInfStatement
.OptRomInfStatement
):
63 FilePathNameList
= FfsFile
.GenFfs(IsMakefile
=Flag
)
64 if len(FilePathNameList
) == 0:
65 EdkLogger
.error("GenFds", GENFDS_ERROR
, "Module %s not produce .efi files, so NO file could be put into option ROM." % (FfsFile
.InfFileName
))
66 if FfsFile
.OverrideAttribs
is None:
67 EfiFileList
.extend(FilePathNameList
)
69 FileName
= os
.path
.basename(FilePathNameList
[0])
70 TmpOutputDir
= os
.path
.join(GenFdsGlobalVariable
.FvDir
, self
.DriverName
, FfsFile
.CurrentArch
)
71 if not os
.path
.exists(TmpOutputDir
) :
72 os
.makedirs(TmpOutputDir
)
73 TmpOutputFile
= os
.path
.join(TmpOutputDir
, FileName
+'.tmp')
75 GenFdsGlobalVariable
.GenerateOptionRom(TmpOutputFile
,
78 FfsFile
.OverrideAttribs
.NeedCompress
,
79 FfsFile
.OverrideAttribs
.PciClassCode
,
80 FfsFile
.OverrideAttribs
.PciRevision
,
81 FfsFile
.OverrideAttribs
.PciDeviceId
,
82 FfsFile
.OverrideAttribs
.PciVendorId
,
84 BinFileList
.append(TmpOutputFile
)
86 FilePathName
= FfsFile
.GenFfs(IsMakefile
=Flag
)
87 if FfsFile
.OverrideAttribs
is not None:
88 FileName
= os
.path
.basename(FilePathName
)
89 TmpOutputDir
= os
.path
.join(GenFdsGlobalVariable
.FvDir
, self
.DriverName
, FfsFile
.CurrentArch
)
90 if not os
.path
.exists(TmpOutputDir
) :
91 os
.makedirs(TmpOutputDir
)
92 TmpOutputFile
= os
.path
.join(TmpOutputDir
, FileName
+'.tmp')
94 GenFdsGlobalVariable
.GenerateOptionRom(TmpOutputFile
,
97 FfsFile
.OverrideAttribs
.NeedCompress
,
98 FfsFile
.OverrideAttribs
.PciClassCode
,
99 FfsFile
.OverrideAttribs
.PciRevision
,
100 FfsFile
.OverrideAttribs
.PciDeviceId
,
101 FfsFile
.OverrideAttribs
.PciVendorId
,
103 BinFileList
.append(TmpOutputFile
)
105 if FfsFile
.FileType
== 'EFI':
106 EfiFileList
.append(FilePathName
)
108 BinFileList
.append(FilePathName
)
113 OutputFile
= os
.path
.join(GenFdsGlobalVariable
.FvDir
, self
.DriverName
)
114 OutputFile
= OutputFile
+ '.rom'
116 GenFdsGlobalVariable
.GenerateOptionRom(
123 GenFdsGlobalVariable
.InfLogger( "\nGenerate %s Option ROM Successfully" %self
.DriverName
)
124 GenFdsGlobalVariable
.SharpCounter
= 0
128 class OverrideAttribs
:
132 # @param self The object pointer
136 self
.PciVendorId
= None
137 self
.PciClassCode
= None
138 self
.PciDeviceId
= None
139 self
.PciRevision
= None
140 self
.NeedCompress
= None