]>
Commit | Line | Data |
---|---|---|
a405b86d | 1 | /** @file\r |
2 | Main file for exit shell level 1 function.\r | |
3 | \r | |
c011b6c9 | 4 | (C) Copyright 2015 Hewlett-Packard Development Company, L.P.<BR>\r |
77dcec12 | 5 | Copyright (c) 2009 - 2011, Intel Corporation. All rights reserved.<BR>\r |
56ba3746 | 6 | SPDX-License-Identifier: BSD-2-Clause-Patent\r |
a405b86d | 7 | \r |
8 | **/\r | |
9 | \r | |
10 | #include "UefiShellLevel1CommandsLib.h"\r | |
11 | \r | |
47d20b54 MK |
12 | STATIC CONST SHELL_PARAM_ITEM ParamList[] = {\r |
13 | { L"/b", TypeFlag },\r | |
14 | { NULL, TypeMax }\r | |
15 | };\r | |
a405b86d | 16 | \r |
17 | /**\r | |
18 | Function for 'exit' command.\r | |
19 | \r | |
20 | @param[in] ImageHandle Handle to the Image (NULL if Internal).\r | |
21 | @param[in] SystemTable Pointer to the System Table (NULL if Internal).\r | |
22 | **/\r | |
23 | SHELL_STATUS\r | |
24 | EFIAPI\r | |
25 | ShellCommandRunExit (\r | |
26 | IN EFI_HANDLE ImageHandle,\r | |
27 | IN EFI_SYSTEM_TABLE *SystemTable\r | |
28 | )\r | |
29 | {\r | |
47d20b54 MK |
30 | EFI_STATUS Status;\r |
31 | LIST_ENTRY *Package;\r | |
32 | CHAR16 *ProblemParam;\r | |
33 | SHELL_STATUS ShellStatus;\r | |
34 | UINT64 RetVal;\r | |
35 | CONST CHAR16 *Return;\r | |
a405b86d | 36 | \r |
47d20b54 | 37 | ShellStatus = SHELL_SUCCESS;\r |
a405b86d | 38 | \r |
39 | //\r | |
40 | // initialize the shell lib (we must be in non-auto-init...)\r | |
41 | //\r | |
47d20b54 MK |
42 | Status = ShellInitialize ();\r |
43 | ASSERT_EFI_ERROR (Status);\r | |
a405b86d | 44 | \r |
47d20b54 MK |
45 | Status = CommandInit ();\r |
46 | ASSERT_EFI_ERROR (Status);\r | |
a405b86d | 47 | \r |
48 | //\r | |
49 | // parse the command line\r | |
50 | //\r | |
51 | Status = ShellCommandLineParse (ParamList, &Package, &ProblemParam, TRUE);\r | |
47d20b54 MK |
52 | if (EFI_ERROR (Status)) {\r |
53 | if ((Status == EFI_VOLUME_CORRUPTED) && (ProblemParam != NULL)) {\r | |
54 | ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_GEN_PROBLEM), gShellLevel1HiiHandle, L"exit", ProblemParam);\r | |
55 | FreePool (ProblemParam);\r | |
a405b86d | 56 | ShellStatus = SHELL_INVALID_PARAMETER;\r |
57 | } else {\r | |
47d20b54 | 58 | ASSERT (FALSE);\r |
a405b86d | 59 | }\r |
60 | } else {\r | |
a405b86d | 61 | //\r |
62 | // return the specified error code\r | |
63 | //\r | |
47d20b54 | 64 | Return = ShellCommandLineGetRawValue (Package, 1);\r |
77dcec12 | 65 | if (Return != NULL) {\r |
47d20b54 MK |
66 | Status = ShellConvertStringToUint64 (Return, &RetVal, FALSE, FALSE);\r |
67 | if (EFI_ERROR (Status)) {\r | |
68 | ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_GEN_PARAM_INV), gShellLevel1HiiHandle, L"exit", Return);\r | |
77dcec12 | 69 | ShellStatus = SHELL_INVALID_PARAMETER;\r |
70 | } else {\r | |
71 | //\r | |
72 | // If we are in a batch file and /b then pass TRUE otherwise false...\r | |
73 | //\r | |
47d20b54 | 74 | ShellCommandRegisterExit ((BOOLEAN)(gEfiShellProtocol->BatchIsActive () && ShellCommandLineGetFlag (Package, L"/b")), RetVal);\r |
77dcec12 | 75 | \r |
b6b22b13 | 76 | ShellStatus = SHELL_SUCCESS;\r |
77dcec12 | 77 | }\r |
78 | } else {\r | |
79 | // If we are in a batch file and /b then pass TRUE otherwise false...\r | |
80 | //\r | |
47d20b54 | 81 | ShellCommandRegisterExit ((BOOLEAN)(gEfiShellProtocol->BatchIsActive () && ShellCommandLineGetFlag (Package, L"/b")), 0);\r |
77dcec12 | 82 | \r |
b6b22b13 | 83 | ShellStatus = SHELL_SUCCESS;\r |
a405b86d | 84 | }\r |
85 | \r | |
86 | ShellCommandLineFreeVarList (Package);\r | |
87 | }\r | |
47d20b54 | 88 | \r |
a405b86d | 89 | return (ShellStatus);\r |
90 | }\r |