VirtualBox

source: vbox/trunk/src/VBox/Devices/EFI/Firmware/ShellPkg/Library/UefiShellLevel3CommandsLib/Ver.c@ 80924

Last change on this file since 80924 was 80721, checked in by vboxsync, 6 years ago

Devices/EFI/FirmwareNew: Start upgrade process to edk2-stable201908 (compiles on Windows and works to some extent), bugref:4643

  • Property svn:eol-style set to native
File size: 4.4 KB
Line 
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
18STATIC 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**/
35SHELL_STATUS
36EFIAPI
37ShellCommandRunVer (
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#ifdef VBOX
144 if (ShellCommandLineGetFlag(Package, L"-vbox")) {
145 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);
146 }
147#endif
148 }
149
150 //
151 // free the command line package
152 //
153 ShellCommandLineFreeVarList (Package);
154 }
155
156 return (ShellStatus);
157}
158
Note: See TracBrowser for help on using the repository browser.

© 2025 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette