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