TianoCore EDK2 master
Loading...
Searching...
No Matches
Exit.c
Go to the documentation of this file.
1
11
12STATIC CONST SHELL_PARAM_ITEM ParamList[] = {
13 { L"/b", TypeFlag },
14 { NULL, TypeMax }
15};
16
24EFIAPI
26 IN EFI_HANDLE ImageHandle,
27 IN EFI_SYSTEM_TABLE *SystemTable
28 )
29{
30 EFI_STATUS Status;
31 LIST_ENTRY *Package;
32 CHAR16 *ProblemParam;
33 SHELL_STATUS ShellStatus;
34 UINT64 RetVal;
35 CONST CHAR16 *Return;
36
37 ShellStatus = SHELL_SUCCESS;
38
39 //
40 // initialize the shell lib (we must be in non-auto-init...)
41 //
42 Status = ShellInitialize ();
43 ASSERT_EFI_ERROR (Status);
44
45 Status = CommandInit ();
46 ASSERT_EFI_ERROR (Status);
47
48 //
49 // parse the command line
50 //
51 Status = ShellCommandLineParse (ParamList, &Package, &ProblemParam, TRUE);
52 if (EFI_ERROR (Status)) {
53 if ((Status == EFI_VOLUME_CORRUPTED) && (ProblemParam != NULL)) {
54 ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_GEN_PROBLEM), gShellLevel1HiiHandle, L"exit", ProblemParam);
55 FreePool (ProblemParam);
56 ShellStatus = SHELL_INVALID_PARAMETER;
57 } else {
58 ASSERT (FALSE);
59 }
60 } else {
61 //
62 // return the specified error code
63 //
64 Return = ShellCommandLineGetRawValue (Package, 1);
65 if (Return != NULL) {
66 Status = ShellConvertStringToUint64 (Return, &RetVal, FALSE, FALSE);
67 if (EFI_ERROR (Status)) {
68 ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_GEN_PARAM_INV), gShellLevel1HiiHandle, L"exit", Return);
69 ShellStatus = SHELL_INVALID_PARAMETER;
70 } else {
71 //
72 // If we are in a batch file and /b then pass TRUE otherwise false...
73 //
74 ShellCommandRegisterExit ((BOOLEAN)(gEfiShellProtocol->BatchIsActive () && ShellCommandLineGetFlag (Package, L"/b")), RetVal);
75
76 ShellStatus = SHELL_SUCCESS;
77 }
78 } else {
79 // If we are in a batch file and /b then pass TRUE otherwise false...
80 //
81 ShellCommandRegisterExit ((BOOLEAN)(gEfiShellProtocol->BatchIsActive () && ShellCommandLineGetFlag (Package, L"/b")), 0);
82
83 ShellStatus = SHELL_SUCCESS;
84 }
85
87 }
88
89 return (ShellStatus);
90}
VOID EFIAPI FreePool(IN VOID *Buffer)
SHELL_STATUS EFIAPI ShellCommandRunExit(IN EFI_HANDLE ImageHandle, IN EFI_SYSTEM_TABLE *SystemTable)
Definition: Exit.c:25
#define NULL
Definition: Base.h:319
#define CONST
Definition: Base.h:259
#define STATIC
Definition: Base.h:264
#define TRUE
Definition: Base.h:301
#define FALSE
Definition: Base.h:307
#define IN
Definition: Base.h:279
#define ASSERT_EFI_ERROR(StatusParameter)
Definition: DebugLib.h:462
SHELL_STATUS
Definition: Shell.h:21
@ SHELL_SUCCESS
Definition: Shell.h:25
@ SHELL_INVALID_PARAMETER
Definition: Shell.h:35
EFI_STATUS EFIAPI CommandInit(VOID)
VOID EFIAPI ShellCommandRegisterExit(IN BOOLEAN ScriptOnly, IN CONST UINT64 ErrorCode)
#define ShellCommandLineParse(CheckList, CheckPackage, ProblemParam, AutoPageBreak)
Make it easy to upgrade from older versions of the shell library.
Definition: ShellLib.h:755
EFI_STATUS EFIAPI ShellPrintHiiEx(IN INT32 Col OPTIONAL, IN INT32 Row OPTIONAL, IN CONST CHAR8 *Language OPTIONAL, IN CONST EFI_STRING_ID HiiFormatStringId, IN CONST EFI_HII_HANDLE HiiFormatHandle,...)
BOOLEAN EFIAPI ShellCommandLineGetFlag(IN CONST LIST_ENTRY *CONST CheckPackage, IN CONST CHAR16 *CONST KeyString)
@ TypeFlag
A flag that is present or not present only (IE "-a").
Definition: ShellLib.h:699
VOID EFIAPI ShellCommandLineFreeVarList(IN LIST_ENTRY *CheckPackage)
EFI_STATUS EFIAPI ShellInitialize(VOID)
Definition: UefiShellLib.c:532
CONST CHAR16 *EFIAPI ShellCommandLineGetRawValue(IN CONST LIST_ENTRY *CONST CheckPackage, IN UINTN Position)
EFI_STATUS EFIAPI ShellConvertStringToUint64(IN CONST CHAR16 *String, OUT UINT64 *Value, IN CONST BOOLEAN ForceHex, IN CONST BOOLEAN StopAtSpace)
RETURN_STATUS EFI_STATUS
Definition: UefiBaseType.h:29
VOID * EFI_HANDLE
Definition: UefiBaseType.h:33
#define STRING_TOKEN(t)