]>
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 | |
5 | Copyright (c) 2009 - 2010, Intel Corporation. All rights reserved.<BR>\r | |
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 | |
19 | #include <Uefi.h>\r | |
20 | \r | |
21 | #include <Protocol/SimpleFileSystem.h>\r | |
22 | #include <Protocol/EfiShellParameters.h>\r | |
23 | #include <Protocol/LoadedImage.h>\r | |
24 | \r | |
25 | #include <Guid/ShellVariableGuid.h>\r | |
26 | \r | |
27 | #include <Library/UefiBootServicesTableLib.h>\r | |
28 | #include <Library/UefiRuntimeServicesTableLib.h>\r | |
29 | #include <Library/MemoryAllocationLib.h>\r | |
30 | #include <Library/UefiLib.h>\r | |
31 | #include <Library/DebugLib.h>\r | |
32 | #include <Library/ShellLib.h>\r | |
33 | #include <Library/FileHandleLib.h>\r | |
34 | \r | |
35 | #include "ShellEnvVar.h"\r | |
36 | #include "FileHandleWrappers.h"\r | |
37 | #include "Shell.h"\r | |
38 | \r | |
39 | /**\r | |
40 | creates a new EFI_SHELL_PARAMETERS_PROTOCOL instance and populates it and then\r | |
41 | installs it on our handle and if there is an existing version of the protocol\r | |
42 | that one is cached for removal later.\r | |
43 | \r | |
44 | @param[in,out] NewShellParameters on a successful return, a pointer to pointer\r | |
45 | to the newly installed interface.\r | |
46 | @param[in,out] RootShellInstance on a successful return, pointer to boolean.\r | |
47 | TRUE if this is the root shell instance.\r | |
48 | \r | |
49 | @retval EFI_SUCCESS the operation completed successfully.\r | |
50 | @return other the operation failed.\r | |
51 | @sa ReinstallProtocolInterface\r | |
52 | @sa InstallProtocolInterface\r | |
53 | @sa ParseCommandLineToArgs\r | |
54 | **/\r | |
55 | EFI_STATUS\r | |
56 | EFIAPI\r | |
57 | CreatePopulateInstallShellParametersProtocol (\r | |
58 | IN OUT EFI_SHELL_PARAMETERS_PROTOCOL **NewShellParameters,\r | |
59 | IN OUT BOOLEAN *RootShellInstance\r | |
60 | );\r | |
61 | \r | |
62 | /**\r | |
63 | frees all memory used by createion and installation of shell parameters protocol\r | |
64 | and if there was an old version installed it will restore that one.\r | |
65 | \r | |
66 | @param NewShellParameters the interface of EFI_SHELL_PARAMETERS_PROTOCOL that is\r | |
67 | being cleaned up.\r | |
68 | \r | |
69 | @retval EFI_SUCCESS the cleanup was successful\r | |
70 | @return other the cleanup failed\r | |
71 | @sa ReinstallProtocolInterface\r | |
72 | @sa UninstallProtocolInterface\r | |
73 | **/\r | |
74 | EFI_STATUS\r | |
75 | EFIAPI\r | |
76 | CleanUpShellParametersProtocol (\r | |
77 | IN OUT EFI_SHELL_PARAMETERS_PROTOCOL *NewShellParameters\r | |
78 | );\r | |
79 | \r | |
80 | /**\r | |
81 | Funcion will replace the current Argc and Argv in the ShellParameters protocol\r | |
82 | structure by parsing NewCommandLine. The current values are returned to the\r | |
83 | user.\r | |
84 | \r | |
85 | @param[in,out] ShellParameters pointer to parameter structure to modify\r | |
86 | @param[in] NewCommandLine the new command line to parse and use\r | |
87 | @param[out] OldArgv pointer to old list of parameters\r | |
88 | @param[out] OldArgc pointer to old number of items in Argv list\r | |
89 | \r | |
90 | @retval EFI_SUCCESS operation was sucessful, Argv and Argc are valid\r | |
91 | @retval EFI_OUT_OF_RESOURCES a memory allocation failed.\r | |
92 | **/\r | |
93 | EFI_STATUS\r | |
94 | EFIAPI\r | |
95 | UpdateArgcArgv(\r | |
96 | IN OUT EFI_SHELL_PARAMETERS_PROTOCOL *ShellParameters,\r | |
97 | IN CONST CHAR16 *NewCommandLine,\r | |
98 | OUT CHAR16 ***OldArgv,\r | |
99 | OUT UINTN *OldArgc\r | |
100 | );\r | |
101 | \r | |
102 | /**\r | |
103 | Funcion will replace the current Argc and Argv in the ShellParameters protocol\r | |
104 | structure with Argv and Argc. The current values are de-allocated and the\r | |
105 | OldArgv must not be deallocated by the caller.\r | |
106 | \r | |
107 | @param[in,out] ShellParameters pointer to parameter structure to modify\r | |
108 | @param[in] OldArgv pointer to old list of parameters\r | |
109 | @param[in] OldArgc pointer to old number of items in Argv list\r | |
110 | **/\r | |
111 | VOID\r | |
112 | EFIAPI\r | |
113 | RestoreArgcArgv(\r | |
114 | IN OUT EFI_SHELL_PARAMETERS_PROTOCOL *ShellParameters,\r | |
115 | IN CHAR16 ***OldArgv,\r | |
116 | IN UINTN *OldArgc\r | |
117 | );\r | |
118 | \r | |
119 | /**\r | |
120 | Funcion will replace the current StdIn and StdOut in the ShellParameters protocol\r | |
121 | structure by parsing NewCommandLine. The current values are returned to the\r | |
122 | user.\r | |
123 | \r | |
124 | If OldStdIn or OldStdOut is NULL then that value is not returned.\r | |
125 | \r | |
126 | @param[in,out] ShellParameters Pointer to parameter structure to modify.\r | |
127 | @param[in] NewCommandLine The new command line to parse and use.\r | |
128 | @param[out] OldStdIn Pointer to old StdIn.\r | |
129 | @param[out] OldStdOut Pointer to old StdOut.\r | |
130 | @param[out] OldStdErr Pointer to old StdErr.\r | |
131 | \r | |
132 | @retval EFI_SUCCESS Operation was sucessful, Argv and Argc are valid.\r | |
133 | @retval EFI_OUT_OF_RESOURCES A memory allocation failed.\r | |
134 | **/\r | |
135 | EFI_STATUS\r | |
136 | EFIAPI\r | |
137 | UpdateStdInStdOutStdErr(\r | |
138 | IN OUT EFI_SHELL_PARAMETERS_PROTOCOL *ShellParameters,\r | |
139 | IN CONST CHAR16 *NewCommandLine,\r | |
140 | OUT SHELL_FILE_HANDLE *OldStdIn OPTIONAL,\r | |
141 | OUT SHELL_FILE_HANDLE *OldStdOut OPTIONAL,\r | |
142 | OUT SHELL_FILE_HANDLE *OldStdErr OPTIONAL\r | |
143 | );\r | |
144 | \r | |
145 | /**\r | |
146 | Funcion will replace the current StdIn and StdOut in the ShellParameters protocol\r | |
147 | structure with StdIn and StdOut. The current values are de-allocated.\r | |
148 | \r | |
149 | @param[in,out] ShellParameters pointer to parameter structure to modify\r | |
150 | @param[out] OldStdIn Pointer to old StdIn.\r | |
151 | @param[out] OldStdOut Pointer to old StdOut.\r | |
152 | @param[out] OldStdErr Pointer to old StdErr.\r | |
153 | **/\r | |
154 | EFI_STATUS\r | |
155 | EFIAPI\r | |
156 | RestoreStdInStdOutStdErr (\r | |
157 | IN OUT EFI_SHELL_PARAMETERS_PROTOCOL *ShellParameters,\r | |
158 | OUT SHELL_FILE_HANDLE *OldStdIn OPTIONAL,\r | |
159 | OUT SHELL_FILE_HANDLE *OldStdOut OPTIONAL,\r | |
160 | OUT SHELL_FILE_HANDLE *OldStdErr OPTIONAL\r | |
161 | );\r | |
162 | \r | |
163 | /**\r | |
164 | function to populate Argc and Argv.\r | |
165 | \r | |
166 | This function parses the CommandLine and divides it into standard C style Argc/Argv\r | |
167 | parameters for inclusion in EFI_SHELL_PARAMETERS_PROTOCOL. this supports space\r | |
168 | delimited and quote surrounded parameter definition.\r | |
169 | \r | |
170 | @param[in] CommandLine String of command line to parse\r | |
171 | @param[in,out] Argv pointer to array of strings; one for each parameter\r | |
172 | @param[in,out] Argc pointer to number of strings in Argv array\r | |
173 | \r | |
174 | @return EFI_SUCCESS the operation was sucessful\r | |
175 | @return EFI_OUT_OF_RESOURCES a memory allocation failed.\r | |
176 | **/\r | |
177 | EFI_STATUS\r | |
178 | EFIAPI\r | |
179 | ParseCommandLineToArgs(\r | |
180 | IN CONST CHAR16 *CommandLine,\r | |
181 | IN OUT CHAR16 ***Argv,\r | |
182 | IN OUT UINTN *Argc\r | |
183 | );\r | |
184 | \r | |
185 | /**\r | |
186 | return the next parameter from a command line string;\r | |
187 | \r | |
188 | This function moves the next parameter from Walker into TempParameter and moves\r | |
189 | Walker up past that parameter for recursive calling. When the final parameter\r | |
190 | is moved *Walker will be set to NULL;\r | |
191 | \r | |
192 | Temp Parameter must be large enough to hold the parameter before calling this\r | |
193 | function.\r | |
194 | \r | |
195 | @param[in,out] Walker pointer to string of command line. Adjusted to\r | |
196 | reminaing command line on return\r | |
197 | @param[in,out] TempParameter pointer to string of command line item extracted.\r | |
198 | \r | |
199 | **/\r | |
200 | VOID\r | |
201 | EFIAPI\r | |
202 | GetNextParameter(\r | |
203 | CHAR16 **Walker,\r | |
204 | CHAR16 **TempParameter\r | |
205 | );\r | |
206 | \r | |
207 | #endif //_SHELL_PARAMETERS_PROTOCOL_PROVIDER_HEADER_\r | |
208 | \r |