2 Main file for Ver shell level 3 function.
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
11 #include "UefiShellLevel3CommandsLib.h"
13 #include <Library/ShellLib.h>
15 STATIC CONST SHELL_PARAM_ITEM ParamList
[] = {
17 { L
"-terse", TypeFlag
},
19 { L
"-_pa", TypeFlag
},
24 Function for 'ver' command.
26 @param[in] ImageHandle Handle to the Image (NULL if Internal).
27 @param[in] SystemTable Pointer to the System Table (NULL if Internal).
32 IN EFI_HANDLE ImageHandle
,
33 IN EFI_SYSTEM_TABLE
*SystemTable
39 SHELL_STATUS ShellStatus
;
42 Level
= PcdGet8 (PcdShellSupportLevel
);
44 ShellStatus
= SHELL_SUCCESS
;
47 // initialize the shell lib (we must be in non-auto-init...)
49 Status
= ShellInitialize ();
50 ASSERT_EFI_ERROR (Status
);
52 Status
= CommandInit ();
53 ASSERT_EFI_ERROR (Status
);
56 // parse the command line
58 Status
= ShellCommandLineParse (ParamList
, &Package
, &ProblemParam
, TRUE
);
59 if (EFI_ERROR (Status
)) {
60 if ((Status
== EFI_VOLUME_CORRUPTED
) && (ProblemParam
!= NULL
)) {
61 ShellPrintHiiEx (-1, -1, NULL
, STRING_TOKEN (STR_GEN_PROBLEM
), gShellLevel3HiiHandle
, L
"ver", ProblemParam
);
62 FreePool (ProblemParam
);
63 ShellStatus
= SHELL_INVALID_PARAMETER
;
71 if (ShellCommandLineGetFlag (Package
, L
"-?")) {
75 if (ShellCommandLineGetRawValue (Package
, 1) != NULL
) {
77 // we have too many parameters
79 ShellPrintHiiEx (-1, -1, NULL
, STRING_TOKEN (STR_GEN_TOO_MANY
), gShellLevel3HiiHandle
, L
"ver");
80 ShellStatus
= SHELL_INVALID_PARAMETER
;
82 if (ShellCommandLineGetFlag (Package
, L
"-s")) {
83 if (ShellCommandLineGetFlag (Package
, L
"-terse") || ShellCommandLineGetFlag (Package
, L
"-t")) {
84 ShellPrintHiiEx (-1, -1, NULL
, STRING_TOKEN (STR_GEN_PARAM_CONFLICT
), gShellLevel3HiiHandle
, L
"ver", L
"-t or -terse", L
"-s");
85 ShellStatus
= SHELL_INVALID_PARAMETER
;
89 gST
->ConOut
->Mode
->CursorRow
,
91 STRING_TOKEN (STR_VER_OUTPUT_SIMPLE
),
92 gShellLevel3HiiHandle
,
93 gEfiShellProtocol
->MajorVersion
,
94 gEfiShellProtocol
->MinorVersion
100 gST
->ConOut
->Mode
->CursorRow
,
102 STRING_TOKEN (STR_VER_OUTPUT_SHELL
),
103 gShellLevel3HiiHandle
,
105 gEfiShellProtocol
->MajorVersion
,
106 gEfiShellProtocol
->MinorVersion
108 if (!ShellCommandLineGetFlag (Package
, L
"-terse") && !ShellCommandLineGetFlag (Package
, L
"-t")) {
113 STRING_TOKEN (STR_VER_OUTPUT_SUPPLIER
),
114 gShellLevel3HiiHandle
,
115 (CHAR16
*)PcdGetPtr (PcdShellSupplier
)
122 STRING_TOKEN (STR_VER_OUTPUT_UEFI
),
123 gShellLevel3HiiHandle
,
124 (gST
->Hdr
.Revision
&0xffff0000)>>16,
125 (gST
->Hdr
.Revision
&0x0000ffff),
127 gST
->FirmwareRevision
133 // implementation specific support for displaying processor architecture
135 if (ShellCommandLineGetFlag (Package
, L
"-_pa")) {
136 ShellPrintEx (-1, -1, L
"%d\r\n", sizeof (UINTN
) == sizeof (UINT64
) ? 64 : 32);
141 // free the command line package
143 ShellCommandLineFreeVarList (Package
);
146 return (ShellStatus
);