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 - 2018, Intel Corporation. All rights reserved.<BR>
|
---|
6 | SPDX-License-Identifier: BSD-2-Clause-Patent
|
---|
7 |
|
---|
8 | **/
|
---|
9 |
|
---|
10 | #include "UefiShellLevel1CommandsLib.h"
|
---|
11 |
|
---|
12 | /**
|
---|
13 | Function for 'stall' command.
|
---|
14 |
|
---|
15 | @param[in] ImageHandle Handle to the Image (NULL if Internal).
|
---|
16 | @param[in] SystemTable Pointer to the System Table (NULL if Internal).
|
---|
17 | **/
|
---|
18 | SHELL_STATUS
|
---|
19 | EFIAPI
|
---|
20 | ShellCommandRunStall (
|
---|
21 | IN EFI_HANDLE ImageHandle,
|
---|
22 | IN EFI_SYSTEM_TABLE *SystemTable
|
---|
23 | )
|
---|
24 | {
|
---|
25 | EFI_STATUS Status;
|
---|
26 | LIST_ENTRY *Package;
|
---|
27 | CHAR16 *ProblemParam;
|
---|
28 | SHELL_STATUS ShellStatus;
|
---|
29 | UINT64 Intermediate;
|
---|
30 |
|
---|
31 | ShellStatus = SHELL_SUCCESS;
|
---|
32 |
|
---|
33 | //
|
---|
34 | // initialize the shell lib (we must be in non-auto-init...)
|
---|
35 | //
|
---|
36 | Status = ShellInitialize ();
|
---|
37 | ASSERT_EFI_ERROR (Status);
|
---|
38 |
|
---|
39 | Status = CommandInit ();
|
---|
40 | ASSERT_EFI_ERROR (Status);
|
---|
41 |
|
---|
42 | //
|
---|
43 | // parse the command line
|
---|
44 | //
|
---|
45 | Status = ShellCommandLineParse (EmptyParamList, &Package, &ProblemParam, TRUE);
|
---|
46 | if (EFI_ERROR (Status)) {
|
---|
47 | if ((Status == EFI_VOLUME_CORRUPTED) && (ProblemParam != NULL)) {
|
---|
48 | ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_GEN_PROBLEM), gShellLevel1HiiHandle, L"stall", ProblemParam);
|
---|
49 | FreePool (ProblemParam);
|
---|
50 | ShellStatus = SHELL_INVALID_PARAMETER;
|
---|
51 | } else {
|
---|
52 | ASSERT (FALSE);
|
---|
53 | }
|
---|
54 | } else {
|
---|
55 | if (ShellCommandLineGetRawValue (Package, 2) != NULL) {
|
---|
56 | ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_GEN_TOO_MANY), gShellLevel1HiiHandle, L"stall");
|
---|
57 | ShellStatus = SHELL_INVALID_PARAMETER;
|
---|
58 | } else if (ShellCommandLineGetRawValue (Package, 1) == NULL) {
|
---|
59 | ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_GEN_TOO_FEW), gShellLevel1HiiHandle, L"stall");
|
---|
60 | ShellStatus = SHELL_INVALID_PARAMETER;
|
---|
61 | } else {
|
---|
62 | Status = ShellConvertStringToUint64 (ShellCommandLineGetRawValue (Package, 1), &Intermediate, FALSE, FALSE);
|
---|
63 | if (EFI_ERROR (Status) || (((UINT64)(UINTN)(Intermediate)) != Intermediate)) {
|
---|
64 | ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_GEN_PARAM_INV), gShellLevel1HiiHandle, L"stall", ShellCommandLineGetRawValue (Package, 1));
|
---|
65 | ShellStatus = SHELL_INVALID_PARAMETER;
|
---|
66 | } else {
|
---|
67 | Status = gBS->Stall ((UINTN)Intermediate);
|
---|
68 | if (EFI_ERROR (Status)) {
|
---|
69 | ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_STALL_FAILED), gShellLevel1HiiHandle, L"stall");
|
---|
70 | ShellStatus = SHELL_DEVICE_ERROR;
|
---|
71 | }
|
---|
72 | }
|
---|
73 | }
|
---|
74 |
|
---|
75 | ShellCommandLineFreeVarList (Package);
|
---|
76 | }
|
---|
77 |
|
---|
78 | return (ShellStatus);
|
---|
79 | }
|
---|