]>
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 *
32 class OPTIONROM (OptionRomClassObject
):
35 # @param self The object pointer
37 def __init__(self
, Name
= ""):
38 OptionRomClassObject
.__init
__(self
)
39 self
.DriverName
= Name
45 # @param self The object pointer
46 # @param Buffer The buffer generated OptROM data will be put
47 # @retval string Generated OptROM file path
49 def AddToBuffer (self
, Buffer
, Flag
=False) :
51 GenFdsGlobalVariable
.InfLogger( "\nGenerating %s Option ROM ..." %self
.DriverName
)
56 # Process Modules in FfsList
57 for FfsFile
in self
.FfsList
:
59 if isinstance(FfsFile
, OptRomInfStatement
.OptRomInfStatement
):
60 FilePathNameList
= FfsFile
.GenFfs(IsMakefile
=Flag
)
61 if len(FilePathNameList
) == 0:
62 EdkLogger
.error("GenFds", GENFDS_ERROR
, "Module %s not produce .efi files, so NO file could be put into option ROM." % (FfsFile
.InfFileName
))
63 if FfsFile
.OverrideAttribs
is None:
64 EfiFileList
.extend(FilePathNameList
)
66 FileName
= os
.path
.basename(FilePathNameList
[0])
67 TmpOutputDir
= os
.path
.join(GenFdsGlobalVariable
.FvDir
, self
.DriverName
, FfsFile
.CurrentArch
)
68 if not os
.path
.exists(TmpOutputDir
) :
69 os
.makedirs(TmpOutputDir
)
70 TmpOutputFile
= os
.path
.join(TmpOutputDir
, FileName
+'.tmp')
72 GenFdsGlobalVariable
.GenerateOptionRom(TmpOutputFile
,
75 FfsFile
.OverrideAttribs
.NeedCompress
,
76 FfsFile
.OverrideAttribs
.PciClassCode
,
77 FfsFile
.OverrideAttribs
.PciRevision
,
78 FfsFile
.OverrideAttribs
.PciDeviceId
,
79 FfsFile
.OverrideAttribs
.PciVendorId
,
81 BinFileList
.append(TmpOutputFile
)
83 FilePathName
= FfsFile
.GenFfs(IsMakefile
=Flag
)
84 if FfsFile
.OverrideAttribs
is not None:
85 FileName
= os
.path
.basename(FilePathName
)
86 TmpOutputDir
= os
.path
.join(GenFdsGlobalVariable
.FvDir
, self
.DriverName
, FfsFile
.CurrentArch
)
87 if not os
.path
.exists(TmpOutputDir
) :
88 os
.makedirs(TmpOutputDir
)
89 TmpOutputFile
= os
.path
.join(TmpOutputDir
, FileName
+'.tmp')
91 GenFdsGlobalVariable
.GenerateOptionRom(TmpOutputFile
,
94 FfsFile
.OverrideAttribs
.NeedCompress
,
95 FfsFile
.OverrideAttribs
.PciClassCode
,
96 FfsFile
.OverrideAttribs
.PciRevision
,
97 FfsFile
.OverrideAttribs
.PciDeviceId
,
98 FfsFile
.OverrideAttribs
.PciVendorId
,
100 BinFileList
.append(TmpOutputFile
)
102 if FfsFile
.FileType
== 'EFI':
103 EfiFileList
.append(FilePathName
)
105 BinFileList
.append(FilePathName
)
110 OutputFile
= os
.path
.join(GenFdsGlobalVariable
.FvDir
, self
.DriverName
)
111 OutputFile
= OutputFile
+ '.rom'
113 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