1 | /** @file
|
---|
2 | Main file for GetMtc shell level 3 function.
|
---|
3 |
|
---|
4 | (C) Copyright 2015 Hewlett-Packard Development Company, L.P.<BR>
|
---|
5 | Copyright (c) 2009 - 2018, Intel Corporation. All rights reserved. <BR>
|
---|
6 | SPDX-License-Identifier: BSD-2-Clause-Patent
|
---|
7 |
|
---|
8 | **/
|
---|
9 |
|
---|
10 | #include "UefiShellLevel3CommandsLib.h"
|
---|
11 |
|
---|
12 | #include <Library/ShellLib.h>
|
---|
13 |
|
---|
14 | /**
|
---|
15 | Function for 'getmtc' command.
|
---|
16 |
|
---|
17 | @param[in] ImageHandle Handle to the Image (NULL if Internal).
|
---|
18 | @param[in] SystemTable Pointer to the System Table (NULL if Internal).
|
---|
19 | **/
|
---|
20 | SHELL_STATUS
|
---|
21 | EFIAPI
|
---|
22 | ShellCommandRunGetMtc (
|
---|
23 | IN EFI_HANDLE ImageHandle,
|
---|
24 | IN EFI_SYSTEM_TABLE *SystemTable
|
---|
25 | )
|
---|
26 | {
|
---|
27 | EFI_STATUS Status;
|
---|
28 | LIST_ENTRY *Package;
|
---|
29 | CHAR16 *ProblemParam;
|
---|
30 | SHELL_STATUS ShellStatus;
|
---|
31 | UINT64 Mtc;
|
---|
32 |
|
---|
33 | ProblemParam = NULL;
|
---|
34 | ShellStatus = SHELL_SUCCESS;
|
---|
35 |
|
---|
36 | //
|
---|
37 | // initialize the shell lib (we must be in non-auto-init...)
|
---|
38 | //
|
---|
39 | Status = ShellInitialize();
|
---|
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), gShellLevel3HiiHandle, L"getmtc", ProblemParam);
|
---|
49 | FreePool(ProblemParam);
|
---|
50 | ShellStatus = SHELL_INVALID_PARAMETER;
|
---|
51 | } else {
|
---|
52 | ASSERT(FALSE);
|
---|
53 | }
|
---|
54 | } else {
|
---|
55 | //
|
---|
56 | // check for "-?"
|
---|
57 | //
|
---|
58 | if (ShellCommandLineGetFlag(Package, L"-?")) {
|
---|
59 | ASSERT(FALSE);
|
---|
60 | } else if (ShellCommandLineGetRawValue(Package, 1) != NULL) {
|
---|
61 | ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_TOO_MANY), gShellLevel3HiiHandle, L"getmtc");
|
---|
62 | ShellStatus = SHELL_INVALID_PARAMETER;
|
---|
63 | } else {
|
---|
64 | //
|
---|
65 | // Get the monotonic counter count
|
---|
66 | //
|
---|
67 | Status = gBS->GetNextMonotonicCount(&Mtc);
|
---|
68 | if (Status == EFI_DEVICE_ERROR) {
|
---|
69 | ShellStatus = SHELL_DEVICE_ERROR;
|
---|
70 | } else if (Status == EFI_SECURITY_VIOLATION) {
|
---|
71 | ShellStatus = SHELL_SECURITY_VIOLATION;
|
---|
72 | } else if (EFI_ERROR(Status)) {
|
---|
73 | ShellStatus = SHELL_DEVICE_ERROR;
|
---|
74 | }
|
---|
75 |
|
---|
76 | //
|
---|
77 | // print it...
|
---|
78 | //
|
---|
79 | if (ShellStatus == SHELL_SUCCESS) {
|
---|
80 | ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GET_MTC_OUTPUT), gShellLevel3HiiHandle, Mtc);
|
---|
81 | }
|
---|
82 | }
|
---|
83 | //
|
---|
84 | // free the command line package
|
---|
85 | //
|
---|
86 | ShellCommandLineFreeVarList (Package);
|
---|
87 | }
|
---|
88 |
|
---|
89 | return (ShellStatus);
|
---|
90 | }
|
---|
91 |
|
---|