def __init__(self):
     self.Header = DistributionPackageHeaderClass()
     self.PackageSurfaceArea = sdict() # {(Guid, Version, Path) : PackageObj}
     self.ModuleSurfaceArea = sdict()  # {(Guid, Version, Path) : ModuleObj}
     self.Tools = MiscFileClass()
     self.MiscellaneousFiles = MiscFileClass()
     self.UserExtensions = []
 def __init__(self):
     self.Header = DistributionPackageHeaderClass()
     self.PackageSurfaceArea = sdict(
     )  # {(Guid, Version, Path) : PackageObj}
     self.ModuleSurfaceArea = sdict()  # {(Guid, Version, Path) : ModuleObj}
     self.Tools = MiscFileClass()
     self.MiscellaneousFiles = MiscFileClass()
     self.UserExtensions = []
Exemplo n.º 3
0
    def __init__(self):
        self.AutoGenVersion          = 0
        self.MetaFile                = ''
        self.BaseName                = ''
        self.ModuleType              = ''
        self.Guid                    = ''
        self.Version                 = ''
        self.PcdIsDriver             = ''
        self.BinaryModule            = ''
        self.Shadow                  = ''
        self.SourceOverridePath      = ''
        self.CustomMakefile          = {}
        self.Specification           = {}
        self.LibraryClass            = []
        self.ModuleEntryPointList    = []
        self.ModuleUnloadImageList   = []
        self.ConstructorList         = []
        self.DestructorList          = []

        self.Binaries                = []
        self.Sources                 = []
        self.LibraryClasses          = sdict()
        self.Libraries               = []
        self.Protocols               = []
        self.Ppis                    = []
        self.Guids                   = []
        self.Includes                = []
        self.Packages                = []
        self.Pcds                    = {}
        self.BuildOptions            = {}
        self.Depex                   = {}
Exemplo n.º 4
0
    def __init__(self):
        self.AutoGenVersion          = 0
        self.MetaFile                = ''
        self.BaseName                = ''
        self.ModuleType              = ''
        self.Guid                    = ''
        self.Version                 = ''
        self.PcdIsDriver             = ''
        self.BinaryModule            = ''
        self.Shadow                  = ''
        self.SourceOverridePath      = ''
        self.CustomMakefile          = {}
        self.Specification           = {}
        self.LibraryClass            = []
        self.ModuleEntryPointList    = []
        self.ModuleUnloadImageList   = []
        self.ConstructorList         = []
        self.DestructorList          = []

        self.Binaries                = []
        self.Sources                 = []
        self.LibraryClasses          = sdict()
        self.Libraries               = []
        self.Protocols               = []
        self.Ppis                    = []
        self.Guids                   = []
        self.Includes                = []
        self.Packages                = []
        self.Pcds                    = {}
        self.BuildOptions            = {}
        self.Depex                   = {}
Exemplo n.º 5
0
def SearchFunctionCalling(Table, SourceFileID, SourceFileFullPath, ItemType,
                          ItemMode):
    LibraryList = sdict()
    Db = EotGlobalData.gDb.TblReport
    Parameters, ItemName, GuidName, GuidMacro, GuidValue, BelongsToFunction = [], '', '', '', '', ''
    if ItemType == 'Protocol' and ItemMode == 'Produced':
        LibraryList = EotGlobalData.gProducedProtocolLibrary
    elif ItemType == 'Protocol' and ItemMode == 'Consumed':
        LibraryList = EotGlobalData.gConsumedProtocolLibrary
    elif ItemType == 'Protocol' and ItemMode == 'Callback':
        LibraryList = EotGlobalData.gCallbackProtocolLibrary
    elif ItemType == 'Ppi' and ItemMode == 'Produced':
        LibraryList = EotGlobalData.gProducedPpiLibrary
    elif ItemType == 'Ppi' and ItemMode == 'Consumed':
        LibraryList = EotGlobalData.gConsumedPpiLibrary

    for Library in LibraryList:
        Index = LibraryList[Library]
        SqlCommand = """select Value, StartLine from %s
                        where Name like '%%%s%%' and Model = %s""" \
                        % (Table, Library, MODEL_IDENTIFIER_FUNCTION_CALLING)
        RecordSet = Db.Exec(SqlCommand)
        for Record in RecordSet:
            IsFound = False
            if Index == -1:
                ParameterList = GetSplitValueList(Record[0], TAB_COMMA_SPLIT)
                for Parameter in ParameterList:
                    Parameters.append(GetParameterName(Parameter))
            else:
                Parameters = [GetProtocolParameter(Record[0], Index)]
            StartLine = Record[1]
            for Parameter in Parameters:
                if Parameter.startswith('g') or Parameter.endswith(
                        'Guid'
                ) or Parameter == 'ShellEnvProtocol' or Parameter == 'ShellInterfaceProtocol':
                    GuidName = GetParameterName(Parameter)
                    Db.Insert(-1, '', '', SourceFileID, SourceFileFullPath,
                              ItemName, ItemType, ItemMode, GuidName,
                              GuidMacro, GuidValue, BelongsToFunction, 0)
                    IsFound = True

            if not IsFound:
                EotGlobalData.gOP_UN_MATCHED.write(
                    '%s, %s, %s, %s, %s, %s\n' %
                    (ItemType, ItemMode, SourceFileID, SourceFileFullPath,
                     StartLine, Parameter))
