]>
git.proxmox.com Git - mirror_edk2.git/blob - BaseTools/Source/Python/GenFds/OptionRom.py
2 # process OptionROM generation
4 # Copyright (c) 2007, Intel Corporation
6 # All rights reserved. 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.
23 import OptRomInfStatement
24 from GenFdsGlobalVariable
import GenFdsGlobalVariable
25 from GenFds
import GenFds
26 from CommonDataClass
.FdfClass
import OptionRomClassObject
27 from Common
.Misc
import SaveFileOnChange
28 from Common
import EdkLogger
29 from Common
.BuildToolError
import *
36 class OPTIONROM (OptionRomClassObject
):
39 # @param self The object pointer
42 OptionRomClassObject
.__init
__(self
)
49 # @param self The object pointer
50 # @param Buffer The buffer generated OptROM data will be put
51 # @retval string Generated OptROM file path
53 def AddToBuffer (self
, Buffer
) :
55 GenFdsGlobalVariable
.InfLogger( "\nGenerating %s Option ROM ..." %self
.DriverName
)
60 # Process Modules in FfsList
61 for FfsFile
in self
.FfsList
:
63 if isinstance(FfsFile
, OptRomInfStatement
.OptRomInfStatement
):
64 FilePathNameList
= FfsFile
.GenFfs()
65 if len(FilePathNameList
) == 0:
66 EdkLogger
.error("GenFds", GENFDS_ERROR
, "Module %s not produce .efi files, so NO file could be put into option ROM." % (FfsFile
.InfFileName
))
67 if FfsFile
.OverrideAttribs
== None:
68 EfiFileList
.extend(FilePathNameList
)
70 FileName
= os
.path
.basename(FilePathNameList
[0])
71 TmpOutputDir
= os
.path
.join(GenFdsGlobalVariable
.FvDir
, self
.DriverName
)
72 if not os
.path
.exists(TmpOutputDir
) :
73 os
.makedirs(TmpOutputDir
)
74 TmpOutputFile
= os
.path
.join(TmpOutputDir
, FileName
+'.tmp')
76 GenFdsGlobalVariable
.GenerateOptionRom(TmpOutputFile
,
79 FfsFile
.OverrideAttribs
.NeedCompress
,
80 FfsFile
.OverrideAttribs
.PciClassCode
,
81 FfsFile
.OverrideAttribs
.PciRevision
,
82 FfsFile
.OverrideAttribs
.PciDeviceId
,
83 FfsFile
.OverrideAttribs
.PciVendorId
)
84 BinFileList
.append(TmpOutputFile
)
86 FilePathName
= FfsFile
.GenFfs()
87 if FfsFile
.OverrideAttribs
!= None:
88 FileName
= os
.path
.basename(FilePathName
)
89 TmpOutputDir
= os
.path
.join(GenFdsGlobalVariable
.FvDir
, self
.DriverName
)
90 if not os
.path
.exists(TmpOutputDir
) :
91 os
.makedirs(TmpOutputDir
)
92 TmpOutputFile
= os
.path
.join(TmpOutputDir
, FileName
+'.tmp')
94 GenFdsGlobalVariable
.GenerateOptionRom(TmpOutputFile
,
97 FfsFile
.OverrideAttribs
.NeedCompress
,
98 FfsFile
.OverrideAttribs
.PciClassCode
,
99 FfsFile
.OverrideAttribs
.PciRevision
,
100 FfsFile
.OverrideAttribs
.PciDeviceId
,
101 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(
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