2 # process APRIORI file data and generate PEI/DXE APRIORI file
4 # Copyright (c) 2007, 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.
21 import FfsFileStatement
22 from GenFdsGlobalVariable
import GenFdsGlobalVariable
23 from CommonDataClass
.FdfClass
import AprioriSectionClassObject
24 from Common
.String
import *
25 from Common
.Misc
import SaveFileOnChange
,PathClass
26 from Common
import EdkLogger
27 from Common
.BuildToolError
import *
29 ## process APRIORI file data and generate PEI/DXE APRIORI file
32 class AprioriSection (AprioriSectionClassObject
):
35 # @param self The object pointer
38 AprioriSectionClassObject
.__init
__(self
)
43 # Generate FFS for APRIORI file
45 # @param self The object pointer
46 # @param FvName for whom apriori file generated
47 # @param Dict dictionary contains macro and its value
48 # @retval string Generated file name
50 def GenFfs (self
, FvName
, Dict
= {}):
51 DXE_GUID
= "FC510EE7-FFDC-11D4-BD41-0080C73C8881"
52 PEI_GUID
= "1B45CC0A-156A-428A-AF62-49864DA0E6E6"
53 Buffer
= StringIO
.StringIO('')
54 AprioriFileGuid
= DXE_GUID
55 if self
.AprioriType
== "PEI":
56 AprioriFileGuid
= PEI_GUID
57 OutputAprFilePath
= os
.path
.join (GenFdsGlobalVariable
.WorkSpaceDir
, \
58 GenFdsGlobalVariable
.FfsDir
,\
59 AprioriFileGuid
+ FvName
)
60 if not os
.path
.exists(OutputAprFilePath
) :
61 os
.makedirs(OutputAprFilePath
)
63 OutputAprFileName
= os
.path
.join( OutputAprFilePath
, \
64 AprioriFileGuid
+ FvName
+ '.Apri' )
65 AprFfsFileName
= os
.path
.join (OutputAprFilePath
,\
66 AprioriFileGuid
+ FvName
+ '.Ffs')
68 Dict
.update(self
.DefineVarDict
)
69 for FfsObj
in self
.FfsList
:
71 if isinstance(FfsObj
, FfsFileStatement
.FileStatement
):
72 Guid
= FfsObj
.NameGuid
74 InfFileName
= NormPath(FfsObj
.InfFileName
)
75 Arch
= FfsObj
.GetCurrentArch()
78 Dict
['$(ARCH)'] = Arch
79 InfFileName
= GenFdsGlobalVariable
.MacroExtend(InfFileName
, Dict
, Arch
)
82 Inf
= GenFdsGlobalVariable
.WorkSpace
.BuildObject
[PathClass(InfFileName
, GenFdsGlobalVariable
.WorkSpaceDir
), Arch
, GenFdsGlobalVariable
.TargetName
, GenFdsGlobalVariable
.ToolChainTag
]
86 Inf
= GenFdsGlobalVariable
.WorkSpace
.BuildObject
[PathClass(InfFileName
, GenFdsGlobalVariable
.WorkSpaceDir
), 'COMMON', GenFdsGlobalVariable
.TargetName
, GenFdsGlobalVariable
.ToolChainTag
]
89 self
.BinFileList
= Inf
.Module
.Binaries
90 if self
.BinFileList
== []:
91 EdkLogger
.error("GenFds", RESOURCE_NOT_AVAILABLE
,
92 "INF %s not found in build ARCH %s!" \
93 % (InfFileName
, GenFdsGlobalVariable
.ArchList
))
96 GuidPart
= Guid
.split('-')
97 Buffer
.write(pack('I', long(GuidPart
[0], 16)))
98 Buffer
.write(pack('H', int(GuidPart
[1], 16)))
99 Buffer
.write(pack('H', int(GuidPart
[2], 16)))
102 Char
= GuidPart
[3][Num
*2:Num
*2+2]
103 Buffer
.write(pack('B', int(Char
, 16)))
106 Char
= GuidPart
[4][Num
*2:Num
*2+2]
107 Buffer
.write(pack('B', int(Char
, 16)))
109 SaveFileOnChange(OutputAprFileName
, Buffer
.getvalue())
111 RawSectionFileName
= os
.path
.join( OutputAprFilePath
, \
112 AprioriFileGuid
+ FvName
+ '.raw' )
113 GenFdsGlobalVariable
.GenerateSection(RawSectionFileName
, [OutputAprFileName
], 'EFI_SECTION_RAW')
114 GenFdsGlobalVariable
.GenerateFfs(AprFfsFileName
, [RawSectionFileName
],
115 'EFI_FV_FILETYPE_FREEFORM', AprioriFileGuid
)
117 return AprFfsFileName