Re: Token values are not produced for PCDs under 'PcdsDynamic' section

Guomin Jiang


This should be compiled into PCD PEIMs and PCD DXE Drivers.

It will be contained by firmware eventually.

It seem that you haven’t changed the firmware, so the firmware can’t get the value and freeze.

From: <> On Behalf Of Konstantin Aladyshev
Sent: Tuesday, June 29, 2021 1:00 AM
Subject: [edk2-discuss] Token values are not produced for PCDs under 'PcdsDynamic' section


I'm trying to understand dynamic PCDs in EDK2.

I've added this code to my package DEC file:
And have added this code to my app INF file:

I'm trying to use PCD in my application like this:
Print(L"PcdMyDynamicVar32=%d\n", PcdGet32(PcdMyDynamicVar32));
PcdSet32S(PcdMyDynamicVar32, 52);
Print(L"PcdMyDynamicVar32=%d\n", PcdGet32(PcdMyDynamicVar32));

But when I try to compile, the token number is not populated to the AutoGen.h:
#define _PCD_TOKEN_PcdMyDynamicVar32 0U
#define _PCD_GET_MODE_32_PcdMyDynamicVar32 LibPcdGet32(_PCD_TOKEN_PcdMyDynamicVar32)
#define _PCD_GET_MODE_SIZE_PcdMyDynamicVar32 LibPcdGetSize(_PCD_TOKEN_PcdMyDynamicVar32)
#define _PCD_SET_MODE_32_PcdMyDynamicVar32(Value) LibPcdSet32(_PCD_TOKEN_PcdMyDynamicVar32, (Value))
#define _PCD_SET_MODE_32_S_PcdMyDynamicVar32(Value) LibPcdSet32S(_PCD_TOKEN_PcdMyDynamicVar32, (Value))
Because of that I get 0 in the first `PcdGet32` call and my application freezes at the `PcdSet32S` call.

But if I change `[PcdsDynamic]` to [PcdsDynamicEx] in my package DEC file token value will be populated:
#define _PCD_TOKEN_gMyPkgTokenSpaceGuid_PcdMyDynamicVar32 1073741828U
#define _PCD_TOKEN_PcdMyDynamicVar32 _PCD_TOKEN_gMyPkgTokenSpaceGuid_PcdMyDynamicVar32
#define _PCD_GET_MODE_32_PcdMyDynamicVar32 LibPcdGetEx32(&gMyPkgTokenSpaceGuid, _PCD_TOKEN_PcdMyDynamicVar32)
#define _PCD_GET_MODE_SIZE_PcdMyDynamicVar32 LibPcdGetExSize(&gMyPkgTokenSpaceGuid, _PCD_TOKEN_PcdMyDynamicVar32)
#define _PCD_SET_MODE_32_PcdMyDynamicVar32(Value) LibPcdSetEx32(&gMyPkgTokenSpaceGuid, _PCD_TOKEN_PcdMyDynamicVar32, (Value))
#define _PCD_SET_MODE_32_S_PcdMyDynamicVar32(Value) LibPcdSetEx32S(&gMyPkgTokenSpaceGuid, _PCD_TOKEN_PcdMyDynamicVar32, (Value))

What is my mistake? Why is the token value not populated when `[PcdsDynamic]` is used?

Best regards,
Konstantin Aladyshev

Join to automatically receive all group messages.