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