]>
git.proxmox.com Git - mirror_edk2.git/blob - Tools/Source/GenBuild/org/tianocore/build/pcd/entity/UsageInstance.java
4 This class indicate an usage instance for a PCD token. This instance maybe a module
5 or platform setting. When a module produce or cosume a PCD token, then this module
6 is an usage instance for this PCD token.
8 Copyright (c) 2006, Intel Corporation
9 All rights reserved. This program and the accompanying materials
10 are licensed and made available under the terms and conditions of the BSD License
11 which accompanies this distribution. The full text of the license may be found at
12 http://opensource.org/licenses/bsd-license.php
14 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
15 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
18 package org
.tianocore
.build
.pcd
.entity
;
21 import java
.util
.UUID
;
23 import org
.tianocore
.build
.autogen
.CommonDefinition
;
24 import org
.tianocore
.build
.pcd
.action
.ActionMessage
;
25 import org
.tianocore
.build
.pcd
.exception
.EntityException
;
28 This class indicate an usage instance for a PCD token. This instance maybe a module
29 or platform setting. When a module produce or cosume a PCD token, then this module
30 is an usage instance for this PCD token.
32 public class UsageInstance
{
34 /// The module type of usage instance.
36 public enum MODULE_TYPE
{SEC
, PEI_CORE
, PEIM
, DXE_CORE
, DXE_DRIVERS
, OTHER_COMPONENTS
}
38 /// This parent that this usage instance belongs to.
40 public Token parentToken
;
42 /// The name of the module who contains this PCD.
44 public String moduleName
;
46 /// The GUID of the module who contains this PCD.
48 public UUID moduleGUID
;
50 /// The name of the package whose module contains this PCD.
52 public String packageName
;
54 /// The GUID of the package whose module contains this PCD.
56 public UUID packageGUID
;
58 /// The PCD type defined for module
60 public Token
.PCD_TYPE modulePcdType
;
62 /// The arch string of module contains this PCD
66 /// The version of module contains this PCD
68 public String version
;
70 /// The module type for this usage instance.
72 public MODULE_TYPE moduleType
;
74 /// The value of the PCD in this usage instance.
78 /// Autogen string for header file.
80 public String hAutogenStr
;
82 * Auotgen string for C code file.
84 public String cAutogenStr
;
89 @param parentToken Member variable.
90 @param pcdType Member variable.
91 @param moduleName Member variable.
92 @param moduleGUID Member variable.
93 @param packageName Member variable.
94 @param packageGUID Member variable.
95 @param moduleType Member variable.
96 @param modulePcdType Member variable.
97 @param arch Member variable.
98 @param version Member variable.
99 @param value Member variable.
101 public UsageInstance (Token parentToken
,
102 Token
.PCD_TYPE pcdType
,
107 MODULE_TYPE moduleType
,
108 Token
.PCD_TYPE modulePcdType
,
112 this.parentToken
= parentToken
;
113 this.moduleName
= moduleName
;
114 this.moduleGUID
= moduleGUID
;
115 this.packageName
= packageName
;
116 this.packageGUID
= packageGUID
;
117 this.moduleType
= moduleType
;
118 this.modulePcdType
= modulePcdType
;
120 this.version
= version
;
122 this.modulePcdType
= pcdType
;
126 Get the primary key for usage instance array for every token.
128 @param moduleName the name of module
129 @param moduleGUID the GUID name of module
130 @param packageName the name of package who contains this module
131 @param packageGUID the GUID name of package
132 @param arch the archtecture string
133 @param version the version of this module
135 @return String primary key
137 public static String
getPrimaryKey(String moduleName
,
144 // Because currently transition schema not require write moduleGuid, package Name, Packge GUID in
145 // <ModuleSA> section, So currently no expect all paramter must be valid.
146 return (moduleName
+ "_" +
147 ((moduleGUID
!= null) ? moduleGUID
.toString() : "NullModuleGuid") + "_" +
148 ((packageName
!= null) ? packageName
: "NullPackageName") + "_" +
149 ((packageGUID
!= null) ? packageGUID
.toString() : "NullPackageGuid") + "_" +
150 ((arch
!= null) ? arch
: "NullArch") + "_" +
151 ((version
!= null) ? version
: "NullVersion"));
155 Get primary key string for this usage instance
157 @return String primary key string
159 public String
getPrimaryKey() {
160 return UsageInstance
.getPrimaryKey(moduleName
, moduleGUID
, packageName
, packageGUID
, arch
, version
);
164 Judget whether current module is PEI driver
168 public boolean isPeiPhaseComponent() {
169 if ((moduleType
== MODULE_TYPE
.PEI_CORE
) ||
170 (moduleType
== MODULE_TYPE
.PEIM
)) {
177 Generate autogen string for header file and C code file.
179 @throws EntityException Fail to generate.
181 @param isBuildUsedLibrary whether the autogen is for library.
183 public void generateAutoGen(boolean isBuildUsedLibrary
)
184 throws EntityException
{
189 hAutogenStr
+= String
.format("#define _PCD_TOKEN_%s 0x%016x\r\n",
190 parentToken
.cName
, parentToken
.tokenNumber
);
191 switch(modulePcdType
) {
193 if(isBuildUsedLibrary
) {
194 hAutogenStr
+= String
.format("extern const BOOLEAN _gPcd_FixedAtBuild_%s;\r\n",
196 hAutogenStr
+= String
.format("#define _PCD_MODE_%s_%s _gPcd_FixedAtBuild_%s\r\n",
197 parentToken
.GetAutogenDefinedatumTypeString(parentToken
.datumType
),
201 hAutogenStr
+= String
.format("#define _PCD_VALUE_%s %s\r\n",
204 hAutogenStr
+= String
.format("extern const BOOLEAN _gPcd_FixedAtBuild_%s;\r\n",
206 cAutogenStr
+= String
.format("GLOBAL_REMOVE_IF_UNREFERENCED const BOOLEAN _gPcd_FixedAtBuild_%s = _PCD_VALUE_%s;\r\n",
209 hAutogenStr
+= String
.format("#define _PCD_MODE_%s_%s _PCD_VALUE_%s\r\n",
210 Token
.GetAutogenDefinedatumTypeString(parentToken
.datumType
),
216 if(isBuildUsedLibrary
) {
217 hAutogenStr
+= String
.format("extern const %s _gPcd_FixedAtBuild_%s;\r\n",
218 Token
.getAutogendatumTypeString(parentToken
.datumType
),
220 hAutogenStr
+= String
.format("#define _PCD_MODE_%s_%s _gPcd_FixedAtBuild_%s\r\n",
221 Token
.GetAutogenDefinedatumTypeString(parentToken
.datumType
),
225 hAutogenStr
+= String
.format("#define _PCD_VALUE_%s %s\r\n",
228 hAutogenStr
+= String
.format("extern const %s _gPcd_FixedAtBuild_%s;\r\n",
229 Token
.getAutogendatumTypeString(parentToken
.datumType
),
231 cAutogenStr
+= String
.format("GLOBAL_REMOVE_IF_UNREFERENCED const %s _gPcd_FixedAtBuild_%s = _PCD_VALUE_%s;\r\n",
232 Token
.getAutogendatumTypeString(parentToken
.datumType
),
235 hAutogenStr
+= String
.format("#define _PCD_MODE_%s_%s _PCD_VALUE_%s\r\n",
236 Token
.GetAutogenDefinedatumTypeString(parentToken
.datumType
),
241 case PATCHABLE_IN_MODULE
:
242 if(isBuildUsedLibrary
) {
243 hAutogenStr
+= String
.format("extern %s _gPcd_BinaryPatch_%s;\r\n",
244 Token
.getAutogendatumTypeString(parentToken
.datumType
),
246 hAutogenStr
+= String
.format("#define _PCD_MODE_%s_%s _gPcd_BinaryPatch_%s\r\n",
247 Token
.GetAutogenDefinedatumTypeString(parentToken
.datumType
),
251 hAutogenStr
+= String
.format("#define _PCD_VALUE_%s %s\r\n",
254 hAutogenStr
+= String
.format("extern %s _gPcd_BinaryPatch_%s;\r\n",
255 Token
.getAutogendatumTypeString(parentToken
.datumType
),
257 cAutogenStr
+= String
.format("GLOBAL_REMOVE_IF_UNREFERENCED %s _gPcd_BinaryPatch_%s = _PCD_VALUE_%s;\r\n",
258 Token
.getAutogendatumTypeString(parentToken
.datumType
),
261 hAutogenStr
+= String
.format("#define _PCD_MODE_%s_%s _gPcd_BinaryPatch_%s\r\n",
262 Token
.GetAutogenDefinedatumTypeString(parentToken
.datumType
),
269 switch(parentToken
.pcdType
) {
271 if(isBuildUsedLibrary
) {
272 hAutogenStr
+= String
.format("extern const BOOLEAN _gPcd_FixedAtBuild_%s;\r\n",
274 hAutogenStr
+= String
.format("#define _PCD_MODE_%s_%s _gPcd_FixedAtBuild_%s\r\n",
275 Token
.GetAutogenDefinedatumTypeString(parentToken
.datumType
),
279 hAutogenStr
+= String
.format("#define _PCD_VALUE_%s %s\r\n",
282 hAutogenStr
+= String
.format("extern const BOOLEAN _gPcd_FixedAtBuild_%s;\r\n",
284 cAutogenStr
+= String
.format("const BOOLEAN _gPcd_FixedAtBuild_%s = _PCD_VALUE_%s;\r\n",
287 hAutogenStr
+= String
.format("#define _PCD_MODE_%s_%s _PCD_VALUE_%s\r\n",
288 Token
.GetAutogenDefinedatumTypeString(parentToken
.datumType
),
294 if(isBuildUsedLibrary
) {
295 hAutogenStr
+= String
.format("extern const %s _gPcd_FixedAtBuild_%s;\r\n",
296 Token
.getAutogendatumTypeString(parentToken
.datumType
),
298 hAutogenStr
+= String
.format("#define _PCD_MODE_%s_%s _gPcd_FixedAtBuild_%s\r\n",
299 Token
.GetAutogenDefinedatumTypeString(parentToken
.datumType
),
304 hAutogenStr
+= String
.format("#define _PCD_VALUE_%s %s\r\n",
307 hAutogenStr
+= String
.format("extern const %s _gPcd_FixedAtBuild_%s\r\n",
308 Token
.getAutogendatumTypeString(parentToken
.datumType
),
310 cAutogenStr
+= String
.format("const %s _gPcd_FixedAtBuild_%s = _PCD_VALUE_%s;\r\n",
311 Token
.GetAutogenDefinedatumTypeString(parentToken
.datumType
),
314 hAutogenStr
+= String
.format("#define _PCD_MODE_%s_%s _PCD_VALUE_%s\r\n",
315 Token
.GetAutogenDefinedatumTypeString(parentToken
.datumType
),
320 case PATCHABLE_IN_MODULE
:
321 hAutogenStr
+= String
.format("#define _PCD_VALUE_%s %s\r\n",
324 hAutogenStr
+= String
.format("extern %s _gPcd_BinaryPatch_%s;\r\n",
325 Token
.getAutogendatumTypeString(parentToken
.datumType
),
328 cAutogenStr
+= String
.format("%s _gPcd_BinaryPatch_%s = _PCD_VALUE_%s;",
329 Token
.getAutogendatumTypeString(parentToken
.datumType
),
332 hAutogenStr
+= String
.format("#define _PCD_MODE_%s_%s _gPcd_BinaryPatch_%s\r\n",
333 Token
.GetAutogenDefinedatumTypeString(parentToken
.datumType
),
338 hAutogenStr
+= String
.format("#define _PCD_MODE_%s_%s LibPcdGet%s(_PCD_TOKEN_%s)\r\n",
339 Token
.GetAutogenDefinedatumTypeString(parentToken
.datumType
),
341 Token
.getAutogenLibrarydatumTypeString(parentToken
.datumType
),
345 throw new EntityException ("The PCD type is unknown");
354 Get the autogen string for header file.
356 @return The string of header file.
358 public String
getHAutogenStr() {
363 Get the autogen string for C code file.
365 @return The string of C Code file.
367 public String
getCAutogenStr() {