]> git.proxmox.com Git - mirror_edk2.git/blob - BaseTools/Source/Python/GenFds/FvImageSection.py
Check In tool source code based on Build tool project revision r1655.
[mirror_edk2.git] / BaseTools / Source / Python / GenFds / FvImageSection.py
1 ## @file
2 # process FV image section generation
3 #
4 # Copyright (c) 2007, Intel Corporation
5 #
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
10 #
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.
13 #
14
15 ##
16 # Import Modules
17 #
18 import Section
19 import StringIO
20 from Ffs import Ffs
21 import subprocess
22 from GenFdsGlobalVariable import GenFdsGlobalVariable
23 import os
24 from CommonDataClass.FdfClass import FvImageSectionClassObject
25 from Common import EdkLogger
26 from Common.BuildToolError import *
27
28 ## generate FV image section
29 #
30 #
31 class FvImageSection(FvImageSectionClassObject):
32
33 ## The constructor
34 #
35 # @param self The object pointer
36 #
37 def __init__(self):
38 FvImageSectionClassObject.__init__(self)
39
40 ## GenSection() method
41 #
42 # Generate FV image section
43 #
44 # @param self The object pointer
45 # @param OutputPath Where to place output file
46 # @param ModuleName Which module this section belongs to
47 # @param SecNum Index of section
48 # @param KeyStringList Filter for inputs of section generation
49 # @param FfsInf FfsInfStatement object that contains this section data
50 # @param Dict dictionary contains macro and its value
51 # @retval tuple (Generated file name, section alignment)
52 #
53 def GenSection(self, OutputPath, ModuleName, SecNum, KeyStringList, FfsInf = None, Dict = {}):
54
55 OutputFileList = []
56 if self.FvFileType != None:
57 FileList, IsSect = Section.Section.GetFileList(FfsInf, self.FvFileType, self.FvFileExtension)
58 if IsSect :
59 return FileList, self.Alignment
60
61 Num = SecNum
62
63 for FileName in FileList:
64 OutputFile = os.path.join(OutputPath, ModuleName + 'SEC' + Num + Ffs.SectionSuffix.get("FV_IMAGE"))
65 GenFdsGlobalVariable.GenerateSection(OutputFile, [FvFileName], 'EFI_SECTION_FIRMWARE_VOLUME_IMAGE')
66 OutputFileList.append(OutputFile)
67 return OutputFileList, self.Alignment
68 #
69 # Generate Fv
70 #
71 if self.FvName != None:
72 Buffer = StringIO.StringIO('')
73 Fv = GenFdsGlobalVariable.FdfParser.Profile.FvDict.get(self.FvName)
74 if Fv != None:
75 self.Fv = Fv
76 FvFileName = self.Fv.AddToBuffer(Buffer, MacroDict = Dict)
77 else:
78 if self.FvFileName != None:
79 FvFileName = GenFdsGlobalVariable.ReplaceWorkspaceMacro(self.FvFileName)
80 else:
81 EdkLogger.error("GenFds", GENFDS_ERROR, "FvImageSection Failed! %s NOT found in FDF" % self.FvName)
82
83 #
84 # Prepare the parameter of GenSection
85 #
86 OutputFile = os.path.join(OutputPath, ModuleName + 'SEC' + SecNum + Ffs.SectionSuffix.get("FV_IMAGE"))
87 GenFdsGlobalVariable.GenerateSection(OutputFile, [FvFileName], 'EFI_SECTION_FIRMWARE_VOLUME_IMAGE')
88 OutputFileList.append(OutputFile)
89
90 return OutputFileList, self.Alignment