summaryrefslogtreecommitdiffstats
path: root/ShellPkg/Library/UefiShellDebug1CommandsLib/Pci.c
diff options
context:
space:
mode:
authorRuiyu Ni <ruiyu.ni@intel.com>2017-02-09 17:24:05 +0800
committerRuiyu Ni <ruiyu.ni@intel.com>2017-02-16 13:40:28 +0800
commit31d7be0135b8e8b95508daa6484bebba6280af15 (patch)
treeb45a14df1298223268ba0a213461adea28ab33f3 /ShellPkg/Library/UefiShellDebug1CommandsLib/Pci.c
parentfd12acdeff7a04ad34ccb95103eb6204b8901749 (diff)
downloadedk2-31d7be0135b8e8b95508daa6484bebba6280af15.tar.gz
edk2-31d7be0135b8e8b95508daa6484bebba6280af15.tar.bz2
edk2-31d7be0135b8e8b95508daa6484bebba6280af15.zip
ShellPkg/pci: Report error when invalid value is specified for "-ec"
Contributed-under: TianoCore Contribution Agreement 1.0 Signed-off-by: Ruiyu Ni <ruiyu.ni@intel.com> Reviewed-by: Jaben Carsey <jaben.carsey@intel.com>
Diffstat (limited to 'ShellPkg/Library/UefiShellDebug1CommandsLib/Pci.c')
-rw-r--r--ShellPkg/Library/UefiShellDebug1CommandsLib/Pci.c21
1 files changed, 15 insertions, 6 deletions
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);
}
}