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