]>
Commit | Line | Data |
---|---|---|
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 | |
16d3e132 | 330 | if (isByteArray) {\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 |
16d3e132 | 345 | } else {\r |
11eb278a | 346 | //\r |
347 | // Example autogen string for following generation:\r | |
348 | // "extern UINT8 _gPcd_BinaryPatch_PcdSampleToken;"\r | |
349 | // \r | |
38ee8d9e | 350 | hAutogenStr += String.format("extern %s _gPcd_BinaryPatch_%s;\r\n",\r |
351 | Token.getAutogendatumTypeString(parentToken.datumType),\r | |
352 | parentToken.cName);\r | |
11eb278a | 353 | //\r |
354 | // Example autogen string for following generation:\r | |
355 | // "#define _PCD_GET_MODE_8_PcdSampleToken _gPcd_BinaryPatch_PcdSampleToken"\r | |
356 | // \r | |
57a38e69 | 357 | hAutogenStr += String.format("#define _PCD_GET_MODE_%s_%s _gPcd_BinaryPatch_%s\r\n",\r |
38ee8d9e | 358 | Token.GetAutogenDefinedatumTypeString(parentToken.datumType),\r |
359 | parentToken.cName,\r | |
bc262841 | 360 | parentToken.cName);\r |
16d3e132 | 361 | }\r |
362 | \r | |
57a38e69 | 363 | //\r |
364 | // Generate _PCD_SET_MODE_xx macro for using set BinaryPatch value via PcdSet macro\r | |
bc262841 | 365 | //\r |
57a38e69 | 366 | if (parentToken.datumType == Token.DATUM_TYPE.POINTER) {\r |
11eb278a | 367 | //\r |
368 | // Example autogen string for following generation:\r | |
369 | // "#define _PCD_SET_MODE_8_PcdSampleToken(SizeOfBuffer, Buffer) CopyMem (_gPcd_BinaryPatch_PcdSampleToken, (Buffer), (SizeOfBuffer))"\r | |
370 | // \r | |
70855975 | 371 | hAutogenStr += String.format("#define _PCD_PATCHABLE_%s_SIZE %d\r\n",\r |
372 | parentToken.cName,\r | |
373 | parentToken.datumSize);\r | |
374 | hAutogenStr += String.format("#define _PCD_SET_MODE_%s_%s(SizeOfBuffer, Buffer) "+\r | |
375 | "LibPatchPcdSetPtr (_gPcd_BinaryPatch_%s, (UINTN)_PCD_PATCHABLE_%s_SIZE, "+\r | |
376 | "(SizeOfBuffer), (Buffer))\r\n",\r | |
57a38e69 | 377 | Token.GetAutogenDefinedatumTypeString(parentToken.datumType),\r |
378 | parentToken.cName,\r | |
70855975 | 379 | parentToken.cName,\r |
57a38e69 | 380 | parentToken.cName);\r |
381 | } else {\r | |
11eb278a | 382 | //\r |
383 | // Example autogen string for following generation:\r | |
384 | // "#define _PCD_SET_MODE_8_PcdSampleToken(Value) (_gPcd_BinaryPatch_PcdSampleToken = (Value))"\r | |
385 | // \r | |
57a38e69 | 386 | hAutogenStr += String.format("#define _PCD_SET_MODE_%s_%s(Value) (_gPcd_BinaryPatch_%s = (Value))\r\n",\r |
387 | Token.GetAutogenDefinedatumTypeString(parentToken.datumType),\r | |
388 | parentToken.cName,\r | |
389 | parentToken.cName);\r | |
390 | }\r | |
bc262841 | 391 | \r |
16d3e132 | 392 | if (!isBuildUsedLibrary) {\r |
11eb278a | 393 | //\r |
394 | // Example autogen string for following generation:\r | |
395 | // "#define _PCD_VALUE_PcdSampleToken 0x111"\r | |
396 | // \r | |
bc262841 | 397 | hAutogenStr += String.format("#define _PCD_VALUE_%s %s\r\n",\r |
398 | parentToken.cName,\r | |
1cf9cdcc | 399 | printDatum);\r |
2435723a | 400 | if (isByteArray) {\r |
11eb278a | 401 | //\r |
402 | // Example autogen string for following generation:\r | |
403 | // "GLOBAL_REMOVE_IF_UNREFERENCED UINT8 _gPcd_BinaryPatch_PcdSampleToken[] = _PCD_VALUE_PcdSampleToken;"\r | |
404 | // \r | |
70855975 | 405 | cAutogenStr += String.format("GLOBAL_REMOVE_IF_UNREFERENCED UINT8 _gPcd_BinaryPatch_%s[%d] = _PCD_VALUE_%s;\r\n",\r |
2435723a | 406 | parentToken.cName,\r |
70855975 | 407 | parentToken.datumSize,\r |
2435723a | 408 | parentToken.cName);\r |
2435723a | 409 | } else {\r |
11eb278a | 410 | //\r |
411 | // Example autogen string for following generation:\r | |
412 | // "GLOBAL_REMOVE_IF_UNREFERENCED UINT8 _gPcd_BinaryPatch_PcdSampleToken[] = _PCD_VALUE_PcdSampleToken;"\r | |
413 | // \r | |
2435723a | 414 | cAutogenStr += String.format("GLOBAL_REMOVE_IF_UNREFERENCED %s _gPcd_BinaryPatch_%s = _PCD_VALUE_%s;\r\n",\r |
415 | Token.getAutogendatumTypeString(parentToken.datumType),\r | |
416 | parentToken.cName,\r | |
417 | parentToken.cName);\r | |
2435723a | 418 | }\r |
38ee8d9e | 419 | }\r |
420 | \r | |
421 | break;\r | |
422 | case DYNAMIC:\r | |
11eb278a | 423 | //\r |
424 | // Example autogen string for following generation:\r | |
425 | // "#define _PCD_GET_MODE_8_PcdSampleToken LibPcdGet%s(_PCD_TOKEN_PcdSampleToken)"\r | |
426 | // \r | |
57a38e69 | 427 | hAutogenStr += String.format("#define _PCD_GET_MODE_%s_%s LibPcdGet%s(_PCD_TOKEN_%s)\r\n",\r |
38ee8d9e | 428 | Token.GetAutogenDefinedatumTypeString(parentToken.datumType),\r |
429 | parentToken.cName,\r | |
430 | Token.getAutogenLibrarydatumTypeString(parentToken.datumType),\r | |
431 | parentToken.cName);\r | |
57a38e69 | 432 | if (parentToken.datumType == Token.DATUM_TYPE.POINTER) {\r |
11eb278a | 433 | //\r |
434 | // Example autogen string for following generation:\r | |
435 | // "#define _PCD_SET_MODE_8_PcdSampleToken(SizeOfBuffer, Buffer) LibPcdSet%s(_PCD_TOKEN_PcdSampleToken, (SizeOfBuffer), (Buffer))"\r | |
436 | // \r | |
57a38e69 | 437 | hAutogenStr += String.format("#define _PCD_SET_MODE_%s_%s(SizeOfBuffer, Buffer) LibPcdSet%s(_PCD_TOKEN_%s, (SizeOfBuffer), (Buffer))\r\n",\r |
438 | Token.GetAutogenDefinedatumTypeString(parentToken.datumType),\r | |
439 | parentToken.cName,\r | |
440 | Token.getAutogenLibrarydatumTypeString(parentToken.datumType),\r | |
441 | parentToken.cName);\r | |
442 | } else {\r | |
11eb278a | 443 | //\r |
444 | // Example autogen string for following generation:\r | |
445 | // "#define _PCD_SET_MODE_8_PcdSampleToken(Value) LibPcdSet%s(_PCD_TOKEN_PcdSampleToken, (Value))"\r | |
446 | // \r | |
57a38e69 | 447 | hAutogenStr += String.format("#define _PCD_SET_MODE_%s_%s(Value) LibPcdSet%s(_PCD_TOKEN_%s, (Value))\r\n",\r |
448 | Token.GetAutogenDefinedatumTypeString(parentToken.datumType),\r | |
449 | parentToken.cName,\r | |
450 | Token.getAutogenLibrarydatumTypeString(parentToken.datumType),\r | |
451 | parentToken.cName);\r | |
452 | }\r | |
38ee8d9e | 453 | break;\r |
454 | case DYNAMIC_EX:\r | |
11e7b0f6 | 455 | guidStringCName = "_gPcd_TokenSpaceGuid_" +\r |
456 | parentToken.tokenSpaceName.toString().replaceAll("-", "_");\r | |
57a38e69 | 457 | \r |
11eb278a | 458 | //\r |
459 | // Example autogen string for following generation:\r | |
460 | // "#define _PCD_GET_MODE_8_PcdSampleToken LibPcdGetEx%s(&_gPcd_TokenSpaceGuid_00_00_00, _PCD_TOKEN_PcdSampleToken)"\r | |
461 | // \r | |
57a38e69 | 462 | hAutogenStr += String.format("#define _PCD_GET_MODE_%s_%s LibPcdGetEx%s(&%s, _PCD_TOKEN_%s)\r\n",\r |
38ee8d9e | 463 | Token.GetAutogenDefinedatumTypeString(parentToken.datumType),\r |
464 | parentToken.cName,\r | |
465 | Token.getAutogenLibrarydatumTypeString(parentToken.datumType),\r | |
a49b34c0 | 466 | guidStringCName,\r |
38ee8d9e | 467 | parentToken.cName);\r |
468 | \r | |
57a38e69 | 469 | if (parentToken.datumType == Token.DATUM_TYPE.POINTER) {\r |
11eb278a | 470 | //\r |
471 | // Example autogen string for following generation:\r | |
472 | // "#define _PCD_SET_MODE_8_PcdSampleToken(SizeOfBuffer, Buffer) LibPcdSetEx%s(&_gPcd_TokenSpaceGuid_00_00_00, _PCD_TOKEN_PcdSampleToken, (SizeOfBuffer), (Buffer))"\r | |
473 | // \r | |
57a38e69 | 474 | hAutogenStr += String.format("#define _PCD_SET_MODE_%s_%s(SizeOfBuffer, Buffer) LibPcdSetEx%s(&%s, _PCD_TOKEN_%s, (SizeOfBuffer), (Buffer))\r\n",\r |
475 | Token.GetAutogenDefinedatumTypeString(parentToken.datumType),\r | |
476 | parentToken.cName,\r | |
477 | Token.getAutogenLibrarydatumTypeString(parentToken.datumType),\r | |
478 | guidStringCName,\r | |
479 | parentToken.cName);\r | |
480 | } else {\r | |
11eb278a | 481 | //\r |
482 | // Example autogen string for following generation:\r | |
483 | // "#define _PCD_SET_MODE_8_PcdSampleToken(Value) LibPcdSetEx%s(&_gPcd_TokenSpaceGuid_00_00_00, _PCD_TOKEN_PcdSampleToken, (Value))"\r | |
484 | //\r | |
57a38e69 | 485 | hAutogenStr += String.format("#define _PCD_SET_MODE_%s_%s(Value) LibPcdSetEx%s(&%s, _PCD_TOKEN_%s, (Value))\r\n",\r |
486 | Token.GetAutogenDefinedatumTypeString(parentToken.datumType),\r | |
487 | parentToken.cName,\r | |
488 | Token.getAutogenLibrarydatumTypeString(parentToken.datumType),\r | |
489 | guidStringCName,\r | |
490 | parentToken.cName);\r | |
491 | \r | |
492 | }\r | |
38ee8d9e | 493 | break;\r |
494 | }\r | |
495 | }\r | |
496 | \r | |
497 | /**\r | |
498 | Get the autogen string for header file.\r | |
bc262841 | 499 | \r |
38ee8d9e | 500 | @return The string of header file.\r |
501 | **/\r | |
502 | public String getHAutogenStr() {\r | |
503 | return hAutogenStr;\r | |
504 | }\r | |
878ddf1f | 505 | \r |
38ee8d9e | 506 | /**\r |
507 | Get the autogen string for C code file.\r | |
bc262841 | 508 | \r |
38ee8d9e | 509 | @return The string of C Code file.\r |
510 | **/\r | |
511 | public String getCAutogenStr() {\r | |
512 | return cAutogenStr;\r | |
878ddf1f | 513 | }\r |
878ddf1f | 514 | }\r |
515 | \r |