1 /** @file
2 Main file for Ver shell level 3 function.
3
4 Copyright (c) 2013, Hewlett-Packard Development Company, L.P.
5 Copyright (c) 2009 - 2010, 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 STATIC CONST SHELL_PARAM_ITEM ParamList[] = {
21 {L"-s", TypeFlag},
22 {L"-terse", TypeFlag},
23 {L"-t", TypeFlag},
24 {L"-_pa", TypeFlag},
25 {NULL, TypeMax}
26 };
27
28 /**
29 Function for 'ver' command.
30
31 @param[in] ImageHandle Handle to the Image (NULL if Internal).
32 @param[in] SystemTable Pointer to the System Table (NULL if Internal).
33 **/
34 SHELL_STATUS
35 EFIAPI
ShellCommandRunVer(IN EFI_HANDLE ImageHandle,IN EFI_SYSTEM_TABLE * SystemTable)36 ShellCommandRunVer (
37 IN EFI_HANDLE ImageHandle,
38 IN EFI_SYSTEM_TABLE *SystemTable
39 )
40 {
41 EFI_STATUS Status;
42 LIST_ENTRY *Package;
43 CHAR16 *ProblemParam;
44 SHELL_STATUS ShellStatus;
45 UINT8 Level;
46
47 Level = PcdGet8(PcdShellSupportLevel);
48 ProblemParam = NULL;
49 ShellStatus = SHELL_SUCCESS;
50
51 //
52 // initialize the shell lib (we must be in non-auto-init...)
53 //
54 Status = ShellInitialize();
55 ASSERT_EFI_ERROR(Status);
56
57 Status = CommandInit();
58 ASSERT_EFI_ERROR(Status);
59
60 //
61 // parse the command line
62 //
63 Status = ShellCommandLineParse (ParamList, &Package, &ProblemParam, TRUE);
64 if (EFI_ERROR(Status)) {
65 if (Status == EFI_VOLUME_CORRUPTED && ProblemParam != NULL) {
66 ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_PROBLEM), gShellLevel3HiiHandle, ProblemParam);
67 FreePool(ProblemParam);
68 ShellStatus = SHELL_INVALID_PARAMETER;
69 } else {
70 ASSERT(FALSE);
71 }
72 } else {
73 //
74 // check for "-?"
75 //
76 if (ShellCommandLineGetFlag(Package, L"-?")) {
77 ASSERT(FALSE);
78 }
79 if (ShellCommandLineGetRawValue(Package, 1) != NULL) {
80 //
81 // we have too many parameters
82 //
83 ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_TOO_MANY), gShellLevel3HiiHandle);
84 ShellStatus = SHELL_INVALID_PARAMETER;
85 } else {
86 if (ShellCommandLineGetFlag(Package, L"-s")) {
87 ShellPrintHiiEx (
88 0,
89 gST->ConOut->Mode->CursorRow,
90 NULL,
91 STRING_TOKEN (STR_VER_OUTPUT_SIMPLE),
92 gShellLevel3HiiHandle,
93 gEfiShellProtocol->MajorVersion,
94 gEfiShellProtocol->MinorVersion
95 );
96 } else {
97 ShellPrintHiiEx (
98 0,
99 gST->ConOut->Mode->CursorRow,
100 NULL,
101 STRING_TOKEN (STR_VER_OUTPUT_SHELL),
102 gShellLevel3HiiHandle,
103 SupportLevel[Level],
104 gEfiShellProtocol->MajorVersion,
105 gEfiShellProtocol->MinorVersion
106 );
107 if (!ShellCommandLineGetFlag(Package, L"-terse") && !ShellCommandLineGetFlag(Package, L"-t")){
108 ShellPrintHiiEx(
109 -1,
110 -1,
111 NULL,
112 STRING_TOKEN (STR_VER_OUTPUT_SUPPLIER),
113 gShellLevel3HiiHandle,
114 (CHAR16 *) PcdGetPtr (PcdShellSupplier)
115 );
116
117
118 ShellPrintHiiEx (
119 -1,
120 -1,
121 NULL,
122 STRING_TOKEN (STR_VER_OUTPUT_UEFI),
123 gShellLevel3HiiHandle,
124 (gST->Hdr.Revision&0xffff0000)>>16,
125 (gST->Hdr.Revision&0x0000ffff),
126 gST->FirmwareVendor,
127 gST->FirmwareRevision
128 );
129 }
130 }
131 //
132 // implementation specific support for displaying processor architecture
133 //
134 if (ShellCommandLineGetFlag(Package, L"-_pa")) {
135 ShellPrintEx(-1, -1, L"%d\r\n", sizeof(UINTN)==sizeof(UINT64)?64:32);
136 }
137 }
138
139 //
140 // free the command line package
141 //
142 ShellCommandLineFreeVarList (Package);
143 }
144
145 return (ShellStatus);
146 }
147
148