]>
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 |
7f9e354a | 74 | @return EFI_INVALID_PARAMETER some parameters are invalid\r |
a405b86d | 75 | @retval EFI_OUT_OF_RESOURCES a memory allocation failed.\r |
76 | **/\r | |
77 | EFI_STATUS\r | |
47d20b54 | 78 | UpdateArgcArgv (\r |
a405b86d | 79 | IN OUT EFI_SHELL_PARAMETERS_PROTOCOL *ShellParameters,\r |
80 | IN CONST CHAR16 *NewCommandLine,\r | |
d1c275c6 | 81 | IN SHELL_OPERATION_TYPES Type,\r |
a405b86d | 82 | OUT CHAR16 ***OldArgv,\r |
83 | OUT UINTN *OldArgc\r | |
84 | );\r | |
85 | \r | |
86 | /**\r | |
6a5033ca | 87 | Function will replace the current Argc and Argv in the ShellParameters protocol\r |
a405b86d | 88 | structure with Argv and Argc. The current values are de-allocated and the\r |
89 | OldArgv must not be deallocated by the caller.\r | |
90 | \r | |
4ff7e37b ED |
91 | @param[in, out] ShellParameters pointer to parameter structure to modify\r |
92 | @param[in] OldArgv pointer to old list of parameters\r | |
93 | @param[in] OldArgc pointer to old number of items in Argv list\r | |
a405b86d | 94 | **/\r |
95 | VOID\r | |
47d20b54 | 96 | RestoreArgcArgv (\r |
a405b86d | 97 | IN OUT EFI_SHELL_PARAMETERS_PROTOCOL *ShellParameters,\r |
98 | IN CHAR16 ***OldArgv,\r | |
99 | IN UINTN *OldArgc\r | |
100 | );\r | |
101 | \r | |
8be0ba36 | 102 | typedef struct {\r |
47d20b54 MK |
103 | EFI_SIMPLE_TEXT_INPUT_PROTOCOL *ConIn;\r |
104 | EFI_HANDLE ConInHandle;\r | |
105 | EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL *ConOut;\r | |
106 | EFI_HANDLE ConOutHandle;\r | |
107 | EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL *ErrOut;\r | |
108 | EFI_HANDLE ErrOutHandle;\r | |
8be0ba36 | 109 | } SYSTEM_TABLE_INFO;\r |
110 | \r | |
a405b86d | 111 | /**\r |
6a5033ca | 112 | Function will replace the current StdIn and StdOut in the ShellParameters protocol\r |
a405b86d | 113 | structure by parsing NewCommandLine. The current values are returned to the\r |
114 | user.\r | |
115 | \r | |
fb84495a | 116 | This will also update the system table.\r |
a405b86d | 117 | \r |
4ff7e37b ED |
118 | @param[in, out] ShellParameters Pointer to parameter structure to modify.\r |
119 | @param[in] NewCommandLine The new command line to parse and use.\r | |
120 | @param[out] OldStdIn Pointer to old StdIn.\r | |
121 | @param[out] OldStdOut Pointer to old StdOut.\r | |
122 | @param[out] OldStdErr Pointer to old StdErr.\r | |
123 | @param[out] SystemTableInfo Pointer to old system table information.\r | |
a405b86d | 124 | \r |
6a5033ca | 125 | @retval EFI_SUCCESS Operation was successful, Argv and Argc are valid.\r |
a405b86d | 126 | @retval EFI_OUT_OF_RESOURCES A memory allocation failed.\r |
127 | **/\r | |
128 | EFI_STATUS\r | |
47d20b54 | 129 | UpdateStdInStdOutStdErr (\r |
a405b86d | 130 | IN OUT EFI_SHELL_PARAMETERS_PROTOCOL *ShellParameters,\r |
fb84495a | 131 | IN CHAR16 *NewCommandLine,\r |
8be0ba36 | 132 | OUT SHELL_FILE_HANDLE *OldStdIn,\r |
133 | OUT SHELL_FILE_HANDLE *OldStdOut,\r | |
134 | OUT SHELL_FILE_HANDLE *OldStdErr,\r | |
135 | OUT SYSTEM_TABLE_INFO *SystemTableInfo\r | |
a405b86d | 136 | );\r |
137 | \r | |
138 | /**\r | |
6a5033ca | 139 | Function will replace the current StdIn and StdOut in the ShellParameters protocol\r |
a405b86d | 140 | structure with StdIn and StdOut. The current values are de-allocated.\r |
141 | \r | |
4ff7e37b ED |
142 | @param[in, out] ShellParameters Pointer to parameter structure to modify.\r |
143 | @param[in] OldStdIn Pointer to old StdIn.\r | |
144 | @param[in] OldStdOut Pointer to old StdOut.\r | |
145 | @param[in] OldStdErr Pointer to old StdErr.\r | |
146 | @param[in] SystemTableInfo Pointer to old system table information.\r | |
a405b86d | 147 | **/\r |
148 | EFI_STATUS\r | |
a405b86d | 149 | RestoreStdInStdOutStdErr (\r |
150 | IN OUT EFI_SHELL_PARAMETERS_PROTOCOL *ShellParameters,\r | |
8be0ba36 | 151 | IN SHELL_FILE_HANDLE *OldStdIn,\r |
152 | IN SHELL_FILE_HANDLE *OldStdOut,\r | |
153 | IN SHELL_FILE_HANDLE *OldStdErr,\r | |
154 | IN SYSTEM_TABLE_INFO *SystemTableInfo\r | |
a405b86d | 155 | );\r |
156 | \r | |
157 | /**\r | |
158 | function to populate Argc and Argv.\r | |
159 | \r | |
160 | This function parses the CommandLine and divides it into standard C style Argc/Argv\r | |
161 | parameters for inclusion in EFI_SHELL_PARAMETERS_PROTOCOL. this supports space\r | |
162 | delimited and quote surrounded parameter definition.\r | |
163 | \r | |
d1c275c6 QS |
164 | @param[in] CommandLine String of command line to parse\r |
165 | @param[in] StripQuotation if TRUE then strip the quotation marks surrounding\r | |
166 | the parameters.\r | |
167 | @param[in, out] Argv pointer to array of strings; one for each parameter\r | |
168 | @param[in, out] Argc pointer to number of strings in Argv array\r | |
a405b86d | 169 | \r |
6a5033ca | 170 | @return EFI_SUCCESS the operation was successful\r |
ddb7050c | 171 | @return EFI_INVALID_PARAMETER some parameters are invalid\r |
a405b86d | 172 | @return EFI_OUT_OF_RESOURCES a memory allocation failed.\r |
173 | **/\r | |
174 | EFI_STATUS\r | |
47d20b54 MK |
175 | ParseCommandLineToArgs (\r |
176 | IN CONST CHAR16 *CommandLine,\r | |
177 | IN BOOLEAN StripQuotation,\r | |
178 | IN OUT CHAR16 ***Argv,\r | |
179 | IN OUT UINTN *Argc\r | |
a405b86d | 180 | );\r |
181 | \r | |
1219c85d RN |
182 | /**\r |
183 | return the next parameter from a command line string;\r | |
184 | \r | |
185 | This function moves the next parameter from Walker into TempParameter and moves\r | |
186 | Walker up past that parameter for recursive calling. When the final parameter\r | |
187 | is moved *Walker will be set to NULL;\r | |
188 | \r | |
189 | Temp Parameter must be large enough to hold the parameter before calling this\r | |
190 | function.\r | |
191 | \r | |
192 | @param[in, out] Walker pointer to string of command line. Adjusted to\r | |
6a5033ca | 193 | remaining command line on return\r |
1219c85d RN |
194 | @param[in, out] TempParameter pointer to string of command line item extracted.\r |
195 | @param[in] Length Length of (*TempParameter) in bytes\r | |
196 | @param[in] StripQuotation if TRUE then strip the quotation marks surrounding\r | |
197 | the parameters.\r | |
198 | \r | |
6a5033ca | 199 | @return EFI_INVALID_PARAMETER A required parameter was NULL or pointed to a NULL or empty string.\r |
1219c85d RN |
200 | @return EFI_NOT_FOUND A closing " could not be found on the specified string\r |
201 | **/\r | |
202 | EFI_STATUS\r | |
47d20b54 | 203 | GetNextParameter (\r |
1219c85d RN |
204 | IN OUT CHAR16 **Walker,\r |
205 | IN OUT CHAR16 **TempParameter,\r | |
206 | IN CONST UINTN Length,\r | |
207 | IN BOOLEAN StripQuotation\r | |
208 | );\r | |
209 | \r | |
a405b86d | 210 | #endif //_SHELL_PARAMETERS_PROTOCOL_PROVIDER_HEADER_\r |