1 | /** @file
|
---|
2 | Main file for attrib shell level 2 function.
|
---|
3 |
|
---|
4 | Copyright (c) 2009 - 2014, Intel Corporation. All rights reserved. <BR>
|
---|
5 | This program and the accompanying materials
|
---|
6 | are licensed and made available under the terms and conditions of the BSD License
|
---|
7 | which accompanies this distribution. The full text of the license may be found at
|
---|
8 | http://opensource.org/licenses/bsd-license.php
|
---|
9 |
|
---|
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.
|
---|
12 |
|
---|
13 | **/
|
---|
14 |
|
---|
15 | #include "UefiShellLevel3CommandsLib.h"
|
---|
16 |
|
---|
17 | /**
|
---|
18 | Function for 'cls' command.
|
---|
19 |
|
---|
20 | @param[in] ImageHandle Handle to the Image (NULL if Internal).
|
---|
21 | @param[in] SystemTable Pointer to the System Table (NULL if Internal).
|
---|
22 | **/
|
---|
23 | SHELL_STATUS
|
---|
24 | EFIAPI
|
---|
25 | ShellCommandRunCls (
|
---|
26 | IN EFI_HANDLE ImageHandle,
|
---|
27 | IN EFI_SYSTEM_TABLE *SystemTable
|
---|
28 | )
|
---|
29 | {
|
---|
30 | EFI_STATUS Status;
|
---|
31 | LIST_ENTRY *Package;
|
---|
32 | UINTN Background;
|
---|
33 | UINTN ForeColor;
|
---|
34 | CHAR16 *ProblemParam;
|
---|
35 | SHELL_STATUS ShellStatus;
|
---|
36 | CONST CHAR16 *Param1;
|
---|
37 |
|
---|
38 | //
|
---|
39 | // Initialize variables
|
---|
40 | //
|
---|
41 | ShellStatus = SHELL_SUCCESS;
|
---|
42 | ProblemParam = NULL;
|
---|
43 | Background = 0;
|
---|
44 |
|
---|
45 | //
|
---|
46 | // initialize the shell lib (we must be in non-auto-init...)
|
---|
47 | //
|
---|
48 | Status = ShellInitialize();
|
---|
49 | ASSERT_EFI_ERROR(Status);
|
---|
50 |
|
---|
51 | //
|
---|
52 | // parse the command line
|
---|
53 | //
|
---|
54 | Status = ShellCommandLineParse (EmptyParamList, &Package, &ProblemParam, TRUE);
|
---|
55 | if (EFI_ERROR(Status)) {
|
---|
56 | if (Status == EFI_VOLUME_CORRUPTED && ProblemParam != NULL) {
|
---|
57 | ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_PROBLEM), gShellLevel3HiiHandle, ProblemParam);
|
---|
58 | FreePool(ProblemParam);
|
---|
59 | ShellStatus = SHELL_INVALID_PARAMETER;
|
---|
60 | } else {
|
---|
61 | ASSERT(FALSE);
|
---|
62 | }
|
---|
63 | } else {
|
---|
64 | //
|
---|
65 | // check for "-?"
|
---|
66 | //
|
---|
67 | if (ShellCommandLineGetFlag(Package, L"-?")) {
|
---|
68 | ASSERT(FALSE);
|
---|
69 | } else {
|
---|
70 | //
|
---|
71 | // If there are 0 value parameters, clear sceen
|
---|
72 | //
|
---|
73 | Param1 = ShellCommandLineGetRawValue(Package, 1);
|
---|
74 | if (Param1 == NULL) {
|
---|
75 | //
|
---|
76 | // clear screen
|
---|
77 | //
|
---|
78 | gST->ConOut->ClearScreen (gST->ConOut);
|
---|
79 | } else if (ShellCommandLineGetCount(Package) > 2) {
|
---|
80 | ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_TOO_MANY), gShellLevel3HiiHandle);
|
---|
81 | ShellStatus = SHELL_INVALID_PARAMETER;
|
---|
82 | } else {
|
---|
83 | if (ShellStrToUintn(Param1) > 7 || StrLen(Param1) > 1 || !ShellIsDecimalDigitCharacter(*Param1)) {
|
---|
84 | ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_PROBLEM), gShellLevel3HiiHandle, Param1);
|
---|
85 | ShellStatus = SHELL_INVALID_PARAMETER;
|
---|
86 | } else {
|
---|
87 | switch (ShellStrToUintn(Param1)) {
|
---|
88 | case 0:
|
---|
89 | Background = EFI_BACKGROUND_BLACK;
|
---|
90 | break;
|
---|
91 | case 1:
|
---|
92 | Background = EFI_BACKGROUND_BLUE;
|
---|
93 | break;
|
---|
94 | case 2:
|
---|
95 | Background = EFI_BACKGROUND_GREEN;
|
---|
96 | break;
|
---|
97 | case 3:
|
---|
98 | Background = EFI_BACKGROUND_CYAN;
|
---|
99 | break;
|
---|
100 | case 4:
|
---|
101 | Background = EFI_BACKGROUND_RED;
|
---|
102 | break;
|
---|
103 | case 5:
|
---|
104 | Background = EFI_BACKGROUND_MAGENTA;
|
---|
105 | break;
|
---|
106 | case 6:
|
---|
107 | Background = EFI_BACKGROUND_BROWN;
|
---|
108 | break;
|
---|
109 | case 7:
|
---|
110 | Background = EFI_BACKGROUND_LIGHTGRAY;
|
---|
111 | break;
|
---|
112 | }
|
---|
113 | ForeColor = (~ShellStrToUintn(Param1)) & 0xF;
|
---|
114 | Status = gST->ConOut->SetAttribute (gST->ConOut, (ForeColor | Background) & 0x7F );
|
---|
115 | ASSERT_EFI_ERROR(Status);
|
---|
116 | Status = gST->ConOut->ClearScreen (gST->ConOut);
|
---|
117 | ASSERT_EFI_ERROR(Status);
|
---|
118 | }
|
---|
119 | }
|
---|
120 | }
|
---|
121 | }
|
---|
122 | //
|
---|
123 | // free the command line package
|
---|
124 | //
|
---|
125 | ShellCommandLineFreeVarList (Package);
|
---|
126 |
|
---|
127 | //
|
---|
128 | // return the status
|
---|
129 | //
|
---|
130 | return (ShellStatus);
|
---|
131 | }
|
---|
132 |
|
---|