--- /dev/null
+/** @file\r
+ Main file for Mode shell Debug1 function.\r
+\r
+ Copyright (c) 2010, Intel Corporation. All rights reserved.<BR>\r
+ This program and the acModeanying materials\r
+ are licensed and made available under the terms and conditions of the BSD License\r
+ which acModeanies 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 "UefiShellDebug1CommandsLib.h"\r
+\r
+SHELL_STATUS\r
+EFIAPI\r
+ShellCommandRunMode (\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
+ UINTN NewCol;\r
+ UINTN NewRow;\r
+ UINTN Col;\r
+ UINTN Row;\r
+ CONST CHAR16 *Temp;\r
+ BOOLEAN Done;\r
+ INT32 LoopVar;\r
+\r
+ ShellStatus = SHELL_SUCCESS;\r
+ Status = EFI_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), gShellDebug1HiiHandle, ProblemParam);\r
+ FreePool(ProblemParam);\r
+ ShellStatus = SHELL_INVALID_PARAMETER;\r
+ } else {\r
+ ASSERT(FALSE);\r
+ }\r
+ } else {\r
+ if (ShellCommandLineGetCount(Package) > 3) {\r
+ ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_TOO_MANY), gShellDebug1HiiHandle);\r
+ ShellStatus = SHELL_INVALID_PARAMETER;\r
+ } else if (ShellCommandLineGetCount(Package) == 2) {\r
+ ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_TOO_FEW), gShellDebug1HiiHandle);\r
+ ShellStatus = SHELL_INVALID_PARAMETER;\r
+ } else if (ShellCommandLineGetCount(Package) == 3) {\r
+ Temp = ShellCommandLineGetRawValue(Package, 1);\r
+ if (!ShellIsHexOrDecimalNumber(Temp, FALSE, FALSE)) {\r
+ ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_PROBLEM), gShellDebug1HiiHandle, Temp);\r
+ ShellStatus = SHELL_INVALID_PARAMETER;\r
+ }\r
+ NewCol = ShellStrToUintn(Temp);\r
+ Temp = ShellCommandLineGetRawValue(Package, 2);\r
+ if (!ShellIsHexOrDecimalNumber(Temp, FALSE, FALSE)) {\r
+ ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_PROBLEM), gShellDebug1HiiHandle, Temp);\r
+ ShellStatus = SHELL_INVALID_PARAMETER;\r
+ }\r
+ NewRow = ShellStrToUintn(Temp);\r
+\r
+ for (LoopVar = 0, Done = FALSE; LoopVar < gST->ConOut->Mode->MaxMode && ShellStatus == SHELL_SUCCESS ; LoopVar++) {\r
+ Status = gST->ConOut->QueryMode(gST->ConOut, LoopVar, &Col, &Row);\r
+ if (EFI_ERROR(Status)) {\r
+ continue;\r
+ }\r
+ if (Col == NewCol && Row == NewRow) {\r
+ Status = gST->ConOut->SetMode(gST->ConOut, LoopVar);\r
+ if (EFI_ERROR(Status)) {\r
+ ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_MODE_SET_FAIL), gShellDebug1HiiHandle, Status);\r
+ ShellStatus = SHELL_DEVICE_ERROR;\r
+ } else {\r
+ // worked fine...\r
+ Done = TRUE;\r
+ }\r
+ break;\r
+ }\r
+ }\r
+\r
+ if (!Done) {\r
+ ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_MODE_NO_MATCH), gShellDebug1HiiHandle);\r
+ ShellStatus = SHELL_INVALID_PARAMETER;\r
+ }\r
+\r
+ } else if (ShellCommandLineGetCount(Package) == 1) {\r
+ //\r
+ // print out valid\r
+ //\r
+ ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_MODE_LIST_HEAD), gShellDebug1HiiHandle);\r
+ for (LoopVar = 0, Done = FALSE; LoopVar < gST->ConOut->Mode->MaxMode && ShellStatus == SHELL_SUCCESS ; LoopVar++) {\r
+ Status = gST->ConOut->QueryMode(gST->ConOut, LoopVar, &Col, &Row);\r
+ if (EFI_ERROR(Status)) {\r
+ continue;\r
+ }\r
+ ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_MODE_LIST_ITEM), gShellDebug1HiiHandle, Col, Row, LoopVar == gST->ConOut->Mode->Mode?L'*':L' ');\r
+ }\r
+ }\r
+ ShellCommandLineFreeVarList (Package);\r
+ }\r
+\r
+ return (ShellStatus);\r
+}\r