Vishal Bhoj | 82c8071 | 2015-12-15 21:13:33 +0530 | [diff] [blame^] | 1 | /** @file
|
| 2 | Main file for GetMtc shell level 3 function.
|
| 3 |
|
| 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
|
| 10 |
|
| 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.
|
| 13 |
|
| 14 | **/
|
| 15 |
|
| 16 | #include "UefiShellLevel3CommandsLib.h"
|
| 17 |
|
| 18 | #include <Library/ShellLib.h>
|
| 19 |
|
| 20 | /**
|
| 21 | Function for 'getmtc' command.
|
| 22 |
|
| 23 | @param[in] ImageHandle Handle to the Image (NULL if Internal).
|
| 24 | @param[in] SystemTable Pointer to the System Table (NULL if Internal).
|
| 25 | **/
|
| 26 | SHELL_STATUS
|
| 27 | EFIAPI
|
| 28 | ShellCommandRunGetMtc (
|
| 29 | IN EFI_HANDLE ImageHandle,
|
| 30 | IN EFI_SYSTEM_TABLE *SystemTable
|
| 31 | )
|
| 32 | {
|
| 33 | EFI_STATUS Status;
|
| 34 | LIST_ENTRY *Package;
|
| 35 | CHAR16 *ProblemParam;
|
| 36 | SHELL_STATUS ShellStatus;
|
| 37 | UINT64 Mtc;
|
| 38 |
|
| 39 | ProblemParam = NULL;
|
| 40 | ShellStatus = SHELL_SUCCESS;
|
| 41 |
|
| 42 | //
|
| 43 | // initialize the shell lib (we must be in non-auto-init...)
|
| 44 | //
|
| 45 | Status = ShellInitialize();
|
| 46 | ASSERT_EFI_ERROR(Status);
|
| 47 |
|
| 48 | //
|
| 49 | // parse the command line
|
| 50 | //
|
| 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;
|
| 57 | } else {
|
| 58 | ASSERT(FALSE);
|
| 59 | }
|
| 60 | } else {
|
| 61 | //
|
| 62 | // check for "-?"
|
| 63 | //
|
| 64 | if (ShellCommandLineGetFlag(Package, L"-?")) {
|
| 65 | ASSERT(FALSE);
|
| 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;
|
| 69 | } else {
|
| 70 | //
|
| 71 | // Get the monotonic counter count
|
| 72 | //
|
| 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;
|
| 80 | }
|
| 81 |
|
| 82 | //
|
| 83 | // print it...
|
| 84 | //
|
| 85 | if (ShellStatus == SHELL_SUCCESS) {
|
| 86 | ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GET_MTC_OUTPUT), gShellLevel3HiiHandle, Mtc);
|
| 87 | }
|
| 88 | }
|
| 89 | //
|
| 90 | // free the command line package
|
| 91 | //
|
| 92 | ShellCommandLineFreeVarList (Package);
|
| 93 | }
|
| 94 |
|
| 95 | return (ShellStatus);
|
| 96 | }
|
| 97 |
|