From 4a40f4cc0e45de28898cdad1b605cc4ca4be2710 Mon Sep 17 00:00:00 2001 From: Konstantin Aladyshev Date: Wed, 31 Aug 2022 16:26:50 +0300 Subject: Finish SKU lesson Signed-off-by: Konstantin Aladyshev --- UefiLessonsPkg/SetSku/SetSku.c | 72 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 72 insertions(+) create mode 100644 UefiLessonsPkg/SetSku/SetSku.c (limited to 'UefiLessonsPkg/SetSku/SetSku.c') 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 +#include + +#include +#include +#include + +//#include + +VOID Usage() +{ + Print(L"Program to set Sku number\n\n"); + Print(L" Usage: SetSku \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; +} -- cgit v1.2.3-18-g5258