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 - 2018, Intel Corporation. All rights reserved.<BR>
|
---|
7 | SPDX-License-Identifier: BSD-2-Clause-Patent
|
---|
8 |
|
---|
9 | **/
|
---|
10 |
|
---|
11 | #include "UefiShellLevel3CommandsLib.h"
|
---|
12 |
|
---|
13 | #include <Library/ShellLib.h>
|
---|
14 | #ifdef VBOX
|
---|
15 | # include <VBox/version.h>
|
---|
16 | #endif
|
---|
17 |
|
---|
18 | STATIC CONST SHELL_PARAM_ITEM ParamList[] = {
|
---|
19 | { L"-s", TypeFlag },
|
---|
20 | { L"-terse", TypeFlag },
|
---|
21 | { L"-t", TypeFlag },
|
---|
22 | { L"-_pa", TypeFlag },
|
---|
23 | #ifdef VBOX
|
---|
24 | {L"-vbox", TypeFlag },
|
---|
25 | #endif
|
---|
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
|
---|
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 |
|
---|
81 | if (ShellCommandLineGetRawValue (Package, 1) != NULL) {
|
---|
82 | //
|
---|
83 | // we have too many parameters
|
---|
84 | //
|
---|
85 | ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_GEN_TOO_MANY), gShellLevel3HiiHandle, L"ver");
|
---|
86 | ShellStatus = SHELL_INVALID_PARAMETER;
|
---|
87 | } else {
|
---|
88 | if (ShellCommandLineGetFlag (Package, L"-s")) {
|
---|
89 | if (ShellCommandLineGetFlag (Package, L"-terse") || ShellCommandLineGetFlag (Package, L"-t")) {
|
---|
90 | ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_GEN_PARAM_CONFLICT), gShellLevel3HiiHandle, L"ver", L"-t or -terse", L"-s");
|
---|
91 | ShellStatus = SHELL_INVALID_PARAMETER;
|
---|
92 | } else {
|
---|
93 | ShellPrintHiiEx (
|
---|
94 | 0,
|
---|
95 | gST->ConOut->Mode->CursorRow,
|
---|
96 | NULL,
|
---|
97 | STRING_TOKEN (STR_VER_OUTPUT_SIMPLE),
|
---|
98 | gShellLevel3HiiHandle,
|
---|
99 | gEfiShellProtocol->MajorVersion,
|
---|
100 | gEfiShellProtocol->MinorVersion
|
---|
101 | );
|
---|
102 | }
|
---|
103 | } else {
|
---|
104 | ShellPrintHiiEx (
|
---|
105 | 0,
|
---|
106 | gST->ConOut->Mode->CursorRow,
|
---|
107 | NULL,
|
---|
108 | STRING_TOKEN (STR_VER_OUTPUT_SHELL),
|
---|
109 | gShellLevel3HiiHandle,
|
---|
110 | SupportLevel[Level],
|
---|
111 | gEfiShellProtocol->MajorVersion,
|
---|
112 | gEfiShellProtocol->MinorVersion
|
---|
113 | );
|
---|
114 | if (!ShellCommandLineGetFlag (Package, L"-terse") && !ShellCommandLineGetFlag (Package, L"-t")) {
|
---|
115 | ShellPrintHiiEx (
|
---|
116 | -1,
|
---|
117 | -1,
|
---|
118 | NULL,
|
---|
119 | STRING_TOKEN (STR_VER_OUTPUT_SUPPLIER),
|
---|
120 | gShellLevel3HiiHandle,
|
---|
121 | (CHAR16 *)PcdGetPtr (PcdShellSupplier)
|
---|
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 | //
|
---|
139 | // implementation specific support for displaying processor architecture
|
---|
140 | //
|
---|
141 | if (ShellCommandLineGetFlag (Package, L"-_pa")) {
|
---|
142 | ShellPrintEx (-1, -1, L"%d\r\n", sizeof (UINTN) == sizeof (UINT64) ? 64 : 32);
|
---|
143 | }
|
---|
144 | #ifdef VBOX
|
---|
145 | if (ShellCommandLineGetFlag(Package, L"-vbox")) {
|
---|
146 | ShellPrintEx(-1, -1, L"Oracle(r) VirtualBox(tm) %d.%d.%d r%d\r\n", VBOX_VERSION_MAJOR, VBOX_VERSION_MINOR, VBOX_VERSION_BUILD, VBOX_REV);
|
---|
147 | }
|
---|
148 | #endif
|
---|
149 | }
|
---|
150 |
|
---|
151 | //
|
---|
152 | // free the command line package
|
---|
153 | //
|
---|
154 | ShellCommandLineFreeVarList (Package);
|
---|
155 | }
|
---|
156 |
|
---|
157 | return (ShellStatus);
|
---|
158 | }
|
---|