/* * Copyright (c) 2021, Konstantin Aladyshev * * SPDX-License-Identifier: MIT */ #include #include #include VOID Usage() { Print(L"Delete variable\n"); Print(L" SetVariableExample \n"); Print(L"\n"); Print(L"Set variable\n"); Print(L" SetVariableExample \n"); Print(L"\n"); Print(L" can be \n"); Print(L"n - NON_VOLATILE\n"); Print(L"b - BOOTSERVICE_ACCESS\n"); Print(L"r - RUNTIME_ACCESS\n"); } INTN EFIAPI ShellAppMain(IN UINTN Argc, IN CHAR16 **Argv) { EFI_STATUS Status; if (Argc==2) { CHAR16* VariableName = Argv[1]; Status = gRT->SetVariable ( VariableName, &gEfiCallerIdGuid, 0, 0, NULL ); if (EFI_ERROR (Status)) { Print(L"%r\n", Status); } else { Print(L"Variable %s was successfully deleted\n", VariableName); } return Status; } else if (Argc==4) { CHAR16* VariableName = Argv[1]; CHAR16* AttributesStr = Argv[2]; CHAR16* Value = Argv[3]; UINT32 Attributes = 0; for (UINTN i=0; iSetVariable ( VariableName, &gEfiCallerIdGuid, Attributes, StrSize(Value), Value ); if (EFI_ERROR (Status)) { Print(L"%r\n", Status); } else { Print(L"Variable %s was successfully changed\n", VariableName); } return Status; } else { Usage(); } return EFI_SUCCESS; }