]>
Commit | Line | Data |
---|---|---|
a405b86d | 1 | /** @file\r |
2 | Main file for attrib shell level 2 function.\r | |
3 | \r | |
c011b6c9 | 4 | (C) Copyright 2015 Hewlett-Packard Development Company, L.P.<BR>\r |
f675a1b4 | 5 | Copyright (c) 2009 - 2016, Intel Corporation. All rights reserved.<BR>\r |
a405b86d | 6 | This program and the accompanying materials\r |
7 | are licensed and made available under the terms and conditions of the BSD License\r | |
8 | which accompanies this distribution. The full text of the license may be found at\r | |
9 | http://opensource.org/licenses/bsd-license.php\r | |
10 | \r | |
11 | THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r | |
12 | WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r | |
13 | \r | |
14 | **/\r | |
15 | \r | |
16 | #include "UefiShellLevel2CommandsLib.h"\r | |
17 | \r | |
18 | STATIC CONST SHELL_PARAM_ITEM ResetParamList[] = {\r | |
f675a1b4 CC |
19 | {L"-w", TypeValue},\r |
20 | {L"-s", TypeValue},\r | |
21 | {L"-c", TypeValue},\r | |
22 | {L"-fwui", TypeFlag },\r | |
23 | {NULL, TypeMax }\r | |
a405b86d | 24 | };\r |
25 | \r | |
26 | /**\r | |
27 | Function for 'reset' command.\r | |
28 | \r | |
29 | @param[in] ImageHandle Handle to the Image (NULL if Internal).\r | |
30 | @param[in] SystemTable Pointer to the System Table (NULL if Internal).\r | |
31 | **/\r | |
32 | SHELL_STATUS\r | |
33 | EFIAPI\r | |
34 | ShellCommandRunReset (\r | |
35 | IN EFI_HANDLE ImageHandle,\r | |
36 | IN EFI_SYSTEM_TABLE *SystemTable\r | |
37 | )\r | |
38 | {\r | |
39 | EFI_STATUS Status;\r | |
40 | LIST_ENTRY *Package;\r | |
41 | CONST CHAR16 *String;\r | |
42 | CHAR16 *ProblemParam;\r | |
43 | SHELL_STATUS ShellStatus;\r | |
f675a1b4 CC |
44 | UINT64 OsIndications;\r |
45 | UINT32 Attr;\r | |
46 | UINTN DataSize;\r | |
a405b86d | 47 | \r |
48 | ShellStatus = SHELL_SUCCESS;\r | |
49 | ProblemParam = NULL;\r | |
50 | \r | |
51 | //\r | |
52 | // initialize the shell lib (we must be in non-auto-init...)\r | |
53 | //\r | |
54 | Status = ShellInitialize();\r | |
55 | ASSERT_EFI_ERROR(Status);\r | |
56 | \r | |
57 | //\r | |
58 | // parse the command line\r | |
59 | //\r | |
60 | Status = ShellCommandLineParse (ResetParamList, &Package, &ProblemParam, TRUE);\r | |
61 | if (EFI_ERROR(Status)) {\r | |
62 | if (Status == EFI_VOLUME_CORRUPTED && ProblemParam != NULL) {\r | |
099e8ff5 | 63 | ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_PROBLEM), gShellLevel2HiiHandle, L"reset", ProblemParam); \r |
a405b86d | 64 | FreePool(ProblemParam);\r |
65 | return (SHELL_INVALID_PARAMETER);\r | |
66 | } else {\r | |
67 | ASSERT(FALSE);\r | |
68 | }\r | |
69 | } else {\r | |
70 | //\r | |
71 | // check for "-?"\r | |
72 | //\r | |
73 | if (ShellCommandLineGetFlag(Package, L"-?")) {\r | |
74 | ASSERT(FALSE);\r | |
75 | } else if (ShellCommandLineGetRawValue(Package, 1) != NULL) {\r | |
099e8ff5 | 76 | ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_TOO_MANY), gShellLevel2HiiHandle, L"reset"); \r |
a405b86d | 77 | ShellStatus = SHELL_INVALID_PARAMETER;\r |
78 | } else {\r | |
f675a1b4 CC |
79 | \r |
80 | if (ShellCommandLineGetFlag (Package, L"-fwui")) {\r | |
81 | \r | |
82 | DataSize = sizeof (OsIndications);\r | |
83 | Status = gRT->GetVariable (\r | |
84 | EFI_OS_INDICATIONS_SUPPORT_VARIABLE_NAME, &gEfiGlobalVariableGuid,\r | |
85 | &Attr, &DataSize, &OsIndications\r | |
86 | );\r | |
87 | if (!EFI_ERROR (Status)) {\r | |
88 | if ((OsIndications & EFI_OS_INDICATIONS_BOOT_TO_FW_UI) != 0) {\r | |
89 | DataSize = sizeof (OsIndications);\r | |
90 | Status = gRT->GetVariable (\r | |
91 | EFI_OS_INDICATIONS_VARIABLE_NAME, &gEfiGlobalVariableGuid,\r | |
92 | &Attr, &DataSize, &OsIndications\r | |
93 | );\r | |
94 | if (!EFI_ERROR (Status)) {\r | |
95 | OsIndications |= EFI_OS_INDICATIONS_BOOT_TO_FW_UI;\r | |
96 | } else {\r | |
97 | OsIndications = EFI_OS_INDICATIONS_BOOT_TO_FW_UI;\r | |
98 | }\r | |
99 | Status = gRT->SetVariable (\r | |
100 | EFI_OS_INDICATIONS_VARIABLE_NAME, &gEfiGlobalVariableGuid,\r | |
101 | EFI_VARIABLE_NON_VOLATILE | EFI_VARIABLE_BOOTSERVICE_ACCESS | EFI_VARIABLE_RUNTIME_ACCESS,\r | |
102 | sizeof (OsIndications), &OsIndications\r | |
103 | );\r | |
104 | }\r | |
105 | }\r | |
106 | if (EFI_ERROR (Status)) {\r | |
107 | ShellStatus = SHELL_UNSUPPORTED;\r | |
108 | goto Error;\r | |
109 | }\r | |
110 | }\r | |
111 | \r | |
a405b86d | 112 | //\r |
33728406 | 113 | // check for warm reset flag, then shutdown reset flag, then cold (default) reset flag\r |
a405b86d | 114 | //\r |
33728406 | 115 | if (ShellCommandLineGetFlag(Package, L"-w")) {\r |
116 | if (ShellCommandLineGetFlag(Package, L"-s") || ShellCommandLineGetFlag(Package, L"-c")) {\r | |
099e8ff5 | 117 | ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_TOO_MANY), gShellLevel2HiiHandle, L"reset"); \r |
a405b86d | 118 | ShellStatus = SHELL_INVALID_PARAMETER;\r |
119 | } else {\r | |
33728406 | 120 | String = ShellCommandLineGetValue(Package, L"-w");\r |
a405b86d | 121 | if (String != NULL) {\r |
d8fdd524 | 122 | gRT->ResetSystem(EfiResetWarm, EFI_SUCCESS, StrSize(String), (VOID*)String);\r |
a405b86d | 123 | } else {\r |
d8fdd524 | 124 | gRT->ResetSystem(EfiResetWarm, EFI_SUCCESS, 0, NULL);\r |
a405b86d | 125 | }\r |
126 | }\r | |
127 | } else if (ShellCommandLineGetFlag(Package, L"-s")) {\r | |
33728406 | 128 | if (ShellCommandLineGetFlag(Package, L"-c")) {\r |
099e8ff5 | 129 | ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_TOO_MANY), gShellLevel2HiiHandle, L"reset"); \r |
a405b86d | 130 | ShellStatus = SHELL_INVALID_PARAMETER;\r |
131 | } else {\r | |
132 | String = ShellCommandLineGetValue(Package, L"-s");\r | |
133 | DEBUG_CODE(ShellPrintEx(-1,-1,L"Reset with %s (%d bytes)", String, String!=NULL?StrSize(String):0););\r | |
134 | if (String != NULL) {\r | |
135 | gRT->ResetSystem(EfiResetShutdown, EFI_SUCCESS, StrSize(String), (VOID*)String);\r | |
136 | } else {\r | |
137 | gRT->ResetSystem(EfiResetShutdown, EFI_SUCCESS, 0, NULL);\r | |
138 | }\r | |
139 | }\r | |
140 | } else {\r | |
141 | //\r | |
142 | // this is default so dont worry about flag...\r | |
143 | //\r | |
33728406 | 144 | String = ShellCommandLineGetValue(Package, L"-c");\r |
a405b86d | 145 | if (String != NULL) {\r |
d8fdd524 | 146 | gRT->ResetSystem(EfiResetCold, EFI_SUCCESS, StrSize(String), (VOID*)String);\r |
a405b86d | 147 | } else {\r |
d8fdd524 | 148 | gRT->ResetSystem(EfiResetCold, EFI_SUCCESS, 0, NULL);\r |
a405b86d | 149 | }\r |
150 | }\r | |
151 | }\r | |
152 | }\r | |
153 | \r | |
154 | //\r | |
155 | // we should never get here... so the free and return are for formality more than use\r | |
156 | // as the ResetSystem function should not return...\r | |
157 | //\r | |
158 | \r | |
f675a1b4 | 159 | Error:\r |
a405b86d | 160 | //\r |
161 | // free the command line package\r | |
162 | //\r | |
163 | ShellCommandLineFreeVarList (Package);\r | |
164 | \r | |
165 | //\r | |
166 | // return the status\r | |
167 | //\r | |
168 | return (ShellStatus);\r | |
169 | }\r | |
170 | \r |