]>
Commit | Line | Data |
---|---|---|
30fdf114 LG |
1 | ## @file\r |
2 | # Open an FPD file and load all its contents to a PlatformClass object.\r | |
3 | #\r | |
40d841f6 LG |
4 | # Copyright (c) 2007, Intel Corporation. All rights reserved.<BR>\r |
5 | # This program and the accompanying materials\r | |
30fdf114 LG |
6 | # are licensed and made available under the terms and conditions of the BSD License\r |
7 | # which accompanies this distribution. The full text of the license may be found at\r | |
8 | # http://opensource.org/licenses/bsd-license.php\r | |
9 | #\r | |
10 | # THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r | |
11 | # WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r | |
12 | #\r | |
13 | \r | |
14 | ##\r | |
15 | # Import Modules\r | |
16 | #\r | |
17 | import os\r | |
18 | from CommonDataClass.PlatformClass import *\r | |
19 | from CommonDataClass.FdfClass import *\r | |
20 | from Common.XmlRoutines import *\r | |
21 | from Common.MigrationUtilities import *\r | |
22 | from EdkIIWorkspaceGuidsInfo import gEdkIIWorkspaceGuidsInfo\r | |
23 | \r | |
24 | ## Load Platform Header\r | |
25 | #\r | |
26 | # Read an input Platform XML DOM object and return Platform Header class object\r | |
27 | # contained in the DOM object.\r | |
28 | #\r | |
29 | # @param XmlFpd An XML DOM object read from FPD file\r | |
30 | # @param FpdFileName The file path of FPD File\r | |
31 | #\r | |
32 | # @retvel PlatformHeader A new Platform Header object loaded from XmlFpd\r | |
33 | #\r | |
34 | def LoadPlatformHeader(XmlFpd, FpdFileName):\r | |
35 | PlatformHeader = PlatformHeaderClass()\r | |
36 | \r | |
37 | XmlTag = "PlatformSurfaceArea/PlatformHeader"\r | |
38 | FpdHeader = XmlNode(XmlFpd, XmlTag)\r | |
39 | \r | |
40 | SetIdentification(PlatformHeader, FpdHeader, "PlatformName", FpdFileName)\r | |
41 | SetCommonHeader(PlatformHeader, FpdHeader)\r | |
42 | \r | |
43 | XmlTag = "PlatformSurfaceArea/PlatformHeader/Specification"\r | |
44 | List = XmlElement(XmlFpd, XmlTag).split()\r | |
45 | SpecificationName = List[0]\r | |
46 | SpecificationValue = List[1]\r | |
47 | PlatformHeader.Specification = {SpecificationName:SpecificationValue}\r | |
48 | \r | |
49 | XmlTag = "PlatformSurfaceArea/PlatformDefinitions/SupportedArchitectures"\r | |
50 | PlatformHeader.SupArchList = XmlElement(XmlFpd, XmlTag).split()\r | |
51 | \r | |
52 | XmlTag = "PlatformSurfaceArea/PlatformDefinitions/BuildTargets"\r | |
53 | PlatformHeader.BuildTargets = XmlElement(XmlFpd, XmlTag).split()\r | |
54 | \r | |
55 | XmlTag = "PlatformSurfaceArea/PlatformDefinitions/IntermediateDirectories"\r | |
56 | PlatformHeader.IntermediateDirectories = XmlElement(XmlFpd, XmlTag)\r | |
57 | \r | |
58 | XmlTag = "PlatformSurfaceArea/PlatformDefinitions/OutputDirectory"\r | |
59 | PlatformHeader.OutputDirectory = XmlElement(XmlFpd, XmlTag)\r | |
60 | \r | |
61 | XmlTag = "PlatformSurfaceArea/PlatformDefinitions/SkuInfo"\r | |
62 | List = map(LoadSkuId, XmlList(XmlFpd, XmlTag))\r | |
63 | if List != []:\r | |
64 | PlatformHeader.SkuIdName = List[0]\r | |
65 | \r | |
66 | return PlatformHeader\r | |
67 | \r | |
68 | ## Load a Platform SkuId\r | |
69 | #\r | |
70 | # Read an input Platform XML DOM object and return a list of Platform SkuId\r | |
71 | # contained in the DOM object.\r | |
72 | #\r | |
73 | # @param XmlPlatformSkuInfo An XML DOM object read from FPD file\r | |
74 | #\r | |
75 | # @retvel PlatformSkuInfo A SkuInfo loaded from XmlFpd\r | |
76 | #\r | |
77 | def LoadPlatformSkuInfo(XmlPlatformSkuInfo):\r | |
78 | XmlTag = "SkuInfo/SkuId"\r | |
79 | SkuInfo = []\r | |
80 | SkuId = XmlElement(XmlPlatformSkuInfo, XmlTag)\r | |
81 | SkuInfo.append(SkuId)\r | |
82 | \r | |
83 | XmlTag = "SkuInfo/Value"\r | |
84 | Value = XmlElement(XmlPlatformSkuInfo, XmlTag)\r | |
85 | SkuInfo.append(Value)\r | |
86 | return SkuInfo\r | |
87 | \r | |
88 | ## Load a Platform SkuId\r | |
89 | #\r | |
90 | # Read an input Platform XML DOM object and return a list of Platform SkuId\r | |
91 | # contained in the DOM object.\r | |
92 | #\r | |
93 | # @param XmlSkuInfo An XML DOM object read from FPD file\r | |
94 | #\r | |
95 | # @retvel List A list of SkuId and SkuValue loaded from XmlFpd\r | |
96 | #\r | |
97 | def LoadSkuId(XmlSkuInfo):\r | |
98 | XmlTag = "SkuInfo/UiSkuName"\r | |
99 | SkuValue = XmlElement(XmlSkuInfo, XmlTag)\r | |
100 | \r | |
101 | XmlTag = "SkuInfo/UiSkuName"\r | |
102 | List = map(LoadSkuID, XmlList(XmlSkuInfo, XmlTag))\r | |
103 | if List != []:\r | |
104 | SkuID = List[0]\r | |
105 | #SkuID = XmlAttribute(XmlSkuInfo, XmlTag)\r | |
106 | List = []\r | |
107 | List.append(SkuID)\r | |
108 | List.append(SkuValue)\r | |
109 | return List\r | |
110 | \r | |
111 | def LoadSkuID(XmlUiSkuName):\r | |
112 | XmlTag = "SkuID"\r | |
113 | SkuID = XmlAttribute(XmlUiSkuName, XmlTag)\r | |
114 | return SkuID\r | |
115 | \r | |
116 | ## Load a list of Platform SkuIds\r | |
117 | #\r | |
118 | # Read an input Platform XML DOM object and return a list of Platform SkuId\r | |
119 | # contained in the DOM object.\r | |
120 | #\r | |
121 | # @param XmlFpd An XML DOM object read from FPD file\r | |
122 | #\r | |
123 | # @retvel PlatformSkuIds A platform SkuIds object loaded from XmlFpd\r | |
124 | #\r | |
125 | def LoadPlatformSkuInfos(XmlFpd):\r | |
126 | PlatformSkuIds = SkuInfoListClass()\r | |
127 | \r | |
128 | SkuInfoList = []\r | |
129 | \r | |
130 | XmlTag = "PlatformSurfaceArea/PlatformDefinitions/SkuInfo"\r | |
131 | List = map(LoadSkuId, XmlList(XmlFpd, XmlTag))\r | |
132 | SkuInfoList = List\r | |
133 | \r | |
134 | XmlTag = "PlatformSurfaceArea/PlatformDefinitions/SkuInfo/UiSkuName"\r | |
135 | Value = XmlElement(XmlFpd, XmlTag)\r | |
136 | \r | |
137 | XmlTag = "PlatformSurfaceArea/DynamicPcdBuildDefinitions/PcdBuildData/SkuInfo"\r | |
138 | # here return a List\r | |
139 | List = map(LoadPlatformSkuInfo, XmlList(XmlFpd, XmlTag))\r | |
140 | \r | |
141 | for SkuInfo in List:\r | |
142 | SkuId = SkuInfo[0]\r | |
143 | Value = SkuInfo[1]\r | |
144 | \r | |
145 | SkuInfoList.append(SkuInfo)\r | |
146 | \r | |
147 | PlatformSkuIds.SkuInfoList = SkuInfoList\r | |
148 | \r | |
149 | return PlatformSkuIds\r | |
150 | \r | |
151 | ## Load Platform Module Build Option\r | |
152 | #\r | |
153 | # Read an input Platform XML DOM object and return Platform Module Build Option class object\r | |
154 | # contained in the DOM object.\r | |
155 | #\r | |
156 | # @param XmlModuleBuildOption An XML DOM object read from FPD file\r | |
157 | #\r | |
158 | # @retvel PlatformBuildOption A Platform Build Option object loaded from XmlFpd\r | |
159 | #\r | |
160 | def LoadModuleBuildOption(XmlModuleBuildOption):\r | |
161 | PlatformBuildOption = PlatformBuildOptionClass()\r | |
162 | PlatformBuildOption.UserDefinedAntTasks = {}\r | |
163 | \r | |
164 | XmlTag = "BuildOptions/Options/Option"\r | |
165 | PlatformBuildOption.Options = map(LoadBuildOption, XmlList(XmlModuleBuildOption, XmlTag))\r | |
166 | \r | |
167 | PlatformBuildOption.UserExtensions = {}\r | |
168 | PlatformBuildOption.FfsKeyList = {}\r | |
169 | return PlatformBuildOption\r | |
170 | \r | |
171 | ## Load Platform Module Extern\r | |
172 | #\r | |
173 | # Read an input Platform XML DOM object and return Platform Module Extern class object\r | |
174 | # contained in the DOM object.\r | |
175 | #\r | |
176 | # @param XmlModuleExtern An XML DOM object read from FPD file\r | |
177 | #\r | |
178 | # @retvel PlatformModuleExtern A Platform Module Extern object loaded from XmlFpd\r | |
179 | #\r | |
180 | def LoadModuleExtern(XmlModuleExtern):\r | |
181 | PlatformModuleExtern = []\r | |
182 | \r | |
183 | XmlTag = "Externs/PcdIsDriver"\r | |
184 | PcdIsDriver = XmlElement(XmlModuleExtern, XmlTag)\r | |
185 | PlatformModuleExtern.append(PcdIsDriver)\r | |
186 | \r | |
187 | XmlTag = "Externs/Specification"\r | |
188 | Specification = XmlElement(XmlModuleExtern, XmlTag)\r | |
189 | PlatformModuleExtern.append(Specification)\r | |
190 | \r | |
191 | XmlTag = "Externs/Extern"\r | |
192 | \r | |
193 | return PlatformModuleExtern\r | |
194 | \r | |
195 | ## Load Platform ModuleSaBuildOptions\r | |
196 | #\r | |
197 | # Read an input Platform XML DOM object and return Platform ModuleSaBuildOptions class object\r | |
198 | # contained in the DOM object.\r | |
199 | #\r | |
200 | # @param XmlModuleSaBuildOptions An XML DOM object read from FPD file\r | |
201 | #\r | |
202 | # @retvel PlatformBuildOptions A list of Platform ModuleSaBuildOption object loaded from XmlFpd\r | |
203 | #\r | |
204 | def LoadPlatformModuleSaBuildOption(XmlModuleSA):\r | |
205 | PlatformModuleSaBuildOption = PlatformBuildOptionClasses()\r | |
206 | \r | |
207 | XmlTag = "ModuleSA/ModuleSaBuildOptions/FvBinding"\r | |
208 | PlatformModuleSaBuildOption.FvBinding = XmlElement(XmlModuleSA, XmlTag)\r | |
209 | \r | |
210 | XmlTag = "ModuleSA/ModuleSaBuildOptions/FfsFormatKey"\r | |
211 | PlatformModuleSaBuildOption.FfsFormatKey = XmlElement(XmlModuleSA, XmlTag)\r | |
212 | \r | |
213 | XmlTag = "ModuleSA/ModuleSaBuildOptions/FfsFileNameGuid"\r | |
214 | PlatformModuleSaBuildOption.FfsFileNameGuid = XmlElement(XmlModuleSA, XmlTag)\r | |
215 | \r | |
216 | XmlTag = "ModuleSA/ModuleSaBuildOptions/Options/Option"\r | |
217 | PlatformModuleSaBuildOption.BuildOptionList = map(LoadBuildOption, XmlList(XmlModuleSA, XmlTag))\r | |
218 | \r | |
219 | return PlatformModuleSaBuildOption\r | |
220 | \r | |
221 | ## Load a list of Platform Library Classes\r | |
222 | #\r | |
223 | # Read an input Platform XML DOM object and return a list of Library Classes\r | |
224 | # contained in the DOM object.\r | |
225 | #\r | |
226 | # @param XmlLibraryInstance An XML DOM object read from FPD file\r | |
227 | #\r | |
228 | # @retvel LibraryInstance A Library Instance loaded from XmlFpd\r | |
229 | #\r | |
230 | def LoadPlatformModuleLibraryInstance(XmlLibraryInstance):\r | |
231 | LibraryInstance = []\r | |
232 | \r | |
233 | XmlTag = "ModuleGuid"\r | |
234 | ModuleGuid = XmlAttribute(XmlLibraryInstance, XmlTag)\r | |
235 | \r | |
236 | ModulePath = gEdkIIWorkspaceGuidsInfo.ResolveModuleFilePath(ModuleGuid)\r | |
237 | ModuleMSAFile = ModulePath.replace('.inf', '.msa')\r | |
238 | WorkSpace = os.getenv('WORKSPACE')\r | |
239 | ModuleMSAFileName = os.path.join(WorkSpace, ModuleMSAFile)\r | |
240 | XmlMsa = XmlParseFile(ModuleMSAFileName)\r | |
241 | \r | |
242 | XmlTag = "ModuleSurfaceArea/LibraryClassDefinitions/LibraryClass/Keyword"\r | |
243 | Name = XmlElement(XmlMsa, XmlTag)\r | |
244 | LibraryInstance.append(Name)\r | |
245 | LibraryInstance.append(ModulePath)\r | |
246 | \r | |
247 | #XmlTag = "PackageGuid"\r | |
248 | #PackageGuid = XmlAttribute(XmlLibraryInstance, XmlTag)\r | |
249 | #LibraryInstance.append(PackageGuid)\r | |
250 | return LibraryInstance\r | |
251 | \r | |
252 | ## Load a Library Class\r | |
253 | #\r | |
254 | # Read an input Platform XML DOM object and return a library class object\r | |
255 | # contained in the DOM object.\r | |
256 | #\r | |
257 | # @param XmlLibraryClass An XML DOM object read from FPD file\r | |
258 | #\r | |
259 | # @retvel SupModuleList A Library Class Supported Module List object loaded from XmlFpd\r | |
260 | #\r | |
261 | def LoadLibraryClassSupModuleList(XmlLibraryClass):\r | |
262 | XmlTag = "Usage"\r | |
263 | Usage = XmlAttribute(XmlLibraryClass, XmlTag)\r | |
264 | if Usage == "ALWAYS_PRODUCED":\r | |
265 | XmlTag = "SupModuleList"\r | |
266 | SupModuleList = XmlAttribute(XmlLibraryClass, XmlTag).split()\r | |
267 | return SupModuleList\r | |
268 | \r | |
269 | ## Load Platform Library Class\r | |
270 | #\r | |
271 | # Read an input Platform XML DOM object and return Platform module class object\r | |
272 | # contained in the DOM object.\r | |
273 | #\r | |
274 | # @param XmlLibraries An XML DOM object read from FPD file\r | |
275 | #\r | |
276 | # @retvel PlatformLibraryClass A Platform Library Class object loaded from XmlFpd\r | |
277 | #\r | |
278 | def LoadPlatformLibraryClass(XmlPlatformLibraryClass):\r | |
279 | PlatformLibraryInstance = PlatformLibraryClass()\r | |
280 | \r | |
281 | XmlTag = "ModuleGuid"\r | |
282 | LibraryInstanceModuleGuid = XmlAttribute(XmlPlatformLibraryClass, XmlTag)\r | |
283 | \r | |
284 | XmlTag = "PackageGuid"\r | |
285 | LibraryInstancePackageGuid = XmlAttribute(XmlPlatformLibraryClass, XmlTag)\r | |
286 | \r | |
287 | LibraryInstancePath = gEdkIIWorkspaceGuidsInfo.ResolveModuleFilePath(LibraryInstanceModuleGuid)\r | |
288 | \r | |
289 | if LibraryInstancePath != "": # if LibraryInstancePath == "" that's because the module guid cannot be resolved\r | |
290 | PlatformLibraryInstance.FilePath = LibraryInstancePath\r | |
291 | # replace *.inf to *.msa\r | |
292 | LibraryInstanceMSAName = LibraryInstancePath.replace('.inf', '.msa')\r | |
293 | WorkSpace = os.getenv('WORKSPACE')\r | |
294 | LibraryInstanceMSAPath = os.path.join(WorkSpace, LibraryInstanceMSAName)\r | |
295 | \r | |
296 | PlatformLibraryInstance.FilePath = LibraryInstancePath\r | |
297 | \r | |
298 | XmlMsa = XmlParseFile(LibraryInstanceMSAPath)\r | |
299 | \r | |
300 | XmlTag = "ModuleSurfaceArea/MsaHeader/ModuleName"\r | |
301 | PlatformLibraryInstance.Name = XmlElement(XmlMsa, XmlTag)\r | |
302 | \r | |
303 | XmlTag = "ModuleSurfaceArea/MsaHeader/ModuleType"\r | |
304 | PlatformLibraryInstance.ModuleType = XmlElement(XmlMsa, XmlTag)\r | |
305 | \r | |
306 | if PlatformLibraryInstance.ModuleType != "BASE":\r | |
307 | XmlTag = "ModuleSurfaceArea/LibraryClassDefinitions/LibraryClass"\r | |
308 | List = map(LoadLibraryClassSupModuleList, XmlList(XmlMsa, XmlTag))\r | |
309 | if List != []:\r | |
310 | PlatformLibraryInstance.SupModuleList = List[0]\r | |
311 | XmlTag = "ModuleSurfaceArea/ModuleDefinitions/SupportedArchitectures"\r | |
312 | PlatformLibraryInstance.SupArchList = XmlElement(XmlMsa, XmlTag).split()\r | |
313 | \r | |
314 | PlatformLibraryInstance.ModuleGuid = LibraryInstanceModuleGuid\r | |
315 | \r | |
316 | XmlTag = "ModuleSurfaceArea/MsaHeader/Version"\r | |
317 | PlatformLibraryInstance.ModuleVersion = XmlElement(XmlMsa, XmlTag)\r | |
318 | \r | |
319 | PlatformLibraryInstance.PackageGuid = LibraryInstancePackageGuid\r | |
320 | PlatformLibraryInstance.PackageVersion = ''\r | |
321 | \r | |
322 | return PlatformLibraryInstance\r | |
323 | \r | |
324 | ## Load Platform Library Classes\r | |
325 | #\r | |
326 | # Read an input Platform XML DOM object and return Platform module class object\r | |
327 | # contained in the DOM object.\r | |
328 | #\r | |
329 | # @param XmlLibraries An XML DOM object read from FPD file\r | |
330 | #\r | |
331 | # @retvel PlatformLibraryClasses A list of Platform Library Class object loaded from XmlFpd\r | |
332 | #\r | |
333 | def LoadPlatformLibraryClasses(XmlFpd):\r | |
334 | PlatformLibraryInstances = PlatformLibraryClasses()\r | |
335 | PlatformLibraryInstances.LibraryList = []\r | |
336 | \r | |
337 | List = []\r | |
338 | XmlTag = "PlatformSurfaceArea/FrameworkModules/ModuleSA/Libraries/Instance"\r | |
339 | List = map(LoadPlatformLibraryClass, XmlList(XmlFpd, XmlTag))\r | |
340 | #List.sort()\r | |
341 | if List == []:\r | |
342 | print "Error"\r | |
343 | else:\r | |
344 | PlatformLibraryInstances.LibraryList = List\r | |
345 | \r | |
346 | return PlatformLibraryInstances\r | |
347 | \r | |
348 | ## Load Platform module\r | |
349 | #\r | |
350 | # Read an input Platform XML DOM object and return Platform module class object\r | |
351 | # contained in the DOM object.\r | |
352 | #\r | |
353 | # @param XmlModuleSA An XML DOM object read from FPD file\r | |
354 | #\r | |
355 | # @retvel PlatformModule A Platform module object loaded from XmlFpd\r | |
356 | #\r | |
357 | def LoadModuleSA(XmlModuleSA):\r | |
358 | PlatformModule = PlatformModuleClass()\r | |
359 | \r | |
360 | # three parts: Libraries instances, PcdBuildDefinition, ModuleSaBuildOptions\r | |
361 | XmlTag = "ModuleSA/Libraries/Instance"\r | |
362 | \r | |
363 | PlatformModule.LibraryClasses = map(LoadPlatformModuleLibraryInstance, XmlList(XmlModuleSA, XmlTag))\r | |
364 | \r | |
365 | XmlTag = "ModuleSA/PcdBuildDefinition/PcdData"\r | |
366 | PlatformModule.PcdBuildDefinitions = map(LoadPlatformPcdData, XmlList(XmlModuleSA, XmlTag))\r | |
367 | \r | |
368 | XmlTag = "ModuleSA/ModuleSaBuildOptions"\r | |
369 | PlatformModule.ModuleSaBuildOption = LoadPlatformModuleSaBuildOption(XmlModuleSA)\r | |
370 | \r | |
371 | XmlTag = "ModuleSA/BuildOptions"\r | |
372 | PlatformModule.BuildOptions = map(LoadModuleBuildOption, XmlList(XmlModuleSA, XmlTag)) #bugbug fix me\r | |
373 | \r | |
374 | XmlTag = "ModuleSA/Externs"\r | |
375 | PlatformModule.Externs = map(LoadModuleExtern, XmlList(XmlModuleSA, XmlTag)) #bugbug fix me\r | |
376 | \r | |
377 | XmlTag = "SupArchList"\r | |
378 | PlatformModule.SupArchList = XmlAttribute(XmlModuleSA, XmlTag).split()\r | |
379 | \r | |
380 | # the package guid which the module depends on, do not care for now\r | |
381 | XmlTag = "PackageGuid"\r | |
382 | PlatformModule.PackageGuid = XmlAttribute(XmlModuleSA, XmlTag)\r | |
383 | \r | |
384 | # the module guid, use this guid to get the module *.msa file and convert it to *.inf file with path\r | |
385 | XmlTag = "ModuleGuid"\r | |
386 | PlatformModule.ModuleGuid = XmlAttribute(XmlModuleSA, XmlTag)\r | |
387 | # use this guid to find the *.msa file path or FilePath $(WORKSPACE)/EdkModulePkg/Core/Dxe/DxeMain.msa\r | |
388 | # then convert $(WORKSPACE)/EdkModulePkg/Core/Dxe/DxeMain.msa to $(WORKSPACE)/EdkModulePkg/Core/Dxe/DxeMain.inf, it's FilePath\r | |
389 | PlatformModulePath = gEdkIIWorkspaceGuidsInfo.ResolveModuleFilePath(PlatformModule.ModuleGuid)\r | |
390 | \r | |
391 | PlatformModule.FilePath = PlatformModulePath # *.inf file path\r | |
392 | # *.inf back to *.msa\r | |
393 | ModuleMSAFileName = PlatformModulePath.replace('.inf', '.msa')\r | |
394 | WorkSpace = os.getenv('WORKSPACE')\r | |
395 | ModuleMSAFileName = os.path.join(WorkSpace, ModuleMSAFileName)\r | |
396 | # Open this module\r | |
397 | #ModuleMSA = open(ModuleMSAFileName, "r")\r | |
398 | XmlMsa = XmlParseFile(ModuleMSAFileName)\r | |
399 | \r | |
400 | XmlTag = "ModuleSurfaceArea/MsaHeader/ModuleName"\r | |
401 | PlatformModule.Name = XmlElement(XmlMsa, XmlTag) # ModuleName\r | |
402 | \r | |
403 | XmlTag = "ModuleSurfaceArea/MsaHeader/ModuleType"\r | |
404 | PlatformModule.ModuleType = XmlElement(XmlMsa, XmlTag)\r | |
405 | \r | |
406 | # IA32, X64, IPF and EBC which the module support arch\r | |
407 | #XmlTag = "ModuleSurfaceArea/ModuleDefinitions/SupportedArchitectures"\r | |
408 | #PlatformModule.SupArchList = XmlElement(XmlMsa, XmlTag).split()\r | |
409 | \r | |
410 | #XmlTag = "ModuleSurfaceArea/MsaHeader/"\r | |
411 | PlatformModule.Type = '' #LIBRARY | LIBRARY_CLASS | MODULE, used by dsc. New in DSC spec\r | |
412 | \r | |
413 | PlatformModule.ExecFilePath = '' # New in DSC spec\r | |
414 | \r | |
415 | XmlTag = "ModuleSurfaceArea/MsaHeader/Specification"\r | |
416 | PlatformModule.Specifications = XmlElement(XmlMsa, XmlTag).split()\r | |
417 | \r | |
418 | return PlatformModule\r | |
419 | \r | |
420 | ## Load Platform modules\r | |
421 | #\r | |
422 | # Read an input Platform XML DOM object and return a list of Platform modules class object\r | |
423 | # contained in the DOM object.\r | |
424 | #\r | |
425 | # @param XmlFpd An XML DOM object read from FPD file\r | |
426 | #\r | |
427 | # @retvel PlatformModules A list of Platform modules object loaded from XmlFpd\r | |
428 | #\r | |
429 | def LoadPlatformModules(XmlFpd):\r | |
430 | PlatformModules = PlatformModuleClasses()\r | |
431 | \r | |
432 | XmlTag = "PlatformSurfaceArea/FrameworkModules/ModuleSA"\r | |
433 | PlatformModules.ModuleList = map(LoadModuleSA, XmlList(XmlFpd, XmlTag))\r | |
434 | \r | |
435 | return PlatformModules\r | |
436 | \r | |
437 | ## Load Platform Flash Definition File\r | |
438 | #\r | |
439 | # Read an input Platform XML DOM object and return Platform Flash Definition File class object\r | |
440 | # contained in the DOM object.\r | |
441 | #\r | |
442 | # @param XmlFpd An XML DOM object read from FPD file\r | |
443 | # @param FpdFileName The file path of FPD File\r | |
444 | #\r | |
445 | # @retvel PlatformFlashDefinitionFile A new Platform Flash Definition File object loaded from XmlFpd\r | |
446 | #\r | |
447 | def LoadPlatformFlashDefinitionFile(XmlFpd, FpdFileName):\r | |
448 | PlatformFlashDefinitionFile = PlatformFlashDefinitionFileClass()\r | |
449 | \r | |
450 | XmlTag = "PlatformSurfaceArea/Flash/FlashDefinitionFile"\r | |
451 | PlatformFlashDefinitionFile.FilePath = XmlElement(XmlFpd, XmlTag)\r | |
452 | \r | |
453 | XmlTag = "PlatformSurfaceArea/Flash/FlashDefinitionFile/Id"\r | |
454 | PlatformFlashDefinitionFile.Id = XmlAttribute(XmlFpd, XmlTag)\r | |
455 | \r | |
456 | XmlTag = "PlatformSurfaceArea/Flash/FlashDefinitionFile/UiName"\r | |
457 | PlatformFlashDefinitionFile.UiName = XmlAttribute(XmlFpd, XmlTag)\r | |
458 | \r | |
459 | XmlTag = "PlatformSurfaceArea/Flash/FlashDefinitionFile/Preferred"\r | |
460 | PlatformFlashDefinitionFile.Preferred = XmlAttribute(XmlFpd, XmlTag)\r | |
461 | \r | |
462 | return PlatformFlashDefinitionFile\r | |
463 | \r | |
464 | ## Load Platform User Defined Ant Tasks\r | |
465 | #\r | |
466 | # Read an input Platform XML DOM object and return platform\r | |
467 | # User Defined Ant Tasks contained in the DOM object.\r | |
468 | #\r | |
469 | # @param XmlUserDefinedAntTasks An XML DOM object read from FPD file\r | |
470 | #\r | |
471 | # @retvel AntTask An Ant Task loaded from XmlFpd\r | |
472 | #\r | |
473 | def LoadUserDefinedAntTasks(XmlFpd):\r | |
474 | Dict = {}\r | |
475 | AntTask = PlatformAntTaskClass()\r | |
476 | \r | |
477 | XmlTag = "PlatformSurfaceArea/BuildOptions/UserDefinedAntTasks/AntTask/Id"\r | |
478 | AntTask.Id = XmlAttribute(XmlFpd, XmlTag)\r | |
479 | \r | |
480 | XmlTag = "PlatformSurfaceArea/BuildOptions/UserDefinedAntTasks/AntTask/AntCmdOptions"\r | |
481 | AntTask.AntCmdOptions = XmlElement(XmlFpd, XmlTag)\r | |
482 | \r | |
483 | XmlTag = "PlatformSurfaceArea/BuildOptions/UserDefinedAntTasks/AntTask/Filename"\r | |
484 | AntTask.FilePath = XmlElement(XmlFpd, XmlTag)\r | |
485 | \r | |
486 | Dict[AntTask.Id] = AntTask\r | |
487 | return Dict\r | |
488 | \r | |
489 | ## Load Platform Build Options\r | |
490 | #\r | |
491 | # Read an input Platform XML DOM object and return a list of platform\r | |
492 | # Build Option contained in the DOM object.\r | |
493 | #\r | |
494 | # @param XmlBuildOptions An XML DOM object read from FPD file\r | |
495 | #\r | |
496 | # @retvel PlatformBuildOptions A list of platform Build Options loaded from XmlFpd\r | |
497 | #\r | |
498 | def LoadBuildOptions(XmlBuildOptions):\r | |
499 | XmlTag = "Option"\r | |
500 | return map(LoadBuildOption, XmlList(XmlBuildOptions, XmlTag)) # LoadBuildOption is a method in MigrationUtilities.py\r | |
501 | \r | |
502 | ## Load Platform Build Option\r | |
503 | #\r | |
504 | # Read an input Platform XML DOM object and return a Build Option\r | |
505 | # contained in the DOM object.\r | |
506 | #\r | |
507 | # @param XmlFpd An XML DOM object read from FPD file\r | |
508 | #\r | |
509 | # @retvel PlatformBuildOption A Build Options loaded from XmlFpd\r | |
510 | #\r | |
511 | def LoadPlatformBuildOption(XmlBuildOptions):\r | |
512 | PlatformBuildOption = PlatformBuildOptionClass()\r | |
513 | \r | |
514 | # handle UserDefinedAntTasks\r | |
515 | XmlTag = "BuildOptions/UserDefinedAntTasks/AntTask"\r | |
516 | PlatformBuildOption.UserDefinedAntTasks = LoadUserDefinedAntTasks(XmlTag)\r | |
517 | \r | |
518 | # handle Options\r | |
519 | XmlTag = "BuildOptions/Options/Option"\r | |
520 | PlatformBuildOption.Options = map(LoadBuildOption, XmlList(XmlBuildOptions, XmlTag))\r | |
521 | \r | |
522 | # handle UserExtensions\r | |
523 | XmlTag = "BuildOptions/UserExtensions"\r | |
524 | PlatformBuildOption.UserExtensions = LoadUserExtensions(XmlTag) # from MigrationUtilities.py LoadUserExtensions\r | |
525 | \r | |
526 | # handle Ffs\r | |
527 | XmlTag = "BuildOptions/Ffs/FfsKey"\r | |
528 | PlatformBuildOption.FfsKeyList = map(LoadPlatformFfs, XmlList(XmlBuildOptions, XmlTag))\r | |
529 | \r | |
530 | return PlatformBuildOption\r | |
531 | \r | |
532 | ## Load Platform Ffs Dictionary\r | |
533 | #\r | |
534 | # Read an input Platform XML DOM object and return a platform Ffs Dictionary\r | |
535 | # contained in the DOM object.\r | |
536 | #\r | |
537 | # @param XmlFpd An XML DOM object read from FPD file\r | |
538 | #\r | |
539 | # @retvel Dict A platform Ffs Dict loaded from XmlFpd\r | |
540 | #\r | |
541 | def LoadPlatformFfsDict(XmlFpd):\r | |
542 | Dict = {}\r | |
543 | XmlTag = "PlatformSurfaceArea/BuildOptions/Ffs"\r | |
544 | List = map(LoadPlatformFfs, XmlList(XmlFpd, XmlTag))\r | |
545 | if List != []:\r | |
546 | for Ffs in List:\r | |
547 | Dict[Ffs.Key] = Ffs\r | |
548 | return Dict\r | |
549 | \r | |
550 | ## Load Platform Ffs Section\r | |
551 | #\r | |
552 | # Read an input Platform XML DOM object and return a platform Ffs Section\r | |
553 | # contained in the DOM object.\r | |
554 | #\r | |
555 | # @param XmlFfs An XML DOM object read from FPD file\r | |
556 | #\r | |
557 | # @retvel PlatformFfsSection A platform Ffs Section loaded from XmlFpd\r | |
558 | #\r | |
559 | def LoadPlatformFfsSection(XmlFfsSection):\r | |
560 | PlatformFfsSection = PlatformFfsSectionClass()\r | |
561 | \r | |
562 | XmlTag = ""\r | |
563 | PlatformFfsSection.BindingOrder = ''\r | |
564 | \r | |
565 | XmlTag = ""\r | |
566 | PlatformFfsSection.Compressible = ''\r | |
567 | \r | |
568 | XmlTag = "SectionType"\r | |
569 | PlatformFfsSection.SectionType = XmlAttribute(XmlFfsSection, XmlTag)\r | |
570 | \r | |
571 | XmlTag = ""\r | |
572 | PlatformFfsSection.EncapsulationType = ''\r | |
573 | \r | |
574 | XmlTag = ""\r | |
575 | PlatformFfsSection.ToolName = ''\r | |
576 | \r | |
577 | XmlTag = ""\r | |
578 | PlatformFfsSection.Filenames = []\r | |
579 | \r | |
580 | XmlTag = ""\r | |
581 | PlatformFfsSection.Args = ''\r | |
582 | \r | |
583 | XmlTag = ""\r | |
584 | PlatformFfsSection.OutFile = ''\r | |
585 | \r | |
586 | XmlTag = ""\r | |
587 | PlatformFfsSection.OutputFileExtension = ''\r | |
588 | \r | |
589 | XmlTag = ""\r | |
590 | PlatformFfsSection.ToolNameElement = ''\r | |
591 | \r | |
592 | return PlatformFfsSection\r | |
593 | \r | |
594 | ## Load Platform Ffs Sections\r | |
595 | #\r | |
596 | # Read an input Platform XML DOM object and return a platform Ffs Sections\r | |
597 | # contained in the DOM object.\r | |
598 | #\r | |
599 | # @param XmlFfs An XML DOM object read from FPD file\r | |
600 | #\r | |
601 | # @retvel PlatformFfsSections A platform Ffs Sections loaded from XmlFpd\r | |
602 | #\r | |
603 | def LoadFfsSections():\r | |
604 | PlatformFfsSections = PlatformFfsSectionsClass()\r | |
605 | PlatformFfsSections.BindingOrder = ''\r | |
606 | PlatformFfsSections.Compressible = ''\r | |
607 | PlatformFfsSections.SectionType = ''\r | |
608 | PlatformFfsSections.EncapsulationType = ''\r | |
609 | PlatformFfsSections.ToolName = ''\r | |
610 | PlatformFfsSections.Section = []\r | |
611 | PlatformFfsSections.Sections = []\r | |
612 | \r | |
613 | return PlatformFfsSections\r | |
614 | \r | |
615 | ## Load Platform Ffs Sections\r | |
616 | #\r | |
617 | # Read an input Platform XML DOM object and return a platform Ffs Sections\r | |
618 | # contained in the DOM object.\r | |
619 | #\r | |
620 | # @param XmlFfs An XML DOM object read from FPD file\r | |
621 | #\r | |
622 | # @retvel PlatformFfsSections A platform Ffs Sections loaded from XmlFpd\r | |
623 | #\r | |
624 | def LoadPlatformFfsSections(XmlFfsSections):\r | |
625 | PlatformFfsSections = PlatformFfsSectionsClass()\r | |
626 | \r | |
627 | XmlTag = ""\r | |
628 | PlatformFfsSections.BindingOrder = ''\r | |
629 | \r | |
630 | XmlTag = ""\r | |
631 | Compressible = ''\r | |
632 | \r | |
633 | XmlTag = ""\r | |
634 | SectionType = ''\r | |
635 | \r | |
636 | XmlTag = "EncapsulationType"\r | |
637 | EncapsulationType = XmlAttribute(XmlFfsSections, XmlTag)\r | |
638 | \r | |
639 | XmlTag = ""\r | |
640 | ToolName = ''\r | |
641 | \r | |
642 | XmlTag = "Sections/Section"\r | |
643 | Section = [] #[ PlatformFfsSectionClass, ... ]\r | |
644 | Section = map(LoadPlatformFfsSection, XmlList(XmlFfsSections, XmlTag))\r | |
645 | \r | |
646 | \r | |
647 | XmlTag = "Sections/Sections"\r | |
648 | Sections = map(LoadFfsSections, XmlList(XmlFfsSections, XmlTag)) #[ PlatformFfsSectionsClass, ...]\r | |
649 | \r | |
650 | return PlatformFfsSections\r | |
651 | \r | |
652 | ## Load Platform Ffs Attribute\r | |
653 | #\r | |
654 | # Read an input Platform XML DOM object and return a platform Ffs Attribute\r | |
655 | # contained in the DOM object.\r | |
656 | #\r | |
657 | # @param XmlFfs An XML DOM object read from FPD file\r | |
658 | #\r | |
659 | # @retvel List A platform Ffs Attribute loaded from XmlFpd\r | |
660 | #\r | |
661 | def LoadFfsAttribute(XmlFfs):\r | |
662 | List = []\r | |
663 | XmlTag = "Ffs/Attribute"\r | |
664 | for XmlAttr in XmlList(XmlFfs, XmlTag):\r | |
665 | XmlTag = "Name"\r | |
666 | Name = XmlAttribute(XmlAttr, XmlTag)\r | |
667 | XmlTag = "Value"\r | |
668 | Value = XmlAttribute(XmlAttr, XmlTag)\r | |
669 | List.append([Name,Value])\r | |
670 | return List\r | |
671 | \r | |
672 | ## Load a list of Platform Build Options\r | |
673 | #\r | |
674 | # Read an input Platform XML DOM object and return a list of Build Options\r | |
675 | # contained in the DOM object.\r | |
676 | #\r | |
677 | # @param XmlFfs An XML DOM object read from FPD file\r | |
678 | #\r | |
679 | # @retvel PlatformFfsKey A platform Ffs key loaded from XmlFpd\r | |
680 | #\r | |
681 | def LoadPlatformFfs(XmlFfs):\r | |
682 | PlatformFfs = PlatformFfsClass()\r | |
683 | \r | |
684 | PlatformFfs.Attribute = {}\r | |
685 | Dict = {}\r | |
686 | \r | |
687 | List = LoadFfsAttribute(XmlFfs)\r | |
688 | \r | |
689 | XmlTag = "Ffs/Sections/Sections"\r | |
690 | PlatformFfs.Sections = map(LoadPlatformFfsSections, XmlList(XmlFfs, XmlTag)) #[PlatformFfsSectionsClass, ...]\r | |
691 | \r | |
692 | for Item in List:\r | |
693 | Name = Item[0]\r | |
694 | Value = Item[1]\r | |
695 | for Item in PlatformFfs.Sections:\r | |
696 | Dict[(Name, Item)] = Value\r | |
697 | PlatformFfs.Attribute = Dict\r | |
698 | \r | |
699 | XmlTag = "Ffs/FfsKey"\r | |
700 | PlatformFfs.Key = XmlAttribute(XmlFfs, XmlTag)\r | |
701 | \r | |
702 | return PlatformFfs\r | |
703 | \r | |
704 | ## Load a list of Platform Build Options\r | |
705 | #\r | |
706 | # Read an input Platform XML DOM object and return a list of Build Options\r | |
707 | # contained in the DOM object.\r | |
708 | #\r | |
709 | # @param XmlFpd An XML DOM object read from FPD file\r | |
710 | #\r | |
711 | # @retvel PlatformBuildOptions A list of Build Options loaded from XmlFpd\r | |
712 | #\r | |
713 | def LoadPlatformBuildOptions(XmlFpd):\r | |
714 | PlatformBuildOptions = PlatformBuildOptionClass()\r | |
715 | \r | |
716 | PlatformBuildOptions.UserDefinedAntTasks = LoadUserDefinedAntTasks(XmlFpd)\r | |
717 | \r | |
718 | XmlTag = "PlatformSurfaceArea/BuildOptions/Options/Option"\r | |
719 | PlatformBuildOptions.Options = map(LoadBuildOption, XmlList(XmlFpd, XmlTag))\r | |
720 | \r | |
721 | PlatformBuildOptions.UserExtensions = LoadPlatformUserExtension(XmlFpd)\r | |
722 | \r | |
723 | PlatformBuildOptions.FfsKeyList = LoadPlatformFfsDict(XmlFpd)\r | |
724 | \r | |
725 | return PlatformBuildOptions\r | |
726 | \r | |
727 | ## Load Platform Pcd Data\r | |
728 | #\r | |
729 | # Read an input Platform XML DOM object and return Platform module class object\r | |
730 | # contained in the DOM object.\r | |
731 | #\r | |
732 | # @param XmlPcd An XML DOM object read from FPD file\r | |
733 | #\r | |
734 | # @retvel PlatformPcdData A Platform Pcd object loaded from XmlFpd\r | |
735 | #\r | |
736 | def LoadPlatformPcdData(XmlPcdData):\r | |
737 | PcdData = PcdClass() # defined in CommonDataClass.CommonClass.py\r | |
738 | \r | |
739 | XmlTag = "ItemType"\r | |
740 | PcdData.ItemType = XmlAttribute(XmlPcdData, XmlTag) #DYNAMIC\r | |
741 | \r | |
742 | XmlTag = "PcdData/C_Name"\r | |
743 | PcdData.C_NAME = XmlElement(XmlPcdData, XmlTag)\r | |
744 | \r | |
745 | XmlTag = "PcdData/Token"\r | |
746 | PcdData.Token = XmlElement(XmlPcdData, XmlTag)\r | |
747 | \r | |
748 | XmlTag = "PcdData/TokenSpaceGuidCName"\r | |
749 | PcdData.TokenSpaceGuidCName = XmlElement(XmlPcdData, XmlTag)\r | |
750 | \r | |
751 | XmlTag = "PcdData/DatumType"\r | |
752 | PcdData.DatumType = XmlElement(XmlPcdData, XmlTag)\r | |
753 | \r | |
754 | XmlTag = "PcdData/MaxDatumSize"\r | |
755 | PcdData.MaxDatumSize = XmlElement(XmlPcdData, XmlTag)\r | |
756 | \r | |
757 | XmlTag = "PcdData/Value"\r | |
758 | PcdData.Value = XmlElement(XmlPcdData, XmlTag)\r | |
759 | \r | |
760 | return PcdData\r | |
761 | \r | |
762 | ## Load a Platform Pcd Build Data\r | |
763 | #\r | |
764 | # Read an input Platform XML DOM object and return a list of Pcd Dynamic\r | |
765 | # contained in the DOM object.\r | |
766 | #\r | |
767 | # @param XmlPcdBuildData An XML DOM object read from FPD file\r | |
768 | #\r | |
769 | # @retvel PcdBuildData A Platform Pcd Build Data loaded from XmlFpd\r | |
770 | #\r | |
771 | def LoadPlatformPcdBuildData(XmlPcdBuildData):\r | |
772 | PcdBuildData = PcdClass() # defined in CommonDataClass.CommonClass.py\r | |
773 | \r | |
774 | XmlTag = "ItemType"\r | |
775 | PcdBuildData.ItemType = XmlAttribute(XmlPcdBuildData, XmlTag) #DYNAMIC\r | |
776 | \r | |
777 | XmlTag = "PcdBuildData/C_Name"\r | |
778 | PcdBuildData.C_NAME = XmlElement(XmlPcdBuildData, XmlTag)\r | |
779 | \r | |
780 | XmlTag = "PcdBuildData/Token"\r | |
781 | PcdBuildData.Token = XmlElement(XmlPcdBuildData, XmlTag)\r | |
782 | \r | |
783 | XmlTag = "PcdBuildData/TokenSpaceGuidCName"\r | |
784 | PcdBuildData.TokenSpaceGuidCName = XmlElement(XmlPcdBuildData, XmlTag)\r | |
785 | \r | |
786 | XmlTag = "PcdBuildData/DatumType"\r | |
787 | PcdBuildData.DatumType = XmlElement(XmlPcdBuildData, XmlTag)\r | |
788 | \r | |
789 | XmlTag = "PcdBuildData/MaxDatumSize"\r | |
790 | PcdBuildData.MaxDatumSize = XmlElement(XmlPcdBuildData, XmlTag)\r | |
791 | \r | |
792 | #XmlTag = "PcdBuildData/Value"\r | |
793 | #PcdBuildData.Value = XmlElement(XmlPcdBuildData, XmlTag)\r | |
794 | \r | |
795 | return PcdBuildData\r | |
796 | \r | |
797 | ## Load a list of Platform Pcd Dynamic\r | |
798 | #\r | |
799 | # Read an input Platform XML DOM object and return a list of Pcd Dynamic\r | |
800 | # contained in the DOM object.\r | |
801 | #\r | |
802 | # @param XmlFpd An XML DOM object read from FPD file\r | |
803 | #\r | |
804 | # @retvel PcdDynamic A list of Pcd Dynamic loaded from XmlFpd\r | |
805 | #\r | |
806 | def LoadDynamicPcdBuildDefinitions(XmlFpd):\r | |
807 | DynamicPcdBuildDefinitions = []\r | |
808 | XmlTag = "PlatformSurfaceArea/DynamicPcdBuildDefinitions/PcdBuildData"\r | |
809 | return map(LoadPlatformPcdBuildData, XmlList(XmlFpd, XmlTag))\r | |
810 | \r | |
811 | ## Load a Platform NameValue object\r | |
812 | #\r | |
813 | # Read an input Platform XML DOM object and return a list of User Extensions\r | |
814 | # contained in the DOM object.\r | |
815 | #\r | |
816 | # @param XmlNameValue An XML DOM object read from FPD file\r | |
817 | #\r | |
818 | # @retvel NameValue A Platform NameValue object\r | |
819 | #\r | |
820 | def LoadNameValue(XmlNameValue):\r | |
821 | NameValue = []\r | |
822 | \r | |
823 | XmlTag = "Name"\r | |
824 | Name = XmlAttribute(XmlNameValue, XmlTag)\r | |
825 | NameValue.append(Name)\r | |
826 | \r | |
827 | XmlTag = "Value"\r | |
828 | Value = XmlAttribute(XmlNameValue, XmlTag)\r | |
829 | NameValue.append(Value)\r | |
830 | \r | |
831 | return NameValue\r | |
832 | \r | |
833 | ## Load a Platform Fv Image Name object\r | |
834 | #\r | |
835 | # Read an input Platform XML DOM object and return a platform Fv Image\r | |
836 | # Name contained in the DOM object.\r | |
837 | #\r | |
838 | # @param XmlFvImageNames An XML DOM object read from FPD file\r | |
839 | #\r | |
840 | # @retvel FvImageNames A Platform Fv Image Name object\r | |
841 | #\r | |
842 | def LoadFvImageNames(XmlFvImageNames):\r | |
843 | XmlTag = "FvImageNames"\r | |
844 | FvImageNames = XmlElement(XmlFvImageNames, XmlTag)\r | |
845 | return FvImageNames\r | |
846 | \r | |
847 | ## Load a Platform Fv Image option object\r | |
848 | #\r | |
849 | # Read an input Platform XML DOM object and return a platform Fv Image\r | |
850 | # Option contained in the DOM object.\r | |
851 | #\r | |
852 | # @param XmlFvImageOptions An XML DOM object read from FPD file\r | |
853 | #\r | |
854 | # @retvel PlatformFvImageOption A Platform Fv Image Option object\r | |
855 | #\r | |
856 | def LoadFvImageOptions(XmlFvImageOptions):\r | |
857 | PlatformFvImageOption = PlatformFvImageOptionClass()\r | |
858 | \r | |
859 | XmlTag = ""\r | |
860 | PlatformFvImageOption.FvImageOptionName = ''\r | |
861 | \r | |
862 | XmlTag = ""\r | |
863 | PlatformFvImageOption.FvImageOptionValues = []\r | |
864 | \r | |
865 | XmlTag = "FvImageOptions/NameValue"\r | |
866 | List = map(LoadNameValue, XmlList(XmlFvImageOptions, XmlTag))\r | |
867 | \r | |
868 | return PlatformFvImageOption\r | |
869 | \r | |
870 | ## Load a Platform Fv Image object\r | |
871 | #\r | |
872 | # Read an input Platform XML DOM object and return a list of User Extensions\r | |
873 | # contained in the DOM object.\r | |
874 | #\r | |
875 | # @param XmlFvImage An XML DOM object read from Fpd file\r | |
876 | #\r | |
877 | # @retvel PlatformFvImage A Platform Fv Image object\r | |
878 | #\r | |
879 | def LoadPlatformFvImage(XmlFvImage):\r | |
880 | PlatformFvImage = PlatformFvImageClass()\r | |
881 | \r | |
882 | XmlTag = "Name"\r | |
883 | PlatformFvImage.Name = XmlAttribute(XmlFvImage, XmlTag)\r | |
884 | \r | |
885 | XmlTag = "Value"\r | |
886 | PlatformFvImage.Value = XmlAttribute(XmlFvImage, XmlTag)\r | |
887 | \r | |
888 | XmlTag = "Type"\r | |
889 | PlatformFvImage.Type = XmlAttribute(XmlFvImage, XmlTag)\r | |
890 | \r | |
891 | XmlTag = "FvImage/FvImageNames"\r | |
892 | PlatformFvImage.FvImageNames = map(LoadFvImageNames, XmlList(XmlFvImage, XmlTag))\r | |
893 | \r | |
894 | XmlTag = "FvImage/FvImageOptions"\r | |
895 | PlatformFvImage.FvImageOptions = map(LoadFvImageOptions, XmlList(XmlFvImage, XmlTag))\r | |
896 | \r | |
897 | return PlatformFvImage\r | |
898 | \r | |
899 | ## Load a Platform fdf object\r | |
900 | #\r | |
901 | # Read an input Platform XML DOM object and return a list of User Extensions\r | |
902 | # contained in the DOM object.\r | |
903 | #\r | |
904 | # @param XmlFvImages An XML DOM object read from FPD file\r | |
905 | #\r | |
906 | # @retvel PlatformFdf A Platform fdf object\r | |
907 | #\r | |
908 | def LoadPlatformFvImages(XmlFvImages):\r | |
909 | List = []\r | |
910 | \r | |
911 | XmlTag = "FvImages/NameValue"\r | |
912 | NameValues = map(LoadNameValue, XmlList(XmlFvImages, XmlTag))\r | |
913 | List.append(NameValues)\r | |
914 | \r | |
915 | XmlTag = "FvImages/FvImage"\r | |
916 | FvImages = map(LoadPlatformFvImage, XmlList(XmlFvImages, XmlTag))\r | |
917 | List.append(FvImages)\r | |
918 | \r | |
919 | XmlTag = "FvImages/FvImageName"\r | |
920 | FvImageNames = map(LoadPlatformFvImageName, XmlList(XmlFvImages, XmlTag))\r | |
921 | List.append(FvImageNames)\r | |
922 | \r | |
923 | return List\r | |
924 | \r | |
925 | ## Load a Platform Fv Image Name object\r | |
926 | #\r | |
927 | # Read an input Platform XML DOM object and return a list of User Extensions\r | |
928 | # contained in the DOM object.\r | |
929 | #\r | |
930 | # @param XmlFvImageName An XML DOM object read from FPD file\r | |
931 | #\r | |
932 | # @retvel PlatformFvImageName A Platform Fv Image Name object\r | |
933 | #\r | |
934 | def LoadPlatformFvImageName(XmlFvImageName):\r | |
935 | PlatformFvImageName = PlatformFvImageNameClass()\r | |
936 | \r | |
937 | XmlTag = "Name"\r | |
938 | PlatformFvImageName.Name = XmlAttribute(XmlFvImageName, XmlTag)\r | |
939 | \r | |
940 | XmlTag = "Type"\r | |
941 | PlatformFvImageName.Type = XmlAttribute(XmlFvImageName, XmlTag)\r | |
942 | \r | |
943 | XmlTag = "FvImageOptions"\r | |
944 | PlatformFvImageName.FvImageOptions = map(LoadFvImageOptions, XmlList(XmlFvImageName, XmlTag))\r | |
945 | \r | |
946 | return PlatformFvImageName\r | |
947 | \r | |
948 | ## Load a list of Platform fdf objects\r | |
949 | #\r | |
950 | # Read an input Platform XML DOM object and return a list of User Extensions\r | |
951 | # contained in the DOM object.\r | |
952 | #\r | |
953 | # @param XmlFpd An XML DOM object read from FPD file\r | |
954 | #\r | |
955 | # @retvel PlatformFdfs A list of Platform fdf object\r | |
956 | #\r | |
957 | def LoadPlatformFdfs(XmlFpd):\r | |
958 | PlatformFvImages = PlatformFvImagesClass()\r | |
959 | \r | |
960 | XmlTag = "PlatformSurfaceArea/Flash/FvImages"\r | |
961 | PlatformFvImages.FvImages = map(LoadPlatformFvImages, XmlList(XmlFpd, XmlTag))\r | |
962 | \r | |
963 | return PlatformFvImages\r | |
964 | \r | |
965 | ## Load a Platform User Extensions\r | |
966 | #\r | |
967 | # Read an input Platform XML DOM object and return an User Extension\r | |
968 | # contained in the DOM object.\r | |
969 | #\r | |
970 | # @param XmlUserExtension An XML DOM object read from FPD file\r | |
971 | #\r | |
972 | # @retvel PlatformUserExtensions A platform User Extension loaded from XmlFpd\r | |
973 | #\r | |
974 | def LoadPlatformUserExtension(XmlFpd):\r | |
975 | Dict = {}\r | |
976 | \r | |
977 | PlatformUserExtensions = UserExtensionsClass()\r | |
978 | \r | |
979 | XmlTag = "PlatformSurfaceArea/BuildOptions/UserExtensions"\r | |
980 | List = map(LoadUserExtensions, XmlList(XmlFpd, XmlTag))\r | |
981 | if List != []:\r | |
982 | for Item in List:\r | |
983 | UserID = Item.UserID\r | |
984 | Identifier = Item.Identifier\r | |
985 | Dict[(UserID, Identifier)] = Item\r | |
986 | #XmlTag = "PlatformSurfaceArea/BuildOptions/UserExtensions/UserID"\r | |
987 | #PlatformUserExtensions.UserID = XmlAttribute(XmlFpd, XmlTag)\r | |
988 | \r | |
989 | #XmlTag = "PlatformSurfaceArea/BuildOptions/UserExtensions/Identifier"\r | |
990 | #PlatformUserExtensions.Identifier = XmlAttribute(XmlFpd, XmlTag)\r | |
991 | \r | |
992 | #PlatformUserExtensions.Content = XmlElementData(XmlFpd)\r | |
993 | #Dict[(PlatformUserExtensions.UserID,PlatformUserExtensions.Identifier)] = PlatformUserExtensions\r | |
994 | #return PlatformUserExtensions\r | |
995 | return Dict\r | |
996 | \r | |
997 | ## Load a list of Platform User Extensions\r | |
998 | #\r | |
999 | # Read an input Platform XML DOM object and return a list of User Extensions\r | |
1000 | # contained in the DOM object.\r | |
1001 | #\r | |
1002 | # @param XmlFpd An XML DOM object read from FPD file\r | |
1003 | #\r | |
1004 | # @retvel UserExtensions A list of platform User Extensions loaded from XmlFpd\r | |
1005 | #\r | |
1006 | def LoadPlatformUserExtensions(XmlFpd):\r | |
1007 | XmlTag = "PlatformSurfaceArea/UserExtensions"\r | |
1008 | return map(LoadUserExtensions, XmlList(XmlFpd, XmlTag)) # from MigrationUtilities.py LoadUserExtensions\r | |
1009 | \r | |
1010 | ## Load a new Platform class object\r | |
1011 | #\r | |
1012 | # Read an input FPD File and return a new Platform class Object.\r | |
1013 | #\r | |
1014 | # @param FpdFileName An XML DOM object read from FPD file\r | |
1015 | #\r | |
1016 | # @retvel Platform A new Platform class object loaded from FPD File\r | |
1017 | #\r | |
1018 | def LoadFpd(FpdFileName):\r | |
1019 | XmlFpd = XmlParseFile(FpdFileName)\r | |
1020 | EdkLogger.verbose("Load FPD File: %s" % FpdFileName)\r | |
1021 | \r | |
1022 | Platform = PlatformClass()\r | |
1023 | Platform.Header = LoadPlatformHeader(XmlFpd, FpdFileName)\r | |
1024 | Platform.SkuInfos = LoadPlatformSkuInfos(XmlFpd)\r | |
1025 | Platform.Libraries = [] #New in dsc spec, do not handle for now\r | |
1026 | Platform.LibraryClasses = LoadPlatformLibraryClasses(XmlFpd)\r | |
1027 | Platform.Modules = LoadPlatformModules(XmlFpd)\r | |
1028 | Platform.FlashDefinitionFile = LoadPlatformFlashDefinitionFile(XmlFpd, FpdFileName)\r | |
1029 | Platform.BuildOptions = LoadPlatformBuildOptions(XmlFpd)\r | |
1030 | Platform.DynamicPcdBuildDefinitions = LoadDynamicPcdBuildDefinitions(XmlFpd)\r | |
1031 | Platform.Fdf = LoadPlatformFdfs(XmlFpd)\r | |
1032 | Platform.UserExtensions = LoadPlatformUserExtensions(XmlFpd)\r | |
1033 | \r | |
1034 | return Platform\r | |
1035 | \r | |
1036 | # This acts like the main() function for the script, unless it is 'import'ed\r | |
1037 | # into another script.\r | |
1038 | if __name__ == '__main__':\r | |
1039 | pass |