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