## @file
# This file is used to create report for Eot tool
#
# Copyright (c) 2008 - 2010, Intel Corporation
# All rights reserved. This program and the accompanying materials
# are licensed and made available under the terms and conditions of the BSD License
# which accompanies this distribution. The full text of the license may be found at
# http://opensource.org/licenses/bsd-license.php
#
# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
#
##
# Import Modules
#
import os
import EotGlobalData
## Report() class
#
# This class defined Report
#
# @param object: Inherited from object class
#
class Report(object):
## The constructor
#
# @param self: The object pointer
# @param ReportName: name of the report
# @param FvObj: FV object after parsing FV images
#
def __init__(self, ReportName = 'Report.html', FvObj = None, DispatchName=None):
self.ReportName = ReportName
self.Op = open(ReportName, 'w+')
self.DispatchList = None
if DispatchName:
self.DispatchList = open(DispatchName, 'w+')
self.FvObj = FvObj
self.FfsIndex = 0
self.PpiIndex = 0
self.ProtocolIndex = 0
if EotGlobalData.gMACRO['EFI_SOURCE'] == '':
EotGlobalData.gMACRO['EFI_SOURCE'] = EotGlobalData.gMACRO['EDK_SOURCE']
## WriteLn() method
#
# Write a line in the report
#
# @param self: The object pointer
# @param Line: The lint to be written into
#
def WriteLn(self, Line):
self.Op.write('%s\n' % Line)
## GenerateReport() method
#
# A caller to generate report
#
# @param self: The object pointer
#
def GenerateReport(self):
self.GenerateHeader()
self.GenerateFv()
self.GenerateTail()
self.Op.close()
self.GenerateUnDispatchedList()
## GenerateUnDispatchedList() method
#
# Create a list for not dispatched items
#
# @param self: The object pointer
#
def GenerateUnDispatchedList(self):
FvObj = self.FvObj
EotGlobalData.gOP_UN_DISPATCHED.write('%s\n' % FvObj.Name)
for Item in FvObj.UnDispatchedFfsDict:
EotGlobalData.gOP_UN_DISPATCHED.write('%s\n' % FvObj.UnDispatchedFfsDict[Item])
## GenerateFv() method
#
# Generate FV information
#
# @param self: The object pointer
#
def GenerateFv(self):
FvObj = self.FvObj
Content = """
""" % (self.FfsIndex, self.FfsIndex, self.FfsIndex, FfsPath, FfsName, FfsGuid, FfsOffset, FfsType, self.FfsIndex)
if self.DispatchList:
if FfsObj.Type in [0x04, 0x06]:
self.DispatchList.write("%s %s %s %s\n" % (FfsGuid, "P", FfsName, FfsPath))
if FfsObj.Type in [0x05, 0x07, 0x08, 0x0A]:
self.DispatchList.write("%s %s %s %s\n" % (FfsGuid, "D", FfsName, FfsPath))
self.WriteLn(Content)
EotGlobalData.gOP_DISPATCH_ORDER.write('%s\n' %FfsName)
if FfsObj.Depex != '':
Content = """
|
""" % (self.FfsIndex, self.FfsIndex, self.FfsIndex, self.FfsIndex)
self.WriteLn(Content)
self.GenerateDepex(FfsObj.Depex)
Content = """ |
"""
self.WriteLn(Content)
# End of DEPEX
# Find Consumed Ppi/Protocol
SqlCommand = """select ModuleName, ItemType, GuidName, GuidValue, GuidMacro from Report
where SourceFileFullPath in
(select Value1 from Inf where BelongsToFile =
(select BelongsToFile from Inf
where Value1 = 'FILE_GUID' and Value2 like '%s' and Model = %s)
and Model = %s)
and ItemMode = 'Consumed' group by GuidName order by ItemType""" \
% (FfsGuid, 5001, 3007)
RecordSet = EotGlobalData.gDb.TblReport.Exec(SqlCommand)
if RecordSet != []:
Count = len(RecordSet)
Content = """
|
""" % (self.FfsIndex, self.FfsIndex, self.FfsIndex, Count, self.FfsIndex)
self.WriteLn(Content)
self.ProtocolIndex = 0
for Record in RecordSet:
self.ProtocolIndex = self.ProtocolIndex + 1
Name = Record[2]
CName = Record[4]
Guid = Record[3]
Type = Record[1]
self.GeneratePpiProtocol(Type, Name, Guid, 'Consumed', CName)
Content = """ |
"""
self.WriteLn(Content)
#End of Consumed Ppi/Portocol
# Find Produced Ppi/Protocol
SqlCommand = """select ModuleName, ItemType, GuidName, GuidValue, GuidMacro from Report
where SourceFileFullPath in
(select Value1 from Inf where BelongsToFile =
(select BelongsToFile from Inf
where Value1 = 'FILE_GUID' and Value2 like '%s' and Model = %s)
and Model = %s)
and ItemMode = 'Produced' group by GuidName order by ItemType""" \
% (FfsGuid, 5001, 3007)
RecordSet = EotGlobalData.gDb.TblReport.Exec(SqlCommand)
if RecordSet != []:
Count = len(RecordSet)
Content = """
|
""" % (self.FfsIndex, self.FfsIndex, self.FfsIndex, Count, self.FfsIndex)
self.WriteLn(Content)
self.PpiIndex = 0
for Record in RecordSet:
self.PpiIndex = self.PpiIndex + 1
Name = Record[2]
CName = Record[4]
Guid = Record[3]
Type = Record[1]
self.GeneratePpiProtocol(Type, Name, Guid, 'Produced', CName)
Content = """ |
"""
self.WriteLn(Content)
RecordSet = None
# End of Produced Ppi/Protocol
Content = """ |
"""
self.WriteLn(Content)
## GenerateTail() method
#
# Generate end tags of HTML report
#
# @param self: The object pointer
#
def GenerateTail(self):
Tail = """