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


Konstantin Aladyshev
 

Thanks Guomin! I've managed to get PcdMyDynamicExVar32 working, but I still have troubles with PcdMyDynamicVar32...

MyPkg/MyPkg.dec:
```
[PcdsDynamic]
gMyPkgTokenSpaceGuid.PcdMyDynamicVar32|0x31313131|UINT32|0x30000001

[PcdsDynamicEx]
gMyPkgTokenSpaceGuid.PcdMyDynamicExVar32|0x32323232|UINT32|0x40000001
```

MyPkg/Myapp/Myapp.inf:
```
[Pcd]
gUefiLessonsPkgTokenSpaceGuid.PcdMyDynamicVar32

[PcdEx]
gUefiLessonsPkgTokenSpaceGuid.PcdMyDynamicExVar32
```

MyPkg/Myapp/Myapp.c:
```
Print(L"PcdMyDynamicExVar32=%x\n", PcdGet32(PcdMyDynamicExVar32));
PcdSet32S(PcdMyDynamicExVar32, 52);
Print(L"PcdMyDynamicExVar32=%x\n", PcdGet32(PcdMyDynamicExVar32));

Print(L"PcdMyDynamicVar32=%x\n", PcdGet32(PcdMyDynamicVar32));
PcdSet32S(PcdMyDynamicVar32, 52);
Print(L"PcdMyDynamicVar32=%x\n", PcdGet32(PcdMyDynamicVar32));
```

Also I've modified OvmfPkg source:
OvmfPkg/OvmfPkgX64.fdf
```
[FV.DXEFV]
...
+ INF MyPkg/MyApp/MyApp.inf
```
OvmfPkg/OvmfPkgX64.dsc
```
+ [PcdsDynamicExDefault]
+ gUefiLessonsPkgTokenSpaceGuid.PcdMyDynamicExVar32

[PcdsDynamicDefault]
+ gUefiLessonsPkgTokenSpaceGuid.PcdMyDynamicVar32
...
```


After OVMF recompilation I see both variables in a PCD database:
hexeditor Build/OvmfX64/RELEASE_GCC5/FV/Ffs/80CF7257-87AB-47f9-A3FE-D50B76D89541PcdDxe/DXEPcdDataBaseSec.raw

However only `PcdMyDynamicExVar32` works correctly in my app. I think it is because of the fact that Token value for PcdMyDynamicVar32 is still 0 in `Build/UefiLessonsPkg/RELEASE_GCC5/X64/UefiLessonsPkg/PCDLesson/PCDLesson/DEBUG/AutoGen.h`
```
#define _PCD_TOKEN_PcdMyDynamicVar32_1 0U
#define _PCD_GET_MODE_32_PcdMyDynamicVar32_1 LibPcdGet32(_PCD_TOKEN_PcdMyDynamicVar32_1)
#define _PCD_GET_MODE_SIZE_PcdMyDynamicVar32_1 LibPcdGetSize(_PCD_TOKEN_PcdMyDynamicVar32_1)
#define _PCD_SET_MODE_32_PcdMyDynamicVar32_1(Value) LibPcdSet32(_PCD_TOKEN_PcdMyDynamicVar32_1, (Value))
#define _PCD_SET_MODE_32_S_PcdMyDynamicVar32_1(Value) LibPcdSet32S(_PCD_TOKEN_PcdMyDynamicVar32_1, (Value))

#define _PCD_TOKEN_gUefiLessonsPkgTokenSpaceGuid_PcdMyDynamicExVar32 1073741825U
#define _PCD_TOKEN_PcdMyDynamicExVar32 _PCD_TOKEN_gUefiLessonsPkgTokenSpaceGuid_PcdMyDynamicExVar32
#define _PCD_GET_MODE_32_PcdMyDynamicExVar32 LibPcdGetEx32(&gUefiLessonsPkgTokenSpaceGuid, _PCD_TOKEN_PcdMyDynamicExVar32)
#define _PCD_GET_MODE_SIZE_PcdMyDynamicExVar32 LibPcdGetExSize(&gUefiLessonsPkgTokenSpaceGuid, _PCD_TOKEN_PcdMyDynamicExVar32)
#define _PCD_SET_MODE_32_PcdMyDynamicExVar32(Value) LibPcdSetEx32(&gUefiLessonsPkgTokenSpaceGuid, _PCD_TOKEN_PcdMyDynamicExVar32, (Value))
#define _PCD_SET_MODE_32_S_PcdMyDynamicExVar32(Value) LibPcdSetEx32S(&gUefiLessonsPkgTokenSpaceGuid, _PCD_TOKEN_PcdMyDynamicExVar32, (Value)
```

What am I doing wrong?

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