1## @file 2# This file is used to define class objects of INF file miscellaneous. 3# Include BootMode/HOB/Event and others. It will consumed by InfParser. 4# 5# Copyright (c) 2011, Intel Corporation. All rights reserved.<BR> 6# 7# This program and the accompanying materials are licensed and made available 8# under the terms and conditions of the BSD License which accompanies this 9# distribution. The full text of the license may be found at 10# http://opensource.org/licenses/bsd-license.php 11# 12# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, 13# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. 14 15''' 16InfMisc 17''' 18 19import Logger.Log as Logger 20from Logger import ToolError 21 22from Library import DataType as DT 23from Object.Parser.InfCommonObject import InfSectionCommonDef 24from Library.Misc import Sdict 25 26## 27# BootModeObject 28# 29class InfBootModeObject(): 30 def __init__(self): 31 self.SupportedBootModes = '' 32 self.HelpString = '' 33 self.Usage = '' 34 35 def SetSupportedBootModes(self, SupportedBootModes): 36 self.SupportedBootModes = SupportedBootModes 37 def GetSupportedBootModes(self): 38 return self.SupportedBootModes 39 40 def SetHelpString(self, HelpString): 41 self.HelpString = HelpString 42 def GetHelpString(self): 43 return self.HelpString 44 45 def SetUsage(self, Usage): 46 self.Usage = Usage 47 def GetUsage(self): 48 return self.Usage 49## 50# EventObject 51# 52class InfEventObject(): 53 def __init__(self): 54 self.EventType = '' 55 self.HelpString = '' 56 self.Usage = '' 57 58 def SetEventType(self, EventType): 59 self.EventType = EventType 60 61 def GetEventType(self): 62 return self.EventType 63 64 def SetHelpString(self, HelpString): 65 self.HelpString = HelpString 66 def GetHelpString(self): 67 return self.HelpString 68 69 def SetUsage(self, Usage): 70 self.Usage = Usage 71 def GetUsage(self): 72 return self.Usage 73## 74# HobObject 75# 76class InfHobObject(): 77 def __init__(self): 78 self.HobType = '' 79 self.Usage = '' 80 self.SupArchList = [] 81 self.HelpString = '' 82 83 def SetHobType(self, HobType): 84 self.HobType = HobType 85 86 def GetHobType(self): 87 return self.HobType 88 89 def SetUsage(self, Usage): 90 self.Usage = Usage 91 def GetUsage(self): 92 return self.Usage 93 94 def SetSupArchList(self, ArchList): 95 self.SupArchList = ArchList 96 def GetSupArchList(self): 97 return self.SupArchList 98 99 def SetHelpString(self, HelpString): 100 self.HelpString = HelpString 101 def GetHelpString(self): 102 return self.HelpString 103 104## 105# InfSpecialCommentObject 106# 107class InfSpecialCommentObject(InfSectionCommonDef): 108 def __init__(self): 109 self.SpecialComments = Sdict() 110 InfSectionCommonDef.__init__(self) 111 112 def SetSpecialComments(self, SepcialSectionList = None, Type = ''): 113 if Type == DT.TYPE_HOB_SECTION or \ 114 Type == DT.TYPE_EVENT_SECTION or \ 115 Type == DT.TYPE_BOOTMODE_SECTION: 116 for Item in SepcialSectionList: 117 if self.SpecialComments.has_key(Type): 118 ObjList = self.SpecialComments[Type] 119 ObjList.append(Item) 120 self.SpecialComments[Type] = ObjList 121 else: 122 ObjList = [] 123 ObjList.append(Item) 124 self.SpecialComments[Type] = ObjList 125 126 return True 127 128 def GetSpecialComments(self): 129 return self.SpecialComments 130 131 132 133## ErrorInInf 134# 135# An encapsulate of Error for INF parser. 136# 137def ErrorInInf(Message=None, ErrorCode=None, LineInfo=None, RaiseError=True): 138 if ErrorCode == None: 139 ErrorCode = ToolError.FORMAT_INVALID 140 if LineInfo == None: 141 LineInfo = ['', -1, ''] 142 Logger.Error("InfParser", 143 ErrorCode, 144 Message=Message, 145 File=LineInfo[0], 146 Line=LineInfo[1], 147 ExtraData=LineInfo[2], 148 RaiseError=RaiseError)