回复: [edk2-discuss] Difference between boolean PCD fixed at build and a PCD feature flag


gaoliming
 

Yes. Feature PCD is same to Boolean fixed at build PCD.



Thanks

Liming

发件人: discuss@edk2.groups.io <discuss@edk2.groups.io> 代表 Konstantin Aladyshev
发送时间: 2021年6月29日 4:46
收件人: discuss@edk2.groups.io
主题: [edk2-discuss] Difference between boolean PCD fixed at build and a PCD feature flag



What is the difference between boolean PCD fixed at build and a PCD feature flag?

```

[PcdsFixedAtBuild]
gMyPkgTokenSpaceGuid.PcdMyVarBool|FALSE|BOOLEAN|0x00000004

[PcdsFeatureFlag]
gMyPkgTokenSpaceGuid.PcdMyFeatureFlagVar|FALSE|BOOLEAN|0x20000001

```

I'm looking at the AutoGen files and the result from both of these PCDs is practically the same.



AutoGen.c
```
GLOBAL_REMOVE_IF_UNREFERENCED const BOOLEAN _gPcd_FixedAtBuild_PcdMyVarBool = _PCD_VALUE_PcdMyVarBool;
GLOBAL_REMOVE_IF_UNREFERENCED const BOOLEAN _gPcd_FixedAtBuild_PcdMyFeatureFlagVar = _PCD_VALUE_PcdMyFeatureFlagVar;
```
AutoGen.h
```
#define _PCD_TOKEN_PcdMyVarBool 0U
#define _PCD_SIZE_PcdMyVarBool 1
#define _PCD_GET_MODE_SIZE_PcdMyVarBool _PCD_SIZE_PcdMyVarBool
#define _PCD_VALUE_PcdMyVarBool 0U
extern const BOOLEAN _gPcd_FixedAtBuild_PcdMyVarBool;
#define _PCD_GET_MODE_BOOL_PcdMyVarBool _gPcd_FixedAtBuild_PcdMyVarBool
//#define _PCD_SET_MODE_BOOL_PcdMyVarBool ASSERT(FALSE) // It is not allowed to set value for a FIXED_AT_BUILD PCD

#define _PCD_TOKEN_PcdMyFeatureFlagVar 0U
#define _PCD_SIZE_PcdMyFeatureFlagVar 1
#define _PCD_GET_MODE_SIZE_PcdMyFeatureFlagVar _PCD_SIZE_PcdMyFeatureFlagVar
#define _PCD_VALUE_PcdMyFeatureFlagVar ((BOOLEAN)0U)
extern const BOOLEAN _gPcd_FixedAtBuild_PcdMyFeatureFlagVar;
#define _PCD_GET_MODE_BOOL_PcdMyFeatureFlagVar _gPcd_FixedAtBuild_PcdMyFeatureFlagVar
//#define _PCD_SET_MODE_BOOL_PcdMyFeatureFlagVar ASSERT(FALSE) // It is not allowed to set value for a FIXED_AT_BUILD PCD
```



Are there any actual differences between those two methods of defining a PCD? Or is `PcdsFeatureFlag` simply a syntactic sugar?

Join discuss@edk2.groups.io to automatically receive all group messages.