]>
git.proxmox.com Git - mirror_edk2.git/blob - BaseTools/Source/Python/GenFds/OptionRom.py
2 # process OptionROM generation
4 # Copyright (c) 2007 - 2016, 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
) :
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()
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
== 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
)
83 BinFileList
.append(TmpOutputFile
)
85 FilePathName
= FfsFile
.GenFfs()
86 if FfsFile
.OverrideAttribs
!= None:
87 FileName
= os
.path
.basename(FilePathName
)
88 TmpOutputDir
= os
.path
.join(GenFdsGlobalVariable
.FvDir
, self
.DriverName
, FfsFile
.CurrentArch
)
89 if not os
.path
.exists(TmpOutputDir
) :
90 os
.makedirs(TmpOutputDir
)
91 TmpOutputFile
= os
.path
.join(TmpOutputDir
, FileName
+'.tmp')
93 GenFdsGlobalVariable
.GenerateOptionRom(TmpOutputFile
,
96 FfsFile
.OverrideAttribs
.NeedCompress
,
97 FfsFile
.OverrideAttribs
.PciClassCode
,
98 FfsFile
.OverrideAttribs
.PciRevision
,
99 FfsFile
.OverrideAttribs
.PciDeviceId
,
100 FfsFile
.OverrideAttribs
.PciVendorId
)
101 BinFileList
.append(TmpOutputFile
)
103 if FfsFile
.FileType
== 'EFI':
104 EfiFileList
.append(FilePathName
)
106 BinFileList
.append(FilePathName
)
111 OutputFile
= os
.path
.join(GenFdsGlobalVariable
.FvDir
, self
.DriverName
)
112 OutputFile
= OutputFile
+ '.rom'
114 GenFdsGlobalVariable
.GenerateOptionRom(
120 GenFdsGlobalVariable
.InfLogger( "\nGenerate %s Option ROM Successfully" %self
.DriverName
)
121 GenFdsGlobalVariable
.SharpCounter
= 0
125 class OverrideAttribs
:
129 # @param self The object pointer
133 self
.PciVendorId
= None
134 self
.PciClassCode
= None
135 self
.PciDeviceId
= None
136 self
.PciRevision
= None
137 self
.NeedCompress
= None