Exemplo n.º 6
0
 def __init__(self):
     self.PackageHeader = PackageHeaderClass()
     self.Header = {}
     self.Includes = []
     self.LibraryClassDeclarations = []
     self.IndustryStdHeaders = []
     self.ModuleFiles = []
     # {[Guid, Value, Path(relative to WORKSPACE)]: ModuleClassObj}
     self.Modules = sdict()
     self.PackageIncludePkgHeaders = []
     self.GuidDeclarations = []
     self.ProtocolDeclarations = []
     self.PpiDeclarations = []
     self.PcdDeclarations = []
     self.PcdChecks = []
     self.UserExtensions = UserExtensionsClass()
     self.MiscFiles = MiscFileClass()
     self.FileList = []
 def __init__(self):
     self.PackageHeader = PackageHeaderClass()
     self.Header = {}
     self.Includes = []
     self.LibraryClassDeclarations = []
     self.IndustryStdHeaders = []
     self.ModuleFiles = []
     # {[Guid, Value, Path(relative to WORKSPACE)]: ModuleClassObj}
     self.Modules = sdict()
     self.PackageIncludePkgHeaders = []
     self.GuidDeclarations = []
     self.ProtocolDeclarations = []
     self.PpiDeclarations = []
     self.PcdDeclarations = []
     self.PcdChecks = []
     self.UserExtensions = UserExtensionsClass()
     self.MiscFiles = MiscFileClass()
     self.FileList = []
Exemplo n.º 8
0
def SearchFunctionCalling(Table, SourceFileID, SourceFileFullPath, ItemType, ItemMode):
    LibraryList = sdict()
    Db = EotGlobalData.gDb.TblReport
    Parameters, ItemName, GuidName, GuidMacro, GuidValue, BelongsToFunction = [], '', '', '', '', ''
    if ItemType == 'Protocol' and ItemMode == 'Produced':
        LibraryList = EotGlobalData.gProducedProtocolLibrary
    elif ItemType == 'Protocol' and ItemMode == 'Consumed':
        LibraryList = EotGlobalData.gConsumedProtocolLibrary
    elif ItemType == 'Protocol' and ItemMode == 'Callback':
        LibraryList = EotGlobalData.gCallbackProtocolLibrary
    elif ItemType == 'Ppi' and ItemMode == 'Produced':
        LibraryList = EotGlobalData.gProducedPpiLibrary
    elif ItemType == 'Ppi' and ItemMode == 'Consumed':
        LibraryList = EotGlobalData.gConsumedPpiLibrary

    for Library in LibraryList:
        Index = LibraryList[Library]
        SqlCommand = """select Value, StartLine from %s
                        where Name like '%%%s%%' and Model = %s""" \
                        % (Table, Library, MODEL_IDENTIFIER_FUNCTION_CALLING)
        RecordSet = Db.Exec(SqlCommand)
        for Record in RecordSet:
            IsFound = False
            if Index == -1:
                ParameterList = GetSplitValueList(Record[0], TAB_COMMA_SPLIT)
                for Parameter in ParameterList:
                    Parameters.append(GetParameterName(Parameter))
            else:
                Parameters = [GetProtocolParameter(Record[0], Index)]
            StartLine = Record[1]
            for Parameter in Parameters:
                if Parameter.startswith('g') or Parameter.endswith('Guid') or Parameter == 'ShellEnvProtocol' or Parameter == 'ShellInterfaceProtocol':
                    GuidName = GetParameterName(Parameter)
                    Db.Insert(-1, '', '', SourceFileID, SourceFileFullPath, ItemName, ItemType, ItemMode, GuidName, GuidMacro, GuidValue, BelongsToFunction, 0)
                    IsFound = True

            if not IsFound:
                EotGlobalData.gOP_UN_MATCHED.write('%s, %s, %s, %s, %s, %s\n' % (ItemType, ItemMode, SourceFileID, SourceFileFullPath, StartLine, Parameter))
