29#define DMP_STORE_VARIABLE_SIGNATURE SIGNATURE_32 ('_', 'd', 's', 's')
53 if ((Atts & EFI_VARIABLE_RUNTIME_ACCESS) != 0) {
55 }
else if ((Atts & EFI_VARIABLE_BOOTSERVICE_ACCESS) != 0) {
71 if (RetString ==
NULL) {
72 RetString =
StrnCatGrow (&RetString, &BufLen, L
"Invalid", 0);
75 if ((RetString !=
NULL) && (RetString[0] == L
'+')) {
96 IN OUT CHAR16 *HexString,
103 ASSERT (Buffer !=
NULL);
104 ASSERT ((BufferSize * 2 + 1) *
sizeof (CHAR16) <= HexStringSize);
106 for (Index = 0, StringIndex = 0; Index < BufferSize; Index += 1) {
109 &HexString[StringIndex],
110 HexStringSize - StringIndex *
sizeof (CHAR16),
112 ((UINT8 *)Buffer)[Index]
134 IN SHELL_FILE_HANDLE FileHandle,
156 if (EFI_ERROR (Status)) {
165 while (Position < FileSize) {
169 BufferSize =
sizeof (NameSize);
171 if (EFI_ERROR (Status) || (BufferSize !=
sizeof (NameSize))) {
179 BufferSize =
sizeof (DataSize);
181 if (EFI_ERROR (Status) || (BufferSize !=
sizeof (DataSize))) {
189 RemainingSize = NameSize +
sizeof (
EFI_GUID) +
sizeof (UINT32) + DataSize +
sizeof (Crc32);
190 BufferSize =
sizeof (NameSize) +
sizeof (DataSize) + RemainingSize;
192 if (Buffer ==
NULL) {
197 BufferSize = RemainingSize;
198 Status =
ShellReadFile (FileHandle, &BufferSize, (UINT32 *)Buffer + 2);
199 if (EFI_ERROR (Status) || (BufferSize != RemainingSize)) {
208 *(UINT32 *)Buffer = NameSize;
209 *((UINT32 *)Buffer + 1) = DataSize;
210 BufferSize = RemainingSize +
sizeof (NameSize) +
sizeof (DataSize) -
sizeof (Crc32);
211 gBS->CalculateCrc32 (
216 if (Crc32 != *(UINT32 *)(Buffer + BufferSize)) {
222 Position += BufferSize +
sizeof (Crc32);
225 if (Variable ==
NULL) {
231 Variable->Signature = DMP_STORE_VARIABLE_SIGNATURE;
232 Variable->Name = (CHAR16 *)(Variable + 1);
233 Variable->DataSize = DataSize;
234 Variable->Data = (UINT8 *)Variable->Name + NameSize;
235 CopyMem (Variable->Name, Buffer + sizeof (NameSize) +
sizeof (DataSize), NameSize);
236 CopyMem (&Variable->Guid, Buffer + sizeof (NameSize) +
sizeof (DataSize) + NameSize,
sizeof (
EFI_GUID));
237 CopyMem (&Variable->Attributes, Buffer + sizeof (NameSize) +
sizeof (DataSize) + NameSize +
sizeof (
EFI_GUID),
sizeof (UINT32));
238 CopyMem (Variable->Data, Buffer + sizeof (NameSize) +
sizeof (DataSize) + NameSize +
sizeof (
EFI_GUID) +
sizeof (UINT32), DataSize);
244 if ((Position != FileSize) || (ShellStatus !=
SHELL_SUCCESS)) {
246 if (Position != FileSize) {
258 if (((Name ==
NULL) || gUnicodeCollation->MetaiMatch (gUnicodeCollation, Variable->Name, (CHAR16 *)Name)) &&
268 gShellDebug1HiiHandle,
274 SHELL_FREE_NON_NULL (Attributes);
277 Status =
gRT->SetVariable (
280 Variable->Attributes,
284 if (EFI_ERROR (Status)) {
315 IN SHELL_FILE_HANDLE FileHandle,
318 IN UINT32 Attributes,
329 NameSize = (UINT32)
StrSize (Name);
330 BufferSize =
sizeof (NameSize) +
sizeof (DataSize)
332 +
sizeof (Attributes)
333 + NameSize + DataSize
337 if (Buffer ==
NULL) {
338 return EFI_OUT_OF_RESOURCES;
345 *(UINT32 *)Ptr = NameSize;
346 Ptr +=
sizeof (NameSize);
347 *(UINT32 *)Ptr = DataSize;
348 Ptr +=
sizeof (DataSize);
359 CopyMem (Ptr, Guid,
sizeof (*Guid));
360 Ptr +=
sizeof (*Guid);
365 *(UINT32 *)Ptr = Attributes;
366 Ptr +=
sizeof (Attributes);
377 gBS->CalculateCrc32 (Buffer, (
UINTN)Ptr - (
UINTN)Buffer, (UINT32 *)Ptr);
382 if (!EFI_ERROR (Status) &&
383 (BufferSize !=
sizeof (NameSize) +
sizeof (DataSize) +
sizeof (*Guid) +
sizeof (Attributes) + NameSize + DataSize +
sizeof (UINT32))
386 Status = EFI_DEVICE_ERROR;
418 IN CONST CHAR16 *Name OPTIONAL,
420 IN DMP_STORE_TYPE Type,
424 IN BOOLEAN *FoundOne,
425 IN BOOLEAN StandardFormatOutput
429 CHAR16 *FoundVarName;
438 CONST CHAR16 *GuidName;
447 if (PrevName !=
NULL) {
448 StrnCatGrow (&FoundVarName, &NameSize, PrevName, 0);
451 if (FoundVarName ==
NULL) {
455 NameSize =
sizeof (CHAR16);
458 Status =
gRT->GetNextVariableName (&NameSize, FoundVarName, &FoundVarGuid);
459 if (Status == EFI_BUFFER_TOO_SMALL) {
460 SHELL_FREE_NON_NULL (FoundVarName);
462 if (FoundVarName !=
NULL) {
463 if (PrevName !=
NULL) {
464 StrnCpyS (FoundVarName, NameSize/
sizeof (CHAR16), PrevName, NameSize/
sizeof (CHAR16) - 1);
467 Status =
gRT->GetNextVariableName (&NameSize, FoundVarName, &FoundVarGuid);
469 Status = EFI_OUT_OF_RESOURCES;
476 if (Status == EFI_NOT_FOUND) {
477 SHELL_FREE_NON_NULL (FoundVarName);
479 }
else if (EFI_ERROR (Status)) {
480 SHELL_FREE_NON_NULL (FoundVarName);
487 ShellStatus =
CascadeProcessVariables (Name, Guid, Type, FileHandle, FoundVarName, FoundVarGuid, FoundOne, StandardFormatOutput);
490 SHELL_FREE_NON_NULL (FoundVarName);
498 if ( ( (Name ==
NULL)
499 || gUnicodeCollation->MetaiMatch (gUnicodeCollation, FoundVarName, (CHAR16 *)Name))
510 Status =
gRT->GetVariable (FoundVarName, &FoundVarGuid, &Atts, &DataSize, DataBuffer);
511 if (Status == EFI_BUFFER_TOO_SMALL) {
512 SHELL_FREE_NON_NULL (DataBuffer);
514 if (DataBuffer ==
NULL) {
515 Status = EFI_OUT_OF_RESOURCES;
517 Status =
gRT->GetVariable (FoundVarName, &FoundVarGuid, &Atts, &DataSize, DataBuffer);
524 if (Type == DmpStoreDisplay) {
525 if (!EFI_ERROR (Status) && (DataBuffer !=
NULL) && (FoundVarName !=
NULL)) {
527 if (StandardFormatOutput) {
528 HexString =
AllocatePool ((DataSize * 2 + 1) *
sizeof (CHAR16));
529 if (HexString !=
NULL) {
535 gShellDebug1HiiHandle,
544 (DataSize * 2 + 1) *
sizeof (CHAR16)
549 Status = EFI_OUT_OF_RESOURCES;
552 Status = gEfiShellProtocol->GetGuidName (&FoundVarGuid, &GuidName);
553 if (EFI_ERROR (Status)) {
559 gShellDebug1HiiHandle,
571 gShellDebug1HiiHandle,
579 DumpHex (2, 0, DataSize, DataBuffer);
582 SHELL_FREE_NON_NULL (AttrString);
584 }
else if (Type == DmpStoreSave) {
585 if (!EFI_ERROR (Status) && (DataBuffer !=
NULL) && (FoundVarName !=
NULL)) {
592 gShellDebug1HiiHandle,
606 SHELL_FREE_NON_NULL (AttrString);
608 }
else if (Type == DmpStoreDelete) {
612 SetStatus =
gRT->SetVariable (FoundVarName, &FoundVarGuid, Atts, 0,
NULL);
613 if (StandardFormatOutput) {
620 gShellDebug1HiiHandle,
631 gShellDebug1HiiHandle,
639 SHELL_FREE_NON_NULL (DataBuffer);
642 SHELL_FREE_NON_NULL (FoundVarName);
644 if (Status == EFI_DEVICE_ERROR) {
646 }
else if (Status == EFI_SECURITY_VIOLATION) {
648 }
else if (EFI_ERROR (Status)) {
652 return (ShellStatus);
672 IN CONST CHAR16 *Name OPTIONAL,
674 IN DMP_STORE_TYPE Type,
675 IN SHELL_FILE_HANDLE FileHandle OPTIONAL,
676 IN BOOLEAN StandardFormatOutput
687 if (StandardFormatOutput) {
691 if (Type == DmpStoreLoad) {
700 return (ShellStatus);
701 }
else if ((Name !=
NULL) && (Guid ==
NULL)) {
702 if (StandardFormatOutput) {
707 }
else if ((Name !=
NULL) && (Guid !=
NULL)) {
709 }
else if ((Name ==
NULL) && (Guid ==
NULL)) {
710 if (StandardFormatOutput) {
715 }
else if ((Name ==
NULL) && (Guid !=
NULL)) {
716 if (StandardFormatOutput) {
726 return (ShellStatus);
753 RETURN_STATUS RStatus;
755 CHAR16 *ProblemParam;
757 CONST CHAR16 *GuidStr;
763 SHELL_FILE_HANDLE FileHandle;
765 BOOLEAN StandardFormatOutput;
771 Type = DmpStoreDisplay;
772 StandardFormatOutput =
FALSE;
775 if (EFI_ERROR (Status)) {
776 if ((Status == EFI_VOLUME_CORRUPTED) && (ProblemParam !=
NULL)) {
805 if (GuidStr !=
NULL) {
806 RStatus =
StrToGuid (GuidStr, &GuidData);
807 if (
RETURN_ERROR (RStatus) || (GuidStr[GUID_STRING_LENGTH] != L
'\0')) {
814 Guid = &gEfiGlobalVariableGuid;
833 Status =
ShellOpenFileByName (File, &FileHandle, EFI_FILE_MODE_WRITE | EFI_FILE_MODE_READ, 0);
834 if (!EFI_ERROR (Status)) {
841 Status = EFI_DEVICE_ERROR;
845 Status = EFI_INVALID_PARAMETER;
848 if (EFI_ERROR (Status)) {
855 }
else if (Status == EFI_NOT_FOUND) {
867 if (!EFI_ERROR (Status)) {
868 Status =
ShellOpenFileByName (File, &FileHandle, EFI_FILE_MODE_CREATE | EFI_FILE_MODE_WRITE | EFI_FILE_MODE_READ, 0);
869 if (EFI_ERROR (Status)) {
874 if (EFI_ERROR (Status)) {
886 if (EFI_ERROR (Status)) {
905 Type = DmpStoreDelete;
909 StandardFormatOutput =
TRUE;
914 if (Type == DmpStoreSave) {
916 }
else if (Type == DmpStoreLoad) {
920 ShellStatus =
ProcessVariables (Name, Guid, Type, FileHandle, StandardFormatOutput);
921 if ((Type == DmpStoreLoad) || (Type == DmpStoreSave)) {
928 if (Package !=
NULL) {
BOOLEAN EFIAPI IsNull(IN CONST LIST_ENTRY *List, IN CONST LIST_ENTRY *Node)
UINTN EFIAPI StrSize(IN CONST CHAR16 *String)
LIST_ENTRY *EFIAPI GetNextNode(IN CONST LIST_ENTRY *List, IN CONST LIST_ENTRY *Node)
LIST_ENTRY *EFIAPI GetFirstNode(IN CONST LIST_ENTRY *List)
LIST_ENTRY *EFIAPI RemoveEntryList(IN CONST LIST_ENTRY *Entry)
RETURN_STATUS EFIAPI StrToGuid(IN CONST CHAR16 *String, OUT GUID *Guid)
LIST_ENTRY *EFIAPI InitializeListHead(IN OUT LIST_ENTRY *ListHead)
RETURN_STATUS EFIAPI StrnCpyS(OUT CHAR16 *Destination, IN UINTN DestMax, IN CONST CHAR16 *Source, IN UINTN Length)
LIST_ENTRY *EFIAPI InsertTailList(IN OUT LIST_ENTRY *ListHead, IN OUT LIST_ENTRY *Entry)
VOID *EFIAPI CopyMem(OUT VOID *DestinationBuffer, IN CONST VOID *SourceBuffer, IN UINTN Length)
BOOLEAN EFIAPI CompareGuid(IN CONST GUID *Guid1, IN CONST GUID *Guid2)
VOID *EFIAPI ZeroMem(OUT VOID *Buffer, IN UINTN Length)
CHAR16 * GetAttrType(IN CONST UINT32 Atts)
SHELL_STATUS CascadeProcessVariables(IN CONST CHAR16 *Name OPTIONAL, IN CONST EFI_GUID *Guid OPTIONAL, IN DMP_STORE_TYPE Type, IN EFI_FILE_PROTOCOL *FileHandle OPTIONAL, IN CONST CHAR16 *CONST PrevName, IN EFI_GUID FoundVarGuid, IN BOOLEAN *FoundOne, IN BOOLEAN StandardFormatOutput)
SHELL_STATUS LoadVariablesFromFile(IN SHELL_FILE_HANDLE FileHandle, IN CONST CHAR16 *Name, IN CONST EFI_GUID *Guid, OUT BOOLEAN *Found)
EFI_STATUS AppendSingleVariableToFile(IN SHELL_FILE_HANDLE FileHandle, IN CONST CHAR16 *Name, IN CONST EFI_GUID *Guid, IN UINT32 Attributes, IN UINT32 DataSize, IN CONST UINT8 *Data)
SHELL_STATUS ProcessVariables(IN CONST CHAR16 *Name OPTIONAL, IN CONST EFI_GUID *Guid OPTIONAL, IN DMP_STORE_TYPE Type, IN SHELL_FILE_HANDLE FileHandle OPTIONAL, IN BOOLEAN StandardFormatOutput)
CHAR16 * BinaryToHexString(IN VOID *Buffer, IN UINTN BufferSize, IN OUT CHAR16 *HexString, IN UINTN HexStringSize)
SHELL_STATUS EFIAPI ShellCommandRunDmpStore(IN EFI_HANDLE ImageHandle, IN EFI_SYSTEM_TABLE *SystemTable)
VOID *EFIAPI AllocateZeroPool(IN UINTN AllocationSize)
VOID EFIAPI FreePool(IN VOID *Buffer)
UINTN EFIAPI UnicodeSPrint(OUT CHAR16 *StartOfBuffer, IN UINTN BufferSize, IN CONST CHAR16 *FormatString,...)
EFI_RUNTIME_SERVICES * gRT
#define RETURN_ERROR(StatusCode)
#define CR(Record, TYPE, Field, TestSignature)
@ SHELL_SECURITY_VIOLATION
@ SHELL_INVALID_PARAMETER
VOID *EFIAPI AllocatePool(IN UINTN AllocationSize)
EFI_FILE_INFO * FileInfo(IN EFI_FILE_HANDLE FHand)
VOID EFIAPI DumpHex(IN UINTN Indent, IN UINTN Offset, IN UINTN DataSize, IN VOID *UserData)
EFI_STATUS EFIAPI ShellGetFileSize(IN SHELL_FILE_HANDLE FileHandle, OUT UINT64 *Size)
CONST CHAR16 *EFIAPI ShellCommandLineGetValue(IN CONST LIST_ENTRY *CheckPackage, IN CHAR16 *KeyString)
EFI_FILE_INFO *EFIAPI ShellGetFileInfo(IN SHELL_FILE_HANDLE FileHandle)
EFI_STATUS EFIAPI ShellDeleteFile(IN SHELL_FILE_HANDLE *FileHandle)
BOOLEAN EFIAPI ShellGetExecutionBreakFlag(VOID)
#define ShellCommandLineParse(CheckList, CheckPackage, ProblemParam, AutoPageBreak)
Make it easy to upgrade from older versions of the shell library.
EFI_STATUS EFIAPI ShellPrintHiiEx(IN INT32 Col OPTIONAL, IN INT32 Row OPTIONAL, IN CONST CHAR8 *Language OPTIONAL, IN CONST EFI_STRING_ID HiiFormatStringId, IN CONST EFI_HII_HANDLE HiiFormatHandle,...)
BOOLEAN EFIAPI ShellCommandLineGetFlag(IN CONST LIST_ENTRY *CONST CheckPackage, IN CONST CHAR16 *CONST KeyString)
@ TypeValue
A flag that has some data following it with a space (IE "-a 1").
@ TypeFlag
A flag that is present or not present only (IE "-a").
EFI_STATUS EFIAPI ShellOpenFileByName(IN CONST CHAR16 *FileName, OUT SHELL_FILE_HANDLE *FileHandle, IN UINT64 OpenMode, IN UINT64 Attributes)
CHAR16 *EFIAPI StrnCatGrow(IN OUT CHAR16 **Destination, IN OUT UINTN *CurrentSize, IN CONST CHAR16 *Source, IN UINTN Count)
VOID EFIAPI ShellCommandLineFreeVarList(IN LIST_ENTRY *CheckPackage)
CONST CHAR16 *EFIAPI ShellCommandLineGetRawValue(IN CONST LIST_ENTRY *CONST CheckPackage, IN UINTN Position)
UINTN EFIAPI ShellCommandLineGetCount(IN CONST LIST_ENTRY *CheckPackage)
EFI_STATUS EFIAPI ShellWriteFile(IN SHELL_FILE_HANDLE FileHandle, IN OUT UINTN *BufferSize, IN VOID *Buffer)
EFI_STATUS EFIAPI ShellCloseFile(IN SHELL_FILE_HANDLE *FileHandle)
EFI_STATUS EFIAPI ShellReadFile(IN SHELL_FILE_HANDLE FileHandle, IN OUT UINTN *ReadSize, OUT VOID *Buffer)
#define EFI_VARIABLE_AUTHENTICATED_WRITE_ACCESS
#define EFI_VARIABLE_HARDWARE_ERROR_RECORD
#define EFI_VARIABLE_NON_VOLATILE
#define EFI_VARIABLE_TIME_BASED_AUTHENTICATED_WRITE_ACCESS