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