2 Main file for Mode shell Debug1 function.
4 Copyright (c) 2010, Intel Corporation. All rights reserved.<BR>
5 This program and the acModeanying materials
6 are licensed and made available under the terms and conditions of the BSD License
7 which acModeanies this distribution. The full text of the license may be found at
8 http://opensource.org/licenses/bsd-license.php
10 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
11 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
15 #include "UefiShellDebug1CommandsLib.h"
20 IN EFI_HANDLE ImageHandle
,
21 IN EFI_SYSTEM_TABLE
*SystemTable
27 SHELL_STATUS ShellStatus
;
36 ShellStatus
= SHELL_SUCCESS
;
40 // initialize the shell lib (we must be in non-auto-init...)
42 Status
= ShellInitialize();
43 ASSERT_EFI_ERROR(Status
);
45 Status
= CommandInit();
46 ASSERT_EFI_ERROR(Status
);
49 // parse the command line
51 Status
= ShellCommandLineParse (EmptyParamList
, &Package
, &ProblemParam
, TRUE
);
52 if (EFI_ERROR(Status
)) {
53 if (Status
== EFI_VOLUME_CORRUPTED
&& ProblemParam
!= NULL
) {
54 ShellPrintHiiEx(-1, -1, NULL
, STRING_TOKEN (STR_GEN_PROBLEM
), gShellDebug1HiiHandle
, ProblemParam
);
55 FreePool(ProblemParam
);
56 ShellStatus
= SHELL_INVALID_PARAMETER
;
61 if (ShellCommandLineGetCount(Package
) > 3) {
62 ShellPrintHiiEx(-1, -1, NULL
, STRING_TOKEN (STR_GEN_TOO_MANY
), gShellDebug1HiiHandle
);
63 ShellStatus
= SHELL_INVALID_PARAMETER
;
64 } else if (ShellCommandLineGetCount(Package
) == 2) {
65 ShellPrintHiiEx(-1, -1, NULL
, STRING_TOKEN (STR_GEN_TOO_FEW
), gShellDebug1HiiHandle
);
66 ShellStatus
= SHELL_INVALID_PARAMETER
;
67 } else if (ShellCommandLineGetCount(Package
) == 3) {
68 Temp
= ShellCommandLineGetRawValue(Package
, 1);
69 if (!ShellIsHexOrDecimalNumber(Temp
, FALSE
, FALSE
)) {
70 ShellPrintHiiEx(-1, -1, NULL
, STRING_TOKEN (STR_GEN_PROBLEM
), gShellDebug1HiiHandle
, Temp
);
71 ShellStatus
= SHELL_INVALID_PARAMETER
;
73 NewCol
= ShellStrToUintn(Temp
);
74 Temp
= ShellCommandLineGetRawValue(Package
, 2);
75 if (!ShellIsHexOrDecimalNumber(Temp
, FALSE
, FALSE
)) {
76 ShellPrintHiiEx(-1, -1, NULL
, STRING_TOKEN (STR_GEN_PROBLEM
), gShellDebug1HiiHandle
, Temp
);
77 ShellStatus
= SHELL_INVALID_PARAMETER
;
79 NewRow
= ShellStrToUintn(Temp
);
81 for (LoopVar
= 0, Done
= FALSE
; LoopVar
< gST
->ConOut
->Mode
->MaxMode
&& ShellStatus
== SHELL_SUCCESS
; LoopVar
++) {
82 Status
= gST
->ConOut
->QueryMode(gST
->ConOut
, LoopVar
, &Col
, &Row
);
83 if (EFI_ERROR(Status
)) {
86 if (Col
== NewCol
&& Row
== NewRow
) {
87 Status
= gST
->ConOut
->SetMode(gST
->ConOut
, LoopVar
);
88 if (EFI_ERROR(Status
)) {
89 ShellPrintHiiEx(-1, -1, NULL
, STRING_TOKEN (STR_MODE_SET_FAIL
), gShellDebug1HiiHandle
, Status
);
90 ShellStatus
= SHELL_DEVICE_ERROR
;
100 ShellPrintHiiEx(-1, -1, NULL
, STRING_TOKEN (STR_MODE_NO_MATCH
), gShellDebug1HiiHandle
);
101 ShellStatus
= SHELL_INVALID_PARAMETER
;
104 } else if (ShellCommandLineGetCount(Package
) == 1) {
108 ShellPrintHiiEx(-1, -1, NULL
, STRING_TOKEN (STR_MODE_LIST_HEAD
), gShellDebug1HiiHandle
);
109 for (LoopVar
= 0, Done
= FALSE
; LoopVar
< gST
->ConOut
->Mode
->MaxMode
&& ShellStatus
== SHELL_SUCCESS
; LoopVar
++) {
110 Status
= gST
->ConOut
->QueryMode(gST
->ConOut
, LoopVar
, &Col
, &Row
);
111 if (EFI_ERROR(Status
)) {
114 ShellPrintHiiEx(-1, -1, NULL
, STRING_TOKEN (STR_MODE_LIST_ITEM
), gShellDebug1HiiHandle
, Col
, Row
, LoopVar
== gST
->ConOut
->Mode
->Mode
?L
'*':L
' ');
117 ShellCommandLineFreeVarList (Package
);
120 return (ShellStatus
);