X-Git-Url: https://git.proxmox.com/?a=blobdiff_plain;f=ShellPkg%2FLibrary%2FUefiShellDebug1CommandsLib%2FDmpStore.c;h=bb2c0b98ec6fdceccb383ad1734ef0649240fdac;hb=26ca6f7e1e2f3ba247d1d3150d6bfb22043a8cda;hp=6332416c8815427adfe8a4e43c0d7c4ae63b6136;hpb=7e63fc9de941fd4e7d075feb5267f5cf96a80d45;p=mirror_edk2.git diff --git a/ShellPkg/Library/UefiShellDebug1CommandsLib/DmpStore.c b/ShellPkg/Library/UefiShellDebug1CommandsLib/DmpStore.c index 6332416c88..bb2c0b98ec 100644 --- a/ShellPkg/Library/UefiShellDebug1CommandsLib/DmpStore.c +++ b/ShellPkg/Library/UefiShellDebug1CommandsLib/DmpStore.c @@ -1,7 +1,8 @@ /** @file Main file for DmpStore shell Debug1 function. - - Copyright (c) 2005 - 2014, Intel Corporation. All rights reserved.
+ + (C) Copyright 2013-2015 Hewlett-Packard Development Company, L.P.
+ Copyright (c) 2005 - 2016, Intel Corporation. All rights reserved.
This program and the accompanying materials are licensed and made available under the terms and conditions of the BSD License which accompanies this distribution. The full text of the license may be found at @@ -41,7 +42,6 @@ typedef struct { @retval The attribute string info. **/ CHAR16 * -EFIAPI GetAttrType ( IN CONST UINT32 Atts ) @@ -56,7 +56,7 @@ GetAttrType ( StrnCatGrow (&RetString, &BufLen, L"+NV", 0); } if ((Atts & EFI_VARIABLE_RUNTIME_ACCESS) != 0) { - StrnCatGrow (&RetString, &BufLen, L"+RS+BS", 0); + StrnCatGrow (&RetString, &BufLen, L"+RT+BS", 0); } else if ((Atts & EFI_VARIABLE_BOOTSERVICE_ACCESS) != 0) { StrnCatGrow (&RetString, &BufLen, L"+BS", 0); } @@ -81,6 +81,42 @@ GetAttrType ( return RetString; } +/** + Convert binary to hex format string. + + @param[in] Buffer The binary data. + @param[in] BufferSize The size in bytes of the binary data. + @param[in, out] HexString Hex format string. + @param[in] HexStringSize The size in bytes of the string. + + @return The hex format string. +**/ +CHAR16* +BinaryToHexString ( + IN VOID *Buffer, + IN UINTN BufferSize, + IN OUT CHAR16 *HexString, + IN UINTN HexStringSize + ) +{ + UINTN Index; + UINTN StringIndex; + + ASSERT (Buffer != NULL); + ASSERT ((BufferSize * 2 + 1) * sizeof (CHAR16) <= HexStringSize); + + for (Index = 0, StringIndex = 0; Index < BufferSize; Index += 1) { + StringIndex += + UnicodeSPrint ( + &HexString[StringIndex], + HexStringSize - StringIndex * sizeof (CHAR16), + L"%02x", + ((UINT8 *) Buffer)[Index] + ); + } + return HexString; +} + /** Load the variable data from file and set to variable data base. @@ -89,11 +125,12 @@ GetAttrType ( @param[in] Guid The guid of the variables to be loaded. @param[out] Found TRUE when at least one variable was loaded and set. - @retval EFI_VOLUME_CORRUPTED The file is in bad format. - @retval EFI_OUT_OF_RESOURCES There is not enough memory to perform the operation. - @retval EFI_SUCCESS Successfully load and set the variables. + @retval SHELL_DEVICE_ERROR Cannot access the file. + @retval SHELL_VOLUME_CORRUPTED The file is in bad format. + @retval SHELL_OUT_OF_RESOURCES There is not enough memory to perform the operation. + @retval SHELL_SUCCESS Successfully load and set the variables. **/ -EFI_STATUS +SHELL_STATUS LoadVariablesFromFile ( IN SHELL_FILE_HANDLE FileHandle, IN CONST CHAR16 *Name, @@ -102,6 +139,7 @@ LoadVariablesFromFile ( ) { EFI_STATUS Status; + SHELL_STATUS ShellStatus; UINT32 NameSize; UINT32 DataSize; UINTN BufferSize; @@ -117,9 +155,11 @@ LoadVariablesFromFile ( Status = ShellGetFileSize (FileHandle, &FileSize); if (EFI_ERROR (Status)) { - return Status; + return SHELL_DEVICE_ERROR; } - + + ShellStatus = SHELL_SUCCESS; + InitializeListHead (&List); Position = 0; @@ -130,7 +170,7 @@ LoadVariablesFromFile ( BufferSize = sizeof (NameSize); Status = ShellReadFile (FileHandle, &BufferSize, &NameSize); if (EFI_ERROR (Status) || (BufferSize != sizeof (NameSize))) { - Status = EFI_VOLUME_CORRUPTED; + ShellStatus = SHELL_VOLUME_CORRUPTED; break; } @@ -140,7 +180,7 @@ LoadVariablesFromFile ( BufferSize = sizeof (DataSize); Status = ShellReadFile (FileHandle, &BufferSize, &DataSize); if (EFI_ERROR (Status) || (BufferSize != sizeof (DataSize))) { - Status = EFI_VOLUME_CORRUPTED; + ShellStatus = SHELL_VOLUME_CORRUPTED; break; } @@ -151,13 +191,13 @@ LoadVariablesFromFile ( BufferSize = sizeof (NameSize) + sizeof (DataSize) + RemainingSize; Buffer = AllocatePool (BufferSize); if (Buffer == NULL) { - Status = EFI_OUT_OF_RESOURCES; + ShellStatus = SHELL_OUT_OF_RESOURCES; break; } BufferSize = RemainingSize; Status = ShellReadFile (FileHandle, &BufferSize, (UINT32 *) Buffer + 2); if (EFI_ERROR (Status) || (BufferSize != RemainingSize)) { - Status = EFI_VOLUME_CORRUPTED; + ShellStatus = SHELL_VOLUME_CORRUPTED; FreePool (Buffer); break; } @@ -175,7 +215,7 @@ LoadVariablesFromFile ( ); if (Crc32 != * (UINT32 *) (Buffer + BufferSize)) { FreePool (Buffer); - Status = EFI_VOLUME_CORRUPTED; + ShellStatus = SHELL_VOLUME_CORRUPTED; break; } @@ -184,7 +224,7 @@ LoadVariablesFromFile ( Variable = AllocateZeroPool (sizeof (*Variable) + NameSize + DataSize); if (Variable == NULL) { FreePool (Buffer); - Status = EFI_OUT_OF_RESOURCES; + ShellStatus = SHELL_OUT_OF_RESOURCES; break; } Variable->Signature = DMP_STORE_VARIABLE_SIGNATURE; @@ -200,13 +240,15 @@ LoadVariablesFromFile ( FreePool (Buffer); } - if ((Position != FileSize) || EFI_ERROR (Status)) { - ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_DMPSTORE_LOAD_BAD_FILE), gShellDebug1HiiHandle); - Status = EFI_VOLUME_CORRUPTED; + if ((Position != FileSize) || (ShellStatus != SHELL_SUCCESS)) { + ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_DMPSTORE_LOAD_BAD_FILE), gShellDebug1HiiHandle, L"dmpstore"); + if (Position != FileSize) { + ShellStatus = SHELL_VOLUME_CORRUPTED; + } } for ( Link = GetFirstNode (&List) - ; !IsNull (&List, Link) && !EFI_ERROR (Status) + ; !IsNull (&List, Link) && (ShellStatus == SHELL_SUCCESS) ; Link = GetNextNode (&List, Link) ) { Variable = CR (Link, DMP_STORE_VARIABLE, Link, DMP_STORE_VARIABLE_SIGNATURE); @@ -230,11 +272,7 @@ LoadVariablesFromFile ( Variable->Data ); if (EFI_ERROR (Status)) { - ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_DMPSTORE_LOAD_GEN_FAIL), gShellDebug1HiiHandle, Variable->Name, Status); - // - // continue set variable upon failure - // - Status = EFI_SUCCESS; + ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_DMPSTORE_LOAD_GEN_FAIL), gShellDebug1HiiHandle, L"dmpstore", Variable->Name, Status); } } } @@ -245,7 +283,7 @@ LoadVariablesFromFile ( FreePool (Variable); } - return Status; + return ShellStatus; } /** @@ -332,7 +370,7 @@ AppendSingleVariableToFile ( FreePool (Buffer); if (!EFI_ERROR (Status) && - (BufferSize != sizeof (NameSize) + sizeof (DataSize) + sizeof (*Guid) + sizeof (Attributes) + NameSize + DataSize) + (BufferSize != sizeof (NameSize) + sizeof (DataSize) + sizeof (*Guid) + sizeof (Attributes) + NameSize + DataSize + sizeof (UINT32)) ) { Status = EFI_DEVICE_ERROR; } @@ -348,14 +386,15 @@ AppendSingleVariableToFile ( This is necessary since once a delete happens GetNextVariableName() will work. - @param[in] Name The variable name of the EFI variable (or NULL). - @param[in] Guid The GUID of the variable set (or NULL). - @param[in] Type The operation type. - @param[in] FileHandle The file to operate on (or NULL). - @param[in] PrevName The previous variable name from GetNextVariableName. L"" to start. - @param[in] FoundVarGuid The previous GUID from GetNextVariableName. ignored at start. - @param[in] FoundOne If a VariableName or Guid was specified and one was printed or - deleted, then set this to TRUE, otherwise ignored. + @param[in] Name The variable name of the EFI variable (or NULL). + @param[in] Guid The GUID of the variable set (or NULL). + @param[in] Type The operation type. + @param[in] FileHandle The file to operate on (or NULL). + @param[in] PrevName The previous variable name from GetNextVariableName. L"" to start. + @param[in] FoundVarGuid The previous GUID from GetNextVariableName. ignored at start. + @param[in] FoundOne If a VariableName or Guid was specified and one was printed or + deleted, then set this to TRUE, otherwise ignored. + @param[in] StandardFormatOutput TRUE indicates Standard-Format Output. @retval SHELL_SUCCESS The operation was successful. @retval SHELL_OUT_OF_RESOURCES A memorty allocation failed. @@ -364,7 +403,6 @@ AppendSingleVariableToFile ( @retval SHELL_NOT_FOUND the Name/Guid pair could not be found. **/ SHELL_STATUS -EFIAPI CascadeProcessVariables ( IN CONST CHAR16 *Name OPTIONAL, IN CONST EFI_GUID *Guid OPTIONAL, @@ -372,7 +410,8 @@ CascadeProcessVariables ( IN EFI_FILE_PROTOCOL *FileHandle OPTIONAL, IN CONST CHAR16 * CONST PrevName, IN EFI_GUID FoundVarGuid, - IN BOOLEAN *FoundOne + IN BOOLEAN *FoundOne, + IN BOOLEAN StandardFormatOutput ) { EFI_STATUS Status; @@ -382,7 +421,9 @@ CascadeProcessVariables ( UINT32 Atts; SHELL_STATUS ShellStatus; UINTN NameSize; - CHAR16 *RetString; + CHAR16 *AttrString; + CHAR16 *HexString; + EFI_STATUS SetStatus; if (ShellGetExecutionBreakFlag()) { return (SHELL_ABORTED); @@ -403,7 +444,7 @@ CascadeProcessVariables ( FoundVarName = AllocateZeroPool (NameSize); if (FoundVarName != NULL) { if (PrevName != NULL) { - StrCpy(FoundVarName, PrevName); + StrnCpyS(FoundVarName, NameSize/sizeof(CHAR16), PrevName, NameSize/sizeof(CHAR16) - 1); } Status = gRT->GetNextVariableName (&NameSize, FoundVarName, &FoundVarGuid); @@ -426,7 +467,12 @@ CascadeProcessVariables ( // // Recurse to the next iteration. We know "our" variable's name. // - ShellStatus = CascadeProcessVariables(Name, Guid, Type, FileHandle, FoundVarName, FoundVarGuid, FoundOne); + ShellStatus = CascadeProcessVariables (Name, Guid, Type, FileHandle, FoundVarName, FoundVarGuid, FoundOne, StandardFormatOutput); + + if (ShellGetExecutionBreakFlag() || (ShellStatus == SHELL_ABORTED)) { + SHELL_FREE_NON_NULL(FoundVarName); + return (SHELL_ABORTED); + } // // No matter what happened we process our own variable @@ -453,50 +499,70 @@ CascadeProcessVariables ( Status = gRT->GetVariable (FoundVarName, &FoundVarGuid, &Atts, &DataSize, DataBuffer); } } - if ((Type == DmpStoreDisplay) || (Type == DmpStoreSave)) { // // Last error check then print this variable out. // - if (!EFI_ERROR(Status) && DataBuffer != NULL) { - RetString = GetAttrType(Atts); - ShellPrintHiiEx( - -1, - -1, - NULL, - STRING_TOKEN(STR_DMPSTORE_HEADER_LINE), - gShellDebug1HiiHandle, - RetString, - &FoundVarGuid, - FoundVarName, - DataSize); - if (Type == DmpStoreDisplay) { - DumpHex(2, 0, DataSize, DataBuffer); + if (Type == DmpStoreDisplay) { + if (!EFI_ERROR(Status) && (DataBuffer != NULL) && (FoundVarName != NULL)) { + AttrString = GetAttrType(Atts); + if (StandardFormatOutput) { + HexString = AllocatePool ((DataSize * 2 + 1) * sizeof (CHAR16)); + if (HexString != NULL) { + ShellPrintHiiEx ( + -1, -1, NULL, STRING_TOKEN (STR_DMPSTORE_VAR_SFO), gShellDebug1HiiHandle, + FoundVarName, &FoundVarGuid, Atts, DataSize, + BinaryToHexString ( + DataBuffer, DataSize, HexString, (DataSize * 2 + 1) * sizeof (CHAR16) + ) + ); + FreePool (HexString); + } else { + Status = EFI_OUT_OF_RESOURCES; + } } else { - Status = AppendSingleVariableToFile ( - FileHandle, - FoundVarName, - &FoundVarGuid, - Atts, - (UINT32) DataSize, - DataBuffer - ); + ShellPrintHiiEx ( + -1, -1, NULL, STRING_TOKEN (STR_DMPSTORE_HEADER_LINE), gShellDebug1HiiHandle, + AttrString, &FoundVarGuid, FoundVarName, DataSize + ); + DumpHex (2, 0, DataSize, DataBuffer); } - SHELL_FREE_NON_NULL(RetString); + SHELL_FREE_NON_NULL (AttrString); + } + } else if (Type == DmpStoreSave) { + if (!EFI_ERROR(Status) && (DataBuffer != NULL) && (FoundVarName != NULL)) { + AttrString = GetAttrType (Atts); + ShellPrintHiiEx ( + -1, -1, NULL, STRING_TOKEN (STR_DMPSTORE_HEADER_LINE), gShellDebug1HiiHandle, + AttrString, &FoundVarGuid, FoundVarName, DataSize + ); + Status = AppendSingleVariableToFile ( + FileHandle, + FoundVarName, + &FoundVarGuid, + Atts, + (UINT32) DataSize, + DataBuffer + ); + SHELL_FREE_NON_NULL (AttrString); } } else if (Type == DmpStoreDelete) { // // We only need name to delete it... // - ShellPrintHiiEx ( - -1, - -1, - NULL, - STRING_TOKEN(STR_DMPSTORE_DELETE_LINE), - gShellDebug1HiiHandle, - &FoundVarGuid, - FoundVarName, - gRT->SetVariable (FoundVarName, &FoundVarGuid, Atts, 0, NULL) - ); + SetStatus = gRT->SetVariable (FoundVarName, &FoundVarGuid, Atts, 0, NULL); + if (StandardFormatOutput) { + if (SetStatus == EFI_SUCCESS) { + ShellPrintHiiEx ( + -1, -1, NULL, STRING_TOKEN (STR_DMPSTORE_NO_VAR_FOUND_NG_SFO), gShellDebug1HiiHandle, + FoundVarName, &FoundVarGuid + ); + } + } else { + ShellPrintHiiEx ( + -1, -1, NULL, STRING_TOKEN (STR_DMPSTORE_DELETE_LINE), gShellDebug1HiiHandle, + &FoundVarGuid, FoundVarName, SetStatus + ); + } } SHELL_FREE_NON_NULL(DataBuffer); } @@ -517,10 +583,11 @@ CascadeProcessVariables ( /** Function to display or delete variables. This will set up and call into the recursive function. - @param[in] Name The variable name of the EFI variable (or NULL). - @param[in] Guid The GUID of the variable set (or NULL). - @param[in] Type The operation type. - @param[in] FileHandle The file to save or load variables. + @param[in] Name The variable name of the EFI variable (or NULL). + @param[in] Guid The GUID of the variable set (or NULL). + @param[in] Type The operation type. + @param[in] FileHandle The file to save or load variables. + @param[in] StandardFormatOutput TRUE indicates Standard-Format Output. @retval SHELL_SUCCESS The operation was successful. @retval SHELL_OUT_OF_RESOURCES A memorty allocation failed. @@ -529,12 +596,12 @@ CascadeProcessVariables ( @retval SHELL_NOT_FOUND the Name/Guid pair could not be found. **/ SHELL_STATUS -EFIAPI ProcessVariables ( IN CONST CHAR16 *Name OPTIONAL, IN CONST EFI_GUID *Guid OPTIONAL, IN DMP_STORE_TYPE Type, - IN SHELL_FILE_HANDLE FileHandle OPTIONAL + IN SHELL_FILE_HANDLE FileHandle OPTIONAL, + IN BOOLEAN StandardFormatOutput ) { SHELL_STATUS ShellStatus; @@ -545,24 +612,40 @@ ProcessVariables ( ShellStatus = SHELL_SUCCESS; ZeroMem (&FoundVarGuid, sizeof(EFI_GUID)); + if (StandardFormatOutput) { + ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN(STR_GEN_SFO_HEADER), gShellDebug1HiiHandle, L"dmpstore"); + } + if (Type == DmpStoreLoad) { ShellStatus = LoadVariablesFromFile (FileHandle, Name, Guid, &Found); } else { - ShellStatus = CascadeProcessVariables(Name, Guid, Type, FileHandle, NULL, FoundVarGuid, &Found); + ShellStatus = CascadeProcessVariables (Name, Guid, Type, FileHandle, NULL, FoundVarGuid, &Found, StandardFormatOutput); } if (!Found) { if (ShellStatus == SHELL_OUT_OF_RESOURCES) { - ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_OUT_MEM), gShellDebug1HiiHandle); + ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_OUT_MEM), gShellDebug1HiiHandle, L"dmpstore"); return (ShellStatus); } else if (Name != NULL && Guid == NULL) { - ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_DMPSTORE_NO_VAR_FOUND_N), gShellDebug1HiiHandle, Name); + if (StandardFormatOutput) { + ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_DMPSTORE_NO_VAR_FOUND_N_SFO), gShellDebug1HiiHandle, Name); + } else { + ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_DMPSTORE_NO_VAR_FOUND_N), gShellDebug1HiiHandle, L"dmpstore", Name); + } } else if (Name != NULL && Guid != NULL) { - ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_DMPSTORE_NO_VAR_FOUND_GN), gShellDebug1HiiHandle, Guid, Name); + ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_DMPSTORE_NO_VAR_FOUND_GN), gShellDebug1HiiHandle, L"dmpstore", Guid, Name); } else if (Name == NULL && Guid == NULL) { - ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_DMPSTORE_NO_VAR_FOUND), gShellDebug1HiiHandle); + if (StandardFormatOutput) { + ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_DMPSTORE_NO_VAR_FOUND_SFO), gShellDebug1HiiHandle); + } else { + ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_DMPSTORE_NO_VAR_FOUND), gShellDebug1HiiHandle, L"dmpstore"); + } } else if (Name == NULL && Guid != NULL) { - ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_DMPSTORE_NO_VAR_FOUND_G), gShellDebug1HiiHandle, Guid); + if (StandardFormatOutput) { + ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_DMPSTORE_NO_VAR_FOUND_G_SFO), gShellDebug1HiiHandle, Guid); + } else { + ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_DMPSTORE_NO_VAR_FOUND_G), gShellDebug1HiiHandle, L"dmpstore", Guid); + } } return (SHELL_NOT_FOUND); } @@ -575,6 +658,7 @@ STATIC CONST SHELL_PARAM_ITEM ParamList[] = { {L"-s", TypeValue}, {L"-all", TypeFlag}, {L"-guid", TypeValue}, + {L"-sfo", TypeFlag}, {NULL, TypeMax} }; @@ -603,17 +687,19 @@ ShellCommandRunDmpStore ( DMP_STORE_TYPE Type; SHELL_FILE_HANDLE FileHandle; EFI_FILE_INFO *FileInfo; + BOOLEAN StandardFormatOutput; - ShellStatus = SHELL_SUCCESS; - Package = NULL; - FileHandle = NULL; - File = NULL; - Type = DmpStoreDisplay; + ShellStatus = SHELL_SUCCESS; + Package = NULL; + FileHandle = NULL; + File = NULL; + Type = DmpStoreDisplay; + StandardFormatOutput = FALSE; Status = ShellCommandLineParse (ParamList, &Package, &ProblemParam, TRUE); if (EFI_ERROR(Status)) { if (Status == EFI_VOLUME_CORRUPTED && ProblemParam != NULL) { - ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_PROBLEM), gShellDebug1HiiHandle, ProblemParam); + ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_PROBLEM), gShellDebug1HiiHandle, L"dmpstore", ProblemParam); FreePool(ProblemParam); ShellStatus = SHELL_INVALID_PARAMETER; } else { @@ -621,41 +707,51 @@ ShellCommandRunDmpStore ( } } else { if (ShellCommandLineGetCount(Package) > 2) { - ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_TOO_MANY), gShellDebug1HiiHandle); + ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_TOO_MANY), gShellDebug1HiiHandle, L"dmpstore"); ShellStatus = SHELL_INVALID_PARAMETER; } else if (ShellCommandLineGetFlag(Package, L"-all") && ShellCommandLineGetFlag(Package, L"-guid")) { - ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_PARAM_CONFLICT), gShellDebug1HiiHandle, L"-all", L"-guid"); + ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_PARAM_CONFLICT), gShellDebug1HiiHandle, L"dmpstore", L"-all", L"-guid"); ShellStatus = SHELL_INVALID_PARAMETER; } else if (ShellCommandLineGetFlag(Package, L"-s") && ShellCommandLineGetFlag(Package, L"-l")) { - ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_PARAM_CONFLICT), gShellDebug1HiiHandle, L"-l", L"-s"); + ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_PARAM_CONFLICT), gShellDebug1HiiHandle, L"dmpstore", L"-l", L"-s"); ShellStatus = SHELL_INVALID_PARAMETER; } else if ((ShellCommandLineGetFlag(Package, L"-s") || ShellCommandLineGetFlag(Package, L"-l")) && ShellCommandLineGetFlag(Package, L"-d")) { - ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_PARAM_CONFLICT), gShellDebug1HiiHandle, L"-l or -s", L"-d"); + ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_PARAM_CONFLICT), gShellDebug1HiiHandle, L"dmpstore", L"-l or -s", L"-d"); + ShellStatus = SHELL_INVALID_PARAMETER; + } else if ((ShellCommandLineGetFlag(Package, L"-s") || ShellCommandLineGetFlag(Package, L"-l")) && ShellCommandLineGetFlag(Package, L"-sfo")) { + ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_PARAM_CONFLICT), gShellDebug1HiiHandle, L"dmpstore", L"-l or -s", L"-sfo"); ShellStatus = SHELL_INVALID_PARAMETER; } else { + // + // Determine the GUID to search for based on -all and -guid parameters + // if (!ShellCommandLineGetFlag(Package, L"-all")) { GuidStr = ShellCommandLineGetValue(Package, L"-guid"); if (GuidStr != NULL) { Status = ConvertStringToGuid(GuidStr, &GuidData); if (EFI_ERROR(Status)) { - ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_PROBLEM), gShellDebug1HiiHandle, GuidStr); + ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_PARAM_INV), gShellDebug1HiiHandle, L"dmpstore", GuidStr); ShellStatus = SHELL_INVALID_PARAMETER; } Guid = &GuidData; } else { Guid = &gEfiGlobalVariableGuid; } - Name = ShellCommandLineGetRawValue(Package, 1); } else { - Name = NULL; Guid = NULL; } + + // + // Get the Name of the variable to find + // + Name = ShellCommandLineGetRawValue(Package, 1); + if (ShellStatus == SHELL_SUCCESS) { if (ShellCommandLineGetFlag(Package, L"-s")) { Type = DmpStoreSave; File = ShellCommandLineGetValue(Package, L"-s"); if (File == NULL) { - ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_NO_VALUE), gShellDebug1HiiHandle, L"-s"); + ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_NO_VALUE), gShellDebug1HiiHandle, L"dmpstore", L"-s"); ShellStatus = SHELL_INVALID_PARAMETER; } else { Status = ShellOpenFileByName (File, &FileHandle, EFI_FILE_MODE_WRITE | EFI_FILE_MODE_READ, 0); @@ -665,16 +761,16 @@ ShellCommandRunDmpStore ( // FileInfo = ShellGetFileInfo (FileHandle); if (FileInfo == NULL) { - ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_GEN_FILE_OPEN_FAIL), gShellDebug1HiiHandle, File); + ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_GEN_FILE_OPEN_FAIL), gShellDebug1HiiHandle, L"dmpstore", File); Status = EFI_DEVICE_ERROR; } else { if ((FileInfo->Attribute & EFI_FILE_DIRECTORY) == EFI_FILE_DIRECTORY) { - ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_GEN_FILE_IS_DIRECTORY), gShellDebug1HiiHandle, File); + ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_GEN_FILE_IS_DIRECTORY), gShellDebug1HiiHandle, L"dmpstore", File); Status = EFI_INVALID_PARAMETER; } else { Status = ShellDeleteFile (&FileHandle); if (EFI_ERROR (Status)) { - ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_GEN_FILE_DELETE_FAIL), gShellDebug1HiiHandle, File); + ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_GEN_FILE_DELETE_FAIL), gShellDebug1HiiHandle, L"dmpstore", File); } } FreePool (FileInfo); @@ -688,13 +784,13 @@ ShellCommandRunDmpStore ( // // Otherwise it's bad. // - ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_GEN_FILE_OPEN_FAIL), gShellDebug1HiiHandle, File); + ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_GEN_FILE_OPEN_FAIL), gShellDebug1HiiHandle, L"dmpstore", File); } if (!EFI_ERROR (Status)) { Status = ShellOpenFileByName (File, &FileHandle, EFI_FILE_MODE_CREATE | EFI_FILE_MODE_WRITE | EFI_FILE_MODE_READ, 0); if (EFI_ERROR (Status)) { - ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_GEN_FILE_OPEN_FAIL), gShellDebug1HiiHandle, File); + ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_GEN_FILE_OPEN_FAIL), gShellDebug1HiiHandle, L"dmpstore", File); } } @@ -706,21 +802,21 @@ ShellCommandRunDmpStore ( Type = DmpStoreLoad; File = ShellCommandLineGetValue(Package, L"-l"); if (File == NULL) { - ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_NO_VALUE), gShellDebug1HiiHandle, L"-l"); + ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_NO_VALUE), gShellDebug1HiiHandle, L"dmpstore", L"-l"); ShellStatus = SHELL_INVALID_PARAMETER; } else { Status = ShellOpenFileByName (File, &FileHandle, EFI_FILE_MODE_READ, 0); if (EFI_ERROR (Status)) { - ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_FILE_OPEN_FAIL), gShellDebug1HiiHandle, File); + ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_FILE_OPEN_FAIL), gShellDebug1HiiHandle, L"dmpstore", File); ShellStatus = SHELL_INVALID_PARAMETER; } else { FileInfo = ShellGetFileInfo (FileHandle); if (FileInfo == NULL) { - ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_GEN_FILE_OPEN_FAIL), gShellDebug1HiiHandle, File); + ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_GEN_FILE_OPEN_FAIL), gShellDebug1HiiHandle, L"dmpstore", File); ShellStatus = SHELL_DEVICE_ERROR; } else { if ((FileInfo->Attribute & EFI_FILE_DIRECTORY) == EFI_FILE_DIRECTORY) { - ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_GEN_FILE_IS_DIRECTORY), gShellDebug1HiiHandle, File); + ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_GEN_FILE_IS_DIRECTORY), gShellDebug1HiiHandle, L"dmpstore", File); ShellStatus = SHELL_INVALID_PARAMETER; } FreePool (FileInfo); @@ -730,6 +826,10 @@ ShellCommandRunDmpStore ( } else if (ShellCommandLineGetFlag(Package, L"-d")) { Type = DmpStoreDelete; } + + if (ShellCommandLineGetFlag (Package,L"-sfo")) { + StandardFormatOutput = TRUE; + } } if (ShellStatus == SHELL_SUCCESS) { @@ -738,7 +838,7 @@ ShellCommandRunDmpStore ( } else if (Type == DmpStoreLoad) { ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_DMPSTORE_LOAD), gShellDebug1HiiHandle, File); } - ShellStatus = ProcessVariables (Name, Guid, Type, FileHandle); + ShellStatus = ProcessVariables (Name, Guid, Type, FileHandle, StandardFormatOutput); if ((Type == DmpStoreLoad) || (Type == DmpStoreSave)) { ShellCloseFile (&FileHandle); }