]> git.proxmox.com Git - mirror_edk2.git/blame - ShellPkg/Library/UefiShellLevel1CommandsLib/Exit.c
ShellPkg: acpiview: Add GT Frame Number validation to GTDT parser
[mirror_edk2.git] / ShellPkg / Library / UefiShellLevel1CommandsLib / Exit.c
CommitLineData
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
12STATIC CONST SHELL_PARAM_ITEM ParamList[] = {\r
13 {L"/b", TypeFlag},\r
14 {NULL, TypeMax}\r
15 };\r
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
23SHELL_STATUS\r
24EFIAPI\r
25ShellCommandRunExit (\r
26 IN EFI_HANDLE ImageHandle,\r
27 IN EFI_SYSTEM_TABLE *SystemTable\r
28 )\r
29{\r
30 EFI_STATUS Status;\r
31 LIST_ENTRY *Package;\r
32 CHAR16 *ProblemParam;\r
33 SHELL_STATUS ShellStatus;\r
77dcec12 34 UINT64 RetVal;\r
35 CONST CHAR16 *Return;\r
a405b86d 36\r
37 ShellStatus = SHELL_SUCCESS;\r
38\r
39 //\r
40 // initialize the shell lib (we must be in non-auto-init...)\r
41 //\r
42 Status = ShellInitialize();\r
43 ASSERT_EFI_ERROR(Status);\r
44\r
45 Status = CommandInit();\r
46 ASSERT_EFI_ERROR(Status);\r
47\r
48 //\r
49 // parse the command line\r
50 //\r
51 Status = ShellCommandLineParse (ParamList, &Package, &ProblemParam, TRUE);\r
52 if (EFI_ERROR(Status)) {\r
53 if (Status == EFI_VOLUME_CORRUPTED && ProblemParam != NULL) {\r
0861edab 54 ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_PROBLEM), gShellLevel1HiiHandle, L"exit", ProblemParam);\r
a405b86d 55 FreePool(ProblemParam);\r
56 ShellStatus = SHELL_INVALID_PARAMETER;\r
57 } else {\r
58 ASSERT(FALSE);\r
59 }\r
60 } else {\r
61\r
a405b86d 62 //\r
63 // return the specified error code\r
64 //\r
77dcec12 65 Return = ShellCommandLineGetRawValue(Package, 1);\r
66 if (Return != NULL) {\r
67 Status = ShellConvertStringToUint64(Return, &RetVal, FALSE, FALSE);\r
68 if (EFI_ERROR(Status)) {\r
0861edab 69 ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_PARAM_INV), gShellLevel1HiiHandle, L"exit", Return);\r
77dcec12 70 ShellStatus = SHELL_INVALID_PARAMETER;\r
71 } else {\r
72 //\r
73 // If we are in a batch file and /b then pass TRUE otherwise false...\r
74 //\r
b6b22b13 75 ShellCommandRegisterExit((BOOLEAN)(gEfiShellProtocol->BatchIsActive() && ShellCommandLineGetFlag(Package, L"/b")), RetVal);\r
77dcec12 76\r
b6b22b13 77 ShellStatus = SHELL_SUCCESS;\r
77dcec12 78 }\r
79 } else {\r
80 // If we are in a batch file and /b then pass TRUE otherwise false...\r
81 //\r
b6b22b13 82 ShellCommandRegisterExit((BOOLEAN)(gEfiShellProtocol->BatchIsActive() && ShellCommandLineGetFlag(Package, L"/b")), 0);\r
77dcec12 83\r
b6b22b13 84 ShellStatus = SHELL_SUCCESS;\r
a405b86d 85 }\r
86\r
87 ShellCommandLineFreeVarList (Package);\r
88 }\r
89 return (ShellStatus);\r
90}\r
91\r