2010-11-16 23:36:37 +01:00
|
|
|
/** @file
|
|
|
|
Main file for Mode shell Debug1 function.
|
|
|
|
|
2015-02-04 23:25:01 +01:00
|
|
|
(C) Copyright 2015 Hewlett-Packard Development Company, L.P.<BR>
|
2018-06-27 15:13:38 +02:00
|
|
|
Copyright (c) 2010 - 2018, Intel Corporation. All rights reserved.<BR>
|
2019-04-04 01:07:06 +02:00
|
|
|
SPDX-License-Identifier: BSD-2-Clause-Patent
|
2010-11-16 23:36:37 +01:00
|
|
|
|
|
|
|
**/
|
|
|
|
|
|
|
|
#include "UefiShellDebug1CommandsLib.h"
|
|
|
|
|
2011-03-25 22:22:20 +01:00
|
|
|
/**
|
|
|
|
Function for 'mode' command.
|
|
|
|
|
|
|
|
@param[in] ImageHandle Handle to the Image (NULL if Internal).
|
|
|
|
@param[in] SystemTable Pointer to the System Table (NULL if Internal).
|
|
|
|
**/
|
2010-11-16 23:36:37 +01:00
|
|
|
SHELL_STATUS
|
|
|
|
EFIAPI
|
|
|
|
ShellCommandRunMode (
|
|
|
|
IN EFI_HANDLE ImageHandle,
|
|
|
|
IN EFI_SYSTEM_TABLE *SystemTable
|
|
|
|
)
|
|
|
|
{
|
2021-12-05 23:54:13 +01:00
|
|
|
EFI_STATUS Status;
|
|
|
|
LIST_ENTRY *Package;
|
|
|
|
CHAR16 *ProblemParam;
|
|
|
|
SHELL_STATUS ShellStatus;
|
|
|
|
UINTN NewCol;
|
|
|
|
UINTN NewRow;
|
|
|
|
UINTN Col;
|
|
|
|
UINTN Row;
|
|
|
|
CONST CHAR16 *Temp;
|
|
|
|
BOOLEAN Done;
|
|
|
|
INT32 LoopVar;
|
|
|
|
|
|
|
|
ShellStatus = SHELL_SUCCESS;
|
|
|
|
Status = EFI_SUCCESS;
|
2010-11-16 23:36:37 +01:00
|
|
|
|
|
|
|
//
|
|
|
|
// initialize the shell lib (we must be in non-auto-init...)
|
|
|
|
//
|
2021-12-05 23:54:13 +01:00
|
|
|
Status = ShellInitialize ();
|
|
|
|
ASSERT_EFI_ERROR (Status);
|
2010-11-16 23:36:37 +01:00
|
|
|
|
2021-12-05 23:54:13 +01:00
|
|
|
Status = CommandInit ();
|
|
|
|
ASSERT_EFI_ERROR (Status);
|
2010-11-16 23:36:37 +01:00
|
|
|
|
|
|
|
//
|
|
|
|
// parse the command line
|
|
|
|
//
|
|
|
|
Status = ShellCommandLineParse (EmptyParamList, &Package, &ProblemParam, TRUE);
|
2021-12-05 23:54:13 +01:00
|
|
|
if (EFI_ERROR (Status)) {
|
|
|
|
if ((Status == EFI_VOLUME_CORRUPTED) && (ProblemParam != NULL)) {
|
|
|
|
ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_GEN_PROBLEM), gShellDebug1HiiHandle, L"mode", ProblemParam);
|
|
|
|
FreePool (ProblemParam);
|
2010-11-16 23:36:37 +01:00
|
|
|
ShellStatus = SHELL_INVALID_PARAMETER;
|
|
|
|
} else {
|
2021-12-05 23:54:13 +01:00
|
|
|
ASSERT (FALSE);
|
2010-11-16 23:36:37 +01:00
|
|
|
}
|
|
|
|
} else {
|
2021-12-05 23:54:13 +01:00
|
|
|
if (ShellCommandLineGetCount (Package) > 3) {
|
|
|
|
ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_GEN_TOO_MANY), gShellDebug1HiiHandle, L"mode");
|
2010-11-16 23:36:37 +01:00
|
|
|
ShellStatus = SHELL_INVALID_PARAMETER;
|
2021-12-05 23:54:13 +01:00
|
|
|
} else if (ShellCommandLineGetCount (Package) == 2) {
|
|
|
|
ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_GEN_TOO_FEW), gShellDebug1HiiHandle, L"mode");
|
2010-11-16 23:36:37 +01:00
|
|
|
ShellStatus = SHELL_INVALID_PARAMETER;
|
2021-12-05 23:54:13 +01:00
|
|
|
} else if (ShellCommandLineGetCount (Package) == 3) {
|
|
|
|
Temp = ShellCommandLineGetRawValue (Package, 1);
|
|
|
|
if (!ShellIsHexOrDecimalNumber (Temp, FALSE, FALSE)) {
|
|
|
|
ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_GEN_PARAM_INV), gShellDebug1HiiHandle, L"mode", Temp);
|
2010-11-16 23:36:37 +01:00
|
|
|
ShellStatus = SHELL_INVALID_PARAMETER;
|
|
|
|
}
|
2021-12-05 23:54:13 +01:00
|
|
|
|
|
|
|
NewCol = ShellStrToUintn (Temp);
|
|
|
|
Temp = ShellCommandLineGetRawValue (Package, 2);
|
|
|
|
if (!ShellIsHexOrDecimalNumber (Temp, FALSE, FALSE)) {
|
|
|
|
ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_GEN_PARAM_INV), gShellDebug1HiiHandle, L"mode", Temp);
|
2010-11-16 23:36:37 +01:00
|
|
|
ShellStatus = SHELL_INVALID_PARAMETER;
|
|
|
|
}
|
|
|
|
|
2021-12-05 23:54:13 +01:00
|
|
|
NewRow = ShellStrToUintn (Temp);
|
|
|
|
|
|
|
|
for (LoopVar = 0, Done = FALSE; LoopVar < gST->ConOut->Mode->MaxMode && ShellStatus == SHELL_SUCCESS; LoopVar++) {
|
|
|
|
Status = gST->ConOut->QueryMode (gST->ConOut, LoopVar, &Col, &Row);
|
|
|
|
if (EFI_ERROR (Status)) {
|
2010-11-16 23:36:37 +01:00
|
|
|
continue;
|
|
|
|
}
|
2021-12-05 23:54:13 +01:00
|
|
|
|
|
|
|
if ((Col == NewCol) && (Row == NewRow)) {
|
|
|
|
Status = gST->ConOut->SetMode (gST->ConOut, LoopVar);
|
|
|
|
if (EFI_ERROR (Status)) {
|
|
|
|
ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_MODE_SET_FAIL), gShellDebug1HiiHandle, L"mode");
|
2010-11-16 23:36:37 +01:00
|
|
|
ShellStatus = SHELL_DEVICE_ERROR;
|
|
|
|
} else {
|
|
|
|
// worked fine...
|
|
|
|
Done = TRUE;
|
|
|
|
}
|
2021-12-05 23:54:13 +01:00
|
|
|
|
2010-11-16 23:36:37 +01:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!Done) {
|
2021-12-05 23:54:13 +01:00
|
|
|
ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_MODE_NO_MATCH), gShellDebug1HiiHandle, L"mode");
|
2010-11-16 23:36:37 +01:00
|
|
|
ShellStatus = SHELL_INVALID_PARAMETER;
|
|
|
|
}
|
2021-12-05 23:54:13 +01:00
|
|
|
} else if (ShellCommandLineGetCount (Package) == 1) {
|
2010-11-16 23:36:37 +01:00
|
|
|
//
|
|
|
|
// print out valid
|
|
|
|
//
|
2021-12-05 23:54:13 +01:00
|
|
|
ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_MODE_LIST_HEAD), gShellDebug1HiiHandle);
|
|
|
|
for (LoopVar = 0, Done = FALSE; LoopVar < gST->ConOut->Mode->MaxMode && ShellStatus == SHELL_SUCCESS; LoopVar++) {
|
|
|
|
Status = gST->ConOut->QueryMode (gST->ConOut, LoopVar, &Col, &Row);
|
|
|
|
if (EFI_ERROR (Status)) {
|
2010-11-16 23:36:37 +01:00
|
|
|
continue;
|
|
|
|
}
|
2021-12-05 23:54:13 +01:00
|
|
|
|
|
|
|
ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_MODE_LIST_ITEM), gShellDebug1HiiHandle, Col, Row, LoopVar == gST->ConOut->Mode->Mode ? L'*' : L' ');
|
2010-11-16 23:36:37 +01:00
|
|
|
}
|
|
|
|
}
|
2021-12-05 23:54:13 +01:00
|
|
|
|
2010-11-16 23:36:37 +01:00
|
|
|
ShellCommandLineFreeVarList (Package);
|
|
|
|
}
|
|
|
|
|
|
|
|
return (ShellStatus);
|
|
|
|
}
|