]> git.proxmox.com Git - mirror_edk2.git/blame - BaseTools/Source/Python/GenFds/CompressSection.py
UefiCpuPkg/S3Resume: Add more perf entry for S3 phase
[mirror_edk2.git] / BaseTools / Source / Python / GenFds / CompressSection.py
CommitLineData
30fdf114
LG
1## @file\r
2# process compress section generation\r
3#\r
37de70b7 4# Copyright (c) 2007 - 2017, Intel Corporation. All rights reserved.<BR>\r
30fdf114 5#\r
40d841f6 6# This program and the accompanying materials\r
30fdf114
LG
7# are licensed and made available under the terms and conditions of the BSD License\r
8# which accompanies this distribution. The full text of the license may be found at\r
9# http://opensource.org/licenses/bsd-license.php\r
10#\r
11# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
12# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
13#\r
14\r
15##\r
16# Import Modules\r
17#\r
18from Ffs import Ffs\r
19import Section\r
20import subprocess\r
97fa0ee9 21import Common.LongFilePathOs as os\r
30fdf114
LG
22from GenFdsGlobalVariable import GenFdsGlobalVariable\r
23from CommonDataClass.FdfClass import CompressSectionClassObject\r
24\r
25## generate compress section\r
26#\r
27#\r
28class CompressSection (CompressSectionClassObject) :\r
29\r
30 ## compress types: PI standard and non PI standard\r
31 CompTypeDict = {\r
52302d4d
LG
32 'PI_STD' : 'PI_STD',\r
33 'PI_NONE' : 'PI_NONE'\r
30fdf114
LG
34 }\r
35\r
36 ## The constructor\r
37 #\r
38 # @param self The object pointer\r
39 #\r
40 def __init__(self):\r
41 CompressSectionClassObject.__init__(self)\r
42\r
43 ## GenSection() method\r
44 #\r
45 # Generate compressed section\r
46 #\r
47 # @param self The object pointer\r
48 # @param OutputPath Where to place output file\r
49 # @param ModuleName Which module this section belongs to\r
50 # @param SecNum Index of section\r
51 # @param KeyStringList Filter for inputs of section generation\r
52 # @param FfsInf FfsInfStatement object that contains this section data\r
53 # @param Dict dictionary contains macro and its value\r
54 # @retval tuple (Generated file name, section alignment)\r
55 #\r
37de70b7 56 def GenSection(self, OutputPath, ModuleName, SecNum, KeyStringList, FfsInf = None, Dict = {}, IsMakefile = False):\r
30fdf114
LG
57\r
58 if FfsInf != None:\r
59 self.CompType = FfsInf.__ExtendMacro__(self.CompType)\r
60 self.Alignment = FfsInf.__ExtendMacro__(self.Alignment)\r
61\r
62 SectFiles = tuple()\r
63 Index = 0\r
4f735fc8 64 MaxAlign = None\r
30fdf114
LG
65 for Sect in self.SectionList:\r
66 Index = Index + 1\r
67 SecIndex = '%s.%d' %(SecNum, Index)\r
37de70b7 68 ReturnSectList, AlignValue = Sect.GenSection(OutputPath, ModuleName, SecIndex, KeyStringList, FfsInf, Dict, IsMakefile=IsMakefile)\r
4f735fc8
FY
69 if AlignValue != None:\r
70 if MaxAlign == None:\r
71 MaxAlign = AlignValue\r
72 if GenFdsGlobalVariable.GetAlignment (AlignValue) > GenFdsGlobalVariable.GetAlignment (MaxAlign):\r
73 MaxAlign = AlignValue\r
30fdf114 74 if ReturnSectList != []:\r
4f735fc8
FY
75 if AlignValue == None:\r
76 AlignValue = "1"\r
30fdf114 77 for FileData in ReturnSectList:\r
37de70b7 78 SectFiles += (FileData,)\r
30fdf114 79\r
4f735fc8
FY
80 if MaxAlign != None:\r
81 if self.Alignment == None:\r
82 self.Alignment = MaxAlign\r
83 else:\r
84 if GenFdsGlobalVariable.GetAlignment (MaxAlign) > GenFdsGlobalVariable.GetAlignment (self.Alignment):\r
85 self.Alignment = MaxAlign\r
30fdf114
LG
86\r
87 OutputFile = OutputPath + \\r
88 os.sep + \\r
89 ModuleName + \\r
90 'SEC' + \\r
91 SecNum + \\r
92 Ffs.SectionSuffix['COMPRESS']\r
93 OutputFile = os.path.normpath(OutputFile)\r
94\r
95 GenFdsGlobalVariable.GenerateSection(OutputFile, SectFiles, Section.Section.SectionType['COMPRESS'],\r
37de70b7 96 CompressionType=self.CompTypeDict[self.CompType], IsMakefile=IsMakefile)\r
30fdf114
LG
97 OutputFileList = []\r
98 OutputFileList.append(OutputFile)\r
99 return OutputFileList, self.Alignment\r
100\r
101\r