aboutsummaryrefslogtreecommitdiffstats
path: root/UefiLessonsPkg
diff options
context:
space:
mode:
authorKonstantin Aladyshev <aladyshev22@gmail.com>2022-08-05 16:53:29 +0300
committerKonstantin Aladyshev <aladyshev22@gmail.com>2022-08-05 16:53:29 +0300
commite26e327f7e3d27264e1986969a981ecd4d4ea116 (patch)
tree33d052ff91840147e74836d0c3f5800726540906 /UefiLessonsPkg
parent557f0954c053d3d1ea1c6497bac1aebf3fb72acf (diff)
downloadUEFI-Lessons-e26e327f7e3d27264e1986969a981ecd4d4ea116.tar.gz
UEFI-Lessons-e26e327f7e3d27264e1986969a981ecd4d4ea116.tar.bz2
UEFI-Lessons-e26e327f7e3d27264e1986969a981ecd4d4ea116.zip
Update PCDLesson source
Signed-off-by: Konstantin Aladyshev <aladyshev22@gmail.com>
Diffstat (limited to 'UefiLessonsPkg')
-rw-r--r--UefiLessonsPkg/Include/CustomPcdTypes.h23
-rw-r--r--UefiLessonsPkg/PCDLesson/PCDLesson.c67
-rw-r--r--UefiLessonsPkg/PCDLesson/PCDLesson.inf48
-rw-r--r--UefiLessonsPkg/UefiLessonsPkg.dsc78
4 files changed, 180 insertions, 36 deletions
diff --git a/UefiLessonsPkg/Include/CustomPcdTypes.h b/UefiLessonsPkg/Include/CustomPcdTypes.h
new file mode 100644
index 0000000..0b9eab0
--- /dev/null
+++ b/UefiLessonsPkg/Include/CustomPcdTypes.h
@@ -0,0 +1,23 @@
+#ifndef CUSTOM_PCD_TYPES_H
+#define CUSTOM_PCD_TYPES_H
+
+typedef struct {
+ EFI_GUID Guid;
+ CHAR16 Name[6];
+} InnerCustomStruct;
+
+typedef struct {
+ UINT8 Val8;
+ UINT32 Val32[2];
+ InnerCustomStruct ValStruct;
+ union {
+ struct {
+ UINT8 Field1:1;
+ UINT8 Field2:4;
+ UINT8 Filed3:3;
+ } BitFields;
+ UINT8 Byte;
+ } ValUnion;
+} CustomStruct;
+
+#endif
diff --git a/UefiLessonsPkg/PCDLesson/PCDLesson.c b/UefiLessonsPkg/PCDLesson/PCDLesson.c
index 2853326..0fca03d 100644
--- a/UefiLessonsPkg/PCDLesson/PCDLesson.c
+++ b/UefiLessonsPkg/PCDLesson/PCDLesson.c
@@ -7,6 +7,7 @@
#include <Library/UefiBootServicesTableLib.h>
#include <Library/UefiLib.h>
+#include <Library/DevicePathLib.h>
#include <Library/PcdLib.h>
EFI_STATUS
@@ -16,34 +17,52 @@ UefiMain (
IN EFI_SYSTEM_TABLE *SystemTable
)
{
- Print(L"PcdMyVar32=%d\n", FixedPcdGet32(PcdMyVar32));
- Print(L"PcdMyVar32_1=%d\n", FixedPcdGet32(PcdMyVar32_1));
- Print(L"PcdMyVar32_2=%d\n", FixedPcdGet32(PcdMyVar32_2));
+ Print(L"PcdInt8=0x%x\n", FixedPcdGet8(PcdInt8));
+ Print(L"PcdInt16=0x%x\n", FixedPcdGet16(PcdInt16));
+ Print(L"PcdInt32=0x%x\n", FixedPcdGet32(PcdInt32));
+ Print(L"PcdInt64=0x%x\n", FixedPcdGet64(PcdInt64));
+ Print(L"PcdBool=0x%x\n", FixedPcdGetBool(PcdBool));
+ Print(L"PcdInt8=0x%x\n", PcdGet8(PcdInt8));
+ Print(L"PcdInt16=0x%x\n", PcdGet16(PcdInt16));
+ Print(L"PcdInt32=0x%x\n", PcdGet32(PcdInt32));
+ Print(L"PcdInt64=0x%x\n", PcdGet64(PcdInt64));
+ Print(L"PcdIntBool=0x%x\n", PcdGetBool(PcdBool));
- Print(L"PcdMyVar32=%d\n", PcdGet32(PcdMyVar32));
+ Print(L"PcdAsciiStr=%a\n", FixedPcdGetPtr(PcdAsciiStr));
+ Print(L"PcdAsciiStrSize=%d\n", FixedPcdGetSize(PcdAsciiStr));
+ Print(L"PcdUCS2Str=%s\n", PcdGetPtr(PcdUCS2Str));
+ Print(L"PcdUCS2StrSize=%d\n", PcdGetSize(PcdUCS2Str));
- Print(L"PcdMyPatchableVar32=%d\n", PcdGet32(PcdMyPatchableVar32));
- EFI_STATUS Status = PcdSet32S(PcdMyPatchableVar32, 44);
- Print(L"Status=%r\n", Status);
- Print(L"PcdMyPatchableVar32=%d\n", PcdGet32(PcdMyPatchableVar32));
- PatchPcdSet32(PcdMyPatchableVar32, 45);
- Print(L"PcdMyPatchableVar32=%d\n", PatchPcdGet32(PcdMyPatchableVar32));
-
-
- Print(L"PcdMyFeatureFlagVar=%d\n", FeaturePcdGet(PcdMyFeatureFlagVar));
- Print(L"PcdMyFeatureFlagVar=%d\n", PcdGetBool(PcdMyFeatureFlagVar));
- Print(L"PcdMyVarBool=%d\n", FixedPcdGetBool(PcdMyVarBool));
- Print(L"PcdMyVarBool=%d\n", PcdGetBool(PcdMyVarBool));
-
+ for (UINTN i=0; i<FixedPcdGetSize(PcdArray); i++) {
+ Print(L"PcdArray[%d]=0x%02x\n", i, ((UINT8*)FixedPcdGetPtr(PcdArray))[i]);
+ }
+ Print(L"PcdGuidInBytes=%g\n", *(EFI_GUID*)FixedPcdGetPtr(PcdGuidInBytes));
+ Print(L"PcdGuid=%g\n", *(EFI_GUID*)FixedPcdGetPtr(PcdGuid));
+ Print(L"PcdDevicePath: %s\n", ConvertDevicePathToText((EFI_DEVICE_PATH_PROTOCOL*) FixedPcdGetPtr(PcdDevicePath), FALSE, FALSE));
+//-------
+ Print(L"PcdInt32Override=%d\n", FixedPcdGet32(PcdInt32Override));
+//-------
+ Print(L"PcdFeatureFlag=%d\n", FeaturePcdGet(PcdFeatureFlag));
+ Print(L"PcdFeatureFlag=%d\n", PcdGetBool(PcdFeatureFlag));
+ Print(L"PcdBool=%d\n", FixedPcdGetBool(PcdBool));
+ Print(L"PcdBool=%d\n", PcdGetBool(PcdBool));
+//-------
+ Print(L"PcdPatchableInt32=0x%x\n", PatchPcdGet32(PcdPatchableInt32));
+ Print(L"PcdPatchableInt32=0x%x\n", PcdGet32(PcdPatchableInt32));
+ PatchPcdSet32(PcdPatchableInt32, 43);
+ Print(L"PcdPatchableInt32=%d\n", PatchPcdGet32(PcdPatchableInt32));
+ EFI_STATUS Status = PcdSet32S(PcdPatchableInt32, 44);
+ Print(L"Status=%r\n", Status);
+ Print(L"PcdPatchableInt32=%d\n", PatchPcdGet32(PcdPatchableInt32));
+//-------
+ Print(L"PcdDynamicInt32=0x%x\n", PcdGet32(PcdDynamicInt32));
+ PcdSet32S(PcdDynamicInt32, 0xBEEFBEEF);
+ Print(L"PcdDynamicInt32=0x%x\n", PcdGet32(PcdDynamicInt32));
- 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));
+ Print(L"PcdDynamicExInt32=%x\n", PcdGetEx32(&gUefiLessonsPkgTokenSpaceGuid, PcdDynamicExInt32));
+ PcdSetEx32S(&gUefiLessonsPkgTokenSpaceGuid, PcdDynamicExInt32, 0x77777777);
+ Print(L"PcdDynamicExInt32=%x\n", PcdGetEx32(&gUefiLessonsPkgTokenSpaceGuid, PcdDynamicExInt32));
return EFI_SUCCESS;
}
diff --git a/UefiLessonsPkg/PCDLesson/PCDLesson.inf b/UefiLessonsPkg/PCDLesson/PCDLesson.inf
index e78808a..6f294ca 100644
--- a/UefiLessonsPkg/PCDLesson/PCDLesson.inf
+++ b/UefiLessonsPkg/PCDLesson/PCDLesson.inf
@@ -24,22 +24,48 @@
UefiLib
[FixedPcd]
- gUefiLessonsPkgTokenSpaceGuid.PcdMyVar32
- gUefiLessonsPkgTokenSpaceGuid.PcdMyVar32_1|43
- gUefiLessonsPkgTokenSpaceGuid.PcdMyVar32_2|43
- gUefiLessonsPkgTokenSpaceGuid.PcdMyVarBool
+ gUefiLessonsPkgTokenSpaceGuid.PcdInt8
+ gUefiLessonsPkgTokenSpaceGuid.PcdInt16
+ gUefiLessonsPkgTokenSpaceGuid.PcdInt32
+ gUefiLessonsPkgTokenSpaceGuid.PcdInt64
+ gUefiLessonsPkgTokenSpaceGuid.PcdBool
+ gUefiLessonsPkgTokenSpaceGuid.PcdExpression
+ gUefiLessonsPkgTokenSpaceGuid.PcdExpression_1
+ gUefiLessonsPkgTokenSpaceGuid.PcdExpression_2
+ gUefiLessonsPkgTokenSpaceGuid.PcdExpression_3
+ gUefiLessonsPkgTokenSpaceGuid.PcdAsciiStr
+ gUefiLessonsPkgTokenSpaceGuid.PcdUCS2Str
+ gUefiLessonsPkgTokenSpaceGuid.PcdArray
+ gUefiLessonsPkgTokenSpaceGuid.PcdGuidInBytes
+ gUefiLessonsPkgTokenSpaceGuid.PcdGuid
+ gUefiLessonsPkgTokenSpaceGuid.PcdGuidByPCD
+ gUefiLessonsPkgTokenSpaceGuid.PcdGuidByEfiGuid
+ gUefiLessonsPkgTokenSpaceGuid.PcdDevicePath
+ gUefiLessonsPkgTokenSpaceGuid.PcdIntCasts
+ gUefiLessonsPkgTokenSpaceGuid.PcdWithLabels
+ gUefiLessonsPkgTokenSpaceGuid.PcdArrayExt
+ gUefiLessonsPkgTokenSpaceGuid.PcdCustomStruct
+ gUefiLessonsPkgTokenSpaceGuid.PcdCustomStruct_1
+ gUefiLessonsPkgTokenSpaceGuid.PcdArrayWithFixedSize
+ gUefiLessonsPkgTokenSpaceGuid.PcdArrayWithFixedSize_1
+ gUefiLessonsPkgTokenSpaceGuid.PcdArrayWithFixedSize_2
+ gUefiLessonsPkgTokenSpaceGuid.PcdArrayWithFixedSize_3
+ gUefiLessonsPkgTokenSpaceGuid.PcdArrayWithFixedSize_4
-[PatchPcd]
- gUefiLessonsPkgTokenSpaceGuid.PcdMyPatchableVar32
+ gUefiLessonsPkgTokenSpaceGuid.PcdInt32Override|43
+
+ gUefiLessonsPkgTokenSpaceGuid.Region1Offset
+ gUefiLessonsPkgTokenSpaceGuid.Region1Size
[FeaturePcd]
- gUefiLessonsPkgTokenSpaceGuid.PcdMyFeatureFlagVar
+ gUefiLessonsPkgTokenSpaceGuid.PcdFeatureFlag
+
+[PatchPcd]
+ gUefiLessonsPkgTokenSpaceGuid.PcdPatchableInt32
[Pcd]
- gUefiLessonsPkgTokenSpaceGuid.PcdMyDynamicVar32
- gUefiLessonsPkgTokenSpaceGuid.PcdMyDynamicVar32_1
+ gUefiLessonsPkgTokenSpaceGuid.PcdDynamicInt32
[PcdEx]
- gUefiLessonsPkgTokenSpaceGuid.PcdMyDynamicExVar32
-
+ gUefiLessonsPkgTokenSpaceGuid.PcdDynamicExInt32
diff --git a/UefiLessonsPkg/UefiLessonsPkg.dsc b/UefiLessonsPkg/UefiLessonsPkg.dsc
index 6f0addb..e3eb498 100644
--- a/UefiLessonsPkg/UefiLessonsPkg.dsc
+++ b/UefiLessonsPkg/UefiLessonsPkg.dsc
@@ -85,5 +85,81 @@
UefiLessonsPkg/FfsFile/FfsFile.inf
[PcdsFixedAtBuild]
- gUefiLessonsPkgTokenSpaceGuid.PcdMyVar32_2|44
+ gUefiLessonsPkgTokenSpaceGuid.PcdInt8|0x88|UINT8|0x3B81CDF1
+ gUefiLessonsPkgTokenSpaceGuid.PcdInt16|0x1616|UINT16|0x77DFB6E6
+ gUefiLessonsPkgTokenSpaceGuid.PcdInt32|0x32323232|UINT32|0xF2A48130
+ gUefiLessonsPkgTokenSpaceGuid.PcdInt64|0x6464646464646464|UINT64|0x652F4E29
+ gUefiLessonsPkgTokenSpaceGuid.PcdBool|TRUE|BOOLEAN|0x69E88A63
+ gUefiLessonsPkgTokenSpaceGuid.PcdExpression|0xFF000000 + 0x00FFFFFF|UINT32|0x9C405222
+ gUefiLessonsPkgTokenSpaceGuid.PcdExpression_1|((0xFFFFFFFF & 0x000000FF) << 8) + 0x33|UINT32|0x5911C44B
+ gUefiLessonsPkgTokenSpaceGuid.PcdExpression_2|(0x00000000 | 0x00100000)|UINT32|0xAD880207
+ gUefiLessonsPkgTokenSpaceGuid.PcdExpression_3|((56 < 78) || !(23 > 44))|BOOLEAN|0x45EDE955
+ gUefiLessonsPkgTokenSpaceGuid.PcdAsciiStr|"hello"|VOID*|0xB29914B5
+ gUefiLessonsPkgTokenSpaceGuid.PcdUCS2Str|L"hello"|VOID*|0xF22124E5
+ gUefiLessonsPkgTokenSpaceGuid.PcdArray|{0xa5, 0xA6, 0xA7}|VOID*|0xD5DB9A27
+ gUefiLessonsPkgTokenSpaceGuid.PcdGuidInBytes|{0x07, 0x07, 0x74, 0xF1, 0x1D, 0x69, 0x03, 0x42, 0xBF, 0xAB, 0x99, 0xE1, 0x32, 0xFA, 0x41, 0x66}|VOID*|0xB9E0CDC0
+ gUefiLessonsPkgTokenSpaceGuid.PcdGuid|{GUID("f1740707-691d-4203-bfab-99e132fa4166")}|VOID*|0x7F2066F7
+ gUefiLessonsPkgTokenSpaceGuid.PcdGuidByPCD|{GUID(gUefiLessonsPkgTokenSpaceGuid)}|VOID*|0x0860CCD5
+ gUefiLessonsPkgTokenSpaceGuid.PcdGuidByEfiGuid|{GUID({0x150cab53, 0xad47, 0x4385, {0xb5, 0xdd, 0xbc, 0xfc, 0x76, 0xba, 0xca, 0xf0}})}|VOID*|0x613506D5
+ gUefiLessonsPkgTokenSpaceGuid.PcdDevicePath|{DEVICE_PATH("PciRoot(0x0)/Pci(0x1,0x1)/Ata(0x0)")}|VOID*|0xC56EE1E2
+ gUefiLessonsPkgTokenSpaceGuid.PcdIntCasts|{UINT16(0x1122), UINT32(0x33445566), UINT8(0x77), UINT64(0x8899aabbccddeeff)}|VOID*|0x647456A6
+ gUefiLessonsPkgTokenSpaceGuid.PcdWithLabels|{ 0x0A, 0x0B, OFFSET_OF(End), 0x0C, LABEL(Start) 0x0D, LABEL(End) 0x0E, 0x0F, OFFSET_OF(Start) }|VOID*|0xD91A8BF6
+ gUefiLessonsPkgTokenSpaceGuid.PcdArrayExt|{0x11, UINT16(0x2233), UINT32(0x44556677), L"hello", "world!", GUID("09b9b358-70bd-421e-bafb-4f97e2ac7d44")}|VOID*|0x7200C5DF
+ gUefiLessonsPkgTokenSpaceGuid.PcdCustomStruct|{0}|CustomStruct|0x535D4CB5 {
+ <Packages>
+ UefiLessonsPkg/UefiLessonsPkg.dec
+ <HeaderFiles>
+ CustomPcdTypes.h
+ }
+ gUefiLessonsPkgTokenSpaceGuid.PcdCustomStruct.Val8|0x11
+ gUefiLessonsPkgTokenSpaceGuid.PcdCustomStruct.Val32[0]|0x22334455
+ gUefiLessonsPkgTokenSpaceGuid.PcdCustomStruct.Val32[1]|0x66778899
+ gUefiLessonsPkgTokenSpaceGuid.PcdCustomStruct.ValStruct.Guid|{GUID("f1740707-691d-4203-bfab-99e132fa4166")}
+ gUefiLessonsPkgTokenSpaceGuid.PcdCustomStruct.ValStruct.Name|L'Hello'
+ gUefiLessonsPkgTokenSpaceGuid.PcdCustomStruct.ValUnion.BitFields.Field2|0xF
+
+ gUefiLessonsPkgTokenSpaceGuid.PcdCustomStruct_1|{CODE(
+ {
+ 0x11,
+ {0x22334455, 0x66778899},
+ {
+ {0xf1740707, 0x691d, 0x4203, {0xbf, 0xab, 0x99, 0xe1, 0x32, 0xfa, 0x41, 0x66}},
+ {0x0048, 0x0065, 0x006c, 0x006c, 0x006f, 0x0000}
+ },
+ {{0x0, 0xf, 0x0}}
+ }
+ )}|CustomStruct|0xC1D6B9A7 {
+ <Packages>
+ UefiLessonsPkg/UefiLessonsPkg.dec
+ <HeaderFiles>
+ CustomPcdTypes.h
+ }
+
+ gUefiLessonsPkgTokenSpaceGuid.PcdArrayWithFixedSize|{0x0}|UINT8[8]|0x4C4CB9A3
+ gUefiLessonsPkgTokenSpaceGuid.PcdArrayWithFixedSize_1|{0x0}|UINT32[3]|0x285DAD21
+ gUefiLessonsPkgTokenSpaceGuid.PcdArrayWithFixedSize_2|{UINT32(0x11223344), UINT32(0x55667788), UINT32(0x99aabbcc)}|UINT32[3]|0x25D6ED26
+ gUefiLessonsPkgTokenSpaceGuid.PcdArrayWithFixedSize_3|{CODE({0x11223344, 0x55667788, 0x99aabbcc})}|UINT32[3]|0xE5BC424D
+ gUefiLessonsPkgTokenSpaceGuid.PcdArrayWithFixedSize_4|{0x0}|CustomStruct[2]|0x0D00EE44 {
+ <Packages>
+ UefiLessonsPkg/UefiLessonsPkg.dec
+ <HeaderFiles>
+ CustomPcdTypes.h
+ }
+
+ gUefiLessonsPkgTokenSpaceGuid.PcdInt32Override|42|UINT32|0x3CB8ABB8
+
+ gUefiLessonsPkgTokenSpaceGuid.Region1Offset|0|UINT32|0x00000005
+ gUefiLessonsPkgTokenSpaceGuid.Region1Size|0|UINT32|0x00000006
+
+[PcdsFeatureFlag]
+ gUefiLessonsPkgTokenSpaceGuid.PcdFeatureFlag|TRUE|BOOLEAN|0x16DD586E
+
+[PcdsPatchableInModule]
+ gUefiLessonsPkgTokenSpaceGuid.PcdPatchableInt32|0x31313131|UINT32|0xFCDA11B5
+
+[PcdsDynamic]
+ gUefiLessonsPkgTokenSpaceGuid.PcdDynamicInt32|0xCAFECAFE|UINT32|0x4F9259A3
+
+[PcdsDynamicEx]
+ gUefiLessonsPkgTokenSpaceGuid.PcdDynamicExInt32|0xBABEBABE|UINT32|0xAF35F3B2