summaryrefslogtreecommitdiff
path: root/ShellPkg/Library
diff options
context:
space:
mode:
authorLeif Lindholm <leif.lindholm@linaro.org>2014-01-24 17:18:26 +0000
committerLeif Lindholm <leif.lindholm@linaro.org>2014-01-24 17:18:26 +0000
commite1e57aa891deef00276b26a4569802a5cd13ce92 (patch)
tree9061825c6c9f5c8bed33d5b2087101ce38f23fdf /ShellPkg/Library
parent18110e987bb049e24ade0fb63b5577def8f99114 (diff)
parent04d965c0713468e055ef328f9f49903bc5944e54 (diff)
Merging uefi-next/linaro-release into masterHEADlinaro-uefi-2014.01master
Signed-off-by: Leif Lindholm <leif.lindholm@linaro.org>
Diffstat (limited to 'ShellPkg/Library')
-rw-r--r--ShellPkg/Library/UefiShellCommandLib/UefiShellCommandLib.c35
-rw-r--r--ShellPkg/Library/UefiShellDebug1CommandsLib/Bcfg.c18
-rw-r--r--ShellPkg/Library/UefiShellDebug1CommandsLib/DmpStore.c722
-rw-r--r--ShellPkg/Library/UefiShellDebug1CommandsLib/Pci.c849
-rw-r--r--ShellPkg/Library/UefiShellDebug1CommandsLib/UefiShellDebug1CommandsLib.unibin152966 -> 171002 bytes
-rw-r--r--ShellPkg/Library/UefiShellInstall1CommandsLib/Bcfg.c18
-rw-r--r--ShellPkg/Library/UefiShellLevel1CommandsLib/For.c8
-rw-r--r--ShellPkg/Library/UefiShellLevel2CommandsLib/Ls.c1
-rw-r--r--ShellPkg/Library/UefiShellLevel2CommandsLib/Map.c7
-rw-r--r--ShellPkg/Library/UefiShellLevel2CommandsLib/Rm.c1
-rw-r--r--ShellPkg/Library/UefiShellLib/UefiShellLib.c24
11 files changed, 1463 insertions, 220 deletions
diff --git a/ShellPkg/Library/UefiShellCommandLib/UefiShellCommandLib.c b/ShellPkg/Library/UefiShellCommandLib/UefiShellCommandLib.c
index 935e8397f..48be39f83 100644
--- a/ShellPkg/Library/UefiShellCommandLib/UefiShellCommandLib.c
+++ b/ShellPkg/Library/UefiShellCommandLib/UefiShellCommandLib.c
@@ -1,7 +1,7 @@
/** @file
Provides interface to shell internal functions for shell commands.
- Copyright (c) 2009 - 2013, Intel Corporation. All rights reserved.<BR>
+ Copyright (c) 2009 - 2014, Intel Corporation. All rights reserved.<BR>
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
@@ -101,6 +101,37 @@ ShellCommandLibConstructor (
}
/**
+ Frees list of file handles.
+
+ @param[in] List The list to free.
+**/
+VOID
+EFIAPI
+FreeFileHandleList (
+ IN BUFFER_LIST *List
+ )
+{
+ BUFFER_LIST *BufferListEntry;
+
+ if (List == NULL){
+ return;
+ }
+ //
+ // enumerate through the buffer list and free all memory
+ //
+ for ( BufferListEntry = ( BUFFER_LIST *)GetFirstNode(&List->Link)
+ ; !IsListEmpty (&List->Link)
+ ; BufferListEntry = (BUFFER_LIST *)GetFirstNode(&List->Link)
+ ){
+ RemoveEntryList(&BufferListEntry->Link);
+ ASSERT(BufferListEntry->Buffer != NULL);
+ SHELL_FREE_NON_NULL(((SHELL_COMMAND_FILE_HANDLE*)(BufferListEntry->Buffer))->Path);
+ SHELL_FREE_NON_NULL(BufferListEntry->Buffer);
+ SHELL_FREE_NON_NULL(BufferListEntry);
+ }
+}
+
+/**
Destructor for the library. free any resources.
@param ImageHandle the image handle of the process
@@ -169,7 +200,7 @@ ShellCommandLibDestructor (
}
}
if (!IsListEmpty(&mFileHandleList.Link)){
- FreeBufferList(&mFileHandleList);
+ FreeFileHandleList(&mFileHandleList);
}
if (mProfileList != NULL) {
diff --git a/ShellPkg/Library/UefiShellDebug1CommandsLib/Bcfg.c b/ShellPkg/Library/UefiShellDebug1CommandsLib/Bcfg.c
index 73831d267..b19d8d9fb 100644
--- a/ShellPkg/Library/UefiShellDebug1CommandsLib/Bcfg.c
+++ b/ShellPkg/Library/UefiShellDebug1CommandsLib/Bcfg.c
@@ -48,16 +48,6 @@ typedef struct {
} BGFG_OPERATION;
/**
- Get the actual number of entries in EFI_KEY_OPTION.Keys, from 0-3.
-
- @param KeyOption Pointer to the EFI_KEY_OPTION structure.
-
- @return Actual number of entries in EFI_KEY_OPTION.Keys.
-**/
-#define KEY_OPTION_INPUT_KEY_COUNT(KeyOption) \
- (((KeyOption)->KeyData & EFI_KEY_OPTION_INPUT_KEY_COUNT_MASK) >> LowBitSet32 (EFI_KEY_OPTION_INPUT_KEY_COUNT_MASK))
-
-/**
Update the optional data for a boot or driver option.
If optional data exists it will be changed.
@@ -843,7 +833,7 @@ BcfgAddOptDebug1(
ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_PROBLEM), gShellDebug1HiiHandle, Walker);
ShellStatus = SHELL_INVALID_PARAMETER;
}
- NewKeyOption.KeyData = (UINT32)Intermediate;
+ NewKeyOption.KeyData.PackedValue = (UINT32)Intermediate;
Temp = StrStr(Walker, L" ");
if (Temp != NULL) {
Walker = Temp;
@@ -858,13 +848,13 @@ BcfgAddOptDebug1(
// Now we know how many EFI_INPUT_KEY structs we need to attach to the end of the EFI_KEY_OPTION struct.
// Re-allocate with the added information.
//
- KeyOptionBuffer = AllocateCopyPool(sizeof(EFI_KEY_OPTION) + (sizeof(EFI_KEY_DATA) * KEY_OPTION_INPUT_KEY_COUNT (&NewKeyOption)), &NewKeyOption);
+ KeyOptionBuffer = AllocateCopyPool(sizeof(EFI_KEY_OPTION) + (sizeof(EFI_KEY_DATA) * NewKeyOption.KeyData.Options.InputKeyCount), &NewKeyOption);
if (KeyOptionBuffer == NULL) {
ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_NO_MEM), gShellDebug1HiiHandle);
ShellStatus = SHELL_OUT_OF_RESOURCES;
}
}
- for (LoopCounter = 0 ; ShellStatus == SHELL_SUCCESS && LoopCounter < KEY_OPTION_INPUT_KEY_COUNT (&NewKeyOption); LoopCounter++) {
+ for (LoopCounter = 0 ; ShellStatus == SHELL_SUCCESS && LoopCounter < NewKeyOption.KeyData.Options.InputKeyCount; LoopCounter++) {
//
// ScanCode
//
@@ -930,7 +920,7 @@ BcfgAddOptDebug1(
VariableName,
(EFI_GUID*)&gEfiGlobalVariableGuid,
EFI_VARIABLE_NON_VOLATILE|EFI_VARIABLE_BOOTSERVICE_ACCESS|EFI_VARIABLE_RUNTIME_ACCESS,
- sizeof(EFI_KEY_OPTION) + (sizeof(EFI_KEY_DATA) * KEY_OPTION_INPUT_KEY_COUNT (&NewKeyOption)),
+ sizeof(EFI_KEY_OPTION) + (sizeof(EFI_KEY_DATA) * NewKeyOption.KeyData.Options.InputKeyCount),
KeyOptionBuffer);
if (EFI_ERROR(Status)) {
ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_BCFG_SET_VAR_FAIL), gShellDebug1HiiHandle, VariableName, Status);
diff --git a/ShellPkg/Library/UefiShellDebug1CommandsLib/DmpStore.c b/ShellPkg/Library/UefiShellDebug1CommandsLib/DmpStore.c
index 3445b7f7e..b41636c7e 100644
--- a/ShellPkg/Library/UefiShellDebug1CommandsLib/DmpStore.c
+++ b/ShellPkg/Library/UefiShellDebug1CommandsLib/DmpStore.c
@@ -1,7 +1,7 @@
/** @file
Main file for DmpStore shell Debug1 function.
- Copyright (c) 2005 - 2013, Intel Corporation. All rights reserved.<BR>
+ Copyright (c) 2005 - 2014, Intel Corporation. All rights reserved.<BR>
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
@@ -14,9 +14,24 @@
#include "UefiShellDebug1CommandsLib.h"
-
-#define INIT_NAME_BUFFER_SIZE 128
-#define INIT_DATA_BUFFER_SIZE 1024
+typedef enum {
+ DmpStoreDisplay,
+ DmpStoreDelete,
+ DmpStoreSave,
+ DmpStoreLoad
+} DMP_STORE_TYPE;
+
+typedef struct {
+ UINT32 Signature;
+ CHAR16 *Name;
+ EFI_GUID Guid;
+ UINT32 Attributes;
+ UINT32 DataSize;
+ UINT8 *Data;
+ LIST_ENTRY Link;
+} DMP_STORE_VARIABLE;
+
+#define DMP_STORE_VARIABLE_SIGNATURE SIGNATURE_32 ('_', 'd', 's', 's')
/**
Base on the input attribute value to return the attribute string.
@@ -67,11 +82,282 @@ GetAttrType (
}
/**
- Function to display or delete variables.
+ Load the variable data from file and set to variable data base.
+
+ @param[in] FileHandle The file to be read.
+ @param[in] Name The name of the variables to be loaded.
+ @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 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.
+**/
+SHELL_STATUS
+LoadVariablesFromFile (
+ IN SHELL_FILE_HANDLE FileHandle,
+ IN CONST CHAR16 *Name,
+ IN CONST EFI_GUID *Guid,
+ OUT BOOLEAN *Found
+ )
+{
+ EFI_STATUS Status;
+ SHELL_STATUS ShellStatus;
+ UINT32 NameSize;
+ UINT32 DataSize;
+ UINTN BufferSize;
+ UINTN RemainingSize;
+ UINT64 Position;
+ UINT64 FileSize;
+ LIST_ENTRY List;
+ DMP_STORE_VARIABLE *Variable;
+ LIST_ENTRY *Link;
+ CHAR16 *Attributes;
+ UINT8 *Buffer;
+ UINT32 Crc32;
+
+ Status = ShellGetFileSize (FileHandle, &FileSize);
+ if (EFI_ERROR (Status)) {
+ return SHELL_DEVICE_ERROR;
+ }
+
+ ShellStatus = SHELL_SUCCESS;
+
+ InitializeListHead (&List);
+
+ Position = 0;
+ while (Position < FileSize) {
+ //
+ // NameSize
+ //
+ BufferSize = sizeof (NameSize);
+ Status = ShellReadFile (FileHandle, &BufferSize, &NameSize);
+ if (EFI_ERROR (Status) || (BufferSize != sizeof (NameSize))) {
+ ShellStatus = SHELL_VOLUME_CORRUPTED;
+ break;
+ }
+
+ //
+ // DataSize
+ //
+ BufferSize = sizeof (DataSize);
+ Status = ShellReadFile (FileHandle, &BufferSize, &DataSize);
+ if (EFI_ERROR (Status) || (BufferSize != sizeof (DataSize))) {
+ ShellStatus = SHELL_VOLUME_CORRUPTED;
+ break;
+ }
- @param[in] VariableName The variable name of the EFI variable (or NULL).
+ //
+ // Name, Guid, Attributes, Data, Crc32
+ //
+ RemainingSize = NameSize + sizeof (EFI_GUID) + sizeof (UINT32) + DataSize + sizeof (Crc32);
+ BufferSize = sizeof (NameSize) + sizeof (DataSize) + RemainingSize;
+ Buffer = AllocatePool (BufferSize);
+ if (Buffer == NULL) {
+ ShellStatus = SHELL_OUT_OF_RESOURCES;
+ break;
+ }
+ BufferSize = RemainingSize;
+ Status = ShellReadFile (FileHandle, &BufferSize, (UINT32 *) Buffer + 2);
+ if (EFI_ERROR (Status) || (BufferSize != RemainingSize)) {
+ ShellStatus = SHELL_VOLUME_CORRUPTED;
+ FreePool (Buffer);
+ break;
+ }
+
+ //
+ // Check Crc32
+ //
+ * (UINT32 *) Buffer = NameSize;
+ * ((UINT32 *) Buffer + 1) = DataSize;
+ BufferSize = RemainingSize + sizeof (NameSize) + sizeof (DataSize) - sizeof (Crc32);
+ gBS->CalculateCrc32 (
+ Buffer,
+ BufferSize,
+ &Crc32
+ );
+ if (Crc32 != * (UINT32 *) (Buffer + BufferSize)) {
+ FreePool (Buffer);
+ ShellStatus = SHELL_VOLUME_CORRUPTED;
+ break;
+ }
+
+ Position += BufferSize + sizeof (Crc32);
+
+ Variable = AllocateZeroPool (sizeof (*Variable) + NameSize + DataSize);
+ if (Variable == NULL) {
+ FreePool (Buffer);
+ ShellStatus = SHELL_OUT_OF_RESOURCES;
+ break;
+ }
+ Variable->Signature = DMP_STORE_VARIABLE_SIGNATURE;
+ Variable->Name = (CHAR16 *) (Variable + 1);
+ Variable->DataSize = DataSize;
+ Variable->Data = (UINT8 *) Variable->Name + NameSize;
+ CopyMem (Variable->Name, Buffer + sizeof (NameSize) + sizeof (DataSize), NameSize);
+ CopyMem (&Variable->Guid, Buffer + sizeof (NameSize) + sizeof (DataSize) + NameSize, sizeof (EFI_GUID));
+ CopyMem (&Variable->Attributes, Buffer + sizeof (NameSize) + sizeof (DataSize) + NameSize + sizeof (EFI_GUID), sizeof (UINT32));
+ CopyMem (Variable->Data, Buffer + sizeof (NameSize) + sizeof (DataSize) + NameSize + sizeof (EFI_GUID) + sizeof (UINT32), DataSize);
+
+ InsertTailList (&List, &Variable->Link);
+ FreePool (Buffer);
+ }
+
+ if ((Position != FileSize) || (ShellStatus != SHELL_SUCCESS)) {
+ ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_DMPSTORE_LOAD_BAD_FILE), gShellDebug1HiiHandle);
+ if (Position != FileSize) {
+ ShellStatus = SHELL_VOLUME_CORRUPTED;
+ }
+ }
+
+ for ( Link = GetFirstNode (&List)
+ ; !IsNull (&List, Link) && (ShellStatus == SHELL_SUCCESS)
+ ; Link = GetNextNode (&List, Link)
+ ) {
+ Variable = CR (Link, DMP_STORE_VARIABLE, Link, DMP_STORE_VARIABLE_SIGNATURE);
+
+ if (((Name == NULL) || gUnicodeCollation->MetaiMatch (gUnicodeCollation, Variable->Name, (CHAR16 *) Name)) &&
+ ((Guid == NULL) || CompareGuid (&Variable->Guid, Guid))
+ ) {
+ Attributes = GetAttrType (Variable->Attributes);
+ ShellPrintHiiEx (
+ -1, -1, NULL, STRING_TOKEN(STR_DMPSTORE_HEADER_LINE), gShellDebug1HiiHandle,
+ Attributes, &Variable->Guid, Variable->Name, Variable->DataSize
+ );
+ SHELL_FREE_NON_NULL(Attributes);
+
+ *Found = TRUE;
+ Status = gRT->SetVariable (
+ Variable->Name,
+ &Variable->Guid,
+ Variable->Attributes,
+ Variable->DataSize,
+ Variable->Data
+ );
+ if (EFI_ERROR (Status)) {
+ ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_DMPSTORE_LOAD_GEN_FAIL), gShellDebug1HiiHandle, Variable->Name, Status);
+ }
+ }
+ }
+
+ for (Link = GetFirstNode (&List); !IsNull (&List, Link); ) {
+ Variable = CR (Link, DMP_STORE_VARIABLE, Link, DMP_STORE_VARIABLE_SIGNATURE);
+ Link = RemoveEntryList (&Variable->Link);
+ FreePool (Variable);
+ }
+
+ return ShellStatus;
+}
+
+/**
+ Append one variable to file.
+
+ @param[in] FileHandle The file to be appended.
+ @param[in] Name The variable name.
+ @param[in] Guid The variable GUID.
+ @param[in] Attributes The variable attributes.
+ @param[in] DataSize The variable data size.
+ @param[in] Data The variable data.
+
+ @retval EFI_OUT_OF_RESOURCES There is not enough memory to perform the operation.
+ @retval EFI_SUCCESS The variable is appended to file successfully.
+ @retval others Failed to append the variable to file.
+**/
+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
+ )
+{
+ UINT32 NameSize;
+ UINT8 *Buffer;
+ UINT8 *Ptr;
+ UINTN BufferSize;
+ EFI_STATUS Status;
+
+ NameSize = (UINT32) StrSize (Name);
+ BufferSize = sizeof (NameSize) + sizeof (DataSize)
+ + sizeof (*Guid)
+ + sizeof (Attributes)
+ + NameSize + DataSize
+ + sizeof (UINT32);
+
+ Buffer = AllocatePool (BufferSize);
+ if (Buffer == NULL) {
+ return EFI_OUT_OF_RESOURCES;
+ }
+
+ Ptr = Buffer;
+ //
+ // NameSize and DataSize
+ //
+ * (UINT32 *) Ptr = NameSize;
+ Ptr += sizeof (NameSize);
+ *(UINT32 *) Ptr = DataSize;
+ Ptr += sizeof (DataSize);
+
+ //
+ // Name
+ //
+ CopyMem (Ptr, Name, NameSize);
+ Ptr += NameSize;
+
+ //
+ // Guid
+ //
+ CopyMem (Ptr, Guid, sizeof (*Guid));
+ Ptr += sizeof (*Guid);
+
+ //
+ // Attributes
+ //
+ * (UINT32 *) Ptr = Attributes;
+ Ptr += sizeof (Attributes);
+
+ //
+ // Data
+ //
+ CopyMem (Ptr, Data, DataSize);
+ Ptr += DataSize;
+
+ //
+ // Crc32
+ //
+ gBS->CalculateCrc32 (Buffer, (UINTN) (Ptr - Buffer), (UINT32 *) Ptr);
+
+ Status = ShellWriteFile (FileHandle, &BufferSize, Buffer);
+ FreePool (Buffer);
+
+ if (!EFI_ERROR (Status) &&
+ (BufferSize != sizeof (NameSize) + sizeof (DataSize) + sizeof (*Guid) + sizeof (Attributes) + NameSize + DataSize)
+ ) {
+ Status = EFI_DEVICE_ERROR;
+ }
+
+ return Status;
+}
+
+/**
+ Recursive function to display or delete variables.
+
+ This function will call itself to create a stack-based list of allt he variables to process,
+ then fromt he last to the first, they will do either printing or deleting.
+
+ 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] Delete TRUE to delete, FALSE otherwise.
+ @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.
@retval SHELL_SUCCESS The operation was successful.
@retval SHELL_OUT_OF_RESOURCES A memorty allocation failed.
@@ -81,169 +367,203 @@ GetAttrType (
**/
SHELL_STATUS
EFIAPI
-ProcessVariables (
- IN CONST CHAR16 *VariableName OPTIONAL,
- IN CONST EFI_GUID *Guid OPTIONAL,
- IN BOOLEAN Delete
+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
)
{
EFI_STATUS Status;
CHAR16 *FoundVarName;
- EFI_GUID FoundVarGuid;
UINT8 *DataBuffer;
UINTN DataSize;
UINT32 Atts;
SHELL_STATUS ShellStatus;
- BOOLEAN Found;
- UINTN NameBufferSize; // Allocated Name buffer size
UINTN NameSize;
- CHAR16 *OldName;
- UINTN OldNameBufferSize;
- UINTN DataBufferSize; // Allocated data buffer size
CHAR16 *RetString;
- Found = FALSE;
- ShellStatus = SHELL_SUCCESS;
- Status = EFI_SUCCESS;
-
- NameBufferSize = INIT_NAME_BUFFER_SIZE;
- DataBufferSize = INIT_DATA_BUFFER_SIZE;
- FoundVarName = AllocateZeroPool (NameBufferSize);
- if (FoundVarName == NULL) {
- return (SHELL_OUT_OF_RESOURCES);
- }
- DataBuffer = AllocatePool (DataBufferSize);
- if (DataBuffer == NULL) {
- FreePool (FoundVarName);
- return (SHELL_OUT_OF_RESOURCES);
+ if (ShellGetExecutionBreakFlag()) {
+ return (SHELL_ABORTED);
}
- for (;;){
- if (ShellGetExecutionBreakFlag()) {
- ShellStatus = SHELL_ABORTED;
- break;
- }
+ NameSize = 0;
+ FoundVarName = NULL;
- NameSize = NameBufferSize;
- Status = gRT->GetNextVariableName (&NameSize, FoundVarName, &FoundVarGuid);
- if (Status == EFI_BUFFER_TOO_SMALL) {
- OldName = FoundVarName;
- OldNameBufferSize = NameBufferSize;
- //
- // Expand at least twice to avoid reallocate many times
- //
- NameBufferSize = NameSize > NameBufferSize * 2 ? NameSize : NameBufferSize * 2;
- FoundVarName = AllocateZeroPool (NameBufferSize);
- if (FoundVarName == NULL) {
- Status = EFI_OUT_OF_RESOURCES;
- FreePool (OldName);
- break;
+ if (PrevName!=NULL) {
+ StrnCatGrow(&FoundVarName, &NameSize, PrevName, 0);
+ } else {
+ FoundVarName = AllocateZeroPool(sizeof(CHAR16));
+ }
+
+ Status = gRT->GetNextVariableName (&NameSize, FoundVarName, &FoundVarGuid);
+ if (Status == EFI_BUFFER_TOO_SMALL) {
+ SHELL_FREE_NON_NULL(FoundVarName);
+ FoundVarName = AllocateZeroPool (NameSize);
+ if (FoundVarName != NULL) {
+ if (PrevName != NULL) {
+ StrCpy(FoundVarName, PrevName);
}
- //
- // Preserve the original content to get correct iteration for GetNextVariableName() call
- //
- CopyMem (FoundVarName, OldName, OldNameBufferSize);
- FreePool (OldName);
- NameSize = NameBufferSize;
+
Status = gRT->GetNextVariableName (&NameSize, FoundVarName, &FoundVarGuid);
+ } else {
+ Status = EFI_OUT_OF_RESOURCES;
}
- if (Status == EFI_NOT_FOUND) {
- break;
- }
- ASSERT_EFI_ERROR(Status);
+ }
+ //
+ // No more is fine.
+ //
+ if (Status == EFI_NOT_FOUND) {
+ SHELL_FREE_NON_NULL(FoundVarName);
+ return (SHELL_SUCCESS);
+ } else if (EFI_ERROR(Status)) {
+ SHELL_FREE_NON_NULL(FoundVarName);
+ return (SHELL_DEVICE_ERROR);
+ }
+
+ //
+ // Recurse to the next iteration. We know "our" variable's name.
+ //
+ ShellStatus = CascadeProcessVariables(Name, Guid, Type, FileHandle, FoundVarName, FoundVarGuid, FoundOne);
+
+ //
+ // No matter what happened we process our own variable
+ // Only continue if Guid and VariableName are each either NULL or a match
+ //
+ if ( ( Name == NULL
+ || gUnicodeCollation->MetaiMatch(gUnicodeCollation, FoundVarName, (CHAR16*) Name) )
+ && ( Guid == NULL
+ || CompareGuid(&FoundVarGuid, Guid) )
+ ) {
+ DataSize = 0;
+ DataBuffer = NULL;
//
- // Check if it matches
+ // do the print or delete
//
- if (VariableName != NULL) {
- if (!gUnicodeCollation->MetaiMatch(gUnicodeCollation, FoundVarName, (CHAR16*)VariableName)) {
- continue;
- }
- }
- if (Guid != NULL) {
- if (!CompareGuid(&FoundVarGuid, Guid)) {
- continue;
+ *FoundOne = TRUE;
+ Status = gRT->GetVariable (FoundVarName, &FoundVarGuid, &Atts, &DataSize, DataBuffer);
+ if (Status == EFI_BUFFER_TOO_SMALL) {
+ SHELL_FREE_NON_NULL (DataBuffer);
+ DataBuffer = AllocatePool (DataSize);
+ if (DataBuffer == NULL) {
+ Status = EFI_OUT_OF_RESOURCES;
+ } else {
+ Status = gRT->GetVariable (FoundVarName, &FoundVarGuid, &Atts, &DataSize, DataBuffer);
}
}
-
- DataSize = DataBufferSize;
- Status = gRT->GetVariable (FoundVarName, &FoundVarGuid, &Atts, &DataSize, DataBuffer);
- if (Status == EFI_BUFFER_TOO_SMALL) {
+ if ((Type == DmpStoreDisplay) || (Type == DmpStoreSave)) {
//
- // Expand at least twice to avoid reallocate many times
+ // Last error check then print this variable out.
//
- FreePool (DataBuffer);
- DataBufferSize = DataSize > DataBufferSize * 2 ? DataSize : DataBufferSize * 2;
- DataBuffer = AllocatePool (DataBufferSize);
- if (DataBuffer == NULL) {
- Status = EFI_OUT_OF_RESOURCES;
- break;
+ if (!EFI_ERROR(Status) && (DataBuffer != NULL) && (FoundVarName != 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);
+ } else {
+ Status = AppendSingleVariableToFile (
+ FileHandle,
+ FoundVarName,
+ &FoundVarGuid,
+ Atts,
+ (UINT32) DataSize,
+ DataBuffer
+ );
+ }
+ SHELL_FREE_NON_NULL(RetString);
}
- DataSize = DataBufferSize;
- Status = gRT->GetVariable (FoundVarName, &FoundVarGuid, &Atts, &DataSize, DataBuffer);
- }
- ASSERT_EFI_ERROR(Status);
-
- //
- // do the print or delete
- //
- Found = TRUE;
- RetString = GetAttrType(Atts);
- if (!Delete) {
- ShellPrintHiiEx(
- -1,
- -1,
- NULL,
- STRING_TOKEN(STR_DMPSTORE_HEADER_LINE),
- gShellDebug1HiiHandle,
- RetString,
- &FoundVarGuid,
- FoundVarName,
- DataSize);
- DumpHex(2, 0, DataSize, DataBuffer);
- } else {
- ShellPrintHiiEx(
+ } else if (Type == DmpStoreDelete) {
+ //
+ // We only need name to delete it...
+ //
+ ShellPrintHiiEx (
-1,
-1,
NULL,
STRING_TOKEN(STR_DMPSTORE_DELETE_LINE),
gShellDebug1HiiHandle,
&FoundVarGuid,
- FoundVarName);
- ShellPrintHiiEx(
- -1,
- -1,
- NULL,
- STRING_TOKEN(STR_DMPSTORE_DELETE_DONE),
- gShellDebug1HiiHandle,
- gRT->SetVariable(FoundVarName, &FoundVarGuid, Atts, 0, NULL));
- FoundVarName[0] = CHAR_NULL;
- }
-
- if (RetString != NULL) {
- FreePool (RetString);
+ FoundVarName,
+ gRT->SetVariable (FoundVarName, &FoundVarGuid, Atts, 0, NULL)
+ );
}
+ SHELL_FREE_NON_NULL(DataBuffer);
}
- if (FoundVarName != NULL) {
- FreePool(FoundVarName);
+ SHELL_FREE_NON_NULL(FoundVarName);
+
+ if (Status == EFI_DEVICE_ERROR) {
+ ShellStatus = SHELL_DEVICE_ERROR;
+ } else if (Status == EFI_SECURITY_VIOLATION) {
+ ShellStatus = SHELL_SECURITY_VIOLATION;
+ } else if (EFI_ERROR(Status)) {
+ ShellStatus = SHELL_NOT_READY;
}
- if (DataBuffer != NULL) {
- FreePool(DataBuffer);
+
+ return (ShellStatus);
+}
+
+/**
+ 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.
+
+ @retval SHELL_SUCCESS The operation was successful.
+ @retval SHELL_OUT_OF_RESOURCES A memorty allocation failed.
+ @retval SHELL_ABORTED The abort message was received.
+ @retval SHELL_DEVICE_ERROR UEFI Variable Services returned an error.
+ @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
+ )
+{
+ SHELL_STATUS ShellStatus;
+ BOOLEAN Found;
+ EFI_GUID FoundVarGuid;
+
+ Found = FALSE;
+ ShellStatus = SHELL_SUCCESS;
+ ZeroMem (&FoundVarGuid, sizeof(EFI_GUID));
+
+ if (Type == DmpStoreLoad) {
+ ShellStatus = LoadVariablesFromFile (FileHandle, Name, Guid, &Found);
+ } else {
+ ShellStatus = CascadeProcessVariables(Name, Guid, Type, FileHandle, NULL, FoundVarGuid, &Found);
}
+
if (!Found) {
- if (Status == EFI_OUT_OF_RESOURCES) {
+ if (ShellStatus == SHELL_OUT_OF_RESOURCES) {
ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_OUT_MEM), gShellDebug1HiiHandle);
- return SHELL_OUT_OF_RESOURCES;
- }
-
- if (VariableName != NULL && Guid == NULL) {
- ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_DMPSTORE_NO_VAR_FOUND_N), gShellDebug1HiiHandle, VariableName);
- } else if (VariableName != NULL && Guid != NULL) {
- ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_DMPSTORE_NO_VAR_FOUND_GN), gShellDebug1HiiHandle, Guid, VariableName);
- } else if (VariableName == NULL && Guid == NULL) {
+ return (ShellStatus);
+ } else if (Name != NULL && Guid == NULL) {
+ ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_DMPSTORE_NO_VAR_FOUND_N), gShellDebug1HiiHandle, Name);
+ } else if (Name != NULL && Guid != NULL) {
+ ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_DMPSTORE_NO_VAR_FOUND_GN), gShellDebug1HiiHandle, Guid, Name);
+ } else if (Name == NULL && Guid == NULL) {
ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_DMPSTORE_NO_VAR_FOUND), gShellDebug1HiiHandle);
- } else if (VariableName == NULL && Guid != NULL) {
+ } else if (Name == NULL && Guid != NULL) {
ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_DMPSTORE_NO_VAR_FOUND_G), gShellDebug1HiiHandle, Guid);
}
return (SHELL_NOT_FOUND);
@@ -253,8 +573,8 @@ ProcessVariables (
STATIC CONST SHELL_PARAM_ITEM ParamList[] = {
{L"-d", TypeFlag},
- {L"-l", TypeFlag},
- {L"-s", TypeFlag},
+ {L"-l", TypeValue},
+ {L"-s", TypeValue},
{L"-all", TypeFlag},
{L"-guid", TypeValue},
{NULL, TypeMax}
@@ -273,17 +593,24 @@ ShellCommandRunDmpStore (
IN EFI_SYSTEM_TABLE *SystemTable
)
{
- EFI_STATUS Status;
- LIST_ENTRY *Package;
- CHAR16 *ProblemParam;
- SHELL_STATUS ShellStatus;
- CONST CHAR16 *Temp;
- EFI_GUID *Guid;
- EFI_GUID GuidData;
- CONST CHAR16 *VariableName;
+ EFI_STATUS Status;
+ LIST_ENTRY *Package;
+ CHAR16 *ProblemParam;
+ SHELL_STATUS ShellStatus;
+ CONST CHAR16 *GuidStr;
+ CONST CHAR16 *File;
+ EFI_GUID *Guid;
+ EFI_GUID GuidData;
+ CONST CHAR16 *Name;
+ DMP_STORE_TYPE Type;
+ SHELL_FILE_HANDLE FileHandle;
+ EFI_FILE_INFO *FileInfo;
ShellStatus = SHELL_SUCCESS;
Package = NULL;
+ FileHandle = NULL;
+ File = NULL;
+ Type = DmpStoreDisplay;
Status = ShellCommandLineParse (ParamList, &Package, &ProblemParam, TRUE);
if (EFI_ERROR(Status)) {
@@ -301,34 +628,121 @@ ShellCommandRunDmpStore (
} 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");
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");
+ 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");
ShellStatus = SHELL_INVALID_PARAMETER;
} else {
if (!ShellCommandLineGetFlag(Package, L"-all")) {
- Temp = ShellCommandLineGetValue(Package, L"-guid");
- if (Temp != NULL) {
- Status = ConvertStringToGuid(Temp, &GuidData);
+ 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, Temp);
+ ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_PROBLEM), gShellDebug1HiiHandle, GuidStr);
ShellStatus = SHELL_INVALID_PARAMETER;
}
Guid = &GuidData;
} else {
Guid = &gEfiGlobalVariableGuid;
}
- VariableName = ShellCommandLineGetRawValue(Package, 1);
+ Name = ShellCommandLineGetRawValue(Package, 1);
} else {
- VariableName = NULL;
- Guid = NULL;
+ Name = NULL;
+ Guid = NULL;
}
if (ShellStatus == SHELL_SUCCESS) {
- if (ShellCommandLineGetFlag(Package, L"-s") || ShellCommandLineGetFlag(Package, L"-l")) {
- ///@todo fix this after lib ready...
- ShellPrintEx(-1, -1, L"Not implemeneted yet.\r\n");
- ShellStatus = SHELL_UNSUPPORTED;
- } else {
- ShellStatus = ProcessVariables (VariableName, Guid, ShellCommandLineGetFlag(Package, L"-d"));
+ 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");
+ ShellStatus = SHELL_INVALID_PARAMETER;
+ } else {
+ Status = ShellOpenFileByName (File, &FileHandle, EFI_FILE_MODE_WRITE | EFI_FILE_MODE_READ, 0);
+ if (!EFI_ERROR (Status)) {
+ //
+ // Delete existing file, but do not delete existing directory
+ //
+ FileInfo = ShellGetFileInfo (FileHandle);
+ if (FileInfo == NULL) {
+ ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_GEN_FILE_OPEN_FAIL), gShellDebug1HiiHandle, 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);
+ 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);
+ }
+ }
+ FreePool (FileInfo);
+ }
+ } else if (Status == EFI_NOT_FOUND) {
+ //
+ // Good when file doesn't exist
+ //
+ Status = EFI_SUCCESS;
+ } else {
+ //
+ // Otherwise it's bad.
+ //
+ ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_GEN_FILE_OPEN_FAIL), gShellDebug1HiiHandle, 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);
+ }
+ }
+
+ if (EFI_ERROR (Status)) {
+ ShellStatus = SHELL_INVALID_PARAMETER;
+ }
+ }
+ } else if (ShellCommandLineGetFlag(Package, L"-l")) {
+ Type = DmpStoreLoad;
+ File = ShellCommandLineGetValue(Package, L"-l");
+ if (File == NULL) {
+ ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_NO_VALUE), gShellDebug1HiiHandle, 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);
+ ShellStatus = SHELL_INVALID_PARAMETER;
+ } else {
+ FileInfo = ShellGetFileInfo (FileHandle);
+ if (FileInfo == NULL) {
+ ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_GEN_FILE_OPEN_FAIL), gShellDebug1HiiHandle, 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);
+ ShellStatus = SHELL_INVALID_PARAMETER;
+ }
+ FreePool (FileInfo);
+ }
+ }
+ }
+ } else if (ShellCommandLineGetFlag(Package, L"-d")) {
+ Type = DmpStoreDelete;
+ }
+ }
+
+ if (ShellStatus == SHELL_SUCCESS) {
+ if (Type == DmpStoreSave) {
+ ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_DMPSTORE_SAVE), gShellDebug1HiiHandle, File);
+ } else if (Type == DmpStoreLoad) {
+ ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_DMPSTORE_LOAD), gShellDebug1HiiHandle, File);
+ }
+ ShellStatus = ProcessVariables (Name, Guid, Type, FileHandle);
+ if ((Type == DmpStoreLoad) || (Type == DmpStoreSave)) {
+ ShellCloseFile (&FileHandle);
}
}
}
diff --git a/ShellPkg/Library/UefiShellDebug1CommandsLib/Pci.c b/ShellPkg/Library/UefiShellDebug1CommandsLib/Pci.c
index e67c93f95..d07ae1721 100644
--- a/ShellPkg/Library/UefiShellDebug1CommandsLib/Pci.c
+++ b/ShellPkg/Library/UefiShellDebug1CommandsLib/Pci.c
@@ -2,7 +2,7 @@
Main file for Pci shell Debug1 function.
Copyright (c) 2013 Hewlett-Packard Development Company, L.P.
- Copyright (c) 2005 - 2011, Intel Corporation. All rights reserved.<BR>
+ Copyright (c) 2005 - 2014, Intel Corporation. All rights reserved.<BR>
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
@@ -1499,7 +1499,8 @@ EFI_STATUS
PciExplainData (
IN PCI_CONFIG_SPACE *ConfigSpace,
IN UINT64 Address,
- IN EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL *IoDev
+ IN EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL *IoDev,
+ IN CONST UINT16 EnhancedDump
);
/**
@@ -1627,7 +1628,8 @@ EFI_STATUS
PciExplainCapabilityStruct (
IN EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL *IoDev,
IN UINT64 Address,
- IN UINT8 CapPtr
+ IN UINT8 CapPtr,
+ IN CONST UINT16 EnhancedDump
);
/**
@@ -1641,7 +1643,8 @@ EFI_STATUS
PciExplainPciExpress (
IN EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL *IoDev,
IN UINT64 Address,
- IN UINT8 CapabilityPtr
+ IN UINT8 CapabilityPtr,
+ IN CONST UINT16 EnhancedDump
);
/**
@@ -2049,6 +2052,8 @@ ShellCommandRunPci (
CHAR16 *ProblemParam;
SHELL_STATUS ShellStatus;
CONST CHAR16 *Temp;
+ UINT64 RetVal;
+ UINT16 EnhancedDump;
ShellStatus = SHELL_SUCCESS;
Status = EFI_SUCCESS;
@@ -2302,7 +2307,16 @@ ShellCommandRunPci (
Temp = ShellCommandLineGetValue(Package, L"-s");
if (Temp != NULL) {
- Segment = (UINT16) ShellStrToUintn (Temp);
+ //
+ // Input converted to hexadecimal number.
+ //
+ if (!EFI_ERROR (ShellConvertStringToUint64 (Temp, &RetVal, TRUE, TRUE))) {
+ Segment = (UINT16) RetVal;
+ } else {
+ ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_GEN_PARAM_INV_HEX), gShellDebug1HiiHandle);
+ ShellStatus = SHELL_INVALID_PARAMETER;
+ goto Done;
+ }
}
//
@@ -2311,7 +2325,17 @@ ShellCommandRunPci (
//
Temp = ShellCommandLineGetRawValue(Package, 1);
if (Temp != NULL) {
- Bus = (UINT16)ShellStrToUintn(Temp);
+ //
+ // Input converted to hexadecimal number.
+ //
+ if (!EFI_ERROR (ShellConvertStringToUint64 (Temp, &RetVal, TRUE, TRUE))) {
+ Bus = (UINT16) RetVal;
+ } else {
+ ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_GEN_PARAM_INV_HEX), gShellDebug1HiiHandle);
+ ShellStatus = SHELL_INVALID_PARAMETER;
+ goto Done;
+ }
+
if (Bus > MAX_BUS_NUMBER) {
ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_PROBLEM), gShellDebug1HiiHandle, Temp);
ShellStatus = SHELL_INVALID_PARAMETER;
@@ -2320,7 +2344,17 @@ ShellCommandRunPci (
}
Temp = ShellCommandLineGetRawValue(Package, 2);
if (Temp != NULL) {
- Device = (UINT16) ShellStrToUintn(Temp);
+ //
+ // Input converted to hexadecimal number.
+ //
+ if (!EFI_ERROR (ShellConvertStringToUint64 (Temp, &RetVal, TRUE, TRUE))) {
+ Device = (UINT16) RetVal;
+ } else {
+ ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_GEN_PARAM_INV_HEX), gShellDebug1HiiHandle);
+ ShellStatus = SHELL_INVALID_PARAMETER;
+ goto Done;
+ }
+
if (Device > MAX_DEVICE_NUMBER){
ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_PROBLEM), gShellDebug1HiiHandle, Temp);
ShellStatus = SHELL_INVALID_PARAMETER;
@@ -2330,7 +2364,17 @@ ShellCommandRunPci (
Temp = ShellCommandLineGetRawValue(Package, 3);
if (Temp != NULL) {
- Func = (UINT16) ShellStrToUintn(Temp);
+ //
+ // Input converted to hexadecimal number.
+ //
+ if (!EFI_ERROR (ShellConvertStringToUint64 (Temp, &RetVal, TRUE, TRUE))) {
+ Func = (UINT16) RetVal;
+ } else {
+ ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_GEN_PARAM_INV_HEX), gShellDebug1HiiHandle);
+ ShellStatus = SHELL_INVALID_PARAMETER;
+ goto Done;
+ }
+
if (Func > MAX_FUNCTION_NUMBER){
ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_PROBLEM), gShellDebug1HiiHandle, Temp);
ShellStatus = SHELL_INVALID_PARAMETER;
@@ -2414,7 +2458,15 @@ ShellCommandRunPci (
// If "-i" appears in command line, interpret data in configuration space
//
if (ExplainData) {
- Status = PciExplainData (&ConfigSpace, Address, IoDev);
+ EnhancedDump = 0;
+ if (ShellCommandLineGetFlag(Package, L"-_e")) {
+ EnhancedDump = 0xFFFF;
+ Temp = ShellCommandLineGetValue(Package, L"-_e");
+ if (Temp != NULL) {
+ EnhancedDump = (UINT16) ShellHexStrToUintn (Temp);
+ }
+ }
+ Status = PciExplainData (&ConfigSpace, Address, IoDev, EnhancedDump);
}
}
Done:
@@ -2615,7 +2667,8 @@ EFI_STATUS
PciExplainData (
IN PCI_CONFIG_SPACE *ConfigSpace,
IN UINT64 Address,
- IN EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL *IoDev
+ IN EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL *IoDev,
+ IN CONST UINT16 EnhancedDump
)
{
PCI_COMMON_HEADER *Common;
@@ -2773,7 +2826,7 @@ PciExplainData (
// If Status bit4 is 1, dump or explain capability structure
//
if ((Common->Status) & EFI_PCI_STATUS_CAPABILITY) {
- PciExplainCapabilityStruct (IoDev, Address, CapPtr);
+ PciExplainCapabilityStruct (IoDev, Address, CapPtr, EnhancedDump);
}
return Status;
@@ -3747,7 +3800,8 @@ EFI_STATUS
PciExplainCapabilityStruct (
IN EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL *IoDev,
IN UINT64 Address,
- IN UINT8 CapPtr
+ IN UINT8 CapPtr,
+ IN CONST UINT16 EnhancedDump
)
{
UINT8 CapabilityPtr;
@@ -3770,7 +3824,7 @@ PciExplainCapabilityStruct (
// Explain PciExpress data
//
if (EFI_PCI_CAPABILITY_ID_PCIEXP == CapabilityID) {
- PciExplainPciExpress (IoDev, Address, CapabilityPtr);
+ PciExplainPciExpress (IoDev, Address, CapabilityPtr, EnhancedDump);
return EFI_SUCCESS;
}
//
@@ -4550,6 +4604,723 @@ ExplainPcieRootStatus (
}
/**
+ Function to interpret and print out the link control structure
+
+ @param[in] HeaderAddress The Address of this capability header.
+ @param[in] HeadersBaseAddress The address of all the extended capability headers.
+**/
+EFI_STATUS
+EFIAPI
+PrintInterpretedExtendedCompatibilityLinkControl (
+ IN CONST PCI_EXP_EXT_HDR *HeaderAddress,
+ IN CONST PCI_EXP_EXT_HDR *HeadersBaseAddress
+ )
+{
+ CONST PCI_EXPRESS_EXTENDED_CAPABILITIES_INTERNAL_LINK_CONTROL *Header;
+ Header = (PCI_EXPRESS_EXTENDED_CAPABILITIES_INTERNAL_LINK_CONTROL*)HeaderAddress;
+
+ ShellPrintHiiEx(
+ -1, -1, NULL,
+ STRING_TOKEN (STR_PCI_EXT_CAP_LINK_CONTROL),
+ gShellDebug1HiiHandle,
+ Header->RootComplexLinkCapabilities,
+ Header->RootComplexLinkControl,
+ Header->RootComplexLinkStatus
+ );
+ DumpHex (
+ 4,
+ EFI_PCIE_CAPABILITY_BASE_OFFSET + ((UINT8*)HeaderAddress - (UINT8*)HeadersBaseAddress),
+ sizeof(PCI_EXPRESS_EXTENDED_CAPABILITIES_INTERNAL_LINK_CONTROL),
+ (VOID *) (HeaderAddress)
+ );
+ return (EFI_SUCCESS);
+}
+
+/**
+ Function to interpret and print out the power budgeting structure
+
+ @param[in] HeaderAddress The Address of this capability header.
+ @param[in] HeadersBaseAddress The address of all the extended capability headers.
+**/
+EFI_STATUS
+EFIAPI
+PrintInterpretedExtendedCompatibilityPowerBudgeting (
+ IN CONST PCI_EXP_EXT_HDR *HeaderAddress,
+ IN CONST PCI_EXP_EXT_HDR *HeadersBaseAddress
+ )
+{
+ CONST PCI_EXPRESS_EXTENDED_CAPABILITIES_POWER_BUDGETING *Header;
+ Header = (PCI_EXPRESS_EXTENDED_CAPABILITIES_POWER_BUDGETING*)HeaderAddress;
+
+ ShellPrintHiiEx(
+ -1, -1, NULL,
+ STRING_TOKEN (STR_PCI_EXT_CAP_POWER),
+ gShellDebug1HiiHandle,
+ Header->DataSelect,
+ Header->Data,
+ Header->PowerBudgetCapability
+ );
+ DumpHex (
+ 4,
+ EFI_PCIE_CAPABILITY_BASE_OFFSET + ((UINT8*)HeaderAddress - (UINT8*)HeadersBaseAddress),
+ sizeof(PCI_EXPRESS_EXTENDED_CAPABILITIES_POWER_BUDGETING),
+ (VOID *) (HeaderAddress)
+ );
+ return (EFI_SUCCESS);
+}
+
+/**
+ Function to interpret and print out the ACS structure
+
+ @param[in] HeaderAddress The Address of this capability header.
+ @param[in] HeadersBaseAddress The address of all the extended capability headers.
+**/
+EFI_STATUS
+EFIAPI
+PrintInterpretedExtendedCompatibilityAcs (
+ IN CONST PCI_EXP_EXT_HDR *HeaderAddress,
+ IN CONST PCI_EXP_EXT_HDR *HeadersBaseAddress
+ )
+{
+ CONST PCI_EXPRESS_EXTENDED_CAPABILITIES_ACS_EXTENDED *Header;
+ UINT16 VectorSize;
+ UINT16 LoopCounter;
+
+ Header = (PCI_EXPRESS_EXTENDED_CAPABILITIES_ACS_EXTENDED*)HeaderAddress;
+ VectorSize = 0;
+
+ ShellPrintHiiEx(
+ -1, -1, NULL,
+ STRING_TOKEN (STR_PCI_EXT_CAP_ACS),
+ gShellDebug1HiiHandle,
+ Header->AcsCapability,
+ Header->AcsControl
+ );
+ if (PCI_EXPRESS_EXTENDED_CAPABILITY_ACS_EXTENDED_GET_EGRES_CONTROL(Header)) {
+ VectorSize = PCI_EXPRESS_EXTENDED_CAPABILITY_ACS_EXTENDED_GET_EGRES_VECTOR_SIZE(Header);
+ if (VectorSize == 0) {
+ VectorSize = 256;
+ }
+ for (LoopCounter = 0 ; LoopCounter * 8 < VectorSize ; LoopCounter++) {
+ ShellPrintHiiEx(
+ -1, -1, NULL,
+ STRING_TOKEN (STR_PCI_EXT_CAP_ACS2),
+ gShellDebug1HiiHandle,
+ LoopCounter + 1,
+ Header->EgressControlVectorArray[LoopCounter]
+ );
+ }
+ }
+ DumpHex (
+ 4,
+ EFI_PCIE_CAPABILITY_BASE_OFFSET + ((UINT8*)HeaderAddress - (UINT8*)HeadersBaseAddress),
+ sizeof(PCI_EXPRESS_EXTENDED_CAPABILITIES_ACS_EXTENDED) + (VectorSize / 8) - 1,
+ (VOID *) (HeaderAddress)
+ );
+ return (EFI_SUCCESS);
+}
+
+/**
+ Function to interpret and print out the latency tolerance reporting structure
+
+ @param[in] HeaderAddress The Address of this capability header.
+ @param[in] HeadersBaseAddress The address of all the extended capability headers.
+**/
+EFI_STATUS
+EFIAPI
+PrintInterpretedExtendedCompatibilityLatencyToleranceReporting (
+ IN CONST PCI_EXP_EXT_HDR *HeaderAddress,
+ IN CONST PCI_EXP_EXT_HDR *HeadersBaseAddress
+ )
+{
+ CONST PCI_EXPRESS_EXTENDED_CAPABILITIES_LATENCE_TOLERANCE_REPORTING *Header;
+ Header = (PCI_EXPRESS_EXTENDED_CAPABILITIES_LATENCE_TOLERANCE_REPORTING*)HeaderAddress;
+
+ ShellPrintHiiEx(
+ -1, -1, NULL,
+ STRING_TOKEN (STR_PCI_EXT_CAP_LAT),
+ gShellDebug1HiiHandle,
+ Header->MaxSnoopLatency,
+ Header->MaxNoSnoopLatency
+ );
+ DumpHex (
+ 4,
+ EFI_PCIE_CAPABILITY_BASE_OFFSET + ((UINT8*)HeaderAddress - (UINT8*)HeadersBaseAddress),
+ sizeof(PCI_EXPRESS_EXTENDED_CAPABILITIES_LATENCE_TOLERANCE_REPORTING),
+ (VOID *) (HeaderAddress)
+ );
+ return (EFI_SUCCESS);
+}
+
+/**
+ Function to interpret and print out the serial number structure
+
+ @param[in] HeaderAddress The Address of this capability header.
+ @param[in] HeadersBaseAddress The address of all the extended capability headers.
+**/
+EFI_STATUS
+EFIAPI
+PrintInterpretedExtendedCompatibilitySerialNumber (
+ IN CONST PCI_EXP_EXT_HDR *HeaderAddress,
+ IN CONST PCI_EXP_EXT_HDR *HeadersBaseAddress
+ )
+{
+ CONST PCI_EXPRESS_EXTENDED_CAPABILITIES_SERIAL_NUMBER *Header;
+ Header = (PCI_EXPRESS_EXTENDED_CAPABILITIES_SERIAL_NUMBER*)HeaderAddress;
+
+ ShellPrintHiiEx(
+ -1, -1, NULL,
+ STRING_TOKEN (STR_PCI_EXT_CAP_SN),
+ gShellDebug1HiiHandle,
+ Header->SerialNumber
+ );
+ DumpHex (
+ 4,
+ EFI_PCIE_CAPABILITY_BASE_OFFSET + ((UINT8*)HeaderAddress - (UINT8*)HeadersBaseAddress),
+ sizeof(PCI_EXPRESS_EXTENDED_CAPABILITIES_SERIAL_NUMBER),
+ (VOID *) (HeaderAddress)
+ );
+ return (EFI_SUCCESS);
+}
+
+/**
+ Function to interpret and print out the RCRB structure
+
+ @param[in] HeaderAddress The Address of this capability header.
+ @param[in] HeadersBaseAddress The address of all the extended capability headers.
+**/
+EFI_STATUS
+EFIAPI
+PrintInterpretedExtendedCompatibilityRcrb (
+ IN CONST PCI_EXP_EXT_HDR *HeaderAddress,
+ IN CONST PCI_EXP_EXT_HDR *HeadersBaseAddress
+ )
+{
+ CONST PCI_EXPRESS_EXTENDED_CAPABILITIES_RCRB_HEADER *Header;
+ Header = (PCI_EXPRESS_EXTENDED_CAPABILITIES_RCRB_HEADER*)HeaderAddress;
+
+ ShellPrintHiiEx(
+ -1, -1, NULL,
+ STRING_TOKEN (STR_PCI_EXT_CAP_RCRB),
+ gShellDebug1HiiHandle,
+ Header->VendorId,
+ Header->DeviceId,
+ Header->RcrbCapabilities,
+ Header->RcrbControl
+ );
+ DumpHex (
+ 4,
+ EFI_PCIE_CAPABILITY_BASE_OFFSET + ((UINT8*)HeaderAddress - (UINT8*)HeadersBaseAddress),
+ sizeof(PCI_EXPRESS_EXTENDED_CAPABILITIES_RCRB_HEADER),
+ (VOID *) (HeaderAddress)
+ );
+ return (EFI_SUCCESS);
+}
+
+/**
+ Function to interpret and print out the vendor specific structure
+
+ @param[in] HeaderAddress The Address of this capability header.
+ @param[in] HeadersBaseAddress The address of all the extended capability headers.
+**/
+EFI_STATUS
+EFIAPI
+PrintInterpretedExtendedCompatibilityVendorSpecific (
+ IN CONST PCI_EXP_EXT_HDR *HeaderAddress,
+ IN CONST PCI_EXP_EXT_HDR *HeadersBaseAddress
+ )
+{
+ CONST PCI_EXPRESS_EXTENDED_CAPABILITIES_VENDOR_SPECIFIC *Header;
+ Header = (PCI_EXPRESS_EXTENDED_CAPABILITIES_VENDOR_SPECIFIC*)HeaderAddress;
+
+ ShellPrintHiiEx(
+ -1, -1, NULL,
+ STRING_TOKEN (STR_PCI_EXT_CAP_VEN),
+ gShellDebug1HiiHandle,
+ Header->VendorSpecificHeader
+ );
+ DumpHex (
+ 4,
+ EFI_PCIE_CAPABILITY_BASE_OFFSET + ((UINT8*)HeaderAddress - (UINT8*)HeadersBaseAddress),
+ PCI_EXPRESS_EXTENDED_CAPABILITY_VENDOR_SPECIFIC_GET_SIZE(Header),
+ (VOID *) (HeaderAddress)
+ );
+ return (EFI_SUCCESS);
+}
+
+/**
+ Function to interpret and print out the Event Collector Endpoint Association structure
+
+ @param[in] HeaderAddress The Address of this capability header.
+ @param[in] HeadersBaseAddress The address of all the extended capability headers.
+**/
+EFI_STATUS
+EFIAPI
+PrintInterpretedExtendedCompatibilityECEA (
+ IN CONST PCI_EXP_EXT_HDR *HeaderAddress,
+ IN CONST PCI_EXP_EXT_HDR *HeadersBaseAddress
+ )
+{
+ CONST PCI_EXPRESS_EXTENDED_CAPABILITIES_EVENT_COLLECTOR_ENDPOINT_ASSOCIATION *Header;
+ Header = (PCI_EXPRESS_EXTENDED_CAPABILITIES_EVENT_COLLECTOR_ENDPOINT_ASSOCIATION*)HeaderAddress;
+
+ ShellPrintHiiEx(
+ -1, -1, NULL,
+ STRING_TOKEN (STR_PCI_EXT_CAP_ECEA),
+ gShellDebug1HiiHandle,
+ Header->AssociationBitmap
+ );
+ DumpHex (
+ 4,
+ EFI_PCIE_CAPABILITY_BASE_OFFSET + ((UINT8*)HeaderAddress - (UINT8*)HeadersBaseAddress),
+ sizeof(PCI_EXPRESS_EXTENDED_CAPABILITIES_EVENT_COLLECTOR_ENDPOINT_ASSOCIATION),
+ (VOID *) (HeaderAddress)
+ );
+ return (EFI_SUCCESS);
+}
+
+/**
+ Function to interpret and print out the ARI structure
+
+ @param[in] HeaderAddress The Address of this capability header.
+ @param[in] HeadersBaseAddress The address of all the extended capability headers.
+**/
+EFI_STATUS
+EFIAPI
+PrintInterpretedExtendedCompatibilityAri (
+ IN CONST PCI_EXP_EXT_HDR *HeaderAddress,
+ IN CONST PCI_EXP_EXT_HDR *HeadersBaseAddress
+ )
+{
+ CONST PCI_EXPRESS_EXTENDED_CAPABILITIES_ARI_CAPABILITY *Header;
+ Header = (PCI_EXPRESS_EXTENDED_CAPABILITIES_ARI_CAPABILITY*)HeaderAddress;
+
+ ShellPrintHiiEx(
+ -1, -1, NULL,
+ STRING_TOKEN (STR_PCI_EXT_CAP_ARI),
+ gShellDebug1HiiHandle,
+ Header->AriCapability,
+ Header->AriControl
+ );
+ DumpHex (
+ 4,
+ EFI_PCIE_CAPABILITY_BASE_OFFSET + ((UINT8*)HeaderAddress - (UINT8*)HeadersBaseAddress),
+ sizeof(PCI_EXPRESS_EXTENDED_CAPABILITIES_ARI_CAPABILITY),
+ (VOID *) (HeaderAddress)
+ );
+ return (EFI_SUCCESS);
+}
+
+/**
+ Function to interpret and print out the DPA structure
+
+ @param[in] HeaderAddress The Address of this capability header.
+ @param[in] HeadersBaseAddress The address of all the extended capability headers.
+**/
+EFI_STATUS
+EFIAPI
+PrintInterpretedExtendedCompatibilityDynamicPowerAllocation (
+ IN CONST PCI_EXP_EXT_HDR *HeaderAddress,
+ IN CONST PCI_EXP_EXT_HDR *HeadersBaseAddress
+ )
+{
+ CONST PCI_EXPRESS_EXTENDED_CAPABILITIES_DYNAMIC_POWER_ALLOCATION *Header;
+ UINT8 LinkCount;
+ Header = (PCI_EXPRESS_EXTENDED_CAPABILITIES_DYNAMIC_POWER_ALLOCATION*)HeaderAddress;
+
+ ShellPrintHiiEx(
+ -1, -1, NULL,
+ STRING_TOKEN (STR_PCI_EXT_CAP_DPA),
+ gShellDebug1HiiHandle,
+ Header->DpaCapability,
+ Header->DpaLatencyIndicator,
+ Header->DpaStatus,
+ Header->DpaControl
+ );
+ for (LinkCount = 0 ; LinkCount < PCI_EXPRESS_EXTENDED_CAPABILITY_DYNAMIC_POWER_ALLOCATION_GET_SUBSTATE_MAX(Header) + 1 ; LinkCount++) {
+ ShellPrintHiiEx(
+ -1, -1, NULL,
+ STRING_TOKEN (STR_PCI_EXT_CAP_DPA2),
+ gShellDebug1HiiHandle,
+ LinkCount+1,
+ Header->DpaPowerAllocationArray[LinkCount]
+ );
+ }
+ DumpHex (
+ 4,
+ EFI_PCIE_CAPABILITY_BASE_OFFSET + ((UINT8*)HeaderAddress - (UINT8*)HeadersBaseAddress),
+ sizeof(PCI_EXPRESS_EXTENDED_CAPABILITIES_DYNAMIC_POWER_ALLOCATION) - 1 + PCI_EXPRESS_EXTENDED_CAPABILITY_DYNAMIC_POWER_ALLOCATION_GET_SUBSTATE_MAX(Header),
+ (VOID *) (HeaderAddress)
+ );
+ return (EFI_SUCCESS);
+}
+
+/**
+ Function to interpret and print out the link declaration structure
+
+ @param[in] HeaderAddress The Address of this capability header.
+ @param[in] HeadersBaseAddress The address of all the extended capability headers.
+**/
+EFI_STATUS
+EFIAPI
+PrintInterpretedExtendedCompatibilityLinkDeclaration (
+ IN CONST PCI_EXP_EXT_HDR *HeaderAddress,
+ IN CONST PCI_EXP_EXT_HDR *HeadersBaseAddress
+ )
+{
+ CONST PCI_EXPRESS_EXTENDED_CAPABILITIES_LINK_DECLARATION *Header;
+ UINT8 LinkCount;
+ Header = (PCI_EXPRESS_EXTENDED_CAPABILITIES_LINK_DECLARATION*)HeaderAddress;
+
+ ShellPrintHiiEx(
+ -1, -1, NULL,
+ STRING_TOKEN (STR_PCI_EXT_CAP_LINK_DECLAR),
+ gShellDebug1HiiHandle,
+ Header->ElementSelfDescription
+ );
+
+ for (LinkCount = 0 ; LinkCount < PCI_EXPRESS_EXTENDED_CAPABILITY_LINK_DECLARATION_GET_LINK_COUNT(Header) ; LinkCount++) {
+ ShellPrintHiiEx(
+ -1, -1, NULL,
+ STRING_TOKEN (STR_PCI_EXT_CAP_LINK_DECLAR2),
+ gShellDebug1HiiHandle,
+ LinkCount+1,
+ Header->LinkEntry[LinkCount]
+ );
+ }
+ DumpHex (
+ 4,
+ EFI_PCIE_CAPABILITY_BASE_OFFSET + ((UINT8*)HeaderAddress - (UINT8*)HeadersBaseAddress),
+ sizeof(PCI_EXPRESS_EXTENDED_CAPABILITIES_LINK_DECLARATION) + (PCI_EXPRESS_EXTENDED_CAPABILITY_LINK_DECLARATION_GET_LINK_COUNT(Header)-1)*sizeof(UINT32),
+ (VOID *) (HeaderAddress)
+ );
+ return (EFI_SUCCESS);
+}
+
+/**
+ Function to interpret and print out the Advanced Error Reporting structure
+
+ @param[in] HeaderAddress The Address of this capability header.
+ @param[in] HeadersBaseAddress The address of all the extended capability headers.
+**/
+EFI_STATUS
+EFIAPI
+PrintInterpretedExtendedCompatibilityAer (
+ IN CONST PCI_EXP_EXT_HDR *HeaderAddress,
+ IN CONST PCI_EXP_EXT_HDR *HeadersBaseAddress
+ )
+{
+ CONST PCI_EXPRESS_EXTENDED_CAPABILITIES_ADVANCED_ERROR_REPORTING *Header;
+ Header = (PCI_EXPRESS_EXTENDED_CAPABILITIES_ADVANCED_ERROR_REPORTING*)HeaderAddress;
+
+ ShellPrintHiiEx(
+ -1, -1, NULL,
+ STRING_TOKEN (STR_PCI_EXT_CAP_AER),
+ gShellDebug1HiiHandle,
+ Header->UncorrectableErrorStatus,
+ Header->UncorrectableErrorMask,
+ Header->UncorrectableErrorSeverity,
+ Header->CorrectableErrorStatus,
+ Header->CorrectableErrorMask,
+ Header->AdvancedErrorCapabilitiesAndControl,
+ Header->HeaderLog,
+ Header->RootErrorCommand,
+ Header->RootErrorStatus,
+ Header->ErrorSourceIdentification,
+ Header->CorrectableErrorSourceIdentification,
+ Header->TlpPrefixLog[0],
+ Header->TlpPrefixLog[1],
+ Header->TlpPrefixLog[2],
+ Header->TlpPrefixLog[3]
+ );
+ DumpHex (
+ 4,
+ EFI_PCIE_CAPABILITY_BASE_OFFSET + ((UINT8*)HeaderAddress - (UINT8*)HeadersBaseAddress),
+ sizeof(PCI_EXPRESS_EXTENDED_CAPABILITIES_ADVANCED_ERROR_REPORTING),
+ (VOID *) (HeaderAddress)
+ );
+ return (EFI_SUCCESS);
+}
+
+/**
+ Function to interpret and print out the multicast structure
+
+ @param[in] HeaderAddress The Address of this capability header.
+ @param[in] HeadersBaseAddress The address of all the extended capability headers.
+ @param[in] PciExpressCapPtr The address of the PCIe capabilities structure.
+**/
+EFI_STATUS
+EFIAPI
+PrintInterpretedExtendedCompatibilityMulticast (
+ IN CONST PCI_EXP_EXT_HDR *HeaderAddress,
+ IN CONST PCI_EXP_EXT_HDR *HeadersBaseAddress,
+ IN CONST PCIE_CAP_STURCTURE *PciExpressCapPtr
+ )
+{
+ CONST PCI_EXPRESS_EXTENDED_CAPABILITIES_MULTICAST *Header;
+ Header = (PCI_EXPRESS_EXTENDED_CAPABILITIES_MULTICAST*)HeaderAddress;
+
+ ShellPrintHiiEx(
+ -1, -1, NULL,
+ STRING_TOKEN (STR_PCI_EXT_CAP_MULTICAST),
+ gShellDebug1HiiHandle,
+ Header->MultiCastCapability,
+ Header->MulticastControl,
+ Header->McBaseAddress,
+ Header->McReceiveAddress,
+ Header->McBlockAll,
+ Header->McBlockUntranslated,
+ Header->McOverlayBar
+ );
+
+ DumpHex (
+ 4,
+ EFI_PCIE_CAPABILITY_BASE_OFFSET + ((UINT8*)HeaderAddress - (UINT8*)HeadersBaseAddress),
+ sizeof(PCI_EXPRESS_EXTENDED_CAPABILITIES_MULTICAST),
+ (VOID *) (HeaderAddress)
+ );
+
+ return (EFI_SUCCESS);
+}
+
+/**
+ Function to interpret and print out the virtual channel and multi virtual channel structure
+
+ @param[in] HeaderAddress The Address of this capability header.
+ @param[in] HeadersBaseAddress The address of all the extended capability headers.
+**/
+EFI_STATUS
+EFIAPI
+PrintInterpretedExtendedCompatibilityVirtualChannel (
+ IN CONST PCI_EXP_EXT_HDR *HeaderAddress,
+ IN CONST PCI_EXP_EXT_HDR *HeadersBaseAddress
+ )
+{
+ CONST PCI_EXPRESS_EXTENDED_CAPABILITIES_VIRTUAL_CHANNEL_CAPABILITY *Header;
+ CONST PCI_EXPRESS_EXTENDED_CAPABILITIES_VIRTUAL_CHANNEL_VC *CapabilityItem;
+ UINT32 ItemCount;
+ Header = (PCI_EXPRESS_EXTENDED_CAPABILITIES_VIRTUAL_CHANNEL_CAPABILITY*)HeaderAddress;
+
+ ShellPrintHiiEx(
+ -1, -1, NULL,
+ STRING_TOKEN (STR_PCI_EXT_CAP_VC_BASE),
+ gShellDebug1HiiHandle,
+ Header->ExtendedVcCount,
+ Header->PortVcCapability1,
+ Header->PortVcCapability2,
+ Header->VcArbTableOffset,
+ Header->PortVcControl,
+ Header->PortVcStatus
+ );
+ for (ItemCount = 0 ; ItemCount < Header->ExtendedVcCount ; ItemCount++) {
+ CapabilityItem = &Header->Capability[ItemCount];
+ ShellPrintHiiEx(
+ -1, -1, NULL,
+ STRING_TOKEN (STR_PCI_EXT_CAP_VC_ITEM),
+ gShellDebug1HiiHandle,
+ ItemCount+1,
+ CapabilityItem->VcResourceCapability,
+ CapabilityItem->PortArbTableOffset,
+ CapabilityItem->VcResourceControl,
+ CapabilityItem->VcResourceStatus
+ );
+ }
+
+ DumpHex (
+ 4,
+ EFI_PCIE_CAPABILITY_BASE_OFFSET + ((UINT8*)HeaderAddress - (UINT8*)HeadersBaseAddress),
+ sizeof(PCI_EXPRESS_EXTENDED_CAPABILITIES_VIRTUAL_CHANNEL_VC) + (Header->ExtendedVcCount - 1) * sizeof(PCI_EXPRESS_EXTENDED_CAPABILITIES_VIRTUAL_CHANNEL_CAPABILITY),
+ (VOID *) (HeaderAddress)
+ );
+
+ return (EFI_SUCCESS);
+}
+
+/**
+ Function to interpret and print out the resizeable bar structure
+
+ @param[in] HeaderAddress The Address of this capability header.
+ @param[in] HeadersBaseAddress The address of all the extended capability headers.
+**/
+EFI_STATUS
+EFIAPI
+PrintInterpretedExtendedCompatibilityResizeableBar (
+ IN CONST PCI_EXP_EXT_HDR *HeaderAddress,
+ IN CONST PCI_EXP_EXT_HDR *HeadersBaseAddress
+ )
+{
+ CONST PCI_EXPRESS_EXTENDED_CAPABILITIES_RESIZABLE_BAR *Header;
+ UINT32 ItemCount;
+ Header = (PCI_EXPRESS_EXTENDED_CAPABILITIES_RESIZABLE_BAR*)HeaderAddress;
+
+ for (ItemCount = 0 ; ItemCount < (UINT32)GET_NUMBER_RESIZABLE_BARS(Header) ; ItemCount++) {
+ ShellPrintHiiEx(
+ -1, -1, NULL,
+ STRING_TOKEN (STR_PCI_EXT_CAP_RESIZE_BAR),
+ gShellDebug1HiiHandle,
+ ItemCount+1,
+ Header->Capability[ItemCount].ResizableBarCapability,
+ Header->Capability[ItemCount].ResizableBarControl
+ );
+ }
+
+ DumpHex (
+ 4,
+ EFI_PCIE_CAPABILITY_BASE_OFFSET + ((UINT8*)HeaderAddress - (UINT8*)HeadersBaseAddress),
+ (UINT32)GET_NUMBER_RESIZABLE_BARS(Header) * sizeof(PCI_EXPRESS_EXTENDED_CAPABILITIES_RESIZABLE_BAR_ENTRY),
+ (VOID *) (HeaderAddress)
+ );
+
+ return (EFI_SUCCESS);
+}
+
+/**
+ Function to interpret and print out the TPH structure
+
+ @param[in] HeaderAddress The Address of this capability header.
+ @param[in] HeadersBaseAddress The address of all the extended capability headers.
+**/
+EFI_STATUS
+EFIAPI
+PrintInterpretedExtendedCompatibilityTph (
+ IN CONST PCI_EXP_EXT_HDR *HeaderAddress,
+ IN CONST PCI_EXP_EXT_HDR *HeadersBaseAddress
+ )
+{
+ CONST PCI_EXPRESS_EXTENDED_CAPABILITIES_TPH *Header;
+ Header = (PCI_EXPRESS_EXTENDED_CAPABILITIES_TPH*)HeaderAddress;
+
+ ShellPrintHiiEx(
+ -1, -1, NULL,
+ STRING_TOKEN (STR_PCI_EXT_CAP_TPH),
+ gShellDebug1HiiHandle,
+ Header->TphRequesterCapability,
+ Header->TphRequesterControl
+ );
+ DumpHex (
+ 8,
+ EFI_PCIE_CAPABILITY_BASE_OFFSET + ((UINT8*)Header->TphStTable - (UINT8*)HeadersBaseAddress),
+ GET_TPH_TABLE_SIZE(Header),
+ (VOID *)Header->TphStTable
+ );
+
+ DumpHex (
+ 4,
+ EFI_PCIE_CAPABILITY_BASE_OFFSET + ((UINT8*)HeaderAddress - (UINT8*)HeadersBaseAddress),
+ sizeof(PCI_EXPRESS_EXTENDED_CAPABILITIES_TPH) + GET_TPH_TABLE_SIZE(Header) - sizeof(UINT16),
+ (VOID *) (HeaderAddress)
+ );
+
+ return (EFI_SUCCESS);
+}
+
+/**
+ Function to interpret and print out the secondary PCIe capability structure
+
+ @param[in] HeaderAddress The Address of this capability header.
+ @param[in] HeadersBaseAddress The address of all the extended capability headers.
+ @param[in] PciExpressCapPtr The address of the PCIe capabilities structure.
+**/
+EFI_STATUS
+EFIAPI
+PrintInterpretedExtendedCompatibilitySecondary (
+ IN CONST PCI_EXP_EXT_HDR *HeaderAddress,
+ IN CONST PCI_EXP_EXT_HDR *HeadersBaseAddress,
+ IN CONST PCIE_CAP_STURCTURE *PciExpressCapPtr
+ )
+{
+ CONST PCI_EXPRESS_EXTENDED_CAPABILITIES_SECONDARY_PCIE *Header;
+ Header = (PCI_EXPRESS_EXTENDED_CAPABILITIES_SECONDARY_PCIE*)HeaderAddress;
+
+ ShellPrintHiiEx(
+ -1, -1, NULL,
+ STRING_TOKEN (STR_PCI_EXT_CAP_SECONDARY),
+ gShellDebug1HiiHandle,
+ Header->LinkControl3,
+ Header->LaneErrorStatus
+ );
+ DumpHex (
+ 8,
+ EFI_PCIE_CAPABILITY_BASE_OFFSET + ((UINT8*)Header->EqualizationControl - (UINT8*)HeadersBaseAddress),
+ PCIE_CAP_MAX_LINK_WIDTH(PciExpressCapPtr->LinkCap),
+ (VOID *)Header->EqualizationControl
+ );
+
+ DumpHex (
+ 4,
+ EFI_PCIE_CAPABILITY_BASE_OFFSET + ((UINT8*)HeaderAddress - (UINT8*)HeadersBaseAddress),
+ sizeof(PCI_EXPRESS_EXTENDED_CAPABILITIES_TPH) - sizeof(Header->EqualizationControl) + PCIE_CAP_MAX_LINK_WIDTH(PciExpressCapPtr->LinkCap),
+ (VOID *) (HeaderAddress)
+ );
+
+ return (EFI_SUCCESS);
+}
+
+/**
+ Display Pcie extended capability details
+
+ @param[in] HeadersBaseAddress The address of all the extended capability headers.
+ @param[in] HeaderAddress The address of this capability header.
+ @param[in] PciExpressCapPtr The address of the PCIe capabilities structure.
+**/
+EFI_STATUS
+EFIAPI
+PrintPciExtendedCapabilityDetails(
+ IN CONST PCI_EXP_EXT_HDR *HeadersBaseAddress,
+ IN CONST PCI_EXP_EXT_HDR *HeaderAddress,
+ IN CONST PCIE_CAP_STURCTURE *PciExpressCapPtr
+ )
+{
+ switch (HeaderAddress->CapabilityId){
+ case PCI_EXPRESS_EXTENDED_CAPABILITY_ADVANCED_ERROR_REPORTING_ID:
+ return PrintInterpretedExtendedCompatibilityAer(HeaderAddress, HeadersBaseAddress);
+ case PCI_EXPRESS_EXTENDED_CAPABILITY_LINK_CONTROL_ID:
+ return PrintInterpretedExtendedCompatibilityLinkControl(HeaderAddress, HeadersBaseAddress);
+ case PCI_EXPRESS_EXTENDED_CAPABILITY_LINK_DECLARATION_ID:
+ return PrintInterpretedExtendedCompatibilityLinkDeclaration(HeaderAddress, HeadersBaseAddress);
+ case PCI_EXPRESS_EXTENDED_CAPABILITY_SERIAL_NUMBER_ID:
+ return PrintInterpretedExtendedCompatibilitySerialNumber(HeaderAddress, HeadersBaseAddress);
+ case PCI_EXPRESS_EXTENDED_CAPABILITY_POWER_BUDGETING_ID:
+ return PrintInterpretedExtendedCompatibilityPowerBudgeting(HeaderAddress, HeadersBaseAddress);
+ case PCI_EXPRESS_EXTENDED_CAPABILITY_ACS_EXTENDED_ID:
+ return PrintInterpretedExtendedCompatibilityAcs(HeaderAddress, HeadersBaseAddress);
+ case PCI_EXPRESS_EXTENDED_CAPABILITY_LATENCE_TOLERANCE_REPORTING_ID:
+ return PrintInterpretedExtendedCompatibilityLatencyToleranceReporting(HeaderAddress, HeadersBaseAddress);
+ case PCI_EXPRESS_EXTENDED_CAPABILITY_ARI_CAPABILITY_ID:
+ return PrintInterpretedExtendedCompatibilityAri(HeaderAddress, HeadersBaseAddress);
+ case PCI_EXPRESS_EXTENDED_CAPABILITY_RCRB_HEADER_ID:
+ return PrintInterpretedExtendedCompatibilityRcrb(HeaderAddress, HeadersBaseAddress);
+ case PCI_EXPRESS_EXTENDED_CAPABILITY_VENDOR_SPECIFIC_ID:
+ return PrintInterpretedExtendedCompatibilityVendorSpecific(HeaderAddress, HeadersBaseAddress);
+ case PCI_EXPRESS_EXTENDED_CAPABILITY_DYNAMIC_POWER_ALLOCATION_ID:
+ return PrintInterpretedExtendedCompatibilityDynamicPowerAllocation(HeaderAddress, HeadersBaseAddress);
+ case PCI_EXPRESS_EXTENDED_CAPABILITY_EVENT_COLLECTOR_ENDPOINT_ASSOCIATION_ID:
+ return PrintInterpretedExtendedCompatibilityECEA(HeaderAddress, HeadersBaseAddress);
+ case PCI_EXPRESS_EXTENDED_CAPABILITY_VIRTUAL_CHANNEL_ID:
+ case PCI_EXPRESS_EXTENDED_CAPABILITY_MULTI_FUNCTION_VIRTUAL_CHANNEL_ID:
+ return PrintInterpretedExtendedCompatibilityVirtualChannel(HeaderAddress, HeadersBaseAddress);
+ case PCI_EXPRESS_EXTENDED_CAPABILITY_MULTICAST_ID:
+ //
+ // should only be present if PCIE_CAP_DEVICEPORT_TYPE(PciExpressCapPtr->PcieCapReg) == 0100b, 0101b, or 0110b
+ //
+ return PrintInterpretedExtendedCompatibilityMulticast(HeaderAddress, HeadersBaseAddress, PciExpressCapPtr);
+ case PCI_EXPRESS_EXTENDED_CAPABILITY_RESIZABLE_BAR_ID:
+ return PrintInterpretedExtendedCompatibilityResizeableBar(HeaderAddress, HeadersBaseAddress);
+ case PCI_EXPRESS_EXTENDED_CAPABILITY_TPH_ID:
+ return PrintInterpretedExtendedCompatibilityTph(HeaderAddress, HeadersBaseAddress);
+ case PCI_EXPRESS_EXTENDED_CAPABILITY_SECONDARY_PCIE_ID:
+ return PrintInterpretedExtendedCompatibilitySecondary(HeaderAddress, HeadersBaseAddress, PciExpressCapPtr);
+ default:
+ ShellPrintEx (-1, -1,
+ L"Unknown PCIe extended capability ID (%04xh). No interpretation available.\r\n",
+ HeaderAddress->CapabilityId
+ );
+ return EFI_SUCCESS;
+ };
+
+}
+
+/**
Display Pcie device structure.
@param[in] IoDev The pointer to the root pci protocol.
@@ -4560,7 +5331,8 @@ EFI_STATUS
PciExplainPciExpress (
IN EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL *IoDev,
IN UINT64 Address,
- IN UINT8 CapabilityPtr
+ IN UINT8 CapabilityPtr,
+ IN CONST UINT16 EnhancedDump
)
{
@@ -4577,6 +5349,7 @@ PciExplainPciExpress (
UINTN Index;
UINT8 *RegAddr;
UINTN RegValue;
+ PCI_EXP_EXT_HDR *ExtHdr;
CapRegAddress = Address + CapabilityPtr;
IoDev->Pci.Read (
@@ -4663,15 +5436,15 @@ PciExplainPciExpress (
Dev = (UINT8) (RShiftU64 (Address, 16));
Func = (UINT8) (RShiftU64 (Address, 8));
- Pciex_Address = CALC_EFI_PCIEX_ADDRESS (Bus, Dev, Func, 0x100);
+ Pciex_Address = CALC_EFI_PCIEX_ADDRESS (Bus, Dev, Func, EFI_PCIE_CAPABILITY_BASE_OFFSET);
- ExtendRegSize = 0x1000 - 0x100;
+ ExtendRegSize = 0x1000 - EFI_PCIE_CAPABILITY_BASE_OFFSET;
ExRegBuffer = (UINT8 *) AllocateZeroPool (ExtendRegSize);
//
// PciRootBridgeIo protocol should support pci express extend space IO
- // (Begins at offset 0x100)
+ // (Begins at offset EFI_PCIE_CAPABILITY_BASE_OFFSET)
//
Status = IoDev->Pci.Read (
IoDev,
@@ -4680,25 +5453,47 @@ PciExplainPciExpress (
(ExtendRegSize) / sizeof (UINT32),
(VOID *) (ExRegBuffer)
);
- if (EFI_ERROR (Status)) {
- FreePool ((VOID *) ExRegBuffer);
+ if (EFI_ERROR (Status) || ExRegBuffer == NULL) {
+ SHELL_FREE_NON_NULL(ExRegBuffer);
return EFI_UNSUPPORTED;
}
- //
- // Start outputing PciEx extend space( 0xFF-0xFFF)
- //
- ShellPrintEx (-1, -1, L"\r\n%HStart dumping PCIex extended configuration space (0x100 - 0xFFF).%N\r\n\r\n");
- if (ExRegBuffer != NULL) {
+ if (EnhancedDump == 0) {
+ //
+ // Print the PciEx extend space in raw bytes ( 0xFF-0xFFF)
+ //
+ ShellPrintEx (-1, -1, L"\r\n%HStart dumping PCIex extended configuration space (0x100 - 0xFFF).%N\r\n\r\n");
+
DumpHex (
2,
- 0x100,
+ EFI_PCIE_CAPABILITY_BASE_OFFSET,
ExtendRegSize,
(VOID *) (ExRegBuffer)
- );
+ );
+ } else {
+ ExtHdr = (PCI_EXP_EXT_HDR*)ExRegBuffer;
+ while (ExtHdr->CapabilityId != 0 && ExtHdr->CapabilityVersion != 0) {
+ //
+ // Process this item
+ //
+ if (EnhancedDump == 0xFFFF || EnhancedDump == ExtHdr->CapabilityId) {
+ //
+ // Print this item
+ //
+ PrintPciExtendedCapabilityDetails((PCI_EXP_EXT_HDR*)ExRegBuffer, ExtHdr, &PciExpressCap);
+ }
- FreePool ((VOID *) ExRegBuffer);
+ //
+ // Advance to the next item if it exists
+ //
+ if (ExtHdr->NextCapabilityOffset != 0) {
+ ExtHdr = (PCI_EXP_EXT_HDR*)((UINT8*)ExRegBuffer + ExtHdr->NextCapabilityOffset);
+ } else {
+ break;
+ }
+ }
}
+ SHELL_FREE_NON_NULL(ExRegBuffer);
Done:
return EFI_SUCCESS;
diff --git a/ShellPkg/Library/UefiShellDebug1CommandsLib/UefiShellDebug1CommandsLib.uni b/ShellPkg/Library/UefiShellDebug1CommandsLib/UefiShellDebug1CommandsLib.uni
index 2dfb808c0..65d058fc4 100644
--- a/ShellPkg/Library/UefiShellDebug1CommandsLib/UefiShellDebug1CommandsLib.uni
+++ b/ShellPkg/Library/UefiShellDebug1CommandsLib/UefiShellDebug1CommandsLib.uni
Binary files differ
diff --git a/ShellPkg/Library/UefiShellInstall1CommandsLib/Bcfg.c b/ShellPkg/Library/UefiShellInstall1CommandsLib/Bcfg.c
index 543ae376e..b91b34ffa 100644
--- a/ShellPkg/Library/UefiShellInstall1CommandsLib/Bcfg.c
+++ b/ShellPkg/Library/UefiShellInstall1CommandsLib/Bcfg.c
@@ -48,16 +48,6 @@ typedef struct {
} BGFG_OPERATION;
/**
- Get the actual number of entries in EFI_KEY_OPTION.Keys, from 0-3.
-
- @param KeyOption Pointer to the EFI_KEY_OPTION structure.
-
- @return Actual number of entries in EFI_KEY_OPTION.Keys.
-**/
-#define KEY_OPTION_INPUT_KEY_COUNT(KeyOption) \
- (((KeyOption)->KeyData & EFI_KEY_OPTION_INPUT_KEY_COUNT_MASK) >> LowBitSet32 (EFI_KEY_OPTION_INPUT_KEY_COUNT_MASK))
-
-/**
Update the optional data for a boot or driver option.
If optional data exists it will be changed.
@@ -841,7 +831,7 @@ BcfgAddOptInstall1(
ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_PROBLEM), gShellInstall1HiiHandle, Walker);
ShellStatus = SHELL_INVALID_PARAMETER;
}
- NewKeyOption.KeyData = (UINT32)Intermediate;
+ NewKeyOption.KeyData.PackedValue = (UINT32)Intermediate;
Temp = StrStr(Walker, L" ");
if (Temp != NULL) {
Walker = Temp;
@@ -856,13 +846,13 @@ BcfgAddOptInstall1(
// Now we know how many EFI_INPUT_KEY structs we need to attach to the end of the EFI_KEY_OPTION struct.
// Re-allocate with the added information.
//
- KeyOptionBuffer = AllocateCopyPool(sizeof(EFI_KEY_OPTION) + (sizeof(EFI_INPUT_KEY) * KEY_OPTION_INPUT_KEY_COUNT (&NewKeyOption)), &NewKeyOption);
+ KeyOptionBuffer = AllocateCopyPool(sizeof(EFI_KEY_OPTION) + (sizeof(EFI_INPUT_KEY) * NewKeyOption.KeyData.Options.InputKeyCount), &NewKeyOption);
if (KeyOptionBuffer == NULL) {
ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_NO_MEM), gShellInstall1HiiHandle);
ShellStatus = SHELL_OUT_OF_RESOURCES;
}
}
- for (LoopCounter = 0 ; ShellStatus == SHELL_SUCCESS && LoopCounter < KEY_OPTION_INPUT_KEY_COUNT (&NewKeyOption); LoopCounter++) {
+ for (LoopCounter = 0 ; ShellStatus == SHELL_SUCCESS && LoopCounter < NewKeyOption.KeyData.Options.InputKeyCount; LoopCounter++) {
//
// ScanCode
//
@@ -928,7 +918,7 @@ BcfgAddOptInstall1(
VariableName,
(EFI_GUID*)&gEfiGlobalVariableGuid,
EFI_VARIABLE_NON_VOLATILE|EFI_VARIABLE_BOOTSERVICE_ACCESS|EFI_VARIABLE_RUNTIME_ACCESS,
- sizeof(EFI_KEY_OPTION) + (sizeof(EFI_INPUT_KEY) * KEY_OPTION_INPUT_KEY_COUNT (&NewKeyOption)),
+ sizeof(EFI_KEY_OPTION) + (sizeof(EFI_INPUT_KEY) * NewKeyOption.KeyData.Options.InputKeyCount),
KeyOptionBuffer);
if (EFI_ERROR(Status)) {
ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_BCFG_SET_VAR_FAIL), gShellInstall1HiiHandle, VariableName, Status);
diff --git a/ShellPkg/Library/UefiShellLevel1CommandsLib/For.c b/ShellPkg/Library/UefiShellLevel1CommandsLib/For.c
index f0c4a23b2..46182f714 100644
--- a/ShellPkg/Library/UefiShellLevel1CommandsLib/For.c
+++ b/ShellPkg/Library/UefiShellLevel1CommandsLib/For.c
@@ -270,7 +270,7 @@ ReturnUintn(
{
UINT64 RetVal;
- if (!EFI_ERROR(ShellConvertStringToUint64(String, &RetVal, FALSE, FALSE))) {
+ if (!EFI_ERROR(ShellConvertStringToUint64(String, &RetVal, FALSE, TRUE))) {
return ((UINTN)RetVal);
}
return ((UINTN)(-1));
@@ -370,11 +370,7 @@ ShellCommandRunFor (
gEfiShellParametersProtocol->Argv[2]) == 0) {
for (LoopVar = 0x3 ; LoopVar < gEfiShellParametersProtocol->Argc ; LoopVar++) {
ASSERT((ArgSet == NULL && ArgSize == 0) || (ArgSet != NULL));
- if (ArgSet == NULL) {
- // ArgSet = StrnCatGrow(&ArgSet, &ArgSize, L"\"", 0);
- } else {
- ArgSet = StrnCatGrow(&ArgSet, &ArgSize, L" \"", 0);
- }
+ ArgSet = StrnCatGrow(&ArgSet, &ArgSize, L" \"", 0);
if (StrStr(gEfiShellParametersProtocol->Argv[LoopVar], L"*") != NULL
||StrStr(gEfiShellParametersProtocol->Argv[LoopVar], L"?") != NULL
||StrStr(gEfiShellParametersProtocol->Argv[LoopVar], L"[") != NULL
diff --git a/ShellPkg/Library/UefiShellLevel2CommandsLib/Ls.c b/ShellPkg/Library/UefiShellLevel2CommandsLib/Ls.c
index 4d0a1563e..cc4a9d4cf 100644
--- a/ShellPkg/Library/UefiShellLevel2CommandsLib/Ls.c
+++ b/ShellPkg/Library/UefiShellLevel2CommandsLib/Ls.c
@@ -393,7 +393,6 @@ PrintLsOutput(
FreePool(CorrectedPath);
ShellCloseFileMetaArg(&ListHead);
- FreePool(ListHead);
return (ShellStatus);
}
diff --git a/ShellPkg/Library/UefiShellLevel2CommandsLib/Map.c b/ShellPkg/Library/UefiShellLevel2CommandsLib/Map.c
index 590dbf79e..9e33286c9 100644
--- a/ShellPkg/Library/UefiShellLevel2CommandsLib/Map.c
+++ b/ShellPkg/Library/UefiShellLevel2CommandsLib/Map.c
@@ -468,6 +468,9 @@ PerformSingleMappingDisplay(
}
} else {
Alias = StrnCatGrow(&Alias, 0, MapList, 0);
+ if (Alias == NULL) {
+ return EFI_OUT_OF_RESOURCES;
+ }
TempSpot = StrStr(Alias, CurrentName);
if (TempSpot != NULL) {
TempSpot2 = StrStr(TempSpot, L";");
@@ -484,6 +487,10 @@ PerformSingleMappingDisplay(
}
} else {
CurrentName = NULL;
+ CurrentName = StrnCatGrow(&CurrentName, 0, L"", 0);
+ if (CurrentName == NULL) {
+ return (EFI_OUT_OF_RESOURCES);
+ }
}
DevPathString = ConvertDevicePathToText(DevPath, TRUE, FALSE);
if (!SFO) {
diff --git a/ShellPkg/Library/UefiShellLevel2CommandsLib/Rm.c b/ShellPkg/Library/UefiShellLevel2CommandsLib/Rm.c
index b85120b76..c1e01426f 100644
--- a/ShellPkg/Library/UefiShellLevel2CommandsLib/Rm.c
+++ b/ShellPkg/Library/UefiShellLevel2CommandsLib/Rm.c
@@ -92,7 +92,6 @@ CascadeDelete(
if (!Quiet) {
Status = ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN(STR_RM_LOG_DELETE_CONF), gShellLevel2HiiHandle, Node->FullName);
Status = ShellPromptForResponse(ShellPromptResponseTypeYesNo, NULL, (VOID**)&Resp);
- ASSERT_EFI_ERROR(Status);
ASSERT(Resp != NULL);
if (EFI_ERROR(Status) || *Resp != ShellPromptResponseYes) {
SHELL_FREE_NON_NULL(Resp);
diff --git a/ShellPkg/Library/UefiShellLib/UefiShellLib.c b/ShellPkg/Library/UefiShellLib/UefiShellLib.c
index 40b87fec3..9b5878675 100644
--- a/ShellPkg/Library/UefiShellLib/UefiShellLib.c
+++ b/ShellPkg/Library/UefiShellLib/UefiShellLib.c
@@ -1,7 +1,7 @@
/** @file
Provides interface to shell functionality for shell commands and applications.
- Copyright (c) 2006 - 2013, Intel Corporation. All rights reserved.<BR>
+ Copyright (c) 2006 - 2014, Intel Corporation. All rights reserved.<BR>
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
@@ -1598,6 +1598,7 @@ ShellCloseFileMetaArg (
FreePool(((EFI_SHELL_FILE_INFO_NO_CONST*)Node)->Info);
FreePool((EFI_SHELL_FILE_INFO_NO_CONST*)Node);
}
+ SHELL_FREE_NON_NULL(*ListHead);
return EFI_SUCCESS;
}
@@ -3296,6 +3297,10 @@ ShellPromptForResponse (
//
*Resp = ShellPromptResponseMax;
while (*Resp == ShellPromptResponseMax) {
+ if (ShellGetExecutionBreakFlag()) {
+ Status = EFI_ABORTED;
+ break;
+ }
gBS->WaitForEvent (1, &gST->ConIn->WaitForKey, &EventIndex);
Status = gST->ConIn->ReadKeyStroke (gST->ConIn, &Key);
ASSERT_EFI_ERROR(Status);
@@ -3324,6 +3329,10 @@ ShellPromptForResponse (
//
*Resp = ShellPromptResponseMax;
while (*Resp == ShellPromptResponseMax) {
+ if (ShellGetExecutionBreakFlag()) {
+ Status = EFI_ABORTED;
+ break;
+ }
gBS->WaitForEvent (1, &gST->ConIn->WaitForKey, &EventIndex);
Status = gST->ConIn->ReadKeyStroke (gST->ConIn, &Key);
ASSERT_EFI_ERROR(Status);
@@ -3358,6 +3367,10 @@ ShellPromptForResponse (
//
*Resp = ShellPromptResponseMax;
while (*Resp == ShellPromptResponseMax) {
+ if (ShellGetExecutionBreakFlag()) {
+ Status = EFI_ABORTED;
+ break;
+ }
gBS->WaitForEvent (1, &gST->ConIn->WaitForKey, &EventIndex);
if (Type == ShellPromptResponseTypeEnterContinue) {
Status = gST->ConIn->ReadKeyStroke (gST->ConIn, &Key);
@@ -3385,6 +3398,10 @@ ShellPromptForResponse (
//
*Resp = ShellPromptResponseMax;
while (*Resp == ShellPromptResponseMax) {
+ if (ShellGetExecutionBreakFlag()) {
+ Status = EFI_ABORTED;
+ break;
+ }
gBS->WaitForEvent (1, &gST->ConIn->WaitForKey, &EventIndex);
Status = gST->ConIn->ReadKeyStroke (gST->ConIn, &Key);
ASSERT_EFI_ERROR(Status);
@@ -3406,6 +3423,10 @@ ShellPromptForResponse (
ShellPrintEx(-1, -1, L"%s", Prompt);
}
while(1) {
+ if (ShellGetExecutionBreakFlag()) {
+ Status = EFI_ABORTED;
+ break;
+ }
gBS->WaitForEvent (1, &gST->ConIn->WaitForKey, &EventIndex);
Status = gST->ConIn->ReadKeyStroke (gST->ConIn, &Key);
ASSERT_EFI_ERROR(Status);
@@ -3419,6 +3440,7 @@ ShellPromptForResponse (
break;
//
// This is the location to add new prompt types.
+ // If your new type loops remember to add ExecutionBreak support.
//
default:
ASSERT(FALSE);