]>
Commit | Line | Data |
---|---|---|
a405b86d | 1 | /** @file\r |
2 | Member functions of EFI_SHELL_PARAMETERS_PROTOCOL and functions for creation,\r | |
3 | manipulation, and initialization of EFI_SHELL_PARAMETERS_PROTOCOL.\r | |
4 | \r | |
4ccd9214 | 5 | Copyright (c) 2009 - 2012, Intel Corporation. All rights reserved.<BR>\r |
56ba3746 | 6 | SPDX-License-Identifier: BSD-2-Clause-Patent\r |
a405b86d | 7 | \r |
8 | **/\r | |
9 | \r | |
10 | #ifndef _SHELL_PARAMETERS_PROTOCOL_PROVIDER_HEADER_\r | |
11 | #define _SHELL_PARAMETERS_PROTOCOL_PROVIDER_HEADER_\r | |
12 | \r | |
a405b86d | 13 | #include "Shell.h"\r |
14 | \r | |
d1c275c6 QS |
15 | typedef enum {\r |
16 | Internal_Command,\r | |
17 | Script_File_Name,\r | |
18 | Efi_Application,\r | |
19 | File_Sys_Change,\r | |
20 | Unknown_Invalid\r | |
21 | } SHELL_OPERATION_TYPES;\r | |
22 | \r | |
a405b86d | 23 | /**\r |
24 | creates a new EFI_SHELL_PARAMETERS_PROTOCOL instance and populates it and then\r | |
25 | installs it on our handle and if there is an existing version of the protocol\r | |
26 | that one is cached for removal later.\r | |
27 | \r | |
4ff7e37b | 28 | @param[in, out] NewShellParameters on a successful return, a pointer to pointer\r |
a405b86d | 29 | to the newly installed interface.\r |
4ff7e37b | 30 | @param[in, out] RootShellInstance on a successful return, pointer to boolean.\r |
a405b86d | 31 | TRUE if this is the root shell instance.\r |
32 | \r | |
33 | @retval EFI_SUCCESS the operation completed successfully.\r | |
34 | @return other the operation failed.\r | |
35 | @sa ReinstallProtocolInterface\r | |
36 | @sa InstallProtocolInterface\r | |
37 | @sa ParseCommandLineToArgs\r | |
38 | **/\r | |
39 | EFI_STATUS\r | |
a405b86d | 40 | CreatePopulateInstallShellParametersProtocol (\r |
41 | IN OUT EFI_SHELL_PARAMETERS_PROTOCOL **NewShellParameters,\r | |
42 | IN OUT BOOLEAN *RootShellInstance\r | |
43 | );\r | |
44 | \r | |
45 | /**\r | |
6a5033ca | 46 | frees all memory used by creation and installation of shell parameters protocol\r |
a405b86d | 47 | and if there was an old version installed it will restore that one.\r |
48 | \r | |
49 | @param NewShellParameters the interface of EFI_SHELL_PARAMETERS_PROTOCOL that is\r | |
50 | being cleaned up.\r | |
51 | \r | |
52 | @retval EFI_SUCCESS the cleanup was successful\r | |
53 | @return other the cleanup failed\r | |
54 | @sa ReinstallProtocolInterface\r | |
55 | @sa UninstallProtocolInterface\r | |
56 | **/\r | |
57 | EFI_STATUS\r | |
a405b86d | 58 | CleanUpShellParametersProtocol (\r |
59 | IN OUT EFI_SHELL_PARAMETERS_PROTOCOL *NewShellParameters\r | |
60 | );\r | |
61 | \r | |
62 | /**\r | |
6a5033ca | 63 | Function will replace the current Argc and Argv in the ShellParameters protocol\r |
a405b86d | 64 | structure by parsing NewCommandLine. The current values are returned to the\r |
65 | user.\r | |
66 | \r | |
4ff7e37b | 67 | @param[in, out] ShellParameters pointer to parameter structure to modify\r |
a405b86d | 68 | @param[in] NewCommandLine the new command line to parse and use\r |
d1c275c6 | 69 | @param[in] Type the type of operation.\r |
a405b86d | 70 | @param[out] OldArgv pointer to old list of parameters\r |
71 | @param[out] OldArgc pointer to old number of items in Argv list\r | |
72 | \r | |
6a5033ca | 73 | @retval EFI_SUCCESS operation was successful, Argv and Argc are valid\r |
a405b86d | 74 | @retval EFI_OUT_OF_RESOURCES a memory allocation failed.\r |
75 | **/\r | |
76 | EFI_STATUS\r | |
a405b86d | 77 | UpdateArgcArgv(\r |
78 | IN OUT EFI_SHELL_PARAMETERS_PROTOCOL *ShellParameters,\r | |
79 | IN CONST CHAR16 *NewCommandLine,\r | |
d1c275c6 | 80 | IN SHELL_OPERATION_TYPES Type,\r |
a405b86d | 81 | OUT CHAR16 ***OldArgv,\r |
82 | OUT UINTN *OldArgc\r | |
83 | );\r | |
84 | \r | |
85 | /**\r | |
6a5033ca | 86 | Function will replace the current Argc and Argv in the ShellParameters protocol\r |
a405b86d | 87 | structure with Argv and Argc. The current values are de-allocated and the\r |
88 | OldArgv must not be deallocated by the caller.\r | |
89 | \r | |
4ff7e37b ED |
90 | @param[in, out] ShellParameters pointer to parameter structure to modify\r |
91 | @param[in] OldArgv pointer to old list of parameters\r | |
92 | @param[in] OldArgc pointer to old number of items in Argv list\r | |
a405b86d | 93 | **/\r |
94 | VOID\r | |
a405b86d | 95 | RestoreArgcArgv(\r |
96 | IN OUT EFI_SHELL_PARAMETERS_PROTOCOL *ShellParameters,\r | |
97 | IN CHAR16 ***OldArgv,\r | |
98 | IN UINTN *OldArgc\r | |
99 | );\r | |
100 | \r | |
8be0ba36 | 101 | typedef struct {\r |
102 | EFI_SIMPLE_TEXT_INPUT_PROTOCOL *ConIn;\r | |
103 | EFI_HANDLE ConInHandle;\r | |
104 | EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL *ConOut;\r | |
105 | EFI_HANDLE ConOutHandle;\r | |
4ccd9214 ED |
106 | EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL *ErrOut;\r |
107 | EFI_HANDLE ErrOutHandle;\r | |
8be0ba36 | 108 | } SYSTEM_TABLE_INFO;\r |
109 | \r | |
a405b86d | 110 | /**\r |
6a5033ca | 111 | Function will replace the current StdIn and StdOut in the ShellParameters protocol\r |
a405b86d | 112 | structure by parsing NewCommandLine. The current values are returned to the\r |
113 | user.\r | |
114 | \r | |
fb84495a | 115 | This will also update the system table.\r |
a405b86d | 116 | \r |
4ff7e37b ED |
117 | @param[in, out] ShellParameters Pointer to parameter structure to modify.\r |
118 | @param[in] NewCommandLine The new command line to parse and use.\r | |
119 | @param[out] OldStdIn Pointer to old StdIn.\r | |
120 | @param[out] OldStdOut Pointer to old StdOut.\r | |
121 | @param[out] OldStdErr Pointer to old StdErr.\r | |
122 | @param[out] SystemTableInfo Pointer to old system table information.\r | |
a405b86d | 123 | \r |
6a5033ca | 124 | @retval EFI_SUCCESS Operation was successful, Argv and Argc are valid.\r |
a405b86d | 125 | @retval EFI_OUT_OF_RESOURCES A memory allocation failed.\r |
126 | **/\r | |
127 | EFI_STATUS\r | |
a405b86d | 128 | UpdateStdInStdOutStdErr(\r |
129 | IN OUT EFI_SHELL_PARAMETERS_PROTOCOL *ShellParameters,\r | |
fb84495a | 130 | IN CHAR16 *NewCommandLine,\r |
8be0ba36 | 131 | OUT SHELL_FILE_HANDLE *OldStdIn,\r |
132 | OUT SHELL_FILE_HANDLE *OldStdOut,\r | |
133 | OUT SHELL_FILE_HANDLE *OldStdErr,\r | |
134 | OUT SYSTEM_TABLE_INFO *SystemTableInfo\r | |
a405b86d | 135 | );\r |
136 | \r | |
137 | /**\r | |
6a5033ca | 138 | Function will replace the current StdIn and StdOut in the ShellParameters protocol\r |
a405b86d | 139 | structure with StdIn and StdOut. The current values are de-allocated.\r |
140 | \r | |
4ff7e37b ED |
141 | @param[in, out] ShellParameters Pointer to parameter structure to modify.\r |
142 | @param[in] OldStdIn Pointer to old StdIn.\r | |
143 | @param[in] OldStdOut Pointer to old StdOut.\r | |
144 | @param[in] OldStdErr Pointer to old StdErr.\r | |
145 | @param[in] SystemTableInfo Pointer to old system table information.\r | |
a405b86d | 146 | **/\r |
147 | EFI_STATUS\r | |
a405b86d | 148 | RestoreStdInStdOutStdErr (\r |
149 | IN OUT EFI_SHELL_PARAMETERS_PROTOCOL *ShellParameters,\r | |
8be0ba36 | 150 | IN SHELL_FILE_HANDLE *OldStdIn,\r |
151 | IN SHELL_FILE_HANDLE *OldStdOut,\r | |
152 | IN SHELL_FILE_HANDLE *OldStdErr,\r | |
153 | IN SYSTEM_TABLE_INFO *SystemTableInfo\r | |
a405b86d | 154 | );\r |
155 | \r | |
156 | /**\r | |
157 | function to populate Argc and Argv.\r | |
158 | \r | |
159 | This function parses the CommandLine and divides it into standard C style Argc/Argv\r | |
160 | parameters for inclusion in EFI_SHELL_PARAMETERS_PROTOCOL. this supports space\r | |
161 | delimited and quote surrounded parameter definition.\r | |
162 | \r | |
d1c275c6 QS |
163 | @param[in] CommandLine String of command line to parse\r |
164 | @param[in] StripQuotation if TRUE then strip the quotation marks surrounding\r | |
165 | the parameters.\r | |
166 | @param[in, out] Argv pointer to array of strings; one for each parameter\r | |
167 | @param[in, out] Argc pointer to number of strings in Argv array\r | |
a405b86d | 168 | \r |
6a5033ca | 169 | @return EFI_SUCCESS the operation was successful\r |
a405b86d | 170 | @return EFI_OUT_OF_RESOURCES a memory allocation failed.\r |
171 | **/\r | |
172 | EFI_STATUS\r | |
a405b86d | 173 | ParseCommandLineToArgs(\r |
174 | IN CONST CHAR16 *CommandLine,\r | |
d1c275c6 QS |
175 | IN BOOLEAN StripQuotation,\r |
176 | IN OUT CHAR16 ***Argv,\r | |
177 | IN OUT UINTN *Argc\r | |
a405b86d | 178 | );\r |
179 | \r | |
1219c85d RN |
180 | /**\r |
181 | return the next parameter from a command line string;\r | |
182 | \r | |
183 | This function moves the next parameter from Walker into TempParameter and moves\r | |
184 | Walker up past that parameter for recursive calling. When the final parameter\r | |
185 | is moved *Walker will be set to NULL;\r | |
186 | \r | |
187 | Temp Parameter must be large enough to hold the parameter before calling this\r | |
188 | function.\r | |
189 | \r | |
190 | @param[in, out] Walker pointer to string of command line. Adjusted to\r | |
6a5033ca | 191 | remaining command line on return\r |
1219c85d RN |
192 | @param[in, out] TempParameter pointer to string of command line item extracted.\r |
193 | @param[in] Length Length of (*TempParameter) in bytes\r | |
194 | @param[in] StripQuotation if TRUE then strip the quotation marks surrounding\r | |
195 | the parameters.\r | |
196 | \r | |
6a5033ca | 197 | @return EFI_INVALID_PARAMETER A required parameter was NULL or pointed to a NULL or empty string.\r |
1219c85d RN |
198 | @return EFI_NOT_FOUND A closing " could not be found on the specified string\r |
199 | **/\r | |
200 | EFI_STATUS\r | |
1219c85d RN |
201 | GetNextParameter(\r |
202 | IN OUT CHAR16 **Walker,\r | |
203 | IN OUT CHAR16 **TempParameter,\r | |
204 | IN CONST UINTN Length,\r | |
205 | IN BOOLEAN StripQuotation\r | |
206 | );\r | |
207 | \r | |
a405b86d | 208 | #endif //_SHELL_PARAMETERS_PROTOCOL_PROVIDER_HEADER_\r |
209 | \r |