2 Main file for GetMtc shell level 3 function.
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
10 #include "UefiShellLevel3CommandsLib.h"
12 #include <Library/ShellLib.h>
15 Function for 'getmtc' command.
17 @param[in] ImageHandle Handle to the Image (NULL if Internal).
18 @param[in] SystemTable Pointer to the System Table (NULL if Internal).
22 ShellCommandRunGetMtc (
23 IN EFI_HANDLE ImageHandle
,
24 IN EFI_SYSTEM_TABLE
*SystemTable
30 SHELL_STATUS ShellStatus
;
34 ShellStatus
= SHELL_SUCCESS
;
37 // initialize the shell lib (we must be in non-auto-init...)
39 Status
= ShellInitialize();
40 ASSERT_EFI_ERROR(Status
);
43 // parse the command line
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
;
58 if (ShellCommandLineGetFlag(Package
, L
"-?")) {
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
;
65 // Get the monotonic counter count
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
;
79 if (ShellStatus
== SHELL_SUCCESS
) {
80 ShellPrintHiiEx(-1, -1, NULL
, STRING_TOKEN (STR_GET_MTC_OUTPUT
), gShellLevel3HiiHandle
, Mtc
);
84 // free the command line package
86 ShellCommandLineFreeVarList (Package
);