2 Main file for attrib shell level 2 function.
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
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.
15 #include "UefiShellLevel2CommandsLib.h"
17 STATIC CONST SHELL_PARAM_ITEM ResetParamList
[] = {
25 Function for 'reset' command.
27 @param[in] ImageHandle Handle to the Image (NULL if Internal).
28 @param[in] SystemTable Pointer to the System Table (NULL if Internal).
32 ShellCommandRunReset (
33 IN EFI_HANDLE ImageHandle
,
34 IN EFI_SYSTEM_TABLE
*SystemTable
41 SHELL_STATUS ShellStatus
;
43 ShellStatus
= SHELL_SUCCESS
;
47 // initialize the shell lib (we must be in non-auto-init...)
49 Status
= ShellInitialize();
50 ASSERT_EFI_ERROR(Status
);
53 // parse the command line
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
);
68 if (ShellCommandLineGetFlag(Package
, L
"-?")) {
70 } else if (ShellCommandLineGetRawValue(Package
, 1) != NULL
) {
71 ShellPrintHiiEx(-1, -1, NULL
, STRING_TOKEN (STR_GEN_TOO_MANY
), gShellLevel2HiiHandle
);
72 ShellStatus
= SHELL_INVALID_PARAMETER
;
75 // check for warm reset flag, then shutdown reset flag, then cold (default) reset flag
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
;
82 String
= ShellCommandLineGetValue(Package
, L
"-w");
84 gRT
->ResetSystem(EfiResetWarm
, EFI_SUCCESS
, StrSize(String
), (VOID
*)String
);
86 gRT
->ResetSystem(EfiResetWarm
, EFI_SUCCESS
, 0, NULL
);
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
;
94 String
= ShellCommandLineGetValue(Package
, L
"-s");
95 DEBUG_CODE(ShellPrintEx(-1,-1,L
"Reset with %s (%d bytes)", String
, String
!=NULL
?StrSize(String
):0););
97 gRT
->ResetSystem(EfiResetShutdown
, EFI_SUCCESS
, StrSize(String
), (VOID
*)String
);
99 gRT
->ResetSystem(EfiResetShutdown
, EFI_SUCCESS
, 0, NULL
);
104 // this is default so dont worry about flag...
106 String
= ShellCommandLineGetValue(Package
, L
"-c");
107 if (String
!= NULL
) {
108 gRT
->ResetSystem(EfiResetCold
, EFI_SUCCESS
, StrSize(String
), (VOID
*)String
);
110 gRT
->ResetSystem(EfiResetCold
, EFI_SUCCESS
, 0, NULL
);
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...
122 // free the command line package
124 ShellCommandLineFreeVarList (Package
);
129 return (ShellStatus
);