]> git.proxmox.com Git - mirror_edk2.git/commitdiff
Updating level 1 commands.
authorjcarsey <jcarsey@6f19259b-4bc3-4df7-8a09-765794883524>
Fri, 25 Mar 2011 20:43:03 +0000 (20:43 +0000)
committerjcarsey <jcarsey@6f19259b-4bc3-4df7-8a09-765794883524>
Fri, 25 Mar 2011 20:43:03 +0000 (20:43 +0000)
exit - correctly convert the parameter to the return code.
for  - update string-to-number conversion.
if   - use shell string-to-number conversion and add comments.
stall- add command

main lib files:
add comments, clarify user visible strings, add stall.

git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@11420 6f19259b-4bc3-4df7-8a09-765794883524

ShellPkg/Library/UefiShellLevel1CommandsLib/Exit.c
ShellPkg/Library/UefiShellLevel1CommandsLib/For.c
ShellPkg/Library/UefiShellLevel1CommandsLib/If.c
ShellPkg/Library/UefiShellLevel1CommandsLib/Stall.c [new file with mode: 0644]
ShellPkg/Library/UefiShellLevel1CommandsLib/UefiShellLevel1CommandsLib.c
ShellPkg/Library/UefiShellLevel1CommandsLib/UefiShellLevel1CommandsLib.h
ShellPkg/Library/UefiShellLevel1CommandsLib/UefiShellLevel1CommandsLib.inf
ShellPkg/Library/UefiShellLevel1CommandsLib/UefiShellLevel1CommandsLib.uni

index 2f2a5bf56580da6b17815affa1108588a941d603..5620d023b1223ac05e32d5a9bc330343ce137a8b 100644 (file)
@@ -1,7 +1,7 @@
 /** @file\r
   Main file for exit shell level 1 function.\r
 \r
 /** @file\r
   Main file for exit shell level 1 function.\r
 \r
-  Copyright (c) 2009 - 2010, Intel Corporation. All rights reserved.<BR>\r
+  Copyright (c) 2009 - 2011, Intel Corporation. All rights reserved.<BR>\r
   This program and the accompanying materials\r
   are licensed and made available under the terms and conditions of the BSD License\r
   which accompanies this distribution.  The full text of the license may be found at\r
   This program and the accompanying materials\r
   are licensed and made available under the terms and conditions of the BSD License\r
   which accompanies this distribution.  The full text of the license may be found at\r
@@ -36,6 +36,8 @@ ShellCommandRunExit (
   LIST_ENTRY          *Package;\r
   CHAR16              *ProblemParam;\r
   SHELL_STATUS        ShellStatus;\r
   LIST_ENTRY          *Package;\r
   CHAR16              *ProblemParam;\r
   SHELL_STATUS        ShellStatus;\r
+  UINT64              RetVal;\r
+  CONST CHAR16        *Return;\r
 \r
   ShellStatus         = SHELL_SUCCESS;\r
 \r
 \r
   ShellStatus         = SHELL_SUCCESS;\r
 \r
@@ -62,16 +64,29 @@ ShellCommandRunExit (
     }\r
   } else {\r
 \r
     }\r
   } else {\r
 \r
-    //\r
-    // If we are in a batch file and /b then pass TRUE otherwise false...\r
-    //\r
-    ShellCommandRegisterExit((BOOLEAN)(gEfiShellProtocol->BatchIsActive() && ShellCommandLineGetFlag(Package, L"/b")));\r
-\r
     //\r
     // return the specified error code\r
     //\r
     //\r
     // return the specified error code\r
     //\r
-    if (ShellCommandLineGetRawValue(Package, 1) != NULL) {\r
-      ShellStatus = (SHELL_STATUS)(ShellStrToUintn(ShellCommandLineGetRawValue(Package, 1)));\r
+    Return = ShellCommandLineGetRawValue(Package, 1);\r
+    if (Return != NULL) {\r
+      Status = ShellConvertStringToUint64(Return, &RetVal, FALSE, FALSE);\r
+      if (EFI_ERROR(Status)) {\r
+        ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_PROBLEM), gShellLevel1HiiHandle, Return);\r
+        ShellStatus = SHELL_INVALID_PARAMETER;\r
+      } else {\r
+        //\r
+        // If we are in a batch file and /b then pass TRUE otherwise false...\r
+        //\r
+        ShellCommandRegisterExit((BOOLEAN)(gEfiShellProtocol->BatchIsActive() && ShellCommandLineGetFlag(Package, L"/b")));\r
+\r
+        ShellStatus = (SHELL_STATUS)(RetVal);\r
+      }\r
+    } else {\r
+      // If we are in a batch file and /b then pass TRUE otherwise false...\r
+      //\r
+      ShellCommandRegisterExit((BOOLEAN)(gEfiShellProtocol->BatchIsActive() && ShellCommandLineGetFlag(Package, L"/b")));\r
+\r
+      ShellStatus = (SHELL_STATUS)0;\r
     }\r
 \r
     ShellCommandLineFreeVarList (Package);\r
     }\r
 \r
     ShellCommandLineFreeVarList (Package);\r
index 297a137664616c546fe89e509f6b04ad7d22b1c8..006ce6c67599bd944a07001eb512ce4eac8582ea 100644 (file)
@@ -1,7 +1,7 @@
 /** @file\r
   Main file for endfor and for shell level 1 functions.\r
 \r
 /** @file\r
   Main file for endfor and for shell level 1 functions.\r
 \r
-  Copyright (c) 2009 - 2010, Intel Corporation. All rights reserved.<BR>\r
+  Copyright (c) 2009 - 2011, Intel Corporation. All rights reserved.<BR>\r
   This program and the accompanying materials\r
   are licensed and made available under the terms and conditions of the BSD License\r
   which accompanies this distribution.  The full text of the license may be found at\r
   This program and the accompanying materials\r
   are licensed and made available under the terms and conditions of the BSD License\r
   which accompanies this distribution.  The full text of the license may be found at\r
 #include "UefiShellLevel1CommandsLib.h"\r
 #include <Library/PrintLib.h>\r
 \r
 #include "UefiShellLevel1CommandsLib.h"\r
 #include <Library/PrintLib.h>\r
 \r
+/**\r
+  Determine if a valid string is a valid number for the 'for' command.\r
+\r
+  @param[in] Number The pointer to the string representation of the number to test.\r
+\r
+  @retval TRUE    The number is valid.\r
+  @retval FALSE   The number is not valid.\r
+**/\r
 BOOLEAN\r
 EFIAPI\r
 ShellIsValidForNumber (\r
 BOOLEAN\r
 EFIAPI\r
 ShellIsValidForNumber (\r
@@ -308,7 +316,7 @@ ShellCommandRunFor (
       ||!((gEfiShellParametersProtocol->Argv[1][1] >= L'a' && gEfiShellParametersProtocol->Argv[1][1] <= L'z')\r
        ||(gEfiShellParametersProtocol->Argv[1][1] >= L'A' && gEfiShellParametersProtocol->Argv[1][1] <= L'Z'))\r
      ) {\r
       ||!((gEfiShellParametersProtocol->Argv[1][1] >= L'a' && gEfiShellParametersProtocol->Argv[1][1] <= L'z')\r
        ||(gEfiShellParametersProtocol->Argv[1][1] >= L'A' && gEfiShellParametersProtocol->Argv[1][1] <= L'Z'))\r
      ) {\r
-      ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_INV_VAR), gShellLevel1HiiHandle, gEfiShellParametersProtocol->Argv[2]);\r
+      ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_INV_VAR), gShellLevel1HiiHandle, gEfiShellParametersProtocol->Argv[1]);\r
       return (SHELL_INVALID_PARAMETER);\r
     }\r
 \r
       return (SHELL_INVALID_PARAMETER);\r
     }\r
 \r
