From 61f0373a3df04323ef130b7d3b610c7cb6504991 Mon Sep 17 00:00:00 2001 From: Konstantin Aladyshev Date: Mon, 28 Jun 2021 16:51:09 +0300 Subject: Add lesson 21 --- Lesson_21/README.md | 71 +++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 71 insertions(+) create mode 100644 Lesson_21/README.md (limited to 'Lesson_21/README.md') diff --git a/Lesson_21/README.md b/Lesson_21/README.md new file mode 100644 index 0000000..4e53c04 --- /dev/null +++ b/Lesson_21/README.md @@ -0,0 +1,71 @@ +Let's create a another variable `PcdMyVar32_1` the same way we did in the previous lesson. + +Add a PCD definition to the `UefiLessonsPkg/UefiLessonsPkg.dec`: +``` +[PcdsFixedAtBuild] + ... + gUefiLessonsPkgTokenSpaceGuid.PcdMyVar32_1|42|UINT32|0x00000002 +``` + +Add print statement to `UefiLessonsPkg/PCDLesson/PCDLesson.c`: +``` +Print(L"PcdMyVar32_1=%d\n", FixedPcdGet32(PcdMyVar32_1)); +``` + +As for the `PCDLesson.inf` this time add an override for a value this time: +``` +[FixedPcd] + ... + gUefiLessonsPkgTokenSpaceGuid.PcdMyVar32_1|43 +``` + +If you build execute our app under OVMF you would get: +``` +FS0:\> PCDLesson.efi +PcdMyVar32=42 +PcdMyVar32_1=43 +``` + +So it means that every App/Driver can override a PCD declared in *.dec file differently. + +______________ + +Now let's create a third variable `PcdMyVar32_2` the same way as `PcdMyVar32_1`. +`UefiLessonsPkg/UefiLessonsPkg.dec` + ``` +[PcdsFixedAtBuild] + ... + gUefiLessonsPkgTokenSpaceGuid.PcdMyVar32_2|42|UINT32|0x00000003 +``` +UefiLessonsPkg/PCDLesson/PCDLesson.c +``` +Print(L"PcdMyVar32_2=%d\n", FixedPcdGet32(PcdMyVar32_2)); +``` +UefiLessonsPkg/PCDLesson/PCDLesson.inf +``` +[FixedPcd] + ... + gUefiLessonsPkgTokenSpaceGuid.PcdMyVar32_2|43 +``` +Only this time add an override for the variable to our `UefiLessonsPkg/UefiLessonsPkg.dsc` file: +``` +[PcdsFixedAtBuild] + gUefiLessonsPkgTokenSpaceGuid.PcdMyVar32_2|44 +``` + +If you build our app and execute in under OVMF now you would get: +``` +FS0:\> PCDLesson.efi +PcdMyVar32=42 +PcdMyVar32_1=43 +PcdMyVar32_2=44 +``` + +So override order would be: +``` +DEC < INF < DSC +``` +- Declaration file (DEC) declares PCD with its default value +- Every App/Driver Information file (INF) can override the value of this PCD differently +- However a package description file that contains all these Apps/Drivers (DSC) can override this PCD for all of them + -- cgit v1.2.3-18-g5258