1 | /** @file
|
---|
2 | Main file for exit shell level 1 function.
|
---|
3 |
|
---|
4 | Copyright (c) 2009 - 2011, Intel Corporation. All rights reserved.<BR>
|
---|
5 | This program and the accompanying materials
|
---|
6 | are licensed and made available under the terms and conditions of the BSD License
|
---|
7 | which accompanies this distribution. The full text of the license may be found at
|
---|
8 | http://opensource.org/licenses/bsd-license.php
|
---|
9 |
|
---|
10 | THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
|
---|
11 | WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
|
---|
12 |
|
---|
13 | **/
|
---|
14 |
|
---|
15 | #include "UefiShellLevel1CommandsLib.h"
|
---|
16 |
|
---|
17 | STATIC CONST SHELL_PARAM_ITEM ParamList[] = {
|
---|
18 | {L"/b", TypeFlag},
|
---|
19 | {NULL, TypeMax}
|
---|
20 | };
|
---|
21 |
|
---|
22 | /**
|
---|
23 | Function for 'exit' command.
|
---|
24 |
|
---|
25 | @param[in] ImageHandle Handle to the Image (NULL if Internal).
|
---|
26 | @param[in] SystemTable Pointer to the System Table (NULL if Internal).
|
---|
27 | **/
|
---|
28 | SHELL_STATUS
|
---|
29 | EFIAPI
|
---|
30 | ShellCommandRunExit (
|
---|
31 | IN EFI_HANDLE ImageHandle,
|
---|
32 | IN EFI_SYSTEM_TABLE *SystemTable
|
---|
33 | )
|
---|
34 | {
|
---|
35 | EFI_STATUS Status;
|
---|
36 | LIST_ENTRY *Package;
|
---|
37 | CHAR16 *ProblemParam;
|
---|
38 | SHELL_STATUS ShellStatus;
|
---|
39 | UINT64 RetVal;
|
---|
40 | CONST CHAR16 *Return;
|
---|
41 |
|
---|
42 | ShellStatus = SHELL_SUCCESS;
|
---|
43 |
|
---|
44 | //
|
---|
45 | // initialize the shell lib (we must be in non-auto-init...)
|
---|
46 | //
|
---|
47 | Status = ShellInitialize();
|
---|
48 | ASSERT_EFI_ERROR(Status);
|
---|
49 |
|
---|
50 | Status = CommandInit();
|
---|
51 | ASSERT_EFI_ERROR(Status);
|
---|
52 |
|
---|
53 | //
|
---|
54 | // parse the command line
|
---|
55 | //
|
---|
56 | Status = ShellCommandLineParse (ParamList, &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), gShellLevel1HiiHandle, ProblemParam);
|
---|
60 | FreePool(ProblemParam);
|
---|
61 | ShellStatus = SHELL_INVALID_PARAMETER;
|
---|
62 | } else {
|
---|
63 | ASSERT(FALSE);
|
---|
64 | }
|
---|
65 | } else {
|
---|
66 |
|
---|
67 | //
|
---|
68 | // return the specified error code
|
---|
69 | //
|
---|
70 | Return = ShellCommandLineGetRawValue(Package, 1);
|
---|
71 | if (Return != NULL) {
|
---|
72 | Status = ShellConvertStringToUint64(Return, &RetVal, FALSE, FALSE);
|
---|
73 | if (EFI_ERROR(Status)) {
|
---|
74 | ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_PROBLEM), gShellLevel1HiiHandle, Return);
|
---|
75 | ShellStatus = SHELL_INVALID_PARAMETER;
|
---|
76 | } else {
|
---|
77 | //
|
---|
78 | // If we are in a batch file and /b then pass TRUE otherwise false...
|
---|
79 | //
|
---|
80 | ShellCommandRegisterExit((BOOLEAN)(gEfiShellProtocol->BatchIsActive() && ShellCommandLineGetFlag(Package, L"/b")), RetVal);
|
---|
81 |
|
---|
82 | ShellStatus = SHELL_SUCCESS;
|
---|
83 | }
|
---|
84 | } else {
|
---|
85 | // If we are in a batch file and /b then pass TRUE otherwise false...
|
---|
86 | //
|
---|
87 | ShellCommandRegisterExit((BOOLEAN)(gEfiShellProtocol->BatchIsActive() && ShellCommandLineGetFlag(Package, L"/b")), 0);
|
---|
88 |
|
---|
89 | ShellStatus = SHELL_SUCCESS;
|
---|
90 | }
|
---|
91 |
|
---|
92 | ShellCommandLineFreeVarList (Package);
|
---|
93 | }
|
---|
94 | return (ShellStatus);
|
---|
95 | }
|
---|
96 |
|
---|