TianoCore EDK2 master
Loading...
Searching...
No Matches
Ver.c
Go to the documentation of this file.
1
12
13#include <Library/ShellLib.h>
14
15STATIC 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
30EFIAPI
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
75 if (ShellCommandLineGetRawValue (Package, 1) != NULL) {
76 //
77 // we have too many parameters
78 //
79 ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_GEN_TOO_MANY), gShellLevel3HiiHandle, L"ver");
80 ShellStatus = SHELL_INVALID_PARAMETER;
81 } else {
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;
86 } else {
88 0,
90 NULL,
91 STRING_TOKEN (STR_VER_OUTPUT_SIMPLE),
92 gShellLevel3HiiHandle,
93 gEfiShellProtocol->MajorVersion,
94 gEfiShellProtocol->MinorVersion
95 );
96 }
97 } else {
99 0,
101 NULL,
102 STRING_TOKEN (STR_VER_OUTPUT_SHELL),
103 gShellLevel3HiiHandle,
104 SupportLevel[Level],
105 gEfiShellProtocol->MajorVersion,
106 gEfiShellProtocol->MinorVersion
107 );
108 if (!ShellCommandLineGetFlag (Package, L"-terse") && !ShellCommandLineGetFlag (Package, L"-t")) {
110 -1,
111 -1,
112 NULL,
113 STRING_TOKEN (STR_VER_OUTPUT_SUPPLIER),
114 gShellLevel3HiiHandle,
115 (CHAR16 *)PcdGetPtr (PcdShellSupplier)
116 );
117
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),
128 );
129 }
130 }
131
132 //
133 // implementation specific support for displaying processor architecture
134 //
135 if (ShellCommandLineGetFlag (Package, L"-_pa")) {
136 ShellPrintEx (-1, -1, L"%d\r\n", sizeof (UINTN) == sizeof (UINT64) ? 64 : 32);
137 }
138 }
139
140 //
141 // free the command line package
142 //
144 }
145
146 return (ShellStatus);
147}
UINT64 UINTN
VOID EFIAPI FreePool(IN VOID *Buffer)
#define NULL
Definition: Base.h:319
#define CONST
Definition: Base.h:259
#define STATIC
Definition: Base.h:264
#define TRUE
Definition: Base.h:301
#define FALSE
Definition: Base.h:307
#define IN
Definition: Base.h:279
#define ASSERT_EFI_ERROR(StatusParameter)
Definition: DebugLib.h:462
SHELL_STATUS
Definition: Shell.h:21
@ SHELL_SUCCESS
Definition: Shell.h:25
@ SHELL_INVALID_PARAMETER
Definition: Shell.h:35
#define PcdGet8(TokenName)
Definition: PcdLib.h:336
#define PcdGetPtr(TokenName)
Definition: PcdLib.h:388
EFI_STATUS EFIAPI CommandInit(VOID)
#define ShellCommandLineParse(CheckList, CheckPackage, ProblemParam, AutoPageBreak)
Make it easy to upgrade from older versions of the shell library.
Definition: ShellLib.h:755
EFI_STATUS EFIAPI ShellPrintHiiEx(IN INT32 Col OPTIONAL, IN INT32 Row OPTIONAL, IN CONST CHAR8 *Language OPTIONAL, IN CONST EFI_STRING_ID HiiFormatStringId, IN CONST EFI_HII_HANDLE HiiFormatHandle,...)
BOOLEAN EFIAPI ShellCommandLineGetFlag(IN CONST LIST_ENTRY *CONST CheckPackage, IN CONST CHAR16 *CONST KeyString)
@ TypeFlag
A flag that is present or not present only (IE "-a").
Definition: ShellLib.h:699
VOID EFIAPI ShellCommandLineFreeVarList(IN LIST_ENTRY *CheckPackage)
EFI_STATUS EFIAPI ShellInitialize(VOID)
Definition: UefiShellLib.c:532
EFI_STATUS EFIAPI ShellPrintEx(IN INT32 Col OPTIONAL, IN INT32 Row OPTIONAL, IN CONST CHAR16 *Format,...)
CONST CHAR16 *EFIAPI ShellCommandLineGetRawValue(IN CONST LIST_ENTRY *CONST CheckPackage, IN UINTN Position)
RETURN_STATUS EFI_STATUS
Definition: UefiBaseType.h:29
VOID * EFI_HANDLE
Definition: UefiBaseType.h:33
EFI_SYSTEM_TABLE * gST
#define STRING_TOKEN(t)
SHELL_STATUS EFIAPI ShellCommandRunVer(IN EFI_HANDLE ImageHandle, IN EFI_SYSTEM_TABLE *SystemTable)
Definition: Ver.c:31
EFI_SIMPLE_TEXT_OUTPUT_MODE * Mode
UINT32 FirmwareRevision
Definition: UefiSpec.h:2042
CHAR16 * FirmwareVendor
Definition: UefiSpec.h:2037
EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL * ConOut
Definition: UefiSpec.h:2064
EFI_TABLE_HEADER Hdr
Definition: UefiSpec.h:2032