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