From 79dae444da030f28c44810252220772e0f39196e Mon Sep 17 00:00:00 2001 From: Konstantin Aladyshev Date: Wed, 30 Jun 2021 20:25:29 +0300 Subject: Add info about generic PcdGet call to lesson 20 Signed-off-by: Konstantin Aladyshev --- Lesson_20/README.md | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) (limited to 'Lesson_20') diff --git a/Lesson_20/README.md b/Lesson_20/README.md index 1f809ef..46a4c5b 100644 --- a/Lesson_20/README.md +++ b/Lesson_20/README.md @@ -80,8 +80,29 @@ Build/UefiLessonsPkg/RELEASE_GCC5/X64/UefiLessonsPkg/PCDLesson/PCDLesson/DEBUG/A GLOBAL_REMOVE_IF_UNREFERENCED const UINT32 _gPcd_FixedAtBuild_PcdMyVar32 = _PCD_VALUE_PcdMyVar32; ``` +So in our case preprocessor expands code like this: +``` +FixedPcdGet32(PcdMyVar32) -> _PCD_VALUE_PcdMyVar32 -> 42U +``` + If you execute app code under OVMF: ``` FS0:\> PCDLesson.efi PcdMyVar32=42 ``` + +There are multiple types of PCDs. `FixedAtBuild` PCD is only one of them. In our code we've used `FixedPcdGet` call to get PCD value, this call would only work if PCD is `FixedAtBuild`. However there is a generic `PcdGet` call that can be used to get a value of PCD regardless its type. +https://github.com/tianocore/edk2/blob/master/MdePkg/Include/Library/PcdLib.h: +``` +#define PcdGet32(TokenName) _PCD_GET_MODE_32_##TokenName +``` + +In our case this would expand to: +``` +PcdGet32(PcdMyVar32) -> _PCD_GET_MODE_32_PcdMyVar32 -> _gPcd_FixedAtBuild_PcdMyVar32 +``` +The latter one is a variable that is defined in a `AutoGen.c` file: +``` + GLOBAL_REMOVE_IF_UNREFERENCED const UINT32 _gPcd_FixedAtBuild_PcdMyVar32 = 42U; +``` +So as you can see result would be the same. The difference is that `PcdGet` would work with other PCD types, that we would cover in the next lessons. -- cgit v1.2.3-18-g5258