]> git.proxmox.com Git - mirror_edk2.git/blame - BaseTools/Source/Python/Eot/Eot.py
Sync BaseTool trunk (version r2649) into EDKII BaseTools.
[mirror_edk2.git] / BaseTools / Source / Python / Eot / Eot.py
CommitLineData
52302d4d
LG
1## @file\r
2# This file is used to be the main entrance of EOT tool\r
3#\r
40d841f6
LG
4# Copyright (c) 2008 - 2010, Intel Corporation. All rights reserved.<BR>\r
5# This program and the accompanying materials\r
52302d4d
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
17import os, time, glob\r
18import Common.EdkLogger as EdkLogger\r
19import EotGlobalData\r
20from optparse import OptionParser\r
21from Common.String import NormPath\r
22from Common import BuildToolError\r
23from Common.Misc import GuidStructureStringToGuidString\r
24from InfParserLite import *\r
25import c\r
26import Database\r
27from FvImage import *\r
28from array import array\r
29from Report import Report\r
30from Common.Misc import ParseConsoleLog\r
b36d134f 31from Common.BuildVersion import gBUILD_VERSION\r
52302d4d
LG
32from Parser import ConvertGuid\r
33\r
34## Class Eot\r
35#\r
36# This class is used to define Eot main entrance\r
37#\r
38# @param object: Inherited from object class\r
39#\r
40class Eot(object):\r
41 ## The constructor\r
42 #\r
43 # @param self: The object pointer\r
44 #\r
45 def __init__(self, CommandLineOption=True, IsInit=True, SourceFileList=None, \\r
46 IncludeDirList=None, DecFileList=None, GuidList=None, LogFile=None,\r
47 FvFileList="", MapFileList="", Report='Report.html', Dispatch=None):\r
48 # Version and Copyright\r
b36d134f 49 self.VersionNumber = ("0.02" + " " + gBUILD_VERSION)\r
52302d4d
LG
50 self.Version = "%prog Version " + self.VersionNumber\r
51 self.Copyright = "Copyright (c) 2008 - 2010, Intel Corporation All rights reserved."\r
52 self.Report = Report\r
53\r
54 self.IsInit = IsInit\r
55 self.SourceFileList = SourceFileList\r
56 self.IncludeDirList = IncludeDirList\r
57 self.DecFileList = DecFileList\r
58 self.GuidList = GuidList\r
59 self.LogFile = LogFile\r
60 self.FvFileList = FvFileList\r
61 self.MapFileList = MapFileList\r
62 self.Dispatch = Dispatch\r
63 \r
64 # Check workspace environment\r
65 if "EFI_SOURCE" not in os.environ:\r
66 if "EDK_SOURCE" not in os.environ:\r
67 pass\r
68 else:\r
69 EotGlobalData.gEDK_SOURCE = os.path.normpath(os.getenv("EDK_SOURCE"))\r
70 else:\r
71 EotGlobalData.gEFI_SOURCE = os.path.normpath(os.getenv("EFI_SOURCE"))\r
72 EotGlobalData.gEDK_SOURCE = os.path.join(EotGlobalData.gEFI_SOURCE, 'Edk')\r
73\r
74 if "WORKSPACE" not in os.environ:\r
75 EdkLogger.error("EOT", BuildToolError.ATTRIBUTE_NOT_AVAILABLE, "Environment variable not found",\r
76 ExtraData="WORKSPACE")\r
77 else:\r
78 EotGlobalData.gWORKSPACE = os.path.normpath(os.getenv("WORKSPACE"))\r
79\r
80 EotGlobalData.gMACRO['WORKSPACE'] = EotGlobalData.gWORKSPACE\r
81 EotGlobalData.gMACRO['EFI_SOURCE'] = EotGlobalData.gEFI_SOURCE\r
82 EotGlobalData.gMACRO['EDK_SOURCE'] = EotGlobalData.gEDK_SOURCE\r
83\r
84 # Parse the options and args\r
85 if CommandLineOption:\r
86 self.ParseOption()\r
87\r
88 if self.FvFileList:\r
89 for FvFile in GetSplitValueList(self.FvFileList, ' '):\r
90 FvFile = os.path.normpath(FvFile)\r
91 if not os.path.isfile(FvFile):\r
92 EdkLogger.error("Eot", EdkLogger.EOT_ERROR, "Can not find file %s " % FvFile)\r
93 EotGlobalData.gFV_FILE.append(FvFile)\r
94 else:\r
95 EdkLogger.error("Eot", EdkLogger.EOT_ERROR, "The fv file list of target platform was not specified")\r
96\r
97 if self.MapFileList:\r
98 for MapFile in GetSplitValueList(self.MapFileList, ' '):\r
99 MapFile = os.path.normpath(MapFile)\r
100 if not os.path.isfile(MapFile):\r
101 EdkLogger.error("Eot", EdkLogger.EOT_ERROR, "Can not find file %s " % MapFile)\r
102 EotGlobalData.gMAP_FILE.append(MapFile)\r
103 \r
104 # Generate source file list\r
105 self.GenerateSourceFileList(self.SourceFileList, self.IncludeDirList)\r
106\r
107 # Generate guid list of dec file list\r
108 self.ParseDecFile(self.DecFileList)\r
109 \r
110 # Generate guid list from GUID list file\r
111 self.ParseGuidList(self.GuidList)\r
112\r
113 # Init Eot database\r
114 EotGlobalData.gDb = Database.Database(Database.DATABASE_PATH)\r
115 EotGlobalData.gDb.InitDatabase(self.IsInit)\r
116\r
117 # Build ECC database\r
118 self.BuildDatabase()\r
119\r
120 # Parse Ppi/Protocol\r
121 self.ParseExecutionOrder()\r
122\r
123 # Merge Identifier tables\r
124 self.GenerateQueryTable()\r
125\r
126 # Generate report database\r
127 self.GenerateReportDatabase()\r
128\r
129 # Load Fv Info\r
130 self.LoadFvInfo()\r
131\r
132 # Load Map Info\r
133 self.LoadMapInfo()\r
134\r
135 # Generate Report\r
136 self.GenerateReport()\r
137\r
138 # Convert log file\r
139 self.ConvertLogFile(self.LogFile)\r
140\r
141 # DONE\r
142 EdkLogger.quiet("EOT FINISHED!")\r
143\r
144 # Close Database\r
145 EotGlobalData.gDb.Close()\r
146\r
147 ## ParseDecFile() method\r
148 #\r
149 # parse DEC file and get all GUID names with GUID values as {GuidName : GuidValue}\r
150 # The Dict is stored in EotGlobalData.gGuidDict\r
151 #\r
152 # @param self: The object pointer\r
153 # @param DecFileList: A list of all DEC files\r
154 #\r
155 def ParseDecFile(self, DecFileList):\r
156 if DecFileList:\r
157 path = os.path.normpath(DecFileList)\r
158 lfr = open(path, 'rb')\r
159 for line in lfr:\r
160 path = os.path.normpath(os.path.join(EotGlobalData.gWORKSPACE, line.strip()))\r
161 if os.path.exists(path):\r
162 dfr = open(path, 'rb')\r
163 for line in dfr:\r
164 line = CleanString(line)\r
165 list = line.split('=')\r
166 if len(list) == 2:\r
167 EotGlobalData.gGuidDict[list[0].strip()] = GuidStructureStringToGuidString(list[1].strip())\r
168\r
169 \r
170 ## ParseGuidList() method\r
171 #\r
172 # Parse Guid list and get all GUID names with GUID values as {GuidName : GuidValue}\r
173 # The Dict is stored in EotGlobalData.gGuidDict\r
174 #\r
175 # @param self: The object pointer\r
176 # @param GuidList: A list of all GUID and its value\r
177 #\r
178 def ParseGuidList(self, GuidList):\r
179 Path = os.path.join(EotGlobalData.gWORKSPACE, GuidList)\r
180 if os.path.isfile(Path):\r
181 for Line in open(Path):\r
182 (GuidName, GuidValue) = Line.split()\r
183 EotGlobalData.gGuidDict[GuidName] = GuidValue\r
184 \r
185 ## ConvertLogFile() method\r
186 #\r
187 # Parse a real running log file to get real dispatch order\r
188 # The result is saved to old file name + '.new'\r
189 #\r
190 # @param self: The object pointer\r
191 # @param LogFile: A real running log file name\r
192 #\r
193 def ConvertLogFile(self, LogFile):\r
194 newline = []\r
195 lfr = None\r
196 lfw = None\r
197 if LogFile:\r
198 lfr = open(LogFile, 'rb')\r
199 lfw = open(LogFile + '.new', 'wb')\r
200 for line in lfr:\r
201 line = line.strip()\r
202 line = line.replace('.efi', '')\r
203 index = line.find("Loading PEIM at ")\r
204 if index > -1:\r
205 newline.append(line[index + 55 : ])\r
206 continue\r
207 index = line.find("Loading driver at ")\r
208 if index > -1:\r
209 newline.append(line[index + 57 : ])\r
210 continue\r
211\r
212 for line in newline:\r
213 lfw.write(line + '\r\n')\r
214\r
215 if lfr:\r
216 lfr.close()\r
217 if lfw:\r
218 lfw.close()\r
219\r
220 ## GenerateSourceFileList() method\r
221 #\r
222 # Generate a list of all source files\r
223 # 1. Search the file list one by one\r
224 # 2. Store inf file name with source file names under it like\r
225 # { INF file name: [source file1, source file2, ...]}\r
226 # 3. Search the include list to find all .h files\r
227 # 4. Store source file list to EotGlobalData.gSOURCE_FILES\r
228 # 5. Store INF file list to EotGlobalData.gINF_FILES\r
229 #\r
230 # @param self: The object pointer\r
231 # @param SourceFileList: A list of all source files\r
232 # @param IncludeFileList: A list of all include files\r
233 #\r
234 def GenerateSourceFileList(self, SourceFileList, IncludeFileList):\r
235 EdkLogger.quiet("Generating source files list ... ")\r
236 mSourceFileList = []\r
237 mInfFileList = []\r
238 mDecFileList = []\r
239 mFileList = {}\r
240 mCurrentInfFile = ''\r
241 mCurrentSourceFileList = []\r
242\r
243 if SourceFileList:\r
244 sfl = open(SourceFileList, 'rb')\r
245 for line in sfl:\r
246 line = os.path.normpath(os.path.join(EotGlobalData.gWORKSPACE, line.strip()))\r
247 if line[-2:].upper() == '.C' or line[-2:].upper() == '.H':\r
248 if line not in mCurrentSourceFileList:\r
249 mCurrentSourceFileList.append(line)\r
250 mSourceFileList.append(line)\r
251 EotGlobalData.gOP_SOURCE_FILES.write('%s\n' % line)\r
252 if line[-4:].upper() == '.INF':\r
253 if mCurrentInfFile != '':\r
254 mFileList[mCurrentInfFile] = mCurrentSourceFileList\r
255 mCurrentSourceFileList = []\r
256 mCurrentInfFile = os.path.normpath(os.path.join(EotGlobalData.gWORKSPACE, line))\r
257 EotGlobalData.gOP_INF.write('%s\n' % mCurrentInfFile)\r
258 if mCurrentInfFile not in mFileList:\r
259 mFileList[mCurrentInfFile] = mCurrentSourceFileList\r
260\r
261 # Get all include files from packages\r
262 if IncludeFileList:\r
263 ifl = open(IncludeFileList, 'rb')\r
264 for line in ifl:\r
265 if not line.strip():\r
266 continue\r
267 newline = os.path.normpath(os.path.join(EotGlobalData.gWORKSPACE, line.strip()))\r
268 for Root, Dirs, Files in os.walk(str(newline)):\r
269 for File in Files:\r
270 FullPath = os.path.normpath(os.path.join(Root, File))\r
271 if FullPath not in mSourceFileList and File[-2:].upper() == '.H':\r
272 mSourceFileList.append(FullPath)\r
273 EotGlobalData.gOP_SOURCE_FILES.write('%s\n' % FullPath)\r
274 if FullPath not in mDecFileList and File.upper().find('.DEC') > -1:\r
275 mDecFileList.append(FullPath)\r
276\r
277 EotGlobalData.gSOURCE_FILES = mSourceFileList\r
278 EotGlobalData.gOP_SOURCE_FILES.close()\r
279\r
280 EotGlobalData.gINF_FILES = mFileList\r
281 EotGlobalData.gOP_INF.close()\r
282\r
283 EotGlobalData.gDEC_FILES = mDecFileList\r
284\r
285\r
286 ## GenerateReport() method\r
287 #\r
288 # Generate final HTML report\r
289 #\r
290 # @param self: The object pointer\r
291 #\r
292 def GenerateReport(self):\r
293 EdkLogger.quiet("Generating report file ... ")\r
294 Rep = Report(self.Report, EotGlobalData.gFV, self.Dispatch)\r
295 Rep.GenerateReport()\r
296\r
297 ## LoadMapInfo() method\r
298 #\r
299 # Load map files and parse them\r
300 #\r
301 # @param self: The object pointer\r
302 #\r
303 def LoadMapInfo(self):\r
304 if EotGlobalData.gMAP_FILE != []:\r
305 EdkLogger.quiet("Parsing Map file ... ")\r
306 EotGlobalData.gMap = ParseMapFile(EotGlobalData.gMAP_FILE)\r
307\r
308 ## LoadFvInfo() method\r
309 #\r
310 # Load FV binary files and parse them\r
311 #\r
312 # @param self: The object pointer\r
313 #\r
314 def LoadFvInfo(self):\r
315 EdkLogger.quiet("Parsing FV file ... ")\r
316 EotGlobalData.gFV = MultipleFv(EotGlobalData.gFV_FILE)\r
317 EotGlobalData.gFV.Dispatch(EotGlobalData.gDb)\r
318\r
319 for Protocol in EotGlobalData.gProtocolList:\r
320 EotGlobalData.gOP_UN_MATCHED_IN_LIBRARY_CALLING.write('%s\n' %Protocol)\r
321\r
322 ## GenerateReportDatabase() method\r
323 #\r
324 # Generate data for the information needed by report\r
325 # 1. Update name, macro and value of all found PPI/PROTOCOL GUID\r
326 # 2. Install hard coded PPI/PROTOCOL\r
327 #\r
328 # @param self: The object pointer\r
329 #\r
330 def GenerateReportDatabase(self):\r
331 EdkLogger.quiet("Generating the cross-reference table of GUID for Ppi/Protocol ... ")\r
332\r
333 # Update Protocol/Ppi Guid\r
334 SqlCommand = """select DISTINCT GuidName from Report"""\r
335 RecordSet = EotGlobalData.gDb.TblReport.Exec(SqlCommand)\r
336 for Record in RecordSet:\r
337 GuidName = Record[0]\r
338 GuidMacro = ''\r
339 GuidMacro2 = ''\r
340 GuidValue = ''\r
341\r
342 # Find value for hardcode guid macro\r
343 if GuidName in EotGlobalData.gGuidMacroDict:\r
344 GuidMacro = EotGlobalData.gGuidMacroDict[GuidName][0]\r
345 GuidValue = EotGlobalData.gGuidMacroDict[GuidName][1]\r
346 SqlCommand = """update Report set GuidMacro = '%s', GuidValue = '%s' where GuidName = '%s'""" %(GuidMacro, GuidValue, GuidName)\r
347 EotGlobalData.gDb.TblReport.Exec(SqlCommand)\r
348 continue\r
349\r
350 # Find guid value defined in Dec file\r
351 if GuidName in EotGlobalData.gGuidDict:\r
352 GuidValue = EotGlobalData.gGuidDict[GuidName]\r
353 SqlCommand = """update Report set GuidMacro = '%s', GuidValue = '%s' where GuidName = '%s'""" %(GuidMacro, GuidValue, GuidName)\r
354 EotGlobalData.gDb.TblReport.Exec(SqlCommand)\r
355 continue\r
356\r
357 # Search defined Macros for guid name\r
358 SqlCommand ="""select DISTINCT Value, Modifier from Query where Name like '%s'""" % GuidName\r
359 GuidMacroSet = EotGlobalData.gDb.TblReport.Exec(SqlCommand)\r
360 # Ignore NULL result\r
361 if not GuidMacroSet:\r
362 continue\r
363 GuidMacro = GuidMacroSet[0][0].strip()\r
364 if not GuidMacro:\r
365 continue\r
366 # Find Guid value of Guid Macro\r
367 SqlCommand ="""select DISTINCT Value from Query2 where Value like '%%%s%%' and Model = %s""" % (GuidMacro, MODEL_IDENTIFIER_MACRO_DEFINE)\r
368 GuidValueSet = EotGlobalData.gDb.TblReport.Exec(SqlCommand)\r
369 if GuidValueSet != []:\r
370 GuidValue = GuidValueSet[0][0]\r
371 GuidValue = GuidValue[GuidValue.find(GuidMacro) + len(GuidMacro) :]\r
372 GuidValue = GuidValue.lower().replace('\\', '').replace('\r', '').replace('\n', '').replace('l', '').strip()\r
373 GuidValue = GuidStructureStringToGuidString(GuidValue)\r
374 SqlCommand = """update Report set GuidMacro = '%s', GuidValue = '%s' where GuidName = '%s'""" %(GuidMacro, GuidValue, GuidName)\r
375 EotGlobalData.gDb.TblReport.Exec(SqlCommand)\r
376 continue\r
377\r
378 # Update Hard Coded Ppi/Protocol\r
379 SqlCommand = """select DISTINCT GuidValue, ItemType from Report where ModuleID = -2 and ItemMode = 'Produced'"""\r
380 RecordSet = EotGlobalData.gDb.TblReport.Exec(SqlCommand)\r
381 for Record in RecordSet:\r
382 if Record[1] == 'Ppi':\r
383 EotGlobalData.gPpiList[Record[0].lower()] = -2\r
384 if Record[1] == 'Protocol':\r
385 EotGlobalData.gProtocolList[Record[0].lower()] = -2\r
386\r
387 ## GenerateQueryTable() method\r
388 #\r
389 # Generate two tables improve query performance\r
390 #\r
391 # @param self: The object pointer\r
392 #\r
393 def GenerateQueryTable(self):\r
394 EdkLogger.quiet("Generating temp query table for analysis ... ")\r
395 for Identifier in EotGlobalData.gIdentifierTableList:\r
396 SqlCommand = """insert into Query (Name, Modifier, Value, Model)\r
397 select Name, Modifier, Value, Model from %s where (Model = %s or Model = %s)""" \\r
398 % (Identifier[0], MODEL_IDENTIFIER_VARIABLE, MODEL_IDENTIFIER_ASSIGNMENT_EXPRESSION)\r
399 EotGlobalData.gDb.TblReport.Exec(SqlCommand)\r
400 SqlCommand = """insert into Query2 (Name, Modifier, Value, Model)\r
401 select Name, Modifier, Value, Model from %s where Model = %s""" \\r
402 % (Identifier[0], MODEL_IDENTIFIER_MACRO_DEFINE)\r
403 EotGlobalData.gDb.TblReport.Exec(SqlCommand)\r
404\r
405 ## ParseExecutionOrder() method\r
406 #\r
407 # Get final execution order\r
408 # 1. Search all PPI\r
409 # 2. Search all PROTOCOL\r
410 #\r
411 # @param self: The object pointer\r
412 #\r
413 def ParseExecutionOrder(self):\r
414 EdkLogger.quiet("Searching Ppi/Protocol ... ")\r
415 for Identifier in EotGlobalData.gIdentifierTableList:\r
416 ModuleID, ModuleName, ModuleGuid, SourceFileID, SourceFileFullPath, ItemName, ItemType, ItemMode, GuidName, GuidMacro, GuidValue, BelongsToFunction, Enabled = \\r
417 -1, '', '', -1, '', '', '', '', '', '', '', '', 0\r
418\r
419 SourceFileID = Identifier[0].replace('Identifier', '')\r
420 SourceFileFullPath = Identifier[1]\r
421 Identifier = Identifier[0]\r
422\r
423 # Find Ppis\r
424 ItemMode = 'Produced'\r
425 SqlCommand = """select Value, Name, BelongsToFile, StartLine, EndLine from %s\r
426 where (Name like '%%%s%%' or Name like '%%%s%%' or Name like '%%%s%%') and Model = %s""" \\r
427 % (Identifier, '.InstallPpi', '->InstallPpi', 'PeiInstallPpi', MODEL_IDENTIFIER_FUNCTION_CALLING)\r
428 SearchPpi(SqlCommand, Identifier, SourceFileID, SourceFileFullPath, ItemMode)\r
429\r
430 ItemMode = 'Produced'\r
431 SqlCommand = """select Value, Name, BelongsToFile, StartLine, EndLine from %s\r
432 where (Name like '%%%s%%' or Name like '%%%s%%') and Model = %s""" \\r
433 % (Identifier, '.ReInstallPpi', '->ReInstallPpi', MODEL_IDENTIFIER_FUNCTION_CALLING)\r
434 SearchPpi(SqlCommand, Identifier, SourceFileID, SourceFileFullPath, ItemMode, 2)\r
435\r
436 SearchPpiCallFunction(Identifier, SourceFileID, SourceFileFullPath, ItemMode)\r
437\r
438 ItemMode = 'Consumed'\r
439 SqlCommand = """select Value, Name, BelongsToFile, StartLine, EndLine from %s\r
440 where (Name like '%%%s%%' or Name like '%%%s%%') and Model = %s""" \\r
441 % (Identifier, '.LocatePpi', '->LocatePpi', MODEL_IDENTIFIER_FUNCTION_CALLING)\r
442 SearchPpi(SqlCommand, Identifier, SourceFileID, SourceFileFullPath, ItemMode)\r
443\r
444 SearchFunctionCalling(Identifier, SourceFileID, SourceFileFullPath, 'Ppi', ItemMode)\r
445\r
446 ItemMode = 'Callback'\r
447 SqlCommand = """select Value, Name, BelongsToFile, StartLine, EndLine from %s\r
448 where (Name like '%%%s%%' or Name like '%%%s%%') and Model = %s""" \\r
449 % (Identifier, '.NotifyPpi', '->NotifyPpi', MODEL_IDENTIFIER_FUNCTION_CALLING)\r
450 SearchPpi(SqlCommand, Identifier, SourceFileID, SourceFileFullPath, ItemMode)\r
451\r
452 # Find Procotols\r
453 ItemMode = 'Produced'\r
454 SqlCommand = """select Value, Name, BelongsToFile, StartLine, EndLine from %s\r
455 where (Name like '%%%s%%' or Name like '%%%s%%' or Name like '%%%s%%' or Name like '%%%s%%') and Model = %s""" \\r
456 % (Identifier, '.InstallProtocolInterface', '.ReInstallProtocolInterface', '->InstallProtocolInterface', '->ReInstallProtocolInterface', MODEL_IDENTIFIER_FUNCTION_CALLING)\r
457 SearchProtocols(SqlCommand, Identifier, SourceFileID, SourceFileFullPath, ItemMode, 1)\r
458\r
459 SqlCommand = """select Value, Name, BelongsToFile, StartLine, EndLine from %s\r
460 where (Name like '%%%s%%' or Name like '%%%s%%') and Model = %s""" \\r
461 % (Identifier, '.InstallMultipleProtocolInterfaces', '->InstallMultipleProtocolInterfaces', MODEL_IDENTIFIER_FUNCTION_CALLING)\r
462 SearchProtocols(SqlCommand, Identifier, SourceFileID, SourceFileFullPath, ItemMode, 2)\r
463\r
464 SearchFunctionCalling(Identifier, SourceFileID, SourceFileFullPath, 'Protocol', ItemMode)\r
465\r
466 ItemMode = 'Consumed'\r
467 SqlCommand = """select Value, Name, BelongsToFile, StartLine, EndLine from %s\r
468 where (Name like '%%%s%%' or Name like '%%%s%%') and Model = %s""" \\r
469 % (Identifier, '.LocateProtocol', '->LocateProtocol', MODEL_IDENTIFIER_FUNCTION_CALLING)\r
470 SearchProtocols(SqlCommand, Identifier, SourceFileID, SourceFileFullPath, ItemMode, 0)\r
471\r
472 SqlCommand = """select Value, Name, BelongsToFile, StartLine, EndLine from %s\r
473 where (Name like '%%%s%%' or Name like '%%%s%%') and Model = %s""" \\r
474 % (Identifier, '.HandleProtocol', '->HandleProtocol', MODEL_IDENTIFIER_FUNCTION_CALLING)\r
475 SearchProtocols(SqlCommand, Identifier, SourceFileID, SourceFileFullPath, ItemMode, 1)\r
476\r
477 SearchFunctionCalling(Identifier, SourceFileID, SourceFileFullPath, 'Protocol', ItemMode)\r
478\r
479 ItemMode = 'Callback'\r
480 SqlCommand = """select Value, Name, BelongsToFile, StartLine, EndLine from %s\r
481 where (Name like '%%%s%%' or Name like '%%%s%%') and Model = %s""" \\r
482 % (Identifier, '.RegisterProtocolNotify', '->RegisterProtocolNotify', MODEL_IDENTIFIER_FUNCTION_CALLING)\r
483 SearchProtocols(SqlCommand, Identifier, SourceFileID, SourceFileFullPath, ItemMode, 0)\r
484\r
485 SearchFunctionCalling(Identifier, SourceFileID, SourceFileFullPath, 'Protocol', ItemMode)\r
486\r
487 # Hard Code\r
488 EotGlobalData.gDb.TblReport.Insert(-2, '', '', -1, '', '', 'Ppi', 'Produced', 'gEfiSecPlatformInformationPpiGuid', '', '', '', 0)\r
489 EotGlobalData.gDb.TblReport.Insert(-2, '', '', -1, '', '', 'Ppi', 'Produced', 'gEfiNtLoadAsDllPpiGuid', '', '', '', 0)\r
490 EotGlobalData.gDb.TblReport.Insert(-2, '', '', -1, '', '', 'Ppi', 'Produced', 'gNtPeiLoadFileGuid', '', '', '', 0)\r
491 EotGlobalData.gDb.TblReport.Insert(-2, '', '', -1, '', '', 'Ppi', 'Produced', 'gPeiNtAutoScanPpiGuid', '', '', '', 0)\r
492 EotGlobalData.gDb.TblReport.Insert(-2, '', '', -1, '', '', 'Ppi', 'Produced', 'gNtFwhPpiGuid', '', '', '', 0)\r
493 EotGlobalData.gDb.TblReport.Insert(-2, '', '', -1, '', '', 'Ppi', 'Produced', 'gPeiNtThunkPpiGuid', '', '', '', 0)\r
494 EotGlobalData.gDb.TblReport.Insert(-2, '', '', -1, '', '', 'Ppi', 'Produced', 'gPeiPlatformTypePpiGuid', '', '', '', 0)\r
495 EotGlobalData.gDb.TblReport.Insert(-2, '', '', -1, '', '', 'Ppi', 'Produced', 'gPeiFrequencySelectionCpuPpiGuid', '', '', '', 0)\r
496 EotGlobalData.gDb.TblReport.Insert(-2, '', '', -1, '', '', 'Ppi', 'Produced', 'gPeiCachePpiGuid', '', '', '', 0)\r
497\r
498 EotGlobalData.gDb.Conn.commit()\r
499\r
500\r
501 ## BuildDatabase() methoc\r
502 #\r
503 # Build the database for target\r
504 #\r
505 # @param self: The object pointer\r
506 #\r
507 def BuildDatabase(self):\r
508 # Clean report table\r
509 EotGlobalData.gDb.TblReport.Drop()\r
510 EotGlobalData.gDb.TblReport.Create()\r
511\r
512 # Build database\r
513 if self.IsInit:\r
514 self.BuildMetaDataFileDatabase(EotGlobalData.gINF_FILES)\r
515 EdkLogger.quiet("Building database for source code ...")\r
516 c.CreateCCodeDB(EotGlobalData.gSOURCE_FILES)\r
517 EdkLogger.quiet("Building database for source code done!")\r
518\r
519 EotGlobalData.gIdentifierTableList = GetTableList((MODEL_FILE_C, MODEL_FILE_H), 'Identifier', EotGlobalData.gDb)\r
520\r
521 ## BuildMetaDataFileDatabase() method\r
522 #\r
523 # Build the database for meta data files\r
524 #\r
525 # @param self: The object pointer\r
526 # @param Inf_Files: A list for all INF files\r
527 #\r
528 def BuildMetaDataFileDatabase(self, Inf_Files):\r
529 EdkLogger.quiet("Building database for meta data files ...")\r
530 for InfFile in Inf_Files:\r
531 EdkLogger.quiet("Parsing %s ..." % str(InfFile))\r
532 EdkInfParser(InfFile, EotGlobalData.gDb, Inf_Files[InfFile], '')\r
533\r
534 EotGlobalData.gDb.Conn.commit()\r
535 EdkLogger.quiet("Building database for meta data files done!")\r
536\r
537 ## ParseOption() method\r
538 #\r
539 # Parse command line options\r
540 #\r
541 # @param self: The object pointer\r
542 #\r
543 def ParseOption(self):\r
544 (Options, Target) = self.EotOptionParser()\r
545\r
546 # Set log level\r
547 self.SetLogLevel(Options)\r
548\r
549 if Options.FvFileList:\r
550 self.FvFileList = Options.FvFileList\r
551 \r
552 if Options.MapFileList:\r
553 self.MapFileList = Options.FvMapFileList\r
554\r
555 if Options.SourceFileList:\r
556 self.SourceFileList = Options.SourceFileList\r
557\r
558 if Options.IncludeDirList:\r
559 self.IncludeDirList = Options.IncludeDirList\r
560\r
561 if Options.DecFileList:\r
562 self.DecFileList = Options.DecFileList\r
563 \r
564 if Options.GuidList:\r
565 self.GuidList = Options.GuidList\r
566\r
567 if Options.LogFile:\r
568 self.LogFile = Options.LogFile\r
569\r
570 if Options.keepdatabase:\r
571 self.IsInit = False\r
572\r
573 ## SetLogLevel() method\r
574 #\r
575 # Set current log level of the tool based on args\r
576 #\r
577 # @param self: The object pointer\r
578 # @param Option: The option list including log level setting\r
579 #\r
580 def SetLogLevel(self, Option):\r
581 if Option.verbose != None:\r
582 EdkLogger.SetLevel(EdkLogger.VERBOSE)\r
583 elif Option.quiet != None:\r
584 EdkLogger.SetLevel(EdkLogger.QUIET)\r
585 elif Option.debug != None:\r
586 EdkLogger.SetLevel(Option.debug + 1)\r
587 else:\r
588 EdkLogger.SetLevel(EdkLogger.INFO)\r
589\r
590 ## EotOptionParser() method\r
591 #\r
592 # Using standard Python module optparse to parse command line option of this tool.\r
593 #\r
594 # @param self: The object pointer\r
595 #\r
596 # @retval Opt A optparse.Values object containing the parsed options\r
597 # @retval Args Target of build command\r
598 #\r
599 def EotOptionParser(self):\r
600 Parser = OptionParser(description = self.Copyright, version = self.Version, prog = "Eot.exe", usage = "%prog [options]")\r
601 Parser.add_option("-m", "--makefile filename", action="store", type="string", dest='MakeFile',\r
602 help="Specify a makefile for the platform.")\r
603 Parser.add_option("-c", "--dsc filename", action="store", type="string", dest="DscFile",\r
604 help="Specify a dsc file for the platform.")\r
605 Parser.add_option("-f", "--fv filename", action="store", type="string", dest="FvFileList",\r
606 help="Specify fv file list, quoted by \"\".")\r
607 Parser.add_option("-a", "--map filename", action="store", type="string", dest="MapFileList",\r
608 help="Specify map file list, quoted by \"\".")\r
609 Parser.add_option("-s", "--source files", action="store", type="string", dest="SourceFileList",\r
610 help="Specify source file list by a file")\r
611 Parser.add_option("-i", "--include dirs", action="store", type="string", dest="IncludeDirList",\r
612 help="Specify include dir list by a file")\r
613 Parser.add_option("-e", "--dec files", action="store", type="string", dest="DecFileList",\r
614 help="Specify dec file list by a file")\r
615 Parser.add_option("-g", "--guid list", action="store", type="string", dest="GuidList",\r
616 help="Specify guid file list by a file")\r
617 Parser.add_option("-l", "--log filename", action="store", type="string", dest="LogFile",\r
618 help="Specify real execution log file")\r
619\r
620 Parser.add_option("-k", "--keepdatabase", action="store_true", type=None, help="The existing Eot database will not be cleaned except report information if this option is specified.")\r
621\r
622 Parser.add_option("-q", "--quiet", action="store_true", type=None, help="Disable all messages except FATAL ERRORS.")\r
623 Parser.add_option("-v", "--verbose", action="store_true", type=None, help="Turn on verbose output with informational messages printed, "\\r
624 "including library instances selected, final dependency expression, "\\r
625 "and warning messages, etc.")\r
626 Parser.add_option("-d", "--debug", action="store", type="int", help="Enable debug messages at specified level.")\r
627\r
628 (Opt, Args)=Parser.parse_args()\r
629\r
630 return (Opt, Args)\r
631\r
632##\r
633#\r
634# This acts like the main() function for the script, unless it is 'import'ed into another\r
635# script.\r
636#\r
637if __name__ == '__main__':\r
638 # Initialize log system\r
639 EdkLogger.Initialize()\r
640 EdkLogger.IsRaiseError = False\r
641 EdkLogger.quiet(time.strftime("%H:%M:%S, %b.%d %Y ", time.localtime()) + "[00:00]" + "\n")\r
642\r
643 StartTime = time.clock()\r
644 Eot = Eot()\r
645 FinishTime = time.clock()\r
646\r
647 BuildDuration = time.strftime("%M:%S", time.gmtime(int(round(FinishTime - StartTime))))\r
648 EdkLogger.quiet("\n%s [%s]" % (time.strftime("%H:%M:%S, %b.%d %Y", time.localtime()), BuildDuration))\r