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