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