]> git.proxmox.com Git - mirror_edk2.git/blob - BaseTools/Source/Python/msa2inf/LoadMsa.py
Check In tool source code based on Build tool project revision r1655.
[mirror_edk2.git] / BaseTools / Source / Python / msa2inf / LoadMsa.py
1 ## @file
2 # Open an MSA file and load all its contents to a ModuleClass object.
3 #
4 # Copyright (c) 2007, Intel Corporation
5 # All rights reserved. This program and the accompanying materials
6 # are licensed and made available under the terms and conditions of the BSD License
7 # which accompanies this distribution. The full text of the license may be found at
8 # http://opensource.org/licenses/bsd-license.php
9 #
10 # THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
11 # WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
12 #
13
14 ##
15 # Import Modules
16 #
17 import os
18 from CommonDataClass.ModuleClass import *
19 from Common.XmlRoutines import *
20 from Common.MigrationUtilities import *
21
22
23 ## Load a list of Module Cloned Records.
24 #
25 # Read an input Module XML DOM object and return a list of Cloned Records
26 # contained in the DOM object.
27 #
28 # @param XmlMsa An XML DOM object read from MSA file.
29 #
30 # @retvel ClonedRecords A list of Cloned Records loaded from XmlMsa.
31 #
32 def LoadModuleClonedRecords(XmlMsa):
33 XmlTag = "ModuleSurfaceArea/ModuleDefinitions/ClonedFrom/Cloned"
34 return map(LoadClonedRecord, XmlList(XmlMsa, XmlTag))
35
36 ## Load Module Header.
37 #
38 # Read an input Module XML DOM object and return Module Header class object
39 # contained in the DOM object.
40 #
41 # @param XmlMsa An XML DOM object read from MSA file.
42 # @param MsaFileName The file path of MSA File.
43 #
44 # @retvel ModuleHeader A new Module Header object loaded from XmlMsa.
45 #
46 def LoadModuleHeader(XmlMsa, MsaFileName):
47 ModuleHeader = ModuleHeaderClass()
48
49 XmlTag = "ModuleSurfaceArea/MsaHeader"
50 MsaHeader = XmlNode(XmlMsa, XmlTag)
51
52 SetIdentification(ModuleHeader, MsaHeader, "ModuleName", MsaFileName)
53 SetCommonHeader(ModuleHeader, MsaHeader)
54
55 XmlTag = "ModuleSurfaceArea/ModuleDefinitions/SupportedArchitectures"
56 ModuleHeader.SupArchList = XmlElement(XmlMsa, XmlTag).split()
57
58 XmlTag = "ModuleSurfaceArea/ModuleDefinitions/BinaryModule"
59 if XmlElement(XmlMsa, XmlTag).lower() == "true":
60 ModuleHeader.BinaryModule = True
61
62 XmlTag = "ModuleSurfaceArea/ModuleDefinitions/OutputFileBasename"
63 ModuleHeader.OutputFileBasename = XmlElement(XmlMsa, XmlTag)
64
65 XmlTag = "ModuleSurfaceArea/ModuleDefinitions/ClonedForm"
66 ModuleHeader.ClonedFrom = LoadModuleClonedRecords(XmlMsa)
67
68 XmlTag = "ModuleSurfaceArea/Externs/PcdDriverTypes"
69 ModuleHeader.PcdIsDriver = XmlElement(XmlMsa, XmlTag)
70
71 XmlTag = "ModuleSurfaceArea/Externs/TianoR8FlashMap_h"
72 if XmlElement(XmlMsa, XmlTag).lower() == "true":
73 ModuleHeader.TianoR8FlashMap_h = True
74
75 XmlTag = "ModuleSurfaceArea/Externs/Specification"
76 for Specification in XmlElementList(XmlMsa, XmlTag):
77 AddToSpecificationDict(ModuleHeader.Specification, Specification)
78
79 return ModuleHeader
80
81
82 ## Load a list of Module Library Classes.
83 #
84 # Read an input Module XML DOM object and return a list of Library Classes
85 # contained in the DOM object.
86 #
87 # @param XmlMsa An XML DOM object read from MSA file.
88 #
89 # @retvel LibraryClasses A list of Library Classes loaded from XmlMsa.
90 #
91 def LoadModuleLibraryClasses(XmlMsa):
92 XmlTag = "ModuleSurfaceArea/LibraryClassDefinitions/LibraryClass"
93 return map(LoadLibraryClass, XmlList(XmlMsa, XmlTag))
94
95
96 ## Load a new Module Source class object.
97 #
98 # Read an input XML Source DOM object and return an object of Source
99 # contained in the DOM object.
100 #
101 # @param XmlFilename A child XML DOM object in Module XML DOM.
102 #
103 # @retvel ModuleSource A new Source object created by XmlFilename.
104 #
105 def LoadModuleSource(XmlFilename):
106 ModuleSource = ModuleSourceFileClass()
107
108 ModuleSource.SourceFile = XmlElementData(XmlFilename)
109
110 XmlTag = "TagName"
111 ModuleSource.TagName = XmlAttribute(XmlFilename, XmlTag)
112
113 XmlTag = "ToolCode"
114 ModuleSource.ToolCode = XmlAttribute(XmlFilename, XmlTag)
115
116 XmlTag = "ToolChainFamily"
117 ModuleSource.ToolChainFamily = XmlAttribute(XmlFilename, XmlTag)
118
119 SetCommon(ModuleSource, XmlFilename)
120
121 return ModuleSource
122
123
124 ## Load a list of Module Sources.
125 #
126 # Read an input Module XML DOM object and return a list of Sources
127 # contained in the DOM object.
128 #
129 # @param XmlMsa An XML DOM object read from MSA file.
130 #
131 # @retvel Sources A list of Sources loaded from XmlMsa.
132 #
133 def LoadModuleSources(XmlMsa):
134 XmlTag = "ModuleSurfaceArea/SourceFiles/Filename"
135 return map(LoadModuleSource, XmlList(XmlMsa, XmlTag))
136
137
138 ## Load a new Module Binary class object.
139 #
140 # Read an input XML Binary DOM object and return an object of Binary
141 # contained in the DOM object.
142 #
143 # @param XmlFilename A child XML DOM object in Module XML DOM.
144 #
145 # @retvel ModuleBinary A new Binary object created by XmlFilename.
146 #
147 def LoadModuleBinary(XmlFilename):
148 ModuleBinary = ModuleBinaryFileClass()
149
150 ModuleBinary.BinaryFile = XmlElementData(XmlFilename)
151
152 XmlTag = "FileType"
153 ModuleBinary.FileType = XmlElementAttribute(XmlFilename, XmlTag)
154
155 SetCommon(ModuleBinary, XmlFilename)
156
157
158 ## Load a list of Module Binaries.
159 #
160 # Read an input Module XML DOM object and return a list of Binaries
161 # contained in the DOM object.
162 #
163 # @param XmlMsa An XML DOM object read from MSA file.
164 #
165 # @retvel Binaries A list of Binaries loaded from XmlMsa.
166 #
167 def LoadModuleBinaries(XmlMsa):
168 XmlTag = "ModuleSurfaceArea/BinaryFiles/Filename"
169 return map(LoadModuleBinary, XmlList(XmlMsa, XmlTag))
170
171
172 ## Load a list of Module Non Processed Files.
173 #
174 # Read an input Module XML DOM object and return a list of Non Processed Files
175 # contained in the DOM object.
176 #
177 # @param XmlMsa An XML DOM object read from MSA file.
178 #
179 # @retvel NonProcessedFiles A list of Non Processed Files loaded from XmlMsa.
180 #
181 def LoadModuleNonProcessedFiles(XmlMsa):
182 XmlTag = "ModuleSurfaceArea/NonProcessedFiles/Filename"
183 return XmlElementList(XmlMsa, XmlTag)
184
185
186 ## Load a new Module Package Dependency class object.
187 #
188 # Read an input XML PackageDependency DOM object and return an object of Package Dependency
189 # contained in the DOM object.
190 #
191 # @param XmlPackage A child XML DOM object in Module XML DOM.
192 #
193 # @retvel ModulePackageDependency A new Package Dependency object created by XmlPackage.
194 #
195 def LoadModulePackageDependency(XmlPackage):
196 ModulePackageDependency = ModulePackageDependencyClass()
197
198 XmlTag = "PackageGuid"
199 PackageKey = XmlAttribute(XmlPackage, XmlTag)
200
201 #
202 #TODO: Add resolution for Package name, package Version
203 #
204 ModulePackageDependency.PackageGuid = PackageKey
205 SetCommon(ModulePackageDependency, XmlPackage)
206
207 return ModulePackageDependency
208
209
210 ## Load a list of Module Package Dependencies.
211 #
212 # Read an input Module XML DOM object and return a list of Package Dependencies
213 # contained in the DOM object.
214 #
215 # @param XmlMsa An XML DOM object read from MSA file.
216 #
217 # @retvel PackageDependencies A list of Package Dependencies loaded from XmlMsa.
218 #
219 def LoadModulePackageDependencies(XmlMsa):
220 XmlTag = "ModuleSurfaceArea/PackageDependencies/Package"
221 return map(LoadModulePackageDependency, XmlList(XmlMsa, XmlTag))
222
223
224 ## Load a list of Module Protocols.
225 #
226 # Read an input Module XML DOM object and return a list of Protocols
227 # contained in the DOM object.
228 #
229 # @param XmlMsa An XML DOM object read from MSA file.
230 #
231 # @retvel Protocols A list of Protocols loaded from XmlMsa.
232 #
233 def LoadModuleProtocols(XmlMsa):
234 XmlTag = "ModuleSurfaceArea/Protocols/Protocol"
235 XmlProtocolList = XmlList(XmlMsa, XmlTag)
236
237 XmlTag = "ModuleSurfaceArea/Protocols/ProtocolNotify"
238 XmlProtocolList += XmlList(XmlMsa, XmlTag)
239
240 return map(LoadGuidProtocolPpiCommon, XmlProtocolList)
241
242
243 ## Load a list of Module Ppis.
244 #
245 # Read an input Module XML DOM object and return a list of Ppis
246 # contained in the DOM object.
247 #
248 # @param XmlMsa An XML DOM object read from MSA file.
249 #
250 # @retvel Ppis A list of Ppis loaded from XmlMsa.
251 #
252 def LoadModulePpis(XmlMsa):
253 XmlTag = "ModuleSurfaceArea/PPIs/Ppi"
254 XmlPpiList = XmlList(XmlMsa, XmlTag)
255
256 XmlTag = "ModuleSurfaceArea/PPIs/PpiNotify"
257 XmlPpiList += XmlList(XmlMsa, XmlTag)
258
259 return map(LoadGuidProtocolPpiCommon, XmlPpiList)
260
261
262 ## Load a new Module Event class object.
263 #
264 # Read an input XML Event DOM object and return an object of Event
265 # contained in the DOM object.
266 #
267 # @param XmlEvent A child XML DOM object in Module XML DOM.
268 # @param Type Specify the event type: SIGNAL_EVENT or CREATE_EVENT.
269 #
270 # @retvel ModuleEvent A new Event object created by XmlEvent.
271 #
272 def LoadModuleEvent(XmlEvent, Type):
273 ModuleEvent = ModuleEventClass()
274
275 XmlTag = "EventTypes/EventType"
276 ModuleEvent.CName = XmlElement(XmlEvent, XmlTag)
277
278 XmlTag = "EventGuidCName"
279 ModuleEvent.GuidCName = XmlAttribute(XmlEvent, XmlTag)
280
281 ModuleEvent.Type = Type
282
283 SetCommon(ModuleEvent, XmlEvent)
284
285 return ModuleEvent
286
287
288 ## Load a list of Module Events.
289 #
290 # Read an input Module XML DOM object and return a list of Events
291 # contained in the DOM object.
292 #
293 # @param XmlMsa An XML DOM object read from MSA file.
294 #
295 # @retvel Events A list of Events loaded from XmlMsa.
296 #
297 def LoadModuleEvents(XmlMsa):
298 ModuleEvents = []
299
300 XmlTag = "ModuleSurfaceArea/Events/CreateEvents/EventTypes"
301 for XmlCreateEvent in XmlList(XmlMsa, XmlTag):
302 ModuleEvent = LoadModuleEvent(XmlCreateEvent, "CREATE_EVENT")
303 ModuleEvents.append(ModuleEvent)
304
305 XmlTag = "ModuleSurfaceArea/Events/SignalEvents/EventTypes"
306 for XmlCreateEvent in XmlList(XmlMsa, XmlTag):
307 ModuleEvent = LoadModuleEvent(XmlCreateEvent, "SIGNAL_EVENT")
308 ModuleEvents.append(ModuleEvent)
309
310 return ModuleEvents
311
312
313 ## Load a new Module Hob class object.
314 #
315 # Read an input XML Hob DOM object and return an object of Hob
316 # contained in the DOM object.
317 #
318 # @param XmlHob A child XML DOM object in Module XML DOM.
319 #
320 # @retvel ModuleHob A new Hob object created by XmlHob.
321 #
322 def LoadModuleHob(XmlHob):
323 ModuleHob = ModuleHobClass()
324
325 XmlTag = "HobTypes/HobType"
326 ModuleHob.Type = XmlElement(XmlHob, XmlTag)
327
328 XmlTag = "HobGuidCName"
329 ModuleHob.GuidCName = XmlAttribute(XmlHob, XmlTag)
330
331 SetCommon(ModuleHob, XmlHob)
332
333 return ModuleHob
334
335
336 ## Load a list of Module Hobs.
337 #
338 # Read an input Module XML DOM object and return a list of Hobs
339 # contained in the DOM object.
340 #
341 # @param XmlMsa An XML DOM object read from MSA file.
342 #
343 # @retvel Hobs A list of Hobs loaded from XmlMsa.
344 #
345 def LoadModuleHobs(XmlMsa):
346 XmlTag = "ModuleSurfaceArea/Hobs/HobTypes"
347 return map(LoadModuleHob, XmlList(XmlMsa, XmlTag))
348
349
350 ## Load a new Module Variable class object.
351 #
352 # Read an input XML Variable DOM object and return an object of Variable
353 # contained in the DOM object.
354 #
355 # @param XmlVariable A child XML DOM object in Module XML DOM.
356 #
357 # @retvel ModuleVariable A new Variable object created by XmlVariable.
358 #
359 def LoadModuleVariable(XmlVariable):
360 ModuleVariable = ModuleVariableClass()
361
362 XmlTag = "Variable/VariableName"
363 HexWordArray = XmlElement(XmlVariable, XmlTag).split()
364 try:
365 ModuleVariable.Name = "".join([unichr(int(a, 16)) for a in HexWordArray])
366 except:
367 ModuleVariable.Name = ""
368
369 XmlTag = "Variable/GuidC_Name"
370 ModuleVariable.GuidCName = XmlElement(XmlVariable, XmlTag)
371
372 SetCommon(ModuleVariable, XmlVariable)
373
374 return ModuleVariable
375
376
377 ## Load a list of Module Variables.
378 #
379 # Read an input Module XML DOM object and return a list of Variables
380 # contained in the DOM object.
381 #
382 # @param XmlMsa An XML DOM object read from MSA file.
383 #
384 # @retvel Variables A list of Variables loaded from XmlMsa.
385 #
386 def LoadModuleVariables(XmlMsa):
387 XmlTag = "ModuleSurfaceArea/Variables/Variable"
388 return map(LoadModuleVariable, XmlList(XmlMsa, XmlTag))
389
390
391 ## Load a new Module Boot Mode class object.
392 #
393 # Read an input XML BootMode DOM object and return an object of Boot Mode
394 # contained in the DOM object.
395 #
396 # @param XmlBootMode A child XML DOM object in Module XML DOM.
397 #
398 # @retvel ModuleBootMode A new Boot Mode object created by XmlBootMode.
399 #
400 def LoadModuleBootMode(XmlBootMode):
401 ModuleBootMode = ModuleBootModeClass()
402
403 XmlTag = "BootModeName"
404 ModuleBootMode.Name = XmlAttribute(XmlBootMode, XmlTag)
405
406 SetCommon(ModuleBootMode, XmlBootMode)
407
408 return ModuleBootMode
409
410
411 ## Load a list of Module Boot Modes.
412 #
413 # Read an input Module XML DOM object and return a list of Boot Modes
414 # contained in the DOM object.
415 #
416 # @param XmlMsa An XML DOM object read from MSA file.
417 #
418 # @retvel BootModes A list of Boot Modes loaded from XmlMsa.
419 #
420 def LoadModuleBootModes(XmlMsa):
421 XmlTag = "ModuleSurfaceArea/BootModes/BootMode"
422 return map(LoadModuleBootMode, XmlList(XmlMsa, XmlTag))
423
424
425 ## Load a new Module System Table class object.
426 #
427 # Read an input XML SystemTable DOM object and return an object of System Table
428 # contained in the DOM object.
429 #
430 # @param XmlSystemTable A child XML DOM object in Module XML DOM.
431 #
432 # @retvel ModuleSystemTable A new System Table object created by XmlSystemTable.
433 #
434 def LoadModuleSystemTable(XmlSystemTable):
435 ModuleSystemTable = ModuleSystemTableClass()
436
437 XmlTag = "SystemTable/SystemTableCName"
438 ModuleSystemTable.CName = XmlElement(XmlSystemTable, XmlTag)
439
440 SetCommon(ModuleSystemTable, XmlSystemTable)
441
442 return ModuleSystemTable
443
444
445 ## Load a list of Module System Tables.
446 #
447 # Read an input Module XML DOM object and return a list of System Tables
448 # contained in the DOM object.
449 #
450 # @param XmlMsa An XML DOM object read from MSA file.
451 #
452 # @retvel SystemTables A list of System Tables loaded from XmlMsa.
453 #
454 def LoadModuleSystemTables(XmlMsa):
455 XmlTag = "ModuleSurfaceArea/SystemTables/SystemTableCNames"
456 return map(LoadModuleSystemTable, XmlList(XmlMsa, XmlTag))
457
458
459 ## Load a new Module Data Hub class object.
460 #
461 # Read an input XML DataHub DOM object and return an object of Data Hub
462 # contained in the DOM object.
463 #
464 # @param XmlDataHub A child XML DOM object in Module XML DOM.
465 #
466 # @retvel ModuleDataHub A new Data Hub object created by XmlDataHub.
467 #
468 def LoadModuleDataHub(XmlDataHub):
469 ModuleDataHub = ModuleDataHubClass()
470
471 XmlTag = "DataHub/DataHubCName"
472 ModuleDataHub.CName = XmlElement(XmlDataHub, "DataHubCName")
473
474 SetCommon(ModuleDataHub, XmlDataHub)
475
476 return ModuleDataHub
477
478
479 ## Load a list of Module Data Hubs.
480 #
481 # Read an input Module XML DOM object and return a list of Data Hubs
482 # contained in the DOM object.
483 #
484 # @param XmlMsa An XML DOM object read from MSA file.
485 #
486 # @retvel DataHubs A list of Data Hubs loaded from XmlMsa.
487 #
488 def LoadModuleDataHubs(XmlMsa):
489 XmlTag = "ModuleSurfaceArea/DataHubs/DataHubRecord"
490 return map(LoadModuleDataHub, XmlList(XmlMsa, XmlTag))
491
492
493 ## Load a new Module Hii Package class object.
494 #
495 # Read an input XML HiiPackage DOM object and return an object of Hii Package
496 # contained in the DOM object.
497 #
498 # @param XmlHiiPackage A child XML DOM object in Module XML DOM.
499 #
500 # @retvel ModuleHiiPackage A new Hii Package object created by XmlHiiPackage.
501 #
502 def LoadModuleHiiPackage(XmlHiiPackage):
503 ModuleHiiPackage = ModuleHiiPackageClass()
504
505 XmlTag = "HiiPackage/HiiPackageCName"
506 ModuleHiiPackage.CName = XmlElement(XmlHiiPackage, "HiiCName")
507
508 SetCommon(ModuleHiiPackage, XmlHiiPackage)
509
510 return ModuleHiiPackage
511
512
513 ## Load a list of Module Hii Packages.
514 #
515 # Read an input Module XML DOM object and return a list of Hii Packages
516 # contained in the DOM object.
517 #
518 # @param XmlMsa An XML DOM object read from MSA file.
519 #
520 # @retvel HiiPackages A list of Hii Packages loaded from XmlMsa.
521 #
522 def LoadModuleHiiPackages(XmlMsa):
523 XmlTag = "ModuleSurfaceArea/HiiPackages/HiiPackage"
524 return map(LoadModuleHiiPackage, XmlList(XmlMsa, XmlTag))
525
526
527 ## Load a list of Module Guids.
528 #
529 # Read an input Module XML DOM object and return a list of Guids
530 # contained in the DOM object.
531 #
532 # @param XmlMsa An XML DOM object read from MSA file.
533 #
534 # @retvel Guids A list of Guids loaded from XmlMsa.
535 #
536 def LoadModuleGuids(XmlMsa):
537 XmlTag = "ModuleSurfaceArea/Guids/GuidCNames"
538 return map(LoadGuidProtocolPpiCommon, XmlList(XmlMsa, XmlTag))
539
540
541 ## Load a list of Module Pcd Codes.
542 #
543 # Read an input Module XML DOM object and return a list of Pcd Codes
544 # contained in the DOM object.
545 #
546 # @param XmlMsa An XML DOM object read from MSA file.
547 #
548 # @retvel PcdCodes A list of Pcd Codes loaded from XmlMsa.
549 #
550 def LoadModulePcdCodes(XmlMsa):
551 XmlTag = "ModuleSurfaceArea/PcdCoded/PcdEntry"
552 return map(LoadPcd, XmlList(XmlMsa, XmlTag))
553
554
555 ## Load a list of Module Extern Images.
556 #
557 # Read an input Module XML DOM object and return a list of Extern Images
558 # contained in the DOM object.
559 #
560 # @param XmlMsa An XML DOM object read from MSA file.
561 #
562 # @retvel ExternImages A list of Extern Images loaded from XmlMsa.
563 #
564 def LoadModuleExternImages(XmlMsa):
565 ModuleExternImages = []
566
567 XmlTag = "ModuleSurfaceArea/Externs/Extern"
568 for XmlExtern in XmlList(XmlMsa, XmlTag):
569 XmlTag = "Extern/ModuleEntryPoint"
570 ModuleEntryPoint = XmlElement(XmlExtern, XmlTag)
571 XmlTag = "Extern/ModuleUnloadImage"
572 ModuleUnloadImage = XmlElement(XmlExtern, XmlTag)
573 if ModuleEntryPoint == "" and ModuleUnloadImage == "":
574 continue
575
576 ModuleExtern = ModuleExternImageClass()
577 ModuleExtern.ModuleEntryPoint = ModuleEntryPoint
578 ModuleExtern.ModuleUnloadImage = ModuleUnloadImage
579 ModuleExternImages.append(ModuleExtern)
580
581 return ModuleExternImages
582
583
584 ## Load a list of Module Extern Libraries.
585 #
586 # Read an input Module XML DOM object and return a list of Extern Libraries
587 # contained in the DOM object.
588 #
589 # @param XmlMsa An XML DOM object read from MSA file.
590 #
591 # @retvel ExternLibraries A list of Extern Libraries loaded from XmlMsa.
592 #
593 def LoadModuleExternLibraries(XmlMsa):
594 ModuleExternLibraries = []
595
596 XmlTag = "ModuleSurfaceArea/Externs/Extern"
597 for XmlExtern in XmlList(XmlMsa, XmlTag):
598 XmlTag = "Extern/Constructor"
599 Constructor = XmlElement(XmlExtern, XmlTag)
600 XmlTag = "Extern/Destructor"
601 Destructor = XmlElement(XmlExtern, XmlTag)
602 if Constructor == "" and Destructor == "":
603 continue
604
605 ModuleExtern = ModuleExternLibraryClass()
606 ModuleExtern.Constructor = Constructor
607 ModuleExtern.Destructor = Destructor
608 ModuleExternLibraries.append(ModuleExtern)
609
610 return ModuleExternLibraries
611
612
613 ## Load a list of Module Extern Drivers.
614 #
615 # Read an input Module XML DOM object and return a list of Extern Drivers
616 # contained in the DOM object.
617 #
618 # @param XmlMsa An XML DOM object read from MSA file.
619 #
620 # @retvel ExternDrivers A list of Extern Drivers loaded from XmlMsa.
621 #
622 def LoadModuleExternDrivers(XmlMsa):
623 ModuleExternDrivers = []
624
625 XmlTag = "ModuleSurfaceArea/Externs/Extern"
626 for XmlExtern in XmlList(XmlMsa, XmlTag):
627 XmlTag = "Extern/DriverBinding"
628 DriverBinding = XmlElement(XmlExtern, XmlTag)
629 XmlTag = "Extern/ComponentName"
630 ComponentName = XmlElement(XmlExtern, XmlTag)
631 XmlTag = "Extern/DriverConfig"
632 DriverConfig = XmlElement(XmlExtern, XmlTag)
633 XmlTag = "Extern/DriverDiag"
634 DriverDiag = XmlElement(XmlExtern, XmlTag)
635 if DriverBinding == "":
636 continue
637
638 ModuleExtern = ModuleExternDriverClass()
639 ModuleExtern.DriverBinding = DriverBinding
640 ModuleExtern.ComponentName = ComponentName
641 ModuleExtern.DriverConfig = DriverConfig
642 ModuleExtern.DriverDiag = DriverDiag
643 ModuleExternDrivers.append(ModuleExtern)
644
645 return ModuleExternDrivers
646
647
648 ## Load a list of Module Extern Call Backs.
649 #
650 # Read an input Module XML DOM object and return a list of Extern Call Backs
651 # contained in the DOM object.
652 #
653 # @param XmlMsa An XML DOM object read from MSA file.
654 #
655 # @retvel ExternCallBacks A list of Extern Call Backs loaded from XmlMsa.
656 #
657 def LoadModuleExternCallBacks(XmlMsa):
658 ModuleExternCallBacks = []
659
660 XmlTag = "ModuleSurfaceArea/Externs/Extern"
661 for XmlExtern in XmlList(XmlMsa, XmlTag):
662 XmlTag = "Extern/SetVirtualAddressMapCallBack"
663 SetVirtualAddressMap = XmlElement(XmlExtern, XmlTag)
664 XmlTag = "Extern/ExitBootServicesCallBack"
665 ExitBootServices = XmlElement(XmlExtern, XmlTag)
666 if SetVirtualAddressMap == "" and ExitBootServices == "":
667 continue
668
669 ModuleExtern = ModuleExternCallBackClass()
670 ModuleExtern.ExitBootServicesCallBack = ExitBootServices
671 ModuleExtern.SetVirtualAddressMapCallBack = SetVirtualAddressMap
672 ModuleExternCallBacks.append(ModuleExtern)
673
674 return ModuleExternCallBacks
675
676
677 ## Load a list of Module Build Options.
678 #
679 # Read an input Module XML DOM object and return a list of Build Options
680 # contained in the DOM object.
681 #
682 # @param XmlMsa An XML DOM object read from MSA file.
683 #
684 # @retvel BuildOptions A list of Build Options loaded from XmlMsa.
685 #
686 def LoadModuleBuildOptions(XmlMsa):
687 XmlTag = "ModuleSurfaceArea/ModuleBuildOptions/Options/Option"
688 return map(LoadBuildOption, XmlList(XmlMsa, XmlTag))
689
690
691 ## Load a list of Module User Extensions.
692 #
693 # Read an input Module XML DOM object and return a list of User Extensions
694 # contained in the DOM object.
695 #
696 # @param XmlMsa An XML DOM object read from MSA file.
697 #
698 # @retvel UserExtensions A list of User Extensions loaded from XmlMsa.
699 #
700 def LoadModuleUserExtensions(XmlMsa):
701 XmlTag = "ModuleSurfaceArea/UserExtensions"
702 return map(LoadUserExtensions, XmlList(XmlMsa, XmlTag))
703
704 ## Load a new Module class object.
705 #
706 # Read an input MSA File and return a new Module class Object.
707 #
708 # @param MsaFileName An XML DOM object read from MSA file.
709 #
710 # @retvel Module A new Module class object loaded from MSA File.
711 #
712 def LoadMsa(MsaFileName):
713 XmlMsa = XmlParseFile(MsaFileName)
714 EdkLogger.verbose("Load MSA File: %s" % MsaFileName)
715
716 Module = ModuleClass()
717 Module.Header = LoadModuleHeader(XmlMsa, MsaFileName)
718 Module.LibraryClasses = LoadModuleLibraryClasses(XmlMsa)
719 Module.Sources = LoadModuleSources(XmlMsa)
720 Module.BinaryFiles = LoadModuleBinaries(XmlMsa)
721 Module.NonProcessedFiles = LoadModuleNonProcessedFiles(XmlMsa)
722 Module.PackageDependencies = LoadModulePackageDependencies(XmlMsa)
723 Module.Protocols = LoadModuleProtocols(XmlMsa)
724 Module.Ppis = LoadModulePpis(XmlMsa)
725 Module.Events = LoadModuleEvents(XmlMsa)
726 Module.Hobs = LoadModuleHobs(XmlMsa)
727 Module.Variables = LoadModuleVariables(XmlMsa)
728 Module.BootModes = LoadModuleBootModes(XmlMsa)
729 Module.SystemTables = LoadModuleSystemTables(XmlMsa)
730 Module.DataHubs = LoadModuleDataHubs(XmlMsa)
731 Module.HiiPackages = LoadModuleHiiPackages(XmlMsa)
732 Module.Guids = LoadModuleGuids(XmlMsa)
733 Module.PcdCodes = LoadModulePcdCodes(XmlMsa)
734 Module.ExternImages = LoadModuleExternImages(XmlMsa)
735 Module.ExternLibraries = LoadModuleExternLibraries(XmlMsa)
736 Module.ExternDrivers = LoadModuleExternDrivers(XmlMsa)
737 Module.ExternCallBacks = LoadModuleExternCallBacks(XmlMsa)
738 Module.BuildOptions = LoadModuleBuildOptions(XmlMsa)
739 Module.UserExtensions = LoadModuleUserExtensions(XmlMsa)
740
741 return Module
742
743
744 # This acts like the main() function for the script, unless it is 'import'ed
745 # into another script.
746 if __name__ == '__main__':
747 pass