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