1 | /** @file
|
---|
2 | Main file for attrib shell level 2 function.
|
---|
3 |
|
---|
4 | Copyright (c) 2009 - 2012, 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 "UefiShellLevel2CommandsLib.h"
|
---|
16 |
|
---|
17 | STATIC CONST SHELL_PARAM_ITEM ResetParamList[] = {
|
---|
18 | {L"-w", TypeValue},
|
---|
19 | {L"-s", TypeValue},
|
---|
20 | {L"-c", TypeValue},
|
---|
21 | {NULL, TypeMax}
|
---|
22 | };
|
---|
23 |
|
---|
24 | /**
|
---|
25 | Function for 'reset' command.
|
---|
26 |
|
---|
27 | @param[in] ImageHandle Handle to the Image (NULL if Internal).
|
---|
28 | @param[in] SystemTable Pointer to the System Table (NULL if Internal).
|
---|
29 | **/
|
---|
30 | SHELL_STATUS
|
---|
31 | EFIAPI
|
---|
32 | ShellCommandRunReset (
|
---|
33 | IN EFI_HANDLE ImageHandle,
|
---|
34 | IN EFI_SYSTEM_TABLE *SystemTable
|
---|
35 | )
|
---|
36 | {
|
---|
37 | EFI_STATUS Status;
|
---|
38 | LIST_ENTRY *Package;
|
---|
39 | CONST CHAR16 *String;
|
---|
40 | CHAR16 *ProblemParam;
|
---|
41 | SHELL_STATUS ShellStatus;
|
---|
42 |
|
---|
43 | ShellStatus = SHELL_SUCCESS;
|
---|
44 | ProblemParam = NULL;
|
---|
45 |
|
---|
46 | //
|
---|
47 | // initialize the shell lib (we must be in non-auto-init...)
|
---|
48 | //
|
---|
49 | Status = ShellInitialize();
|
---|
50 | ASSERT_EFI_ERROR(Status);
|
---|
51 |
|
---|
52 | //
|
---|
53 | // parse the command line
|
---|
54 | //
|
---|
55 | Status = ShellCommandLineParse (ResetParamList, &Package, &ProblemParam, TRUE);
|
---|
56 | if (EFI_ERROR(Status)) {
|
---|
57 | if (Status == EFI_VOLUME_CORRUPTED && ProblemParam != NULL) {
|
---|
58 | ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_PROBLEM), gShellLevel2HiiHandle, ProblemParam);
|
---|
59 | FreePool(ProblemParam);
|
---|
60 | return (SHELL_INVALID_PARAMETER);
|
---|
61 | } else {
|
---|
62 | ASSERT(FALSE);
|
---|
63 | }
|
---|
64 | } else {
|
---|
65 | //
|
---|
66 | // check for "-?"
|
---|
67 | //
|
---|
68 | if (ShellCommandLineGetFlag(Package, L"-?")) {
|
---|
69 | ASSERT(FALSE);
|
---|
70 | } else if (ShellCommandLineGetRawValue(Package, 1) != NULL) {
|
---|
71 | ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_TOO_MANY), gShellLevel2HiiHandle);
|
---|
72 | ShellStatus = SHELL_INVALID_PARAMETER;
|
---|
73 | } else {
|
---|
74 | //
|
---|
75 | // check for warm reset flag, then shutdown reset flag, then cold (default) reset flag
|
---|
76 | //
|
---|
77 | if (ShellCommandLineGetFlag(Package, L"-w")) {
|
---|
78 | if (ShellCommandLineGetFlag(Package, L"-s") || ShellCommandLineGetFlag(Package, L"-c")) {
|
---|
79 | ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_TOO_MANY), gShellLevel2HiiHandle);
|
---|
80 | ShellStatus = SHELL_INVALID_PARAMETER;
|
---|
81 | } else {
|
---|
82 | String = ShellCommandLineGetValue(Package, L"-w");
|
---|
83 | if (String != NULL) {
|
---|
84 | gRT->ResetSystem(EfiResetWarm, EFI_SUCCESS, StrSize(String), (VOID*)String);
|
---|
85 | } else {
|
---|
86 | gRT->ResetSystem(EfiResetWarm, EFI_SUCCESS, 0, NULL);
|
---|
87 | }
|
---|
88 | }
|
---|
89 | } else if (ShellCommandLineGetFlag(Package, L"-s")) {
|
---|
90 | if (ShellCommandLineGetFlag(Package, L"-c")) {
|
---|
91 | ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_TOO_MANY), gShellLevel2HiiHandle);
|
---|
92 | ShellStatus = SHELL_INVALID_PARAMETER;
|
---|
93 | } else {
|
---|
94 | String = ShellCommandLineGetValue(Package, L"-s");
|
---|
95 | DEBUG_CODE(ShellPrintEx(-1,-1,L"Reset with %s (%d bytes)", String, String!=NULL?StrSize(String):0););
|
---|
96 | if (String != NULL) {
|
---|
97 | gRT->ResetSystem(EfiResetShutdown, EFI_SUCCESS, StrSize(String), (VOID*)String);
|
---|
98 | } else {
|
---|
99 | gRT->ResetSystem(EfiResetShutdown, EFI_SUCCESS, 0, NULL);
|
---|
100 | }
|
---|
101 | }
|
---|
102 | } else {
|
---|
103 | //
|
---|
104 | // this is default so dont worry about flag...
|
---|
105 | //
|
---|
106 | String = ShellCommandLineGetValue(Package, L"-c");
|
---|
107 | if (String != NULL) {
|
---|
108 | gRT->ResetSystem(EfiResetCold, EFI_SUCCESS, StrSize(String), (VOID*)String);
|
---|
109 | } else {
|
---|
110 | gRT->ResetSystem(EfiResetCold, EFI_SUCCESS, 0, NULL);
|
---|
111 | }
|
---|
112 | }
|
---|
113 | }
|
---|
114 | }
|
---|
115 |
|
---|
116 | //
|
---|
117 | // we should never get here... so the free and return are for formality more than use
|
---|
118 | // as the ResetSystem function should not return...
|
---|
119 | //
|
---|
120 |
|
---|
121 | //
|
---|
122 | // free the command line package
|
---|
123 | //
|
---|
124 | ShellCommandLineFreeVarList (Package);
|
---|
125 |
|
---|
126 | //
|
---|
127 | // return the status
|
---|
128 | //
|
---|
129 | return (ShellStatus);
|
---|
130 | }
|
---|
131 |
|
---|