2 Main file for attrib shell level 2 function.
4 (C) Copyright 2015 Hewlett-Packard Development Company, L.P.<BR>
5 Copyright (c) 2009 - 2012, Intel Corporation. All rights reserved.<BR>
6 This program and the accompanying materials
7 are licensed and made available under the terms and conditions of the BSD License
8 which accompanies this distribution. The full text of the license may be found at
9 http://opensource.org/licenses/bsd-license.php
11 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
12 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
16 #include "UefiShellLevel2CommandsLib.h"
18 STATIC CONST SHELL_PARAM_ITEM ResetParamList
[] = {
26 Function for 'reset' command.
28 @param[in] ImageHandle Handle to the Image (NULL if Internal).
29 @param[in] SystemTable Pointer to the System Table (NULL if Internal).
33 ShellCommandRunReset (
34 IN EFI_HANDLE ImageHandle
,
35 IN EFI_SYSTEM_TABLE
*SystemTable
42 SHELL_STATUS ShellStatus
;
44 ShellStatus
= SHELL_SUCCESS
;
48 // initialize the shell lib (we must be in non-auto-init...)
50 Status
= ShellInitialize();
51 ASSERT_EFI_ERROR(Status
);
54 // parse the command line
56 Status
= ShellCommandLineParse (ResetParamList
, &Package
, &ProblemParam
, TRUE
);
57 if (EFI_ERROR(Status
)) {
58 if (Status
== EFI_VOLUME_CORRUPTED
&& ProblemParam
!= NULL
) {
59 ShellPrintHiiEx(-1, -1, NULL
, STRING_TOKEN (STR_GEN_PROBLEM
), gShellLevel2HiiHandle
, L
"reset", ProblemParam
);
60 FreePool(ProblemParam
);
61 return (SHELL_INVALID_PARAMETER
);
69 if (ShellCommandLineGetFlag(Package
, L
"-?")) {
71 } else if (ShellCommandLineGetRawValue(Package
, 1) != NULL
) {
72 ShellPrintHiiEx(-1, -1, NULL
, STRING_TOKEN (STR_GEN_TOO_MANY
), gShellLevel2HiiHandle
, L
"reset");
73 ShellStatus
= SHELL_INVALID_PARAMETER
;
76 // check for warm reset flag, then shutdown reset flag, then cold (default) reset flag
78 if (ShellCommandLineGetFlag(Package
, L
"-w")) {
79 if (ShellCommandLineGetFlag(Package
, L
"-s") || ShellCommandLineGetFlag(Package
, L
"-c")) {
80 ShellPrintHiiEx(-1, -1, NULL
, STRING_TOKEN (STR_GEN_TOO_MANY
), gShellLevel2HiiHandle
, L
"reset");
81 ShellStatus
= SHELL_INVALID_PARAMETER
;
83 String
= ShellCommandLineGetValue(Package
, L
"-w");
85 gRT
->ResetSystem(EfiResetWarm
, EFI_SUCCESS
, StrSize(String
), (VOID
*)String
);
87 gRT
->ResetSystem(EfiResetWarm
, EFI_SUCCESS
, 0, NULL
);
90 } else if (ShellCommandLineGetFlag(Package
, L
"-s")) {
91 if (ShellCommandLineGetFlag(Package
, L
"-c")) {
92 ShellPrintHiiEx(-1, -1, NULL
, STRING_TOKEN (STR_GEN_TOO_MANY
), gShellLevel2HiiHandle
, L
"reset");
93 ShellStatus
= SHELL_INVALID_PARAMETER
;
95 String
= ShellCommandLineGetValue(Package
, L
"-s");
96 DEBUG_CODE(ShellPrintEx(-1,-1,L
"Reset with %s (%d bytes)", String
, String
!=NULL
?StrSize(String
):0););
98 gRT
->ResetSystem(EfiResetShutdown
, EFI_SUCCESS
, StrSize(String
), (VOID
*)String
);
100 gRT
->ResetSystem(EfiResetShutdown
, EFI_SUCCESS
, 0, NULL
);
105 // this is default so dont worry about flag...
107 String
= ShellCommandLineGetValue(Package
, L
"-c");
108 if (String
!= NULL
) {
109 gRT
->ResetSystem(EfiResetCold
, EFI_SUCCESS
, StrSize(String
), (VOID
*)String
);
111 gRT
->ResetSystem(EfiResetCold
, EFI_SUCCESS
, 0, NULL
);
118 // we should never get here... so the free and return are for formality more than use
119 // as the ResetSystem function should not return...
123 // free the command line package
125 ShellCommandLineFreeVarList (Package
);
130 return (ShellStatus
);