]>
Commit | Line | Data |
---|---|---|
1 | /** @file\r | |
2 | CommonDefinition class.\r | |
3 | \r | |
4 | This class is to define some common marcos and funcions, which used by AutoGen.\r | |
5 | \r | |
6 | Copyright (c) 2006, Intel Corporation\r | |
7 | All rights reserved. This program and the accompanying materials\r | |
8 | are licensed and made available under the terms and conditions of the BSD License\r | |
9 | which accompanies this distribution. The full text of the license may be found at\r | |
10 | http://opensource.org/licenses/bsd-license.php\r | |
11 | \r | |
12 | THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r | |
13 | WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r | |
14 | \r | |
15 | **/\r | |
16 | package org.tianocore.build.autogen;\r | |
17 | \r | |
18 | /**\r | |
19 | CommonDefinition\r | |
20 | \r | |
21 | This class is to define some common marcos, which used by AutoGen.\r | |
22 | \r | |
23 | **/\r | |
24 | public class CommonDefinition {\r | |
25 | public final static String spdSuffix = ".spd";\r | |
26 | public final static String mbdSuffix = ".mbd";\r | |
27 | public final static String msaSuffix = ".msa";\r | |
28 | public final static String LibraryStr = "LIBRARY";\r | |
29 | public final static String autoGenHbegin = "extern int __make_me_compile_correctly;\r\n";\r | |
30 | public final static String include = "#include";\r | |
31 | public final static String autoGenCLine1 = "\r\n";\r | |
32 | \r | |
33 | public final static String autoGenCLine2 = "const UINT8 _gDebugPropertyMask "\r | |
34 | + "= DEBUG_PROPERTY_DEBUG_ASSERT_ENABLED"\r | |
35 | + " | DEBUG_PROPERTY_DEBUG_PRINT_ENABLED"\r | |
36 | + " | DEBUG_PROPERTY_DEBUG_CODE_ENABLED;\r\n";\r | |
37 | \r | |
38 | public final static String autoGenCLine3 = "const UINTN _gModuleDefaultErrorLevel"\r | |
39 | + " = EFI_D_ERROR | EFI_D_LOAD;\r\n";\r | |
40 | \r | |
41 | public final static String autoGenHLine1 = "#define EFI_SPECIFICATION_VERSION 0x00020000\r\n";\r | |
42 | public final static String autoGenHVersionDefault = "#define EFI_SPECIFICATION_VERSION 0x00000000\r\n";\r | |
43 | public final static String autoGenHLine2 = "#define EDK_RELEASE_VERSION 0x00090000\r\n";\r | |
44 | public final static String autoGenHReleaseDefault = "#define EDK_RELEASE_VERSION 0x00000000\r\n";\r | |
45 | \r | |
46 | public final static String includeAutogenH = "#include <AutoGen.h>\r\n" ;\r | |
47 | \r | |
48 | public final static String gEfi = "gEfi";\r | |
49 | public final static String protocolGuid = "ProtocolGuid";\r | |
50 | public final static String ppiGuid = "PpiGuid";\r | |
51 | public final static String guidGuid = "Guid";\r | |
52 | \r | |
53 | //\r | |
54 | // AutoGen.h and AutoGen.c file's header\r | |
55 | //\r | |
56 | public final static String autogenHNotation = \r | |
57 | "/**\r\n" +\r | |
58 | " DO NOT EDIT\r\n" +\r | |
59 | " FILE auto-generated by GenBuild tasks\r\n" +\r | |
60 | " Module name:\r\n" +\r | |
61 | " AutoGen.h\r\n" +\r | |
62 | " Abstract:" +\r | |
63 | " Auto-generated AutoGen.h for building module or library.\r\n" +\r | |
64 | "**/\r\n\r\n";\r | |
65 | \r | |
66 | public final static String autogenCNotation = \r | |
67 | "/**\r\n" +\r | |
68 | " DO NOT EDIT\r\n" +\r | |
69 | " FILE auto-generated by GenBuild tasks\r\n" +\r | |
70 | " Module name:\r\n" +\r | |
71 | " AutoGen.c\r\n" +\r | |
72 | " Abstract:" +\r | |
73 | " Auto-generated AutoGen.c for building module or library.\r\n" +\r | |
74 | "**/\r\n\r\n";\r | |
75 | \r | |
76 | //\r | |
77 | // module type\r | |
78 | //\r | |
79 | public final static int ModuleTypeBase = 0;\r | |
80 | public final static int ModuleTypeSec = 1;\r | |
81 | public final static int ModuleTypePeiCore = 2;\r | |
82 | public final static int ModuleTypePeim = 3;\r | |
83 | public final static int ModuleTypeDxeCore = 4;\r | |
84 | public final static int ModuleTypeDxeDriver = 5;\r | |
85 | public final static int ModuleTypeDxeRuntimeDriver = 6;\r | |
86 | public final static int ModuleTypeDxeSmmDriver = 7;\r | |
87 | public final static int ModuleTypeDxeSalDriver = 8;\r | |
88 | public final static int ModuleTypeUefiDriver = 9;\r | |
89 | public final static int ModuleTypeUefiApplication = 10;\r | |
90 | public final static int ModuleTypeUnknown = 11;\r | |
91 | \r | |
92 | \r | |
93 | //\r | |
94 | // component type\r | |
95 | // \r | |
96 | public final static int ComponentTypeNull = 0;\r | |
97 | public final static int ComponentTypeApriori = 1;\r | |
98 | public final static int ComponentTypeSec = 2;\r | |
99 | public final static int ComponentTypeLibrary = 3;\r | |
100 | public final static int ComponentTypeFvImageFile = 4;\r | |
101 | public final static int ComponentTypeBsDriver = 5;\r | |
102 | public final static int ComponentTypeRtDriver = 6;\r | |
103 | public final static int ComponentTypeSalRtDriver =7;\r | |
104 | public final static int ComponentTypePe32Peim = 8;\r | |
105 | public final static int ComponentTypePicPeim =9;\r | |
106 | public final static int ComponentTypeCombinedPeimDriver =10;\r | |
107 | public final static int ComponentTypePeiCore = 11;\r | |
108 | public final static int ComponentTypeDxeCore = 12;\r | |
109 | public final static int ComponentTypeApplication = 13;\r | |
110 | public final static int ComponentTypeBsDriverEfi = 14;\r | |
111 | public final static int ComponentTypeShellApp = 15;\r | |
112 | public final static int ComponentTypeBinary =16;\r | |
113 | public final static int ComponentTypeLogo = 17;\r | |
114 | public final static int ComponentTypeCustomBuild = 18;\r | |
115 | public final static int ComponentTypeUnknown = 19;\r | |
116 | \r | |
117 | \r | |
118 | //\r | |
119 | // Usaged style\r | |
120 | //\r | |
121 | public final static String AlwaysConsumed = "ALWAYS_CONSUMED";\r | |
122 | public final static String AlwaysProduced = "ALWAYS_PRODUCED";\r | |
123 | \r | |
124 | \r | |
125 | public static class MyEnum {\r | |
126 | String moduleTypeStr;\r | |
127 | int type;\r | |
128 | \r | |
129 | MyEnum (String str, int type) {\r | |
130 | this.type = type;\r | |
131 | this.moduleTypeStr = str;\r | |
132 | }\r | |
133 | \r | |
134 | int ForInt(String str) {\r | |
135 | if (str.equals(this.moduleTypeStr)) {\r | |
136 | return this.type;\r | |
137 | } else\r | |
138 | return -1;\r | |
139 | }\r | |
140 | }\r | |
141 | \r | |
142 | //\r | |
143 | // Module type\r | |
144 | //\r | |
145 | public static final MyEnum[] moduleEnum = new MyEnum[] {\r | |
146 | new MyEnum("BASE", ModuleTypeBase),\r | |
147 | new MyEnum("SEC", ModuleTypeSec),\r | |
148 | new MyEnum("PEI_CORE", ModuleTypePeiCore),\r | |
149 | new MyEnum("PEIM", ModuleTypePeim),\r | |
150 | new MyEnum("DXE_CORE", ModuleTypeDxeCore),\r | |
151 | new MyEnum("DXE_DRIVER", ModuleTypeDxeRuntimeDriver),\r | |
152 | new MyEnum("DXE_RUNTIME_DRIVER", ModuleTypeDxeRuntimeDriver),\r | |
153 | new MyEnum("DXE_SAL_DRIVER", ModuleTypeDxeSmmDriver),\r | |
154 | new MyEnum("DXE_SMM_DRIVER", ModuleTypeDxeSalDriver),\r | |
155 | new MyEnum("UEFI_DRIVER", ModuleTypeUefiDriver),\r | |
156 | new MyEnum("UEFI_APPLICATION", ModuleTypeUefiApplication) };\r | |
157 | \r | |
158 | //\r | |
159 | // Component type\r | |
160 | //\r | |
161 | public static final MyEnum[] componentEnum = new MyEnum[]{\r | |
162 | new MyEnum("APRIORI", ComponentTypeApriori),\r | |
163 | new MyEnum("SEC", ComponentTypeSec),\r | |
164 | new MyEnum("LIBRARY", ComponentTypeLibrary),\r | |
165 | new MyEnum("FV_IMAGE_FILE", ComponentTypeFvImageFile),\r | |
166 | new MyEnum("BS_DRIVER", ComponentTypeBsDriver),\r | |
167 | new MyEnum("RT_DRIVER", ComponentTypeRtDriver),\r | |
168 | new MyEnum("SAL_RT_DRIVER", ComponentTypeSalRtDriver),\r | |
169 | new MyEnum("PE32_PEIM", ComponentTypePe32Peim),\r | |
170 | new MyEnum("PIC_PEIM", ComponentTypePicPeim),\r | |
171 | new MyEnum("COMBINED_PEIM_DRIVER", ComponentTypeCombinedPeimDriver),\r | |
172 | new MyEnum("PEI_CORE", ComponentTypePeiCore),\r | |
173 | new MyEnum("DXE_CORE", ComponentTypeDxeCore),\r | |
174 | new MyEnum("APPLICATION", ComponentTypeApplication),\r | |
175 | new MyEnum("BS_DRIVER_EFI", ComponentTypeBsDriverEfi),\r | |
176 | new MyEnum("SHELLAPP", ComponentTypeShellApp),\r | |
177 | new MyEnum("BINARY", ComponentTypeBinary),\r | |
178 | new MyEnum("LOGO", ComponentTypeLogo),\r | |
179 | new MyEnum("CUSTOM_BUILD", ComponentTypeCustomBuild)\r | |
180 | };\r | |
181 | \r | |
182 | /**\r | |
183 | getModuleType\r | |
184 | \r | |
185 | This function get the module type value according module type string.\r | |
186 | \r | |
187 | @param moduleTypeStr String of modlue type.\r | |
188 | @return \r | |
189 | **/\r | |
190 | static public int getModuleType(String moduleTypeStr) {\r | |
191 | int returnValue = -1;\r | |
192 | for (int i = 0; i < CommonDefinition.moduleEnum.length; i++) {\r | |
193 | returnValue = CommonDefinition.moduleEnum[i].ForInt(moduleTypeStr);\r | |
194 | if (returnValue != -1) {\r | |
195 | return returnValue;\r | |
196 | }\r | |
197 | }\r | |
198 | return CommonDefinition.ModuleTypeUnknown;\r | |
199 | }\r | |
200 | \r | |
201 | /**\r | |
202 | getComponentType\r | |
203 | \r | |
204 | This function get the component type value according commponet type \r | |
205 | string.\r | |
206 | \r | |
207 | @param componentTypeStr String of component type.\r | |
208 | @return\r | |
209 | **/\r | |
210 | static public int getComponentType (String componentTypeStr){\r | |
211 | int returnValue = -1;\r | |
212 | for (int i = 0; i < CommonDefinition.componentEnum.length; i++) {\r | |
213 | returnValue = CommonDefinition.componentEnum[i].ForInt(componentTypeStr);\r | |
214 | if (returnValue != -1) {\r | |
215 | return returnValue;\r | |
216 | }\r | |
217 | }\r | |
218 | return CommonDefinition.ComponentTypeUnknown;\r | |
219 | }\r | |
220 | \r | |
221 | /**\r | |
222 | getComponentTypeString\r | |
223 | \r | |
224 | This function get the commponet type string according component type value.\r | |
225 | \r | |
226 | @param componentType Integer value of component type.\r | |
227 | @return\r | |
228 | **/\r | |
229 | static public String getComponentTypeString (int componentType) {\r | |
230 | if ((componentType > CommonDefinition.ComponentTypeUnknown) || \r | |
231 | (componentType < CommonDefinition.ComponentTypeNull)) {\r | |
232 | return null;\r | |
233 | }\r | |
234 | for (int index = 0; index < CommonDefinition.componentEnum.length; index ++) {\r | |
235 | if (componentType == CommonDefinition.componentEnum[index].type) {\r | |
236 | return CommonDefinition.componentEnum[index].moduleTypeStr;\r | |
237 | }\r | |
238 | }\r | |
239 | return null;\r | |
240 | }\r | |
241 | \r | |
242 | /**\r | |
243 | isLibraryComponent \r | |
244 | \r | |
245 | This function is to check does componet is library according to commponet\r | |
246 | type value.\r | |
247 | \r | |
248 | @param componentType Integer value of component type.\r | |
249 | @return\r | |
250 | **/\r | |
251 | static public boolean isLibraryComponent (int componentType) {\r | |
252 | if (ComponentTypeLibrary == componentType) {\r | |
253 | return true;\r | |
254 | }\r | |
255 | return false;\r | |
256 | }\r | |
257 | \r | |
258 | static public boolean isPeiPhaseComponent (int componentType) {\r | |
259 | if (ComponentTypePe32Peim == componentType\r | |
260 | || ComponentTypePicPeim == componentType\r | |
261 | || ComponentTypeCombinedPeimDriver == componentType\r | |
262 | || ComponentTypePeiCore == componentType) {\r | |
263 | return true;\r | |
264 | }\r | |
265 | return false;\r | |
266 | }\r | |
267 | \r | |
268 | static public boolean isPe32PeimComponent (int componentType) {\r | |
269 | if (ComponentTypePe32Peim == componentType) {\r | |
270 | return true;\r | |
271 | }\r | |
272 | return false;\r | |
273 | }\r | |
274 | \r | |
275 | static public boolean isBsDriverComponent (int componentType) {\r | |
276 | if (ComponentTypeBsDriver == componentType) {\r | |
277 | return true;\r | |
278 | }\r | |
279 | return false;\r | |
280 | }\r | |
281 | \r | |
282 | } |