/** @file\r
Main file for attrib shell level 2 function.\r
\r
- Copyright (c) 2009 - 2010, Intel Corporation. All rights reserved. <BR>\r
+ (C) Copyright 2016 Hewlett Packard Enterprise Development LP<BR>\r
+ (C) Copyright 2015 Hewlett-Packard Development Company, L.P.<BR>\r
+ Copyright (c) 2009 - 2018, Intel Corporation. All rights reserved. <BR>\r
This program and the accompanying materials\r
are licensed and made available under the terms and conditions of the BSD License\r
which accompanies this distribution. The full text of the license may be found at\r
\r
#include "UefiShellLevel3CommandsLib.h"\r
\r
+STATIC CONST SHELL_PARAM_ITEM ParamList[] = {\r
+ {L"-sfo", TypeFlag},\r
+ {NULL, TypeMax}\r
+ };\r
+\r
/**\r
Function for 'cls' command.\r
\r
{\r
EFI_STATUS Status;\r
LIST_ENTRY *Package;\r
- CHAR16 *Message;\r
UINTN Background;\r
- UINTN ForeColor;\r
+ UINTN Foreground;\r
CHAR16 *ProblemParam;\r
SHELL_STATUS ShellStatus;\r
- CONST CHAR16 *Param1;\r
-\r
- ShellStatus = SHELL_SUCCESS;\r
- ProblemParam = NULL;\r
- Background = 0;\r
+ CONST CHAR16 *BackColorStr;\r
+ CONST CHAR16 *ForeColorStr;\r
\r
//\r
// Initialize variables\r
//\r
- Message = NULL;\r
+ ShellStatus = SHELL_SUCCESS;\r
+ ProblemParam = NULL;\r
+ Background = 0;\r
+ Foreground = 0;\r
\r
//\r
// initialize the shell lib (we must be in non-auto-init...)\r
//\r
// parse the command line\r
//\r
- Status = ShellCommandLineParse (EmptyParamList, &Package, &ProblemParam, TRUE);\r
+ Status = ShellCommandLineParse (ParamList, &Package, &ProblemParam, TRUE);\r
if (EFI_ERROR(Status)) {\r
if (Status == EFI_VOLUME_CORRUPTED && ProblemParam != NULL) {\r
- ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_PROBLEM), gShellLevel3HiiHandle, ProblemParam);\r
+ ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_PROBLEM), gShellLevel3HiiHandle, L"cls", ProblemParam);\r
FreePool(ProblemParam);\r
ShellStatus = SHELL_INVALID_PARAMETER;\r
} else {\r
//\r
if (ShellCommandLineGetFlag(Package, L"-?")) {\r
ASSERT(FALSE);\r
+ } else if (ShellCommandLineGetFlag (Package, L"-sfo")) {\r
+ if (ShellCommandLineGetCount (Package) > 1) {\r
+ ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_GEN_TOO_MANY), gShellLevel3HiiHandle, L"cls");\r
+ ShellStatus = SHELL_INVALID_PARAMETER;\r
+ } else {\r
+ Background = (gST->ConOut->Mode->Attribute >> 4) & 0x7;\r
+ Foreground = gST->ConOut->Mode->Attribute & 0x0F;\r
+ ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_GEN_SFO_HEADER), gShellLevel3HiiHandle, L"cls");\r
+ ShellPrintHiiEx (\r
+ -1,\r
+ -1,\r
+ NULL,\r
+ STRING_TOKEN (STR_CLS_OUTPUT_SFO),\r
+ gShellLevel3HiiHandle,\r
+ gST->ConOut->Mode->Attribute,\r
+ Foreground,\r
+ Background\r
+ );\r
+ }\r
} else {\r
//\r
// If there are 0 value parameters, clear sceen\r
//\r
- Param1 = ShellCommandLineGetRawValue(Package, 1);\r
- if (Param1 == NULL) {\r
+ BackColorStr = ShellCommandLineGetRawValue (Package, 1);\r
+ ForeColorStr = ShellCommandLineGetRawValue (Package, 2);\r
+\r
+ if (BackColorStr == NULL && ForeColorStr == NULL) {\r
//\r
// clear screen\r
//\r
gST->ConOut->ClearScreen (gST->ConOut);\r
- } else if (ShellCommandLineGetCount(Package) > 2) {\r
- ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_TOO_MANY), gShellLevel3HiiHandle);\r
+ } else if (ShellCommandLineGetCount (Package) > 3) {\r
+ ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_GEN_TOO_MANY), gShellLevel3HiiHandle, L"cls");\r
ShellStatus = SHELL_INVALID_PARAMETER;\r
} else {\r
- if (StrDecimalToUintn(Param1) > 7 || StrLen(Param1) > 1 || !ShellIsDecimalDigitCharacter(*Param1)) {\r
- ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_PROBLEM), gShellLevel3HiiHandle, Param1);\r
- ShellStatus = SHELL_INVALID_PARAMETER;\r
- } else {\r
- switch (StrDecimalToUintn(Param1)) {\r
- case 0:\r
- Background = EFI_BACKGROUND_BLACK;\r
- break;\r
- case 1:\r
- Background = EFI_BACKGROUND_BLUE;\r
- break;\r
- case 2:\r
- Background = EFI_BACKGROUND_GREEN;\r
- break;\r
- case 3:\r
- Background = EFI_BACKGROUND_CYAN;\r
- break;\r
- case 4:\r
- Background = EFI_BACKGROUND_RED;\r
- break;\r
- case 5:\r
- Background = EFI_BACKGROUND_MAGENTA;\r
- break;\r
- case 6:\r
- Background = EFI_BACKGROUND_BROWN;\r
- break;\r
- case 7:\r
- Background = EFI_BACKGROUND_LIGHTGRAY;\r
- break;\r
+ if (BackColorStr != NULL) {\r
+ if ((ShellStrToUintn (BackColorStr) > 7) || (StrLen (BackColorStr) > 1) || (!ShellIsDecimalDigitCharacter (*BackColorStr))) {\r
+ ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_GEN_PARAM_INV), gShellLevel3HiiHandle, L"cls", BackColorStr);\r
+ ShellStatus = SHELL_INVALID_PARAMETER;\r
+ } else {\r
+ switch (ShellStrToUintn (BackColorStr)) {\r
+ case 0:\r
+ Background = EFI_BACKGROUND_BLACK;\r
+ break;\r
+ case 1:\r
+ Background = EFI_BACKGROUND_BLUE;\r
+ break;\r
+ case 2:\r
+ Background = EFI_BACKGROUND_GREEN;\r
+ break;\r
+ case 3:\r
+ Background = EFI_BACKGROUND_CYAN;\r
+ break;\r
+ case 4:\r
+ Background = EFI_BACKGROUND_RED;\r
+ break;\r
+ case 5:\r
+ Background = EFI_BACKGROUND_MAGENTA;\r
+ break;\r
+ case 6:\r
+ Background = EFI_BACKGROUND_BROWN;\r
+ break;\r
+ case 7:\r
+ Background = EFI_BACKGROUND_LIGHTGRAY;\r
+ break;\r
+ }\r
+\r
+ if (ForeColorStr != NULL) {\r
+ if ((ShellStrToUintn (ForeColorStr) > 15) || (StrLen (ForeColorStr) > 2) || (!ShellIsDecimalDigitCharacter (*ForeColorStr))) {\r
+ ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_GEN_PARAM_INV), gShellLevel3HiiHandle, L"cls", ForeColorStr);\r
+ ShellStatus = SHELL_INVALID_PARAMETER;\r
+ } else {\r
+ switch (ShellStrToUintn (ForeColorStr)) {\r
+ case 0:\r
+ Foreground = EFI_BLACK;\r
+ break;\r
+ case 1:\r
+ Foreground = EFI_BLUE;\r
+ break;\r
+ case 2:\r
+ Foreground = EFI_GREEN;\r
+ break;\r
+ case 3:\r
+ Foreground = EFI_CYAN;\r
+ break;\r
+ case 4:\r
+ Foreground = EFI_RED;\r
+ break;\r
+ case 5:\r
+ Foreground = EFI_MAGENTA;\r
+ break;\r
+ case 6:\r
+ Foreground = EFI_BROWN;\r
+ break;\r
+ case 7:\r
+ Foreground = EFI_LIGHTGRAY;\r
+ break;\r
+ case 8:\r
+ Foreground = EFI_DARKGRAY;\r
+ break;\r
+ case 9:\r
+ Foreground = EFI_LIGHTBLUE;\r
+ break;\r
+ case 10:\r
+ Foreground = EFI_LIGHTGREEN;\r
+ break;\r
+ case 11:\r
+ Foreground = EFI_LIGHTCYAN;\r
+ break;\r
+ case 12:\r
+ Foreground = EFI_LIGHTRED;\r
+ break;\r
+ case 13:\r
+ Foreground = EFI_LIGHTMAGENTA;\r
+ break;\r
+ case 14:\r
+ Foreground = EFI_YELLOW;\r
+ break;\r
+ case 15:\r
+ Foreground = EFI_WHITE;\r
+ break;\r
+ }\r
+ }\r
+ } else {\r
+ //\r
+ // Since foreground color is not modified, so retain\r
+ // existing foreground color without any change to it.\r
+ //\r
+ Foreground = gST->ConOut->Mode->Attribute & 0x0F;\r
+ }\r
+\r
+ if (ShellStatus == SHELL_SUCCESS) {\r
+ Status = gST->ConOut->SetAttribute (gST->ConOut, (Foreground | Background) & 0x7F);\r
+ ASSERT_EFI_ERROR (Status);\r
+ Status = gST->ConOut->ClearScreen (gST->ConOut);\r
+ ASSERT_EFI_ERROR (Status);\r
+ }\r
}\r
- ForeColor = (~StrDecimalToUintn(Param1)) & 0xF;\r
- Status = gST->ConOut->SetAttribute (gST->ConOut, ForeColor | Background);\r
- ASSERT_EFI_ERROR(Status);\r
- Status = gST->ConOut->ClearScreen (gST->ConOut);\r
- ASSERT_EFI_ERROR(Status);\r
}\r
}\r
}\r