aboutsummaryrefslogtreecommitdiffstats
path: root/Lesson_20
diff options
context:
space:
mode:
authorKonstantin Aladyshev <aladyshev22@gmail.com>2021-06-30 20:25:29 +0300
committerKonstantin Aladyshev <aladyshev22@gmail.com>2021-06-30 20:25:29 +0300
commit79dae444da030f28c44810252220772e0f39196e (patch)
treee98872e94650893ebdfcb6827b5a08094e3c3558 /Lesson_20
parentba566e7a315cbb229f457c5afb76b56af53136a3 (diff)
downloadUEFI-Lessons-79dae444da030f28c44810252220772e0f39196e.tar.gz
UEFI-Lessons-79dae444da030f28c44810252220772e0f39196e.tar.bz2
UEFI-Lessons-79dae444da030f28c44810252220772e0f39196e.zip
Add info about generic PcdGet call to lesson 20
Signed-off-by: Konstantin Aladyshev <aladyshev22@gmail.com>
Diffstat (limited to 'Lesson_20')
-rw-r--r--Lesson_20/README.md21
1 files changed, 21 insertions, 0 deletions
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.