summaryrefslogtreecommitdiffstats
path: root/src/VBox/Devices/EFI/Firmware/BaseTools/Source/Python/Table
diff options
context:
space:
mode:
Diffstat (limited to 'src/VBox/Devices/EFI/Firmware/BaseTools/Source/Python/Table')
-rwxr-xr-xsrc/VBox/Devices/EFI/Firmware/BaseTools/Source/Python/Table/Table.py114
-rwxr-xr-xsrc/VBox/Devices/EFI/Firmware/BaseTools/Source/Python/Table/TableDataModel.py90
-rwxr-xr-xsrc/VBox/Devices/EFI/Firmware/BaseTools/Source/Python/Table/TableDec.py103
-rwxr-xr-xsrc/VBox/Devices/EFI/Firmware/BaseTools/Source/Python/Table/TableDsc.py103
-rwxr-xr-xsrc/VBox/Devices/EFI/Firmware/BaseTools/Source/Python/Table/TableEotReport.py71
-rwxr-xr-xsrc/VBox/Devices/EFI/Firmware/BaseTools/Source/Python/Table/TableFdf.py104
-rwxr-xr-xsrc/VBox/Devices/EFI/Firmware/BaseTools/Source/Python/Table/TableFile.py99
-rwxr-xr-xsrc/VBox/Devices/EFI/Firmware/BaseTools/Source/Python/Table/TableFunction.py90
-rwxr-xr-xsrc/VBox/Devices/EFI/Firmware/BaseTools/Source/Python/Table/TableIdentifier.py85
-rwxr-xr-xsrc/VBox/Devices/EFI/Firmware/BaseTools/Source/Python/Table/TableInf.py109
-rwxr-xr-xsrc/VBox/Devices/EFI/Firmware/BaseTools/Source/Python/Table/TablePcd.py85
-rwxr-xr-xsrc/VBox/Devices/EFI/Firmware/BaseTools/Source/Python/Table/TableQuery.py63
-rwxr-xr-xsrc/VBox/Devices/EFI/Firmware/BaseTools/Source/Python/Table/TableReport.py127
-rw-r--r--src/VBox/Devices/EFI/Firmware/BaseTools/Source/Python/Table/__init__.py9
14 files changed, 1252 insertions, 0 deletions
diff --git a/src/VBox/Devices/EFI/Firmware/BaseTools/Source/Python/Table/Table.py b/src/VBox/Devices/EFI/Firmware/BaseTools/Source/Python/Table/Table.py
new file mode 100755
index 00000000..3d6e3c6f
--- /dev/null
+++ b/src/VBox/Devices/EFI/Firmware/BaseTools/Source/Python/Table/Table.py
@@ -0,0 +1,114 @@
+## @file
+# This file is used to create/update/query/erase a common table
+#
+# Copyright (c) 2008 - 2018, Intel Corporation. All rights reserved.<BR>
+# SPDX-License-Identifier: BSD-2-Clause-Patent
+#
+
+##
+# Import Modules
+#
+import Common.EdkLogger as EdkLogger
+
+## TableFile
+#
+# This class defined a common table
+#
+# @param object: Inherited from object class
+#
+# @param Cursor: Cursor of the database
+# @param TableName: Name of the table
+#
+class Table(object):
+ def __init__(self, Cursor):
+ self.Cur = Cursor
+ self.Table = ''
+ self.ID = 0
+
+ ## Create table
+ #
+ # Create a table
+ #
+ def Create(self, SqlCommand):
+ self.Cur.execute(SqlCommand)
+ self.ID = 0
+ EdkLogger.verbose(SqlCommand + " ... DONE!")
+
+ ## Insert table
+ #
+ # Insert a record into a table
+ #
+ def Insert(self, SqlCommand):
+ self.Exec(SqlCommand)
+
+ ## Query table
+ #
+ # Query all records of the table
+ #
+ def Query(self):
+ EdkLogger.verbose("\nQuery table %s started ..." % self.Table)
+ SqlCommand = """select * from %s""" % self.Table
+ self.Cur.execute(SqlCommand)
+ for Rs in self.Cur:
+ EdkLogger.verbose(str(Rs))
+
+ TotalCount = self.GetCount()
+ EdkLogger.verbose("*** Total %s records in table %s ***" % (TotalCount, self.Table) )
+ EdkLogger.verbose("Query tabel %s DONE!" % self.Table)
+
+ ## Drop a table
+ #
+ # Drop the table
+ #
+ def Drop(self):
+ SqlCommand = """drop table IF EXISTS %s""" % self.Table
+ self.Cur.execute(SqlCommand)
+ EdkLogger.verbose("Drop tabel %s ... DONE!" % self.Table)
+
+ ## Get count
+ #
+ # Get a count of all records of the table
+ #
+ # @retval Count: Total count of all records
+ #
+ def GetCount(self):
+ SqlCommand = """select count(ID) from %s""" % self.Table
+ self.Cur.execute(SqlCommand)
+ for Item in self.Cur:
+ return Item[0]
+
+ ## Generate ID
+ #
+ # Generate an ID if input ID is -1
+ #
+ # @param ID: Input ID
+ #
+ # @retval ID: New generated ID
+ #
+ def GenerateID(self, ID):
+ if ID == -1:
+ self.ID = self.ID + 1
+
+ return self.ID
+
+ ## Init the ID of the table
+ #
+ # Init the ID of the table
+ #
+ def InitID(self):
+ self.ID = self.GetCount()
+
+ ## Exec
+ #
+ # Exec Sql Command, return result
+ #
+ # @param SqlCommand: The SqlCommand to be executed
+ #
+ # @retval RecordSet: The result after executed
+ #
+ def Exec(self, SqlCommand):
+ EdkLogger.debug(4, "SqlCommand: %s" % SqlCommand)
+ self.Cur.execute(SqlCommand)
+ RecordSet = self.Cur.fetchall()
+ EdkLogger.debug(4, "RecordSet: %s" % RecordSet)
+ return RecordSet
diff --git a/src/VBox/Devices/EFI/Firmware/BaseTools/Source/Python/Table/TableDataModel.py b/src/VBox/Devices/EFI/Firmware/BaseTools/Source/Python/Table/TableDataModel.py
new file mode 100755
index 00000000..fa8b1dfa
--- /dev/null
+++ b/src/VBox/Devices/EFI/Firmware/BaseTools/Source/Python/Table/TableDataModel.py
@@ -0,0 +1,90 @@
+## @file
+# This file is used to create/update/query/erase table for data models
+#
+# Copyright (c) 2008 - 2018, Intel Corporation. All rights reserved.<BR>
+# SPDX-License-Identifier: BSD-2-Clause-Patent
+#
+
+##
+# Import Modules
+#
+from __future__ import absolute_import
+import Common.EdkLogger as EdkLogger
+import CommonDataClass.DataClass as DataClass
+from Table.Table import Table
+from Common.StringUtils import ConvertToSqlString
+
+## TableDataModel
+#
+# This class defined a table used for data model
+#
+# @param object: Inherited from object class
+#
+#
+class TableDataModel(Table):
+ def __init__(self, Cursor):
+ Table.__init__(self, Cursor)
+ self.Table = 'DataModel'
+
+ ## Create table
+ #
+ # Create table DataModel
+ #
+ # @param ID: ID of a ModelType
+ # @param CrossIndex: CrossIndex of a ModelType
+ # @param Name: Name of a ModelType
+ # @param Description: Description of a ModelType
+ #
+ def Create(self):
+ SqlCommand = """create table IF NOT EXISTS %s (ID INTEGER PRIMARY KEY,
+ CrossIndex INTEGER NOT NULL,
+ Name VARCHAR NOT NULL,
+ Description VARCHAR
+ )""" % self.Table
+ Table.Create(self, SqlCommand)
+
+ ## Insert table
+ #
+ # Insert a record into table DataModel
+ #
+ # @param ID: ID of a ModelType
+ # @param CrossIndex: CrossIndex of a ModelType
+ # @param Name: Name of a ModelType
+ # @param Description: Description of a ModelType
+ #
+ def Insert(self, CrossIndex, Name, Description):
+ self.ID = self.ID + 1
+ (Name, Description) = ConvertToSqlString((Name, Description))
+ SqlCommand = """insert into %s values(%s, %s, '%s', '%s')""" % (self.Table, self.ID, CrossIndex, Name, Description)
+ Table.Insert(self, SqlCommand)
+
+ return self.ID
+
+ ## Init table
+ #
+ # Create all default records of table DataModel
+ #
+ def InitTable(self):
+ EdkLogger.verbose("\nInitialize table DataModel started ...")
+ for Item in DataClass.MODEL_LIST:
+ CrossIndex = Item[1]
+ Name = Item[0]
+ Description = Item[0]
+ self.Insert(CrossIndex, Name, Description)
+ EdkLogger.verbose("Initialize table DataModel ... DONE!")
+
+ ## Get CrossIndex
+ #
+ # Get a model's cross index from its name
+ #
+ # @param ModelName: Name of the model
+ # @retval CrossIndex: CrossIndex of the model
+ #
+ def GetCrossIndex(self, ModelName):
+ CrossIndex = -1
+ SqlCommand = """select CrossIndex from DataModel where name = '""" + ModelName + """'"""
+ self.Cur.execute(SqlCommand)
+ for Item in self.Cur:
+ CrossIndex = Item[0]
+
+ return CrossIndex
diff --git a/src/VBox/Devices/EFI/Firmware/BaseTools/Source/Python/Table/TableDec.py b/src/VBox/Devices/EFI/Firmware/BaseTools/Source/Python/Table/TableDec.py
new file mode 100755
index 00000000..b6297a3d
--- /dev/null
+++ b/src/VBox/Devices/EFI/Firmware/BaseTools/Source/Python/Table/TableDec.py
@@ -0,0 +1,103 @@
+## @file
+# This file is used to create/update/query/erase table for dec datas
+#
+# Copyright (c) 2008 - 2018, Intel Corporation. All rights reserved.<BR>
+# SPDX-License-Identifier: BSD-2-Clause-Patent
+#
+
+##
+# Import Modules
+#
+from __future__ import absolute_import
+import Common.EdkLogger as EdkLogger
+import CommonDataClass.DataClass as DataClass
+from Table.Table import Table
+from Common.StringUtils import ConvertToSqlString
+
+## TableDec
+#
+# This class defined a table used for data model
+#
+# @param object: Inherited from object class
+#
+#
+class TableDec(Table):
+ def __init__(self, Cursor):
+ Table.__init__(self, Cursor)
+ self.Table = 'Dec'
+
+ ## Create table
+ #
+ # Create table Dec
+ #
+ # @param ID: ID of a Dec item
+ # @param Model: Model of a Dec item
+ # @param Value1: Value1 of a Dec item
+ # @param Value2: Value2 of a Dec item
+ # @param Value3: Value3 of a Dec item
+ # @param Arch: Arch of a Dec item
+ # @param BelongsToItem: The item belongs to which another item
+ # @param BelongsToFile: The item belongs to which dsc file
+ # @param StartLine: StartLine of a Dec item
+ # @param StartColumn: StartColumn of a Dec item
+ # @param EndLine: EndLine of a Dec item
+ # @param EndColumn: EndColumn of a Dec item
+ # @param Enabled: If this item enabled
+ #
+ def Create(self):
+ SqlCommand = """create table IF NOT EXISTS %s (ID INTEGER PRIMARY KEY,
+ Model INTEGER NOT NULL,
+ Value1 VARCHAR NOT NULL,
+ Value2 VARCHAR,
+ Value3 VARCHAR,
+ Arch VarCHAR,
+ BelongsToItem SINGLE NOT NULL,
+ BelongsToFile SINGLE NOT NULL,
+ StartLine INTEGER NOT NULL,
+ StartColumn INTEGER NOT NULL,
+ EndLine INTEGER NOT NULL,
+ EndColumn INTEGER NOT NULL,
+ Enabled INTEGER DEFAULT 0
+ )""" % self.Table
+ Table.Create(self, SqlCommand)
+
+ ## Insert table
+ #
+ # Insert a record into table Dec
+ #
+ # @param ID: ID of a Dec item
+ # @param Model: Model of a Dec item
+ # @param Value1: Value1 of a Dec item
+ # @param Value2: Value2 of a Dec item
+ # @param Value3: Value3 of a Dec item
+ # @param Arch: Arch of a Dec item
+ # @param BelongsToItem: The item belongs to which another item
+ # @param BelongsToFile: The item belongs to which dsc file
+ # @param StartLine: StartLine of a Dec item
+ # @param StartColumn: StartColumn of a Dec item
+ # @param EndLine: EndLine of a Dec item
+ # @param EndColumn: EndColumn of a Dec item
+ # @param Enabled: If this item enabled
+ #
+ def Insert(self, Model, Value1, Value2, Value3, Value4, Value5, Arch, BelongsToItem, BelongsToFile, StartLine, StartColumn, EndLine, EndColumn, Enabled):
+ self.ID = self.ID + 1
+ (Value1, Value2, Value3, Arch) = ConvertToSqlString((Value1, Value2, Value3, Arch))
+ SqlCommand = """insert into %s values(%s, %s, '%s', '%s', '%s', '%s', %s, %s, %s, %s, %s, %s, %s)""" \
+ % (self.Table, self.ID, Model, Value1, Value2, Value3, Arch, BelongsToItem, BelongsToFile, StartLine, StartColumn, EndLine, EndColumn, Enabled)
+ Table.Insert(self, SqlCommand)
+
+ return self.ID
+
+ ## Query table
+ #
+ # @param Model: The Model of Record
+ #
+ # @retval: A recordSet of all found records
+ #
+ def Query(self, Model):
+ SqlCommand = """select ID, Value1, Value2, Value3, Arch, BelongsToItem, BelongsToFile, StartLine from %s
+ where Model = %s
+ and Enabled > -1""" % (self.Table, Model)
+ EdkLogger.debug(4, "SqlCommand: %s" % SqlCommand)
+ self.Cur.execute(SqlCommand)
+ return self.Cur.fetchall()
diff --git a/src/VBox/Devices/EFI/Firmware/BaseTools/Source/Python/Table/TableDsc.py b/src/VBox/Devices/EFI/Firmware/BaseTools/Source/Python/Table/TableDsc.py
new file mode 100755
index 00000000..8cca2db6
--- /dev/null
+++ b/src/VBox/Devices/EFI/Firmware/BaseTools/Source/Python/Table/TableDsc.py
@@ -0,0 +1,103 @@
+from __future__ import absolute_import
+## @file
+# This file is used to create/update/query/erase table for dsc datas
+#
+# Copyright (c) 2008 - 2018, Intel Corporation. All rights reserved.<BR>
+# SPDX-License-Identifier: BSD-2-Clause-Patent
+#
+
+##
+# Import Modules
+#
+import Common.EdkLogger as EdkLogger
+import CommonDataClass.DataClass as DataClass
+from Table.Table import Table
+from Common.StringUtils import ConvertToSqlString
+
+## TableDsc
+#
+# This class defined a table used for data model
+#
+# @param object: Inherited from object class
+#
+#
+class TableDsc(Table):
+ def __init__(self, Cursor):
+ Table.__init__(self, Cursor)
+ self.Table = 'Dsc'
+
+ ## Create table
+ #
+ # Create table Dsc
+ #
+ # @param ID: ID of a Dsc item
+ # @param Model: Model of a Dsc item
+ # @param Value1: Value1 of a Dsc item
+ # @param Value2: Value2 of a Dsc item
+ # @param Value3: Value3 of a Dsc item
+ # @param Arch: Arch of a Dsc item
+ # @param BelongsToItem: The item belongs to which another item
+ # @param BelongsToFile: The item belongs to which dsc file
+ # @param StartLine: StartLine of a Dsc item
+ # @param StartColumn: StartColumn of a Dsc item
+ # @param EndLine: EndLine of a Dsc item
+ # @param EndColumn: EndColumn of a Dsc item
+ # @param Enabled: If this item enabled
+ #
+ def Create(self):
+ SqlCommand = """create table IF NOT EXISTS %s (ID INTEGER PRIMARY KEY,
+ Model INTEGER NOT NULL,
+ Value1 VARCHAR NOT NULL,
+ Value2 VARCHAR,
+ Value3 VARCHAR,
+ Arch VarCHAR,
+ BelongsToItem SINGLE NOT NULL,
+ BelongsToFile SINGLE NOT NULL,
+ StartLine INTEGER NOT NULL,
+ StartColumn INTEGER NOT NULL,
+ EndLine INTEGER NOT NULL,
+ EndColumn INTEGER NOT NULL,
+ Enabled INTEGER DEFAULT 0
+ )""" % self.Table
+ Table.Create(self, SqlCommand)
+
+ ## Insert table
+ #
+ # Insert a record into table Dsc
+ #
+ # @param ID: ID of a Dsc item
+ # @param Model: Model of a Dsc item
+ # @param Value1: Value1 of a Dsc item
+ # @param Value2: Value2 of a Dsc item
+ # @param Value3: Value3 of a Dsc item
+ # @param Arch: Arch of a Dsc item
+ # @param BelongsToItem: The item belongs to which another item
+ # @param BelongsToFile: The item belongs to which dsc file
+ # @param StartLine: StartLine of a Dsc item
+ # @param StartColumn: StartColumn of a Dsc item
+ # @param EndLine: EndLine of a Dsc item
+ # @param EndColumn: EndColumn of a Dsc item
+ # @param Enabled: If this item enabled
+ #
+ def Insert(self, Model, Value1, Value2, Value3, Arch, BelongsToItem, BelongsToFile, StartLine, StartColumn, EndLine, EndColumn, Enabled):
+ self.ID = self.ID + 1
+ (Value1, Value2, Value3, Arch) = ConvertToSqlString((Value1, Value2, Value3, Arch))
+ SqlCommand = """insert into %s values(%s, %s, '%s', '%s', '%s', '%s', %s, %s, %s, %s, %s, %s, %s)""" \
+ % (self.Table, self.ID, Model, Value1, Value2, Value3, Arch, BelongsToItem, BelongsToFile, StartLine, StartColumn, EndLine, EndColumn, Enabled)
+ Table.Insert(self, SqlCommand)
+
+ return self.ID
+
+ ## Query table
+ #
+ # @param Model: The Model of Record
+ #
+ # @retval: A recordSet of all found records
+ #
+ def Query(self, Model):
+ SqlCommand = """select ID, Value1, Value2, Value3, Arch, BelongsToItem, BelongsToFile, StartLine from %s
+ where Model = %s
+ and Enabled > -1""" % (self.Table, Model)
+ EdkLogger.debug(4, "SqlCommand: %s" % SqlCommand)
+ self.Cur.execute(SqlCommand)
+ return self.Cur.fetchall()
diff --git a/src/VBox/Devices/EFI/Firmware/BaseTools/Source/Python/Table/TableEotReport.py b/src/VBox/Devices/EFI/Firmware/BaseTools/Source/Python/Table/TableEotReport.py
new file mode 100755
index 00000000..c54b6c62
--- /dev/null
+++ b/src/VBox/Devices/EFI/Firmware/BaseTools/Source/Python/Table/TableEotReport.py
@@ -0,0 +1,71 @@
+## @file
+# This file is used to create/update/query/erase table for ECC reports
+#
+# Copyright (c) 2008 - 2018, Intel Corporation. All rights reserved.<BR>
+# SPDX-License-Identifier: BSD-2-Clause-Patent
+#
+
+##
+# Import Modules
+#
+from __future__ import absolute_import
+import Common.EdkLogger as EdkLogger
+import Common.LongFilePathOs as os, time
+from Table.Table import Table
+from Common.StringUtils import ConvertToSqlString2
+import Eot.EotToolError as EotToolError
+import Eot.EotGlobalData as EotGlobalData
+
+## TableReport
+#
+# This class defined a table used for data model
+#
+# @param object: Inherited from object class
+#
+#
+class TableEotReport(Table):
+ def __init__(self, Cursor):
+ Table.__init__(self, Cursor)
+ self.Table = 'Report'
+
+ ## Create table
+ #
+ # Create table report
+ #
+ #
+ def Create(self):
+ SqlCommand = """create table IF NOT EXISTS %s (ID INTEGER PRIMARY KEY,
+ ModuleID INTEGER DEFAULT -1,
+ ModuleName TEXT DEFAULT '',
+ ModuleGuid TEXT DEFAULT '',
+ SourceFileID INTEGER DEFAULT -1,
+ SourceFileFullPath TEXT DEFAULT '',
+ ItemName TEXT DEFAULT '',
+ ItemType TEXT DEFAULT '',
+ ItemMode TEXT DEFAULT '',
+ GuidName TEXT DEFAULT '',
+ GuidMacro TEXT DEFAULT '',
+ GuidValue TEXT DEFAULT '',
+ BelongsToFunction TEXT DEFAULT '',
+ Enabled INTEGER DEFAULT 0
+ )""" % self.Table
+ Table.Create(self, SqlCommand)
+
+ ## Insert table
+ #
+ # Insert a record into table report
+ #
+ #
+ def Insert(self, ModuleID = -1, ModuleName = '', ModuleGuid = '', SourceFileID = -1, SourceFileFullPath = '', \
+ ItemName = '', ItemType = '', ItemMode = '', GuidName = '', GuidMacro = '', GuidValue = '', BelongsToFunction = '', Enabled = 0):
+ self.ID = self.ID + 1
+ SqlCommand = """insert into %s values(%s, %s, '%s', '%s', %s, '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', %s)""" \
+ % (self.Table, self.ID, ModuleID, ModuleName, ModuleGuid, SourceFileID, SourceFileFullPath, \
+ ItemName, ItemType, ItemMode, GuidName, GuidMacro, GuidValue, BelongsToFunction, Enabled)
+ Table.Insert(self, SqlCommand)
+
+ def GetMaxID(self):
+ SqlCommand = """select max(ID) from %s""" % self.Table
+ self.Cur.execute(SqlCommand)
+ for Item in self.Cur:
+ return Item[0]
diff --git a/src/VBox/Devices/EFI/Firmware/BaseTools/Source/Python/Table/TableFdf.py b/src/VBox/Devices/EFI/Firmware/BaseTools/Source/Python/Table/TableFdf.py
new file mode 100755
index 00000000..14b8919f
--- /dev/null
+++ b/src/VBox/Devices/EFI/Firmware/BaseTools/Source/Python/Table/TableFdf.py
@@ -0,0 +1,104 @@
+## @file
+# This file is used to create/update/query/erase table for fdf datas
+#
+# Copyright (c) 2008 - 2018, Intel Corporation. All rights reserved.<BR>
+# SPDX-License-Identifier: BSD-2-Clause-Patent
+#
+
+##
+# Import Modules
+#
+from __future__ import absolute_import
+import Common.EdkLogger as EdkLogger
+import CommonDataClass.DataClass as DataClass
+from Table.Table import Table
+from Common.StringUtils import ConvertToSqlString
+
+## TableFdf
+#
+# This class defined a table used for data model
+#
+# @param object: Inherited from object class
+#
+#
+class TableFdf(Table):
+ def __init__(self, Cursor):
+ Table.__init__(self, Cursor)
+ self.Table = 'Fdf'
+
+ ## Create table
+ #
+ # Create table Fdf
+ #
+ # @param ID: ID of a Fdf item
+ # @param Model: Model of a Fdf item
+ # @param Value1: Value1 of a Fdf item
+ # @param Value2: Value2 of a Fdf item
+ # @param Value3: Value3 of a Fdf item
+ # @param Arch: Arch of a Fdf item
+ # @param BelongsToItem: The item belongs to which another item
+ # @param BelongsToFile: The item belongs to which fdf file
+ # @param StartLine: StartLine of a Fdf item
+ # @param StartColumn: StartColumn of a Fdf item
+ # @param EndLine: EndLine of a Fdf item
+ # @param EndColumn: EndColumn of a Fdf item
+ # @param Enabled: If this item enabled
+ #
+ def Create(self):
+ SqlCommand = """create table IF NOT EXISTS %s (ID INTEGER PRIMARY KEY,
+ Model INTEGER NOT NULL,
+ Value1 VARCHAR NOT NULL,
+ Value2 VARCHAR,
+ Value3 VARCHAR,
+ Scope1 VarCHAR,
+ Scope2 VarCHAR,
+ BelongsToItem SINGLE NOT NULL,
+ BelongsToFile SINGLE NOT NULL,
+ StartLine INTEGER NOT NULL,
+ StartColumn INTEGER NOT NULL,
+ EndLine INTEGER NOT NULL,
+ EndColumn INTEGER NOT NULL,
+ Enabled INTEGER DEFAULT 0
+ )""" % self.Table
+ Table.Create(self, SqlCommand)
+
+ ## Insert table
+ #
+ # Insert a record into table Fdf
+ #
+ # @param ID: ID of a Fdf item
+ # @param Model: Model of a Fdf item
+ # @param Value1: Value1 of a Fdf item
+ # @param Value2: Value2 of a Fdf item
+ # @param Value3: Value3 of a Fdf item
+ # @param Arch: Arch of a Fdf item
+ # @param BelongsToItem: The item belongs to which another item
+ # @param BelongsToFile: The item belongs to which fdf file
+ # @param StartLine: StartLine of a Fdf item
+ # @param StartColumn: StartColumn of a Fdf item
+ # @param EndLine: EndLine of a Fdf item
+ # @param EndColumn: EndColumn of a Fdf item
+ # @param Enabled: If this item enabled
+ #
+ def Insert(self, Model, Value1, Value2, Value3, Scope1, Scope2, BelongsToItem, BelongsToFile, StartLine, StartColumn, EndLine, EndColumn, Enabled):
+ self.ID = self.ID + 1
+ (Value1, Value2, Value3, Scope1, Scope2) = ConvertToSqlString((Value1, Value2, Value3, Scope1, Scope2))
+ SqlCommand = """insert into %s values(%s, %s, '%s', '%s', '%s', '%s', '%s', %s, %s, %s, %s, %s, %s, %s)""" \
+ % (self.Table, self.ID, Model, Value1, Value2, Value3, Scope1, Scope2, BelongsToItem, BelongsToFile, StartLine, StartColumn, EndLine, EndColumn, Enabled)
+ Table.Insert(self, SqlCommand)
+
+ return self.ID
+
+ ## Query table
+ #
+ # @param Model: The Model of Record
+ #
+ # @retval: A recordSet of all found records
+ #
+ def Query(self, Model):
+ SqlCommand = """select ID, Value1, Value2, Value3, Scope1, Scope2, BelongsToItem, BelongsToFile, StartLine from %s
+ where Model = %s
+ and Enabled > -1""" % (self.Table, Model)
+ EdkLogger.debug(4, "SqlCommand: %s" % SqlCommand)
+ self.Cur.execute(SqlCommand)
+ return self.Cur.fetchall()
diff --git a/src/VBox/Devices/EFI/Firmware/BaseTools/Source/Python/Table/TableFile.py b/src/VBox/Devices/EFI/Firmware/BaseTools/Source/Python/Table/TableFile.py
new file mode 100755
index 00000000..a2442288
--- /dev/null
+++ b/src/VBox/Devices/EFI/Firmware/BaseTools/Source/Python/Table/TableFile.py
@@ -0,0 +1,99 @@
+## @file
+# This file is used to create/update/query/erase table for files
+#
+# Copyright (c) 2008 - 2018, Intel Corporation. All rights reserved.<BR>
+# SPDX-License-Identifier: BSD-2-Clause-Patent
+#
+
+##
+# Import Modules
+#
+from __future__ import absolute_import
+import Common.EdkLogger as EdkLogger
+from Table.Table import Table
+from Common.StringUtils import ConvertToSqlString
+import Common.LongFilePathOs as os
+from CommonDataClass.DataClass import FileClass
+
+## TableFile
+#
+# This class defined a table used for file
+#
+# @param object: Inherited from object class
+#
+class TableFile(Table):
+ def __init__(self, Cursor):
+ Table.__init__(self, Cursor)
+ self.Table = 'File'
+
+ ## Create table
+ #
+ # Create table File
+ #
+ # @param ID: ID of a File
+ # @param Name: Name of a File
+ # @param ExtName: ExtName of a File
+ # @param Path: Path of a File
+ # @param FullPath: FullPath of a File
+ # @param Model: Model of a File
+ # @param TimeStamp: TimeStamp of a File
+ #
+ def Create(self):
+ SqlCommand = """create table IF NOT EXISTS %s (ID INTEGER PRIMARY KEY,
+ Name VARCHAR NOT NULL,
+ ExtName VARCHAR,
+ Path VARCHAR,
+ FullPath VARCHAR NOT NULL,
+ Model INTEGER DEFAULT 0,
+ TimeStamp VARCHAR NOT NULL
+ )""" % self.Table
+ Table.Create(self, SqlCommand)
+
+ ## Insert table
+ #
+ # Insert a record into table File
+ #
+ # @param ID: ID of a File
+ # @param Name: Name of a File
+ # @param ExtName: ExtName of a File
+ # @param Path: Path of a File
+ # @param FullPath: FullPath of a File
+ # @param Model: Model of a File
+ # @param TimeStamp: TimeStamp of a File
+ #
+ def Insert(self, Name, ExtName, Path, FullPath, Model, TimeStamp):
+ self.ID = self.ID + 1
+ (Name, ExtName, Path, FullPath) = ConvertToSqlString((Name, ExtName, Path, FullPath))
+ SqlCommand = """insert into %s values(%s, '%s', '%s', '%s', '%s', %s, '%s')""" \
+ % (self.Table, self.ID, Name, ExtName, Path, FullPath, Model, TimeStamp)
+ Table.Insert(self, SqlCommand)
+
+ return self.ID
+ ## InsertFile
+ #
+ # Insert one file to table
+ #
+ # @param FileFullPath: The full path of the file
+ # @param Model: The model of the file
+ #
+ # @retval FileID: The ID after record is inserted
+ #
+ def InsertFile(self, FileFullPath, Model):
+ (Filepath, Name) = os.path.split(FileFullPath)
+ (Root, Ext) = os.path.splitext(FileFullPath)
+ TimeStamp = os.stat(FileFullPath)[8]
+ File = FileClass(-1, Name, Ext, Filepath, FileFullPath, Model, '', [], [], [])
+ return self.Insert(File.Name, File.ExtName, File.Path, File.FullPath, File.Model, TimeStamp)
+
+ ## Get ID of a given file
+ #
+ # @param FilePath Path of file
+ #
+ # @retval ID ID value of given file in the table
+ #
+ def GetFileId(self, File):
+ QueryScript = "select ID from %s where FullPath = '%s'" % (self.Table, str(File))
+ RecordList = self.Exec(QueryScript)
+ if len(RecordList) == 0:
+ return None
+ return RecordList[0][0]
diff --git a/src/VBox/Devices/EFI/Firmware/BaseTools/Source/Python/Table/TableFunction.py b/src/VBox/Devices/EFI/Firmware/BaseTools/Source/Python/Table/TableFunction.py
new file mode 100755
index 00000000..4e5ab4d9
--- /dev/null
+++ b/src/VBox/Devices/EFI/Firmware/BaseTools/Source/Python/Table/TableFunction.py
@@ -0,0 +1,90 @@
+## @file
+# This file is used to create/update/query/erase table for functions
+#
+# Copyright (c) 2008 - 2018, Intel Corporation. All rights reserved.<BR>
+# SPDX-License-Identifier: BSD-2-Clause-Patent
+#
+
+##
+# Import Modules
+#
+from __future__ import absolute_import
+import Common.EdkLogger as EdkLogger
+from Table.Table import Table
+from Common.StringUtils import ConvertToSqlString
+
+## TableFunction
+#
+# This class defined a table used for function
+#
+# @param Table: Inherited from Table class
+#
+class TableFunction(Table):
+ def __init__(self, Cursor):
+ Table.__init__(self, Cursor)
+ self.Table = 'Function'
+
+ ## Create table
+ #
+ # Create table Function
+ #
+ # @param ID: ID of a Function
+ # @param Header: Header of a Function
+ # @param Modifier: Modifier of a Function
+ # @param Name: Name of a Function
+ # @param ReturnStatement: ReturnStatement of a Function
+ # @param StartLine: StartLine of a Function
+ # @param StartColumn: StartColumn of a Function
+ # @param EndLine: EndLine of a Function
+ # @param EndColumn: EndColumn of a Function
+ # @param BodyStartLine: StartLine of a Function body
+ # @param BodyStartColumn: StartColumn of a Function body
+ # @param BelongsToFile: The Function belongs to which file
+ # @param FunNameStartLine: StartLine of a Function name
+ # @param FunNameStartColumn: StartColumn of a Function name
+ #
+ def Create(self):
+ SqlCommand = """create table IF NOT EXISTS %s (ID INTEGER PRIMARY KEY,
+ Header TEXT,
+ Modifier VARCHAR,
+ Name VARCHAR NOT NULL,
+ ReturnStatement VARCHAR,
+ StartLine INTEGER NOT NULL,
+ StartColumn INTEGER NOT NULL,
+ EndLine INTEGER NOT NULL,
+ EndColumn INTEGER NOT NULL,
+ BodyStartLine INTEGER NOT NULL,
+ BodyStartColumn INTEGER NOT NULL,
+ BelongsToFile SINGLE NOT NULL,
+ FunNameStartLine INTEGER NOT NULL,
+ FunNameStartColumn INTEGER NOT NULL
+ )""" % self.Table
+ Table.Create(self, SqlCommand)
+
+ ## Insert table
+ #
+ # Insert a record into table Function
+ #
+ # @param ID: ID of a Function
+ # @param Header: Header of a Function
+ # @param Modifier: Modifier of a Function
+ # @param Name: Name of a Function
+ # @param ReturnStatement: ReturnStatement of a Function
+ # @param StartLine: StartLine of a Function
+ # @param StartColumn: StartColumn of a Function
+ # @param EndLine: EndLine of a Function
+ # @param EndColumn: EndColumn of a Function
+ # @param BodyStartLine: StartLine of a Function body
+ # @param BodyStartColumn: StartColumn of a Function body
+ # @param BelongsToFile: The Function belongs to which file
+ # @param FunNameStartLine: StartLine of a Function name
+ # @param FunNameStartColumn: StartColumn of a Function name
+ #
+ def Insert(self, Header, Modifier, Name, ReturnStatement, StartLine, StartColumn, EndLine, EndColumn, BodyStartLine, BodyStartColumn, BelongsToFile, FunNameStartLine, FunNameStartColumn):
+ self.ID = self.ID + 1
+ (Header, Modifier, Name, ReturnStatement) = ConvertToSqlString((Header, Modifier, Name, ReturnStatement))
+ SqlCommand = """insert into %s values(%s, '%s', '%s', '%s', '%s', %s, %s, %s, %s, %s, %s, %s, %s, %s)""" \
+ % (self.Table, self.ID, Header, Modifier, Name, ReturnStatement, StartLine, StartColumn, EndLine, EndColumn, BodyStartLine, BodyStartColumn, BelongsToFile, FunNameStartLine, FunNameStartColumn)
+ Table.Insert(self, SqlCommand)
+
+ return self.ID
diff --git a/src/VBox/Devices/EFI/Firmware/BaseTools/Source/Python/Table/TableIdentifier.py b/src/VBox/Devices/EFI/Firmware/BaseTools/Source/Python/Table/TableIdentifier.py
new file mode 100755
index 00000000..97300361
--- /dev/null
+++ b/src/VBox/Devices/EFI/Firmware/BaseTools/Source/Python/Table/TableIdentifier.py
@@ -0,0 +1,85 @@
+## @file
+# This file is used to create/update/query/erase table for Identifiers
+#
+# Copyright (c) 2008 - 2018, Intel Corporation. All rights reserved.<BR>
+# SPDX-License-Identifier: BSD-2-Clause-Patent
+#
+
+##
+# Import Modules
+#
+from __future__ import absolute_import
+import Common.EdkLogger as EdkLogger
+from Common.StringUtils import ConvertToSqlString
+from Table.Table import Table
+
+## TableIdentifier
+#
+# This class defined a table used for Identifier
+#
+# @param object: Inherited from object class
+#
+#
+class TableIdentifier(Table):
+ def __init__(self, Cursor):
+ Table.__init__(self, Cursor)
+ self.Table = 'Identifier'
+
+ ## Create table
+ #
+ # Create table Identifier
+ #
+ # @param ID: ID of a Identifier
+ # @param Modifier: Modifier of a Identifier
+ # @param Type: Type of a Identifier
+ # @param Name: Name of a Identifier
+ # @param Value: Value of a Identifier
+ # @param Model: Model of a Identifier
+ # @param BelongsToFile: The Identifier belongs to which file
+ # @param BelongsToFunction: The Identifier belongs to which function
+ # @param StartLine: StartLine of a Identifier
+ # @param StartColumn: StartColumn of a Identifier
+ # @param EndLine: EndLine of a Identifier
+ # @param EndColumn: EndColumn of a Identifier
+ #
+ def Create(self):
+ SqlCommand = """create table IF NOT EXISTS %s(ID INTEGER PRIMARY KEY,
+ Modifier VARCHAR,
+ Type VARCHAR,
+ Name VARCHAR NOT NULL,
+ Value VARCHAR NOT NULL,
+ Model INTEGER NOT NULL,
+ BelongsToFile SINGLE NOT NULL,
+ BelongsToFunction SINGLE DEFAULT -1,
+ StartLine INTEGER NOT NULL,
+ StartColumn INTEGER NOT NULL,
+ EndLine INTEGER NOT NULL,
+ EndColumn INTEGER NOT NULL
+ )""" % self.Table
+ Table.Create(self, SqlCommand)
+
+ ## Insert table
+ #
+ # Insert a record into table Identifier
+ #
+ # @param ID: ID of a Identifier
+ # @param Modifier: Modifier of a Identifier
+ # @param Type: Type of a Identifier
+ # @param Name: Name of a Identifier
+ # @param Value: Value of a Identifier
+ # @param Model: Model of a Identifier
+ # @param BelongsToFile: The Identifier belongs to which file
+ # @param BelongsToFunction: The Identifier belongs to which function
+ # @param StartLine: StartLine of a Identifier
+ # @param StartColumn: StartColumn of a Identifier
+ # @param EndLine: EndLine of a Identifier
+ # @param EndColumn: EndColumn of a Identifier
+ #
+ def Insert(self, Modifier, Type, Name, Value, Model, BelongsToFile, BelongsToFunction, StartLine, StartColumn, EndLine, EndColumn):
+ self.ID = self.ID + 1
+ (Modifier, Type, Name, Value) = ConvertToSqlString((Modifier, Type, Name, Value))
+ SqlCommand = """insert into %s values(%s, '%s', '%s', '%s', '%s', %s, %s, %s, %s, %s, %s, %s)""" \
+ % (self.Table, self.ID, Modifier, Type, Name, Value, Model, BelongsToFile, BelongsToFunction, StartLine, StartColumn, EndLine, EndColumn)
+ Table.Insert(self, SqlCommand)
+
+ return self.ID
diff --git a/src/VBox/Devices/EFI/Firmware/BaseTools/Source/Python/Table/TableInf.py b/src/VBox/Devices/EFI/Firmware/BaseTools/Source/Python/Table/TableInf.py
new file mode 100755
index 00000000..3c5c0e1d
--- /dev/null
+++ b/src/VBox/Devices/EFI/Firmware/BaseTools/Source/Python/Table/TableInf.py
@@ -0,0 +1,109 @@
+## @file
+# This file is used to create/update/query/erase table for inf datas
+#
+# Copyright (c) 2008 - 2018, Intel Corporation. All rights reserved.<BR>
+# SPDX-License-Identifier: BSD-2-Clause-Patent
+#
+
+##
+# Import Modules
+#
+from __future__ import absolute_import
+import Common.EdkLogger as EdkLogger
+import CommonDataClass.DataClass as DataClass
+from Table.Table import Table
+from Common.StringUtils import ConvertToSqlString
+
+## TableInf
+#
+# This class defined a table used for data model
+#
+# @param object: Inherited from object class
+#
+#
+class TableInf(Table):
+ def __init__(self, Cursor):
+ Table.__init__(self, Cursor)
+ self.Table = 'Inf'
+
+ ## Create table
+ #
+ # Create table Inf
+ #
+ # @param ID: ID of a Inf item
+ # @param Model: Model of a Inf item
+ # @param Value1: Value1 of a Inf item
+ # @param Value2: Value2 of a Inf item
+ # @param Value3: Value3 of a Inf item
+ # @param Value4: Value4 of a Inf item
+ # @param Value5: Value5 of a Inf item
+ # @param Arch: Arch of a Inf item
+ # @param BelongsToItem: The item belongs to which another item
+ # @param BelongsToFile: The item belongs to which dsc file
+ # @param StartLine: StartLine of a Inf item
+ # @param StartColumn: StartColumn of a Inf item
+ # @param EndLine: EndLine of a Inf item
+ # @param EndColumn: EndColumn of a Inf item
+ # @param Enabled: If this item enabled
+ #
+ def Create(self):
+ SqlCommand = """create table IF NOT EXISTS %s (ID INTEGER PRIMARY KEY,
+ Model INTEGER NOT NULL,
+ Value1 VARCHAR NOT NULL,
+ Value2 VARCHAR,
+ Value3 VARCHAR,
+ Value4 VARCHAR,
+ Value5 VARCHAR,
+ Arch VarCHAR,
+ BelongsToItem SINGLE NOT NULL,
+ BelongsToFile SINGLE NOT NULL,
+ StartLine INTEGER NOT NULL,
+ StartColumn INTEGER NOT NULL,
+ EndLine INTEGER NOT NULL,
+ EndColumn INTEGER NOT NULL,
+ Enabled INTEGER DEFAULT 0
+ )""" % self.Table
+ Table.Create(self, SqlCommand)
+
+ ## Insert table
+ #
+ # Insert a record into table Inf
+ #
+ # @param ID: ID of a Inf item
+ # @param Model: Model of a Inf item
+ # @param Value1: Value1 of a Inf item
+ # @param Value2: Value2 of a Inf item
+ # @param Value3: Value3 of a Inf item
+ # @param Value4: Value4 of a Inf item
+ # @param Value5: Value5 of a Inf item
+ # @param Arch: Arch of a Inf item
+ # @param BelongsToItem: The item belongs to which another item
+ # @param BelongsToFile: The item belongs to which dsc file
+ # @param StartLine: StartLine of a Inf item
+ # @param StartColumn: StartColumn of a Inf item
+ # @param EndLine: EndLine of a Inf item
+ # @param EndColumn: EndColumn of a Inf item
+ # @param Enabled: If this item enabled
+ #
+ def Insert(self, Model, Value1, Value2, Value3, Value4, Value5, Arch, BelongsToItem, BelongsToFile, StartLine, StartColumn, EndLine, EndColumn, Enabled):
+ self.ID = self.ID + 1
+ (Value1, Value2, Value3, Value4, Value5, Arch) = ConvertToSqlString((Value1, Value2, Value3, Value4, Value5, Arch))
+ SqlCommand = """insert into %s values(%s, %s, '%s', '%s', '%s', '%s', '%s', '%s', %s, %s, %s, %s, %s, %s, %s)""" \
+ % (self.Table, self.ID, Model, Value1, Value2, Value3, Value4, Value5, Arch, BelongsToItem, BelongsToFile, StartLine, StartColumn, EndLine, EndColumn, Enabled)
+ Table.Insert(self, SqlCommand)
+
+ return self.ID
+
+ ## Query table
+ #
+ # @param Model: The Model of Record
+ #
+ # @retval: A recordSet of all found records
+ #
+ def Query(self, Model):
+ SqlCommand = """select ID, Value1, Value2, Value3, Arch, BelongsToItem, BelongsToFile, StartLine from %s
+ where Model = %s
+ and Enabled > -1""" % (self.Table, Model)
+ EdkLogger.debug(4, "SqlCommand: %s" % SqlCommand)
+ self.Cur.execute(SqlCommand)
+ return self.Cur.fetchall()
diff --git a/src/VBox/Devices/EFI/Firmware/BaseTools/Source/Python/Table/TablePcd.py b/src/VBox/Devices/EFI/Firmware/BaseTools/Source/Python/Table/TablePcd.py
new file mode 100755
index 00000000..22d40fc4
--- /dev/null
+++ b/src/VBox/Devices/EFI/Firmware/BaseTools/Source/Python/Table/TablePcd.py
@@ -0,0 +1,85 @@
+## @file
+# This file is used to create/update/query/erase table for pcds
+#
+# Copyright (c) 2008 - 2018, Intel Corporation. All rights reserved.<BR>
+# SPDX-License-Identifier: BSD-2-Clause-Patent
+#
+
+##
+# Import Modules
+#
+from __future__ import absolute_import
+import Common.EdkLogger as EdkLogger
+from Table.Table import Table
+from Common.StringUtils import ConvertToSqlString
+
+## TablePcd
+#
+# This class defined a table used for pcds
+#
+# @param object: Inherited from object class
+#
+#
+class TablePcd(Table):
+ def __init__(self, Cursor):
+ Table.__init__(self, Cursor)
+ self.Table = 'Pcd'
+
+ ## Create table
+ #
+ # Create table Pcd
+ #
+ # @param ID: ID of a Pcd
+ # @param CName: CName of a Pcd
+ # @param TokenSpaceGuidCName: TokenSpaceGuidCName of a Pcd
+ # @param Token: Token of a Pcd
+ # @param DatumType: DatumType of a Pcd
+ # @param Model: Model of a Pcd
+ # @param BelongsToFile: The Pcd belongs to which file
+ # @param BelongsToFunction: The Pcd belongs to which function
+ # @param StartLine: StartLine of a Pcd
+ # @param StartColumn: StartColumn of a Pcd
+ # @param EndLine: EndLine of a Pcd
+ # @param EndColumn: EndColumn of a Pcd
+ #
+ def Create(self):
+ SqlCommand = """create table IF NOT EXISTS %s (ID INTEGER PRIMARY KEY,
+ CName VARCHAR NOT NULL,
+ TokenSpaceGuidCName VARCHAR NOT NULL,
+ Token INTEGER,
+ DatumType VARCHAR,
+ Model INTEGER NOT NULL,
+ BelongsToFile SINGLE NOT NULL,
+ BelongsToFunction SINGLE DEFAULT -1,
+ StartLine INTEGER NOT NULL,
+ StartColumn INTEGER NOT NULL,
+ EndLine INTEGER NOT NULL,
+ EndColumn INTEGER NOT NULL
+ )""" % self.Table
+ Table.Create(self, SqlCommand)
+
+ ## Insert table
+ #
+ # Insert a record into table Pcd
+ #
+ # @param ID: ID of a Pcd
+ # @param CName: CName of a Pcd
+ # @param TokenSpaceGuidCName: TokenSpaceGuidCName of a Pcd
+ # @param Token: Token of a Pcd
+ # @param DatumType: DatumType of a Pcd
+ # @param Model: Model of a Pcd
+ # @param BelongsToFile: The Pcd belongs to which file
+ # @param BelongsToFunction: The Pcd belongs to which function
+ # @param StartLine: StartLine of a Pcd
+ # @param StartColumn: StartColumn of a Pcd
+ # @param EndLine: EndLine of a Pcd
+ # @param EndColumn: EndColumn of a Pcd
+ #
+ def Insert(self, CName, TokenSpaceGuidCName, Token, DatumType, Model, BelongsToFile, BelongsToFunction, StartLine, StartColumn, EndLine, EndColumn):
+ self.ID = self.ID + 1
+ (CName, TokenSpaceGuidCName, DatumType) = ConvertToSqlString((CName, TokenSpaceGuidCName, DatumType))
+ SqlCommand = """insert into %s values(%s, '%s', '%s', %s, '%s', %s, %s, %s, %s, %s, %s, %s)""" \
+ % (self.Table, self.ID, CName, TokenSpaceGuidCName, Token, DatumType, Model, BelongsToFile, BelongsToFunction, StartLine, StartColumn, EndLine, EndColumn)
+ Table.Insert(self, SqlCommand)
+
+ return self.ID
diff --git a/src/VBox/Devices/EFI/Firmware/BaseTools/Source/Python/Table/TableQuery.py b/src/VBox/Devices/EFI/Firmware/BaseTools/Source/Python/Table/TableQuery.py
new file mode 100755
index 00000000..454c61dd
--- /dev/null
+++ b/src/VBox/Devices/EFI/Firmware/BaseTools/Source/Python/Table/TableQuery.py
@@ -0,0 +1,63 @@
+## @file
+# This file is used to create/update/query/erase table for Queries
+#
+# Copyright (c) 2008, Intel Corporation. All rights reserved.<BR>
+# SPDX-License-Identifier: BSD-2-Clause-Patent
+#
+
+##
+# Import Modules
+#
+from __future__ import absolute_import
+import Common.EdkLogger as EdkLogger
+from Common.StringUtils import ConvertToSqlString
+from Table.Table import Table
+
+## TableQuery
+#
+# This class defined a table used for Query
+#
+# @param object: Inherited from object class
+#
+#
+class TableQuery(Table):
+ def __init__(self, Cursor):
+ Table.__init__(self, Cursor)
+ self.Table = 'Query'
+
+ ## Create table
+ #
+ # Create table Query
+ #
+ # @param ID: ID of a Query
+ # @param Name: Name of a Query
+ # @param Modifier: Modifier of a Query
+ # @param Value: Type of a Query
+ # @param Model: Model of a Query
+ #
+ def Create(self):
+ SqlCommand = """create table IF NOT EXISTS %s(ID INTEGER PRIMARY KEY,
+ Name TEXT DEFAULT '',
+ Modifier TEXT DEFAULT '',
+ Value TEXT DEFAULT '',
+ Model INTEGER DEFAULT 0
+ )""" % self.Table
+ Table.Create(self, SqlCommand)
+
+ ## Insert table
+ #
+ # Insert a record into table Query
+ #
+ # @param ID: ID of a Query
+ # @param Name: Name of a Query
+ # @param Modifier: Modifier of a Query
+ # @param Value: Value of a Query
+ # @param Model: Model of a Query
+ #
+ def Insert(self, Name, Modifier, Value, Model):
+ self.ID = self.ID + 1
+ SqlCommand = """insert into %s values(%s, '%s', '%s', '%s', %s)""" \
+ % (self.Table, self.ID, Name, Modifier, Value, Model)
+ Table.Insert(self, SqlCommand)
+
+ return self.ID
diff --git a/src/VBox/Devices/EFI/Firmware/BaseTools/Source/Python/Table/TableReport.py b/src/VBox/Devices/EFI/Firmware/BaseTools/Source/Python/Table/TableReport.py
new file mode 100755
index 00000000..e9d1c87a
--- /dev/null
+++ b/src/VBox/Devices/EFI/Firmware/BaseTools/Source/Python/Table/TableReport.py
@@ -0,0 +1,127 @@
+## @file
+# This file is used to create/update/query/erase table for ECC reports
+#
+# Copyright (c) 2008 - 2018, Intel Corporation. All rights reserved.<BR>
+# SPDX-License-Identifier: BSD-2-Clause-Patent
+#
+
+##
+# Import Modules
+#
+from __future__ import absolute_import
+import Common.EdkLogger as EdkLogger
+import Common.LongFilePathOs as os, time
+from Table.Table import Table
+from Common.StringUtils import ConvertToSqlString2
+import Ecc.EccToolError as EccToolError
+import Ecc.EccGlobalData as EccGlobalData
+from Common.LongFilePathSupport import OpenLongFilePath as open
+
+## TableReport
+#
+# This class defined a table used for data model
+#
+# @param object: Inherited from object class
+#
+#
+class TableReport(Table):
+ def __init__(self, Cursor):
+ Table.__init__(self, Cursor)
+ self.Table = 'Report'
+
+ ## Create table
+ #
+ # Create table report
+ #
+ # @param ID: ID of an Error
+ # @param ErrorID: ID of an Error TypeModel of a Report item
+ # @param OtherMsg: Other error message besides the standard error message
+ # @param BelongsToItem: The error belongs to which item
+ # @param Enabled: If this error enabled
+ # @param Corrected: if this error corrected
+ #
+ def Create(self):
+ SqlCommand = """create table IF NOT EXISTS %s (ID INTEGER PRIMARY KEY,
+ ErrorID INTEGER NOT NULL,
+ OtherMsg TEXT,
+ BelongsToTable TEXT NOT NULL,
+ BelongsToItem SINGLE NOT NULL,
+ Enabled INTEGER DEFAULT 0,
+ Corrected INTEGER DEFAULT -1
+ )""" % self.Table
+ Table.Create(self, SqlCommand)
+
+ ## Insert table
+ #
+ # Insert a record into table report
+ #
+ # @param ID: ID of an Error
+ # @param ErrorID: ID of an Error TypeModel of a report item
+ # @param OtherMsg: Other error message besides the standard error message
+ # @param BelongsToTable: The error item belongs to which table
+ # @param BelongsToItem: The error belongs to which item
+ # @param Enabled: If this error enabled
+ # @param Corrected: if this error corrected
+ #
+ def Insert(self, ErrorID, OtherMsg='', BelongsToTable='', BelongsToItem= -1, Enabled=0, Corrected= -1):
+ self.ID = self.ID + 1
+ SqlCommand = """insert into %s values(%s, %s, '%s', '%s', %s, %s, %s)""" \
+ % (self.Table, self.ID, ErrorID, ConvertToSqlString2(OtherMsg), BelongsToTable, BelongsToItem, Enabled, Corrected)
+ Table.Insert(self, SqlCommand)
+
+ return self.ID
+
+ ## Query table
+ #
+ # @retval: A recordSet of all found records
+ #
+ def Query(self):
+ SqlCommand = """select ID, ErrorID, OtherMsg, BelongsToTable, BelongsToItem, Corrected from %s
+ where Enabled > -1 order by ErrorID, BelongsToItem""" % (self.Table)
+ return self.Exec(SqlCommand)
+
+ ## Update table
+ #
+ def UpdateBelongsToItemByFile(self, ItemID=-1, File=""):
+ SqlCommand = """update Report set BelongsToItem=%s where BelongsToTable='File' and BelongsToItem=-2
+ and OtherMsg like '%%%s%%'""" % (ItemID, File)
+ return self.Exec(SqlCommand)
+
+ ## Convert to CSV
+ #
+ # Get all enabled records from table report and save them to a .csv file
+ #
+ # @param Filename: To filename to save the report content
+ #
+ def ToCSV(self, Filename='Report.csv'):
+ try:
+ File = open(Filename, 'w+')
+ File.write("""No, Error Code, Error Message, File, LineNo, Other Error Message\n""")
+ RecordSet = self.Query()
+ Index = 0
+ for Record in RecordSet:
+ Index = Index + 1
+ ErrorID = Record[1]
+ OtherMsg = Record[2]
+ BelongsToTable = Record[3]
+ BelongsToItem = Record[4]
+ IsCorrected = Record[5]
+ SqlCommand = ''
+ if BelongsToTable == 'File':
+ SqlCommand = """select 1, FullPath from %s where ID = %s
+ """ % (BelongsToTable, BelongsToItem)
+ else:
+ SqlCommand = """select A.StartLine, B.FullPath from %s as A, File as B
+ where A.ID = %s and B.ID = A.BelongsToFile
+ """ % (BelongsToTable, BelongsToItem)
+ NewRecord = self.Exec(SqlCommand)
+ if NewRecord != []:
+ File.write("""%s,%s,"%s",%s,%s,"%s"\n""" % (Index, ErrorID, EccToolError.gEccErrorMessage[ErrorID], NewRecord[0][1], NewRecord[0][0], OtherMsg))
+ EdkLogger.quiet("%s(%s): [%s]%s %s" % (NewRecord[0][1], NewRecord[0][0], ErrorID, EccToolError.gEccErrorMessage[ErrorID], OtherMsg))
+
+ File.close()
+ except IOError:
+ NewFilename = 'Report_' + time.strftime("%Y%m%d_%H%M%S.csv", time.localtime())
+ EdkLogger.warn("ECC", "The report file %s is locked by other progress, use %s instead!" % (Filename, NewFilename))
+ self.ToCSV(NewFilename)
+
diff --git a/src/VBox/Devices/EFI/Firmware/BaseTools/Source/Python/Table/__init__.py b/src/VBox/Devices/EFI/Firmware/BaseTools/Source/Python/Table/__init__.py
new file mode 100644
index 00000000..01fd9642
--- /dev/null
+++ b/src/VBox/Devices/EFI/Firmware/BaseTools/Source/Python/Table/__init__.py
@@ -0,0 +1,9 @@
+## @file
+# Python 'Table' package initialization file.
+#
+# This file is required to make Python interpreter treat the directory
+# as containing package.
+#
+# Copyright (c) 2008 - 2010, Intel Corporation. All rights reserved.<BR>
+# SPDX-License-Identifier: BSD-2-Clause-Patent
+#