aboutsummaryrefslogtreecommitdiffstats
path: root/Lessons
diff options
context:
space:
mode:
Diffstat (limited to 'Lessons')
-rw-r--r--Lessons/Lesson_37/README.md227
-rw-r--r--Lessons/Lesson_37/UefiLessonsPkg/Include/Library/SimpleLibrary.h2
-rw-r--r--Lessons/Lesson_37/UefiLessonsPkg/Library/SimpleLibrary/SimpleLibrary.c5
-rw-r--r--Lessons/Lesson_37/UefiLessonsPkg/Library/SimpleLibrary/SimpleLibrary.inf15
-rw-r--r--Lessons/Lesson_37/UefiLessonsPkg/Library/SimpleLibraryWithConstructor/SimpleLibraryWithConstructor.c18
-rw-r--r--Lessons/Lesson_37/UefiLessonsPkg/Library/SimpleLibraryWithConstructor/SimpleLibraryWithConstructor.inf16
-rw-r--r--Lessons/Lesson_37/UefiLessonsPkg/Library/SimpleLibraryWithConstructorAndDestructor/SimpleLibraryWithConstructorAndDestructor.c28
-rw-r--r--Lessons/Lesson_37/UefiLessonsPkg/Library/SimpleLibraryWithConstructorAndDestructor/SimpleLibraryWithConstructorAndDestructor.inf17
-rw-r--r--Lessons/Lesson_37/UefiLessonsPkg/SimpleLibraryUser/SimpleLibraryUser.c16
-rw-r--r--Lessons/Lesson_37/UefiLessonsPkg/SimpleLibraryUser/SimpleLibraryUser.inf20
-rw-r--r--Lessons/Lesson_37/UefiLessonsPkg/UefiLessonsPkg.dec34
-rw-r--r--Lessons/Lesson_37/UefiLessonsPkg/UefiLessonsPkg.dsc62
12 files changed, 460 insertions, 0 deletions
diff --git a/Lessons/Lesson_37/README.md b/Lessons/Lesson_37/README.md
new file mode 100644
index 0000000..8f73957
--- /dev/null
+++ b/Lessons/Lesson_37/README.md
@@ -0,0 +1,227 @@
+In this lesson we'll learn about library constructor and destructor.
+
+Create a new library module `UefiLessonsPkg/Library/SimpleLibraryWithConstructor/SimpleLibraryWithConstructor.inf`:
+```
+[Defines]
+ INF_VERSION = 1.25
+ BASE_NAME = SimpleLibraryWithConstructor
+ FILE_GUID = 96952c1e-86a6-4700-96b0-e7303ac3f92d
+ MODULE_TYPE = UEFI_APPLICATION
+ VERSION_STRING = 1.0
+ LIBRARY_CLASS = SimpleLibrary | UEFI_APPLICATION
+ CONSTRUCTOR = SimpleLibraryConstructor <--------
+
+[Sources]
+ SimpleLibraryWithConstructor.c
+
+[Packages]
+ MdePkg/MdePkg.dec
+ UefiLessonsPkg/UefiLessonsPkg.dec
+```
+Here we've added `CONSTRUCTOR` statement with a name of constructor function. Let's add `Print` statement to it, to know when it is executed.
+
+`UefiLessonsPkg/Library/SimpleLibraryWithConstructor/SimpleLibraryWithConstructor.c`:
+```
+#include <Library/UefiLib.h>
+#include <Library/SimpleLibrary.h>
+
+UINTN Plus2(UINTN number) {
+ return number+2;
+}
+
+EFI_STATUS
+EFIAPI
+SimpleLibraryConstructor(
+ IN EFI_HANDLE ImageHandle,
+ IN EFI_SYSTEM_TABLE *SystemTable
+ )
+{
+ Print(L"Hello from library constructor!\n");
+ return EFI_SUCCESS;
+}
+```
+
+Now we don't need to create another app that would use our new lib, we can simply change library implementation in the `UefiLessonsPkg/UefiLessonsPkg.dsc` and our `SimpleLibraryUser` would be recompiled with our new library version:
+```
+[LibraryClasses]
+ ...
+ #SimpleLibrary|UefiLessonsPkg/Library/SimpleLibrary/SimpleLibrary.inf
+ SimpleLibrary|UefiLessonsPkg/Library/SimpleLibraryWithConstructor/SimpleLibraryWithConstructor.inf
+```
+
+If you build our app and execute it under OVMF now you would get:
+```
+FS0:\> SimpleLibraryUser.efi
+Hello from library constructor!
+5
+```
+
+An example of a library that uses constructor would be `UefiBootServicesTableLib` library https://github.com/tianocore/edk2/blob/master/MdePkg/Library/UefiBootServicesTableLib/UefiBootServicesTableLib.inf. We've used it all over in our lessons, so let's take a look at it.
+
+As a matter of fact, constructor is the only thing that this library has.
+
+To understand how this library works take a look at its *.c and *.h files:
+
+https://github.com/tianocore/edk2/blob/master/MdePkg/Library/UefiBootServicesTableLib/UefiBootServicesTableLib.c
+```
+EFI_HANDLE gImageHandle = NULL;
+EFI_SYSTEM_TABLE *gST = NULL;
+EFI_BOOT_SERVICES *gBS = NULL;
+
+EFI_STATUS
+EFIAPI
+UefiBootServicesTableLibConstructor (
+ IN EFI_HANDLE ImageHandle,
+ IN EFI_SYSTEM_TABLE *SystemTable
+ )
+{
+ gImageHandle = ImageHandle;
+ gST = SystemTable;
+ gBS = SystemTable->BootServices;
+
+ return EFI_SUCCESS;
+}
+```
+https://github.com/tianocore/edk2/blob/master/MdePkg/Include/Library/UefiBootServicesTableLib.h:
+```
+extern EFI_HANDLE gImageHandle;
+extern EFI_SYSTEM_TABLE *gST;
+extern EFI_BOOT_SERVICES *gBS;
+```
+
+So as you can see this library just sets some global variables - shortcuts for the UEFI main parts. As the library constructors execute before the main app code, with this library you can access `gImageHandle`/`gST`/`gBS` anywhere in your app code from the very start.
+
+# DESTRUCTOR
+
+Similar we can create another version of a `SimpleLibrary` that would have both constructor and destructor.
+
+`UefiLessonsPkg/Library/SimpleLibraryWithConstructorAndDestructor/SimpleLibraryWithConstructorAndDestructor.inf`:
+```
+[Defines]
+ INF_VERSION = 1.25
+ BASE_NAME = SimpleLibraryWithConstructorAndDestructor
+ FILE_GUID = 96952c1e-86a6-4700-96b0-e7303ac3f92d
+ MODULE_TYPE = UEFI_APPLICATION
+ VERSION_STRING = 1.0
+ LIBRARY_CLASS = SimpleLibrary | UEFI_APPLICATION
+ CONSTRUCTOR = SimpleLibraryConstructor
+ DESTRUCTOR = SimpleLibraryDestructor <-----------
+
+[Sources]
+ SimpleLibraryWithConstructorAndDestructor.c
+
+[Packages]
+ MdePkg/MdePkg.dec
+ UefiLessonsPkg/UefiLessonsPkg.dec
+```
+`UefiLessonsPkg/Library/SimpleLibraryWithConstructorAndDestructor/SimpleLibraryWithConstructorAndDestructor.c`:
+```
+#include <Library/UefiLib.h>
+#include <Library/SimpleLibrary.h>
+
+UINTN Plus2(UINTN number) {
+ return number+2;
+}
+
+EFI_STATUS
+EFIAPI
+SimpleLibraryConstructor(
+ IN EFI_HANDLE ImageHandle,
+ IN EFI_SYSTEM_TABLE *SystemTable
+ )
+{
+ Print(L"Hello from library constructor!\n");
+ return EFI_SUCCESS;
+}
+
+EFI_STATUS
+EFIAPI
+SimpleLibraryDestructor(
+ IN EFI_HANDLE ImageHandle,
+ IN EFI_SYSTEM_TABLE *SystemTable
+ )
+{
+ Print(L"Hello from library destructor!\n");
+ return EFI_SUCCESS;
+}
+```
+
+Don't forget to change the library backend in the `UefiLessonsPkg/UefiLessonsPkg.dsc`:
+```
+[LibraryClasses]
+ ...
+ #SimpleLibrary|UefiLessonsPkg/Library/SimpleLibrary/SimpleLibrary.inf
+ #SimpleLibrary|UefiLessonsPkg/Library/SimpleLibraryWithConstructor/SimpleLibraryWithConstructor.inf
+ SimpleLibrary|UefiLessonsPkg/Library/SimpleLibraryWithConstructorAndDestructor/SimpleLibraryWithConstructorAndDestructor.inf
+```
+
+Now our app would have print strings both at the beginning and in the end:
+```
+FS0:\> SimpleLibraryUser.efi
+Hello from library constructor!
+5
+Hello from library destructor!
+```
+
+
+As an example of a library with both CONSTRUCTOR and DESTRUCTOR take a look at the https://github.com/tianocore/edk2/blob/master/MdePkg/Library/UefiDebugLibConOut/DebugLibConstructor.c, it uses `CreateEvent` in a constructor, and closes it in a desctrutor with a `CloseEvent`.
+
+
+# `NULL` library
+
+
+As you already know OVMF includes `Shell` app in itself. For its compilation OVMF package DSC file (https://github.com/tianocore/edk2/blob/master/OvmfPkg/OvmfPkgX64.dsc) contains these strings:
+```
+[Components]
+ ...
+ ShellPkg/Application/Shell/Shell.inf {
+ <LibraryClasses>
+ ShellCommandLib|ShellPkg/Library/UefiShellCommandLib/UefiShellCommandLib.inf
+ NULL|ShellPkg/Library/UefiShellLevel2CommandsLib/UefiShellLevel2CommandsLib.inf
+ NULL|ShellPkg/Library/UefiShellLevel1CommandsLib/UefiShellLevel1CommandsLib.inf
+ NULL|ShellPkg/Library/UefiShellLevel3CommandsLib/UefiShellLevel3CommandsLib.inf
+ NULL|ShellPkg/Library/UefiShellDriver1CommandsLib/UefiShellDriver1CommandsLib.inf
+ NULL|ShellPkg/Library/UefiShellDebug1CommandsLib/UefiShellDebug1CommandsLib.inf
+ NULL|ShellPkg/Library/UefiShellInstall1CommandsLib/UefiShellInstall1CommandsLib.inf
+ NULL|ShellPkg/Library/UefiShellNetwork1CommandsLib/UefiShellNetwork1CommandsLib.inf
+ ...
+ HandleParsingLib|ShellPkg/Library/UefiHandleParsingLib/UefiHandleParsingLib.inf
+ PrintLib|MdePkg/Library/BasePrintLib/BasePrintLib.inf
+ BcfgCommandLib|ShellPkg/Library/UefiShellBcfgCommandLib/UefiShellBcfgCommandLib.inf
+
+ ...
+ }
+```
+
+Here you can notice that some of the library classes have `NULL` class.
+
+`NULL` library classes are conceptually an "anonymous library". It enables one to statically link code into a module even if the module doesn't directly call functions in that library.
+
+It can be useful if we don't need to call library API in our app, but just need library constructor/destructor functions.
+
+If you'll take a look at the file https://github.com/tianocore/edk2/blob/master/ShellPkg/Library/UefiShellLevel1CommandsLib/UefiShellLevel1CommandsLib.c you'll see that this module constructor is used to add additional commands to the Shell:
+```
+EFI_STATUS
+EFIAPI
+ShellLevel1CommandsLibConstructor (
+ IN EFI_HANDLE ImageHandle,
+ IN EFI_SYSTEM_TABLE *SystemTable
+ )
+{
+ ...
+ ShellCommandRegisterCommandName(L"stall", ShellCommandRunStall , ShellCommandGetManFileNameLevel1, 1, L"", FALSE, gShellLevel1HiiHandle, (EFI_STRING_ID)(PcdGet8(PcdShellSupportLevel) < 3 ? 0 : STRING_TOKEN(STR_GET_HELP_STALL) ));
+ ShellCommandRegisterCommandName(L"for", ShellCommandRunFor , ShellCommandGetManFileNameLevel1, 1, L"", FALSE, gShellLevel1HiiHandle, (EFI_STRING_ID)(PcdGet8(PcdShellSupportLevel) < 3 ? 0 : STRING_TOKEN(STR_GET_HELP_FOR) ));
+ ShellCommandRegisterCommandName(L"goto", ShellCommandRunGoto , ShellCommandGetManFileNameLevel1, 1, L"", FALSE, gShellLevel1HiiHandle, (EFI_STRING_ID)(PcdGet8(PcdShellSupportLevel) < 3 ? 0 : STRING_TOKEN(STR_GET_HELP_GOTO) ));
+ ShellCommandRegisterCommandName(L"if", ShellCommandRunIf , ShellCommandGetManFileNameLevel1, 1, L"", FALSE, gShellLevel1HiiHandle, (EFI_STRING_ID)(PcdGet8(PcdShellSupportLevel) < 3 ? 0 : STRING_TOKEN(STR_GET_HELP_IF) ));
+ ShellCommandRegisterCommandName(L"shift", ShellCommandRunShift , ShellCommandGetManFileNameLevel1, 1, L"", FALSE, gShellLevel1HiiHandle, (EFI_STRING_ID)(PcdGet8(PcdShellSupportLevel) < 3 ? 0 : STRING_TOKEN(STR_GET_HELP_SHIFT) ));
+ ShellCommandRegisterCommandName(L"exit", ShellCommandRunExit , ShellCommandGetManFileNameLevel1, 1, L"", TRUE , gShellLevel1HiiHandle, (EFI_STRING_ID)(PcdGet8(PcdShellSupportLevel) < 3 ? 0 : STRING_TOKEN(STR_GET_HELP_EXIT) ));
+ ShellCommandRegisterCommandName(L"else", ShellCommandRunElse , ShellCommandGetManFileNameLevel1, 1, L"", FALSE, gShellLevel1HiiHandle, (EFI_STRING_ID)(PcdGet8(PcdShellSupportLevel) < 3 ? 0 : STRING_TOKEN(STR_GET_HELP_ELSE) ));
+ ShellCommandRegisterCommandName(L"endif", ShellCommandRunEndIf , ShellCommandGetManFileNameLevel1, 1, L"", FALSE, gShellLevel1HiiHandle, (EFI_STRING_ID)(PcdGet8(PcdShellSupportLevel) < 3 ? 0 : STRING_TOKEN(STR_GET_HELP_ENDIF) ));
+ ShellCommandRegisterCommandName(L"endfor", ShellCommandRunEndFor , ShellCommandGetManFileNameLevel1, 1, L"", FALSE, gShellLevel1HiiHandle, (EFI_STRING_ID)(PcdGet8(PcdShellSupportLevel) < 3 ? 0 : STRING_TOKEN(STR_GET_HELP_ENDFOR)));
+
+ return (EFI_SUCCESS);
+```
+
+This is an elegant way to split shell command support to different modules.
+With this functionality you can easily compile your image of `Shell` with a necessary commands support.
+
diff --git a/Lessons/Lesson_37/UefiLessonsPkg/Include/Library/SimpleLibrary.h b/Lessons/Lesson_37/UefiLessonsPkg/Include/Library/SimpleLibrary.h
new file mode 100644
index 0000000..105bc87
--- /dev/null
+++ b/Lessons/Lesson_37/UefiLessonsPkg/Include/Library/SimpleLibrary.h
@@ -0,0 +1,2 @@
+UINTN Plus2(UINTN number);
+
diff --git a/Lessons/Lesson_37/UefiLessonsPkg/Library/SimpleLibrary/SimpleLibrary.c b/Lessons/Lesson_37/UefiLessonsPkg/Library/SimpleLibrary/SimpleLibrary.c
new file mode 100644
index 0000000..acffba4
--- /dev/null
+++ b/Lessons/Lesson_37/UefiLessonsPkg/Library/SimpleLibrary/SimpleLibrary.c
@@ -0,0 +1,5 @@
+#include <Library/SimpleLibrary.h>
+
+UINTN Plus2(UINTN number) {
+ return number+2;
+}
diff --git a/Lessons/Lesson_37/UefiLessonsPkg/Library/SimpleLibrary/SimpleLibrary.inf b/Lessons/Lesson_37/UefiLessonsPkg/Library/SimpleLibrary/SimpleLibrary.inf
new file mode 100644
index 0000000..92027a4
--- /dev/null
+++ b/Lessons/Lesson_37/UefiLessonsPkg/Library/SimpleLibrary/SimpleLibrary.inf
@@ -0,0 +1,15 @@
+[Defines]
+ INF_VERSION = 1.25
+ BASE_NAME = SimpleLibrary
+ FILE_GUID = 826c8951-5bd2-4d72-a9d9-f7ab48684117
+ MODULE_TYPE = UEFI_APPLICATION
+ VERSION_STRING = 1.0
+ LIBRARY_CLASS = SimpleLibrary | UEFI_APPLICATION
+
+[Sources]
+ SimpleLibrary.c
+
+[Packages]
+ MdePkg/MdePkg.dec
+ UefiLessonsPkg/UefiLessonsPkg.dec
+
diff --git a/Lessons/Lesson_37/UefiLessonsPkg/Library/SimpleLibraryWithConstructor/SimpleLibraryWithConstructor.c b/Lessons/Lesson_37/UefiLessonsPkg/Library/SimpleLibraryWithConstructor/SimpleLibraryWithConstructor.c
new file mode 100644
index 0000000..5ade80e
--- /dev/null
+++ b/Lessons/Lesson_37/UefiLessonsPkg/Library/SimpleLibraryWithConstructor/SimpleLibraryWithConstructor.c
@@ -0,0 +1,18 @@
+#include <Library/UefiLib.h>
+#include <Library/SimpleLibrary.h>
+
+UINTN Plus2(UINTN number) {
+ return number+2;
+}
+
+EFI_STATUS
+EFIAPI
+SimpleLibraryConstructor(
+ IN EFI_HANDLE ImageHandle,
+ IN EFI_SYSTEM_TABLE *SystemTable
+ )
+{
+ Print(L"Hello from library constructor!\n");
+ return EFI_SUCCESS;
+}
+
diff --git a/Lessons/Lesson_37/UefiLessonsPkg/Library/SimpleLibraryWithConstructor/SimpleLibraryWithConstructor.inf b/Lessons/Lesson_37/UefiLessonsPkg/Library/SimpleLibraryWithConstructor/SimpleLibraryWithConstructor.inf
new file mode 100644
index 0000000..fc56624
--- /dev/null
+++ b/Lessons/Lesson_37/UefiLessonsPkg/Library/SimpleLibraryWithConstructor/SimpleLibraryWithConstructor.inf
@@ -0,0 +1,16 @@
+[Defines]
+ INF_VERSION = 1.25
+ BASE_NAME = SimpleLibraryWithConstructor
+ FILE_GUID = 96952c1e-86a6-4700-96b0-e7303ac3f92d
+ MODULE_TYPE = UEFI_APPLICATION
+ VERSION_STRING = 1.0
+ LIBRARY_CLASS = SimpleLibrary | UEFI_APPLICATION
+ CONSTRUCTOR = SimpleLibraryConstructor
+
+[Sources]
+ SimpleLibraryWithConstructor.c
+
+[Packages]
+ MdePkg/MdePkg.dec
+ UefiLessonsPkg/UefiLessonsPkg.dec
+
diff --git a/Lessons/Lesson_37/UefiLessonsPkg/Library/SimpleLibraryWithConstructorAndDestructor/SimpleLibraryWithConstructorAndDestructor.c b/Lessons/Lesson_37/UefiLessonsPkg/Library/SimpleLibraryWithConstructorAndDestructor/SimpleLibraryWithConstructorAndDestructor.c
new file mode 100644
index 0000000..f903e99
--- /dev/null
+++ b/Lessons/Lesson_37/UefiLessonsPkg/Library/SimpleLibraryWithConstructorAndDestructor/SimpleLibraryWithConstructorAndDestructor.c
@@ -0,0 +1,28 @@
+#include <Library/UefiLib.h>
+#include <Library/SimpleLibrary.h>
+
+UINTN Plus2(UINTN number) {
+ return number+2;
+}
+
+EFI_STATUS
+EFIAPI
+SimpleLibraryConstructor(
+ IN EFI_HANDLE ImageHandle,
+ IN EFI_SYSTEM_TABLE *SystemTable
+ )
+{
+ Print(L"Hello from library constructor!\n");
+ return EFI_SUCCESS;
+}
+
+EFI_STATUS
+EFIAPI
+SimpleLibraryDestructor(
+ IN EFI_HANDLE ImageHandle,
+ IN EFI_SYSTEM_TABLE *SystemTable
+ )
+{
+ Print(L"Hello from library destructor!\n");
+ return EFI_SUCCESS;
+}
diff --git a/Lessons/Lesson_37/UefiLessonsPkg/Library/SimpleLibraryWithConstructorAndDestructor/SimpleLibraryWithConstructorAndDestructor.inf b/Lessons/Lesson_37/UefiLessonsPkg/Library/SimpleLibraryWithConstructorAndDestructor/SimpleLibraryWithConstructorAndDestructor.inf
new file mode 100644
index 0000000..3fc3bbe
--- /dev/null
+++ b/Lessons/Lesson_37/UefiLessonsPkg/Library/SimpleLibraryWithConstructorAndDestructor/SimpleLibraryWithConstructorAndDestructor.inf
@@ -0,0 +1,17 @@
+[Defines]
+ INF_VERSION = 1.25
+ BASE_NAME = SimpleLibraryWithConstructorAndDestructor
+ FILE_GUID = 96952c1e-86a6-4700-96b0-e7303ac3f92d
+ MODULE_TYPE = UEFI_APPLICATION
+ VERSION_STRING = 1.0
+ LIBRARY_CLASS = SimpleLibrary | UEFI_APPLICATION
+ CONSTRUCTOR = SimpleLibraryConstructor
+ DESTRUCTOR = SimpleLibraryDestructor
+
+[Sources]
+ SimpleLibraryWithConstructorAndDestructor.c
+
+[Packages]
+ MdePkg/MdePkg.dec
+ UefiLessonsPkg/UefiLessonsPkg.dec
+
diff --git a/Lessons/Lesson_37/UefiLessonsPkg/SimpleLibraryUser/SimpleLibraryUser.c b/Lessons/Lesson_37/UefiLessonsPkg/SimpleLibraryUser/SimpleLibraryUser.c
new file mode 100644
index 0000000..9747b97
--- /dev/null
+++ b/Lessons/Lesson_37/UefiLessonsPkg/SimpleLibraryUser/SimpleLibraryUser.c
@@ -0,0 +1,16 @@
+#include <Library/UefiBootServicesTableLib.h>
+#include <Library/UefiLib.h>
+
+#include <Library/SimpleLibrary.h>
+
+EFI_STATUS
+EFIAPI
+UefiMain (
+ IN EFI_HANDLE ImageHandle,
+ IN EFI_SYSTEM_TABLE *SystemTable
+ )
+{
+ Print(L"%d\n", Plus2(3));
+
+ return EFI_SUCCESS;
+}
diff --git a/Lessons/Lesson_37/UefiLessonsPkg/SimpleLibraryUser/SimpleLibraryUser.inf b/Lessons/Lesson_37/UefiLessonsPkg/SimpleLibraryUser/SimpleLibraryUser.inf
new file mode 100644
index 0000000..d7e5be8
--- /dev/null
+++ b/Lessons/Lesson_37/UefiLessonsPkg/SimpleLibraryUser/SimpleLibraryUser.inf
@@ -0,0 +1,20 @@
+[Defines]
+ INF_VERSION = 1.25
+ BASE_NAME = SimpleLibraryUser
+ FILE_GUID = 22a1f57c-21ca-4011-9133-e3df0d01dace
+ MODULE_TYPE = UEFI_APPLICATION
+ VERSION_STRING = 1.0
+ ENTRY_POINT = UefiMain
+
+[Sources]
+ SimpleLibraryUser.c
+
+[Packages]
+ MdePkg/MdePkg.dec
+ UefiLessonsPkg/UefiLessonsPkg.dec
+
+[LibraryClasses]
+ UefiApplicationEntryPoint
+ UefiLib
+ SimpleLibrary
+
diff --git a/Lessons/Lesson_37/UefiLessonsPkg/UefiLessonsPkg.dec b/Lessons/Lesson_37/UefiLessonsPkg/UefiLessonsPkg.dec
new file mode 100644
index 0000000..cc355aa
--- /dev/null
+++ b/Lessons/Lesson_37/UefiLessonsPkg/UefiLessonsPkg.dec
@@ -0,0 +1,34 @@
+[Defines]
+ DEC_SPECIFICATION = 0x00010005
+ PACKAGE_NAME = UefiLessonsPkg
+ PACKAGE_GUID = 7e7edbba-ca2c-4177-a3f0-d3371358773a
+ PACKAGE_VERSION = 1.01
+
+[Includes]
+ Include
+
+[Guids]
+ # FILE_GUID as defined in UefiLessonsPkg/HelloWorld/HelloWorld.inf
+ gHelloWorldFileGuid = {0x2e55fa38, 0xf148, 0x42d3, {0xaf, 0x90, 0x1b, 0xe2, 0x47, 0x32, 0x3e, 0x30}}
+ gUefiLessonsPkgTokenSpaceGuid = {0x150cab53, 0xad47, 0x4385, {0xb5, 0xdd, 0xbc, 0xfc, 0x76, 0xba, 0xca, 0xf0}}
+
+[Protocols]
+
+[PcdsFixedAtBuild]
+ gUefiLessonsPkgTokenSpaceGuid.PcdMyVar32|42|UINT32|0x00000001
+ gUefiLessonsPkgTokenSpaceGuid.PcdMyVar32_1|42|UINT32|0x00000002
+ gUefiLessonsPkgTokenSpaceGuid.PcdMyVar32_2|42|UINT32|0x00000003
+ gUefiLessonsPkgTokenSpaceGuid.PcdMyVarBool|FALSE|BOOLEAN|0x00000004
+
+[PcdsPatchableInModule]
+ gUefiLessonsPkgTokenSpaceGuid.PcdMyPatchableVar32|0x31313131|UINT32|0x10000001
+
+[PcdsFeatureFlag]
+ gUefiLessonsPkgTokenSpaceGuid.PcdMyFeatureFlagVar|FALSE|BOOLEAN|0x20000001
+
+[PcdsDynamic]
+ gUefiLessonsPkgTokenSpaceGuid.PcdMyDynamicVar32|0x38323232|UINT32|0x30000001
+ gUefiLessonsPkgTokenSpaceGuid.PcdMyDynamicVar32_1|42|UINT32|0x30000002
+
+[PcdsDynamicEx]
+ gUefiLessonsPkgTokenSpaceGuid.PcdMyDynamicExVar32|0x38333333|UINT32|0x40000001
diff --git a/Lessons/Lesson_37/UefiLessonsPkg/UefiLessonsPkg.dsc b/Lessons/Lesson_37/UefiLessonsPkg/UefiLessonsPkg.dsc
new file mode 100644
index 0000000..cdd60c9
--- /dev/null
+++ b/Lessons/Lesson_37/UefiLessonsPkg/UefiLessonsPkg.dsc
@@ -0,0 +1,62 @@
+[Defines]
+ DSC_SPECIFICATION = 0x0001001C
+ PLATFORM_GUID = 3db7270f-ffac-4139-90a4-0ae68f3f8167
+ PLATFORM_VERSION = 0.01
+ PLATFORM_NAME = UefiLessonsPkg
+ SKUID_IDENTIFIER = DEFAULT
+ SUPPORTED_ARCHITECTURES = X64
+ BUILD_TARGETS = RELEASE
+
+
+[LibraryClasses]
+ UefiApplicationEntryPoint|MdePkg/Library/UefiApplicationEntryPoint/UefiApplicationEntryPoint.inf
+ UefiBootServicesTableLib|MdePkg/Library/UefiBootServicesTableLib/UefiBootServicesTableLib.inf
+ DebugLib|MdePkg/Library/UefiDebugLibConOut/UefiDebugLibConOut.inf
+ BaseLib|MdePkg/Library/BaseLib/BaseLib.inf
+ #PcdLib|MdePkg/Library/BasePcdLibNull/BasePcdLibNull.inf
+ PcdLib|MdePkg/Library/DxePcdLib/DxePcdLib.inf
+ BaseMemoryLib|MdePkg/Library/BaseMemoryLib/BaseMemoryLib.inf
+ RegisterFilterLib|MdePkg/Library/RegisterFilterLibNull/RegisterFilterLibNull.inf
+ PrintLib|MdePkg/Library/BasePrintLib/BasePrintLib.inf
+ DebugPrintErrorLevelLib|MdePkg/Library/BaseDebugPrintErrorLevelLib/BaseDebugPrintErrorLevelLib.inf
+ UefiLib|MdePkg/Library/UefiLib/UefiLib.inf
+ MemoryAllocationLib|MdePkg/Library/UefiMemoryAllocationLib/UefiMemoryAllocationLib.inf
+ DevicePathLib|MdePkg/Library/UefiDevicePathLib/UefiDevicePathLib.inf
+ UefiRuntimeServicesTableLib|MdePkg/Library/UefiRuntimeServicesTableLib/UefiRuntimeServicesTableLib.inf
+ ShellCEntryLib|ShellPkg/Library/UefiShellCEntryLib/UefiShellCEntryLib.inf
+ ShellLib|ShellPkg/Library/UefiShellLib/UefiShellLib.inf
+ FileHandleLib|MdePkg/Library/UefiFileHandleLib/UefiFileHandleLib.inf
+ HiiLib|MdeModulePkg/Library/UefiHiiLib/UefiHiiLib.inf
+ SortLib|MdeModulePkg/Library/UefiSortLib/UefiSortLib.inf
+ UefiHiiServicesLib|MdeModulePkg/Library/UefiHiiServicesLib/UefiHiiServicesLib.inf
+ #SimpleLibrary|UefiLessonsPkg/Library/SimpleLibrary/SimpleLibrary.inf
+ #SimpleLibrary|UefiLessonsPkg/Library/SimpleLibraryWithConstructor/SimpleLibraryWithConstructor.inf
+ SimpleLibrary|UefiLessonsPkg/Library/SimpleLibraryWithConstructorAndDestructor/SimpleLibraryWithConstructorAndDestructor.inf
+
+[Components]
+ UefiLessonsPkg/SimplestApp/SimplestApp.inf
+ UefiLessonsPkg/HelloWorld/HelloWorld.inf
+ UefiLessonsPkg/ImageHandle/ImageHandle.inf
+ UefiLessonsPkg/ImageInfo/ImageInfo.inf
+ UefiLessonsPkg/MemoryInfo/MemoryInfo.inf
+ UefiLessonsPkg/SimpleShellApp/SimpleShellApp.inf
+ UefiLessonsPkg/ListVariables/ListVariables.inf
+ UefiLessonsPkg/ShowBootVariables/ShowBootVariables.inf
+ UefiLessonsPkg/InteractiveApp/InteractiveApp.inf
+ #UefiLessonsPkg/GOPInfo/GOPInfo.inf
+ #UefiLessonsPkg/HiiMenu/HiiMenu.inf
+ #UefiLessonsPkg/TestGlyphs/TestGlyphs.inf
+ #UefiLessonsPkg/ShowHii/ShowHii.inf
+ UefiLessonsPkg/PCDLesson/PCDLesson.inf
+ UefiLessonsPkg/ShowTables/ShowTables.inf
+ UefiLessonsPkg/AcpiInfo/AcpiInfo.inf
+ UefiLessonsPkg/SaveBGRT/SaveBGRT.inf
+ UefiLessonsPkg/ListPCI/ListPCI.inf
+ UefiLessonsPkg/PCIRomInfo/PCIRomInfo.inf
+ UefiLessonsPkg/Library/SimpleLibrary/SimpleLibrary.inf
+ UefiLessonsPkg/Library/SimpleLibraryWithConstructor/SimpleLibraryWithConstructor.inf
+ UefiLessonsPkg/SimpleLibraryUser/SimpleLibraryUser.inf
+
+[PcdsFixedAtBuild]
+ gUefiLessonsPkgTokenSpaceGuid.PcdMyVar32_2|44
+