1 /** @file 2 Main file for Pause shell level 3 function. 3 4 (C) Copyright 2015 Hewlett-Packard Development Company, L.P.<BR> 5 Copyright (c) 2009 - 2014, Intel Corporation. All rights reserved. <BR> 6 This program and the accompanying materials 7 are licensed and made available under the terms and conditions of the BSD License 8 which accompanies this distribution. The full text of the license may be found at 9 http://opensource.org/licenses/bsd-license.php 10 11 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, 12 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. 13 14 **/ 15 16 #include "UefiShellLevel3CommandsLib.h" 17 18 STATIC CONST SHELL_PARAM_ITEM ParamList[] = { 19 {L"-q", TypeFlag}, 20 {NULL, TypeMax} 21 }; 22 23 /** 24 Function for 'pause' command. 25 26 @param[in] ImageHandle Handle to the Image (NULL if Internal). 27 @param[in] SystemTable Pointer to the System Table (NULL if Internal). 28 **/ 29 SHELL_STATUS 30 EFIAPI 31 ShellCommandRunPause ( 32 IN EFI_HANDLE ImageHandle, 33 IN EFI_SYSTEM_TABLE *SystemTable 34 ) 35 { 36 EFI_STATUS Status; 37 LIST_ENTRY *Package; 38 CHAR16 *ProblemParam; 39 SHELL_STATUS ShellStatus; 40 SHELL_PROMPT_RESPONSE *Resp; 41 42 ProblemParam = NULL; 43 ShellStatus = SHELL_SUCCESS; 44 Resp = NULL; 45 46 // 47 // initialize the shell lib (we must be in non-auto-init...) 48 // 49 Status = ShellInitialize(); 50 ASSERT_EFI_ERROR(Status); 51 52 Status = CommandInit(); 53 ASSERT_EFI_ERROR(Status); 54 55 if (!gEfiShellProtocol->BatchIsActive()) { 56 ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_NO_SCRIPT), gShellLevel3HiiHandle, L"pause"); 57 return (SHELL_UNSUPPORTED); 58 } 59 60 // 61 // parse the command line 62 // 63 Status = ShellCommandLineParse (ParamList, &Package, &ProblemParam, TRUE); 64 if (EFI_ERROR(Status)) { 65 if (Status == EFI_VOLUME_CORRUPTED && ProblemParam != NULL) { 66 ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_PROBLEM), gShellLevel3HiiHandle, L"pause", ProblemParam); 67 FreePool(ProblemParam); 68 ShellStatus = SHELL_INVALID_PARAMETER; 69 } else { 70 ASSERT(FALSE); 71 } 72 } else { 73 // 74 // check for "-?" 75 // 76 if (ShellCommandLineGetFlag(Package, L"-?")) { 77 ASSERT(FALSE); 78 } else if (ShellCommandLineGetRawValue(Package, 1) != NULL) { 79 ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_TOO_MANY), gShellLevel3HiiHandle, L"pause"); 80 ShellStatus = SHELL_INVALID_PARAMETER; 81 } else { 82 if (!ShellCommandLineGetFlag(Package, L"-q")) { 83 Status = ShellPromptForResponseHii(ShellPromptResponseTypeQuitContinue, STRING_TOKEN (STR_PAUSE_PROMPT), gShellLevel3HiiHandle, (VOID**)&Resp); 84 } else { 85 Status = ShellPromptForResponse(ShellPromptResponseTypeQuitContinue, NULL, (VOID**)&Resp); 86 } 87 88 if (EFI_ERROR(Status) || Resp == NULL || *Resp == ShellPromptResponseQuit) { 89 ShellCommandRegisterExit(TRUE, 0); 90 ShellStatus = SHELL_ABORTED; 91 } 92 93 if (Resp != NULL) { 94 FreePool(Resp); 95 } 96 } 97 98 // 99 // free the command line package 100 // 101 ShellCommandLineFreeVarList (Package); 102 } 103 104 105 return (ShellStatus); 106 } 107 108