From 6064c1e48b622f53538f4df9bdd402c607a87d51 Mon Sep 17 00:00:00 2001 From: Konstantin Aladyshev Date: Sat, 10 Jul 2021 00:04:40 +0300 Subject: Move lessons to separate folder Signed-off-by: Konstantin Aladyshev --- .../ShowBootVariables/ShowBootVariables.c | 93 ---------------------- 1 file changed, 93 deletions(-) delete mode 100644 Lesson_16/UefiLessonsPkg/ShowBootVariables/ShowBootVariables.c (limited to 'Lesson_16/UefiLessonsPkg/ShowBootVariables/ShowBootVariables.c') diff --git a/Lesson_16/UefiLessonsPkg/ShowBootVariables/ShowBootVariables.c b/Lesson_16/UefiLessonsPkg/ShowBootVariables/ShowBootVariables.c deleted file mode 100644 index 7f6b58c..0000000 --- a/Lesson_16/UefiLessonsPkg/ShowBootVariables/ShowBootVariables.c +++ /dev/null @@ -1,93 +0,0 @@ -#include -#include - -#include -#include - -#include -#include - - -EFI_STATUS -GetNvramVariable( CHAR16 *VariableName, - EFI_GUID *VariableOwnerGuid, - VOID **Buffer, - UINTN *BufferSize) -{ - UINTN Size = 0; - *BufferSize = 0; - - EFI_STATUS Status = gRT->GetVariable(VariableName, VariableOwnerGuid, NULL, &Size, NULL); - if (Status != EFI_BUFFER_TOO_SMALL) { - Print(L"Error! 'gRT->GetVariable' call returned %r\n", Status); - return Status; - } - - *Buffer = AllocateZeroPool(Size); - if (!Buffer) { - Print(L"Error! 'AllocateZeroPool' call returned %r\n", Status); - return EFI_OUT_OF_RESOURCES; - } - - Status = gRT->GetVariable(VariableName, VariableOwnerGuid, NULL, &Size, *Buffer); - if (Status == EFI_SUCCESS) { - *BufferSize = Size; - } else { - FreePool( *Buffer ); - *Buffer = NULL; - } - - return Status; -} - - -VOID PrintBootOption(CHAR16* BootOptionName) -{ - UINTN OptionSize; - UINT8* Buffer; - - EFI_STATUS Status = GetNvramVariable(BootOptionName, &gEfiGlobalVariableGuid, (VOID**)&Buffer, &OptionSize); - if (Status == EFI_SUCCESS) { - EFI_LOAD_OPTION* LoadOption = (EFI_LOAD_OPTION*) Buffer; - CHAR16* Description = (CHAR16*)(Buffer + sizeof (EFI_LOAD_OPTION)); - UINTN DescriptionSize = StrSize(Description); - - Print(L"%s\n", Description); - if (LoadOption->FilePathListLength != 0) { - VOID* FilePathList = (UINT8 *)Description + DescriptionSize; - CHAR16* DevPathString = ConvertDevicePathToText(FilePathList, TRUE, FALSE); - Print(L"%s\n", DevPathString); - } - } else { - Print(L"Can't get %s variable\n", BootOptionName); - } -} - - -INTN EFIAPI ShellAppMain(IN UINTN Argc, IN CHAR16 **Argv) -{ - UINTN OptionSize; - EFI_STATUS Status; - - UINT16* BootCurrent; - Status = GetNvramVariable(L"BootCurrent", &gEfiGlobalVariableGuid, (VOID**)&BootCurrent, &OptionSize); - if (Status != EFI_SUCCESS) { - Print(L"Can't get BootCurrent variable\n"); - } - - UINT16* BootOrderArray; - Status = GetNvramVariable(L"BootOrder", &gEfiGlobalVariableGuid, (VOID**)&BootOrderArray, &OptionSize); - if (Status == EFI_SUCCESS) { - for (UINTN i=0; i<(OptionSize/sizeof(UINT16)); i++) { - CHAR16 BootOptionStr[sizeof("Boot####")+1]; - UnicodeSPrint(BootOptionStr, (sizeof("Boot####")+1)*sizeof(CHAR16), L"Boot%04x", BootOrderArray[i]); - Print(L"%s%s\n", BootOptionStr, (BootOrderArray[i] == *BootCurrent)? L"*" : L"" ); - PrintBootOption(BootOptionStr); - Print(L"\n"); - } - } else { - Print(L"Can't get BootOrder variable\n"); - } - - return EFI_SUCCESS; -} -- cgit v1.2.3-18-g5258