aboutsummaryrefslogtreecommitdiffstats
path: root/Lessons/Lesson_25/README.md
diff options
context:
space:
mode:
Diffstat (limited to 'Lessons/Lesson_25/README.md')
-rw-r--r--Lessons/Lesson_25/README.md19
1 files changed, 19 insertions, 0 deletions
diff --git a/Lessons/Lesson_25/README.md b/Lessons/Lesson_25/README.md
index 15b0b85..ccbcc90 100644
--- a/Lessons/Lesson_25/README.md
+++ b/Lessons/Lesson_25/README.md
@@ -144,6 +144,25 @@ PcdDynamicInt32=0xCAFECAFE
PcdDynamicInt32=0xBEEFBEEF
```
+As we don't always use our application as a part of Ovmf package it would be better to guard the `PcdDynamicInt32` access for cases when local tokan is unassigned.
+
+We can do it with a help of a `PcdToken` macro:
+```
+#define PcdToken(TokenName) _PCD_TOKEN_##TokenName
+```
+
+Code usage as simple as this:
+```
+if (PcdToken(PcdDynamicInt32)) {
+ Print(L"PcdDynamicInt32=0x%x\n", PcdGet32(PcdDynamicInt32));
+ PcdSet32S(PcdDynamicInt32, 0xBEEFBEEF);
+ Print(L"PcdDynamicInt32=0x%x\n", PcdGet32(PcdDynamicInt32));
+} else {
+ Print(L"PcdDynamicInt32 token is unassigned\n");
+}
+```
+At least now if you accidently copy `Build/UefiLessonsPkg/RELEASE_GCC5/X64/PCDLesson.efi` instead of `Build/OvmfX64/RELEASE_GCC5/X64/PCDLesson.efi` the application won't break the OVMF.
+
# Dynamic Ex PCD
Suppose we already have the necessary PCD in the PCD Database. And we want to access it via application from the UEFI Shell.