UsageList = ("PRODUCES", "PRODUCED", "ALWAYS_PRODUCES", "ALWAYS_PRODUCED", "SOMETIMES_PRODUCES",\r
"SOMETIMES_PRODUCED", "CONSUMES", "CONSUMED", "ALWAYS_CONSUMES", "ALWAYS_CONSUMED",\r
"SOMETIMES_CONSUMES", "SOMETIMES_CONSUMED", "SOMETIME_CONSUMES")\r
+ErrorMsgMap = {\r
+ MODEL_EFI_GUID : "The usage for this GUID is not listed in this INF: %s[%d]:%s",\r
+ MODEL_EFI_PPI : "The usage for this PPI is not listed in this INF: %s[%d]:%s.",\r
+ MODEL_EFI_PROTOCOL : "The usage for this Protocol is not listed in this INF: %s[%d]:%s.",\r
+ MODEL_PCD_DYNAMIC : "The usage for this PCD is not listed in this INF: %s[%d]:%s."\r
+}\r
\r
+def CheckInfComment(SectionType, Comments, InfFile, LineNo, ValueList):\r
+ if SectionType in [MODEL_PCD_PATCHABLE_IN_MODULE, MODEL_PCD_DYNAMIC_EX, MODEL_PCD_DYNAMIC]:\r
+ CheckUsage(Comments, UsageList, InfFile, LineNo, ValueList[0]+'.'+ValueList[1], ErrorMsgMap[MODEL_PCD_DYNAMIC])\r
+ elif SectionType in [MODEL_EFI_GUID, MODEL_EFI_PPI]:\r
+ CheckUsage(Comments, UsageList, InfFile, LineNo, ValueList[0], ErrorMsgMap[SectionType])\r
+ elif SectionType == MODEL_EFI_PROTOCOL:\r
+ CheckUsage(Comments, UsageList + ("TO_START", "BY_START"), InfFile, LineNo, ValueList[0], ErrorMsgMap[SectionType])\r
+\r
+def CheckUsage(Comments, Usages, InfFile, LineNo, Value, ErrorMsg):\r
+ for Comment in Comments:\r
+ for Word in Comment[0].replace('#', ' ').split():\r
+ if Word in Usages:\r
+ return\r
+ EdkLogger.error(\r
+ "Parser", FORMAT_INVALID,\r
+ ErrorMsg % (InfFile, LineNo, Value)\r
+ )\r