aboutsummaryrefslogtreecommitdiffstats
path: root/UefiLessonsPkg
diff options
context:
space:
mode:
authorKonstantin Aladyshev <aladyshev22@gmail.com>2022-08-31 16:26:50 +0300
committerKonstantin Aladyshev <aladyshev22@gmail.com>2022-08-31 16:26:50 +0300
commit4a40f4cc0e45de28898cdad1b605cc4ca4be2710 (patch)
tree764a4148ed1e7aa01edc92cd6ffb4187731e37a5 /UefiLessonsPkg
parent98fed58216884e79a1ff4814a0abb366361d9e1a (diff)
downloadUEFI-Lessons-4a40f4cc0e45de28898cdad1b605cc4ca4be2710.tar.gz
UEFI-Lessons-4a40f4cc0e45de28898cdad1b605cc4ca4be2710.tar.bz2
UEFI-Lessons-4a40f4cc0e45de28898cdad1b605cc4ca4be2710.zip
Finish SKU lesson
Signed-off-by: Konstantin Aladyshev <aladyshev22@gmail.com>
Diffstat (limited to 'UefiLessonsPkg')
-rw-r--r--UefiLessonsPkg/SetSku/SetSku.c72
-rw-r--r--UefiLessonsPkg/SetSku/SetSku.inf17
-rw-r--r--UefiLessonsPkg/UefiLessonsPkg.dsc1
3 files changed, 90 insertions, 0 deletions
diff --git a/UefiLessonsPkg/SetSku/SetSku.c b/UefiLessonsPkg/SetSku/SetSku.c
new file mode 100644
index 0000000..8683947
--- /dev/null
+++ b/UefiLessonsPkg/SetSku/SetSku.c
@@ -0,0 +1,72 @@
+#include <Library/UefiBootServicesTableLib.h>
+#include <Library/UefiLib.h>
+
+#include <Pi/PiMultiPhase.h>
+#include <Protocol/PiPcd.h>
+#include <Protocol/PiPcdInfo.h>
+
+//#include <Library/PcdLib.h>
+
+VOID Usage()
+{
+ Print(L"Program to set Sku number\n\n");
+ Print(L" Usage: SetSku <SkuNumber in hex>\n");
+}
+
+INTN
+EFIAPI
+ShellAppMain (
+ IN UINTN Argc,
+ IN CHAR16 **Argv
+ )
+{
+ EFI_STATUS Status;
+
+ if (Argc != 2) {
+ Usage();
+ return EFI_INVALID_PARAMETER;
+ }
+
+ UINTN SkuNumber;
+ RETURN_STATUS ReturnStatus;
+ ReturnStatus = StrHexToUintnS(Argv[1], NULL, &SkuNumber);
+ if (RETURN_ERROR(ReturnStatus)) {
+ Print(L"Error! Can't convert SkuId string to number\n");
+ return EFI_INVALID_PARAMETER;
+ }
+
+ EFI_PCD_PROTOCOL* pcdProtocol;
+ Status = gBS->LocateProtocol(&gEfiPcdProtocolGuid,
+ NULL,
+ (VOID **)&pcdProtocol);
+ if (EFI_ERROR(Status)) {
+ Print(L"Error! Can't find EFI_PCD_PROTOCOL\n");
+ return EFI_UNSUPPORTED;
+ }
+
+ EFI_GET_PCD_INFO_PROTOCOL* getPcdInfoProtocol;
+ Status = gBS->LocateProtocol(&gEfiGetPcdInfoProtocolGuid,
+ NULL,
+ (VOID **)&getPcdInfoProtocol);
+ if (EFI_ERROR(Status)) {
+ Print(L"Error! Can't find EFI_GET_PCD_INFO_PROTOCOL\n");
+ return EFI_UNSUPPORTED;
+ }
+
+
+ pcdProtocol->SetSku(SkuNumber);
+
+ UINTN SkuId = getPcdInfoProtocol->GetSku();
+/*
+ LibPcdSetSku(SkuNumber);
+ UINTN SkuId = LibPcdGetSku();
+*/
+ if (SkuId != SkuNumber) {
+ Print(L"Failed to change SkuId to 0x%lx, SkuId is still 0x%lx\n", SkuNumber, SkuId);
+ return EFI_UNSUPPORTED;
+ }
+
+ Print(L"Sku is changed successfully to 0x%lx\n", SkuNumber);
+
+ return EFI_SUCCESS;
+}
diff --git a/UefiLessonsPkg/SetSku/SetSku.inf b/UefiLessonsPkg/SetSku/SetSku.inf
new file mode 100644
index 0000000..b14aed8
--- /dev/null
+++ b/UefiLessonsPkg/SetSku/SetSku.inf
@@ -0,0 +1,17 @@
+[Defines]
+ INF_VERSION = 1.25
+ BASE_NAME = SetSku
+ FILE_GUID = 8cb96f21-d1dc-4f4a-8064-c3a5b556f73a
+ MODULE_TYPE = UEFI_APPLICATION
+ VERSION_STRING = 1.0
+ ENTRY_POINT = ShellCEntryLib
+
+[Sources]
+ SetSku.c
+
+[Packages]
+ MdePkg/MdePkg.dec
+
+[LibraryClasses]
+ ShellCEntryLib
+ UefiLib
diff --git a/UefiLessonsPkg/UefiLessonsPkg.dsc b/UefiLessonsPkg/UefiLessonsPkg.dsc
index e3eb498..7be25fe 100644
--- a/UefiLessonsPkg/UefiLessonsPkg.dsc
+++ b/UefiLessonsPkg/UefiLessonsPkg.dsc
@@ -83,6 +83,7 @@
UefiLessonsPkg/HIIFormDataElements/HIIFormDataElements.inf
UefiLessonsPkg/HIIFormLabel/HIIFormLabel.inf
UefiLessonsPkg/FfsFile/FfsFile.inf
+ UefiLessonsPkg/SetSku/SetSku.inf
[PcdsFixedAtBuild]
gUefiLessonsPkgTokenSpaceGuid.PcdInt8|0x88|UINT8|0x3B81CDF1