2 Main file for GetMtc shell level 3 function.
4 (C) Copyright 2015 Hewlett-Packard Development Company, L.P.<BR>
5 Copyright (c) 2009 - 2013, 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
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.
16 #include "UefiShellLevel3CommandsLib.h"
18 #include <Library/ShellLib.h>
21 Function for 'getmtc' command.
23 @param[in] ImageHandle Handle to the Image (NULL if Internal).
24 @param[in] SystemTable Pointer to the System Table (NULL if Internal).
28 ShellCommandRunGetMtc (
29 IN EFI_HANDLE ImageHandle
,
30 IN EFI_SYSTEM_TABLE
*SystemTable
36 SHELL_STATUS ShellStatus
;
40 ShellStatus
= SHELL_SUCCESS
;
43 // initialize the shell lib (we must be in non-auto-init...)
45 Status
= ShellInitialize();
46 ASSERT_EFI_ERROR(Status
);
49 // parse the command line
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
), gShellLevel3HiiHandle
, L
"getmtc", ProblemParam
);
55 FreePool(ProblemParam
);
56 ShellStatus
= SHELL_INVALID_PARAMETER
;
64 if (ShellCommandLineGetFlag(Package
, L
"-?")) {
66 } else if (ShellCommandLineGetRawValue(Package
, 1) != NULL
) {
67 ShellPrintHiiEx(-1, -1, NULL
, STRING_TOKEN (STR_GEN_TOO_MANY
), gShellLevel3HiiHandle
, L
"getmtc");
68 ShellStatus
= SHELL_INVALID_PARAMETER
;
71 // Get the monotonic counter count
73 Status
= gBS
->GetNextMonotonicCount(&Mtc
);
74 if (Status
== EFI_DEVICE_ERROR
) {
75 ShellStatus
= SHELL_DEVICE_ERROR
;
76 } else if (Status
== EFI_SECURITY_VIOLATION
) {
77 ShellStatus
= SHELL_SECURITY_VIOLATION
;
78 } else if (EFI_ERROR(Status
)) {
79 ShellStatus
= SHELL_DEVICE_ERROR
;
85 if (ShellStatus
== SHELL_SUCCESS
) {
86 ShellPrintHiiEx(-1, -1, NULL
, STRING_TOKEN (STR_GET_MTC_OUTPUT
), gShellLevel3HiiHandle
, Mtc
);
90 // free the command line package
92 ShellCommandLineFreeVarList (Package
);