2 Main file for Mode shell Debug1 function.
4 (C) Copyright 2015 Hewlett-Packard Development Company, L.P.<BR>
5 Copyright (c) 2010 - 2018, Intel Corporation. All rights reserved.<BR>
6 This program and the accompanying materials
7 are licensed and made available under the terms and conditions of the BSD License
8 which acModeanies this distribution. The full text of the license may be found at
9 http://opensource.org/licenses/bsd-license.php
11 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
12 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
16 #include "UefiShellDebug1CommandsLib.h"
19 Function for 'mode' command.
21 @param[in] ImageHandle Handle to the Image (NULL if Internal).
22 @param[in] SystemTable Pointer to the System Table (NULL if Internal).
27 IN EFI_HANDLE ImageHandle
,
28 IN EFI_SYSTEM_TABLE
*SystemTable
34 SHELL_STATUS ShellStatus
;
43 ShellStatus
= SHELL_SUCCESS
;
47 // initialize the shell lib (we must be in non-auto-init...)
49 Status
= ShellInitialize();
50 ASSERT_EFI_ERROR(Status
);
52 Status
= CommandInit();
53 ASSERT_EFI_ERROR(Status
);
56 // parse the command line
58 Status
= ShellCommandLineParse (EmptyParamList
, &Package
, &ProblemParam
, TRUE
);
59 if (EFI_ERROR(Status
)) {
60 if (Status
== EFI_VOLUME_CORRUPTED
&& ProblemParam
!= NULL
) {
61 ShellPrintHiiEx(-1, -1, NULL
, STRING_TOKEN (STR_GEN_PROBLEM
), gShellDebug1HiiHandle
, L
"mode", ProblemParam
);
62 FreePool(ProblemParam
);
63 ShellStatus
= SHELL_INVALID_PARAMETER
;
68 if (ShellCommandLineGetCount(Package
) > 3) {
69 ShellPrintHiiEx(-1, -1, NULL
, STRING_TOKEN (STR_GEN_TOO_MANY
), gShellDebug1HiiHandle
, L
"mode");
70 ShellStatus
= SHELL_INVALID_PARAMETER
;
71 } else if (ShellCommandLineGetCount(Package
) == 2) {
72 ShellPrintHiiEx(-1, -1, NULL
, STRING_TOKEN (STR_GEN_TOO_FEW
), gShellDebug1HiiHandle
, L
"mode");
73 ShellStatus
= SHELL_INVALID_PARAMETER
;
74 } else if (ShellCommandLineGetCount(Package
) == 3) {
75 Temp
= ShellCommandLineGetRawValue(Package
, 1);
76 if (!ShellIsHexOrDecimalNumber(Temp
, FALSE
, FALSE
)) {
77 ShellPrintHiiEx(-1, -1, NULL
, STRING_TOKEN (STR_GEN_PARAM_INV
), gShellDebug1HiiHandle
, L
"mode", Temp
);
78 ShellStatus
= SHELL_INVALID_PARAMETER
;
80 NewCol
= ShellStrToUintn(Temp
);
81 Temp
= ShellCommandLineGetRawValue(Package
, 2);
82 if (!ShellIsHexOrDecimalNumber(Temp
, FALSE
, FALSE
)) {
83 ShellPrintHiiEx(-1, -1, NULL
, STRING_TOKEN (STR_GEN_PARAM_INV
), gShellDebug1HiiHandle
, L
"mode", Temp
);
84 ShellStatus
= SHELL_INVALID_PARAMETER
;
86 NewRow
= ShellStrToUintn(Temp
);
88 for (LoopVar
= 0, Done
= FALSE
; LoopVar
< gST
->ConOut
->Mode
->MaxMode
&& ShellStatus
== SHELL_SUCCESS
; LoopVar
++) {
89 Status
= gST
->ConOut
->QueryMode(gST
->ConOut
, LoopVar
, &Col
, &Row
);
90 if (EFI_ERROR(Status
)) {
93 if (Col
== NewCol
&& Row
== NewRow
) {
94 Status
= gST
->ConOut
->SetMode(gST
->ConOut
, LoopVar
);
95 if (EFI_ERROR(Status
)) {
96 ShellPrintHiiEx(-1, -1, NULL
, STRING_TOKEN (STR_MODE_SET_FAIL
), gShellDebug1HiiHandle
, L
"mode");
97 ShellStatus
= SHELL_DEVICE_ERROR
;
107 ShellPrintHiiEx(-1, -1, NULL
, STRING_TOKEN (STR_MODE_NO_MATCH
), gShellDebug1HiiHandle
, L
"mode");
108 ShellStatus
= SHELL_INVALID_PARAMETER
;
111 } else if (ShellCommandLineGetCount(Package
) == 1) {
115 ShellPrintHiiEx(-1, -1, NULL
, STRING_TOKEN (STR_MODE_LIST_HEAD
), gShellDebug1HiiHandle
);
116 for (LoopVar
= 0, Done
= FALSE
; LoopVar
< gST
->ConOut
->Mode
->MaxMode
&& ShellStatus
== SHELL_SUCCESS
; LoopVar
++) {
117 Status
= gST
->ConOut
->QueryMode(gST
->ConOut
, LoopVar
, &Col
, &Row
);
118 if (EFI_ERROR(Status
)) {
121 ShellPrintHiiEx(-1, -1, NULL
, STRING_TOKEN (STR_MODE_LIST_ITEM
), gShellDebug1HiiHandle
, Col
, Row
, LoopVar
== gST
->ConOut
->Mode
->Mode
?L
'*':L
' ');
124 ShellCommandLineFreeVarList (Package
);
127 return (ShellStatus
);