]>
Commit | Line | Data |
---|---|---|
5d73d92f | 1 | /** @file\r |
2 | Main file for Mode shell Debug1 function.\r | |
3 | \r | |
c011b6c9 | 4 | (C) Copyright 2015 Hewlett-Packard Development Company, L.P.<BR>\r |
d0cec2da LG |
5 | Copyright (c) 2010 - 2013, Intel Corporation. All rights reserved.<BR>\r |
6 | This program and the accompanying materials\r | |
5d73d92f | 7 | are licensed and made available under the terms and conditions of the BSD License\r |
8 | which acModeanies this distribution. The full text of the license may be found at\r | |
9 | http://opensource.org/licenses/bsd-license.php\r | |
10 | \r | |
11 | THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r | |
12 | WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r | |
13 | \r | |
14 | **/\r | |
15 | \r | |
16 | #include "UefiShellDebug1CommandsLib.h"\r | |
17 | \r | |
3737ac2b | 18 | /**\r |
19 | Function for 'mode' command.\r | |
20 | \r | |
21 | @param[in] ImageHandle Handle to the Image (NULL if Internal).\r | |
22 | @param[in] SystemTable Pointer to the System Table (NULL if Internal).\r | |
23 | **/\r | |
5d73d92f | 24 | SHELL_STATUS\r |
25 | EFIAPI\r | |
26 | ShellCommandRunMode (\r | |
27 | IN EFI_HANDLE ImageHandle,\r | |
28 | IN EFI_SYSTEM_TABLE *SystemTable\r | |
29 | )\r | |
30 | {\r | |
31 | EFI_STATUS Status;\r | |
32 | LIST_ENTRY *Package;\r | |
33 | CHAR16 *ProblemParam;\r | |
34 | SHELL_STATUS ShellStatus;\r | |
35 | UINTN NewCol;\r | |
36 | UINTN NewRow;\r | |
37 | UINTN Col;\r | |
38 | UINTN Row;\r | |
39 | CONST CHAR16 *Temp;\r | |
40 | BOOLEAN Done;\r | |
41 | INT32 LoopVar;\r | |
42 | \r | |
43 | ShellStatus = SHELL_SUCCESS;\r | |
44 | Status = EFI_SUCCESS;\r | |
45 | \r | |
46 | //\r | |
47 | // initialize the shell lib (we must be in non-auto-init...)\r | |
48 | //\r | |
49 | Status = ShellInitialize();\r | |
50 | ASSERT_EFI_ERROR(Status);\r | |
51 | \r | |
52 | Status = CommandInit();\r | |
53 | ASSERT_EFI_ERROR(Status);\r | |
54 | \r | |
55 | //\r | |
56 | // parse the command line\r | |
57 | //\r | |
58 | Status = ShellCommandLineParse (EmptyParamList, &Package, &ProblemParam, TRUE);\r | |
59 | if (EFI_ERROR(Status)) {\r | |
60 | if (Status == EFI_VOLUME_CORRUPTED && ProblemParam != NULL) {\r | |
4092a8f6 | 61 | ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_PROBLEM), gShellDebug1HiiHandle, L"mode", ProblemParam); \r |
5d73d92f | 62 | FreePool(ProblemParam);\r |
63 | ShellStatus = SHELL_INVALID_PARAMETER;\r | |
64 | } else {\r | |
65 | ASSERT(FALSE);\r | |
66 | }\r | |
67 | } else {\r | |
68 | if (ShellCommandLineGetCount(Package) > 3) {\r | |
4092a8f6 | 69 | ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_TOO_MANY), gShellDebug1HiiHandle, L"mode"); \r |
5d73d92f | 70 | ShellStatus = SHELL_INVALID_PARAMETER;\r |
71 | } else if (ShellCommandLineGetCount(Package) == 2) {\r | |
4092a8f6 | 72 | ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_TOO_FEW), gShellDebug1HiiHandle, L"mode"); \r |
5d73d92f | 73 | ShellStatus = SHELL_INVALID_PARAMETER;\r |
74 | } else if (ShellCommandLineGetCount(Package) == 3) {\r | |
75 | Temp = ShellCommandLineGetRawValue(Package, 1);\r | |
76 | if (!ShellIsHexOrDecimalNumber(Temp, FALSE, FALSE)) {\r | |
4092a8f6 | 77 | ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_PARAM_INV), gShellDebug1HiiHandle, L"mode", Temp); \r |
5d73d92f | 78 | ShellStatus = SHELL_INVALID_PARAMETER;\r |
79 | }\r | |
80 | NewCol = ShellStrToUintn(Temp);\r | |
81 | Temp = ShellCommandLineGetRawValue(Package, 2);\r | |
82 | if (!ShellIsHexOrDecimalNumber(Temp, FALSE, FALSE)) {\r | |
4092a8f6 | 83 | ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_PARAM_INV), gShellDebug1HiiHandle, L"mode", Temp); \r |
5d73d92f | 84 | ShellStatus = SHELL_INVALID_PARAMETER;\r |
85 | }\r | |
86 | NewRow = ShellStrToUintn(Temp);\r | |
87 | \r | |
88 | for (LoopVar = 0, Done = FALSE; LoopVar < gST->ConOut->Mode->MaxMode && ShellStatus == SHELL_SUCCESS ; LoopVar++) {\r | |
89 | Status = gST->ConOut->QueryMode(gST->ConOut, LoopVar, &Col, &Row);\r | |
90 | if (EFI_ERROR(Status)) {\r | |
91 | continue;\r | |
92 | }\r | |
93 | if (Col == NewCol && Row == NewRow) {\r | |
94 | Status = gST->ConOut->SetMode(gST->ConOut, LoopVar);\r | |
95 | if (EFI_ERROR(Status)) {\r | |
4092a8f6 | 96 | ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_MODE_SET_FAIL), gShellDebug1HiiHandle, L"mode"); \r |
5d73d92f | 97 | ShellStatus = SHELL_DEVICE_ERROR;\r |
98 | } else {\r | |
99 | // worked fine...\r | |
100 | Done = TRUE;\r | |
101 | }\r | |
102 | break;\r | |
103 | }\r | |
104 | }\r | |
105 | \r | |
106 | if (!Done) {\r | |
4092a8f6 | 107 | ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_MODE_NO_MATCH), gShellDebug1HiiHandle, L"mode"); \r |
5d73d92f | 108 | ShellStatus = SHELL_INVALID_PARAMETER;\r |
109 | }\r | |
110 | \r | |
111 | } else if (ShellCommandLineGetCount(Package) == 1) {\r | |
112 | //\r | |
113 | // print out valid\r | |
114 | //\r | |
115 | ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_MODE_LIST_HEAD), gShellDebug1HiiHandle);\r | |
116 | for (LoopVar = 0, Done = FALSE; LoopVar < gST->ConOut->Mode->MaxMode && ShellStatus == SHELL_SUCCESS ; LoopVar++) {\r | |
117 | Status = gST->ConOut->QueryMode(gST->ConOut, LoopVar, &Col, &Row);\r | |
118 | if (EFI_ERROR(Status)) {\r | |
119 | continue;\r | |
120 | }\r | |
121 | ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_MODE_LIST_ITEM), gShellDebug1HiiHandle, Col, Row, LoopVar == gST->ConOut->Mode->Mode?L'*':L' ');\r | |
122 | }\r | |
123 | }\r | |
124 | ShellCommandLineFreeVarList (Package);\r | |
125 | }\r | |
126 | \r | |
127 | return (ShellStatus);\r | |
128 | }\r |