]>
git.proxmox.com Git - mirror_edk2.git/blob - BaseTools/Source/Python/Eot/Report.py
2 # This file is used to create report for Eot tool
4 # Copyright (c) 2008 - 2014, Intel Corporation. All rights reserved.<BR>
5 # 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
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.
17 import Common
.LongFilePathOs
as os
19 from Common
.LongFilePathSupport
import OpenLongFilePath
as open
23 # This class defined Report
25 # @param object: Inherited from object class
30 # @param self: The object pointer
31 # @param ReportName: name of the report
32 # @param FvObj: FV object after parsing FV images
34 def __init__(self
, ReportName
= 'Report.html', FvObj
= None, DispatchName
=None):
35 self
.ReportName
= ReportName
36 self
.Op
= open(ReportName
, 'w+')
37 self
.DispatchList
= None
39 self
.DispatchList
= open(DispatchName
, 'w+')
43 self
.ProtocolIndex
= 0
44 if EotGlobalData
.gMACRO
['EFI_SOURCE'] == '':
45 EotGlobalData
.gMACRO
['EFI_SOURCE'] = EotGlobalData
.gMACRO
['EDK_SOURCE']
49 # Write a line in the report
51 # @param self: The object pointer
52 # @param Line: The lint to be written into
54 def WriteLn(self
, Line
):
55 self
.Op
.write('%s\n' % Line
)
57 ## GenerateReport() method
59 # A caller to generate report
61 # @param self: The object pointer
63 def GenerateReport(self
):
68 self
.GenerateUnDispatchedList()
70 ## GenerateUnDispatchedList() method
72 # Create a list for not dispatched items
74 # @param self: The object pointer
76 def GenerateUnDispatchedList(self
):
78 EotGlobalData
.gOP_UN_DISPATCHED
.write('%s\n' % FvObj
.Name
)
79 for Item
in FvObj
.UnDispatchedFfsDict
:
80 EotGlobalData
.gOP_UN_DISPATCHED
.write('%s\n' % FvObj
.UnDispatchedFfsDict
[Item
])
82 ## GenerateFv() method
84 # Generate FV information
86 # @param self: The object pointer
91 <td width="20%%"><strong>Name</strong></td>
92 <td width="60%%"><strong>Guid</strong></td>
93 <td width="20%%"><strong>Size</strong></td>
97 for Info
in FvObj
.BasicInfo
:
106 </tr>""" % (FvName
, FvGuid
, FvSize
)
107 self
.WriteLn(Content
)
109 Content
= """ <td colspan="3"><table width="100%%" border="1">
111 self
.WriteLn(Content
)
113 EotGlobalData
.gOP_DISPATCH_ORDER
.write('Dispatched:\n')
114 for FfsId
in FvObj
.OrderedFfsDict
:
115 self
.GenerateFfs(FvObj
.OrderedFfsDict
[FfsId
])
116 Content
= """ </table></td>
118 self
.WriteLn(Content
)
121 Content
= """ <td colspan="3"><table width="100%%" border="1">
123 <tr><strong>UnDispatched</strong></tr>"""
124 self
.WriteLn(Content
)
126 EotGlobalData
.gOP_DISPATCH_ORDER
.write('\nUnDispatched:\n')
127 for FfsId
in FvObj
.UnDispatchedFfsDict
:
128 self
.GenerateFfs(FvObj
.UnDispatchedFfsDict
[FfsId
])
129 Content
= """ </table></td>
131 self
.WriteLn(Content
)
133 ## GenerateDepex() method
135 # Generate Depex information
137 # @param self: The object pointer
138 # @param DepexString: A DEPEX string needed to be parsed
140 def GenerateDepex(self
, DepexString
):
141 NonGuidList
= ['AND', 'OR', 'NOT', 'BEFORE', 'AFTER', 'TRUE', 'FALSE']
142 ItemList
= DepexString
.split(' ')
144 for Item
in ItemList
:
145 if Item
not in NonGuidList
:
146 SqlCommand
= """select DISTINCT GuidName from Report where GuidValue like '%s' and ItemMode = 'Produced' group by GuidName""" % (Item
)
147 RecordSet
= EotGlobalData
.gDb
.TblReport
.Exec(SqlCommand
)
149 Item
= RecordSet
[0][0]
150 DepexString
= DepexString
+ Item
+ ' '
152 <td width="5%%"></td>
153 <td width="95%%">%s</td>
154 </tr>""" % (DepexString
)
155 self
.WriteLn(Content
)
157 ## GeneratePpi() method
159 # Generate PPI information
161 # @param self: The object pointer
162 # @param Name: CName of a GUID
163 # @param Guid: Value of a GUID
164 # @param Type: Type of a GUID
166 def GeneratePpi(self
, Name
, Guid
, Type
):
167 self
.GeneratePpiProtocol('Ppi', Name
, Guid
, Type
, self
.PpiIndex
)
169 ## GenerateProtocol() method
171 # Generate PROTOCOL information
173 # @param self: The object pointer
174 # @param Name: CName of a GUID
175 # @param Guid: Value of a GUID
176 # @param Type: Type of a GUID
178 def GenerateProtocol(self
, Name
, Guid
, Type
):
179 self
.GeneratePpiProtocol('Protocol', Name
, Guid
, Type
, self
.ProtocolIndex
)
181 ## GeneratePpiProtocol() method
183 # Generate PPI/PROTOCOL information
185 # @param self: The object pointer
186 # @param Model: Model of a GUID, PPI or PROTOCOL
187 # @param Name: Name of a GUID
188 # @param Guid: Value of a GUID
189 # @param Type: Type of a GUID
190 # @param CName: CName(Index) of a GUID
192 def GeneratePpiProtocol(self
, Model
, Name
, Guid
, Type
, CName
):
194 <td width="5%%"></td>
195 <td width="10%%">%s</td>
196 <td width="85%%" colspan="3">%s</td>
198 </tr>""" % (Model
, Name
, Guid
)
199 self
.WriteLn(Content
)
200 if Type
== 'Produced':
201 SqlCommand
= """select DISTINCT SourceFileFullPath, BelongsToFunction from Report where GuidName like '%s' and ItemMode = 'Callback'""" % Name
202 RecordSet
= EotGlobalData
.gDb
.TblReport
.Exec(SqlCommand
)
203 for Record
in RecordSet
:
204 SqlCommand
= """select FullPath from File
206 select DISTINCT BelongsToFile from Inf
207 where Value1 like '%s')""" % Record
[0]
208 ModuleSet
= EotGlobalData
.gDb
.TblReport
.Exec(SqlCommand
)
209 Inf
= ModuleSet
[0][0].replace(EotGlobalData
.gMACRO
['WORKSPACE'], '.')
212 for Item
in EotGlobalData
.gMap
:
213 if Function
in EotGlobalData
.gMap
[Item
]:
214 Address
= EotGlobalData
.gMap
[Item
][Function
]
216 if '_' + Function
in EotGlobalData
.gMap
[Item
]:
217 Address
= EotGlobalData
.gMap
[Item
]['_' + Function
]
220 <td width="5%%"></td>
221 <td width="10%%">%s</td>
222 <td width="40%%">%s</td>
223 <td width="35%%">%s</td>
224 <td width="10%%">%s</td>
225 </tr>""" % ('Callback', Inf
, Function
, Address
)
226 self
.WriteLn(Content
)
228 ## GenerateFfs() method
230 # Generate FFS information
232 # @param self: The object pointer
233 # @param FfsObj: FFS object after FV image is parsed
235 def GenerateFfs(self
, FfsObj
):
236 self
.FfsIndex
= self
.FfsIndex
+ 1
237 if FfsObj
!= None and FfsObj
.Type
in [0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0xA]:
238 FfsGuid
= FfsObj
.Guid
239 FfsOffset
= FfsObj
._OFF
_
240 FfsName
= 'Unknown-Module'
242 FfsType
= FfsObj
._TypeName
[FfsObj
.Type
]
244 # Hard code for Binary INF
245 if FfsGuid
.upper() == '7BB28B99-61BB-11D5-9A5D-0090273FC14D':
248 if FfsGuid
.upper() == '7E374E25-8E01-4FEE-87F2-390C23C606CD':
249 FfsName
= 'AcpiTables'
251 if FfsGuid
.upper() == '961578FE-B6B7-44C3-AF35-6BC705CD2B1F':
254 # Find FFS Path and Name
255 SqlCommand
= """select Value2 from Inf
256 where BelongsToFile = (select BelongsToFile from Inf where Value1 = 'FILE_GUID' and lower(Value2) = lower('%s') and Model = %s)
257 and Model = %s and Value1='BASE_NAME'""" % (FfsGuid
, 5001, 5001)
258 RecordSet
= EotGlobalData
.gDb
.TblReport
.Exec(SqlCommand
)
260 FfsName
= RecordSet
[0][0]
262 SqlCommand
= """select FullPath from File
263 where ID = (select BelongsToFile from Inf where Value1 = 'FILE_GUID' and lower(Value2) = lower('%s') and Model = %s)
264 and Model = %s""" % (FfsGuid
, 5001, 1011)
265 RecordSet
= EotGlobalData
.gDb
.TblReport
.Exec(SqlCommand
)
267 FfsPath
= RecordSet
[0][0]
270 <tr class='styleFfs' id='FfsHeader%s'>
271 <td width="55%%"><span onclick="Display('FfsHeader%s', 'Ffs%s')" onMouseOver="funOnMouseOver()" onMouseOut="funOnMouseOut()">%s</span></td>
272 <td width="15%%">%s</td>
273 <!--<td width="20%%">%s</td>-->
274 <!--<td width="20%%">%s</td>-->
275 <td width="10%%">%s</td>
277 <tr id='Ffs%s' style='display:none;'>
278 <td colspan="4"><table width="100%%" border="1">""" % (self
.FfsIndex
, self
.FfsIndex
, self
.FfsIndex
, FfsPath
, FfsName
, FfsGuid
, FfsOffset
, FfsType
, self
.FfsIndex
)
280 if self
.DispatchList
:
281 if FfsObj
.Type
in [0x04, 0x06]:
282 self
.DispatchList
.write("%s %s %s %s\n" % (FfsGuid
, "P", FfsName
, FfsPath
))
283 if FfsObj
.Type
in [0x05, 0x07, 0x08, 0x0A]:
284 self
.DispatchList
.write("%s %s %s %s\n" % (FfsGuid
, "D", FfsName
, FfsPath
))
286 self
.WriteLn(Content
)
288 EotGlobalData
.gOP_DISPATCH_ORDER
.write('%s\n' %FfsName
)
290 if FfsObj
.Depex
!= '':
292 <td><span id='DepexHeader%s' class="styleDepex" onclick="Display('DepexHeader%s', 'Depex%s')" onMouseOver="funOnMouseOver()" onMouseOut="funOnMouseOut()">  DEPEX expression</span></td>
294 <tr id='Depex%s' style='display:none;'>
295 <td><table width="100%%" border="1">""" % (self
.FfsIndex
, self
.FfsIndex
, self
.FfsIndex
, self
.FfsIndex
)
296 self
.WriteLn(Content
)
297 self
.GenerateDepex(FfsObj
.Depex
)
298 Content
= """ </table></td>
300 self
.WriteLn(Content
)
303 # Find Consumed Ppi/Protocol
304 SqlCommand
= """select ModuleName, ItemType, GuidName, GuidValue, GuidMacro from Report
305 where SourceFileFullPath in
306 (select Value1 from Inf where BelongsToFile =
307 (select BelongsToFile from Inf
308 where Value1 = 'FILE_GUID' and Value2 like '%s' and Model = %s)
310 and ItemMode = 'Consumed' group by GuidName order by ItemType""" \
311 % (FfsGuid
, 5001, 3007)
313 RecordSet
= EotGlobalData
.gDb
.TblReport
.Exec(SqlCommand
)
315 Count
= len(RecordSet
)
317 <td><span id='ConsumedHeader%s' class="styleConsumed" onclick="Display('ConsumedHeader%s', 'Consumed%s')" onMouseOver="funOnMouseOver()" onMouseOut="funOnMouseOut()">  Consumed Ppis/Protocols List (%s)</span></td>
319 <tr id='Consumed%s' style='display:none;'>
320 <td><table width="100%%" border="1">""" % (self
.FfsIndex
, self
.FfsIndex
, self
.FfsIndex
, Count
, self
.FfsIndex
)
321 self
.WriteLn(Content
)
322 self
.ProtocolIndex
= 0
323 for Record
in RecordSet
:
324 self
.ProtocolIndex
= self
.ProtocolIndex
+ 1
329 self
.GeneratePpiProtocol(Type
, Name
, Guid
, 'Consumed', CName
)
331 Content
= """ </table></td>
333 self
.WriteLn(Content
)
334 #End of Consumed Ppi/Portocol
336 # Find Produced Ppi/Protocol
337 SqlCommand
= """select ModuleName, ItemType, GuidName, GuidValue, GuidMacro from Report
338 where SourceFileFullPath in
339 (select Value1 from Inf where BelongsToFile =
340 (select BelongsToFile from Inf
341 where Value1 = 'FILE_GUID' and Value2 like '%s' and Model = %s)
343 and ItemMode = 'Produced' group by GuidName order by ItemType""" \
344 % (FfsGuid
, 5001, 3007)
346 RecordSet
= EotGlobalData
.gDb
.TblReport
.Exec(SqlCommand
)
348 Count
= len(RecordSet
)
350 <td><span id='ProducedHeader%s' class="styleProduced" onclick="Display('ProducedHeader%s', 'Produced%s')" onMouseOver="funOnMouseOver()" onMouseOut="funOnMouseOut()">  Produced Ppis/Protocols List (%s)</span></td>
352 <tr id='Produced%s' style='display:none;'>
353 <td><table width="100%%" border="1">""" % (self
.FfsIndex
, self
.FfsIndex
, self
.FfsIndex
, Count
, self
.FfsIndex
)
354 self
.WriteLn(Content
)
356 for Record
in RecordSet
:
357 self
.PpiIndex
= self
.PpiIndex
+ 1
362 self
.GeneratePpiProtocol(Type
, Name
, Guid
, 'Produced', CName
)
364 Content
= """ </table></td>
366 self
.WriteLn(Content
)
368 # End of Produced Ppi/Protocol
370 Content
= """ </table></td>
372 self
.WriteLn(Content
)
374 ## GenerateTail() method
376 # Generate end tags of HTML report
378 # @param self: The object pointer
380 def GenerateTail(self
):
386 ## GenerateHeader() method
388 # Generate start tags of HTML report
390 # @param self: The object pointer
392 def GenerateHeader(self
):
393 Header
= """<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
394 "http://www.w3.org/TR/html4/loose.dtd">
397 <title>Execution Order Tool Report</title>
398 <meta http-equiv="Content-Type" content="text/html">
399 <style type="text/css">
419 <Script type="text/javascript">
420 function Display(ParentID, SubID)
422 SubItem = document.getElementById(SubID);
423 ParentItem = document.getElementById(ParentID);
424 if (SubItem.style.display == 'none')
426 SubItem.style.display = ''
427 ParentItem.style.fontWeight = 'normal'
431 SubItem.style.display = 'none'
432 ParentItem.style.fontWeight = 'bold'
437 function funOnMouseOver()
439 document.body.style.cursor = "hand";
442 function funOnMouseOut()
444 document.body.style.cursor = "";
451 <table width="100%%" border="1">"""
456 # This acts like the main() function for the script, unless it is 'import'ed into another
459 if __name__
== '__main__':
460 # Initialize log system
461 FilePath
= 'FVRECOVERYFLOPPY.fv'
462 if FilePath
.lower().endswith(".fv"):
463 fd
= open(FilePath
, 'rb')
466 buf
.fromfile(fd
, os
.path
.getsize(FilePath
))
470 fv
= FirmwareVolume("FVRECOVERY", buf
, 0)
472 report
= Report('Report.html', fv
)
473 report
.GenerateReport()