Exemplo n.º 9
0
def _GetModuleLibraryInstances(Module, Platform, BuildDatabase, Arch, Target,
                               Toolchain):
    ModuleType = Module.ModuleType

    # for overriding library instances with module specific setting
    PlatformModule = Platform.Modules[str(Module)]

    # add forced library instances (specified under LibraryClasses sections)
    #
    # If a module has a MODULE_TYPE of USER_DEFINED,
    # do not link in NULL library class instances from the global [LibraryClasses.*] sections.
    #
    if Module.ModuleType != SUP_MODULE_USER_DEFINED:
        for LibraryClass in Platform.LibraryClasses.GetKeys():
            if LibraryClass.startswith("NULL") and Platform.LibraryClasses[
                    LibraryClass, Module.ModuleType]:
                Module.LibraryClasses[LibraryClass] = Platform.LibraryClasses[
                    LibraryClass, Module.ModuleType]

    # add forced library instances (specified in module overrides)
    for LibraryClass in PlatformModule.LibraryClasses:
        if LibraryClass.startswith("NULL"):
            Module.LibraryClasses[
                LibraryClass] = PlatformModule.LibraryClasses[LibraryClass]

    # EdkII module
    LibraryConsumerList = [Module]
    Constructor = []
    ConsumedByList = sdict()
    LibraryInstance = sdict()

    while len(LibraryConsumerList) > 0:
        M = LibraryConsumerList.pop()
        for LibraryClassName in M.LibraryClasses:
            if LibraryClassName not in LibraryInstance:
                # override library instance for this module
                if LibraryClassName in PlatformModule.LibraryClasses:
                    LibraryPath = PlatformModule.LibraryClasses[
                        LibraryClassName]
                else:
                    LibraryPath = Platform.LibraryClasses[LibraryClassName,
                                                          ModuleType]
                if LibraryPath == None or LibraryPath == "":
                    LibraryPath = M.LibraryClasses[LibraryClassName]
                    if LibraryPath == None or LibraryPath == "":
                        return []

                LibraryModule = BuildDatabase[LibraryPath, Arch, Target,
                                              Toolchain]
                # for those forced library instance (NULL library), add a fake library class
                if LibraryClassName.startswith("NULL"):
                    LibraryModule.LibraryClass.append(
                        LibraryClassObject(LibraryClassName, [ModuleType]))
                elif LibraryModule.LibraryClass == None \
                     or len(LibraryModule.LibraryClass) == 0 \
                     or (ModuleType != 'USER_DEFINED'
                         and ModuleType not in LibraryModule.LibraryClass[0].SupModList):
                    # only USER_DEFINED can link against any library instance despite of its SupModList
                    return []

                LibraryInstance[LibraryClassName] = LibraryModule
                LibraryConsumerList.append(LibraryModule)
            else:
                LibraryModule = LibraryInstance[LibraryClassName]

            if LibraryModule == None:
                continue

            if LibraryModule.ConstructorList != [] and LibraryModule not in Constructor:
                Constructor.append(LibraryModule)

            if LibraryModule not in ConsumedByList:
                ConsumedByList[LibraryModule] = []
            # don't add current module itself to consumer list
            if M != Module:
                if M in ConsumedByList[LibraryModule]:
                    continue
                ConsumedByList[LibraryModule].append(M)
    #
    # Initialize the sorted output list to the empty set
    #
    SortedLibraryList = []
    #
    # Q <- Set of all nodes with no incoming edges
    #
    LibraryList = []  #LibraryInstance.values()
    Q = []
    for LibraryClassName in LibraryInstance:
        M = LibraryInstance[LibraryClassName]
        LibraryList.append(M)
        if ConsumedByList[M] == []:
            Q.append(M)

    #
    # start the  DAG algorithm
    #
    while True:
        EdgeRemoved = True
        while Q == [] and EdgeRemoved:
            EdgeRemoved = False
            # for each node Item with a Constructor
            for Item in LibraryList:
                if Item not in Constructor:
                    continue
                # for each Node without a constructor with an edge e from Item to Node
                for Node in ConsumedByList[Item]:
                    if Node in Constructor:
                        continue
                    # remove edge e from the graph if Node has no constructor
                    ConsumedByList[Item].remove(Node)
                    EdgeRemoved = True
                    if ConsumedByList[Item] == []:
                        # insert Item into Q
                        Q.insert(0, Item)
                        break
                if Q != []:
                    break
        # DAG is done if there's no more incoming edge for all nodes
        if Q == []:
            break

        # remove node from Q
        Node = Q.pop()
        # output Node
        SortedLibraryList.append(Node)

        # for each node Item with an edge e from Node to Item do
        for Item in LibraryList:
            if Node not in ConsumedByList[Item]:
                continue
            # remove edge e from the graph
            ConsumedByList[Item].remove(Node)

            if ConsumedByList[Item] != []:
                continue
            # insert Item into Q, if Item has no other incoming edges
            Q.insert(0, Item)

    #
    # if any remaining node Item in the graph has a constructor and an incoming edge, then the graph has a cycle
    #
    for Item in LibraryList:
        if ConsumedByList[Item] != [] and Item in Constructor and len(
                Constructor) > 1:
            return []
        if Item not in SortedLibraryList:
            SortedLibraryList.append(Item)

    #
    # Build the list of constructor and destructir names
    # The DAG Topo sort produces the destructor order, so the list of constructors must generated in the reverse order
    #
    SortedLibraryList.reverse()
    return SortedLibraryList
