EDK2 doxygen online documents - Firmware Encoding Index 1
EDK2 doxygen online documents - Firmware Encoding Index

BaseTools/Source/Python/GenFds/FvImageSection.py

Go to the documentation of this file.
00001 ## @file
00002 # process FV image section generation
00003 #
00004 #  Copyright (c) 2007, Intel Corporation. All rights reserved.<BR>
00005 #
00006 #  This program and the accompanying materials
00007 #  are licensed and made available under the terms and conditions of the BSD License
00008 #  which accompanies this distribution.  The full text of the license may be found at
00009 #  http://opensource.org/licenses/bsd-license.php
00010 #
00011 #  THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
00012 #  WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
00013 #
00014 
00015 ##
00016 # Import Modules
00017 #
00018 import Section
00019 import StringIO
00020 from Ffs import Ffs
00021 import subprocess
00022 from GenFdsGlobalVariable import GenFdsGlobalVariable
00023 import os
00024 from CommonDataClass.FdfClass import FvImageSectionClassObject
00025 from Common import EdkLogger
00026 from Common.BuildToolError import *
00027 
00028 ## generate FV image section
00029 #
00030 #
00031 class FvImageSection(FvImageSectionClassObject):
00032 
00033     ## The constructor
00034     #
00035     #   @param  self        The object pointer
00036     #
00037     def __init__(self):
00038         FvImageSectionClassObject.__init__(self)
00039 
00040     ## GenSection() method
00041     #
00042     #   Generate FV image section
00043     #
00044     #   @param  self        The object pointer
00045     #   @param  OutputPath  Where to place output file
00046     #   @param  ModuleName  Which module this section belongs to
00047     #   @param  SecNum      Index of section
00048     #   @param  KeyStringList  Filter for inputs of section generation
00049     #   @param  FfsInf      FfsInfStatement object that contains this section data
00050     #   @param  Dict        dictionary contains macro and its value
00051     #   @retval tuple       (Generated file name, section alignment)
00052     #
00053     def GenSection(self, OutputPath, ModuleName, SecNum, KeyStringList, FfsInf = None, Dict = {}):
00054 
00055         OutputFileList = []
00056         if self.FvFileType != None:
00057             FileList, IsSect = Section.Section.GetFileList(FfsInf, self.FvFileType, self.FvFileExtension)
00058             if IsSect :
00059                 return FileList, self.Alignment
00060 
00061             Num = SecNum
00062 
00063             for FileName in FileList:
00064                 OutputFile = os.path.join(OutputPath, ModuleName + 'SEC' + Num + Ffs.SectionSuffix.get("FV_IMAGE"))
00065                 GenFdsGlobalVariable.GenerateSection(OutputFile, [FvFileName], 'EFI_SECTION_FIRMWARE_VOLUME_IMAGE')
00066                 OutputFileList.append(OutputFile)
00067             return OutputFileList, self.Alignment
00068         #
00069         # Generate Fv
00070         #
00071         if self.FvName != None:
00072             Buffer = StringIO.StringIO('')
00073             Fv = GenFdsGlobalVariable.FdfParser.Profile.FvDict.get(self.FvName)
00074             if Fv != None:
00075                 self.Fv = Fv
00076                 FvFileName = Fv.AddToBuffer(Buffer, self.FvAddr, MacroDict = Dict)
00077                 if Fv.FvAlignment != None:
00078                     if self.Alignment == None:
00079                         self.Alignment = Fv.FvAlignment
00080                     else:
00081                         if GenFdsGlobalVariable.GetAlignment (Fv.FvAlignment) > GenFdsGlobalVariable.GetAlignment (self.Alignment):
00082                             self.Alignment = Fv.FvAlignment
00083             else:
00084                 if self.FvFileName != None:
00085                     FvFileName = GenFdsGlobalVariable.ReplaceWorkspaceMacro(self.FvFileName)
00086                 else:
00087                     EdkLogger.error("GenFds", GENFDS_ERROR, "FvImageSection Failed! %s NOT found in FDF" % self.FvName)
00088 
00089             #
00090             # Prepare the parameter of GenSection
00091             #
00092             OutputFile = os.path.join(OutputPath, ModuleName + 'SEC' + SecNum + Ffs.SectionSuffix.get("FV_IMAGE"))
00093             GenFdsGlobalVariable.GenerateSection(OutputFile, [FvFileName], 'EFI_SECTION_FIRMWARE_VOLUME_IMAGE')
00094             OutputFileList.append(OutputFile)
00095 
00096             return OutputFileList, self.Alignment
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Defines