def SetPcdName(PcdItem, CurrentLineOfPcdItem, PcdItemObj): # # Only PCD Name specified # <PcdName> ::= <TokenSpaceGuidCName> "." <TokenCName> # PcdId = GetSplitValueList(PcdItem[0], DT.TAB_SPLIT) if len(PcdId) != 2: Logger.Error("InfParser", ToolError.FORMAT_INVALID, ST.ERR_INF_PARSER_PCD_NAME_FORMAT_ERROR, File=CurrentLineOfPcdItem[2], Line=CurrentLineOfPcdItem[1], ExtraData=CurrentLineOfPcdItem[0]) else: # # Validate PcdTokenSpaceGuidCName # if not IsValidCVariableName(PcdId[0]): Logger.Error("InfParser", ToolError.FORMAT_INVALID, ST.ERR_INF_PARSER_PCD_CVAR_GUID, File=CurrentLineOfPcdItem[2], Line=CurrentLineOfPcdItem[1], ExtraData=PcdId[0]) if not IsValidCVariableName(PcdId[1]): Logger.Error("InfParser", ToolError.FORMAT_INVALID, ST.ERR_INF_PARSER_PCD_CVAR_PCDCNAME, File=CurrentLineOfPcdItem[2], Line=CurrentLineOfPcdItem[1], ExtraData=PcdId[1]) PcdItemObj.SetTokenSpaceGuidCName(PcdId[0]) PcdItemObj.SetCName(PcdId[1]) return PcdItemObj
def SetUnloadImages(self, UnloadImages, Comments): # # It can be a list # ValueList = [] TokenList = GetSplitValueList(UnloadImages, DT.TAB_VALUE_SPLIT) ValueList[0:len(TokenList)] = TokenList InfDefineUnloadImageItemObj = InfDefineUnloadImageItem() if not IsValidCVariableName(ValueList[0]): ErrorInInf(ST.ERR_INF_PARSER_DEFINE_FROMAT_INVALID % (ValueList[0]), LineInfo=self.CurrentLine) InfDefineUnloadImageItemObj.SetCName(ValueList[0]) if len(ValueList) == 2: if ValueList[1].strip() == '': ErrorInInf(ST.ERR_INF_PARSER_DEFINE_FROMAT_INVALID % (ValueList[1]), LineInfo=self.CurrentLine) # # Validate FFE # FeatureFlagRtv = IsValidFeatureFlagExp(ValueList[1].strip()) if not FeatureFlagRtv[0]: ErrorInInf(ST.ERR_INF_PARSER_FEATURE_FLAG_EXP_SYNTAX_INVLID % (FeatureFlagRtv[1]), LineInfo=self.CurrentLine) InfDefineUnloadImageItemObj.SetFeatureFlagExp(ValueList[1]) if len(ValueList) > 2: ErrorInInf(ST.ERR_INF_PARSER_DEFINE_FROMAT_INVALID % (UnloadImages), LineInfo=self.CurrentLine) InfDefineUnloadImageItemObj.Comments = Comments self.UnloadImages.append(InfDefineUnloadImageItemObj)
def SetDestructor(self, Destructor, Comments): # # It can be a list and only 1 set to TRUE # ValueList = [] TokenList = GetSplitValueList(Destructor, DT.TAB_VALUE_SPLIT) ValueList[0:len(TokenList)] = TokenList InfDefineDestructorItemObj = InfDefineDestructorItem() if not IsValidCVariableName(ValueList[0]): ErrorInInf(ST.ERR_INF_PARSER_DEFINE_FROMAT_INVALID % (ValueList[0]), LineInfo=self.CurrentLine) InfDefineDestructorItemObj.SetCName(ValueList[0]) if len(ValueList) >= 2: ModList = GetSplitValueList(ValueList[1].strip(), ' ') if ValueList[1].strip() == '': ErrorInInf(ST.ERR_INF_PARSER_DEFINE_FROMAT_INVALID % (ValueList[1]), LineInfo=self.CurrentLine) for ModItem in ModList: if ModItem not in DT.MODULE_LIST: ErrorInInf(ST.ERR_INF_PARSER_DEFINE_MODULETYPE_INVALID % (ModItem), LineInfo=self.CurrentLine) InfDefineDestructorItemObj.SetSupModList(ModList) if len(ValueList) == 3: if ValueList[2].strip() == '': ErrorInInf(ST.ERR_INF_PARSER_DEFINE_FROMAT_INVALID % (ValueList[2]), LineInfo=self.CurrentLine) # # Validate FFE # FeatureFlagRtv = IsValidFeatureFlagExp(ValueList[2].strip()) if not FeatureFlagRtv[0]: ErrorInInf(ST.ERR_INF_PARSER_FEATURE_FLAG_EXP_SYNTAX_INVLID % (FeatureFlagRtv[1]), LineInfo=self.CurrentLine) InfDefineDestructorItemObj.SetFeatureFlagExp(ValueList[2]) if len(ValueList) > 3: ErrorInInf(ST.ERR_INF_PARSER_DEFINE_FROMAT_INVALID % (Destructor), LineInfo=self.CurrentLine) InfDefineDestructorItemObj.Comments = Comments self.Destructor.append(InfDefineDestructorItemObj)
def SetGuid(self, GuidList, Arch = None): __SupportArchList = [] for ArchItem in Arch: # # Validate Arch # if (ArchItem == '' or ArchItem == None): ArchItem = 'COMMON' __SupportArchList.append(ArchItem) for Item in GuidList: # # Get Comment content of this protocol # CommentsList = None if len(Item) == 3: CommentsList = Item[1] CurrentLineOfItem = Item[2] Item = Item[0] InfGuidItemObj = InfGuidItem() if len(Item) >= 1 and len(Item) <= 2: # # Only GuildName contained # if not IsValidCVariableName(Item[0]): Logger.Error("InfParser", ToolError.FORMAT_INVALID, ST.ERR_INF_PARSER_INVALID_CNAME%(Item[0]), File=CurrentLineOfItem[2], Line=CurrentLineOfItem[1], ExtraData=CurrentLineOfItem[0]) if (Item[0] != ''): InfGuidItemObj.SetName(Item[0]) else: Logger.Error("InfParser", ToolError.FORMAT_INVALID, ST.ERR_INF_PARSER_CNAME_MISSING, File=CurrentLineOfItem[2], Line=CurrentLineOfItem[1], ExtraData=CurrentLineOfItem[0]) if len(Item) == 2: # # Contained CName and Feature Flag Express # <statements> ::= <CName> ["|" <FeatureFlagExpress>] # For GUID entry. # if Item[1].strip() == '': Logger.Error("InfParser", ToolError.FORMAT_INVALID, ST.ERR_INF_PARSER_FEATURE_FLAG_EXP_MISSING, File=CurrentLineOfItem[2], Line=CurrentLineOfItem[1], ExtraData=CurrentLineOfItem[0]) # # Validate Feature Flag Express # FeatureFlagRtv = IsValidFeatureFlagExp(Item[1].strip()) if not FeatureFlagRtv[0]: Logger.Error("InfParser", ToolError.FORMAT_INVALID, ST.ERR_INF_PARSER_FEATURE_FLAG_EXP_SYNTAX_INVLID%(FeatureFlagRtv[1]), File=CurrentLineOfItem[2], Line=CurrentLineOfItem[1], ExtraData=CurrentLineOfItem[0]) InfGuidItemObj.SetFeatureFlagExp(Item[1]) if len(Item) != 1 and len(Item) != 2: # # Invalid format of GUID statement # Logger.Error("InfParser", ToolError.FORMAT_INVALID, ST.ERR_INF_PARSER_GUID_PPI_PROTOCOL_SECTION_CONTENT_ERROR, File=CurrentLineOfItem[2], Line=CurrentLineOfItem[1], ExtraData=CurrentLineOfItem[0]) InfGuidItemObj = ParseGuidComment(CommentsList, InfGuidItemObj) InfGuidItemObj.SetSupArchList(__SupportArchList) # # Determine GUID name duplicate. Follow below rule: # # A GUID must not be duplicated within a [Guids] section. # A GUID may appear in multiple architectural [Guids] # sections. A GUID listed in an architectural [Guids] # section must not be listed in the common architectural # [Guids] section. # # NOTE: This check will not report error now. # for Item in self.Guids: if Item.GetName() == InfGuidItemObj.GetName(): ItemSupArchList = Item.GetSupArchList() for ItemArch in ItemSupArchList: for GuidItemObjArch in __SupportArchList: if ItemArch == GuidItemObjArch: # # ST.ERR_INF_PARSER_ITEM_DUPLICATE # pass if ItemArch.upper() == 'COMMON' or GuidItemObjArch.upper() == 'COMMON': # # ST.ERR_INF_PARSER_ITEM_DUPLICATE_COMMON # pass if self.Guids.has_key((InfGuidItemObj)): GuidList = self.Guids[InfGuidItemObj] GuidList.append(InfGuidItemObj) self.Guids[InfGuidItemObj] = GuidList else: GuidList = [] GuidList.append(InfGuidItemObj) self.Guids[InfGuidItemObj] = GuidList return True
def SetProtocol( self, ProtocolContent, Arch=None, ): __SupArchList = [] for ArchItem in Arch: # # Validate Arch # if (ArchItem == '' or ArchItem == None): ArchItem = 'COMMON' __SupArchList.append(ArchItem) for Item in ProtocolContent: # # Get Comment content of this protocol # CommentsList = None if len(Item) == 3: CommentsList = Item[1] CurrentLineOfItem = Item[2] LineInfo = (CurrentLineOfItem[2], CurrentLineOfItem[1], CurrentLineOfItem[0]) Item = Item[0] InfProtocolItemObj = InfProtocolItem() if len(Item) >= 1 and len(Item) <= 2: # # Only CName contained # if not IsValidCVariableName(Item[0]): ErrorInInf(ST.ERR_INF_PARSER_INVALID_CNAME % (Item[0]), LineInfo=LineInfo) if (Item[0] != ''): InfProtocolItemObj.SetName(Item[0]) else: ErrorInInf(ST.ERR_INF_PARSER_CNAME_MISSING, LineInfo=LineInfo) if len(Item) == 2: # # Contained CName and Feature Flag Express # <statements> ::= <CName> ["|" # <FeatureFlagExpress>] # For Protocol Object # if Item[1].strip() == '': ErrorInInf(ST.ERR_INF_PARSER_FEATURE_FLAG_EXP_MISSING, LineInfo=LineInfo) # # Validate Feature Flag Express for Item[1] # FeatureFlagRtv = IsValidFeatureFlagExp(Item[1].strip()) if not FeatureFlagRtv[0]: ErrorInInf( ST.ERR_INF_PARSER_FEATURE_FLAG_EXP_SYNTAX_INVLID % (FeatureFlagRtv[1]), LineInfo=LineInfo) InfProtocolItemObj.SetFeatureFlagExp(Item[1]) if len(Item) < 1 or len(Item) > 2: # # Invalid format of Protocols statement # ErrorInInf( ST.ERR_INF_PARSER_GUID_PPI_PROTOCOL_SECTION_CONTENT_ERROR, LineInfo=LineInfo) # # Get/Set Usage and HelpString for Protocol entry # if CommentsList != None and len(CommentsList) != 0: InfProtocolItemObj = ParseProtocolComment( CommentsList, InfProtocolItemObj) else: CommentItemIns = InfProtocolItemCommentContent() CommentItemIns.SetUsageItem(DT.ITEM_UNDEFINED) CommentItemIns.SetNotify(DT.ITEM_UNDEFINED) InfProtocolItemObj.SetCommentList([CommentItemIns]) InfProtocolItemObj.SetSupArchList(__SupArchList) # # Determine protocol name duplicate. Follow below rule: # # A protocol must not be duplicated within a [Protocols] section. # A protocol may appear in multiple architectural [Protocols] # sections. A protocol listed in an architectural [Protocols] # section must not be listed in the common architectural # [Protocols] section. # # NOTE: This check will not report error now. # for Item in self.Protocols: if Item.GetName() == InfProtocolItemObj.GetName(): ItemSupArchList = Item.GetSupArchList() for ItemArch in ItemSupArchList: for ProtocolItemObjArch in __SupArchList: if ItemArch == ProtocolItemObjArch: # # ST.ERR_INF_PARSER_ITEM_DUPLICATE # pass if ItemArch.upper( ) == 'COMMON' or ProtocolItemObjArch.upper( ) == 'COMMON': # # ST.ERR_INF_PARSER_ITEM_DUPLICATE_COMMON # pass if self.Protocols.has_key((InfProtocolItemObj)): ProcotolList = self.Protocols[InfProtocolItemObj] ProcotolList.append(InfProtocolItemObj) self.Protocols[InfProtocolItemObj] = ProcotolList else: ProcotolList = [] ProcotolList.append(InfProtocolItemObj) self.Protocols[InfProtocolItemObj] = ProcotolList return True
def SetPpi(self, PpiList, Arch=None): __SupArchList = [] for ArchItem in Arch: # # Validate Arch # if (ArchItem == '' or ArchItem == None): ArchItem = 'COMMON' __SupArchList.append(ArchItem) for Item in PpiList: # # Get Comment content of this protocol # CommentsList = None if len(Item) == 3: CommentsList = Item[1] CurrentLineOfItem = Item[2] Item = Item[0] InfPpiItemObj = InfPpiItem() if len(Item) >= 1 and len(Item) <= 2: # # Only CName contained # if not IsValidCVariableName(Item[0]): Logger.Error("InfParser", ToolError.FORMAT_INVALID, ST.ERR_INF_PARSER_INVALID_CNAME % (Item[0]), File=CurrentLineOfItem[2], Line=CurrentLineOfItem[1], ExtraData=CurrentLineOfItem[0]) if (Item[0] != ''): InfPpiItemObj.SetName(Item[0]) else: Logger.Error("InfParser", ToolError.FORMAT_INVALID, ST.ERR_INF_PARSER_CNAME_MISSING, File=CurrentLineOfItem[2], Line=CurrentLineOfItem[1], ExtraData=CurrentLineOfItem[0]) # # Have FeatureFlag information # if len(Item) == 2: # # Contained CName and Feature Flag Express # <statements> ::= <CName> ["|" <FeatureFlagExpress>] # Item[1] should not be empty # if Item[1].strip() == '': Logger.Error("InfParser", ToolError.FORMAT_INVALID, ST.ERR_INF_PARSER_FEATURE_FLAG_EXP_MISSING, File=CurrentLineOfItem[2], Line=CurrentLineOfItem[1], ExtraData=CurrentLineOfItem[0]) # # Validate Feature Flag Express for PPI entry # Item[1] contain FFE information # FeatureFlagRtv = IsValidFeatureFlagExp(Item[1].strip()) if not FeatureFlagRtv[0]: Logger.Error( "InfParser", ToolError.FORMAT_INVALID, ST.ERR_INF_PARSER_FEATURE_FLAG_EXP_SYNTAX_INVLID % (FeatureFlagRtv[1]), File=CurrentLineOfItem[2], Line=CurrentLineOfItem[1], ExtraData=CurrentLineOfItem[0]) InfPpiItemObj.SetFeatureFlagExp(Item[1]) if len(Item) != 1 and len(Item) != 2: # # Invalid format of Ppi statement # Logger.Error( "InfParser", ToolError.FORMAT_INVALID, ST.ERR_INF_PARSER_GUID_PPI_PROTOCOL_SECTION_CONTENT_ERROR, File=CurrentLineOfItem[2], Line=CurrentLineOfItem[1], ExtraData=CurrentLineOfItem[0]) # # Get/Set Usage and HelpString for PPI entry # if CommentsList != None and len(CommentsList) != 0: InfPpiItemObj = ParsePpiComment(CommentsList, InfPpiItemObj) else: CommentItemIns = InfPpiItemCommentContent() CommentItemIns.SetUsage(DT.ITEM_UNDEFINED) CommentItemIns.SetNotify(DT.ITEM_UNDEFINED) InfPpiItemObj.SetCommentList([CommentItemIns]) InfPpiItemObj.SetSupArchList(__SupArchList) # # Determine PPI name duplicate. Follow below rule: # # A PPI must not be duplicated within a [Ppis] section. # A PPI may appear in multiple architectural [Ppis] # sections. A PPI listed in an architectural [Ppis] # section must not be listed in the common architectural # [Ppis] section. # # NOTE: This check will not report error now. # for Item in self.Ppis: if Item.GetName() == InfPpiItemObj.GetName(): ItemSupArchList = Item.GetSupArchList() for ItemArch in ItemSupArchList: for PpiItemObjArch in __SupArchList: if ItemArch == PpiItemObjArch: # # ST.ERR_INF_PARSER_ITEM_DUPLICATE # pass if ItemArch.upper( ) == 'COMMON' or PpiItemObjArch.upper( ) == 'COMMON': # # ST.ERR_INF_PARSER_ITEM_DUPLICATE_COMMON # pass if self.Ppis.has_key((InfPpiItemObj)): PpiList = self.Ppis[InfPpiItemObj] PpiList.append(InfPpiItemObj) self.Ppis[InfPpiItemObj] = PpiList else: PpiList = [] PpiList.append(InfPpiItemObj) self.Ppis[InfPpiItemObj] = PpiList return True