summaryrefslogtreecommitdiff
path: root/ShellPkg
diff options
context:
space:
mode:
authorSteven Kinney <steven.kinney@linaro.org>2013-12-17 14:11:15 -0600
committerSteven Kinney <steven.kinney@linaro.org>2013-12-17 14:11:15 -0600
commit18110e987bb049e24ade0fb63b5577def8f99114 (patch)
tree9e8970d250ea95ffdc01cf81480a17c9b3f515cd /ShellPkg
parentaec0833cc55918a9111af736171ba8ceb976824e (diff)
parent709b5d97be16420bc96161221903abb006c076a1 (diff)
Merging uefi-next/linaro-release into masterlinaro-uefi-2013.12
Signed-off-by: Steven Kinney <steven.kinney@linaro.org>
Diffstat (limited to 'ShellPkg')
-rw-r--r--ShellPkg/Application/Shell/ConsoleLogger.c5
-rw-r--r--ShellPkg/Application/Shell/ConsoleWrappers.c34
-rw-r--r--ShellPkg/Application/Shell/ConsoleWrappers.h11
-rw-r--r--ShellPkg/Application/Shell/FileHandleWrappers.c43
-rw-r--r--ShellPkg/Application/Shell/Shell.c42
-rw-r--r--ShellPkg/Application/Shell/ShellManParser.c16
-rw-r--r--ShellPkg/Application/Shell/ShellParametersProtocol.c44
-rw-r--r--ShellPkg/Include/Library/ShellLib.h17
-rw-r--r--ShellPkg/Library/UefiHandleParsingLib/UefiHandleParsingLib.c17
-rw-r--r--ShellPkg/Library/UefiHandleParsingLib/UefiHandleParsingLib.h6
-rw-r--r--ShellPkg/Library/UefiHandleParsingLib/UefiHandleParsingLib.inf6
-rw-r--r--ShellPkg/Library/UefiHandleParsingLib/UefiHandleParsingLib.unibin24050 -> 24454 bytes
-rw-r--r--ShellPkg/Library/UefiShellDebug1CommandsLib/Mm.c37
-rw-r--r--ShellPkg/Library/UefiShellDebug1CommandsLib/Pci.c497
-rw-r--r--ShellPkg/Library/UefiShellDebug1CommandsLib/Pci.h3
-rw-r--r--ShellPkg/Library/UefiShellLevel1CommandsLib/For.c35
-rw-r--r--ShellPkg/Library/UefiShellLevel1CommandsLib/If.c9
-rw-r--r--ShellPkg/Library/UefiShellLevel1CommandsLib/UefiShellLevel1CommandsLib.c7
-rw-r--r--ShellPkg/Library/UefiShellLevel2CommandsLib/Map.c91
-rw-r--r--ShellPkg/Library/UefiShellLib/UefiShellLib.c28
20 files changed, 629 insertions, 319 deletions
diff --git a/ShellPkg/Application/Shell/ConsoleLogger.c b/ShellPkg/Application/Shell/ConsoleLogger.c
index 0a2b1fa5e..c3729f16c 100644
--- a/ShellPkg/Application/Shell/ConsoleLogger.c
+++ b/ShellPkg/Application/Shell/ConsoleLogger.c
@@ -1,6 +1,7 @@
/** @file
Provides interface to shell console logger.
+ Copyright (c) 2013 Hewlett-Packard Development Company, L.P.
Copyright (c) 2009 - 2011, 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
@@ -640,6 +641,10 @@ ConsoleLoggerDoPageBreak(
} else if (*Resp == ShellPromptResponseQuit) {
FreePool(Resp);
ShellInfoObject.ConsoleInfo->Enabled = FALSE;
+ //
+ // When user wants to quit, the shell should stop running the command.
+ //
+ gBS->SignalEvent (ShellInfoObject.NewEfiShellProtocol->ExecutionBreak);
return (EFI_DEVICE_ERROR);
} else {
ASSERT(FALSE);
diff --git a/ShellPkg/Application/Shell/ConsoleWrappers.c b/ShellPkg/Application/Shell/ConsoleWrappers.c
index d85d1acf4..38491216f 100644
--- a/ShellPkg/Application/Shell/ConsoleWrappers.c
+++ b/ShellPkg/Application/Shell/ConsoleWrappers.c
@@ -1,6 +1,7 @@
/** @file
Function definitions for shell simple text in and out on top of file handles.
+ Copyright (c) 2013 Hewlett-Packard Development Company, L.P.
Copyright (c) 2010 - 2011, 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
@@ -24,6 +25,7 @@ typedef struct {
EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL SimpleTextOut;
SHELL_FILE_HANDLE FileHandle;
EFI_HANDLE TheHandle;
+ EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL *OriginalSimpleTextOut;
} SHELL_EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL;
/**
@@ -253,7 +255,14 @@ FileBasedSimpleTextOutQueryMode (
OUT UINTN *Rows
)
{
- return (EFI_UNSUPPORTED);
+ EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL *PassThruProtocol = ((SHELL_EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL *)This)->OriginalSimpleTextOut;
+
+ // Pass the QueryMode call thru to the original SimpleTextOutProtocol
+ return (PassThruProtocol->QueryMode(
+ PassThruProtocol,
+ ModeNumber,
+ Columns,
+ Rows));
}
/**
@@ -386,8 +395,9 @@ FileBasedSimpleTextOutOutputString (
Function to create a EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL on top of a
SHELL_FILE_HANDLE to support redirecting output from a file.
- @param[in] FileHandleToUse The pointer to the SHELL_FILE_HANDLE to use.
- @param[in] HandleLocation The pointer of a location to copy handle with protocol to.
+ @param[in] FileHandleToUse The pointer to the SHELL_FILE_HANDLE to use.
+ @param[in] HandleLocation The pointer of a location to copy handle with protocol to.
+ @param[in] OriginalProtocol The pointer to the original output protocol for pass thru of functions.
@retval NULL There was insufficient memory available.
@return A pointer to the allocated protocol structure;
@@ -395,8 +405,9 @@ FileBasedSimpleTextOutOutputString (
EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL*
EFIAPI
CreateSimpleTextOutOnFile(
- IN SHELL_FILE_HANDLE FileHandleToUse,
- IN EFI_HANDLE *HandleLocation
+ IN SHELL_FILE_HANDLE FileHandleToUse,
+ IN EFI_HANDLE *HandleLocation,
+ IN EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL *OriginalProtocol
)
{
SHELL_EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL *ProtocolToReturn;
@@ -411,6 +422,7 @@ CreateSimpleTextOutOnFile(
return (NULL);
}
ProtocolToReturn->FileHandle = FileHandleToUse;
+ ProtocolToReturn->OriginalSimpleTextOut = OriginalProtocol;
ProtocolToReturn->SimpleTextOut.Reset = FileBasedSimpleTextOutReset;
ProtocolToReturn->SimpleTextOut.TestString = FileBasedSimpleTextOutTestString;
ProtocolToReturn->SimpleTextOut.QueryMode = FileBasedSimpleTextOutQueryMode;
@@ -425,12 +437,12 @@ CreateSimpleTextOutOnFile(
FreePool(ProtocolToReturn);
return (NULL);
}
- ProtocolToReturn->SimpleTextOut.Mode->MaxMode = 0;
- ProtocolToReturn->SimpleTextOut.Mode->Mode = 0;
- ProtocolToReturn->SimpleTextOut.Mode->Attribute = 0;
- ProtocolToReturn->SimpleTextOut.Mode->CursorColumn = 0;
- ProtocolToReturn->SimpleTextOut.Mode->CursorRow = 0;
- ProtocolToReturn->SimpleTextOut.Mode->CursorVisible = FALSE;
+ ProtocolToReturn->SimpleTextOut.Mode->MaxMode = OriginalProtocol->Mode->MaxMode;
+ ProtocolToReturn->SimpleTextOut.Mode->Mode = OriginalProtocol->Mode->Mode;
+ ProtocolToReturn->SimpleTextOut.Mode->Attribute = OriginalProtocol->Mode->Attribute;
+ ProtocolToReturn->SimpleTextOut.Mode->CursorColumn = OriginalProtocol->Mode->CursorColumn;
+ ProtocolToReturn->SimpleTextOut.Mode->CursorRow = OriginalProtocol->Mode->CursorRow;
+ ProtocolToReturn->SimpleTextOut.Mode->CursorVisible = OriginalProtocol->Mode->CursorVisible;
Status = gBS->InstallProtocolInterface(
&(ProtocolToReturn->TheHandle),
diff --git a/ShellPkg/Application/Shell/ConsoleWrappers.h b/ShellPkg/Application/Shell/ConsoleWrappers.h
index 572113d39..13d12e8f4 100644
--- a/ShellPkg/Application/Shell/ConsoleWrappers.h
+++ b/ShellPkg/Application/Shell/ConsoleWrappers.h
@@ -1,6 +1,7 @@
/** @file
Function definitions for shell simple text in and out on top of file handles.
+ Copyright (c) 2013 Hewlett-Packard Development Company, L.P.
Copyright (c) 2010 - 2011, 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
@@ -50,8 +51,9 @@ CloseSimpleTextInOnFile(
Function to create a EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL on top of a
SHELL_FILE_HANDLE to support redirecting output from a file.
- @param[in] FileHandleToUse The pointer to the SHELL_FILE_HANDLE to use.
- @param[in] HandleLocation The pointer of a location to copy handle with protocol to.
+ @param[in] FileHandleToUse The pointer to the SHELL_FILE_HANDLE to use.
+ @param[in] HandleLocation The pointer of a location to copy handle with protocol to.
+ @param[in] OriginalProtocol The pointer to the original output protocol for pass thru of functions.
@retval NULL There was insufficient memory available.
@return A pointer to the allocated protocol structure;
@@ -59,8 +61,9 @@ CloseSimpleTextInOnFile(
EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL*
EFIAPI
CreateSimpleTextOutOnFile(
- IN SHELL_FILE_HANDLE FileHandleToUse,
- IN EFI_HANDLE *HandleLocation
+ IN SHELL_FILE_HANDLE FileHandleToUse,
+ IN EFI_HANDLE *HandleLocation,
+ IN EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL *OriginalProtocol
);
/**
diff --git a/ShellPkg/Application/Shell/FileHandleWrappers.c b/ShellPkg/Application/Shell/FileHandleWrappers.c
index 2ca13cb3f..ef8293c1d 100644
--- a/ShellPkg/Application/Shell/FileHandleWrappers.c
+++ b/ShellPkg/Application/Shell/FileHandleWrappers.c
@@ -3,6 +3,7 @@
StdIn, StdOut, StdErr, etc...).
Copyright (c) 2009 - 2011, Intel Corporation. All rights reserved.<BR>
+ Copyright (c) 2013, Hewlett-Packard Development Company, L.P.
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
@@ -950,8 +951,48 @@ FileInterfaceEnvClose(
IN EFI_FILE_PROTOCOL *This
)
{
+ VOID* NewBuffer;
+ UINTN NewSize;
+ EFI_STATUS Status;
+
+ //
+ // Most if not all UEFI commands will have an '\r\n' at the end of any output.
+ // Since the output was redirected to a variable, it does not make sense to
+ // keep this. So, before closing, strip the trailing '\r\n' from the variable
+ // if it exists.
+ //
+ NewBuffer = NULL;
+ NewSize = 0;
+
+ Status = SHELL_GET_ENVIRONMENT_VARIABLE(((EFI_FILE_PROTOCOL_ENVIRONMENT*)This)->Name, &NewSize, NewBuffer);
+ if (Status == EFI_BUFFER_TOO_SMALL) {
+ NewBuffer = AllocateZeroPool(NewSize + sizeof(CHAR16));
+ if (NewBuffer == NULL) {
+ return EFI_OUT_OF_RESOURCES;
+ }
+ Status = SHELL_GET_ENVIRONMENT_VARIABLE(((EFI_FILE_PROTOCOL_ENVIRONMENT*)This)->Name, &NewSize, NewBuffer);
+ }
+
+ if (!EFI_ERROR(Status)) {
+
+ if (StrSize(NewBuffer) > 6)
+ {
+ if ((((CHAR16*)NewBuffer)[(StrSize(NewBuffer)/2) - 2] == CHAR_LINEFEED)
+ && (((CHAR16*)NewBuffer)[(StrSize(NewBuffer)/2) - 3] == CHAR_CARRIAGE_RETURN)) {
+ ((CHAR16*)NewBuffer)[(StrSize(NewBuffer)/2) - 3] = CHAR_NULL;
+ }
+
+ if (IsVolatileEnv(((EFI_FILE_PROTOCOL_ENVIRONMENT*)This)->Name)) {
+ Status = SHELL_SET_ENVIRONMENT_VARIABLE_V(((EFI_FILE_PROTOCOL_ENVIRONMENT*)This)->Name, StrSize(NewBuffer), NewBuffer);
+ } else {
+ Status = SHELL_SET_ENVIRONMENT_VARIABLE_NV(((EFI_FILE_PROTOCOL_ENVIRONMENT*)This)->Name, StrSize(NewBuffer), NewBuffer);
+ }
+ }
+ }
+
+ SHELL_FREE_NON_NULL(NewBuffer);
FreePool((EFI_FILE_PROTOCOL_ENVIRONMENT*)This);
- return (EFI_SUCCESS);
+ return (Status);
}
/**
diff --git a/ShellPkg/Application/Shell/Shell.c b/ShellPkg/Application/Shell/Shell.c
index e5a648833..1b52692ec 100644
--- a/ShellPkg/Application/Shell/Shell.c
+++ b/ShellPkg/Application/Shell/Shell.c
@@ -1415,9 +1415,9 @@ RunCommand(
}
//
- // Remove any spaces at the beginning of the string.
+ // Remove any spaces and tabs at the beginning of the string.
//
- while (CleanOriginal[0] == L' ') {
+ while ((CleanOriginal[0] == L' ') || (CleanOriginal[0] == L'\t')) {
CopyMem(CleanOriginal, CleanOriginal+1, StrSize(CleanOriginal) - sizeof(CleanOriginal[0]));
}
@@ -1593,10 +1593,15 @@ RunCommand(
if (!EFI_ERROR(Status)) {
Status = ShellCommandRunCommandHandler(ShellInfoObject.NewShellParametersProtocol->Argv[0], &ShellStatus, &LastError);
ASSERT_EFI_ERROR(Status);
- UnicodeSPrint(LeString, sizeof(LeString), L"0x%08Lx", ShellStatus);
- DEBUG_CODE(InternalEfiShellSetEnv(L"DebugLasterror", LeString, TRUE););
+
+ if (sizeof(EFI_STATUS) == sizeof(UINT64)) {
+ UnicodeSPrint(LeString, sizeof(LeString), L"0x%Lx", ShellStatus);
+ } else {
+ UnicodeSPrint(LeString, sizeof(LeString), L"0x%x", ShellStatus);
+ }
+ DEBUG_CODE(InternalEfiShellSetEnv(L"debuglasterror", LeString, TRUE););
if (LastError) {
- InternalEfiShellSetEnv(L"Lasterror", LeString, TRUE);
+ InternalEfiShellSetEnv(L"lasterror", LeString, TRUE);
}
//
// Pass thru the exitcode from the app.
@@ -1622,6 +1627,14 @@ RunCommand(
}
if (CommandWithPath == NULL || ShellIsDirectory(CommandWithPath) == EFI_SUCCESS) {
ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_SHELL_NOT_FOUND), ShellInfoObject.HiiHandle, ShellInfoObject.NewShellParametersProtocol->Argv[0]);
+
+ if (sizeof(EFI_STATUS) == sizeof(UINT64)) {
+ UnicodeSPrint(LeString, sizeof(LeString), L"0x%Lx", EFI_NOT_FOUND);
+ } else {
+ UnicodeSPrint(LeString, sizeof(LeString), L"0x%x", EFI_NOT_FOUND);
+ }
+ DEBUG_CODE(InternalEfiShellSetEnv(L"debuglasterror", LeString, TRUE););
+ InternalEfiShellSetEnv(L"lasterror", LeString, TRUE);
} else {
//
// Check if it's a NSH (script) file.
@@ -1642,11 +1655,15 @@ RunCommand(
);
//
- // Updatet last error status.
+ // Update last error status.
//
- UnicodeSPrint(LeString, sizeof(LeString), L"0x%08Lx", StatusCode);
- DEBUG_CODE(InternalEfiShellSetEnv(L"DebugLasterror", LeString, TRUE););
- InternalEfiShellSetEnv(L"Lasterror", LeString, TRUE);
+ if (sizeof(EFI_STATUS) == sizeof(UINT64)) {
+ UnicodeSPrint(LeString, sizeof(LeString), L"0x%Lx", StatusCode);
+ } else {
+ UnicodeSPrint(LeString, sizeof(LeString), L"0x%x", StatusCode);
+ }
+ DEBUG_CODE(InternalEfiShellSetEnv(L"debuglasterror", LeString, TRUE););
+ InternalEfiShellSetEnv(L"lasterror", LeString, TRUE);
}
}
}
@@ -1952,9 +1969,12 @@ RunScriptFileHandle (
}
if (ShellCommandGetScriptExit()) {
+ //
+ // ShellCommandGetExitCode() always returns a UINT64
+ //
UnicodeSPrint(LeString, sizeof(LeString), L"0x%Lx", ShellCommandGetExitCode());
- DEBUG_CODE(InternalEfiShellSetEnv(L"DebugLasterror", LeString, TRUE););
- InternalEfiShellSetEnv(L"Lasterror", LeString, TRUE);
+ DEBUG_CODE(InternalEfiShellSetEnv(L"debuglasterror", LeString, TRUE););
+ InternalEfiShellSetEnv(L"lasterror", LeString, TRUE);
ShellCommandRegisterExit(FALSE, 0);
Status = EFI_SUCCESS;
diff --git a/ShellPkg/Application/Shell/ShellManParser.c b/ShellPkg/Application/Shell/ShellManParser.c
index 470f51a8e..8196a6ac9 100644
--- a/ShellPkg/Application/Shell/ShellManParser.c
+++ b/ShellPkg/Application/Shell/ShellManParser.c
@@ -1,7 +1,7 @@
/** @file
Provides interface to shell MAN file parser.
- Copyright (c) 2009 - 2011, Intel Corporation. All rights reserved.<BR>
+ Copyright (c) 2009 - 2013, 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
@@ -491,6 +491,20 @@ ManFileFindTitleSection(
}
StrCpy(TitleString, L".TH ");
StrCat(TitleString, Command);
+
+ //
+ // If the "name" ends with .efi we can safely chop that off since "help foo.efi" and "help foo"
+ // should produce the same results.
+ //
+ if ((StrLen(Command)> 4)
+ && (TitleString[StrLen(TitleString)-1] == L'i' || TitleString[StrLen(TitleString)-1] == L'I')
+ && (TitleString[StrLen(TitleString)-2] == L'f' || TitleString[StrLen(TitleString)-2] == L'F')
+ && (TitleString[StrLen(TitleString)-3] == L'e' || TitleString[StrLen(TitleString)-2] == L'E')
+ && (TitleString[StrLen(TitleString)-4] == L'.')
+ ) {
+ TitleString[StrLen(TitleString)-4] = CHAR_NULL;
+ }
+
TitleLen = StrLen(TitleString);
for (;!ShellFileHandleEof(Handle);Size = 1024) {
Status = ShellFileHandleReadLine(Handle, ReadLine, &Size, TRUE, Ascii);
diff --git a/ShellPkg/Application/Shell/ShellParametersProtocol.c b/ShellPkg/Application/Shell/ShellParametersProtocol.c
index 2f8c626b0..b6598c0cf 100644
--- a/ShellPkg/Application/Shell/ShellParametersProtocol.c
+++ b/ShellPkg/Application/Shell/ShellParametersProtocol.c
@@ -2,6 +2,7 @@
Member functions of EFI_SHELL_PARAMETERS_PROTOCOL and functions for creation,
manipulation, and initialization of EFI_SHELL_PARAMETERS_PROTOCOL.
+ Copyright (c) 2013 Hewlett-Packard Development Company, L.P.
Copyright (c) 2009 - 2013, 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
@@ -538,6 +539,35 @@ FixFileName (
}
/**
+ Fix a string to only have the environment variable name, removing starting at the first space of whatever is quoted and removing the leading and trailing %.
+
+ @param[in] FileName The filename to start with.
+
+ @retval NULL FileName was invalid.
+ @return The modified FileName.
+**/
+CHAR16*
+EFIAPI
+FixVarName (
+ IN CHAR16 *FileName
+ )
+{
+ CHAR16 *Copy;
+ CHAR16 *TempLocation;
+
+ Copy = FileName;
+
+ if (FileName[0] == L'%') {
+ Copy = FileName+1;
+ if ((TempLocation = StrStr(Copy , L"%")) != NULL) {
+ TempLocation[0] = CHAR_NULL;
+ }
+ }
+
+ return (FixFileName(Copy));
+}
+
+/**
Funcion will replace the current StdIn and StdOut in the ShellParameters protocol
structure by parsing NewCommandLine. The current values are returned to the
user.
@@ -913,17 +943,17 @@ UpdateStdInStdOutStdErr(
}
}
if (StdErrVarName != NULL) {
- if ((StdErrVarName = FixFileName(StdErrVarName)) == NULL) {
+ if ((StdErrVarName = FixVarName(StdErrVarName)) == NULL) {
Status = EFI_INVALID_PARAMETER;
}
}
if (StdOutVarName != NULL) {
- if ((StdOutVarName = FixFileName(StdOutVarName)) == NULL) {
+ if ((StdOutVarName = FixVarName(StdOutVarName)) == NULL) {
Status = EFI_INVALID_PARAMETER;
}
}
if (StdInVarName != NULL) {
- if ((StdInVarName = FixFileName(StdInVarName)) == NULL) {
+ if ((StdInVarName = FixVarName(StdInVarName)) == NULL) {
Status = EFI_INVALID_PARAMETER;
}
}
@@ -1008,7 +1038,7 @@ UpdateStdInStdOutStdErr(
}
if (!EFI_ERROR(Status)) {
ShellParameters->StdErr = TempHandle;
- gST->StdErr = CreateSimpleTextOutOnFile(TempHandle, &gST->StandardErrorHandle);
+ gST->StdErr = CreateSimpleTextOutOnFile(TempHandle, &gST->StandardErrorHandle, gST->StdErr);
}
}
@@ -1051,7 +1081,7 @@ UpdateStdInStdOutStdErr(
}
if (!EFI_ERROR(Status)) {
ShellParameters->StdOut = TempHandle;
- gST->ConOut = CreateSimpleTextOutOnFile(TempHandle, &gST->ConsoleOutHandle);
+ gST->ConOut = CreateSimpleTextOutOnFile(TempHandle, &gST->ConsoleOutHandle, gST->ConOut);
}
}
}
@@ -1069,7 +1099,7 @@ UpdateStdInStdOutStdErr(
TempHandle = CreateFileInterfaceEnv(StdOutVarName);
ASSERT(TempHandle != NULL);
ShellParameters->StdOut = TempHandle;
- gST->ConOut = CreateSimpleTextOutOnFile(TempHandle, &gST->ConsoleOutHandle);
+ gST->ConOut = CreateSimpleTextOutOnFile(TempHandle, &gST->ConsoleOutHandle, gST->ConOut);
}
//
@@ -1085,7 +1115,7 @@ UpdateStdInStdOutStdErr(
TempHandle = CreateFileInterfaceEnv(StdErrVarName);
ASSERT(TempHandle != NULL);
ShellParameters->StdErr = TempHandle;
- gST->StdErr = CreateSimpleTextOutOnFile(TempHandle, &gST->StandardErrorHandle);
+ gST->StdErr = CreateSimpleTextOutOnFile(TempHandle, &gST->StandardErrorHandle, gST->StdErr);
}
//
diff --git a/ShellPkg/Include/Library/ShellLib.h b/ShellPkg/Include/Library/ShellLib.h
index eefa030ad..4a79acdd5 100644
--- a/ShellPkg/Include/Library/ShellLib.h
+++ b/ShellPkg/Include/Library/ShellLib.h
@@ -1008,6 +1008,23 @@ ShellStrToUintn(
);
/**
+ Function return the number converted from a hex representation of a number.
+
+ Note: this function cannot be used when (UINTN)(-1), (0xFFFFFFFF) may be a valid
+ result. Use ShellConvertStringToUint64 instead.
+
+ @param[in] String String representation of a number.
+
+ @return The unsigned integer result of the conversion.
+ @retval (UINTN)(-1) An error occured.
+**/
+UINTN
+EFIAPI
+ShellHexStrToUintn(
+ IN CONST CHAR16 *String
+ );
+
+/**
Safely append with automatic string resizing given length of Destination and
desired length of copy from Source.
diff --git a/ShellPkg/Library/UefiHandleParsingLib/UefiHandleParsingLib.c b/ShellPkg/Library/UefiHandleParsingLib/UefiHandleParsingLib.c
index 515fab329..7c2e9c735 100644
--- a/ShellPkg/Library/UefiHandleParsingLib/UefiHandleParsingLib.c
+++ b/ShellPkg/Library/UefiHandleParsingLib/UefiHandleParsingLib.c
@@ -1,6 +1,7 @@
/** @file
Provides interface to advanced shell functionality for parsing both handle and protocol database.
+ Copyright (c) 2013 Hewlett-Packard Development Company, L.P.
Copyright (c) 2010 - 2013, 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
@@ -618,7 +619,17 @@ STATIC CONST GUID_INFO_BLOCK mGuidStringList[] = {
{STRING_TOKEN(STR_KMS), &gEfiKmsProtocolGuid, NULL},
{STRING_TOKEN(STR_BLK_IO2), &gEfiBlockIo2ProtocolGuid, NULL},
{STRING_TOKEN(STR_SSC), &gEfiStorageSecurityCommandProtocolGuid, NULL},
- {STRING_TOKEN(STR_UC2), &gEfiUserCredential2ProtocolGuid, NULL},
+ {STRING_TOKEN(STR_UCRED2), &gEfiUserCredential2ProtocolGuid, NULL},
+
+//
+// UEFI 2.4
+//
+ {STRING_TOKEN(STR_DISK_IO2), &gEfiDiskIo2ProtocolGuid, NULL},
+
+//
+// PI Spec ones
+//
+ {STRING_TOKEN(STR_IDE_CONT_INIT), &gEfiIdeControllerInitProtocolGuid, NULL},
//
// terminator
@@ -753,7 +764,7 @@ GetGuidFromStringName(
if (PcdGetBool(PcdShellIncludeNtGuids)) {
for (ListWalker = mGuidStringListNT ; ListWalker != NULL && ListWalker->GuidId != NULL ; ListWalker++) {
String = HiiGetString(mHandleParsingHiiHandle, ListWalker->StringId, Lang);
- if (Name != NULL && String != NULL && StrCmp(Name, String)==0) {
+ if (Name != NULL && String != NULL && StringNoCaseCompare (&Name, &String) == 0) {
*Guid = ListWalker->GuidId;
}
SHELL_FREE_NON_NULL(String);
@@ -764,7 +775,7 @@ GetGuidFromStringName(
}
for (ListWalker = mGuidStringList ; ListWalker != NULL && ListWalker->GuidId != NULL ; ListWalker++) {
String = HiiGetString(mHandleParsingHiiHandle, ListWalker->StringId, Lang);
- if (Name != NULL && String != NULL && StrCmp(Name, String)==0) {
+ if (Name != NULL && String != NULL && StringNoCaseCompare (&Name, &String) == 0) {
*Guid = ListWalker->GuidId;
}
SHELL_FREE_NON_NULL(String);
diff --git a/ShellPkg/Library/UefiHandleParsingLib/UefiHandleParsingLib.h b/ShellPkg/Library/UefiHandleParsingLib/UefiHandleParsingLib.h
index 3b1ad2bac..37c05d04b 100644
--- a/ShellPkg/Library/UefiHandleParsingLib/UefiHandleParsingLib.h
+++ b/ShellPkg/Library/UefiHandleParsingLib/UefiHandleParsingLib.h
@@ -1,7 +1,8 @@
/** @file
Provides interface to advanced shell functionality for parsing both handle and protocol database.
- Copyright (c) 2011 - 2012, Intel Corporation. All rights reserved.<BR>
+ Copyright (c) 2013 Hewlett-Packard Development Company, L.P.
+ Copyright (c) 2011 - 2013, 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
@@ -130,6 +131,8 @@
#include <Protocol/BlockIo2.h>
#include <Protocol/StorageSecurityCommand.h>
#include <Protocol/UserCredential2.h>
+#include <Protocol/IdeControllerInit.h>
+#include <Protocol/DiskIo2.h>
#include <Library/HandleParsingLib.h>
#include <Library/UefiBootServicesTableLib.h>
@@ -143,6 +146,7 @@
#include <Library/UefiLib.h>
#include <Library/HiiLib.h>
#include <Library/ShellLib.h>
+#include <Library/SortLib.h>
typedef struct {
LIST_ENTRY Link;
diff --git a/ShellPkg/Library/UefiHandleParsingLib/UefiHandleParsingLib.inf b/ShellPkg/Library/UefiHandleParsingLib/UefiHandleParsingLib.inf
index 15226a0b2..e1d5d8c80 100644
--- a/ShellPkg/Library/UefiHandleParsingLib/UefiHandleParsingLib.inf
+++ b/ShellPkg/Library/UefiHandleParsingLib/UefiHandleParsingLib.inf
@@ -1,6 +1,7 @@
## @file
# Provides interface to advanced shell functionality for parsing both handle and protocol database.
-# Copyright (c) 2010 - 2012, Intel Corporation. All rights reserved. <BR>
+# Copyright (c) 2013 Hewlett-Packard Development Company, L.P.
+# Copyright (c) 2010 - 2013, 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
@@ -47,6 +48,7 @@
PrintLib
UefiLib
HiiLib
+ SortLib
[Protocols]
gEfiSimpleFileSystemProtocolGuid ##CONSUMES
@@ -167,6 +169,8 @@
gEfiTcgProtocolGuid ##UNDEFINED
gEfiHiiPackageListProtocolGuid ##UNDEFINED
gEfiDriverFamilyOverrideProtocolGuid ##UNDEFINED
+ gEfiIdeControllerInitProtocolGuid ##UNDEFINED
+ gEfiDiskIo2ProtocolGuid ##UNDEFINED
[Guids]
gEfiFileInfoGuid ##CONSUMES
diff --git a/ShellPkg/Library/UefiHandleParsingLib/UefiHandleParsingLib.uni b/ShellPkg/Library/UefiHandleParsingLib/UefiHandleParsingLib.uni
index 6a9074eaf..998a386fa 100644
--- a/ShellPkg/Library/UefiHandleParsingLib/UefiHandleParsingLib.uni
+++ b/ShellPkg/Library/UefiHandleParsingLib/UefiHandleParsingLib.uni
Binary files differ
diff --git a/ShellPkg/Library/UefiShellDebug1CommandsLib/Mm.c b/ShellPkg/Library/UefiShellDebug1CommandsLib/Mm.c
index 5bb3cff2d..636acb21d 100644
--- a/ShellPkg/Library/UefiShellDebug1CommandsLib/Mm.c
+++ b/ShellPkg/Library/UefiShellDebug1CommandsLib/Mm.c
@@ -1,7 +1,7 @@
/** @file
Main file for Mm shell Debug1 function.
- Copyright (c) 2005 - 2011, Intel Corporation. All rights reserved.<BR>
+ Copyright (c) 2005 - 2013, 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
@@ -315,7 +315,10 @@ ShellCommandRunMm (
}
}
- if (ShellCommandLineGetFlag (Package, L"-n")) {
+ //
+ // Non interactive for a script file or for the specific parameter
+ //
+ if (gEfiShellProtocol->BatchIsActive() || ShellCommandLineGetFlag (Package, L"-n")) {
Interactive = FALSE;
}
@@ -360,6 +363,11 @@ ShellCommandRunMm (
Temp = ShellCommandLineGetRawValue(Package, 2);
if (Temp != NULL) {
+ //
+ // Per spec if value is specified, then -n is assumed.
+ //
+ Interactive = FALSE;
+
if (!ShellIsHexOrDecimalNumber(Temp, TRUE, FALSE) || EFI_ERROR(ShellConvertStringToUint64(Temp, &Value, TRUE, FALSE))) {
ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_PROBLEM), gShellDebug1HiiHandle, Temp);
ShellStatus = SHELL_INVALID_PARAMETER;
@@ -489,23 +497,34 @@ ShellCommandRunMm (
if (!Interactive) {
Buffer = 0;
if (AccessType == EFIMemoryMappedIo) {
- ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_MM_MMIO), gShellDebug1HiiHandle);
+ if (!gEfiShellProtocol->BatchIsActive()) {
+ ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_MM_MMIO), gShellDebug1HiiHandle);
+ }
IoDev->Mem.Read (IoDev, Width, Address, 1, &Buffer);
} else if (AccessType == EfiIo) {
- ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_MM_IO), gShellDebug1HiiHandle);
+ if (!gEfiShellProtocol->BatchIsActive()) {
+ ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_MM_IO), gShellDebug1HiiHandle);
+ }
IoDev->Io.Read (IoDev, Width, Address, 1, &Buffer);
} else if (AccessType == EfiPciConfig) {
- ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_MM_PCI), gShellDebug1HiiHandle);
+ if (!gEfiShellProtocol->BatchIsActive()) {
+ ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_MM_PCI), gShellDebug1HiiHandle);
+ }
IoDev->Pci.Read (IoDev, Width, Address, 1, &Buffer);
} else if (AccessType == EfiPciEConfig) {
- ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_MM_PCIE), gShellDebug1HiiHandle);
+ if (!gEfiShellProtocol->BatchIsActive()) {
+ ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_MM_PCIE), gShellDebug1HiiHandle);
+ }
IoDev->Pci.Read (IoDev, Width, PciEAddress, 1, &Buffer);
} else {
- ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_MM_MEM), gShellDebug1HiiHandle);
+ if (!gEfiShellProtocol->BatchIsActive()) {
+ ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_MM_MEM), gShellDebug1HiiHandle);
+ }
ReadMem (Width, Address, 1, &Buffer);
}
-
- ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_MM_ADDRESS), gShellDebug1HiiHandle, Address);
+ if (!gEfiShellProtocol->BatchIsActive()) {
+ ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_MM_ADDRESS), gShellDebug1HiiHandle, Address);
+ }
if (Size == 1) {
ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_MM_BUF2), gShellDebug1HiiHandle, (UINTN)Buffer);
} else if (Size == 2) {
diff --git a/ShellPkg/Library/UefiShellDebug1CommandsLib/Pci.c b/ShellPkg/Library/UefiShellDebug1CommandsLib/Pci.c
index 4ca1fd1bd..e67c93f95 100644
--- a/ShellPkg/Library/UefiShellDebug1CommandsLib/Pci.c
+++ b/ShellPkg/Library/UefiShellDebug1CommandsLib/Pci.c
@@ -1,6 +1,7 @@
/** @file
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>
This program and the accompanying materials
are licensed and made available under the terms and conditions of the BSD License
@@ -1388,7 +1389,6 @@ PciPrintClassCode (
{
UINT32 ClassCode;
PCI_CLASS_STRINGS ClassStrings;
- CHAR16 OutputString[PCI_CLASS_STRING_LIMIT + 1];
ClassCode = 0;
ClassCode |= ClassCodePtr[0];
@@ -1402,9 +1402,9 @@ PciPrintClassCode (
if (IncludePIF) {
//
- // Only print base class and sub class name
+ // Print base class, sub class, and programming inferface name
//
- ShellPrintEx(-1,-1, L"%s - %s - %s",
+ ShellPrintEx (-1, -1, L"%s - %s - %s",
ClassStrings.BaseClass,
ClassStrings.SubClass,
ClassStrings.PIFClass
@@ -1412,18 +1412,12 @@ PciPrintClassCode (
} else {
//
- // Print base class, sub class, and programming inferface name
+ // Only print base class and sub class name
//
- UnicodeSPrint (
- OutputString,
- PCI_CLASS_STRING_LIMIT * sizeof (CHAR16),
- L"%s - %s",
+ ShellPrintEx (-1, -1, L"%s - %s",
ClassStrings.BaseClass,
ClassStrings.SubClass
- );
-
- OutputString[PCI_CLASS_STRING_LIMIT] = 0;
- ShellPrintEx(-1,-1, L"%s", OutputString);
+ );
}
}
@@ -2359,7 +2353,6 @@ ShellCommandRunPci (
if (EFI_ERROR (Status)) {
ShellPrintHiiEx(
-1, -1, NULL, STRING_TOKEN (STR_PCI_NO_FIND), gShellDebug1HiiHandle,
- gShellDebug1HiiHandle,
Segment,
Bus
);
@@ -2632,7 +2625,7 @@ PciExplainData (
Common = &(ConfigSpace->Common);
- Print (L"\n");
+ ShellPrintEx (-1, -1, L"\r\n");
//
// Print Vendor Id and Device Id
@@ -2657,7 +2650,7 @@ PciExplainData (
//
// Print register Revision ID
//
- ShellPrintEx(-1, -1, L"/r/n");
+ ShellPrintEx(-1, -1, L"\r\n");
ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_PCI_LINE_RID), gShellDebug1HiiHandle,
INDEX_OF (&(Common->RevisionId)),
Common->RevisionId
@@ -2733,7 +2726,7 @@ PciExplainData (
//
ShellPrintHiiEx(-1, -1, NULL,STRING_TOKEN (STR_PCI2_CLASS), gShellDebug1HiiHandle);
PciPrintClassCode ((UINT8 *) Common->ClassCode, TRUE);
- Print (L"\n");
+ ShellPrintEx (-1, -1, L"\r\n");
if (ShellGetExecutionBreakFlag()) {
return EFI_SUCCESS;
@@ -2824,7 +2817,7 @@ PciExplainDeviceData (
if (!BarExist) {
BarExist = TRUE;
ShellPrintHiiEx(-1, -1, NULL,STRING_TOKEN (STR_PCI2_START_TYPE), gShellDebug1HiiHandle);
- Print (L" --------------------------------------------------------------------------");
+ ShellPrintEx (-1, -1, L" --------------------------------------------------------------------------");
}
Status = PciExplainBar (
@@ -2844,7 +2837,7 @@ PciExplainDeviceData (
ShellPrintHiiEx(-1, -1, NULL,STRING_TOKEN (STR_PCI2_NONE), gShellDebug1HiiHandle);
} else {
- Print (L"\n --------------------------------------------------------------------------");
+ ShellPrintEx (-1, -1, L"\r\n --------------------------------------------------------------------------");
}
//
@@ -2975,7 +2968,7 @@ PciExplainBridgeData (
if (!BarExist) {
BarExist = TRUE;
ShellPrintHiiEx(-1, -1, NULL,STRING_TOKEN (STR_PCI2_START_TYPE_2), gShellDebug1HiiHandle);
- Print (L" --------------------------------------------------------------------------");
+ ShellPrintEx (-1, -1, L" --------------------------------------------------------------------------");
}
Status = PciExplainBar (
@@ -2994,7 +2987,7 @@ PciExplainBridgeData (
if (!BarExist) {
ShellPrintHiiEx(-1, -1, NULL,STRING_TOKEN (STR_PCI2_NONE), gShellDebug1HiiHandle);
} else {
- Print (L"\n --------------------------------------------------------------------------");
+ ShellPrintEx (-1, -1, L"\r\n --------------------------------------------------------------------------");
}
//
@@ -3022,7 +3015,7 @@ PciExplainBridgeData (
INDEX_OF (&(Bridge->SubordinateBus))
);
- Print (L" ------------------------------------------------------\n");
+ ShellPrintEx (-1, -1, L" ------------------------------------------------------\r\n");
ShellPrintHiiEx(-1, -1, NULL,STRING_TOKEN (STR_PCI2_BRIDGE), gShellDebug1HiiHandle, Bridge->PrimaryBus);
ShellPrintHiiEx(-1, -1, NULL,STRING_TOKEN (STR_PCI2_BRIDGE), gShellDebug1HiiHandle, Bridge->SecondaryBus);
@@ -3049,7 +3042,7 @@ PciExplainBridgeData (
// base and limit address are listed.
//
ShellPrintHiiEx(-1, -1, NULL,STRING_TOKEN (STR_PCI2_RESOURCE_TYPE), gShellDebug1HiiHandle);
- Print (L"----------------------------------------------------------------------\n");
+ ShellPrintEx (-1, -1, L"----------------------------------------------------------------------\r\n");
//
// IO Base & Limit
@@ -3218,7 +3211,7 @@ PciExplainBar (
//
IsMem = FALSE;
ShellPrintHiiEx(-1, -1, NULL,STRING_TOKEN (STR_PCI2_ONE_VAR_4), gShellDebug1HiiHandle, *Bar & 0xfffffffc);
- Print (L"I/O ");
+ ShellPrintEx (-1, -1, L"I/O ");
}
//
@@ -3292,7 +3285,7 @@ PciExplainBar (
} else {
ShellPrintHiiEx(-1, -1, NULL,STRING_TOKEN (STR_PCI2_RSHIFT), gShellDebug1HiiHandle, (UINT32) RShiftU64 (NewBar64, 32));
ShellPrintHiiEx(-1, -1, NULL,STRING_TOKEN (STR_PCI2_RSHIFT), gShellDebug1HiiHandle, (UINT32) NewBar64);
- Print (L" ");
+ ShellPrintEx (-1, -1, L" ");
ShellPrintHiiEx(-1, -1, NULL,
STRING_TOKEN (STR_PCI2_RSHIFT),
gShellDebug1HiiHandle,
@@ -3352,7 +3345,7 @@ PciExplainCardBusData (
INDEX_OF (&(CardBus->SubordinateBusNumber))
);
- Print (L" ------------------------------------------------------\n");
+ ShellPrintEx (-1, -1, L" ------------------------------------------------------\r\n");
ShellPrintHiiEx(-1, -1, NULL,STRING_TOKEN (STR_PCI2_CARDBUS), gShellDebug1HiiHandle, CardBus->PciBusNumber);
ShellPrintHiiEx(-1, -1, NULL,STRING_TOKEN (STR_PCI2_CARDBUS_2), gShellDebug1HiiHandle, CardBus->CardBusBusNumber);
@@ -3372,7 +3365,7 @@ PciExplainCardBusData (
// Print Memory/Io ranges this cardbus bridge forwards
//
ShellPrintHiiEx(-1, -1, NULL,STRING_TOKEN (STR_PCI2_RESOURCE_TYPE_2), gShellDebug1HiiHandle);
- Print (L"----------------------------------------------------------------------\n");
+ ShellPrintEx (-1, -1, L"----------------------------------------------------------------------\r\n");
ShellPrintHiiEx(-1, -1, NULL,
STRING_TOKEN (STR_PCI2_MEM_3),
@@ -3805,8 +3798,8 @@ ExplainPcieCapReg (
CHAR16 *DevicePortType;
PcieCapReg = PciExpressCap->PcieCapReg;
- Print (
- L" Capability Version(3:0): %E0x%04x%N\n",
+ ShellPrintEx (-1, -1,
+ L" Capability Version(3:0): %E0x%04x%N\r\n",
PCIE_CAP_VERSION (PcieCapReg)
);
if ((UINT8) PCIE_CAP_DEVICEPORT_TYPE (PcieCapReg) < PCIE_DEVICE_PORT_TYPE_MAX) {
@@ -3814,8 +3807,8 @@ ExplainPcieCapReg (
} else {
DevicePortType = L"Unknown Type";
}
- Print (
- L" Device/PortType(7:4): %E%s%N\n",
+ ShellPrintEx (-1, -1,
+ L" Device/PortType(7:4): %E%s%N\r\n",
DevicePortType
);
//
@@ -3825,13 +3818,13 @@ ExplainPcieCapReg (
//
if (PCIE_CAP_DEVICEPORT_TYPE (PcieCapReg) == PCIE_ROOT_COMPLEX_ROOT_PORT ||
PCIE_CAP_DEVICEPORT_TYPE (PcieCapReg) == PCIE_SWITCH_DOWNSTREAM_PORT) {
- Print (
- L" Slot Implemented(8): %E%d%N\n",
+ ShellPrintEx (-1, -1,
+ L" Slot Implemented(8): %E%d%N\r\n",
PCIE_CAP_SLOT_IMPLEMENTED (PcieCapReg)
);
}
- Print (
- L" Interrupt Message Number(13:9): %E0x%05x%N\n",
+ ShellPrintEx (-1, -1,
+ L" Interrupt Message Number(13:9): %E0x%05x%N\r\n",
PCIE_CAP_INT_MSG_NUM (PcieCapReg)
);
return EFI_SUCCESS;
@@ -3858,18 +3851,18 @@ ExplainPcieDeviceCap (
PcieCapReg = PciExpressCap->PcieCapReg;
PcieDeviceCap = PciExpressCap->PcieDeviceCap;
DevicePortType = (UINT8) PCIE_CAP_DEVICEPORT_TYPE (PcieCapReg);
- Print (L" Max_Payload_Size Supported(2:0): ");
+ ShellPrintEx (-1, -1, L" Max_Payload_Size Supported(2:0): ");
if (PCIE_CAP_MAX_PAYLOAD (PcieDeviceCap) < 6) {
- Print (L"%E%d bytes%N\n", 1 << (PCIE_CAP_MAX_PAYLOAD (PcieDeviceCap) + 7));
+ ShellPrintEx (-1, -1, L"%E%d bytes%N\r\n", 1 << (PCIE_CAP_MAX_PAYLOAD (PcieDeviceCap) + 7));
} else {
- Print (L"%EUnknown%N\n");
+ ShellPrintEx (-1, -1, L"%EUnknown%N\r\n");
}
- Print (
- L" Phantom Functions Supported(4:3): %E%d%N\n",
+ ShellPrintEx (-1, -1,
+ L" Phantom Functions Supported(4:3): %E%d%N\r\n",
PCIE_CAP_PHANTOM_FUNC (PcieDeviceCap)
);
- Print (
- L" Extended Tag Field Supported(5): %E%d-bit Tag field supported%N\n",
+ ShellPrintEx (-1, -1,
+ L" Extended Tag Field Supported(5): %E%d-bit Tag field supported%N\r\n",
PCIE_CAP_EXTENDED_TAG (PcieDeviceCap) ? 8 : 5
);
//
@@ -3878,25 +3871,25 @@ ExplainPcieDeviceCap (
if (IS_PCIE_ENDPOINT (DevicePortType)) {
L0sLatency = (UINT8) PCIE_CAP_L0SLATENCY (PcieDeviceCap);
L1Latency = (UINT8) PCIE_CAP_L1LATENCY (PcieDeviceCap);
- Print (L" Endpoint L0s Acceptable Latency(8:6): ");
+ ShellPrintEx (-1, -1, L" Endpoint L0s Acceptable Latency(8:6): ");
if (L0sLatency < 4) {
- Print (L"%EMaximum of %d ns%N\n", 1 << (L0sLatency + 6));
+ ShellPrintEx (-1, -1, L"%EMaximum of %d ns%N\r\n", 1 << (L0sLatency + 6));
} else {
if (L0sLatency < 7) {
- Print (L"%EMaximum of %d us%N\n", 1 << (L0sLatency - 3));
+ ShellPrintEx (-1, -1, L"%EMaximum of %d us%N\r\n", 1 << (L0sLatency - 3));
} else {
- Print (L"%ENo limit%N\n");
+ ShellPrintEx (-1, -1, L"%ENo limit%N\r\n");
}
}
- Print (L" Endpoint L1 Acceptable Latency(11:9): ");
+ ShellPrintEx (-1, -1, L" Endpoint L1 Acceptable Latency(11:9): ");
if (L1Latency < 7) {
- Print (L"%EMaximum of %d us%N\n", 1 << (L1Latency + 1));
+ ShellPrintEx (-1, -1, L"%EMaximum of %d us%N\r\n", 1 << (L1Latency + 1));
} else {
- Print (L"%ENo limit%N\n");
+ ShellPrintEx (-1, -1, L"%ENo limit%N\r\n");
}
}
- Print (
- L" Role-based Error Reporting(15): %E%d%N\n",
+ ShellPrintEx (-1, -1,
+ L" Role-based Error Reporting(15): %E%d%N\r\n",
PCIE_CAP_ERR_REPORTING (PcieDeviceCap)
);
//
@@ -3905,12 +3898,12 @@ ExplainPcieDeviceCap (
// b) Captured Slot Power Scale
//
if (DevicePortType == PCIE_SWITCH_UPSTREAM_PORT) {
- Print (
- L" Captured Slot Power Limit Value(25:18): %E0x%02x%N\n",
+ ShellPrintEx (-1, -1,
+ L" Captured Slot Power Limit Value(25:18): %E0x%02x%N\r\n",
PCIE_CAP_SLOT_POWER_VALUE (PcieDeviceCap)
);
- Print (
- L" Captured Slot Power Limit Scale(27:26): %E%s%N\n",
+ ShellPrintEx (-1, -1,
+ L" Captured Slot Power Limit Scale(27:26): %E%s%N\r\n",
SlotPwrLmtScaleTable[PCIE_CAP_SLOT_POWER_SCALE (PcieDeviceCap)]
);
}
@@ -3918,8 +3911,8 @@ ExplainPcieDeviceCap (
// Function Level Reset Capability is only valid for Endpoint
//
if (IS_PCIE_ENDPOINT (DevicePortType)) {
- Print (
- L" Function Level Reset Capability(28): %E%d%N\n",
+ ShellPrintEx (-1, -1,
+ L" Function Level Reset Capability(28): %E%d%N\r\n",
PCIE_CAP_FUNC_LEVEL_RESET (PcieDeviceCap)
);
}
@@ -3943,60 +3936,60 @@ ExplainPcieDeviceControl (
PcieCapReg = PciExpressCap->PcieCapReg;
PcieDeviceControl = PciExpressCap->DeviceControl;
- Print (
- L" Correctable Error Reporting Enable(0): %E%d%N\n",
+ ShellPrintEx (-1, -1,
+ L" Correctable Error Reporting Enable(0): %E%d%N\r\n",
PCIE_CAP_COR_ERR_REPORTING_ENABLE (PcieDeviceControl)
);
- Print (
- L" Non-Fatal Error Reporting Enable(1): %E%d%N\n",
+ ShellPrintEx (-1, -1,
+ L" Non-Fatal Error Reporting Enable(1): %E%d%N\r\n",
PCIE_CAP_NONFAT_ERR_REPORTING_ENABLE (PcieDeviceControl)
);
- Print (
- L" Fatal Error Reporting Enable(2): %E%d%N\n",
+ ShellPrintEx (-1, -1,
+ L" Fatal Error Reporting Enable(2): %E%d%N\r\n",
PCIE_CAP_FATAL_ERR_REPORTING_ENABLE (PcieDeviceControl)
);
- Print (
- L" Unsupported Request Reporting Enable(3): %E%d%N\n",
+ ShellPrintEx (-1, -1,
+ L" Unsupported Request Reporting Enable(3): %E%d%N\r\n",
PCIE_CAP_UNSUP_REQ_REPORTING_ENABLE (PcieDeviceControl)
);
- Print (
- L" Enable Relaxed Ordering(4): %E%d%N\n",
+ ShellPrintEx (-1, -1,
+ L" Enable Relaxed Ordering(4): %E%d%N\r\n",
PCIE_CAP_RELAXED_ORDERING_ENABLE (PcieDeviceControl)
);
- Print (L" Max_Payload_Size(7:5): ");
+ ShellPrintEx (-1, -1, L" Max_Payload_Size(7:5): ");
if (PCIE_CAP_MAX_PAYLOAD_SIZE (PcieDeviceControl) < 6) {
- Print (L"%E%d bytes%N\n", 1 << (PCIE_CAP_MAX_PAYLOAD_SIZE (PcieDeviceControl) + 7));
+ ShellPrintEx (-1, -1, L"%E%d bytes%N\r\n", 1 << (PCIE_CAP_MAX_PAYLOAD_SIZE (PcieDeviceControl) + 7));
} else {
- Print (L"%EUnknown%N\n");
+ ShellPrintEx (-1, -1, L"%EUnknown%N\r\n");
}
- Print (
- L" Extended Tag Field Enable(8): %E%d%N\n",
+ ShellPrintEx (-1, -1,
+ L" Extended Tag Field Enable(8): %E%d%N\r\n",
PCIE_CAP_EXTENDED_TAG_ENABLE (PcieDeviceControl)
);
- Print (
- L" Phantom Functions Enable(9): %E%d%N\n",
+ ShellPrintEx (-1, -1,
+ L" Phantom Functions Enable(9): %E%d%N\r\n",
PCIE_CAP_PHANTOM_FUNC_ENABLE (PcieDeviceControl)
);
- Print (
- L" Auxiliary (AUX) Power PM Enable(10): %E%d%N\n",
+ ShellPrintEx (-1, -1,
+ L" Auxiliary (AUX) Power PM Enable(10): %E%d%N\r\n",
PCIE_CAP_AUX_PM_ENABLE (PcieDeviceControl)
);
- Print (
- L" Enable No Snoop(11): %E%d%N\n",
+ ShellPrintEx (-1, -1,
+ L" Enable No Snoop(11): %E%d%N\r\n",
PCIE_CAP_NO_SNOOP_ENABLE (PcieDeviceControl)
);
- Print (L" Max_Read_Request_Size(14:12): ");
+ ShellPrintEx (-1, -1, L" Max_Read_Request_Size(14:12): ");
if (PCIE_CAP_MAX_READ_REQ_SIZE (PcieDeviceControl) < 6) {
- Print (L"%E%d bytes%N\n", 1 << (PCIE_CAP_MAX_READ_REQ_SIZE (PcieDeviceControl) + 7));
+ ShellPrintEx (-1, -1, L"%E%d bytes%N\r\n", 1 << (PCIE_CAP_MAX_READ_REQ_SIZE (PcieDeviceControl) + 7));
} else {
- Print (L"%EUnknown%N\n");
+ ShellPrintEx (-1, -1, L"%EUnknown%N\r\n");
}
//
// Read operation is only valid for PCI Express to PCI/PCI-X Bridges
//
if (PCIE_CAP_DEVICEPORT_TYPE (PcieCapReg) == PCIE_PCIE_TO_PCIX_BRIDGE) {
- Print (
- L" Bridge Configuration Retry Enable(15): %E%d%N\n",
+ ShellPrintEx (-1, -1,
+ L" Bridge Configuration Retry Enable(15): %E%d%N\r\n",
PCIE_CAP_BRG_CONF_RETRY (PcieDeviceControl)
);
}
@@ -4018,28 +4011,28 @@ ExplainPcieDeviceStatus (
UINT16 PcieDeviceStatus;
PcieDeviceStatus = PciExpressCap->DeviceStatus;
- Print (
- L" Correctable Error Detected(0): %E%d%N\n",
+ ShellPrintEx (-1, -1,
+ L" Correctable Error Detected(0): %E%d%N\r\n",
PCIE_CAP_COR_ERR_DETECTED (PcieDeviceStatus)
);
- Print (
- L" Non-Fatal Error Detected(1): %E%d%N\n",
+ ShellPrintEx (-1, -1,
+ L" Non-Fatal Error Detected(1): %E%d%N\r\n",
PCIE_CAP_NONFAT_ERR_DETECTED (PcieDeviceStatus)
);
- Print (
- L" Fatal Error Detected(2): %E%d%N\n",
+ ShellPrintEx (-1, -1,
+ L" Fatal Error Detected(2): %E%d%N\r\n",
PCIE_CAP_FATAL_ERR_DETECTED (PcieDeviceStatus)
);
- Print (
- L" Unsupported Request Detected(3): %E%d%N\n",
+ ShellPrintEx (-1, -1,
+ L" Unsupported Request Detected(3): %E%d%N\r\n",
PCIE_CAP_UNSUP_REQ_DETECTED (PcieDeviceStatus)
);
- Print (
- L" AUX Power Detected(4): %E%d%N\n",
+ ShellPrintEx (-1, -1,
+ L" AUX Power Detected(4): %E%d%N\r\n",
PCIE_CAP_AUX_POWER_DETECTED (PcieDeviceStatus)
);
- Print (
- L" Transactions Pending(5): %E%d%N\n",
+ ShellPrintEx (-1, -1,
+ L" Transactions Pending(5): %E%d%N\r\n",
PCIE_CAP_TRANSACTION_PENDING (PcieDeviceStatus)
);
return EFI_SUCCESS;
@@ -4058,32 +4051,41 @@ ExplainPcieLinkCap (
)
{
UINT32 PcieLinkCap;
- CHAR16 *SupLinkSpeeds;
+ CHAR16 *MaxLinkSpeed;
CHAR16 *AspmValue;
PcieLinkCap = PciExpressCap->LinkCap;
- switch (PCIE_CAP_SUP_LINK_SPEEDS (PcieLinkCap)) {
+ switch (PCIE_CAP_MAX_LINK_SPEED (PcieLinkCap)) {
case 1:
- SupLinkSpeeds = L"2.5 GT/s";
+ MaxLinkSpeed = L"2.5 GT/s";
break;
case 2:
- SupLinkSpeeds = L"5.0 GT/s and 2.5 GT/s";
+ MaxLinkSpeed = L"5.0 GT/s";
+ break;
+ case 3:
+ MaxLinkSpeed = L"8.0 GT/s";
break;
default:
- SupLinkSpeeds = L"Unknown";
+ MaxLinkSpeed = L"Unknown";
break;
}
- Print (
- L" Supported Link Speeds(3:0): %E%s supported%N\n",
- SupLinkSpeeds
+ ShellPrintEx (-1, -1,
+ L" Maximum Link Speed(3:0): %E%s%N\r\n",
+ MaxLinkSpeed
);
- Print (
- L" Maximum Link Width(9:4): %Ex%d%N\n",
+ ShellPrintEx (-1, -1,
+ L" Maximum Link Width(9:4): %Ex%d%N\r\n",
PCIE_CAP_MAX_LINK_WIDTH (PcieLinkCap)
);
switch (PCIE_CAP_ASPM_SUPPORT (PcieLinkCap)) {
+ case 0:
+ AspmValue = L"Not";
+ break;
case 1:
- AspmValue = L"L0s Entry";
+ AspmValue = L"L0s";
+ break;
+ case 2:
+ AspmValue = L"L1";
break;
case 3:
AspmValue = L"L0s and L1";
@@ -4092,36 +4094,36 @@ ExplainPcieLinkCap (
AspmValue = L"Reserved";
break;
}
- Print (
- L" Active State Power Management Support(11:10): %E%s Supported%N\n",
+ ShellPrintEx (-1, -1,
+ L" Active State Power Management Support(11:10): %E%s Supported%N\r\n",
AspmValue
);
- Print (
- L" L0s Exit Latency(14:12): %E%s%N\n",
+ ShellPrintEx (-1, -1,
+ L" L0s Exit Latency(14:12): %E%s%N\r\n",
L0sLatencyStrTable[PCIE_CAP_L0S_LATENCY (PcieLinkCap)]
);
- Print (
- L" L1 Exit Latency(17:15): %E%s%N\n",
+ ShellPrintEx (-1, -1,
+ L" L1 Exit Latency(17:15): %E%s%N\r\n",
L1LatencyStrTable[PCIE_CAP_L0S_LATENCY (PcieLinkCap)]
);
- Print (
- L" Clock Power Management(18): %E%d%N\n",
+ ShellPrintEx (-1, -1,
+ L" Clock Power Management(18): %E%d%N\r\n",
PCIE_CAP_CLOCK_PM (PcieLinkCap)
);
- Print (
- L" Surprise Down Error Reporting Capable(19): %E%d%N\n",
+ ShellPrintEx (-1, -1,
+ L" Surprise Down Error Reporting Capable(19): %E%d%N\r\n",
PCIE_CAP_SUP_DOWN_ERR_REPORTING (PcieLinkCap)
);
- Print (
- L" Data Link Layer Link Active Reporting Capable(20): %E%d%N\n",
+ ShellPrintEx (-1, -1,
+ L" Data Link Layer Link Active Reporting Capable(20): %E%d%N\r\n",
PCIE_CAP_LINK_ACTIVE_REPORTING (PcieLinkCap)
);
- Print (
- L" Link Bandwidth Notification Capability(21): %E%d%N\n",
+ ShellPrintEx (-1, -1,
+ L" Link Bandwidth Notification Capability(21): %E%d%N\r\n",
PCIE_CAP_LINK_BWD_NOTIF_CAP (PcieLinkCap)
);
- Print (
- L" Port Number(31:24): %E0x%02x%N\n",
+ ShellPrintEx (-1, -1,
+ L" Port Number(31:24): %E0x%02x%N\r\n",
PCIE_CAP_PORT_NUMBER (PcieLinkCap)
);
return EFI_SUCCESS;
@@ -4144,16 +4146,16 @@ ExplainPcieLinkControl (
PcieLinkControl = PciExpressCap->LinkControl;
DevicePortType = (UINT8) PCIE_CAP_DEVICEPORT_TYPE (PciExpressCap->PcieCapReg);
- Print (
- L" Active State Power Management Control(1:0): %E%s%N\n",
+ ShellPrintEx (-1, -1,
+ L" Active State Power Management Control(1:0): %E%s%N\r\n",
ASPMCtrlStrTable[PCIE_CAP_ASPM_CONTROL (PcieLinkControl)]
);
//
// RCB is not applicable to switches
//
if (!IS_PCIE_SWITCH(DevicePortType)) {
- Print (
- L" Read Completion Boundary (RCB)(3): %E%d byte%N\n",
+ ShellPrintEx (-1, -1,
+ L" Read Completion Boundary (RCB)(3): %E%d byte%N\r\n",
1 << (PCIE_CAP_RCB (PcieLinkControl) + 6)
);
}
@@ -4166,33 +4168,33 @@ ExplainPcieLinkControl (
if (!IS_PCIE_ENDPOINT (DevicePortType) &&
DevicePortType != PCIE_SWITCH_UPSTREAM_PORT &&
DevicePortType != PCIE_PCIE_TO_PCIX_BRIDGE) {
- Print (
- L" Link Disable(4): %E%d%N\n",
+ ShellPrintEx (-1, -1,
+ L" Link Disable(4): %E%d%N\r\n",
PCIE_CAP_LINK_DISABLE (PcieLinkControl)
);
}
- Print (
- L" Common Clock Configuration(6): %E%d%N\n",
+ ShellPrintEx (-1, -1,
+ L" Common Clock Configuration(6): %E%d%N\r\n",
PCIE_CAP_COMMON_CLK_CONF (PcieLinkControl)
);
- Print (
- L" Extended Synch(7): %E%d%N\n",
+ ShellPrintEx (-1, -1,
+ L" Extended Synch(7): %E%d%N\r\n",
PCIE_CAP_EXT_SYNC (PcieLinkControl)
);
- Print (
- L" Enable Clock Power Management(8): %E%d%N\n",
+ ShellPrintEx (-1, -1,
+ L" Enable Clock Power Management(8): %E%d%N\r\n",
PCIE_CAP_CLK_PWR_MNG (PcieLinkControl)
);
- Print (
- L" Hardware Autonomous Width Disable(9): %E%d%N\n",
+ ShellPrintEx (-1, -1,
+ L" Hardware Autonomous Width Disable(9): %E%d%N\r\n",
PCIE_CAP_HW_AUTO_WIDTH_DISABLE (PcieLinkControl)
);
- Print (
- L" Link Bandwidth Management Interrupt Enable(10): %E%d%N\n",
+ ShellPrintEx (-1, -1,
+ L" Link Bandwidth Management Interrupt Enable(10): %E%d%N\r\n",
PCIE_CAP_LINK_BDW_MNG_INT_EN (PcieLinkControl)
);
- Print (
- L" Link Autonomous Bandwidth Interrupt Enable(11): %E%d%N\n",
+ ShellPrintEx (-1, -1,
+ L" Link Autonomous Bandwidth Interrupt Enable(11): %E%d%N\r\n",
PCIE_CAP_LINK_AUTO_BDW_INT_EN (PcieLinkControl)
);
return EFI_SUCCESS;
@@ -4211,46 +4213,49 @@ ExplainPcieLinkStatus (
)
{
UINT16 PcieLinkStatus;
- CHAR16 *SupLinkSpeeds;
+ CHAR16 *CurLinkSpeed;
PcieLinkStatus = PciExpressCap->LinkStatus;
switch (PCIE_CAP_CUR_LINK_SPEED (PcieLinkStatus)) {
case 1:
- SupLinkSpeeds = L"2.5 GT/s";
+ CurLinkSpeed = L"2.5 GT/s";
break;
case 2:
- SupLinkSpeeds = L"5.0 GT/s";
+ CurLinkSpeed = L"5.0 GT/s";
+ break;
+ case 3:
+ CurLinkSpeed = L"8.0 GT/s";
break;
default:
- SupLinkSpeeds = L"Reserved";
+ CurLinkSpeed = L"Reserved";
break;
}
- Print (
- L" Current Link Speed(3:0): %E%s%N\n",
- SupLinkSpeeds
+ ShellPrintEx (-1, -1,
+ L" Current Link Speed(3:0): %E%s%N\r\n",
+ CurLinkSpeed
);
- Print (
- L" Negotiated Link Width(9:4): %Ex%d%N\n",
+ ShellPrintEx (-1, -1,
+ L" Negotiated Link Width(9:4): %Ex%d%N\r\n",
PCIE_CAP_NEGO_LINK_WIDTH (PcieLinkStatus)
);
- Print (
- L" Link Training(11): %E%d%N\n",
+ ShellPrintEx (-1, -1,
+ L" Link Training(11): %E%d%N\r\n",
PCIE_CAP_LINK_TRAINING (PcieLinkStatus)
);
- Print (
- L" Slot Clock Configuration(12): %E%d%N\n",
+ ShellPrintEx (-1, -1,
+ L" Slot Clock Configuration(12): %E%d%N\r\n",
PCIE_CAP_SLOT_CLK_CONF (PcieLinkStatus)
);
- Print (
- L" Data Link Layer Link Active(13): %E%d%N\n",
+ ShellPrintEx (-1, -1,
+ L" Data Link Layer Link Active(13): %E%d%N\r\n",
PCIE_CAP_DATA_LINK_ACTIVE (PcieLinkStatus)
);
- Print (
- L" Link Bandwidth Management Status(14): %E%d%N\n",
+ ShellPrintEx (-1, -1,
+ L" Link Bandwidth Management Status(14): %E%d%N\r\n",
PCIE_CAP_LINK_BDW_MNG_STAT (PcieLinkStatus)
);
- Print (
- L" Link Autonomous Bandwidth Status(15): %E%d%N\n",
+ ShellPrintEx (-1, -1,
+ L" Link Autonomous Bandwidth Status(15): %E%d%N\r\n",
PCIE_CAP_LINK_AUTO_BDW_STAT (PcieLinkStatus)
);
return EFI_SUCCESS;
@@ -4272,52 +4277,52 @@ ExplainPcieSlotCap (
PcieSlotCap = PciExpressCap->SlotCap;
- Print (
- L" Attention Button Present(0): %E%d%N\n",
+ ShellPrintEx (-1, -1,
+ L" Attention Button Present(0): %E%d%N\r\n",
PCIE_CAP_ATT_BUT_PRESENT (PcieSlotCap)
);
- Print (
- L" Power Controller Present(1): %E%d%N\n",
+ ShellPrintEx (-1, -1,
+ L" Power Controller Present(1): %E%d%N\r\n",
PCIE_CAP_PWR_CTRLLER_PRESENT (PcieSlotCap)
);
- Print (
- L" MRL Sensor Present(2): %E%d%N\n",
+ ShellPrintEx (-1, -1,
+ L" MRL Sensor Present(2): %E%d%N\r\n",
PCIE_CAP_MRL_SENSOR_PRESENT (PcieSlotCap)
);
- Print (
- L" Attention Indicator Present(3): %E%d%N\n",
+ ShellPrintEx (-1, -1,
+ L" Attention Indicator Present(3): %E%d%N\r\n",
PCIE_CAP_ATT_IND_PRESENT (PcieSlotCap)
);
- Print (
- L" Power Indicator Present(4): %E%d%N\n",
+ ShellPrintEx (-1, -1,
+ L" Power Indicator Present(4): %E%d%N\r\n",
PCIE_CAP_PWD_IND_PRESENT (PcieSlotCap)
);
- Print (
- L" Hot-Plug Surprise(5): %E%d%N\n",
+ ShellPrintEx (-1, -1,
+ L" Hot-Plug Surprise(5): %E%d%N\r\n",
PCIE_CAP_HOTPLUG_SUPPRISE (PcieSlotCap)
);
- Print (
- L" Hot-Plug Capable(6): %E%d%N\n",
+ ShellPrintEx (-1, -1,
+ L" Hot-Plug Capable(6): %E%d%N\r\n",
PCIE_CAP_HOTPLUG_CAPABLE (PcieSlotCap)
);
- Print (
- L" Slot Power Limit Value(14:7): %E0x%02x%N\n",
+ ShellPrintEx (-1, -1,
+ L" Slot Power Limit Value(14:7): %E0x%02x%N\r\n",
PCIE_CAP_SLOT_PWR_LIMIT_VALUE (PcieSlotCap)
);
- Print (
- L" Slot Power Limit Scale(16:15): %E%s%N\n",
+ ShellPrintEx (-1, -1,
+ L" Slot Power Limit Scale(16:15): %E%s%N\r\n",
SlotPwrLmtScaleTable[PCIE_CAP_SLOT_PWR_LIMIT_SCALE (PcieSlotCap)]
);
- Print (
- L" Electromechanical Interlock Present(17): %E%d%N\n",
+ ShellPrintEx (-1, -1,
+ L" Electromechanical Interlock Present(17): %E%d%N\r\n",
PCIE_CAP_ELEC_INTERLOCK_PRESENT (PcieSlotCap)
);
- Print (
- L" No Command Completed Support(18): %E%d%N\n",
+ ShellPrintEx (-1, -1,
+ L" No Command Completed Support(18): %E%d%N\r\n",
PCIE_CAP_NO_COMM_COMPLETED_SUP (PcieSlotCap)
);
- Print (
- L" Physical Slot Number(31:19): %E%d%N\n",
+ ShellPrintEx (-1, -1,
+ L" Physical Slot Number(31:19): %E%d%N\r\n",
PCIE_CAP_PHY_SLOT_NUM (PcieSlotCap)
);
@@ -4339,50 +4344,50 @@ ExplainPcieSlotControl (
UINT16 PcieSlotControl;
PcieSlotControl = PciExpressCap->SlotControl;
- Print (
- L" Attention Button Pressed Enable(0): %E%d%N\n",
+ ShellPrintEx (-1, -1,
+ L" Attention Button Pressed Enable(0): %E%d%N\r\n",
PCIE_CAP_ATT_BUT_ENABLE (PcieSlotControl)
);
- Print (
- L" Power Fault Detected Enable(1): %E%d%N\n",
+ ShellPrintEx (-1, -1,
+ L" Power Fault Detected Enable(1): %E%d%N\r\n",
PCIE_CAP_PWR_FLT_DETECT_ENABLE (PcieSlotControl)
);
- Print (
- L" MRL Sensor Changed Enable(2): %E%d%N\n",
+ ShellPrintEx (-1, -1,
+ L" MRL Sensor Changed Enable(2): %E%d%N\r\n",
PCIE_CAP_MRL_SENSOR_CHANGE_ENABLE (PcieSlotControl)
);
- Print (
- L" Presence Detect Changed Enable(3): %E%d%N\n",
+ ShellPrintEx (-1, -1,
+ L" Presence Detect Changed Enable(3): %E%d%N\r\n",
PCIE_CAP_PRES_DETECT_CHANGE_ENABLE (PcieSlotControl)
);
- Print (
- L" Command Completed Interrupt Enable(4): %E%d%N\n",
+ ShellPrintEx (-1, -1,
+ L" Command Completed Interrupt Enable(4): %E%d%N\r\n",
PCIE_CAP_COMM_CMPL_INT_ENABLE (PcieSlotControl)
);
- Print (
- L" Hot-Plug Interrupt Enable(5): %E%d%N\n",
+ ShellPrintEx (-1, -1,
+ L" Hot-Plug Interrupt Enable(5): %E%d%N\r\n",
PCIE_CAP_HOTPLUG_INT_ENABLE (PcieSlotControl)
);
- Print (
- L" Attention Indicator Control(7:6): %E%s%N\n",
+ ShellPrintEx (-1, -1,
+ L" Attention Indicator Control(7:6): %E%s%N\r\n",
IndicatorTable[PCIE_CAP_ATT_IND_CTRL (PcieSlotControl)]
);
- Print (
- L" Power Indicator Control(9:8): %E%s%N\n",
+ ShellPrintEx (-1, -1,
+ L" Power Indicator Control(9:8): %E%s%N\r\n",
IndicatorTable[PCIE_CAP_PWR_IND_CTRL (PcieSlotControl)]
);
- Print (L" Power Controller Control(10): %EPower ");
+ ShellPrintEx (-1, -1, L" Power Controller Control(10): %EPower ");
if (PCIE_CAP_PWR_CTRLLER_CTRL (PcieSlotControl)) {
- Print (L"Off%N\n");
+ ShellPrintEx (-1, -1, L"Off%N\r\n");
} else {
- Print (L"On%N\n");
+ ShellPrintEx (-1, -1, L"On%N\r\n");
}
- Print (
- L" Electromechanical Interlock Control(11): %E%d%N\n",
+ ShellPrintEx (-1, -1,
+ L" Electromechanical Interlock Control(11): %E%d%N\r\n",
PCIE_CAP_ELEC_INTERLOCK_CTRL (PcieSlotControl)
);
- Print (
- L" Data Link Layer State Changed Enable(12): %E%d%N\n",
+ ShellPrintEx (-1, -1,
+ L" Data Link Layer State Changed Enable(12): %E%d%N\r\n",
PCIE_CAP_DLINK_STAT_CHANGE_ENABLE (PcieSlotControl)
);
return EFI_SUCCESS;
@@ -4404,46 +4409,46 @@ ExplainPcieSlotStatus (
PcieSlotStatus = PciExpressCap->SlotStatus;
- Print (
- L" Attention Button Pressed(0): %E%d%N\n",
+ ShellPrintEx (-1, -1,
+ L" Attention Button Pressed(0): %E%d%N\r\n",
PCIE_CAP_ATT_BUT_PRESSED (PcieSlotStatus)
);
- Print (
- L" Power Fault Detected(1): %E%d%N\n",
+ ShellPrintEx (-1, -1,
+ L" Power Fault Detected(1): %E%d%N\r\n",
PCIE_CAP_PWR_FLT_DETECTED (PcieSlotStatus)
);
- Print (
- L" MRL Sensor Changed(2): %E%d%N\n",
+ ShellPrintEx (-1, -1,
+ L" MRL Sensor Changed(2): %E%d%N\r\n",
PCIE_CAP_MRL_SENSOR_CHANGED (PcieSlotStatus)
);
- Print (
- L" Presence Detect Changed(3): %E%d%N\n",
+ ShellPrintEx (-1, -1,
+ L" Presence Detect Changed(3): %E%d%N\r\n",
PCIE_CAP_PRES_DETECT_CHANGED (PcieSlotStatus)
);
- Print (
- L" Command Completed(4): %E%d%N\n",
+ ShellPrintEx (-1, -1,
+ L" Command Completed(4): %E%d%N\r\n",
PCIE_CAP_COMM_COMPLETED (PcieSlotStatus)
);
- Print (L" MRL Sensor State(5): %EMRL ");
+ ShellPrintEx (-1, -1, L" MRL Sensor State(5): %EMRL ");
if (PCIE_CAP_MRL_SENSOR_STATE (PcieSlotStatus)) {
- Print (L" Opened%N\n");
+ ShellPrintEx (-1, -1, L" Opened%N\r\n");
} else {
- Print (L" Closed%N\n");
+ ShellPrintEx (-1, -1, L" Closed%N\r\n");
}
- Print (L" Presence Detect State(6): ");
+ ShellPrintEx (-1, -1, L" Presence Detect State(6): ");
if (PCIE_CAP_PRES_DETECT_STATE (PcieSlotStatus)) {
- Print (L"%ECard Present in slot%N\n");
+ ShellPrintEx (-1, -1, L"%ECard Present in slot%N\r\n");
} else {
- Print (L"%ESlot Empty%N\n");
+ ShellPrintEx (-1, -1, L"%ESlot Empty%N\r\n");
}
- Print (L" Electromechanical Interlock Status(7): %EElectromechanical Interlock ");
+ ShellPrintEx (-1, -1, L" Electromechanical Interlock Status(7): %EElectromechanical Interlock ");
if (PCIE_CAP_ELEC_INTERLOCK_STATE (PcieSlotStatus)) {
- Print (L"Engaged%N\n");
+ ShellPrintEx (-1, -1, L"Engaged%N\r\n");
} else {
- Print (L"Disengaged%N\n");
+ ShellPrintEx (-1, -1, L"Disengaged%N\r\n");
}
- Print (
- L" Data Link Layer State Changed(8): %E%d%N\n",
+ ShellPrintEx (-1, -1,
+ L" Data Link Layer State Changed(8): %E%d%N\r\n",
PCIE_CAP_DLINK_STAT_CHANGED (PcieSlotStatus)
);
return EFI_SUCCESS;
@@ -4465,24 +4470,24 @@ ExplainPcieRootControl (
PcieRootControl = PciExpressCap->RootControl;
- Print (
- L" System Error on Correctable Error Enable(0): %E%d%N\n",
+ ShellPrintEx (-1, -1,
+ L" System Error on Correctable Error Enable(0): %E%d%N\r\n",
PCIE_CAP_SYSERR_ON_CORERR_EN (PcieRootControl)
);
- Print (
- L" System Error on Non-Fatal Error Enable(1): %E%d%N\n",
+ ShellPrintEx (-1, -1,
+ L" System Error on Non-Fatal Error Enable(1): %E%d%N\r\n",
PCIE_CAP_SYSERR_ON_NONFATERR_EN (PcieRootControl)
);
- Print (
- L" System Error on Fatal Error Enable(2): %E%d%N\n",
+ ShellPrintEx (-1, -1,
+ L" System Error on Fatal Error Enable(2): %E%d%N\r\n",
PCIE_CAP_SYSERR_ON_FATERR_EN (PcieRootControl)
);
- Print (
- L" PME Interrupt Enable(3): %E%d%N\n",
+ ShellPrintEx (-1, -1,
+ L" PME Interrupt Enable(3): %E%d%N\r\n",
PCIE_CAP_PME_INT_ENABLE (PcieRootControl)
);
- Print (
- L" CRS Software Visibility Enable(4): %E%d%N\n",
+ ShellPrintEx (-1, -1,
+ L" CRS Software Visibility Enable(4): %E%d%N\r\n",
PCIE_CAP_CRS_SW_VIS_ENABLE (PcieRootControl)
);
@@ -4505,8 +4510,8 @@ ExplainPcieRootCap (
PcieRootCap = PciExpressCap->RsvdP;
- Print (
- L" CRS Software Visibility(0): %E%d%N\n",
+ ShellPrintEx (-1, -1,
+ L" CRS Software Visibility(0): %E%d%N\r\n",
PCIE_CAP_CRS_SW_VIS (PcieRootCap)
);
@@ -4529,16 +4534,16 @@ ExplainPcieRootStatus (
PcieRootStatus = PciExpressCap->RootStatus;
- Print (
- L" PME Requester ID(15:0): %E0x%04x%N\n",
+ ShellPrintEx (-1, -1,
+ L" PME Requester ID(15:0): %E0x%04x%N\r\n",
PCIE_CAP_PME_REQ_ID (PcieRootStatus)
);
- Print (
- L" PME Status(16): %E%d%N\n",
+ ShellPrintEx (-1, -1,
+ L" PME Status(16): %E%d%N\r\n",
PCIE_CAP_PME_STATUS (PcieRootStatus)
);
- Print (
- L" PME Pending(17): %E%d%N\n",
+ ShellPrintEx (-1, -1,
+ L" PME Pending(17): %E%d%N\r\n",
PCIE_CAP_PME_PENDING (PcieRootStatus)
);
return EFI_SUCCESS;
@@ -4584,7 +4589,7 @@ PciExplainPciExpress (
DevicePortType = (UINT8) PCIE_CAP_DEVICEPORT_TYPE (PciExpressCap.PcieCapReg);
- Print (L"\nPci Express device capability structure:\n");
+ ShellPrintEx (-1, -1, L"\r\nPci Express device capability structure:\r\n");
for (Index = 0; PcieExplainList[Index].Type < PcieExplainTypeMax; Index++) {
if (ShellGetExecutionBreakFlag()) {
@@ -4682,7 +4687,7 @@ PciExplainPciExpress (
//
// Start outputing PciEx extend space( 0xFF-0xFFF)
//
- Print (L"\n%HStart dumping PCIex extended configuration space (0x100 - 0xFFF).%N\n\n");
+ ShellPrintEx (-1, -1, L"\r\n%HStart dumping PCIex extended configuration space (0x100 - 0xFFF).%N\r\n\r\n");
if (ExRegBuffer != NULL) {
DumpHex (
diff --git a/ShellPkg/Library/UefiShellDebug1CommandsLib/Pci.h b/ShellPkg/Library/UefiShellDebug1CommandsLib/Pci.h
index 04a22da52..8a053ab98 100644
--- a/ShellPkg/Library/UefiShellDebug1CommandsLib/Pci.h
+++ b/ShellPkg/Library/UefiShellDebug1CommandsLib/Pci.h
@@ -1,6 +1,7 @@
/** @file
Header file for Pci shell Debug1 function.
+ Copyright (c) 2013 Hewlett-Packard Development Company, L.P.
Copyright (c) 2005 - 2010, 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
@@ -157,7 +158,7 @@ typedef enum {
//
// Link Capabilities Register
//
-#define PCIE_CAP_SUP_LINK_SPEEDS(PcieLinkCap) \
+#define PCIE_CAP_MAX_LINK_SPEED(PcieLinkCap) \
((PcieLinkCap) & 0x0f)
#define PCIE_CAP_MAX_LINK_WIDTH(PcieLinkCap) \
(((PcieLinkCap) >> 4) & 0x3f)
diff --git a/ShellPkg/Library/UefiShellLevel1CommandsLib/For.c b/ShellPkg/Library/UefiShellLevel1CommandsLib/For.c
index b01c69d3d..f0c4a23b2 100644
--- a/ShellPkg/Library/UefiShellLevel1CommandsLib/For.c
+++ b/ShellPkg/Library/UefiShellLevel1CommandsLib/For.c
@@ -254,6 +254,29 @@ InternalRemoveAliasFromList(
}
/**
+ Function to determine whether a string is decimal or hex representation of a number
+ and return the number converted from the string.
+
+ @param[in] String String representation of a number
+
+ @return the number
+ @retval (UINTN)(-1) An error ocurred.
+**/
+UINTN
+EFIAPI
+ReturnUintn(
+ IN CONST CHAR16 *String
+ )
+{
+ UINT64 RetVal;
+
+ if (!EFI_ERROR(ShellConvertStringToUint64(String, &RetVal, FALSE, FALSE))) {
+ return ((UINTN)RetVal);
+ }
+ return ((UINTN)(-1));
+}
+
+/**
Function for 'for' command.
@param[in] ImageHandle Handle to the Image (NULL if Internal).
@@ -486,9 +509,9 @@ ShellCommandRunFor (
ShellStatus = SHELL_INVALID_PARAMETER;
} else {
if (ArgSetWalker[0] == L'-') {
- Info->Current = 0 - (INTN)ShellStrToUintn(ArgSetWalker+1);
+ Info->Current = 0 - (INTN)ReturnUintn(ArgSetWalker+1);
} else {
- Info->Current = (INTN)ShellStrToUintn(ArgSetWalker);
+ Info->Current = (INTN)ReturnUintn(ArgSetWalker);
}
ArgSetWalker = StrStr(ArgSetWalker, L" ");
while (ArgSetWalker != NULL && ArgSetWalker[0] == L' ') {
@@ -508,9 +531,9 @@ ShellCommandRunFor (
ShellStatus = SHELL_INVALID_PARAMETER;
} else {
if (ArgSetWalker[0] == L'-') {
- Info->End = 0 - (INTN)ShellStrToUintn(ArgSetWalker+1);
+ Info->End = 0 - (INTN)ReturnUintn(ArgSetWalker+1);
} else {
- Info->End = (INTN)ShellStrToUintn(ArgSetWalker);
+ Info->End = (INTN)ReturnUintn(ArgSetWalker);
}
if (Info->Current < Info->End) {
Info->Step = 1;
@@ -540,9 +563,9 @@ ShellCommandRunFor (
ASSERT(Info->Step == 1 || Info->Step == -1);
} else {
if (ArgSetWalker[0] == L'-') {
- Info->Step = 0 - (INTN)ShellStrToUintn(ArgSetWalker+1);
+ Info->Step = 0 - (INTN)ReturnUintn(ArgSetWalker+1);
} else {
- Info->Step = (INTN)ShellStrToUintn(ArgSetWalker);
+ Info->Step = (INTN)ReturnUintn(ArgSetWalker);
}
if (StrStr(ArgSetWalker, L" ") != NULL) {
diff --git a/ShellPkg/Library/UefiShellLevel1CommandsLib/If.c b/ShellPkg/Library/UefiShellLevel1CommandsLib/If.c
index f5bc12638..791b1aed8 100644
--- a/ShellPkg/Library/UefiShellLevel1CommandsLib/If.c
+++ b/ShellPkg/Library/UefiShellLevel1CommandsLib/If.c
@@ -1,6 +1,7 @@
/** @file
Main file for If and else shell level 1 function.
+ Copyright (c) 2013, Hewlett-Packard Development Company, L.P.
Copyright (c) 2009 - 2011, 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
@@ -734,7 +735,11 @@ MoveToTagSpecial (
continue;
}
CommandWalker = CommandName;
- while (CommandWalker[0] == L' ') {
+
+ //
+ // Skip leading spaces and tabs.
+ //
+ while ((CommandWalker[0] == L' ') || (CommandWalker[0] == L'\t')) {
CommandWalker++;
}
TempLocation = StrStr(CommandWalker, L" ");
@@ -847,7 +852,7 @@ ShellCommandRunIf (
NULL,
STRING_TOKEN (STR_SYNTAX_NO_MATCHING),
gShellLevel1HiiHandle,
- L"EnfIf",
+ L"EndIf",
L"If",
CurrentScriptFile!=NULL
&& CurrentScriptFile->CurrentCommand!=NULL
diff --git a/ShellPkg/Library/UefiShellLevel1CommandsLib/UefiShellLevel1CommandsLib.c b/ShellPkg/Library/UefiShellLevel1CommandsLib/UefiShellLevel1CommandsLib.c
index 6f67f49ae..5dca0629d 100644
--- a/ShellPkg/Library/UefiShellLevel1CommandsLib/UefiShellLevel1CommandsLib.c
+++ b/ShellPkg/Library/UefiShellLevel1CommandsLib/UefiShellLevel1CommandsLib.c
@@ -1,6 +1,7 @@
/** @file
Main file for NULL named library for level 1 shell command functions.
+ Copyright (c) 2013, Hewlett-Packard Development Company, L.P.
Copyright (c) 2009 - 2011, 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
@@ -150,7 +151,11 @@ TestNodeForMove (
}
CommandNameWalker = CommandName;
- while(CommandNameWalker[0] == L' ') {
+
+ //
+ // Skip leading spaces and tabs.
+ //
+ while ((CommandNameWalker[0] == L' ') || (CommandNameWalker[0] == L'\t')) {
CommandNameWalker++;
}
TempLocation = StrStr(CommandNameWalker, L" ");
diff --git a/ShellPkg/Library/UefiShellLevel2CommandsLib/Map.c b/ShellPkg/Library/UefiShellLevel2CommandsLib/Map.c
index bd004beaa..590dbf79e 100644
--- a/ShellPkg/Library/UefiShellLevel2CommandsLib/Map.c
+++ b/ShellPkg/Library/UefiShellLevel2CommandsLib/Map.c
@@ -397,10 +397,14 @@ PerformSingleMappingDisplay(
CHAR16 *MediaType;
CHAR16 *DevPathString;
CHAR16 *TempSpot;
+ CHAR16 *Alias;
UINTN TempLen;
BOOLEAN Removable;
CONST CHAR16 *TempSpot2;
+ Alias = NULL;
+ TempSpot2 = NULL;
+ CurrentName = NULL;
DevPath = DevicePathFromHandle(Handle);
DevPathCopy = DevPath;
MapList = gEfiShellProtocol->GetMapFromDevicePath(&DevPathCopy);
@@ -412,14 +416,74 @@ PerformSingleMappingDisplay(
return EFI_NOT_FOUND;
}
- CurrentName = NULL;
- CurrentName = StrnCatGrow(&CurrentName, 0, MapList, 0);
- if (CurrentName == NULL) {
- return (EFI_OUT_OF_RESOURCES);
- }
- TempSpot = StrStr(CurrentName, L";");
- if (TempSpot != NULL) {
- *TempSpot = CHAR_NULL;
+ if (Normal) {
+ //
+ // Allocate a name
+ //
+ CurrentName = NULL;
+ CurrentName = StrnCatGrow(&CurrentName, 0, MapList, 0);
+ if (CurrentName == NULL) {
+ return (EFI_OUT_OF_RESOURCES);
+ }
+
+ //
+ // Chop off the other names that become "Alias(s)"
+ // leaving just the normal name
+ //
+ TempSpot = StrStr(CurrentName, L";");
+ if (TempSpot != NULL) {
+ *TempSpot = CHAR_NULL;
+ }
+ } else if (Consist) {
+ CurrentName = NULL;
+
+ //
+ // Skip the first name. This is the standard name.
+ //
+ TempSpot = StrStr(MapList, L";");
+ if (TempSpot != NULL) {
+ TempSpot++;
+ }
+ SearchList(TempSpot, L"HD*", &CurrentName, TRUE, FALSE, L";");
+ if (CurrentName == NULL) {
+ SearchList(TempSpot, L"CD*", &CurrentName, TRUE, FALSE, L";");
+ }
+ if (CurrentName == NULL) {
+ SearchList(TempSpot, L"FP*", &CurrentName, TRUE, FALSE, L";");
+ }
+ if (CurrentName == NULL) {
+ SearchList(TempSpot, L"F*", &CurrentName, TRUE, FALSE, L";");
+ }
+ if (CurrentName == NULL) {
+ //
+ // We didnt find anything, so just the first one in the list...
+ //
+ CurrentName = StrnCatGrow(&CurrentName, 0, MapList, 0);
+ if (CurrentName == NULL) {
+ return (EFI_OUT_OF_RESOURCES);
+ }
+ TempSpot = StrStr(CurrentName, L";");
+ if (TempSpot != NULL) {
+ *TempSpot = CHAR_NULL;
+ }
+ } else {
+ Alias = StrnCatGrow(&Alias, 0, MapList, 0);
+ TempSpot = StrStr(Alias, CurrentName);
+ if (TempSpot != NULL) {
+ TempSpot2 = StrStr(TempSpot, L";");
+ if (TempSpot2 != NULL) {
+ TempSpot2++; // Move past ";" from CurrentName
+ CopyMem(TempSpot, TempSpot2, StrSize(TempSpot2));
+ } else {
+ *TempSpot = CHAR_NULL;
+ }
+ }
+ if (Alias[StrLen(Alias)-1] == L';') {
+ Alias[StrLen(Alias)-1] = CHAR_NULL;
+ }
+ }
+ } else {
+ CurrentName = NULL;
}
DevPathString = ConvertDevicePathToText(DevPath, TRUE, FALSE);
if (!SFO) {
@@ -431,7 +495,7 @@ PerformSingleMappingDisplay(
STRING_TOKEN (STR_MAP_ENTRY),
gShellLevel2HiiHandle,
CurrentName,
- TempLen < StrLen(MapList)?MapList + TempLen+1:L"",
+ Alias!=NULL?Alias:(TempLen < StrLen(MapList)?MapList + TempLen+1:L""),
DevPathString
);
if (Verbose) {
@@ -454,7 +518,7 @@ PerformSingleMappingDisplay(
TempSpot2
);
}
- FreePool(MediaType);
+ SHELL_FREE_NON_NULL(MediaType);
}
} else {
TempLen = StrLen(CurrentName);
@@ -466,11 +530,12 @@ PerformSingleMappingDisplay(
gShellLevel2HiiHandle,
CurrentName,
DevPathString,
- TempLen < StrLen(MapList)?MapList + TempLen+1:L""
+ Consist?L"":(TempLen < StrLen(MapList)?MapList + TempLen+1:L"")
);
}
- FreePool(DevPathString);
- FreePool(CurrentName);
+ SHELL_FREE_NON_NULL(DevPathString);
+ SHELL_FREE_NON_NULL(CurrentName);
+ SHELL_FREE_NON_NULL(Alias);
return EFI_SUCCESS;
}
diff --git a/ShellPkg/Library/UefiShellLib/UefiShellLib.c b/ShellPkg/Library/UefiShellLib/UefiShellLib.c
index 6b985ed64..40b87fec3 100644
--- a/ShellPkg/Library/UefiShellLib/UefiShellLib.c
+++ b/ShellPkg/Library/UefiShellLib/UefiShellLib.c
@@ -3057,8 +3057,34 @@ ShellIsFileInPath(
}
/**
+ Function return the number converted from a hex representation of a number.
+
+ Note: this function cannot be used when (UINTN)(-1), (0xFFFFFFFF) may be a valid
+ result. Use ShellConvertStringToUint64 instead.
+
+ @param[in] String String representation of a number.
+
+ @return The unsigned integer result of the conversion.
+ @retval (UINTN)(-1) An error occured.
+**/
+UINTN
+EFIAPI
+ShellHexStrToUintn(
+ IN CONST CHAR16 *String
+ )
+{
+ UINT64 RetVal;
+
+ if (!EFI_ERROR(ShellConvertStringToUint64(String, &RetVal, TRUE, TRUE))) {
+ return ((UINTN)RetVal);
+ }
+
+ return ((UINTN)(-1));
+}
+
+/**
Function to determine whether a string is decimal or hex representation of a number
- and return the number converted from the string.
+ and return the number converted from the string. Spaces are always skipped.
@param[in] String String representation of a number