878ddf1f |
1 | /** @file\r |
2 | UsageInstance class.\r |
3 | \r |
4 | This class indicate an usage instance for a PCD token. This instance maybe a module\r |
5 | or platform setting. When a module produce or cosume a PCD token, then this module\r |
6 | is an usage instance for this PCD token.\r |
bc262841 |
7 | \r |
878ddf1f |
8 | Copyright (c) 2006, Intel Corporation\r |
9 | All rights reserved. This program and the accompanying materials\r |
10 | are licensed and made available under the terms and conditions of the BSD License\r |
11 | which accompanies this distribution. The full text of the license may be found at\r |
12 | http://opensource.org/licenses/bsd-license.php\r |
bc262841 |
13 | \r |
878ddf1f |
14 | THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r |
15 | WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r |
16 | \r |
bc262841 |
17 | **/\r |
d14ebb43 |
18 | package org.tianocore.pcd.entity;\r |
878ddf1f |
19 | \r |
d14ebb43 |
20 | import org.tianocore.pcd.entity.CommonDefinition;\r |
21 | import org.tianocore.pcd.entity.UsageIdentification;\r |
878ddf1f |
22 | \r |
23 | /**\r |
24 | This class indicate an usage instance for a PCD token. This instance maybe a module\r |
25 | or platform setting. When a module produce or cosume a PCD token, then this module\r |
26 | is an usage instance for this PCD token.\r |
27 | **/\r |
28 | public class UsageInstance {\r |
38ee8d9e |
29 | ///\r |
30 | /// This parent that this usage instance belongs to.\r |
31 | ///\r |
eece174a |
32 | public Token parentToken;\r |
38ee8d9e |
33 | \r |
34 | ///\r |
eece174a |
35 | /// ModuleIdentification for Usage Instance\r |
bc262841 |
36 | ///\r |
d14ebb43 |
37 | public UsageIdentification usageId;\r |
38ee8d9e |
38 | \r |
39 | ///\r |
eece174a |
40 | /// Arch also is a key for a UsageInstance\r |
bc262841 |
41 | ///\r |
eece174a |
42 | public String arch;\r |
38ee8d9e |
43 | \r |
44 | ///\r |
bc262841 |
45 | /// The PCD type defined for module\r |
46 | ///\r |
eece174a |
47 | public Token.PCD_TYPE modulePcdType;\r |
38ee8d9e |
48 | \r |
49 | ///\r |
bc262841 |
50 | /// The value of the PCD in this usage instance.\r |
51 | ///\r |
eece174a |
52 | public String datum;\r |
38ee8d9e |
53 | \r |
54 | ///\r |
55 | /// The maxDatumSize could be different for same PCD in different module\r |
56 | /// But this case is allow for FeatureFlag, FixedAtBuild, PatchableInModule\r |
57 | /// type.\r |
bc262841 |
58 | ///\r |
eece174a |
59 | public int maxDatumSize;\r |
38ee8d9e |
60 | \r |
61 | ///\r |
62 | /// Autogen string for header file.\r |
63 | ///\r |
eece174a |
64 | public String hAutogenStr;\r |
38ee8d9e |
65 | \r |
66 | ///\r |
67 | /// Auotgen string for C code file.\r |
bc262841 |
68 | ///\r |
eece174a |
69 | public String cAutogenStr;\r |
38ee8d9e |
70 | \r |
71 | /**\r |
eece174a |
72 | Constructure function for UsageInstance\r |
bc262841 |
73 | \r |
eece174a |
74 | @param parentToken The token instance for this usgaInstance\r |
f28c0830 |
75 | @param usageId The identification for usage instance\r |
eece174a |
76 | @param modulePcdType The PCD type for this usage instance\r |
77 | @param value The value of this PCD in this usage instance\r |
78 | @param maxDatumSize The max datum size of this PCD in this usage\r |
79 | instance.\r |
80 | **/\r |
81 | public UsageInstance(Token parentToken,\r |
d14ebb43 |
82 | UsageIdentification usageId,\r |
eece174a |
83 | Token.PCD_TYPE modulePcdType,\r |
eece174a |
84 | String value,\r |
85 | int maxDatumSize) {\r |
38ee8d9e |
86 | this.parentToken = parentToken;\r |
d14ebb43 |
87 | this.usageId = usageId;\r |
38ee8d9e |
88 | this.modulePcdType = modulePcdType;\r |
38ee8d9e |
89 | this.datum = value;\r |
90 | this.maxDatumSize = maxDatumSize;\r |
91 | }\r |
92 | \r |
93 | /**\r |
94 | Get the primary key for usage instance array for every token.\r |
bc262841 |
95 | \r |
d14ebb43 |
96 | @param usageId The identification of UsageInstance\r |
bc262841 |
97 | \r |
eece174a |
98 | @retval String The primary key for this usage instance\r |
99 | **/\r |
d14ebb43 |
100 | public static String getPrimaryKey(UsageIdentification usageId) {\r |
101 | return usageId.toString();\r |
38ee8d9e |
102 | }\r |
103 | \r |
104 | /**\r |
105 | Get primary key string for this usage instance\r |
bc262841 |
106 | \r |
38ee8d9e |
107 | @return String primary key string\r |
108 | **/\r |
109 | public String getPrimaryKey() {\r |
d14ebb43 |
110 | return UsageInstance.getPrimaryKey(usageId);\r |
38ee8d9e |
111 | }\r |
112 | \r |
113 | /**\r |
114 | Judget whether current module is PEI driver\r |
bc262841 |
115 | \r |
eece174a |
116 | @return boolean whether current module is PEI driver\r |
117 | **/\r |
38ee8d9e |
118 | public boolean isPeiPhaseComponent() {\r |
d14ebb43 |
119 | int moduleType = CommonDefinition.getModuleType(usageId.moduleType);\r |
eece174a |
120 | \r |
136adffc |
121 | if ((moduleType == CommonDefinition.ModuleTypePeiCore) ||\r |
122 | (moduleType == CommonDefinition.ModuleTypePeim)) {\r |
38ee8d9e |
123 | return true;\r |
124 | }\r |
125 | return false;\r |
126 | }\r |
127 | \r |
128 | /**\r |
eece174a |
129 | Judge whether current module is DXE driver.\r |
bc262841 |
130 | \r |
eece174a |
131 | @return boolean whether current module is DXE driver\r |
132 | **/\r |
133 | public boolean isDxePhaseComponent() {\r |
d14ebb43 |
134 | int moduleType = CommonDefinition.getModuleType(usageId.moduleType);\r |
eece174a |
135 | \r |
136 | if ((moduleType == CommonDefinition.ModuleTypeDxeDriver) ||\r |
137 | (moduleType == CommonDefinition.ModuleTypeDxeRuntimeDriver) ||\r |
138 | (moduleType == CommonDefinition.ModuleTypeDxeSalDriver) ||\r |
139 | (moduleType == CommonDefinition.ModuleTypeDxeSmmDriver) ||\r |
140 | (moduleType == CommonDefinition.ModuleTypeUefiDriver) ||\r |
141 | (moduleType == CommonDefinition.ModuleTypeUefiApplication)\r |
142 | ) {\r |
143 | return true;\r |
144 | }\r |
145 | return false;\r |
146 | }\r |
147 | \r |
148 | /**\r |
149 | Generate autogen string for header file and C code file.\r |
bc262841 |
150 | \r |
38ee8d9e |
151 | @param isBuildUsedLibrary whether the autogen is for library.\r |
eece174a |
152 | **/\r |
153 | public void generateAutoGen(boolean isBuildUsedLibrary) {\r |
51da9e80 |
154 | String guidStringCName = null;\r |
155 | boolean isByteArray = false;\r |
156 | String printDatum = null;\r |
157 | String tokenNumberString = null;\r |
38ee8d9e |
158 | \r |
159 | hAutogenStr = "";\r |
160 | cAutogenStr = "";\r |
161 | \r |
162 | if (this.modulePcdType == Token.PCD_TYPE.DYNAMIC_EX) {\r |
eece174a |
163 | //\r |
164 | // For DYNAMIC_EX type PCD, use original token number in SPD or FPD to generate autogen\r |
bc262841 |
165 | //\r |
51da9e80 |
166 | tokenNumberString = Long.toString(parentToken.dynamicExTokenNumber, 16);\r |
38ee8d9e |
167 | } else {\r |
eece174a |
168 | //\r |
169 | // For Others type PCD, use autogenerated token number to generate autogen\r |
bc262841 |
170 | //\r |
51da9e80 |
171 | tokenNumberString = Long.toString(parentToken.tokenNumber, 16);\r |
38ee8d9e |
172 | }\r |
173 | \r |
eece174a |
174 | hAutogenStr += String.format("#define _PCD_TOKEN_%s 0x%s\r\n", parentToken.cName, tokenNumberString);\r |
175 | \r |
176 | //\r |
177 | // Judge the value of this PCD is byte array type\r |
bc262841 |
178 | //\r |
2435723a |
179 | if (!isBuildUsedLibrary && !parentToken.isDynamicPCD) {\r |
180 | if (datum.trim().charAt(0) == '{') {\r |
181 | isByteArray = true;\r |
182 | }\r |
183 | }\r |
184 | \r |
eece174a |
185 | //\r |
186 | // "ULL" should be added to value's tail for UINT64 value\r |
bc262841 |
187 | //\r |
1cf9cdcc |
188 | if (parentToken.datumType == Token.DATUM_TYPE.UINT64) {\r |
189 | printDatum = this.datum + "ULL";\r |
190 | } else {\r |
191 | printDatum = this.datum;\r |
192 | }\r |
193 | \r |
38ee8d9e |
194 | switch (modulePcdType) {\r |
195 | case FEATURE_FLAG:\r |
11eb278a |
196 | //\r |
197 | // Example autogen string for following generation:\r |
198 | // "extern const BOOLEAN _gPcd_FixedAtBuild_PcdSampleToken";\r |
199 | // \r |
bc262841 |
200 | hAutogenStr += String.format("extern const BOOLEAN _gPcd_FixedAtBuild_%s;\r\n",\r |
16d3e132 |
201 | parentToken.cName);\r |
11eb278a |
202 | //\r |
203 | // Example autogen string for following generation:\r |
204 | // "#define _PCD_GET_MODE_8_PcdSampleToken _gPcd_FixedAtBuild_PcdSampleToken";\r |
205 | // \r |
57a38e69 |
206 | hAutogenStr += String.format("#define _PCD_GET_MODE_%s_%s _gPcd_FixedAtBuild_%s\r\n",\r |
bc262841 |
207 | Token.GetAutogenDefinedatumTypeString(parentToken.datumType),\r |
16d3e132 |
208 | parentToken.cName,\r |
209 | parentToken.cName);\r |
11eb278a |
210 | //\r |
211 | // Example autogen string for following generation:\r |
212 | // "//#define _PCD_SET_MODE_8_PcdSampleToken ASSERT(FALSE) If is not allowed to set value...";\r |
213 | // \r |
57a38e69 |
214 | hAutogenStr += String.format("//#define _PCD_SET_MODE_%s_%s ASSERT(FALSE) If is not allowed to set value for a FEATURE_FLAG PCD\r\n",\r |
bc262841 |
215 | Token.GetAutogenDefinedatumTypeString(parentToken.datumType),\r |
57a38e69 |
216 | parentToken.cName);\r |
16d3e132 |
217 | \r |
218 | if (!isBuildUsedLibrary) {\r |
11eb278a |
219 | //\r |
220 | // Example autogen string for following generation:\r |
221 | // "#define _PCD_VALUE_PcdSampleToken 0x1000"\r |
222 | // \r |
bc262841 |
223 | hAutogenStr += String.format("#define _PCD_VALUE_%s %s\r\n",\r |
224 | parentToken.cName,\r |
1cf9cdcc |
225 | printDatum);\r |
11eb278a |
226 | //\r |
227 | // Example autogen string for following generation:\r |
228 | // "GLOBAL_REMOVE_IF_UNREFERENCED const BOOLEAN _gPcd_FixedAtBuild_PcdSampleToken = _PCD_VALUE_PcdSampleToken;"\r |
229 | // \r |
38ee8d9e |
230 | cAutogenStr += String.format("GLOBAL_REMOVE_IF_UNREFERENCED const BOOLEAN _gPcd_FixedAtBuild_%s = _PCD_VALUE_%s;\r\n",\r |
231 | parentToken.cName,\r |
232 | parentToken.cName);\r |
38ee8d9e |
233 | }\r |
234 | break;\r |
235 | case FIXED_AT_BUILD:\r |
16d3e132 |
236 | if (isByteArray) {\r |
11eb278a |
237 | //\r |
238 | // Example autogen string for following generation:\r |
239 | // "extern const BOOLEAN _gPcd_FixedAtBuild_PcdSampleToken";\r |
240 | // \r |
16d3e132 |
241 | hAutogenStr += String.format("extern const UINT8 _gPcd_FixedAtBuild_%s[];\r\n",\r |
242 | parentToken.cName);\r |
11eb278a |
243 | //\r |
244 | // Example autogen string for following generation:\r |
245 | // "#define _PCD_GET_MODE_8_PcdSampleToken (VOID*)_gPcd_FixedAtBuild_PcdSampleToken";\r |
246 | // \r |
bc262841 |
247 | hAutogenStr += String.format("#define _PCD_GET_MODE_%s_%s (VOID*)_gPcd_FixedAtBuild_%s\r\n",\r |
16d3e132 |
248 | Token.GetAutogenDefinedatumTypeString(parentToken.datumType),\r |
249 | parentToken.cName,\r |
250 | parentToken.cName);\r |
251 | } else {\r |
11eb278a |
252 | //\r |
253 | // Example autogen string for following generation:\r |
254 | // "extern const UINT8 _gPcd_FixedAtBuild_PcdSampleToken";\r |
255 | // \r |
38ee8d9e |
256 | hAutogenStr += String.format("extern const %s _gPcd_FixedAtBuild_%s;\r\n",\r |
257 | Token.getAutogendatumTypeString(parentToken.datumType),\r |
258 | parentToken.cName);\r |
11eb278a |
259 | //\r |
260 | // Example autogen string for following generation:\r |
261 | // "#define _PCD_GET_MODE_8_PcdSampleToken _gPcd_FixedAtBuild_PcdSampleToken";\r |
262 | // \r |
bc262841 |
263 | hAutogenStr += String.format("#define _PCD_GET_MODE_%s_%s _gPcd_FixedAtBuild_%s\r\n",\r |
38ee8d9e |
264 | Token.GetAutogenDefinedatumTypeString(parentToken.datumType),\r |
265 | parentToken.cName,\r |
266 | parentToken.cName);\r |
16d3e132 |
267 | }\r |
268 | \r |
11eb278a |
269 | //\r |
270 | // Example autogen string for following generation:\r |
271 | // "//#define _PCD_SET_MODE_8_PcdSampleToken ASSERT(FALSE) If is not allowed to set value...";\r |
272 | // \r |
57a38e69 |
273 | hAutogenStr += String.format("//#define _PCD_SET_MODE_%s_%s ASSERT(FALSE) // It is not allowed to set value for a FIXED_AT_BUILD PCD\r\n",\r |
bc262841 |
274 | Token.GetAutogenDefinedatumTypeString(parentToken.datumType),\r |
57a38e69 |
275 | parentToken.cName);\r |
16d3e132 |
276 | if (!isBuildUsedLibrary) {\r |
9efa2da0 |
277 | if (parentToken.datumType == Token.DATUM_TYPE.POINTER) {\r |
278 | if (isByteArray) {\r |
11eb278a |
279 | //\r |
280 | // Example autogen string for following generation:\r |
281 | // "#define _PCD_VALUE_PcdSampleToken (VOID*)_gPcd_FixedAtBuild_PcdSampleToken"\r |
282 | // \r |
bc262841 |
283 | hAutogenStr += String.format("#define _PCD_VALUE_%s (VOID*)_gPcd_FixedAtBuild_%s\r\n",\r |
284 | parentToken.cName,\r |
9efa2da0 |
285 | parentToken.cName);\r |
11eb278a |
286 | //\r |
287 | // Example autogen string for following generation:\r |
288 | // "GLOBAL_REMOVE_IF_UNREFERENCED const UINT8 _gPcd_FixedAtBuild_PcdSampleToken[] = 'dfdf';"\r |
289 | // \r |
9efa2da0 |
290 | cAutogenStr += String.format("GLOBAL_REMOVE_IF_UNREFERENCED const UINT8 _gPcd_FixedAtBuild_%s[] = %s;\r\n",\r |
291 | parentToken.cName,\r |
292 | printDatum);\r |
293 | } else {\r |
11eb278a |
294 | //\r |
295 | // Example autogen string for following generation:\r |
296 | // "#define _PCD_VALUE_PcdSampleToken 0x222"\r |
297 | // \r |
bc262841 |
298 | hAutogenStr += String.format("#define _PCD_VALUE_%s %s\r\n",\r |
299 | parentToken.cName,\r |
9efa2da0 |
300 | printDatum);\r |
11eb278a |
301 | //\r |
302 | // Example autogen string for following generation:\r |
303 | // "GLOBAL_REMOVE_IF_UNREFERENCED const UINT8 _gPcd_FixedAtBuild_PcdSampleToken[] = _PCD_VALUE_PcdSampleToken;"\r |
304 | // \r |
9efa2da0 |
305 | cAutogenStr += String.format("GLOBAL_REMOVE_IF_UNREFERENCED const %s _gPcd_FixedAtBuild_%s = _PCD_VALUE_%s;\r\n",\r |
306 | Token.getAutogendatumTypeString(parentToken.datumType),\r |
307 | parentToken.cName,\r |
308 | parentToken.cName);\r |
309 | }\r |
2435723a |
310 | } else {\r |
11eb278a |
311 | //\r |
312 | // Example autogen string for following generation:\r |
313 | // "#define _PCD_VALUE_PcdSampleToken 0x222"\r |
314 | // \r |
bc262841 |
315 | hAutogenStr += String.format("#define _PCD_VALUE_%s %s\r\n",\r |
316 | parentToken.cName,\r |
9efa2da0 |
317 | printDatum);\r |
11eb278a |
318 | //\r |
319 | // Example autogen string for following generation:\r |
320 | // "GLOBAL_REMOVE_IF_UNREFERENCED const UINT8 _gPcd_FixedAtBuild_PcdSampleToken[] = _PCD_VALUE_PcdSampleToken;"\r |
321 | // \r |
2435723a |
322 | cAutogenStr += String.format("GLOBAL_REMOVE_IF_UNREFERENCED const %s _gPcd_FixedAtBuild_%s = _PCD_VALUE_%s;\r\n",\r |
323 | Token.getAutogendatumTypeString(parentToken.datumType),\r |
324 | parentToken.cName,\r |
325 | parentToken.cName);\r |
2435723a |
326 | }\r |
38ee8d9e |
327 | }\r |
328 | break;\r |
329 | case PATCHABLE_IN_MODULE:\r |
a3222f6a |
330 | if (parentToken.datumType == Token.DATUM_TYPE.POINTER) {\r |
11eb278a |
331 | //\r |
332 | // Example autogen string for following generation:\r |
333 | // "extern UINT8 _gPcd_BinaryPatch_PcdSampleToken[];"\r |
334 | // \r |
16d3e132 |
335 | hAutogenStr += String.format("extern UINT8 _gPcd_BinaryPatch_%s[];\r\n",\r |
336 | parentToken.cName);\r |
11eb278a |
337 | //\r |
338 | // Example autogen string for following generation:\r |
339 | // "#define _PCD_GET_MODE_8_PcdSampleToken (VOID*)_gPcd_BinaryPatch_PcdSampleToken"\r |
340 | // \r |
57a38e69 |
341 | hAutogenStr += String.format("#define _PCD_GET_MODE_%s_%s (VOID*)_gPcd_BinaryPatch_%s\r\n",\r |
16d3e132 |
342 | Token.GetAutogenDefinedatumTypeString(parentToken.datumType),\r |
343 | parentToken.cName,\r |
bc262841 |
344 | parentToken.cName);\r |
a3222f6a |
345 | //\r |
346 | // Example autogen string for following generation:\r |
347 | // "#define _PCD_SET_MODE_8_PcdSampleToken(SizeOfBuffer, Buffer) CopyMem (_gPcd_BinaryPatch_PcdSampleToken, (Buffer), (SizeOfBuffer))"\r |
348 | // \r |
349 | hAutogenStr += String.format("#define _PCD_PATCHABLE_%s_SIZE %d\r\n",\r |
350 | parentToken.cName,\r |
351 | parentToken.datumSize);\r |
352 | hAutogenStr += String.format("#define _PCD_SET_MODE_%s_%s(SizeOfBuffer, Buffer) "+\r |
353 | "LibPatchPcdSetPtr (_gPcd_BinaryPatch_%s, (UINTN)_PCD_PATCHABLE_%s_SIZE, "+\r |
354 | "(SizeOfBuffer), (Buffer))\r\n",\r |
355 | Token.GetAutogenDefinedatumTypeString(parentToken.datumType),\r |
356 | parentToken.cName,\r |
357 | parentToken.cName,\r |
358 | parentToken.cName);\r |
359 | \r |
16d3e132 |
360 | } else {\r |
11eb278a |
361 | //\r |
362 | // Example autogen string for following generation:\r |
363 | // "extern UINT8 _gPcd_BinaryPatch_PcdSampleToken;"\r |
364 | // \r |
38ee8d9e |
365 | hAutogenStr += String.format("extern %s _gPcd_BinaryPatch_%s;\r\n",\r |
366 | Token.getAutogendatumTypeString(parentToken.datumType),\r |
367 | parentToken.cName);\r |
11eb278a |
368 | //\r |
369 | // Example autogen string for following generation:\r |
370 | // "#define _PCD_GET_MODE_8_PcdSampleToken _gPcd_BinaryPatch_PcdSampleToken"\r |
371 | // \r |
57a38e69 |
372 | hAutogenStr += String.format("#define _PCD_GET_MODE_%s_%s _gPcd_BinaryPatch_%s\r\n",\r |
38ee8d9e |
373 | Token.GetAutogenDefinedatumTypeString(parentToken.datumType),\r |
374 | parentToken.cName,\r |
bc262841 |
375 | parentToken.cName);\r |
11eb278a |
376 | //\r |
377 | // Example autogen string for following generation:\r |
378 | // "#define _PCD_SET_MODE_8_PcdSampleToken(Value) (_gPcd_BinaryPatch_PcdSampleToken = (Value))"\r |
379 | // \r |
57a38e69 |
380 | hAutogenStr += String.format("#define _PCD_SET_MODE_%s_%s(Value) (_gPcd_BinaryPatch_%s = (Value))\r\n",\r |
381 | Token.GetAutogenDefinedatumTypeString(parentToken.datumType),\r |
382 | parentToken.cName,\r |
383 | parentToken.cName);\r |
384 | }\r |
bc262841 |
385 | \r |
16d3e132 |
386 | if (!isBuildUsedLibrary) {\r |
a3222f6a |
387 | if (parentToken.datumType == Token.DATUM_TYPE.POINTER) {\r |
388 | printDatum = parentToken.getByteArrayForPointerDatum(printDatum);\r |
389 | }\r |
11eb278a |
390 | //\r |
391 | // Example autogen string for following generation:\r |
392 | // "#define _PCD_VALUE_PcdSampleToken 0x111"\r |
393 | // \r |
bc262841 |
394 | hAutogenStr += String.format("#define _PCD_VALUE_%s %s\r\n",\r |
395 | parentToken.cName,\r |
1cf9cdcc |
396 | printDatum);\r |
a3222f6a |
397 | if (parentToken.datumType == Token.DATUM_TYPE.POINTER) {\r |
11eb278a |
398 | //\r |
399 | // Example autogen string for following generation:\r |
400 | // "GLOBAL_REMOVE_IF_UNREFERENCED UINT8 _gPcd_BinaryPatch_PcdSampleToken[] = _PCD_VALUE_PcdSampleToken;"\r |
401 | // \r |
70855975 |
402 | cAutogenStr += String.format("GLOBAL_REMOVE_IF_UNREFERENCED UINT8 _gPcd_BinaryPatch_%s[%d] = _PCD_VALUE_%s;\r\n",\r |
2435723a |
403 | parentToken.cName,\r |
70855975 |
404 | parentToken.datumSize,\r |
2435723a |
405 | parentToken.cName);\r |
2435723a |
406 | } else {\r |
11eb278a |
407 | //\r |
408 | // Example autogen string for following generation:\r |
409 | // "GLOBAL_REMOVE_IF_UNREFERENCED UINT8 _gPcd_BinaryPatch_PcdSampleToken[] = _PCD_VALUE_PcdSampleToken;"\r |
410 | // \r |
2435723a |
411 | cAutogenStr += String.format("GLOBAL_REMOVE_IF_UNREFERENCED %s _gPcd_BinaryPatch_%s = _PCD_VALUE_%s;\r\n",\r |
412 | Token.getAutogendatumTypeString(parentToken.datumType),\r |
413 | parentToken.cName,\r |
414 | parentToken.cName);\r |
2435723a |
415 | }\r |
38ee8d9e |
416 | }\r |
417 | \r |
418 | break;\r |
419 | case DYNAMIC:\r |
11eb278a |
420 | //\r |
421 | // Example autogen string for following generation:\r |
422 | // "#define _PCD_GET_MODE_8_PcdSampleToken LibPcdGet%s(_PCD_TOKEN_PcdSampleToken)"\r |
423 | // \r |
57a38e69 |
424 | hAutogenStr += String.format("#define _PCD_GET_MODE_%s_%s LibPcdGet%s(_PCD_TOKEN_%s)\r\n",\r |
38ee8d9e |
425 | Token.GetAutogenDefinedatumTypeString(parentToken.datumType),\r |
426 | parentToken.cName,\r |
427 | Token.getAutogenLibrarydatumTypeString(parentToken.datumType),\r |
428 | parentToken.cName);\r |
57a38e69 |
429 | if (parentToken.datumType == Token.DATUM_TYPE.POINTER) {\r |
11eb278a |
430 | //\r |
431 | // Example autogen string for following generation:\r |
432 | // "#define _PCD_SET_MODE_8_PcdSampleToken(SizeOfBuffer, Buffer) LibPcdSet%s(_PCD_TOKEN_PcdSampleToken, (SizeOfBuffer), (Buffer))"\r |
433 | // \r |
57a38e69 |
434 | hAutogenStr += String.format("#define _PCD_SET_MODE_%s_%s(SizeOfBuffer, Buffer) LibPcdSet%s(_PCD_TOKEN_%s, (SizeOfBuffer), (Buffer))\r\n",\r |
435 | Token.GetAutogenDefinedatumTypeString(parentToken.datumType),\r |
436 | parentToken.cName,\r |
437 | Token.getAutogenLibrarydatumTypeString(parentToken.datumType),\r |
438 | parentToken.cName);\r |
439 | } else {\r |
11eb278a |
440 | //\r |
441 | // Example autogen string for following generation:\r |
442 | // "#define _PCD_SET_MODE_8_PcdSampleToken(Value) LibPcdSet%s(_PCD_TOKEN_PcdSampleToken, (Value))"\r |
443 | // \r |
57a38e69 |
444 | hAutogenStr += String.format("#define _PCD_SET_MODE_%s_%s(Value) LibPcdSet%s(_PCD_TOKEN_%s, (Value))\r\n",\r |
445 | Token.GetAutogenDefinedatumTypeString(parentToken.datumType),\r |
446 | parentToken.cName,\r |
447 | Token.getAutogenLibrarydatumTypeString(parentToken.datumType),\r |
448 | parentToken.cName);\r |
449 | }\r |
38ee8d9e |
450 | break;\r |
451 | case DYNAMIC_EX:\r |
11e7b0f6 |
452 | guidStringCName = "_gPcd_TokenSpaceGuid_" +\r |
453 | parentToken.tokenSpaceName.toString().replaceAll("-", "_");\r |
57a38e69 |
454 | \r |
11eb278a |
455 | //\r |
456 | // Example autogen string for following generation:\r |
457 | // "#define _PCD_GET_MODE_8_PcdSampleToken LibPcdGetEx%s(&_gPcd_TokenSpaceGuid_00_00_00, _PCD_TOKEN_PcdSampleToken)"\r |
458 | // \r |
57a38e69 |
459 | hAutogenStr += String.format("#define _PCD_GET_MODE_%s_%s LibPcdGetEx%s(&%s, _PCD_TOKEN_%s)\r\n",\r |
38ee8d9e |
460 | Token.GetAutogenDefinedatumTypeString(parentToken.datumType),\r |
461 | parentToken.cName,\r |
462 | Token.getAutogenLibrarydatumTypeString(parentToken.datumType),\r |
a49b34c0 |
463 | guidStringCName,\r |
38ee8d9e |
464 | parentToken.cName);\r |
465 | \r |
57a38e69 |
466 | if (parentToken.datumType == Token.DATUM_TYPE.POINTER) {\r |
11eb278a |
467 | //\r |
468 | // Example autogen string for following generation:\r |
469 | // "#define _PCD_SET_MODE_8_PcdSampleToken(SizeOfBuffer, Buffer) LibPcdSetEx%s(&_gPcd_TokenSpaceGuid_00_00_00, _PCD_TOKEN_PcdSampleToken, (SizeOfBuffer), (Buffer))"\r |
470 | // \r |
57a38e69 |
471 | hAutogenStr += String.format("#define _PCD_SET_MODE_%s_%s(SizeOfBuffer, Buffer) LibPcdSetEx%s(&%s, _PCD_TOKEN_%s, (SizeOfBuffer), (Buffer))\r\n",\r |
472 | Token.GetAutogenDefinedatumTypeString(parentToken.datumType),\r |
473 | parentToken.cName,\r |
474 | Token.getAutogenLibrarydatumTypeString(parentToken.datumType),\r |
475 | guidStringCName,\r |
476 | parentToken.cName);\r |
477 | } else {\r |
11eb278a |
478 | //\r |
479 | // Example autogen string for following generation:\r |
480 | // "#define _PCD_SET_MODE_8_PcdSampleToken(Value) LibPcdSetEx%s(&_gPcd_TokenSpaceGuid_00_00_00, _PCD_TOKEN_PcdSampleToken, (Value))"\r |
481 | //\r |
57a38e69 |
482 | hAutogenStr += String.format("#define _PCD_SET_MODE_%s_%s(Value) LibPcdSetEx%s(&%s, _PCD_TOKEN_%s, (Value))\r\n",\r |
483 | Token.GetAutogenDefinedatumTypeString(parentToken.datumType),\r |
484 | parentToken.cName,\r |
485 | Token.getAutogenLibrarydatumTypeString(parentToken.datumType),\r |
486 | guidStringCName,\r |
487 | parentToken.cName);\r |
488 | \r |
489 | }\r |
38ee8d9e |
490 | break;\r |
491 | }\r |
492 | }\r |
493 | \r |
494 | /**\r |
495 | Get the autogen string for header file.\r |
bc262841 |
496 | \r |
38ee8d9e |
497 | @return The string of header file.\r |
498 | **/\r |
499 | public String getHAutogenStr() {\r |
500 | return hAutogenStr;\r |
501 | }\r |
878ddf1f |
502 | \r |
38ee8d9e |
503 | /**\r |
504 | Get the autogen string for C code file.\r |
bc262841 |
505 | \r |
38ee8d9e |
506 | @return The string of C Code file.\r |
507 | **/\r |
508 | public String getCAutogenStr() {\r |
509 | return cAutogenStr;\r |
878ddf1f |
510 | }\r |
878ddf1f |
511 | }\r |
512 | \r |