1 /** @file
2 Main file for Ver shell level 3 function.
3
4 (C) Copyright 2016 Hewlett Packard Enterprise Development LP<BR>
5 (C) Copyright 2013-2015 Hewlett-Packard Development Company, L.P.<BR>
6 Copyright (c) 2009 - 2010, Intel Corporation. All rights reserved.<BR>
7 This program and the accompanying materials
8 are licensed and made available under the terms and conditions of the BSD License
9 which accompanies this distribution. The full text of the license may be found at
10 http://opensource.org/licenses/bsd-license.php
11
12 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
13 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
14
15 **/
16
17 #include "UefiShellLevel3CommandsLib.h"
18
19 #include <Library/ShellLib.h>
20
21 STATIC CONST SHELL_PARAM_ITEM ParamList[] = {
22 {L"-s", TypeFlag},
23 {L"-terse", TypeFlag},
24 {L"-t", TypeFlag},
25 {L"-_pa", TypeFlag},
26 {NULL, TypeMax}
27 };
28
29 /**
30 Function for 'ver' command.
31
32 @param[in] ImageHandle Handle to the Image (NULL if Internal).
33 @param[in] SystemTable Pointer to the System Table (NULL if Internal).
34 **/
35 SHELL_STATUS
36 EFIAPI
ShellCommandRunVer(IN EFI_HANDLE ImageHandle,IN EFI_SYSTEM_TABLE * SystemTable)37 ShellCommandRunVer (
38 IN EFI_HANDLE ImageHandle,
39 IN EFI_SYSTEM_TABLE *SystemTable
40 )
41 {
42 EFI_STATUS Status;
43 LIST_ENTRY *Package;
44 CHAR16 *ProblemParam;
45 SHELL_STATUS ShellStatus;
46 UINT8 Level;
47
48 Level = PcdGet8(PcdShellSupportLevel);
49 ProblemParam = NULL;
50 ShellStatus = SHELL_SUCCESS;
51
52 //
53 // initialize the shell lib (we must be in non-auto-init...)
54 //
55 Status = ShellInitialize();
56 ASSERT_EFI_ERROR(Status);
57
58 Status = CommandInit();
59 ASSERT_EFI_ERROR(Status);
60
61 //
62 // parse the command line
63 //
64 Status = ShellCommandLineParse (ParamList, &Package, &ProblemParam, TRUE);
65 if (EFI_ERROR(Status)) {
66 if (Status == EFI_VOLUME_CORRUPTED && ProblemParam != NULL) {
67 ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_PROBLEM), gShellLevel3HiiHandle, L"ver", ProblemParam);
68 FreePool(ProblemParam);
69 ShellStatus = SHELL_INVALID_PARAMETER;
70 } else {
71 ASSERT(FALSE);
72 }
73 } else {
74 //
75 // check for "-?"
76 //
77 if (ShellCommandLineGetFlag(Package, L"-?")) {
78 ASSERT(FALSE);
79 }
80 if (ShellCommandLineGetRawValue(Package, 1) != NULL) {
81 //
82 // we have too many parameters
83 //
84 ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_TOO_MANY), gShellLevel3HiiHandle, L"ver");
85 ShellStatus = SHELL_INVALID_PARAMETER;
86 } else {
87 if (ShellCommandLineGetFlag(Package, L"-s")) {
88 if (ShellCommandLineGetFlag(Package, L"-terse") || ShellCommandLineGetFlag(Package, L"-t")){
89 ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_PARAM_CONFLICT), gShellLevel3HiiHandle, L"ver", L"-t or -terse", L"-s");
90 ShellStatus = SHELL_INVALID_PARAMETER;
91 } else {
92 ShellPrintHiiEx (
93 0,
94 gST->ConOut->Mode->CursorRow,
95 NULL,
96 STRING_TOKEN (STR_VER_OUTPUT_SIMPLE),
97 gShellLevel3HiiHandle,
98 gEfiShellProtocol->MajorVersion,
99 gEfiShellProtocol->MinorVersion
100 );
101 }
102 } else {
103 ShellPrintHiiEx (
104 0,
105 gST->ConOut->Mode->CursorRow,
106 NULL,
107 STRING_TOKEN (STR_VER_OUTPUT_SHELL),
108 gShellLevel3HiiHandle,
109 SupportLevel[Level],
110 gEfiShellProtocol->MajorVersion,
111 gEfiShellProtocol->MinorVersion
112 );
113 if (!ShellCommandLineGetFlag(Package, L"-terse") && !ShellCommandLineGetFlag(Package, L"-t")){
114 ShellPrintHiiEx(
115 -1,
116 -1,
117 NULL,
118 STRING_TOKEN (STR_VER_OUTPUT_SUPPLIER),
119 gShellLevel3HiiHandle,
120 (CHAR16 *) PcdGetPtr (PcdShellSupplier)
121 );
122
123
124 ShellPrintHiiEx (
125 -1,
126 -1,
127 NULL,
128 STRING_TOKEN (STR_VER_OUTPUT_UEFI),
129 gShellLevel3HiiHandle,
130 (gST->Hdr.Revision&0xffff0000)>>16,
131 (gST->Hdr.Revision&0x0000ffff),
132 gST->FirmwareVendor,
133 gST->FirmwareRevision
134 );
135 }
136 }
137 //
138 // implementation specific support for displaying processor architecture
139 //
140 if (ShellCommandLineGetFlag(Package, L"-_pa")) {
141 ShellPrintEx(-1, -1, L"%d\r\n", sizeof(UINTN)==sizeof(UINT64)?64:32);
142 }
143 }
144
145 //
146 // free the command line package
147 //
148 ShellCommandLineFreeVarList (Package);
149 }
150
151 return (ShellStatus);
152 }
153
154