]> git.proxmox.com Git - mirror_edk2.git/blob - ShellPkg/Library/UefiShellLevel3CommandsLib/Ver.c
ShellPkg: acpiview: Fix '\n\n' printing in Table Checksum reporting
[mirror_edk2.git] / ShellPkg / Library / UefiShellLevel3CommandsLib / Ver.c
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
15 STATIC CONST SHELL_PARAM_ITEM ParamList[] = {
16 {L"-s", TypeFlag},
17 {L"-terse", TypeFlag},
18 {L"-t", TypeFlag},
19 {L"-_pa", TypeFlag},
20 {NULL, TypeMax}
21 };
22
23 /**
24 Function for 'ver' command.
25
26 @param[in] ImageHandle Handle to the Image (NULL if Internal).
27 @param[in] SystemTable Pointer to the System Table (NULL if Internal).
28 **/
29 SHELL_STATUS
30 EFIAPI
31 ShellCommandRunVer (
32 IN EFI_HANDLE ImageHandle,
33 IN EFI_SYSTEM_TABLE *SystemTable
34 )
35 {
36 EFI_STATUS Status;
37 LIST_ENTRY *Package;
38 CHAR16 *ProblemParam;
39 SHELL_STATUS ShellStatus;
40 UINT8 Level;
41
42 Level = PcdGet8(PcdShellSupportLevel);
43 ProblemParam = NULL;
44 ShellStatus = SHELL_SUCCESS;
45
46 //
47 // initialize the shell lib (we must be in non-auto-init...)
48 //
49 Status = ShellInitialize();
50 ASSERT_EFI_ERROR(Status);
51
52 Status = CommandInit();
53 ASSERT_EFI_ERROR(Status);
54
55 //
56 // parse the command line
57 //
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;
64 } else {
65 ASSERT(FALSE);
66 }
67 } else {
68 //
69 // check for "-?"
70 //
71 if (ShellCommandLineGetFlag(Package, L"-?")) {
72 ASSERT(FALSE);
73 }
74 if (ShellCommandLineGetRawValue(Package, 1) != NULL) {
75 //
76 // we have too many parameters
77 //
78 ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_TOO_MANY), gShellLevel3HiiHandle, L"ver");
79 ShellStatus = SHELL_INVALID_PARAMETER;
80 } else {
81 if (ShellCommandLineGetFlag(Package, L"-s")) {
82 if (ShellCommandLineGetFlag(Package, L"-terse") || ShellCommandLineGetFlag(Package, L"-t")){
83 ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_PARAM_CONFLICT), gShellLevel3HiiHandle, L"ver", L"-t or -terse", L"-s");
84 ShellStatus = SHELL_INVALID_PARAMETER;
85 } else {
86 ShellPrintHiiEx (
87 0,
88 gST->ConOut->Mode->CursorRow,
89 NULL,
90 STRING_TOKEN (STR_VER_OUTPUT_SIMPLE),
91 gShellLevel3HiiHandle,
92 gEfiShellProtocol->MajorVersion,
93 gEfiShellProtocol->MinorVersion
94 );
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