@@ -379,7 +387,7 @@ ShellCommandRunFor (
         if (ArgSet == NULL) {\r
 //        ArgSet = StrnCatGrow(&ArgSet, &ArgSize, L"\"", 0);\r
         } else {\r
         if (ArgSet == NULL) {\r
 //        ArgSet = StrnCatGrow(&ArgSet, &ArgSize, L"\"", 0);\r
         } else {\r
-          ArgSet = StrnCatGrow(&ArgSet, &ArgSize, L"  ", 0);\r
+          ArgSet = StrnCatGrow(&ArgSet, &ArgSize, L" ", 0);\r
         }\r
         ArgSet = StrnCatGrow(&ArgSet, &ArgSize, gEfiShellParametersProtocol->Argv[LoopVar], 0);\r
 //        ArgSet = StrnCatGrow(&ArgSet, &ArgSize, L" ", 0);\r
         }\r
         ArgSet = StrnCatGrow(&ArgSet, &ArgSize, gEfiShellParametersProtocol->Argv[LoopVar], 0);\r
 //        ArgSet = StrnCatGrow(&ArgSet, &ArgSize, L" ", 0);\r
@@ -397,49 +405,60 @@ ShellCommandRunFor (
         ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_PROBLEM_SCRIPT), gShellLevel1HiiHandle, ArgSet, ShellCommandGetCurrentScriptFile()->CurrentCommand->Line);\r
         ShellStatus = SHELL_INVALID_PARAMETER;\r
       } else {\r
         ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_PROBLEM_SCRIPT), gShellLevel1HiiHandle, ArgSet, ShellCommandGetCurrentScriptFile()->CurrentCommand->Line);\r
         ShellStatus = SHELL_INVALID_PARAMETER;\r
       } else {\r
-        ArgSetWalker++;\r
-        while (ArgSetWalker != NULL && ArgSetWalker[0] == L' ') {\r
-          ArgSetWalker++;\r
+        TempSpot = StrStr(ArgSetWalker, L")");\r
+        if (TempSpot != NULL) {\r
+          TempString = TempSpot+1;\r
+          if (*(TempString) != CHAR_NULL) {\r
+            while(TempString != NULL && *TempString == L' ') {\r
+              TempString++;\r
+            }\r
+            if (StrLen(TempString) > 0) {\r
+              TempSpot = NULL;\r
+            }\r
+          }\r
         }\r
         }\r
-        if (!ShellIsValidForNumber(ArgSetWalker)) {\r
+        if (TempSpot == NULL) {\r
           ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_PROBLEM_SCRIPT), gShellLevel1HiiHandle, ArgSet, ShellCommandGetCurrentScriptFile()->CurrentCommand->Line);\r
           ShellStatus = SHELL_INVALID_PARAMETER;\r
         } else {\r
           ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_PROBLEM_SCRIPT), gShellLevel1HiiHandle, ArgSet, ShellCommandGetCurrentScriptFile()->CurrentCommand->Line);\r
           ShellStatus = SHELL_INVALID_PARAMETER;\r
         } else {\r
-          if (ArgSetWalker[0] == L'-') {\r
-            Info->Current = 0 - (INTN)ShellStrToUintn(ArgSetWalker+1);\r
-          } else {\r
-            Info->Current = (INTN)ShellStrToUintn(ArgSetWalker);\r
-          }\r
-          ArgSetWalker  = StrStr(ArgSetWalker, L" ");\r
+          *TempSpot = CHAR_NULL;\r
+          ArgSetWalker++;\r
           while (ArgSetWalker != NULL && ArgSetWalker[0] == L' ') {\r
             ArgSetWalker++;\r
           }\r
           while (ArgSetWalker != NULL && ArgSetWalker[0] == L' ') {\r
             ArgSetWalker++;\r
           }\r
-          if (ArgSetWalker == NULL || *ArgSetWalker == CHAR_NULL || !ShellIsValidForNumber(ArgSetWalker)){\r
+          if (!ShellIsValidForNumber(ArgSetWalker)) {\r
             ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_PROBLEM_SCRIPT), gShellLevel1HiiHandle, ArgSet, ShellCommandGetCurrentScriptFile()->CurrentCommand->Line);\r
             ShellStatus = SHELL_INVALID_PARAMETER;\r
           } else {\r
             if (ArgSetWalker[0] == L'-') {\r
             ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_PROBLEM_SCRIPT), gShellLevel1HiiHandle, ArgSet, ShellCommandGetCurrentScriptFile()->CurrentCommand->Line);\r
             ShellStatus = SHELL_INVALID_PARAMETER;\r
           } else {\r
             if (ArgSetWalker[0] == L'-') {\r
-              Info->End = 0 - (INTN)ShellStrToUintn(ArgSetWalker+1);\r
+              Info->Current = 0 - (INTN)ShellStrToUintn(ArgSetWalker+1);\r
             } else {\r
             } else {\r
-              Info->End = (INTN)ShellStrToUintn(ArgSetWalker);\r
+              Info->Current = (INTN)ShellStrToUintn(ArgSetWalker);\r
             }\r
             }\r
-            if (Info->Current < Info->End) {\r
-              Info->Step            = 1;\r
-            } else {\r
-              Info->Step            = -1;\r
-            }\r
-\r
             ArgSetWalker  = StrStr(ArgSetWalker, L" ");\r
             while (ArgSetWalker != NULL && ArgSetWalker[0] == L' ') {\r
               ArgSetWalker++;\r
             }\r
             ArgSetWalker  = StrStr(ArgSetWalker, L" ");\r
             while (ArgSetWalker != NULL && ArgSetWalker[0] == L' ') {\r
               ArgSetWalker++;\r
             }\r
-            if (ArgSetWalker != NULL && *ArgSetWalker != CHAR_NULL) {\r
-              TempSpot = StrStr(ArgSetWalker, L")");\r
-              if (TempSpot == NULL) {\r
-                ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_PROBLEM_SCRIPT), gShellLevel1HiiHandle, ArgSet, ShellCommandGetCurrentScriptFile()->CurrentCommand->Line);\r
-                ShellStatus = SHELL_INVALID_PARAMETER;\r
+            if (ArgSetWalker == NULL || *ArgSetWalker == CHAR_NULL || !ShellIsValidForNumber(ArgSetWalker)){\r
+              ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_PROBLEM_SCRIPT), gShellLevel1HiiHandle, ArgSet, ShellCommandGetCurrentScriptFile()->CurrentCommand->Line);\r
+              ShellStatus = SHELL_INVALID_PARAMETER;\r
+            } else {\r
+              if (ArgSetWalker[0] == L'-') {\r
+                Info->End = 0 - (INTN)ShellStrToUintn(ArgSetWalker+1);\r
               } else {\r
               } else {\r
-                *TempSpot = CHAR_NULL;\r
+                Info->End = (INTN)ShellStrToUintn(ArgSetWalker);\r
+              }\r
+              if (Info->Current < Info->End) {\r
+                Info->Step            = 1;\r
+              } else {\r
+                Info->Step            = -1;\r
+              }\r
+\r
+              ArgSetWalker  = StrStr(ArgSetWalker, L" ");\r
+              while (ArgSetWalker != NULL && ArgSetWalker[0] == L' ') {\r
+                ArgSetWalker++;\r
+              }\r
+              if (ArgSetWalker != NULL && *ArgSetWalker != CHAR_NULL) {\r
                 if (ArgSetWalker == NULL || *ArgSetWalker == CHAR_NULL || !ShellIsValidForNumber(ArgSetWalker)){\r
                   ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_PROBLEM_SCRIPT), gShellLevel1HiiHandle, ArgSet, ShellCommandGetCurrentScriptFile()->CurrentCommand->Line);\r
                   ShellStatus = SHELL_INVALID_PARAMETER;\r
                 if (ArgSetWalker == NULL || *ArgSetWalker == CHAR_NULL || !ShellIsValidForNumber(ArgSetWalker)){\r
                   ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_PROBLEM_SCRIPT), gShellLevel1HiiHandle, ArgSet, ShellCommandGetCurrentScriptFile()->CurrentCommand->Line);\r
                   ShellStatus = SHELL_INVALID_PARAMETER;\r
@@ -452,8 +471,14 @@ ShellCommandRunFor (
                     } else {\r
                       Info->Step = (INTN)ShellStrToUintn(ArgSetWalker);\r
                     }\r
                     } else {\r
                       Info->Step = (INTN)ShellStrToUintn(ArgSetWalker);\r
                     }\r
+\r
+                    if (StrStr(ArgSetWalker, L" ") != NULL) {\r
+                      ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_PROBLEM_SCRIPT), gShellLevel1HiiHandle, ArgSet, ShellCommandGetCurrentScriptFile()->CurrentCommand->Line);\r
+                      ShellStatus = SHELL_INVALID_PARAMETER;\r
+                    }\r
                   }\r
                 }\r
                   }\r
                 }\r
+                \r
               }\r
             }\r
           }\r
               }\r
             }\r
           }\r
