]> git.proxmox.com Git - mirror_edk2.git/commitdiff
ShellPkg/pci: Report error when invalid value is specified for "-ec"
authorRuiyu Ni <ruiyu.ni@intel.com>
Thu, 9 Feb 2017 09:24:05 +0000 (17:24 +0800)
committerRuiyu Ni <ruiyu.ni@intel.com>
Thu, 16 Feb 2017 05:40:28 +0000 (13:40 +0800)
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Ruiyu Ni <ruiyu.ni@intel.com>
Reviewed-by: Jaben Carsey <jaben.carsey@intel.com>
ShellPkg/Library/UefiShellDebug1CommandsLib/Pci.c
ShellPkg/Library/UefiShellDebug1CommandsLib/UefiShellDebug1CommandsLib.uni

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