]>
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 # SPDX-License-Identifier: BSD-2-Clause-Patent
12 from __future__
import absolute_import
13 import Common
.LongFilePathOs
as os
16 from . import OptRomInfStatement
17 from .GenFdsGlobalVariable
import GenFdsGlobalVariable
18 from CommonDataClass
.FdfClass
import OptionRomClassObject
19 from Common
.Misc
import SaveFileOnChange
20 from Common
import EdkLogger
21 from Common
.BuildToolError
import *
26 class OPTIONROM (OptionRomClassObject
):
29 # @param self The object pointer
31 def __init__(self
, Name
= ""):
32 OptionRomClassObject
.__init
__(self
)
33 self
.DriverName
= Name
39 # @param self The object pointer
40 # @param Buffer The buffer generated OptROM data will be put
41 # @retval string Generated OptROM file path
43 def AddToBuffer (self
, Buffer
, Flag
=False) :
45 GenFdsGlobalVariable
.InfLogger( "\nGenerating %s Option ROM ..." %self
.DriverName
)
50 # Process Modules in FfsList
51 for FfsFile
in self
.FfsList
:
53 if isinstance(FfsFile
, OptRomInfStatement
.OptRomInfStatement
):
54 FilePathNameList
= FfsFile
.GenFfs(IsMakefile
=Flag
)
55 if len(FilePathNameList
) == 0:
56 EdkLogger
.error("GenFds", GENFDS_ERROR
, "Module %s not produce .efi files, so NO file could be put into option ROM." % (FfsFile
.InfFileName
))
57 if FfsFile
.OverrideAttribs
is None:
58 EfiFileList
.extend(FilePathNameList
)
60 FileName
= os
.path
.basename(FilePathNameList
[0])
61 TmpOutputDir
= os
.path
.join(GenFdsGlobalVariable
.FvDir
, self
.DriverName
, FfsFile
.CurrentArch
)
62 if not os
.path
.exists(TmpOutputDir
) :
63 os
.makedirs(TmpOutputDir
)
64 TmpOutputFile
= os
.path
.join(TmpOutputDir
, FileName
+'.tmp')
66 GenFdsGlobalVariable
.GenerateOptionRom(TmpOutputFile
,
69 FfsFile
.OverrideAttribs
.NeedCompress
,
70 FfsFile
.OverrideAttribs
.PciClassCode
,
71 FfsFile
.OverrideAttribs
.PciRevision
,
72 FfsFile
.OverrideAttribs
.PciDeviceId
,
73 FfsFile
.OverrideAttribs
.PciVendorId
,
75 BinFileList
.append(TmpOutputFile
)
77 FilePathName
= FfsFile
.GenFfs(IsMakefile
=Flag
)
78 if FfsFile
.OverrideAttribs
is not None:
79 FileName
= os
.path
.basename(FilePathName
)
80 TmpOutputDir
= os
.path
.join(GenFdsGlobalVariable
.FvDir
, self
.DriverName
, FfsFile
.CurrentArch
)
81 if not os
.path
.exists(TmpOutputDir
) :
82 os
.makedirs(TmpOutputDir
)
83 TmpOutputFile
= os
.path
.join(TmpOutputDir
, FileName
+'.tmp')
85 GenFdsGlobalVariable
.GenerateOptionRom(TmpOutputFile
,
88 FfsFile
.OverrideAttribs
.NeedCompress
,
89 FfsFile
.OverrideAttribs
.PciClassCode
,
90 FfsFile
.OverrideAttribs
.PciRevision
,
91 FfsFile
.OverrideAttribs
.PciDeviceId
,
92 FfsFile
.OverrideAttribs
.PciVendorId
,
94 BinFileList
.append(TmpOutputFile
)
96 if FfsFile
.FileType
== 'EFI':
97 EfiFileList
.append(FilePathName
)
99 BinFileList
.append(FilePathName
)
104 OutputFile
= os
.path
.join(GenFdsGlobalVariable
.FvDir
, self
.DriverName
)
105 OutputFile
= OutputFile
+ '.rom'
107 GenFdsGlobalVariable
.GenerateOptionRom(
114 GenFdsGlobalVariable
.InfLogger( "\nGenerate %s Option ROM Successfully" %self
.DriverName
)
115 GenFdsGlobalVariable
.SharpCounter
= 0
119 class OverrideAttribs
:
123 # @param self The object pointer
127 self
.PciVendorId
= None
128 self
.PciClassCode
= None
129 self
.PciDeviceId
= None
130 self
.PciRevision
= None
131 self
.NeedCompress
= None