TianoCore EDK2 master
Loading...
Searching...
No Matches
GetMtc.c
Go to the documentation of this file.
1
11
12#include <Library/ShellLib.h>
13
21EFIAPI
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 //
85 // free the command line package
86 //
88 }
89
90 return (ShellStatus);
91}
VOID EFIAPI FreePool(IN VOID *Buffer)
SHELL_STATUS EFIAPI ShellCommandRunGetMtc(IN EFI_HANDLE ImageHandle, IN EFI_SYSTEM_TABLE *SystemTable)
Definition: GetMtc.c:22
#define NULL
Definition: Base.h:319
#define TRUE
Definition: Base.h:301
#define FALSE
Definition: Base.h:307
#define IN
Definition: Base.h:279
#define ASSERT_EFI_ERROR(StatusParameter)
Definition: DebugLib.h:462
SHELL_STATUS
Definition: Shell.h:21
@ SHELL_SUCCESS
Definition: Shell.h:25
@ SHELL_DEVICE_ERROR
Definition: Shell.h:63
@ SHELL_SECURITY_VIOLATION
Definition: Shell.h:141
@ SHELL_INVALID_PARAMETER
Definition: Shell.h:35
#define ShellCommandLineParse(CheckList, CheckPackage, ProblemParam, AutoPageBreak)
Make it easy to upgrade from older versions of the shell library.
Definition: ShellLib.h:755
EFI_STATUS EFIAPI ShellPrintHiiEx(IN INT32 Col OPTIONAL, IN INT32 Row OPTIONAL, IN CONST CHAR8 *Language OPTIONAL, IN CONST EFI_STRING_ID HiiFormatStringId, IN CONST EFI_HII_HANDLE HiiFormatHandle,...)
BOOLEAN EFIAPI ShellCommandLineGetFlag(IN CONST LIST_ENTRY *CONST CheckPackage, IN CONST CHAR16 *CONST KeyString)
VOID EFIAPI ShellCommandLineFreeVarList(IN LIST_ENTRY *CheckPackage)
EFI_STATUS EFIAPI ShellInitialize(VOID)
Definition: UefiShellLib.c:532
CONST CHAR16 *EFIAPI ShellCommandLineGetRawValue(IN CONST LIST_ENTRY *CONST CheckPackage, IN UINTN Position)
SHELL_PARAM_ITEM EmptyParamList[]
Helper structure for no parameters (besides -? and -b)
Definition: UefiShellLib.c:19
RETURN_STATUS EFI_STATUS
Definition: UefiBaseType.h:29
VOID * EFI_HANDLE
Definition: UefiBaseType.h:33
EFI_BOOT_SERVICES * gBS
#define STRING_TOKEN(t)