]>
git.proxmox.com Git - mirror_edk2.git/blob - BaseTools/Source/Python/GenFds/OptionRom.py
2 # process OptionROM generation
4 # Copyright (c) 2007 - 2018, 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
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 *
33 class OPTIONROM (OptionRomClassObject
):
36 # @param self The object pointer
39 OptionRomClassObject
.__init
__(self
)
46 # @param self The object pointer
47 # @param Buffer The buffer generated OptROM data will be put
48 # @retval string Generated OptROM file path
50 def AddToBuffer (self
, Buffer
, Flag
=False) :
52 GenFdsGlobalVariable
.InfLogger( "\nGenerating %s Option ROM ..." %self
.DriverName
)
57 # Process Modules in FfsList
58 for FfsFile
in self
.FfsList
:
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
)
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')
73 GenFdsGlobalVariable
.GenerateOptionRom(TmpOutputFile
,
76 FfsFile
.OverrideAttribs
.NeedCompress
,
77 FfsFile
.OverrideAttribs
.PciClassCode
,
78 FfsFile
.OverrideAttribs
.PciRevision
,
79 FfsFile
.OverrideAttribs
.PciDeviceId
,
80 FfsFile
.OverrideAttribs
.PciVendorId
,
82 BinFileList
.append(TmpOutputFile
)
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')
92 GenFdsGlobalVariable
.GenerateOptionRom(TmpOutputFile
,
95 FfsFile
.OverrideAttribs
.NeedCompress
,
96 FfsFile
.OverrideAttribs
.PciClassCode
,
97 FfsFile
.OverrideAttribs
.PciRevision
,
98 FfsFile
.OverrideAttribs
.PciDeviceId
,
99 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(
121 GenFdsGlobalVariable
.InfLogger( "\nGenerate %s Option ROM Successfully" %self
.DriverName
)
122 GenFdsGlobalVariable
.SharpCounter
= 0
126 class OverrideAttribs
:
130 # @param self The object pointer
134 self
.PciVendorId
= None
135 self
.PciClassCode
= None
136 self
.PciDeviceId
= None
137 self
.PciRevision
= None
138 self
.NeedCompress
= None