gOP_UN_MATCHED_IN_LIBRARY_CALLING = open(gUN_MATCHED_IN_LIBRARY_CALLING_LOG, 'w+')

# Log file for order of dispatched PEIM/DRIVER
gDISPATCH_ORDER_LOG = 'Log_DispatchOrder.log'
gOP_DISPATCH_ORDER = open(gDISPATCH_ORDER_LOG, 'w+')

# Log file for source files not found
gUN_FOUND_FILES = 'Log_UnFoundSourceFiles.log'
gOP_UN_FOUND_FILES = open(gUN_FOUND_FILES, 'w+')

# Log file for found source files
gSOURCE_FILES = 'Log_SourceFiles.log'
gOP_SOURCE_FILES = open(gSOURCE_FILES, 'w+')

# Dict for GUID found in DEC files
gGuidDict = sdict()

# Dict for hard coded GUID Macros
# {GuidName : [GuidMacro : GuidValue]}
gGuidMacroDict = sdict()

# Dict for PPI
gPpiList = {}

# Dict for PROTOCOL
gProtocolList = {}

# Dict for consumed PPI function calling
gConsumedPpiLibrary = sdict()
gConsumedPpiLibrary['EfiCommonLocateInterface'] = 0
gConsumedPpiLibrary['PeiServicesLocatePpi'] = 0
Exemplo n.º 11
0
                                         'w+')

# Log file for order of dispatched PEIM/DRIVER
gDISPATCH_ORDER_LOG = 'Log_DispatchOrder.log'
gOP_DISPATCH_ORDER = open(gDISPATCH_ORDER_LOG, 'w+')

# Log file for source files not found
gUN_FOUND_FILES = 'Log_UnFoundSourceFiles.log'
gOP_UN_FOUND_FILES = open(gUN_FOUND_FILES, 'w+')

# Log file for found source files
gSOURCE_FILES = 'Log_SourceFiles.log'
gOP_SOURCE_FILES = open(gSOURCE_FILES, 'w+')

# Dict for GUID found in DEC files
gGuidDict = sdict()

# Dict for hard coded GUID Macros
# {GuidName : [GuidMacro : GuidValue]}
gGuidMacroDict = sdict()

# Dict for PPI
gPpiList = {}

# Dict for PROTOCOL
gProtocolList = {}

