1 | /** @file
|
---|
2 | Main file for stall shell level 1 function.
|
---|
3 |
|
---|
4 | Copyright (c) 2011, Intel Corporation. All rights reserved.<BR>
|
---|
5 | This program and the accompanying materials
|
---|
6 | are licensed and made available under the terms and conditions of the BSD License
|
---|
7 | which accompanies this distribution. The full text of the license may be found at
|
---|
8 | http://opensource.org/licenses/bsd-license.php
|
---|
9 |
|
---|
10 | THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
|
---|
11 | WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
|
---|
12 |
|
---|
13 | **/
|
---|
14 |
|
---|
15 | #include "UefiShellLevel1CommandsLib.h"
|
---|
16 |
|
---|
17 | /**
|
---|
18 | Function for 'stall' command.
|
---|
19 |
|
---|
20 | @param[in] ImageHandle Handle to the Image (NULL if Internal).
|
---|
21 | @param[in] SystemTable Pointer to the System Table (NULL if Internal).
|
---|
22 | **/
|
---|
23 | SHELL_STATUS
|
---|
24 | EFIAPI
|
---|
25 | ShellCommandRunStall (
|
---|
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 Intermediate;
|
---|
35 |
|
---|
36 | ShellStatus = SHELL_SUCCESS;
|
---|
37 |
|
---|
38 | //
|
---|
39 | // initialize the shell lib (we must be in non-auto-init...)
|
---|
40 | //
|
---|
41 | Status = ShellInitialize();
|
---|
42 | ASSERT_EFI_ERROR(Status);
|
---|
43 |
|
---|
44 | Status = CommandInit();
|
---|
45 | ASSERT_EFI_ERROR(Status);
|
---|
46 |
|
---|
47 | //
|
---|
48 | // parse the command line
|
---|
49 | //
|
---|
50 | Status = ShellCommandLineParse (EmptyParamList, &Package, &ProblemParam, TRUE);
|
---|
51 | if (EFI_ERROR(Status)) {
|
---|
52 | if (Status == EFI_VOLUME_CORRUPTED && ProblemParam != NULL) {
|
---|
53 | ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_PROBLEM), gShellLevel1HiiHandle, ProblemParam);
|
---|
54 | FreePool(ProblemParam);
|
---|
55 | ShellStatus = SHELL_INVALID_PARAMETER;
|
---|
56 | } else {
|
---|
57 | ASSERT(FALSE);
|
---|
58 | }
|
---|
59 | } else {
|
---|
60 | if (ShellCommandLineGetRawValue(Package, 2) != NULL) {
|
---|
61 | ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_TOO_MANY), gShellLevel1HiiHandle);
|
---|
62 | ShellStatus = SHELL_INVALID_PARAMETER;
|
---|
63 | } else if (ShellCommandLineGetRawValue(Package, 1) == NULL) {
|
---|
64 | ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_TOO_FEW), gShellLevel1HiiHandle);
|
---|
65 | ShellStatus = SHELL_INVALID_PARAMETER;
|
---|
66 | } else {
|
---|
67 | Status = ShellConvertStringToUint64(ShellCommandLineGetRawValue(Package, 1), &Intermediate, FALSE, FALSE);
|
---|
68 | if (EFI_ERROR(Status) || ((UINT64)(UINTN)(Intermediate)) != Intermediate) {
|
---|
69 | ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_PROBLEM_VAL), gShellLevel1HiiHandle, ShellCommandLineGetRawValue(Package, 1));
|
---|
70 | ShellStatus = SHELL_INVALID_PARAMETER;
|
---|
71 | } else {
|
---|
72 | Status = gBS->Stall((UINTN)Intermediate);
|
---|
73 | if (EFI_ERROR(Status)) {
|
---|
74 | ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_STALL_FAILED), gShellLevel1HiiHandle, Status);
|
---|
75 | ShellStatus = SHELL_DEVICE_ERROR;
|
---|
76 | }
|
---|
77 | }
|
---|
78 | }
|
---|
79 | ShellCommandLineFreeVarList (Package);
|
---|
80 | }
|
---|
81 | return (ShellStatus);
|
---|
82 | }
|
---|
83 |
|
---|