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