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

Konstantin Aladyshev

Sorry, I didn't understand your answer. Could you please elaborate it for me.

I'm trying to write `UEFI_APPLICATION` and test its execution in UEFI
Shell in QEMU running OVMF.
I also use `DxePcdLib` as PcdLib in my package DSC file:
In this library LibPcdGet32 is translate to:
LibPcdGet32 (
IN UINTN TokenNumber
return GetPcdProtocol()->Get32 (TokenNumber);
So the correct `TokenNumber` should be passed for this to work correctly.

But as I said Token for my variable is set to 0 for some reason in AutoGen.h:
#define _PCD_TOKEN_PcdMyDynamicVar32 0U

On Tue, Jun 29, 2021 at 12:25 PM Jiang, Guomin <> wrote:


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.