]>
git.proxmox.com Git - mirror_edk2.git/blob - BaseTools/Source/Python/GenFds/AprioriSection.py
2 # process APRIORI file data and generate PEI/DXE APRIORI file
4 # Copyright (c) 2007 - 2018, Intel Corporation. All rights reserved.<BR>
6 # 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.
18 from __future__
import absolute_import
19 from struct
import pack
20 import Common
.LongFilePathOs
as os
21 from io
import BytesIO
22 from .FfsFileStatement
import FileStatement
23 from .GenFdsGlobalVariable
import GenFdsGlobalVariable
24 from Common
.StringUtils
import NormPath
25 from Common
.Misc
import SaveFileOnChange
, PathClass
26 from Common
.EdkLogger
import error
as EdkLoggerError
27 from Common
.BuildToolError
import RESOURCE_NOT_AVAILABLE
28 from Common
.DataType
import TAB_COMMON
30 DXE_APRIORI_GUID
= "FC510EE7-FFDC-11D4-BD41-0080C73C8881"
31 PEI_APRIORI_GUID
= "1B45CC0A-156A-428A-AF62-49864DA0E6E6"
33 ## process APRIORI file data and generate PEI/DXE APRIORI file
36 class AprioriSection (object):
39 # @param self The object pointer
42 self
.DefineVarDict
= {}
48 # Generate FFS for APRIORI file
50 # @param self The object pointer
51 # @param FvName for whom apriori file generated
52 # @param Dict dictionary contains macro and its value
53 # @retval string Generated file name
55 def GenFfs (self
, FvName
, Dict
= {}, IsMakefile
= False):
57 if self
.AprioriType
== "PEI":
58 AprioriFileGuid
= PEI_APRIORI_GUID
60 AprioriFileGuid
= DXE_APRIORI_GUID
62 OutputAprFilePath
= os
.path
.join (GenFdsGlobalVariable
.WorkSpaceDir
, \
63 GenFdsGlobalVariable
.FfsDir
,\
64 AprioriFileGuid
+ FvName
)
65 if not os
.path
.exists(OutputAprFilePath
):
66 os
.makedirs(OutputAprFilePath
)
68 OutputAprFileName
= os
.path
.join( OutputAprFilePath
, \
69 AprioriFileGuid
+ FvName
+ '.Apri' )
70 AprFfsFileName
= os
.path
.join (OutputAprFilePath
,\
71 AprioriFileGuid
+ FvName
+ '.Ffs')
73 Dict
.update(self
.DefineVarDict
)
75 for FfsObj
in self
.FfsList
:
77 if isinstance(FfsObj
, FileStatement
):
78 Guid
= FfsObj
.NameGuid
80 InfFileName
= NormPath(FfsObj
.InfFileName
)
81 Arch
= FfsObj
.GetCurrentArch()
84 Dict
['$(ARCH)'] = Arch
85 InfFileName
= GenFdsGlobalVariable
.MacroExtend(InfFileName
, Dict
, Arch
)
88 Inf
= GenFdsGlobalVariable
.WorkSpace
.BuildObject
[PathClass(InfFileName
, GenFdsGlobalVariable
.WorkSpaceDir
), Arch
, GenFdsGlobalVariable
.TargetName
, GenFdsGlobalVariable
.ToolChainTag
]
91 Inf
= GenFdsGlobalVariable
.WorkSpace
.BuildObject
[PathClass(InfFileName
, GenFdsGlobalVariable
.WorkSpaceDir
), TAB_COMMON
, GenFdsGlobalVariable
.TargetName
, GenFdsGlobalVariable
.ToolChainTag
]
94 if not Inf
.Module
.Binaries
:
95 EdkLoggerError("GenFds", RESOURCE_NOT_AVAILABLE
,
96 "INF %s not found in build ARCH %s!" \
97 % (InfFileName
, GenFdsGlobalVariable
.ArchList
))
99 GuidPart
= Guid
.split('-')
100 Buffer
.write(pack('I', long(GuidPart
[0], 16)))
101 Buffer
.write(pack('H', int(GuidPart
[1], 16)))
102 Buffer
.write(pack('H', int(GuidPart
[2], 16)))
105 Char
= GuidPart
[3][Num
*2:Num
*2+2]
106 Buffer
.write(pack('B', int(Char
, 16)))
109 Char
= GuidPart
[4][Num
*2:Num
*2+2]
110 Buffer
.write(pack('B', int(Char
, 16)))
112 SaveFileOnChange(OutputAprFileName
, Buffer
.getvalue())
114 RawSectionFileName
= os
.path
.join( OutputAprFilePath
, \
115 AprioriFileGuid
+ FvName
+ '.raw' )
120 MakefilePath
= InfFileName
, Arch
121 GenFdsGlobalVariable
.GenerateSection(RawSectionFileName
, [OutputAprFileName
], 'EFI_SECTION_RAW', IsMakefile
=IsMakefile
)
122 GenFdsGlobalVariable
.GenerateFfs(AprFfsFileName
, [RawSectionFileName
],
123 'EFI_FV_FILETYPE_FREEFORM', AprioriFileGuid
, MakefilePath
=MakefilePath
)
125 return AprFfsFileName