diff options
author | Chris Phillips <chrisp@hp.com> | 2013-12-02 21:45:28 +0000 |
---|---|---|
committer | jcarsey <jcarsey@6f19259b-4bc3-4df7-8a09-765794883524> | 2013-12-02 21:45:28 +0000 |
commit | 6855763eb262f3d95dc0216d035cc7203b4e29cc (patch) | |
tree | da58eb32270503f761759102217a94fadd5116dd /ShellPkg/Library/UefiShellDebug1CommandsLib/Pci.c | |
parent | ed8b529782eee377c7f50a7220a40f92db506eed (diff) | |
download | edk2-6855763eb262f3d95dc0216d035cc7203b4e29cc.zip edk2-6855763eb262f3d95dc0216d035cc7203b4e29cc.tar.gz edk2-6855763eb262f3d95dc0216d035cc7203b4e29cc.tar.bz2 |
ShellPkg: Fix pci command to parse seg, bus, dev, and func arguments as hex
- Added STR_GEN_PARAM_INV_HEX string
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Chris Phillips <chrisp@hp.com>
Reviewed-by: Jaben Carsey <jaben.carsey@intel.com>
git-svn-id: https://svn.code.sf.net/p/edk2/code/trunk/edk2@14926 6f19259b-4bc3-4df7-8a09-765794883524
Diffstat (limited to 'ShellPkg/Library/UefiShellDebug1CommandsLib/Pci.c')
-rw-r--r-- | ShellPkg/Library/UefiShellDebug1CommandsLib/Pci.c | 48 |
1 files changed, 44 insertions, 4 deletions
diff --git a/ShellPkg/Library/UefiShellDebug1CommandsLib/Pci.c b/ShellPkg/Library/UefiShellDebug1CommandsLib/Pci.c index e67c93f..d200939 100644 --- a/ShellPkg/Library/UefiShellDebug1CommandsLib/Pci.c +++ b/ShellPkg/Library/UefiShellDebug1CommandsLib/Pci.c @@ -2049,6 +2049,7 @@ ShellCommandRunPci ( CHAR16 *ProblemParam;
SHELL_STATUS ShellStatus;
CONST CHAR16 *Temp;
+ UINT64 RetVal;
ShellStatus = SHELL_SUCCESS;
Status = EFI_SUCCESS;
@@ -2302,7 +2303,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 +2321,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 +2340,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 +2360,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;
|