@@ -529,9 +554,9 @@ ShellCommandRunFor (
         if (Info->CurrentValue[0] == L'\"') {\r
           Info->CurrentValue++;\r
         }\r
         if (Info->CurrentValue[0] == L'\"') {\r
           Info->CurrentValue++;\r
         }\r
-        while (Info->CurrentValue[0] == L' ') {\r
-          Info->CurrentValue++;\r
-        }\r
+//        while (Info->CurrentValue[0] == L' ') {\r
+//          Info->CurrentValue++;\r
+//        }\r
         if (Info->CurrentValue[0] == L'\"') {\r
           Info->CurrentValue++;\r
         }\r
         if (Info->CurrentValue[0] == L'\"') {\r
           Info->CurrentValue++;\r
         }\r
index f3fc6b06a83d7d300aab8d31b4de31252fe6f82a..59069e568f42d09565d005f73c85c046977bc595 100644 (file)
@@ -1,7 +1,7 @@
 /** @file\r
   Main file for If and else shell level 1 function.\r
 \r
 /** @file\r
   Main file for If and else shell level 1 function.\r
 \r
-  Copyright (c) 2009 - 2010, Intel Corporation. All rights reserved.<BR>\r
+  Copyright (c) 2009 - 2011, Intel Corporation. All rights reserved.<BR>\r
   This program and the accompanying materials\r
   are licensed and made available under the terms and conditions of the BSD License\r
   which accompanies this distribution.  The full text of the license may be found at\r
   This program and the accompanying materials\r
   are licensed and made available under the terms and conditions of the BSD License\r
   which accompanies this distribution.  The full text of the license may be found at\r
 #include "UefiShellLevel1CommandsLib.h"\r
 #include <Library/PrintLib.h>\r
 \r
 #include "UefiShellLevel1CommandsLib.h"\r
 #include <Library/PrintLib.h>\r
 \r
-\r
-\r
-\r
 typedef enum {\r
 typedef enum {\r
-  END_TAG_OR,\r
-  END_TAG_AND,\r
-  END_TAG_THEN,\r
-  END_TAG_MAX\r
+  EndTagOr,\r
+  EndTagAnd,\r
+  EndTagThen,\r
+  EndTagMax\r
 } END_TAG_TYPE;\r
 \r
 typedef enum {\r
 } END_TAG_TYPE;\r
 \r
 typedef enum {\r
-  OPERATOR_GT,\r
-  OPERATOR_LT,\r
-  OPERATOR_EQ,\r
-  OPERATOR_NE,\r
-  OPERATOR_GE,\r
-  OPERATOR_LE,\r
-  OPERATOR_UGT,\r
-  OPERATOR_ULT,\r
-  OPERATOR_UGE,\r
-  OPERATOR_ULE,\r
-  OPERATOR_MAX\r
+  OperatorGreaterThan,\r
+  OperatorLessThan,\r
+  OperatorEqual,\r
+  OperatorNotEqual,\r
+  OperatorGreatorOrEqual,\r
+  OperatorLessOrEqual,\r
+  OperatorUnisgnedGreaterThan,\r
+  OperatorUnsignedLessThan,\r
+  OperatorUnsignedGreaterOrEqual,\r
+  OperatorUnsignedLessOrEqual,\r
+  OperatorMax\r
 } BIN_OPERATOR_TYPE;\r
 \r
 } BIN_OPERATOR_TYPE;\r
 \r
+/**\r
+  Extract the next fragment, if there is one.\r
+\r
+  @param[in,out] Statement    The current remaining statement.\r
+  @param[in] Fragment         The current fragment.\r
+\r
+  @retval FALSE   There is not another fragment.\r
+  @retval TRUE    There is another fragment.\r
+**/\r
 BOOLEAN\r
 EFIAPI\r
 IsNextFragment (\r
 BOOLEAN\r
 EFIAPI\r
 IsNextFragment (\r
-  IN CONST CHAR16         **Statement,\r
+  IN OUT CONST CHAR16     **Statement,\r
   IN CONST CHAR16         *Fragment\r
   )\r
 {\r
   IN CONST CHAR16         *Fragment\r
   )\r
 {\r
@@ -71,6 +77,14 @@ IsNextFragment (
   return (FALSE);\r
 }\r
 \r
   return (FALSE);\r
 }\r
 \r
+/**\r
+  Determine if String represents a valid profile.\r
+\r
+  @param[in] String     The pointer to the string to test.\r
+\r
+  @retval TRUE    String is a valid profile.\r
+  @retval FALSE   String is not a valid profile.\r
+**/\r
 BOOLEAN\r
 EFIAPI\r
 IsValidProfile (\r
 BOOLEAN\r
 EFIAPI\r
 IsValidProfile (\r
@@ -88,6 +102,17 @@ IsValidProfile (
   return (FALSE);\r
 }\r
 \r
   return (FALSE);\r
 }\r
 \r
+/**\r
+  Do a comparison between 2 things.\r
+\r
+  @param[in] Compare1           The first item to compare.\r
+  @param[in] Compare2           The second item to compare.\r
+  @param[in] BinOp              The type of comparison to perform.\r
+  @param[in] CaseInsensitive    TRUE to do non-case comparison, FALSE otherwise.\r
+  @param[in] ForceStringCompare TRUE to force string comparison, FALSE otherwise.\r
+\r
+  @return     The result of the comparison.\r
+**/\r
 BOOLEAN\r
 EFIAPI\r
 TestOperation (\r
 BOOLEAN\r
 EFIAPI\r
 TestOperation (\r
@@ -105,8 +130,8 @@ TestOperation (
   // "Compare1 BinOp Compare2"\r
   //\r
   switch (BinOp) {\r
   // "Compare1 BinOp Compare2"\r
   //\r
   switch (BinOp) {\r
-  case OPERATOR_UGT:\r
-  case OPERATOR_GT:\r
+  case OperatorUnisgnedGreaterThan:\r
+  case OperatorGreaterThan:\r
     if (ForceStringCompare || !ShellIsHexOrDecimalNumber(Compare1, FALSE, FALSE) || !ShellIsHexOrDecimalNumber(Compare2, FALSE, FALSE)) {\r
       //\r
       // string compare\r
     if (ForceStringCompare || !ShellIsHexOrDecimalNumber(Compare1, FALSE, FALSE) || !ShellIsHexOrDecimalNumber(Compare2, FALSE, FALSE)) {\r
       //\r
       // string compare\r
@@ -119,16 +144,16 @@ TestOperation (
       // numeric compare\r
       //\r
       if (Compare1[0] == L'-') {\r
       // numeric compare\r
       //\r
       if (Compare1[0] == L'-') {\r
-        Cmp1 = 0 - (INTN)StrDecimalToUintn(Compare1+1);\r
+        Cmp1 = 0 - (INTN)ShellStrToUintn(Compare1+1);\r
       } else {\r
       } else {\r
-        Cmp1 = (INTN)StrDecimalToUintn(Compare1);\r
+        Cmp1 = (INTN)ShellStrToUintn(Compare1);\r
       }\r
       if (Compare2[0] == L'-') {\r
       }\r
       if (Compare2[0] == L'-') {\r
-        Cmp2 = 0 - (INTN)StrDecimalToUintn(Compare2+1);\r
+        Cmp2 = 0 - (INTN)ShellStrToUintn(Compare2+1);\r
       } else {\r
       } else {\r
-        Cmp2 = (INTN)StrDecimalToUintn(Compare2);\r
+        Cmp2 = (INTN)ShellStrToUintn(Compare2);\r
       }\r
       }\r
-      if (BinOp == OPERATOR_GT) {\r
+      if (BinOp == OperatorGreaterThan) {\r
         if (Cmp1 > Cmp2) {\r
           return (TRUE);\r
         }\r
         if (Cmp1 > Cmp2) {\r
           return (TRUE);\r
         }\r
@@ -140,8 +165,8 @@ TestOperation (
     }\r
     return (FALSE);\r
     break;\r
     }\r
     return (FALSE);\r
     break;\r
-  case OPERATOR_ULT:\r
-  case OPERATOR_LT:\r
+  case OperatorUnsignedLessThan:\r
+  case OperatorLessThan:\r
     if (ForceStringCompare || !ShellIsHexOrDecimalNumber(Compare1, FALSE, FALSE) || !ShellIsHexOrDecimalNumber(Compare2, FALSE, FALSE)) {\r
       //\r
       // string compare\r
     if (ForceStringCompare || !ShellIsHexOrDecimalNumber(Compare1, FALSE, FALSE) || !ShellIsHexOrDecimalNumber(Compare2, FALSE, FALSE)) {\r
       //\r
       // string compare\r
@@ -154,16 +179,16 @@ TestOperation (
       // numeric compare\r
       //\r
       if (Compare1[0] == L'-') {\r
       // numeric compare\r
       //\r
       if (Compare1[0] == L'-') {\r
-        Cmp1 = 0 - (INTN)StrDecimalToUintn(Compare1+1);\r
+        Cmp1 = 0 - (INTN)ShellStrToUintn(Compare1+1);\r
       } else {\r
       } else {\r
-        Cmp1 = (INTN)StrDecimalToUintn(Compare1);\r
+        Cmp1 = (INTN)ShellStrToUintn(Compare1);\r
       }\r
       if (Compare2[0] == L'-') {\r
       }\r
       if (Compare2[0] == L'-') {\r
-        Cmp2 = 0 - (INTN)StrDecimalToUintn(Compare2+1);\r
+        Cmp2 = 0 - (INTN)ShellStrToUintn(Compare2+1);\r
       } else {\r
       } else {\r
-        Cmp2 = (INTN)StrDecimalToUintn(Compare2);\r
+        Cmp2 = (INTN)ShellStrToUintn(Compare2);\r
       }\r
       }\r
-      if (BinOp == OPERATOR_LT) {\r
+      if (BinOp == OperatorLessThan) {\r
         if (Cmp1 < Cmp2) {\r
           return (TRUE);\r
         }\r
         if (Cmp1 < Cmp2) {\r
           return (TRUE);\r
         }\r
@@ -176,7 +201,7 @@ TestOperation (
     }\r
     return (FALSE);\r
     break;\r
     }\r
     return (FALSE);\r
     break;\r
-  case OPERATOR_EQ:\r
+  case OperatorEqual:\r
     if (ForceStringCompare || !ShellIsHexOrDecimalNumber(Compare1, FALSE, FALSE) || !ShellIsHexOrDecimalNumber(Compare2, FALSE, FALSE)) {\r
       //\r
       // string compare\r
     if (ForceStringCompare || !ShellIsHexOrDecimalNumber(Compare1, FALSE, FALSE) || !ShellIsHexOrDecimalNumber(Compare2, FALSE, FALSE)) {\r
       //\r
       // string compare\r
@@ -204,7 +229,7 @@ TestOperation (
     }\r
     return (FALSE);\r
     break;\r
     }\r
     return (FALSE);\r
     break;\r
-  case OPERATOR_NE:\r
+  case OperatorNotEqual:\r
     if (ForceStringCompare || !ShellIsHexOrDecimalNumber(Compare1, FALSE, FALSE) || !ShellIsHexOrDecimalNumber(Compare2, FALSE, FALSE)) {\r
       //\r
       // string compare\r
     if (ForceStringCompare || !ShellIsHexOrDecimalNumber(Compare1, FALSE, FALSE) || !ShellIsHexOrDecimalNumber(Compare2, FALSE, FALSE)) {\r
       //\r
       // string compare\r
@@ -217,14 +242,14 @@ TestOperation (
       // numeric compare\r
       //\r
       if (Compare1[0] == L'-') {\r
       // numeric compare\r
       //\r
       if (Compare1[0] == L'-') {\r
-        Cmp1 = 0 - (INTN)StrDecimalToUintn(Compare1+1);\r
+        Cmp1 = 0 - (INTN)ShellStrToUintn(Compare1+1);\r
       } else {\r
       } else {\r
-        Cmp1 = (INTN)StrDecimalToUintn(Compare1);\r
+        Cmp1 = (INTN)ShellStrToUintn(Compare1);\r
       }\r
       if (Compare2[0] == L'-') {\r
       }\r
       if (Compare2[0] == L'-') {\r
-        Cmp2 = 0 - (INTN)StrDecimalToUintn(Compare2+1);\r
+        Cmp2 = 0 - (INTN)ShellStrToUintn(Compare2+1);\r
       } else {\r
       } else {\r
-        Cmp2 = (INTN)StrDecimalToUintn(Compare2);\r
+        Cmp2 = (INTN)ShellStrToUintn(Compare2);\r
       }\r
       if (Cmp1 != Cmp2) {\r
         return (TRUE);\r
       }\r
       if (Cmp1 != Cmp2) {\r
         return (TRUE);\r
@@ -232,8 +257,8 @@ TestOperation (
     }\r
     return (FALSE);\r
     break;\r
     }\r
     return (FALSE);\r
     break;\r
-  case OPERATOR_UGE:\r
-  case OPERATOR_GE:\r
+  case OperatorUnsignedGreaterOrEqual:\r
+  case OperatorGreatorOrEqual:\r
     if (ForceStringCompare || !ShellIsHexOrDecimalNumber(Compare1, FALSE, FALSE) || !ShellIsHexOrDecimalNumber(Compare2, FALSE, FALSE)) {\r
       //\r
       // string compare\r
     if (ForceStringCompare || !ShellIsHexOrDecimalNumber(Compare1, FALSE, FALSE) || !ShellIsHexOrDecimalNumber(Compare2, FALSE, FALSE)) {\r
       //\r
       // string compare\r
@@ -246,16 +271,16 @@ TestOperation (
       // numeric compare\r
       //\r
       if (Compare1[0] == L'-') {\r
       // numeric compare\r
       //\r
       if (Compare1[0] == L'-') {\r
-        Cmp1 = 0 - (INTN)StrDecimalToUintn(Compare1+1);\r
+        Cmp1 = 0 - (INTN)ShellStrToUintn(Compare1+1);\r
       } else {\r
       } else {\r
-        Cmp1 = (INTN)StrDecimalToUintn(Compare1);\r
+        Cmp1 = (INTN)ShellStrToUintn(Compare1);\r
       }\r
       if (Compare2[0] == L'-') {\r
       }\r
       if (Compare2[0] == L'-') {\r
-        Cmp2 = 0 - (INTN)StrDecimalToUintn(Compare2+1);\r
+        Cmp2 = 0 - (INTN)ShellStrToUintn(Compare2+1);\r
       } else {\r
       } else {\r
-        Cmp2 = (INTN)StrDecimalToUintn(Compare2);\r
+        Cmp2 = (INTN)ShellStrToUintn(Compare2);\r
       }\r
       }\r
-      if (BinOp == OPERATOR_GE) {\r
+      if (BinOp == OperatorGreatorOrEqual) {\r
         if (Cmp1 >= Cmp2) {\r
           return (TRUE);\r
         }\r
         if (Cmp1 >= Cmp2) {\r
           return (TRUE);\r
         }\r
@@ -267,8 +292,8 @@ TestOperation (
     }\r
     return (FALSE);\r
     break;\r
     }\r
     return (FALSE);\r
     break;\r
-  case OPERATOR_LE:\r
-  case OPERATOR_ULE:\r
+  case OperatorLessOrEqual:\r
+  case OperatorUnsignedLessOrEqual:\r
     if (ForceStringCompare || !ShellIsHexOrDecimalNumber(Compare1, FALSE, FALSE) || !ShellIsHexOrDecimalNumber(Compare2, FALSE, FALSE)) {\r
       //\r
       // string compare\r
     if (ForceStringCompare || !ShellIsHexOrDecimalNumber(Compare1, FALSE, FALSE) || !ShellIsHexOrDecimalNumber(Compare2, FALSE, FALSE)) {\r
       //\r
       // string compare\r
@@ -281,16 +306,16 @@ TestOperation (
       // numeric compare\r
       //\r
       if (Compare1[0] == L'-') {\r
       // numeric compare\r
       //\r
       if (Compare1[0] == L'-') {\r
-        Cmp1 = 0 - (INTN)StrDecimalToUintn(Compare1+1);\r
+        Cmp1 = 0 - (INTN)ShellStrToUintn(Compare1+1);\r
       } else {\r
       } else {\r
-        Cmp1 = (INTN)StrDecimalToUintn(Compare1);\r
+        Cmp1 = (INTN)ShellStrToUintn(Compare1);\r
       }\r
       if (Compare2[0] == L'-') {\r
       }\r
       if (Compare2[0] == L'-') {\r
-        Cmp2 = 0 - (INTN)StrDecimalToUintn(Compare2+1);\r
+        Cmp2 = 0 - (INTN)ShellStrToUintn(Compare2+1);\r
       } else {\r
       } else {\r
-        Cmp2 = (INTN)StrDecimalToUintn(Compare2);\r
+        Cmp2 = (INTN)ShellStrToUintn(Compare2);\r
       }\r
       }\r
-      if (BinOp == OPERATOR_LE) {\r
+      if (BinOp == OperatorLessOrEqual) {\r
         if (Cmp1 <= Cmp2) {\r
           return (TRUE);\r
         }\r
         if (Cmp1 <= Cmp2) {\r
           return (TRUE);\r
         }\r
@@ -308,6 +333,22 @@ TestOperation (
   }\r
 }\r
 \r
   }\r
 }\r
 \r
+/**\r
+  Process an if statement and determine if its is valid or not.\r
+\r
+  @param[in,out] PassingState     Opon entry, the current state.  Upon exit, \r
+                                  the new state.\r
+  @param[in] StartParameterNumber The number of the first parameter of\r
+                                  this statement.\r
+  @param[in] EndParameterNumber   The number of the final parameter of\r
+                                  this statement.\r
+  @param[in] OperatorToUse        The type of termination operator.\r
+  @param[in] CaseInsensitive      TRUE for case insensitive, FALSE otherwise.\r
+  @param[in] ForceStringCompare   TRUE for all string based, FALSE otherwise.\r
+\r
+  @retval EFI_INVALID_PARAMETER   A parameter was invalid.\r
+  @retval EFI_SUCCESS             The operation was successful.                                  \r
+**/\r
 EFI_STATUS\r
 EFIAPI\r
 ProcessStatement (\r
 EFI_STATUS\r
 EFIAPI\r
 ProcessStatement (\r
@@ -329,10 +370,10 @@ ProcessStatement (
   CHAR16                  HexString[20];\r
   CHAR16                  *TempSpot;\r
 \r
   CHAR16                  HexString[20];\r
   CHAR16                  *TempSpot;\r
 \r
-  ASSERT((END_TAG_TYPE)OperatorToUse != END_TAG_THEN);\r
+  ASSERT((END_TAG_TYPE)OperatorToUse != EndTagThen);\r
 \r
   Status          = EFI_SUCCESS;\r
 \r
   Status          = EFI_SUCCESS;\r
-  BinOp           = OPERATOR_MAX;\r
+  BinOp           = OperatorMax;\r
   OperationResult = FALSE;\r
   StatementWalker = gEfiShellParametersProtocol->Argv[StartParameterNumber];\r
   if (IsNextFragment((CONST CHAR16**)(&StatementWalker), L"not")) {\r
   OperationResult = FALSE;\r
   StatementWalker = gEfiShellParametersProtocol->Argv[StartParameterNumber];\r
   if (IsNextFragment((CONST CHAR16**)(&StatementWalker), L"not")) {\r
@@ -397,7 +438,7 @@ ProcessStatement (
     //\r
     Compare1 = NULL;\r
     Compare2 = NULL;\r
     //\r
     Compare1 = NULL;\r
     Compare2 = NULL;\r
-    BinOp    = OPERATOR_MAX;\r
+    BinOp    = OperatorMax;\r
 \r
     //\r
     // get the first item\r
 \r
     //\r
     // get the first item\r
@@ -473,27 +514,27 @@ ProcessStatement (
     ASSERT(StartParameterNumber+1<EndParameterNumber);\r
     StatementWalker = gEfiShellParametersProtocol->Argv[StartParameterNumber+1];\r
     if (IsNextFragment((CONST CHAR16**)(&StatementWalker), L"gt")) {\r
     ASSERT(StartParameterNumber+1<EndParameterNumber);\r
     StatementWalker = gEfiShellParametersProtocol->Argv[StartParameterNumber+1];\r
     if (IsNextFragment((CONST CHAR16**)(&StatementWalker), L"gt")) {\r
-      BinOp = OPERATOR_GT;\r
+      BinOp = OperatorGreaterThan;\r
     } else if (IsNextFragment((CONST CHAR16**)(&StatementWalker), L"lt")) {\r
     } else if (IsNextFragment((CONST CHAR16**)(&StatementWalker), L"lt")) {\r
-      BinOp = OPERATOR_LT;\r
+      BinOp = OperatorLessThan;\r
     } else if (IsNextFragment((CONST CHAR16**)(&StatementWalker), L"eq")) {\r
     } else if (IsNextFragment((CONST CHAR16**)(&StatementWalker), L"eq")) {\r
-      BinOp = OPERATOR_EQ;\r
+      BinOp = OperatorEqual;\r
     } else if (IsNextFragment((CONST CHAR16**)(&StatementWalker), L"ne")) {\r
     } else if (IsNextFragment((CONST CHAR16**)(&StatementWalker), L"ne")) {\r
-      BinOp = OPERATOR_NE;\r
+      BinOp = OperatorNotEqual;\r
     } else if (IsNextFragment((CONST CHAR16**)(&StatementWalker), L"ge")) {\r
     } else if (IsNextFragment((CONST CHAR16**)(&StatementWalker), L"ge")) {\r
-      BinOp = OPERATOR_GE;\r
+      BinOp = OperatorGreatorOrEqual;\r
     } else if (IsNextFragment((CONST CHAR16**)(&StatementWalker), L"le")) {\r
     } else if (IsNextFragment((CONST CHAR16**)(&StatementWalker), L"le")) {\r
-      BinOp = OPERATOR_LE;\r
+      BinOp = OperatorLessOrEqual;\r
     } else if (IsNextFragment((CONST CHAR16**)(&StatementWalker), L"==")) {\r
     } else if (IsNextFragment((CONST CHAR16**)(&StatementWalker), L"==")) {\r
-      BinOp = OPERATOR_EQ;\r
+      BinOp = OperatorEqual;\r
     } else if (IsNextFragment((CONST CHAR16**)(&StatementWalker), L"ugt")) {\r
     } else if (IsNextFragment((CONST CHAR16**)(&StatementWalker), L"ugt")) {\r
-      BinOp = OPERATOR_UGT;\r
+      BinOp = OperatorUnisgnedGreaterThan;\r
     } else if (IsNextFragment((CONST CHAR16**)(&StatementWalker), L"ult")) {\r
     } else if (IsNextFragment((CONST CHAR16**)(&StatementWalker), L"ult")) {\r
-      BinOp = OPERATOR_ULT;\r
+      BinOp = OperatorUnsignedLessThan;\r
     } else if (IsNextFragment((CONST CHAR16**)(&StatementWalker), L"uge")) {\r
     } else if (IsNextFragment((CONST CHAR16**)(&StatementWalker), L"uge")) {\r
-      BinOp = OPERATOR_UGE;\r
+      BinOp = OperatorUnsignedGreaterOrEqual;\r
     } else if (IsNextFragment((CONST CHAR16**)(&StatementWalker), L"ule")) {\r
     } else if (IsNextFragment((CONST CHAR16**)(&StatementWalker), L"ule")) {\r
-      BinOp = OPERATOR_ULE;\r
+      BinOp = OperatorUnsignedLessOrEqual;\r
     } else {\r
       ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_INVALID_BINOP), gShellLevel1HiiHandle, StatementWalker);\r
       Status = EFI_INVALID_PARAMETER;\r
     } else {\r
       ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_INVALID_BINOP), gShellLevel1HiiHandle, StatementWalker);\r
       Status = EFI_INVALID_PARAMETER;\r
@@ -566,7 +607,7 @@ ProcessStatement (
       Compare2 = StrnCatGrow(&Compare2, NULL, StatementWalker, 0);\r
     }\r
 \r
       Compare2 = StrnCatGrow(&Compare2, NULL, StatementWalker, 0);\r
     }\r
 \r
-    if (Compare1 != NULL && Compare2 != NULL && BinOp != OPERATOR_MAX) {\r
+    if (Compare1 != NULL && Compare2 != NULL && BinOp != OperatorMax) {\r
       OperationResult = TestOperation(Compare1, Compare2, BinOp, CaseInsensitive, ForceStringCompare);\r
     }\r
 \r
       OperationResult = TestOperation(Compare1, Compare2, BinOp, CaseInsensitive, ForceStringCompare);\r
     }\r
 \r
@@ -583,13 +624,13 @@ ProcessStatement (
       OperationResult = (BOOLEAN)(!OperationResult);\r
     }\r
     switch(OperatorToUse) {\r
       OperationResult = (BOOLEAN)(!OperationResult);\r
     }\r
     switch(OperatorToUse) {\r
-      case END_TAG_OR:\r
+      case EndTagOr:\r
         *PassingState = (BOOLEAN)(*PassingState || OperationResult);\r
         break;\r
         *PassingState = (BOOLEAN)(*PassingState || OperationResult);\r
         break;\r
-      case END_TAG_AND:\r
+      case EndTagAnd:\r
         *PassingState = (BOOLEAN)(*PassingState && OperationResult);\r
         break;\r
         *PassingState = (BOOLEAN)(*PassingState && OperationResult);\r
         break;\r
-      case END_TAG_MAX:\r
+      case EndTagMax:\r
         *PassingState = (BOOLEAN)(OperationResult);\r
         break;\r
       default:\r
         *PassingState = (BOOLEAN)(OperationResult);\r
         break;\r
       default:\r
@@ -599,6 +640,18 @@ ProcessStatement (
   return (Status);\r
 }\r
 \r
   return (Status);\r
 }\r
 \r
+/**\r
+  Break up the next part of the if statement (until the next 'and', 'or', or 'then').\r
+\r
+  @param[in] ParameterNumber      The current parameter number.\r
+  @param[out] EndParameter        Upon successful return, will point to the \r
+                                  parameter to start the next iteration with.\r
+  @param[out] EndTag              Upon successful return, will point to the \r
+                                  type that was found at the end of this statement.\r
+\r
+  @retval TRUE    A valid statement was found.\r
+  @retval FALSE   A valid statement was not found.\r
+**/\r
 BOOLEAN\r
 EFIAPI\r
 BuildNextStatement (\r
 BOOLEAN\r
 EFIAPI\r
 BuildNextStatement (\r
@@ -610,7 +663,7 @@ BuildNextStatement (
   CHAR16    *Buffer;\r
   UINTN     BufferSize;\r
 \r
   CHAR16    *Buffer;\r
   UINTN     BufferSize;\r
 \r
-  *EndTag = END_TAG_MAX;\r
+  *EndTag = EndTagMax;\r
 \r
   for(Buffer = NULL, BufferSize = 0\r
     ; ParameterNumber < gEfiShellParametersProtocol->Argc\r
 \r
   for(Buffer = NULL, BufferSize = 0\r
     ; ParameterNumber < gEfiShellParametersProtocol->Argc\r
@@ -621,30 +674,39 @@ BuildNextStatement (
           gEfiShellParametersProtocol->Argv[ParameterNumber],\r
           L"or") == 0) {\r
       *EndParameter = ParameterNumber - 1;\r
           gEfiShellParametersProtocol->Argv[ParameterNumber],\r
           L"or") == 0) {\r
       *EndParameter = ParameterNumber - 1;\r
-      *EndTag = END_TAG_OR;\r
+      *EndTag = EndTagOr;\r
       break;\r
     } else if (gUnicodeCollation->StriColl(\r
           gUnicodeCollation,\r
           gEfiShellParametersProtocol->Argv[ParameterNumber],\r
           L"and") == 0) {\r
       *EndParameter = ParameterNumber - 1;\r
       break;\r
     } else if (gUnicodeCollation->StriColl(\r
           gUnicodeCollation,\r
           gEfiShellParametersProtocol->Argv[ParameterNumber],\r
           L"and") == 0) {\r
       *EndParameter = ParameterNumber - 1;\r
-      *EndTag = END_TAG_AND;\r
+      *EndTag = EndTagAnd;\r
       break;\r
     } else if (gUnicodeCollation->StriColl(\r
           gUnicodeCollation,\r
           gEfiShellParametersProtocol->Argv[ParameterNumber],\r
           L"then") == 0) {\r
       *EndParameter = ParameterNumber - 1;\r
       break;\r
     } else if (gUnicodeCollation->StriColl(\r
           gUnicodeCollation,\r
           gEfiShellParametersProtocol->Argv[ParameterNumber],\r
           L"then") == 0) {\r
       *EndParameter = ParameterNumber - 1;\r
-      *EndTag = END_TAG_THEN;\r
+      *EndTag = EndTagThen;\r
       break;\r
     }\r
   }\r
       break;\r
     }\r
   }\r
-  if (*EndTag == END_TAG_MAX) {\r
+  if (*EndTag == EndTagMax) {\r
     return (FALSE);\r
   }\r
   return (TRUE);\r
 }\r
 \r
     return (FALSE);\r
   }\r
   return (TRUE);\r
 }\r
 \r
+/**\r
+  Move the script file pointer to a different place in the script file.\r
+  This one is special since it handles the if/else/endif syntax.\r
+\r
+  @param[in] ScriptFile     The script file from GetCurrnetScriptFile().\r
+\r
+  @retval TRUE     The move target was found and the move was successful.\r
+  @retval FALSE    Something went wrong.\r
+**/\r
 BOOLEAN\r
 EFIAPI\r
 MoveToTagSpecial (\r
 BOOLEAN\r
 EFIAPI\r
 MoveToTagSpecial (\r
@@ -721,6 +783,14 @@ MoveToTagSpecial (
   return (Found);\r
 }\r
 \r
   return (Found);\r
 }\r
 \r
+/**\r
+  Deal with the result of the if operation.\r
+\r
+  @param[in] Result     The result of the if.\r
+\r
+  @retval EFI_SUCCESS       The operation was successful.\r
+  @retval EFI_NOT_FOUND     The ending tag could not be found.\r
+**/\r
 EFI_STATUS\r
 EFIAPI\r
 PerformResultOperation (\r
 EFI_STATUS\r
 EFIAPI\r
 PerformResultOperation (\r
@@ -822,7 +892,7 @@ ShellCommandRunIf (
     ForceString     = FALSE;\r
   }\r
 \r
     ForceString     = FALSE;\r
   }\r
 \r
-  for ( ShellStatus = SHELL_SUCCESS, CurrentValue = FALSE, Ending = END_TAG_MAX\r
+  for ( ShellStatus = SHELL_SUCCESS, CurrentValue = FALSE, Ending = EndTagMax\r
       ; CurrentParameter < gEfiShellParametersProtocol->Argc && ShellStatus == SHELL_SUCCESS\r
       ; CurrentParameter++) {\r
     if (gUnicodeCollation->StriColl(\r
       ; CurrentParameter < gEfiShellParametersProtocol->Argc && ShellStatus == SHELL_SUCCESS\r
       ; CurrentParameter++) {\r
     if (gUnicodeCollation->StriColl(\r
@@ -862,7 +932,7 @@ ShellCommandRunIf (
           //\r
           // Optomize to get out of the loop early...\r
           //\r
           //\r
           // Optomize to get out of the loop early...\r
           //\r
-          if ((Ending == END_TAG_OR && CurrentValue) || (Ending == END_TAG_AND && !CurrentValue)) {\r
+          if ((Ending == EndTagOr && CurrentValue) || (Ending == EndTagAnd && !CurrentValue)) {\r
             Status = PerformResultOperation(CurrentValue);\r
             if (EFI_ERROR(Status)) {\r
               ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_SYNTAX_AFTER_BAD), gShellLevel1HiiHandle, gEfiShellParametersProtocol->Argv[CurrentParameter]);\r
             Status = PerformResultOperation(CurrentValue);\r
             if (EFI_ERROR(Status)) {\r
               ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_SYNTAX_AFTER_BAD), gShellLevel1HiiHandle, gEfiShellParametersProtocol->Argv[CurrentParameter]);\r
@@ -877,7 +947,7 @@ ShellCommandRunIf (
         //\r
         // Skip over the or or and parameter.\r
         //\r
         //\r
         // Skip over the or or and parameter.\r
         //\r
-        if (Ending == END_TAG_OR || Ending == END_TAG_AND) {\r
+        if (Ending == EndTagOr || Ending == EndTagAnd) {\r
           CurrentParameter++;\r
         }\r
       }\r
           CurrentParameter++;\r
         }\r
       }\r
diff --git a/ShellPkg/Library/UefiShellLevel1CommandsLib/Stall.c b/ShellPkg/Library/UefiShellLevel1CommandsLib/Stall.c
new file mode 100644 (file)
index 0000000..2270323
--- /dev/null
@@ -0,0 +1,83 @@
+/** @file\r
+  Main file for stall shell level 1 function.\r
+\r
+  Copyright (c) 2011, Intel Corporation. All rights reserved.<BR>\r
+  This program and the accompanying materials\r
+  are licensed and made available under the terms and conditions of the BSD License\r
+  which accompanies this distribution.  The full text of the license may be found at\r
+  http://opensource.org/licenses/bsd-license.php\r
+\r
+  THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
+  WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
+\r
+**/\r
+\r
+#include "UefiShellLevel1CommandsLib.h"\r
+\r
+/**\r
+  Function for 'stall' command.\r
+\r
+  @param[in] ImageHandle  Handle to the Image (NULL if Internal).\r
+  @param[in] SystemTable  Pointer to the System Table (NULL if Internal).\r
+**/\r
+SHELL_STATUS\r
+EFIAPI\r
+ShellCommandRunStall (\r
+  IN EFI_HANDLE        ImageHandle,\r
+  IN EFI_SYSTEM_TABLE  *SystemTable\r
+  )\r
+{\r
+  EFI_STATUS          Status;\r
+  LIST_ENTRY          *Package;\r
+  CHAR16              *ProblemParam;\r
+  SHELL_STATUS        ShellStatus;\r
+  UINT64              Intermediate;\r
+\r
+  ShellStatus         = SHELL_SUCCESS;\r
+\r
+  //\r
+  // initialize the shell lib (we must be in non-auto-init...)\r
+  //\r
+  Status = ShellInitialize();\r
+  ASSERT_EFI_ERROR(Status);\r
+\r
+  Status = CommandInit();\r
+  ASSERT_EFI_ERROR(Status);\r
+\r
+  //\r
+  // parse the command line\r
+  //\r
+  Status = ShellCommandLineParse (EmptyParamList, &Package, &ProblemParam, TRUE);\r
+  if (EFI_ERROR(Status)) {\r
+    if (Status == EFI_VOLUME_CORRUPTED && ProblemParam != NULL) {\r
+      ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_PROBLEM), gShellLevel1HiiHandle, ProblemParam);\r
+      FreePool(ProblemParam);\r
+      ShellStatus = SHELL_INVALID_PARAMETER;\r
+    } else {\r
+      ASSERT(FALSE);\r
+    }\r
+  } else {\r
+    if (ShellCommandLineGetRawValue(Package, 2) != NULL) {\r
+      ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_TOO_MANY), gShellLevel1HiiHandle);\r
+      ShellStatus = SHELL_INVALID_PARAMETER;\r
+    } else if (ShellCommandLineGetRawValue(Package, 1) == NULL) {\r
+      ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_TOO_FEW), gShellLevel1HiiHandle);\r
+      ShellStatus = SHELL_INVALID_PARAMETER;\r
+    } else {\r
+      Status = ShellConvertStringToUint64(ShellCommandLineGetRawValue(Package, 1), &Intermediate, FALSE, FALSE);\r
+      if (EFI_ERROR(Status) || ((UINT64)(UINTN)(Intermediate)) != Intermediate) {\r
+        ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_PROBLEM_VAL), gShellLevel1HiiHandle, ShellCommandLineGetRawValue(Package, 1));\r
+        ShellStatus = SHELL_INVALID_PARAMETER;\r
+      } else {\r
+        Status = gBS->Stall((UINTN)Intermediate);\r
+        if (EFI_ERROR(Status)) {\r
+          ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_STALL_FAILED), gShellLevel1HiiHandle, Status);\r
+          ShellStatus = SHELL_DEVICE_ERROR;\r
+        }\r
+      }\r
+    }\r
+    ShellCommandLineFreeVarList (Package);\r
+  }\r
+  return (ShellStatus);\r
+}\r
+\r
index 47b6f92864931931b95ba423cb3cd6c5cb4e801e..bae834f1646fa0639a0683dfad6961410c86739b 100644 (file)
@@ -1,7 +1,7 @@
 /** @file\r
   Main file for NULL named library for level 1 shell command functions.\r
 \r
 /** @file\r
   Main file for NULL named library for level 1 shell command functions.\r
 \r
-  Copyright (c) 2009 - 2010, Intel Corporation. All rights reserved.<BR>\r
+  Copyright (c) 2009 - 2011, Intel Corporation. All rights reserved.<BR>\r
   This program and the accompanying materials\r
   are licensed and made available under the terms and conditions of the BSD License\r
   which accompanies this distribution.  The full text of the license may be found at\r
   This program and the accompanying materials\r
   are licensed and made available under the terms and conditions of the BSD License\r
   which accompanies this distribution.  The full text of the license may be found at\r
@@ -22,6 +22,11 @@ CONST EFI_GUID gShellLevel1HiiGuid = \
   };\r
 \r
 \r
   };\r
 \r
 \r
+/**\r
+  Return the help text filename.  Only used if no HII information found.\r
+\r
+  @retval the filename.\r
+**/\r
 CONST CHAR16*\r
 EFIAPI\r
 ShellCommandGetManFileNameLevel1 (\r
 CONST CHAR16*\r
 EFIAPI\r
 ShellCommandGetManFileNameLevel1 (\r
@@ -64,6 +69,7 @@ ShellLevel1CommandsLibConstructor (
   //\r
   // install our shell command handlers that are always installed\r
   //\r
   //\r
   // install our shell command handlers that are always installed\r
   //\r
+  ShellCommandRegisterCommandName(L"stall",  ShellCommandRunStall   , ShellCommandGetManFileNameLevel1, 1, L"", FALSE, gShellLevel1HiiHandle, (EFI_STRING_ID)(PcdGet8(PcdShellSupportLevel) < 3 ? 0 : STRING_TOKEN(STR_GET_HELP_STALL) ));\r
   ShellCommandRegisterCommandName(L"for",    ShellCommandRunFor     , ShellCommandGetManFileNameLevel1, 1, L"", FALSE, gShellLevel1HiiHandle, (EFI_STRING_ID)(PcdGet8(PcdShellSupportLevel) < 3 ? 0 : STRING_TOKEN(STR_GET_HELP_FOR)   ));\r
   ShellCommandRegisterCommandName(L"goto",   ShellCommandRunGoto    , ShellCommandGetManFileNameLevel1, 1, L"", FALSE, gShellLevel1HiiHandle, (EFI_STRING_ID)(PcdGet8(PcdShellSupportLevel) < 3 ? 0 : STRING_TOKEN(STR_GET_HELP_GOTO)  ));\r
   ShellCommandRegisterCommandName(L"if",     ShellCommandRunIf      , ShellCommandGetManFileNameLevel1, 1, L"", FALSE, gShellLevel1HiiHandle, (EFI_STRING_ID)(PcdGet8(PcdShellSupportLevel) < 3 ? 0 : STRING_TOKEN(STR_GET_HELP_IF)    ));\r
   ShellCommandRegisterCommandName(L"for",    ShellCommandRunFor     , ShellCommandGetManFileNameLevel1, 1, L"", FALSE, gShellLevel1HiiHandle, (EFI_STRING_ID)(PcdGet8(PcdShellSupportLevel) < 3 ? 0 : STRING_TOKEN(STR_GET_HELP_FOR)   ));\r
   ShellCommandRegisterCommandName(L"goto",   ShellCommandRunGoto    , ShellCommandGetManFileNameLevel1, 1, L"", FALSE, gShellLevel1HiiHandle, (EFI_STRING_ID)(PcdGet8(PcdShellSupportLevel) < 3 ? 0 : STRING_TOKEN(STR_GET_HELP_GOTO)  ));\r
   ShellCommandRegisterCommandName(L"if",     ShellCommandRunIf      , ShellCommandGetManFileNameLevel1, 1, L"", FALSE, gShellLevel1HiiHandle, (EFI_STRING_ID)(PcdGet8(PcdShellSupportLevel) < 3 ? 0 : STRING_TOKEN(STR_GET_HELP_IF)    ));\r
@@ -78,6 +84,9 @@ ShellLevel1CommandsLibConstructor (
 \r
 /**\r
   Destructor for the library.  free any resources.\r
 \r
 /**\r
   Destructor for the library.  free any resources.\r
+\r
+  @param ImageHandle            The image handle of the process.\r
+  @param SystemTable            The EFI System Table pointer.\r
 **/\r
 EFI_STATUS\r
 EFIAPI\r
 **/\r
 EFI_STATUS\r
 EFIAPI\r
@@ -92,6 +101,29 @@ ShellLevel1CommandsLibDestructor (
   return (EFI_SUCCESS);\r
 }\r
 \r
   return (EFI_SUCCESS);\r
 }\r
 \r
+/**\r
+  Test a node to see if meets the criterion.\r
+\r
+  It functions so that count starts at 1 and it increases or decreases when it\r
+  hits the specified tags.  when it hits zero the location has been found.\r
+\r
+  DecrementerTag and IncrementerTag are used to get around for/endfor and \r
+  similar paired types where the entire middle should be ignored.\r
+\r
+  If label is used it will be used instead of the count.\r
+\r
+  @param[in] Function         The function to use to enumerate through the \r
+                              list.  Normally GetNextNode or GetPreviousNode.\r
+  @param[in] DecrementerTag   The tag to decrement the count at.\r
+  @param[in] IncrementerTag   The tag to increment the count at.\r
+  @param[in] Label            A label to look for.\r
+  @param[in,out] ScriptFile   The pointer to the current script file structure.\r
+  @param[in] MovePast         TRUE makes function return 1 past the found \r
+                              location.\r
+  @param[in] FindOnly         TRUE to not change the ScriptFile.\r
+  @param[in] CommandNode      The pointer to the Node to test.\r
+  @param[in,out] TargetCount  The pointer to the current count.\r
+**/\r
 BOOLEAN\r
 EFIAPI\r
 TestNodeForMove (\r
 BOOLEAN\r
 EFIAPI\r
 TestNodeForMove (\r
@@ -99,11 +131,11 @@ TestNodeForMove (
   IN CONST CHAR16               *DecrementerTag,\r
   IN CONST CHAR16               *IncrementerTag,\r
   IN CONST CHAR16               *Label OPTIONAL,\r
   IN CONST CHAR16               *DecrementerTag,\r
   IN CONST CHAR16               *IncrementerTag,\r
   IN CONST CHAR16               *Label OPTIONAL,\r
-  IN SCRIPT_FILE                *ScriptFile,\r
+  IN OUT SCRIPT_FILE            *ScriptFile,\r
   IN CONST BOOLEAN              MovePast,\r
   IN CONST BOOLEAN              FindOnly,\r
   IN CONST SCRIPT_COMMAND_LIST  *CommandNode,\r
   IN CONST BOOLEAN              MovePast,\r
   IN CONST BOOLEAN              FindOnly,\r
   IN CONST SCRIPT_COMMAND_LIST  *CommandNode,\r
-  IN UINTN                      *TargetCount\r
+  IN OUT UINTN                  *TargetCount\r
   )\r
 {\r
   BOOLEAN             Found;\r
   )\r
 {\r
   BOOLEAN             Found;\r
@@ -186,6 +218,29 @@ TestNodeForMove (
   return (Found);\r
 }\r
 \r
   return (Found);\r
 }\r
 \r
+/**\r
+  Move the script pointer from 1 tag (line) to another.\r
+\r
+  It functions so that count starts at 1 and it increases or decreases when it\r
+  hits the specified tags.  when it hits zero the location has been found.\r
+\r
+  DecrementerTag and IncrementerTag are used to get around for/endfor and \r
+  similar paired types where the entire middle should be ignored.\r
+\r
+  If label is used it will be used instead of the count.\r
+\r
+  @param[in] Function         The function to use to enumerate through the \r
+                              list.  Normally GetNextNode or GetPreviousNode.\r
+  @param[in] DecrementerTag   The tag to decrement the count at.\r
+  @param[in] IncrementerTag   The tag to increment the count at.\r
+  @param[in] Label            A label to look for.\r
+  @param[in,out] ScriptFile   The pointer to the current script file structure.\r
+  @param[in] MovePast         TRUE makes function return 1 past the found \r
+                              location.\r
+  @param[in] FindOnly         TRUE to not change the ScriptFile.\r
+  @param[in] WrapAroundScript TRUE to wrap end-to-begining or vise versa in \r
+                              searching.\r
+**/\r
 BOOLEAN\r
 EFIAPI\r
 MoveToTag (\r
 BOOLEAN\r
 EFIAPI\r
 MoveToTag (\r
@@ -193,7 +248,7 @@ MoveToTag (
   IN CONST CHAR16               *DecrementerTag,\r
   IN CONST CHAR16               *IncrementerTag,\r
   IN CONST CHAR16               *Label OPTIONAL,\r
   IN CONST CHAR16               *DecrementerTag,\r
   IN CONST CHAR16               *IncrementerTag,\r
   IN CONST CHAR16               *Label OPTIONAL,\r
-  IN SCRIPT_FILE                *ScriptFile,\r
+  IN OUT SCRIPT_FILE            *ScriptFile,\r
   IN CONST BOOLEAN              MovePast,\r
   IN CONST BOOLEAN              FindOnly,\r
   IN CONST BOOLEAN              WrapAroundScript\r
   IN CONST BOOLEAN              MovePast,\r
   IN CONST BOOLEAN              FindOnly,\r
   IN CONST BOOLEAN              WrapAroundScript\r
index b0aa51bc1b3e034665a111972319214c6af894fb..eadb501e2003e8f82ecbedf803a88503d3e8c449 100644 (file)
@@ -1,7 +1,7 @@
 /** @file\r
   Main file for NULL named library for level 1 shell command functions.\r
 \r
 /** @file\r
   Main file for NULL named library for level 1 shell command functions.\r
 \r
-  Copyright (c) 2009 - 2010, Intel Corporation. All rights reserved.<BR>\r
+  Copyright (c) 2009 - 2011, Intel Corporation. All rights reserved.<BR>\r
   This program and the accompanying materials\r
   are licensed and made available under the terms and conditions of the BSD License\r
   which accompanies this distribution.  The full text of the license may be found at\r
   This program and the accompanying materials\r
   are licensed and made available under the terms and conditions of the BSD License\r
   which accompanies this distribution.  The full text of the license may be found at\r
@@ -12,6 +12,9 @@
 \r
 **/\r
 \r
 \r
 **/\r
 \r
+#if !defined (_UEFI_SHELL_LEVEL1_COMMANDS_LIB_H_)\r
+#define _UEFI_SHELL_LEVEL1_COMMANDS_LIB_H_\r
+\r
 #include <Uefi.h>\r
 #include <ShellBase.h>\r
 \r
 #include <Uefi.h>\r
 #include <ShellBase.h>\r
 \r
 extern        EFI_HANDLE                        gShellLevel1HiiHandle;\r
 extern CONST  EFI_GUID                          gShellLevel1HiiGuid;\r
 \r
 extern        EFI_HANDLE                        gShellLevel1HiiHandle;\r
 extern CONST  EFI_GUID                          gShellLevel1HiiGuid;\r
 \r
+/**\r
+  Function for 'stall' command.\r
+\r
+  @param[in] ImageHandle  Handle to the Image (NULL if Internal).\r
+  @param[in] SystemTable  Pointer to the System Table (NULL if Internal).\r
+**/\r
+SHELL_STATUS\r
+EFIAPI\r
+ShellCommandRunStall (\r
+  IN EFI_HANDLE        ImageHandle,\r
+  IN EFI_SYSTEM_TABLE  *SystemTable\r
+  );\r
+\r
 /**\r
   Function for 'exit' command.\r
 \r
 /**\r
   Function for 'exit' command.\r
 \r
@@ -156,16 +172,27 @@ LIST_ENTRY *
   );\r
 \r
 /**\r
   );\r
 \r
 /**\r
-  Function to move to a spacified tag in a script file structure.\r
-\r
-  @param[in] Function       The pointer to the function to move with.\r
-  @param[in] DecrementerTag The pointer to a string to decrement upon finding.\r
-  @param[in] IncrementerTag The pointer to a string to increment upon finding.\r
-  @param[in] Label          A Label to look for.\r
-  @param[in] ScriptFile     The script file structure to look in.\r
-  @param[in] MovePast       TRUE to go to the element just after the found one.  FALSE otherwise.\r
-  @param[in] FindOnly       FALSE to change the execution point in the script file structure.   TRUE otherwise.\r
-  @param[in] WrapAroundScript  TRUE to go to begining when end is hit, or vise versa.  FALSE otherwise.\r
+  Move the script pointer from 1 tag (line) to another.\r
+\r
+  It functions so that count starts at 1 and it increases or decreases when it\r
+  hits the specified tags.  when it hits zero the location has been found.\r
+\r
+  DecrementerTag and IncrementerTag are used to get around for/endfor and \r
+  similar paired types where the entire middle should be ignored.\r
+\r
+  If label is used it will be used instead of the count.\r
+\r
+  @param[in] Function         The function to use to enumerate through the \r
+                              list.  Normally GetNextNode or GetPreviousNode.\r
+  @param[in] DecrementerTag   The tag to decrement the count at.\r
+  @param[in] IncrementerTag   The tag to increment the count at.\r
+  @param[in] Label            A label to look for.\r
+  @param[in,out] ScriptFile   The pointer to the current script file structure.\r
+  @param[in] MovePast         TRUE makes function return 1 past the found \r
+                              location.\r
+  @param[in] FindOnly         TRUE to not change the ScriptFile.\r
+  @param[in] WrapAroundScript TRUE to wrap end-to-begining or vise versa in \r
+                              searching.\r
 **/\r
 BOOLEAN\r
 EFIAPI\r
 **/\r
 BOOLEAN\r
 EFIAPI\r
@@ -174,9 +201,11 @@ MoveToTag (
   IN CONST CHAR16               *DecrementerTag,\r
   IN CONST CHAR16               *IncrementerTag,\r
   IN CONST CHAR16               *Label OPTIONAL,\r
   IN CONST CHAR16               *DecrementerTag,\r
   IN CONST CHAR16               *IncrementerTag,\r
   IN CONST CHAR16               *Label OPTIONAL,\r
-  IN SCRIPT_FILE                *ScriptFile,\r
+  IN OUT SCRIPT_FILE            *ScriptFile,\r
   IN CONST BOOLEAN              MovePast,\r
   IN CONST BOOLEAN              FindOnly,\r
   IN CONST BOOLEAN              WrapAroundScript\r
   );\r
 \r
   IN CONST BOOLEAN              MovePast,\r
   IN CONST BOOLEAN              FindOnly,\r
   IN CONST BOOLEAN              WrapAroundScript\r
   );\r
 \r
+#endif\r
+\r
index b4697f390813fc9645f11bb551f55d68c3c569f8..8b04b7d369eff111529763084f0c3574cd01de35 100644 (file)
@@ -1,7 +1,7 @@
 ##  @file\r
 #  Provides shell level 1 functions\r
 #\r
 ##  @file\r
 #  Provides shell level 1 functions\r
 #\r
-#  Copyright (c) 2009-2010, Intel Corporation. All rights reserved. <BR>\r
+#  Copyright (c) 2009-2011, Intel Corporation. All rights reserved. <BR>\r
 #\r
 #  This program and the accompanying materials\r
 #  are licensed and made available under the terms and conditions of the BSD License\r
 #\r
 #  This program and the accompanying materials\r
 #  are licensed and made available under the terms and conditions of the BSD License\r
@@ -31,6 +31,7 @@
   If.c\r
   For.c\r
   Shift.c\r
   If.c\r
   For.c\r
   Shift.c\r
+  Stall.c\r
 \r
 [Packages]\r
   MdePkg/MdePkg.dec\r
 \r
 [Packages]\r
   MdePkg/MdePkg.dec\r
index 47e44ca7b386b212f46204969e51f2be440660a1..56bfaea92d4d54e35cd01b79e1981ac77bf3856f 100644 (file)
Binary files a/ShellPkg/Library/UefiShellLevel1CommandsLib/UefiShellLevel1CommandsLib.uni and b/ShellPkg/Library/UefiShellLevel1CommandsLib/UefiShellLevel1CommandsLib.uni differ