]>
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 from __future__
import absolute_import
19 import Common
.LongFilePathOs
as os
22 from . import OptRomInfStatement
23 from .GenFdsGlobalVariable
import GenFdsGlobalVariable
24 from CommonDataClass
.FdfClass
import OptionRomClassObject
25 from Common
.Misc
import SaveFileOnChange
26 from Common
import EdkLogger
27 from Common
.BuildToolError
import *
34 class OPTIONROM (OptionRomClassObject
):
37 # @param self The object pointer
40 OptionRomClassObject
.__init
__(self
)
47 # @param self The object pointer
48 # @param Buffer The buffer generated OptROM data will be put
49 # @retval string Generated OptROM file path
51 def AddToBuffer (self
, Buffer
, Flag
=False) :
53 GenFdsGlobalVariable
.InfLogger( "\nGenerating %s Option ROM ..." %self
.DriverName
)
58 # Process Modules in FfsList
59 for FfsFile
in self
.FfsList
:
61 if isinstance(FfsFile
, OptRomInfStatement
.OptRomInfStatement
):
62 FilePathNameList
= FfsFile
.GenFfs(IsMakefile
=Flag
)
63 if len(FilePathNameList
) == 0:
64 EdkLogger
.error("GenFds", GENFDS_ERROR
, "Module %s not produce .efi files, so NO file could be put into option ROM." % (FfsFile
.InfFileName
))
65 if FfsFile
.OverrideAttribs
is None:
66 EfiFileList
.extend(FilePathNameList
)
68 FileName
= os
.path
.basename(FilePathNameList
[0])
69 TmpOutputDir
= os
.path
.join(GenFdsGlobalVariable
.FvDir
, self
.DriverName
, FfsFile
.CurrentArch
)
70 if not os
.path
.exists(TmpOutputDir
) :
71 os
.makedirs(TmpOutputDir
)
72 TmpOutputFile
= os
.path
.join(TmpOutputDir
, FileName
+'.tmp')
74 GenFdsGlobalVariable
.GenerateOptionRom(TmpOutputFile
,
77 FfsFile
.OverrideAttribs
.NeedCompress
,
78 FfsFile
.OverrideAttribs
.PciClassCode
,
79 FfsFile
.OverrideAttribs
.PciRevision
,
80 FfsFile
.OverrideAttribs
.PciDeviceId
,
81 FfsFile
.OverrideAttribs
.PciVendorId
,
83 BinFileList
.append(TmpOutputFile
)
85 FilePathName
= FfsFile
.GenFfs(IsMakefile
=Flag
)
86 if FfsFile
.OverrideAttribs
is not 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
,
102 BinFileList
.append(TmpOutputFile
)
104 if FfsFile
.FileType
== 'EFI':
105 EfiFileList
.append(FilePathName
)
107 BinFileList
.append(FilePathName
)
112 OutputFile
= os
.path
.join(GenFdsGlobalVariable
.FvDir
, self
.DriverName
)
113 OutputFile
= OutputFile
+ '.rom'
115 GenFdsGlobalVariable
.GenerateOptionRom(
122 GenFdsGlobalVariable
.InfLogger( "\nGenerate %s Option ROM Successfully" %self
.DriverName
)
123 GenFdsGlobalVariable
.SharpCounter
= 0
127 class OverrideAttribs
:
131 # @param self The object pointer
135 self
.PciVendorId
= None
136 self
.PciClassCode
= None
137 self
.PciDeviceId
= None
138 self
.PciRevision
= None
139 self
.NeedCompress
= None