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