Vishal Bhoj | 82c8071 | 2015-12-15 21:13:33 +0530 | [diff] [blame^] | 1 | /** @file
|
| 2 | Main file for stall shell level 1 function.
|
| 3 |
|
| 4 | (C) Copyright 2015 Hewlett-Packard Development Company, L.P.<BR>
|
| 5 | Copyright (c) 2011, 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 "UefiShellLevel1CommandsLib.h"
|
| 17 |
|
| 18 | /**
|
| 19 | Function for 'stall' command.
|
| 20 |
|
| 21 | @param[in] ImageHandle Handle to the Image (NULL if Internal).
|
| 22 | @param[in] SystemTable Pointer to the System Table (NULL if Internal).
|
| 23 | **/
|
| 24 | SHELL_STATUS
|
| 25 | EFIAPI
|
| 26 | ShellCommandRunStall (
|
| 27 | IN EFI_HANDLE ImageHandle,
|
| 28 | IN EFI_SYSTEM_TABLE *SystemTable
|
| 29 | )
|
| 30 | {
|
| 31 | EFI_STATUS Status;
|
| 32 | LIST_ENTRY *Package;
|
| 33 | CHAR16 *ProblemParam;
|
| 34 | SHELL_STATUS ShellStatus;
|
| 35 | UINT64 Intermediate;
|
| 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 (EmptyParamList, &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"stall", ProblemParam);
|
| 55 | FreePool(ProblemParam);
|
| 56 | ShellStatus = SHELL_INVALID_PARAMETER;
|
| 57 | } else {
|
| 58 | ASSERT(FALSE);
|
| 59 | }
|
| 60 | } else {
|
| 61 | if (ShellCommandLineGetRawValue(Package, 2) != NULL) {
|
| 62 | ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_TOO_MANY), gShellLevel1HiiHandle, L"stall");
|
| 63 | ShellStatus = SHELL_INVALID_PARAMETER;
|
| 64 | } else if (ShellCommandLineGetRawValue(Package, 1) == NULL) {
|
| 65 | ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_TOO_FEW), gShellLevel1HiiHandle, L"stall");
|
| 66 | ShellStatus = SHELL_INVALID_PARAMETER;
|
| 67 | } else {
|
| 68 | Status = ShellConvertStringToUint64(ShellCommandLineGetRawValue(Package, 1), &Intermediate, FALSE, FALSE);
|
| 69 | if (EFI_ERROR(Status) || ((UINT64)(UINTN)(Intermediate)) != Intermediate) {
|
| 70 | ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_PARAM_INV), gShellLevel1HiiHandle, L"stall", ShellCommandLineGetRawValue(Package, 1));
|
| 71 | ShellStatus = SHELL_INVALID_PARAMETER;
|
| 72 | } else {
|
| 73 | Status = gBS->Stall((UINTN)Intermediate);
|
| 74 | if (EFI_ERROR(Status)) {
|
| 75 | ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_STALL_FAILED), gShellLevel1HiiHandle, L"stall");
|
| 76 | ShellStatus = SHELL_DEVICE_ERROR;
|
| 77 | }
|
| 78 | }
|
| 79 | }
|
| 80 | ShellCommandLineFreeVarList (Package);
|
| 81 | }
|
| 82 | return (ShellStatus);
|
| 83 | }
|
| 84 |
|