# Dict for consumed PPI function calling
gConsumedPpiLibrary = sdict()
gConsumedPpiLibrary['EfiCommonLocateInterface'] = 0
gConsumedPpiLibrary['PeiServicesLocatePpi'] = 0
Exemplo n.º 12
0
def _GetModuleLibraryInstances(Module, Platform, BuildDatabase, Arch, Target, Toolchain):
    ModuleType = Module.ModuleType

    # for overriding library instances with module specific setting
    PlatformModule = Platform.Modules[str(Module)]

    # add forced library instances (specified under LibraryClasses sections)
    #
    # If a module has a MODULE_TYPE of USER_DEFINED,
    # do not link in NULL library class instances from the global [LibraryClasses.*] sections.
    #
    if Module.ModuleType != SUP_MODULE_USER_DEFINED:
        for LibraryClass in Platform.LibraryClasses.GetKeys():
            if LibraryClass.startswith("NULL") and Platform.LibraryClasses[LibraryClass, Module.ModuleType]:
                Module.LibraryClasses[LibraryClass] = Platform.LibraryClasses[LibraryClass, Module.ModuleType]

    # add forced library instances (specified in module overrides)
    for LibraryClass in PlatformModule.LibraryClasses:
        if LibraryClass.startswith("NULL"):
            Module.LibraryClasses[LibraryClass] = PlatformModule.LibraryClasses[LibraryClass]

    # EdkII module
    LibraryConsumerList = [Module]
    Constructor = []
    ConsumedByList = sdict()
    LibraryInstance = sdict()

    while len(LibraryConsumerList) > 0:
        M = LibraryConsumerList.pop()
        for LibraryClassName in M.LibraryClasses:
            if LibraryClassName not in LibraryInstance:
                # override library instance for this module
                if LibraryClassName in PlatformModule.LibraryClasses:
                    LibraryPath = PlatformModule.LibraryClasses[LibraryClassName]
                else:
                    LibraryPath = Platform.LibraryClasses[LibraryClassName, ModuleType]
                if LibraryPath == None or LibraryPath == "":
                    LibraryPath = M.LibraryClasses[LibraryClassName]
                    if LibraryPath == None or LibraryPath == "":
                        return []

                LibraryModule = BuildDatabase[LibraryPath, Arch, Target, Toolchain]
                # for those forced library instance (NULL library), add a fake library class
                if LibraryClassName.startswith("NULL"):
                    LibraryModule.LibraryClass.append(LibraryClassObject(LibraryClassName, [ModuleType]))
                elif LibraryModule.LibraryClass == None \
                     or len(LibraryModule.LibraryClass) == 0 \
                     or (ModuleType != 'USER_DEFINED'
                         and ModuleType not in LibraryModule.LibraryClass[0].SupModList):
                    # only USER_DEFINED can link against any library instance despite of its SupModList
                    return []

                LibraryInstance[LibraryClassName] = LibraryModule
                LibraryConsumerList.append(LibraryModule)
            else:
                LibraryModule = LibraryInstance[LibraryClassName]

            if LibraryModule == None:
                continue

            if LibraryModule.ConstructorList != [] and LibraryModule not in Constructor:
                Constructor.append(LibraryModule)

            if LibraryModule not in ConsumedByList:
                ConsumedByList[LibraryModule] = []
            # don't add current module itself to consumer list
            if M != Module:
                if M in ConsumedByList[LibraryModule]:
                    continue
                ConsumedByList[LibraryModule].append(M)
    #
    # Initialize the sorted output list to the empty set
    #
    SortedLibraryList = []
    #
    # Q <- Set of all nodes with no incoming edges
    #
    LibraryList = [] #LibraryInstance.values()
    Q = []
    for LibraryClassName in LibraryInstance:
        M = LibraryInstance[LibraryClassName]
        LibraryList.append(M)
        if ConsumedByList[M] == []:
            Q.append(M)

    #
    # start the  DAG algorithm
    #
    while True:
        EdgeRemoved = True
        while Q == [] and EdgeRemoved:
            EdgeRemoved = False
            # for each node Item with a Constructor
            for Item in LibraryList:
                if Item not in Constructor:
                    continue
                # for each Node without a constructor with an edge e from Item to Node
                for Node in ConsumedByList[Item]:
                    if Node in Constructor:
                        continue
                    # remove edge e from the graph if Node has no constructor
                    ConsumedByList[Item].remove(Node)
                    EdgeRemoved = True
                    if ConsumedByList[Item] == []:
                        # insert Item into Q
                        Q.insert(0, Item)
                        break
                if Q != []:
                    break
        # DAG is done if there's no more incoming edge for all nodes
        if Q == []:
            break

        # remove node from Q
        Node = Q.pop()
        # output Node
        SortedLibraryList.append(Node)

        # for each node Item with an edge e from Node to Item do
        for Item in LibraryList:
            if Node not in ConsumedByList[Item]:
                continue
            # remove edge e from the graph
            ConsumedByList[Item].remove(Node)

            if ConsumedByList[Item] != []:
                continue
            # insert Item into Q, if Item has no other incoming edges
            Q.insert(0, Item)

    #
    # if any remaining node Item in the graph has a constructor and an incoming edge, then the graph has a cycle
    #
    for Item in LibraryList:
        if ConsumedByList[Item] != [] and Item in Constructor and len(Constructor) > 1:
            return []
        if Item not in SortedLibraryList:
            SortedLibraryList.append(Item)

    #
    # Build the list of constructor and destructir names
    # The DAG Topo sort produces the destructor order, so the list of constructors must generated in the reverse order
    #
    SortedLibraryList.reverse()
    return SortedLibraryList