diff --git a/ShellPkg/Library/UefiShellDebug1CommandsLib/Pci.c b/ShellPkg/Library/UefiShellDebug1CommandsLib/Pci.c index fb7561f668..37f15d6cdf 100644 --- a/ShellPkg/Library/UefiShellDebug1CommandsLib/Pci.c +++ b/ShellPkg/Library/UefiShellDebug1CommandsLib/Pci.c @@ -2726,6 +2726,7 @@ ShellCommandRunPci ( Bus = 0; Device = 0; Func = 0; + EnhancedDump = 0xFFFF; if (ShellCommandLineGetFlag(Package, L"-i")) { ExplainData = TRUE; } @@ -2807,6 +2808,20 @@ ShellCommandRunPci ( } } + Temp = ShellCommandLineGetValue (Package, L"-ec"); + if (Temp != NULL) { + // + // Input converted to hexadecimal number. + // + if (!EFI_ERROR (ShellConvertStringToUint64 (Temp, &RetVal, TRUE, TRUE))) { + EnhancedDump = (UINT16) RetVal; + } else { + ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_GEN_PARAM_INV_HEX), gShellDebug1HiiHandle, L"pci", Temp); + ShellStatus = SHELL_INVALID_PARAMETER; + goto Done; + } + } + // // Find the protocol interface who's in charge of current segment, and its // bus range covers the current bus @@ -2883,12 +2898,6 @@ ShellCommandRunPci ( // If "-i" appears in command line, interpret data in configuration space // if (ExplainData) { - EnhancedDump = 0xFFFF; - if (ShellCommandLineGetFlag(Package, L"-ec")) { - Temp = ShellCommandLineGetValue(Package, L"-ec"); - ASSERT (Temp != NULL); - EnhancedDump = (UINT16) ShellHexStrToUintn (Temp); - } Status = PciExplainData (&ConfigSpace, Address, IoDev, EnhancedDump); } } diff --git a/ShellPkg/Library/UefiShellDebug1CommandsLib/UefiShellDebug1CommandsLib.uni b/ShellPkg/Library/UefiShellDebug1CommandsLib/UefiShellDebug1CommandsLib.uni index 8ea4215f9c..7c0ca986e8 100644 --- a/ShellPkg/Library/UefiShellDebug1CommandsLib/UefiShellDebug1CommandsLib.uni +++ b/ShellPkg/Library/UefiShellDebug1CommandsLib/UefiShellDebug1CommandsLib.uni @@ -39,7 +39,7 @@ #string STR_GEN_PCIRBIO_NF #language en-US "%H%s%N: Protocol - PciRootBridgeIo not found.\r\n" #string STR_GEN_PCIRBIO_ER #language en-US "%H%s%N: Problem accessing the data using Protocol - PciRootBridgeIo\r\n" #string STR_GEN_PARAM_INV #language en-US "%H%s%N: Invalid argument - '%H%s%N'\r\n" -#string STR_GEN_PARAM_INV_HEX #language en-US "%H%s%N: Invalid parameter - '%H%s%N:'. Must be hexadecimal.\r\n" +#string STR_GEN_PARAM_INV_HEX #language en-US "%H%s%N: Invalid parameter - '%H%s%N'. Must be hexadecimal.\r\n" #string STR_GEN_PARAM_CONFLICT #language en-US "%H%s%N: Flags conflict with - '%H%s%N' and '%H%s%N'\r\n" #string STR_GEN_OUT_MEM #language en-US "%H%s%N: Memory allocation was not successful.\r\n" #string STR_GEN_MAP_PROTOCOL #language en-US "%H%s%N: Mapped device '%B%s%N' does not have protocol %B%s%N\r\n"