TianoCore EDK2 master
Loading...
Searching...
No Matches
Pause.c
Go to the documentation of this file.
1
11
12STATIC CONST SHELL_PARAM_ITEM ParamList[] = {
13 { L"-q", 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;
35
36 ProblemParam = NULL;
37 ShellStatus = SHELL_SUCCESS;
38 Resp = NULL;
39
40 //
41 // initialize the shell lib (we must be in non-auto-init...)
42 //
43 Status = ShellInitialize ();
44 ASSERT_EFI_ERROR (Status);
45
46 Status = CommandInit ();
47 ASSERT_EFI_ERROR (Status);
48
49 if (!gEfiShellProtocol->BatchIsActive ()) {
50 ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_NO_SCRIPT), gShellLevel3HiiHandle, L"pause");
51 return (SHELL_UNSUPPORTED);
52 }
53
54 //
55 // parse the command line
56 //
57 Status = ShellCommandLineParse (ParamList, &Package, &ProblemParam, TRUE);
58 if (EFI_ERROR (Status)) {
59 if ((Status == EFI_VOLUME_CORRUPTED) && (ProblemParam != NULL)) {
60 ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_GEN_PROBLEM), gShellLevel3HiiHandle, L"pause", ProblemParam);
61 FreePool (ProblemParam);
62 ShellStatus = SHELL_INVALID_PARAMETER;
63 } else {
64 ASSERT (FALSE);
65 }
66 } else {
67 //
68 // check for "-?"
69 //
70 if (ShellCommandLineGetFlag (Package, L"-?")) {
71 ASSERT (FALSE);
72 } else if (ShellCommandLineGetRawValue (Package, 1) != NULL) {
73 ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_GEN_TOO_MANY), gShellLevel3HiiHandle, L"pause");
74 ShellStatus = SHELL_INVALID_PARAMETER;
75 } else {
76 if (!ShellCommandLineGetFlag (Package, L"-q")) {
77 Status = ShellPromptForResponseHii (ShellPromptResponseTypeQuitContinue, STRING_TOKEN (STR_PAUSE_PROMPT), gShellLevel3HiiHandle, (VOID **)&Resp);
78 } else {
79 Status = ShellPromptForResponse (ShellPromptResponseTypeQuitContinue, NULL, (VOID **)&Resp);
80 }
81
82 if (EFI_ERROR (Status) || (Resp == NULL) || (*Resp == ShellPromptResponseQuit)) {
84 ShellStatus = SHELL_ABORTED;
85 }
86
87 if (Resp != NULL) {
88 FreePool (Resp);
89 }
90 }
91
92 //
93 // free the command line package
94 //
96 }
97
98 return (ShellStatus);
99}
VOID EFIAPI FreePool(IN VOID *Buffer)
#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_ABORTED
Definition: Shell.h:128
@ SHELL_SUCCESS
Definition: Shell.h:25
@ SHELL_UNSUPPORTED
Definition: Shell.h:40
@ SHELL_INVALID_PARAMETER
Definition: Shell.h:35
SHELL_STATUS EFIAPI ShellCommandRunPause(IN EFI_HANDLE ImageHandle, IN EFI_SYSTEM_TABLE *SystemTable)
Definition: Pause.c:25
EFI_STATUS EFIAPI CommandInit(VOID)
VOID EFIAPI ShellCommandRegisterExit(IN BOOLEAN ScriptOnly, IN CONST UINT64 ErrorCode)
EFI_STATUS EFIAPI ShellPromptForResponseHii(IN SHELL_PROMPT_REQUEST_TYPE Type, IN CONST EFI_STRING_ID HiiFormatStringId, IN CONST EFI_HII_HANDLE HiiFormatHandle, IN OUT VOID **Response)
#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
EFI_STATUS EFIAPI ShellPromptForResponse(IN SHELL_PROMPT_REQUEST_TYPE Type, IN CHAR16 *Prompt OPTIONAL, IN OUT VOID **Response OPTIONAL)
SHELL_PROMPT_RESPONSE
Definition: ShellLib.h:1198
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)
RETURN_STATUS EFI_STATUS
Definition: UefiBaseType.h:29
VOID * EFI_HANDLE
Definition: UefiBaseType.h:33
#define STRING_TOKEN(t)