]> git.proxmox.com Git - mirror_edk2.git/blame - ShellPkg/Library/UefiShellLevel2CommandsLib/Reset.c
ShellPkg: Fix timezone command
[mirror_edk2.git] / ShellPkg / Library / UefiShellLevel2CommandsLib / Reset.c
CommitLineData
a405b86d 1/** @file\r
2 Main file for attrib shell level 2 function.\r
3\r
344b16e1 4 Copyright (c) 2009 - 2012, Intel Corporation. All rights reserved.<BR>\r
a405b86d 5 This program and the accompanying materials\r
6 are licensed and made available under the terms and conditions of the BSD License\r
7 which accompanies this distribution. The full text of the license may be found at\r
8 http://opensource.org/licenses/bsd-license.php\r
9\r
10 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
11 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
12\r
13**/\r
14\r
15#include "UefiShellLevel2CommandsLib.h"\r
16\r
17STATIC CONST SHELL_PARAM_ITEM ResetParamList[] = {\r
18 {L"-w", TypeValue},\r
19 {L"-s", TypeValue},\r
20 {L"-c", TypeValue},\r
21 {NULL, TypeMax}\r
22 };\r
23\r
24/**\r
25 Function for 'reset' command.\r
26\r
27 @param[in] ImageHandle Handle to the Image (NULL if Internal).\r
28 @param[in] SystemTable Pointer to the System Table (NULL if Internal).\r
29**/\r
30SHELL_STATUS\r
31EFIAPI\r
32ShellCommandRunReset (\r
33 IN EFI_HANDLE ImageHandle,\r
34 IN EFI_SYSTEM_TABLE *SystemTable\r
35 )\r
36{\r
37 EFI_STATUS Status;\r
38 LIST_ENTRY *Package;\r
39 CONST CHAR16 *String;\r
40 CHAR16 *ProblemParam;\r
41 SHELL_STATUS ShellStatus;\r
42\r
43 ShellStatus = SHELL_SUCCESS;\r
44 ProblemParam = NULL;\r
45\r
46 //\r
47 // initialize the shell lib (we must be in non-auto-init...)\r
48 //\r
49 Status = ShellInitialize();\r
50 ASSERT_EFI_ERROR(Status);\r
51\r
52 //\r
53 // parse the command line\r
54 //\r
55 Status = ShellCommandLineParse (ResetParamList, &Package, &ProblemParam, TRUE);\r
56 if (EFI_ERROR(Status)) {\r
57 if (Status == EFI_VOLUME_CORRUPTED && ProblemParam != NULL) {\r
58 ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_PROBLEM), gShellLevel2HiiHandle, ProblemParam);\r
59 FreePool(ProblemParam);\r
60 return (SHELL_INVALID_PARAMETER);\r
61 } else {\r
62 ASSERT(FALSE);\r
63 }\r
64 } else {\r
65 //\r
66 // check for "-?"\r
67 //\r
68 if (ShellCommandLineGetFlag(Package, L"-?")) {\r
69 ASSERT(FALSE);\r
70 } else if (ShellCommandLineGetRawValue(Package, 1) != NULL) {\r
71 ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_TOO_MANY), gShellLevel2HiiHandle);\r
72 ShellStatus = SHELL_INVALID_PARAMETER;\r
73 } else {\r
74 //\r
33728406 75 // check for warm reset flag, then shutdown reset flag, then cold (default) reset flag\r
a405b86d 76 //\r
33728406 77 if (ShellCommandLineGetFlag(Package, L"-w")) {\r
78 if (ShellCommandLineGetFlag(Package, L"-s") || ShellCommandLineGetFlag(Package, L"-c")) {\r
a405b86d 79 ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_TOO_MANY), gShellLevel2HiiHandle);\r
80 ShellStatus = SHELL_INVALID_PARAMETER;\r
81 } else {\r
33728406 82 String = ShellCommandLineGetValue(Package, L"-w");\r
a405b86d 83 if (String != NULL) {\r
d8fdd524 84 gRT->ResetSystem(EfiResetWarm, EFI_SUCCESS, StrSize(String), (VOID*)String);\r
a405b86d 85 } else {\r
d8fdd524 86 gRT->ResetSystem(EfiResetWarm, EFI_SUCCESS, 0, NULL);\r
a405b86d 87 }\r
88 }\r
89 } else if (ShellCommandLineGetFlag(Package, L"-s")) {\r
33728406 90 if (ShellCommandLineGetFlag(Package, L"-c")) {\r
a405b86d 91 ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_TOO_MANY), gShellLevel2HiiHandle);\r
92 ShellStatus = SHELL_INVALID_PARAMETER;\r
93 } else {\r
94 String = ShellCommandLineGetValue(Package, L"-s");\r
95 DEBUG_CODE(ShellPrintEx(-1,-1,L"Reset with %s (%d bytes)", String, String!=NULL?StrSize(String):0););\r
96 if (String != NULL) {\r
97 gRT->ResetSystem(EfiResetShutdown, EFI_SUCCESS, StrSize(String), (VOID*)String);\r
98 } else {\r
99 gRT->ResetSystem(EfiResetShutdown, EFI_SUCCESS, 0, NULL);\r
100 }\r
101 }\r
102 } else {\r
103 //\r
104 // this is default so dont worry about flag...\r
105 //\r
33728406 106 String = ShellCommandLineGetValue(Package, L"-c");\r
a405b86d 107 if (String != NULL) {\r
d8fdd524 108 gRT->ResetSystem(EfiResetCold, EFI_SUCCESS, StrSize(String), (VOID*)String);\r
a405b86d 109 } else {\r
d8fdd524 110 gRT->ResetSystem(EfiResetCold, EFI_SUCCESS, 0, NULL);\r
a405b86d 111 }\r
112 }\r
113 }\r
114 }\r
115\r
116 //\r
117 // we should never get here... so the free and return are for formality more than use\r
118 // as the ResetSystem function should not return...\r
119 //\r
120\r
121 //\r
122 // free the command line package\r
123 //\r
124 ShellCommandLineFreeVarList (Package);\r
125\r
126 //\r
127 // return the status\r
128 //\r
129 return (ShellStatus);\r
130}\r
131\r