mirror of
https://github.com/acidanthera/audk.git
synced 2025-09-24 10:17:45 +02:00
BaseTools/Python: Replace GenFw with ImageTool
This commit is contained in:
parent
e446bbff25
commit
d8937ed6df
@ -94,7 +94,7 @@ class DataSection (DataSectionClassObject):
|
|||||||
StrippedFile = os.path.join(OutputPath, ModuleName + '.stripped')
|
StrippedFile = os.path.join(OutputPath, ModuleName + '.stripped')
|
||||||
GenFdsGlobalVariable.GenerateFirmwareImage(
|
GenFdsGlobalVariable.GenerateFirmwareImage(
|
||||||
StrippedFile,
|
StrippedFile,
|
||||||
[GenFdsGlobalVariable.MacroExtend(self.SectFileName, Dict)],
|
GenFdsGlobalVariable.MacroExtend(self.SectFileName, Dict),
|
||||||
Strip=True,
|
Strip=True,
|
||||||
IsMakefile = IsMakefile
|
IsMakefile = IsMakefile
|
||||||
)
|
)
|
||||||
|
@ -289,7 +289,7 @@ class EfiSection (EfiSectionClassObject):
|
|||||||
StrippedFile = os.path.join(OutputPath, ModuleName + '.stripped')
|
StrippedFile = os.path.join(OutputPath, ModuleName + '.stripped')
|
||||||
GenFdsGlobalVariable.GenerateFirmwareImage(
|
GenFdsGlobalVariable.GenerateFirmwareImage(
|
||||||
StrippedFile,
|
StrippedFile,
|
||||||
[File],
|
File,
|
||||||
Strip=True,
|
Strip=True,
|
||||||
IsMakefile = IsMakefile
|
IsMakefile = IsMakefile
|
||||||
)
|
)
|
||||||
|
@ -786,7 +786,7 @@ class FfsInfStatement(FfsInfStatementClassObject):
|
|||||||
StrippedFile = os.path.join(self.OutputPath, ModuleName + '.stipped')
|
StrippedFile = os.path.join(self.OutputPath, ModuleName + '.stipped')
|
||||||
GenFdsGlobalVariable.GenerateFirmwareImage(
|
GenFdsGlobalVariable.GenerateFirmwareImage(
|
||||||
StrippedFile,
|
StrippedFile,
|
||||||
[File],
|
File,
|
||||||
Strip=True,
|
Strip=True,
|
||||||
IsMakefile=IsMakefile
|
IsMakefile=IsMakefile
|
||||||
)
|
)
|
||||||
@ -820,7 +820,7 @@ class FfsInfStatement(FfsInfStatementClassObject):
|
|||||||
StrippedFile = os.path.join(self.OutputPath, ModuleName + '.stipped')
|
StrippedFile = os.path.join(self.OutputPath, ModuleName + '.stipped')
|
||||||
GenFdsGlobalVariable.GenerateFirmwareImage(
|
GenFdsGlobalVariable.GenerateFirmwareImage(
|
||||||
StrippedFile,
|
StrippedFile,
|
||||||
[GenSecInputFile],
|
GenSecInputFile,
|
||||||
Strip=True,
|
Strip=True,
|
||||||
IsMakefile=IsMakefile
|
IsMakefile=IsMakefile
|
||||||
)
|
)
|
||||||
|
@ -607,36 +607,17 @@ class GenFdsGlobalVariable:
|
|||||||
GenFdsGlobalVariable.CallExternalTool(Cmd, "Failed to generate FV")
|
GenFdsGlobalVariable.CallExternalTool(Cmd, "Failed to generate FV")
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def GenerateFirmwareImage(Output, Input, Type="efi", SubType=None, Zero=False,
|
def GenerateFirmwareImage(Output, Input, Format="Auto", Strip=False, IsMakefile=False):
|
||||||
Strip=False, Replace=False, TimeStamp=None, Join=False,
|
|
||||||
Align=None, Padding=None, Convert=False, IsMakefile=False):
|
|
||||||
if not GenFdsGlobalVariable.NeedsUpdate(Output, Input) and not IsMakefile:
|
if not GenFdsGlobalVariable.NeedsUpdate(Output, Input) and not IsMakefile:
|
||||||
return
|
return
|
||||||
GenFdsGlobalVariable.DebugLogger(EdkLogger.DEBUG_5, "%s needs update because of newer %s" % (Output, Input))
|
GenFdsGlobalVariable.DebugLogger(EdkLogger.DEBUG_5, "%s needs update because of newer %s" % (Output, Input))
|
||||||
|
|
||||||
Cmd = ["GenFw"]
|
Cmd = ["ImageTool GenImage"]
|
||||||
if Type.lower() == "te":
|
if Format != "Auto":
|
||||||
Cmd.append("-t")
|
Cmd += ("-c", Format)
|
||||||
if SubType:
|
|
||||||
Cmd += ("-e", SubType)
|
|
||||||
if TimeStamp:
|
|
||||||
Cmd += ("-s", TimeStamp)
|
|
||||||
if Align:
|
|
||||||
Cmd += ("-a", Align)
|
|
||||||
if Padding:
|
|
||||||
Cmd += ("-p", Padding)
|
|
||||||
if Zero:
|
|
||||||
Cmd.append("-z")
|
|
||||||
if Strip:
|
if Strip:
|
||||||
Cmd.append("-l")
|
Cmd.append("-s")
|
||||||
if Replace:
|
Cmd += ("-o", Output, Input)
|
||||||
Cmd.append("-r")
|
|
||||||
if Join:
|
|
||||||
Cmd.append("-j")
|
|
||||||
if Convert:
|
|
||||||
Cmd.append("-m")
|
|
||||||
Cmd += ("-o", Output)
|
|
||||||
Cmd += Input
|
|
||||||
if IsMakefile:
|
if IsMakefile:
|
||||||
if " ".join(Cmd).strip() not in GenFdsGlobalVariable.SecCmdList:
|
if " ".join(Cmd).strip() not in GenFdsGlobalVariable.SecCmdList:
|
||||||
GenFdsGlobalVariable.SecCmdList.append(" ".join(Cmd).strip())
|
GenFdsGlobalVariable.SecCmdList.append(" ".join(Cmd).strip())
|
||||||
|
@ -639,11 +639,11 @@ class ModuleReport(object):
|
|||||||
if os.path.isfile(DefaultEFIfile):
|
if os.path.isfile(DefaultEFIfile):
|
||||||
Tempfile = os.path.join(OutputDir, self.ModuleName + "_hash.tmp")
|
Tempfile = os.path.join(OutputDir, self.ModuleName + "_hash.tmp")
|
||||||
# rebase the efi image since its base address may not zero
|
# rebase the efi image since its base address may not zero
|
||||||
cmd = ["GenFw", "--rebase", str(0), "-o", Tempfile, DefaultEFIfile]
|
cmd = ["ImageTool GenImage -b 0 -o", Tempfile, DefaultEFIfile]
|
||||||
try:
|
try:
|
||||||
PopenObject = subprocess.Popen(' '.join(cmd), stdout=subprocess.PIPE, stderr=subprocess.PIPE, shell=True)
|
PopenObject = subprocess.Popen(' '.join(cmd), stdout=subprocess.PIPE, stderr=subprocess.PIPE, shell=True)
|
||||||
except Exception as X:
|
except Exception as X:
|
||||||
EdkLogger.error("GenFw", COMMAND_FAILURE, ExtraData="%s: %s" % (str(X), cmd[0]))
|
EdkLogger.error("ImageTool", COMMAND_FAILURE, ExtraData="%s: %s" % (str(X), cmd[0]))
|
||||||
EndOfProcedure = threading.Event()
|
EndOfProcedure = threading.Event()
|
||||||
EndOfProcedure.clear()
|
EndOfProcedure.clear()
|
||||||
if PopenObject.stderr:
|
if PopenObject.stderr:
|
||||||
@ -656,7 +656,7 @@ class ModuleReport(object):
|
|||||||
if PopenObject.stderr:
|
if PopenObject.stderr:
|
||||||
StdErrThread.join()
|
StdErrThread.join()
|
||||||
if PopenObject.returncode != 0:
|
if PopenObject.returncode != 0:
|
||||||
EdkLogger.error("GenFw", COMMAND_FAILURE, "Failed to generate firmware hash image for %s" % (DefaultEFIfile))
|
EdkLogger.error("ImageTool", COMMAND_FAILURE, "Failed to generate firmware hash image for %s" % (DefaultEFIfile))
|
||||||
if os.path.isfile(Tempfile):
|
if os.path.isfile(Tempfile):
|
||||||
self.Hash = hashlib.sha1()
|
self.Hash = hashlib.sha1()
|
||||||
buf = open(Tempfile, 'rb').read()
|
buf = open(Tempfile, 'rb').read()
|
||||||
|
@ -1522,18 +1522,18 @@ class Build():
|
|||||||
BaseAddress = BaseAddress - ModuleInfo.Image.Size
|
BaseAddress = BaseAddress - ModuleInfo.Image.Size
|
||||||
BaseAddress = AlignDown(BaseAddress, ModuleInfo.Image.SectionAlignment)
|
BaseAddress = AlignDown(BaseAddress, ModuleInfo.Image.SectionAlignment)
|
||||||
#
|
#
|
||||||
# Update Image to new BaseAddress by GenFw tool
|
# Update Image to new BaseAddress by ImageTool tool
|
||||||
#
|
#
|
||||||
LaunchCommand(["GenFw", "--rebase", str(BaseAddress), "-r", ModuleOutputImage], ModuleInfo.OutputDir)
|
LaunchCommand(["ImageTool", "GenImage", "-b", str(BaseAddress), "-o", ModuleOutputImage, ModuleOutputImage], ModuleInfo.OutputDir)
|
||||||
LaunchCommand(["GenFw", "--rebase", str(BaseAddress), "-r", ModuleDebugImage], ModuleInfo.DebugDir)
|
LaunchCommand(["ImageTool", "GenImage", "-b", str(BaseAddress), "-o", ModuleOutputImage, ModuleOutputImage], ModuleInfo.DebugDir)
|
||||||
## for SMM module in SMRAM, the SMRAM will be allocated from base to top.
|
## for SMM module in SMRAM, the SMRAM will be allocated from base to top.
|
||||||
else:
|
else:
|
||||||
BaseAddress = AlignUp(BaseAddress, ModuleInfo.Image.SectionAlignment)
|
BaseAddress = AlignUp(BaseAddress, ModuleInfo.Image.SectionAlignment)
|
||||||
#
|
#
|
||||||
# Set new address to the section header only for SMM driver.
|
# Set new address to the section header only for SMM driver.
|
||||||
#
|
#
|
||||||
LaunchCommand(["GenFw", "--address", str(BaseAddress), "-r", ModuleOutputImage], ModuleInfo.OutputDir)
|
LaunchCommand(["ImageTool", "GenImage", "-f -b", str(BaseAddress), "-o", ModuleOutputImage, ModuleOutputImage], ModuleInfo.OutputDir)
|
||||||
LaunchCommand(["GenFw", "--address", str(BaseAddress), "-r", ModuleDebugImage], ModuleInfo.DebugDir)
|
LaunchCommand(["ImageTool", "GenImage", "-f -b", str(BaseAddress), "-o", ModuleOutputImage, ModuleOutputImage], ModuleInfo.DebugDir)
|
||||||
#
|
#
|
||||||
# Collect function address from Map file
|
# Collect function address from Map file
|
||||||
#
|
#
|
||||||
|
Loading…
x
Reference in New Issue
Block a user