]> git.proxmox.com Git - mirror_edk2.git/blame - ShellPkg/Library/UefiShellLevel3CommandsLib/GetMtc.c
Update Code to pass EBC compiler.
[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
cbcccd2c 4 Copyright (c) 2009 - 2013, Intel Corporation. All rights reserved. <BR>\r
a405b86d 5 This program and the accompanying materials\r
6 are licensed and made available under the terms and conditions of the BSD License\r
7 which accompanies this distribution. The full text of the license may be found at\r
8 http://opensource.org/licenses/bsd-license.php\r
9\r
10 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
11 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
12\r
13**/\r
14\r
15#include "UefiShellLevel3CommandsLib.h"\r
16\r
17#include <Library/ShellLib.h>\r
18\r
19/**\r
20 Function for 'getmtc' command.\r
21\r
22 @param[in] ImageHandle Handle to the Image (NULL if Internal).\r
23 @param[in] SystemTable Pointer to the System Table (NULL if Internal).\r
24**/\r
25SHELL_STATUS\r
26EFIAPI\r
27ShellCommandRunGetMtc (\r
28 IN EFI_HANDLE ImageHandle,\r
29 IN EFI_SYSTEM_TABLE *SystemTable\r
30 )\r
31{\r
32 EFI_STATUS Status;\r
33 LIST_ENTRY *Package;\r
34 CHAR16 *ProblemParam;\r
35 SHELL_STATUS ShellStatus;\r
36 UINT64 Mtc;\r
37\r
38 ProblemParam = NULL;\r
39 ShellStatus = SHELL_SUCCESS;\r
40\r
41 //\r
42 // initialize the shell lib (we must be in non-auto-init...)\r
43 //\r
44 Status = ShellInitialize();\r
45 ASSERT_EFI_ERROR(Status);\r
46\r
47 //\r
48 // parse the command line\r
49 //\r
50 Status = ShellCommandLineParse (EmptyParamList, &Package, &ProblemParam, TRUE);\r
51 if (EFI_ERROR(Status)) {\r
52 if (Status == EFI_VOLUME_CORRUPTED && ProblemParam != NULL) {\r
53 ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_PROBLEM), gShellLevel3HiiHandle, ProblemParam);\r
54 FreePool(ProblemParam);\r
55 ShellStatus = SHELL_INVALID_PARAMETER;\r
56 } else {\r
57 ASSERT(FALSE);\r
58 }\r
59 } else {\r
60 //\r
61 // check for "-?"\r
62 //\r
63 if (ShellCommandLineGetFlag(Package, L"-?")) {\r
64 ASSERT(FALSE);\r
65 } else if (ShellCommandLineGetRawValue(Package, 1) != NULL) {\r
66 ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_TOO_MANY), gShellLevel3HiiHandle);\r
67 ShellStatus = SHELL_INVALID_PARAMETER;\r
68 } else {\r
69 //\r
70 // Get the monotonic counter count\r
71 //\r
72 Status = gBS->GetNextMonotonicCount(&Mtc);\r
cbcccd2c
LG
73 if (Status == EFI_DEVICE_ERROR) {\r
74 ShellStatus = SHELL_DEVICE_ERROR;\r
75 } else if (Status == EFI_SECURITY_VIOLATION) {\r
76 ShellStatus = SHELL_SECURITY_VIOLATION;\r
77 } else if (EFI_ERROR(Status)) {\r
78 ShellStatus = SHELL_DEVICE_ERROR;\r
a405b86d 79 }\r
80\r
81 //\r
82 // print it...\r
83 //\r
84 if (ShellStatus == SHELL_SUCCESS) {\r
85 ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GET_MTC_OUTPUT), gShellLevel3HiiHandle, Mtc);\r
86 }\r
87 }\r
88 //\r
89 // free the command line package\r
90 //\r
91 ShellCommandLineFreeVarList (Package);\r
92 }\r
93\r
94 return (ShellStatus);\r
95}\r
96\r