]>
Commit | Line | Data |
---|---|---|
a405b86d | 1 | /** @file\r |
2 | Provides interface to shell internal functions for shell commands.\r | |
3 | \r | |
4 | This library is for use ONLY by shell commands linked into the shell application.\r | |
5 | This library will not funciton if it is used for UEFI Shell 2.0 Applications.\r | |
6 | \r | |
4bbdc0e1 | 7 | Copyright (c) 2009 - 2011, Intel Corporation. All rights reserved.<BR>\r |
a405b86d | 8 | This program and the accompanying materials\r |
9 | are licensed and made available under the terms and conditions of the BSD License\r | |
10 | which accompanies this distribution. The full text of the license may be found at\r | |
11 | http://opensource.org/licenses/bsd-license.php.\r | |
12 | \r | |
13 | THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r | |
14 | WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r | |
15 | \r | |
16 | **/\r | |
17 | \r | |
18 | #ifndef _SHELL_COMMAND_LIB_\r | |
19 | #define _SHELL_COMMAND_LIB_\r | |
20 | \r | |
21 | #include <Uefi.h>\r | |
22 | #include <ShellBase.h>\r | |
23 | \r | |
24 | #include <Protocol/EfiShell.h>\r | |
25 | #include <Protocol/EfiShellParameters.h>\r | |
26 | #include <Protocol/UnicodeCollation.h>\r | |
27 | #include <Protocol/DevicePathToText.h>\r | |
28 | #include <Protocol/SimpleFileSystem.h>\r | |
29 | \r | |
30 | #include <Library/UefiBootServicesTableLib.h>\r | |
31 | \r | |
32 | //\r | |
33 | // The extern global protocol poionters.\r | |
34 | //\r | |
a405b86d | 35 | extern EFI_UNICODE_COLLATION_PROTOCOL *gUnicodeCollation;\r |
36 | extern EFI_DEVICE_PATH_TO_TEXT_PROTOCOL *gDevPathToText;\r | |
37 | extern CONST CHAR16* SupportLevel[];\r | |
38 | \r | |
39 | //\r | |
40 | // The map list objects.\r | |
41 | //\r | |
42 | typedef struct {\r | |
43 | LIST_ENTRY Link;\r | |
44 | EFI_DEVICE_PATH_PROTOCOL *DevicePath;\r | |
45 | CHAR16 *MapName;\r | |
46 | CHAR16 *CurrentDirectoryPath;\r | |
47 | UINT64 Flags;\r | |
48 | } SHELL_MAP_LIST;\r | |
49 | /// List of Mappings - DeviceName and Drive Letter(ism).\r | |
50 | extern SHELL_MAP_LIST gShellMapList;\r | |
51 | /// Pointer to node of current directory in the mMapList.\r | |
52 | extern SHELL_MAP_LIST *gShellCurDir;\r | |
53 | \r | |
54 | /**\r | |
55 | Returns the help MAN fileName for a given shell command.\r | |
56 | \r | |
57 | @retval !NULL The unicode string of the MAN filename.\r | |
58 | @retval NULL An error ocurred.\r | |
59 | \r | |
60 | **/\r | |
61 | typedef\r | |
62 | CONST CHAR16 *\r | |
63 | (EFIAPI *SHELL_GET_MAN_FILENAME)(\r | |
64 | VOID\r | |
65 | );\r | |
66 | \r | |
67 | /**\r | |
68 | Runs a shell command on a given command line.\r | |
69 | \r | |
70 | The specific operation of a given shell command is specified in the UEFI Shell\r | |
71 | Specification 2.0, or in the source of the given command.\r | |
72 | \r | |
73 | Upon completion of the command run the shell protocol and environment variables\r | |
74 | may have been updated due to the operation.\r | |
75 | \r | |
76 | @param[in] ImageHandle The ImageHandle to the app, or NULL if\r | |
77 | the command built into shell.\r | |
78 | @param[in] SystemTable The pointer to the system table.\r | |
79 | \r | |
80 | @retval RETURN_SUCCESS The shell command was sucessful.\r | |
81 | @retval RETURN_UNSUPPORTED The command is not supported.\r | |
82 | **/\r | |
83 | typedef\r | |
84 | SHELL_STATUS\r | |
85 | (EFIAPI *SHELL_RUN_COMMAND)(\r | |
86 | IN EFI_HANDLE ImageHandle,\r | |
87 | IN EFI_SYSTEM_TABLE *SystemTable\r | |
88 | );\r | |
89 | \r | |
90 | /**\r | |
91 | Registers the handlers of type SHELL_RUN_COMMAND and\r | |
92 | SHELL_GET_MAN_FILENAME for each shell command.\r | |
93 | \r | |
94 | If the ShellSupportLevel is greater than the value of\r | |
95 | PcdShellSupportLevel, then return RETURN_UNSUPPORTED.\r | |
96 | \r | |
97 | Registers the the handlers specified by GetHelpInfoHandler and CommandHandler\r | |
98 | with the command specified by CommandString. If the command named by\r | |
99 | CommandString has already been registered, then return\r | |
100 | RETURN_ALREADY_STARTED.\r | |
101 | \r | |
102 | If there are not enough resources available to register the handlers, then\r | |
103 | RETURN_OUT_OF_RESOURCES is returned.\r | |
104 | \r | |
105 | If CommandString is NULL, then ASSERT().\r | |
106 | If GetHelpInfoHandler is NULL, then ASSERT().\r | |
107 | If CommandHandler is NULL, then ASSERT().\r | |
108 | If ProfileName is NULL, then ASSERT().\r | |
109 | \r | |
110 | @param[in] CommandString The pointer to the command name. This is the\r | |
111 | name to look for on the command line in\r | |
112 | the shell.\r | |
113 | @param[in] CommandHandler The pointer to a function that runs the\r | |
114 | specified command.\r | |
115 | @param[in] GetManFileName The pointer to a function that provides man\r | |
116 | filename.\r | |
117 | @param[in] ShellMinSupportLevel The minimum Shell Support Level which has this\r | |
118 | function.\r | |
119 | @param[in] ProfileName The profile name to require for support of this\r | |
120 | function.\r | |
121 | @param[in] CanAffectLE Indicates whether this command's return value\r | |
122 | can change the LASTERROR environment variable.\r | |
123 | @param[in] HiiHandle The handle of this command's HII entry.\r | |
124 | @param[in] ManFormatHelp The HII locator for the help text.\r | |
125 | \r | |
126 | @retval RETURN_SUCCESS The handlers were registered.\r | |
127 | @retval RETURN_OUT_OF_RESOURCES There are not enough resources available to\r | |
128 | register the shell command.\r | |
129 | @retval RETURN_UNSUPPORTED The ShellMinSupportLevel was higher than the\r | |
130 | currently allowed support level.\r | |
131 | @retval RETURN_ALREADY_STARTED The CommandString represents a command that\r | |
132 | is already registered. Only one handler set for\r | |
133 | a given command is allowed.\r | |
134 | @sa SHELL_GET_MAN_FILENAME\r | |
135 | @sa SHELL_RUN_COMMAND\r | |
136 | **/\r | |
137 | RETURN_STATUS\r | |
138 | EFIAPI\r | |
139 | ShellCommandRegisterCommandName (\r | |
140 | IN CONST CHAR16 *CommandString,\r | |
141 | IN SHELL_RUN_COMMAND CommandHandler,\r | |
142 | IN SHELL_GET_MAN_FILENAME GetManFileName,\r | |
143 | IN UINT32 ShellMinSupportLevel,\r | |
144 | IN CONST CHAR16 *ProfileName,\r | |
145 | IN CONST BOOLEAN CanAffectLE,\r | |
146 | IN CONST EFI_HANDLE HiiHandle,\r | |
147 | IN CONST EFI_STRING_ID ManFormatHelp\r | |
148 | );\r | |
149 | \r | |
150 | /**\r | |
151 | Checks if a command string has been registered for CommandString, and if so, it runs\r | |
152 | the previously registered handler for that command with the command line.\r | |
153 | \r | |
154 | If CommandString is NULL, then ASSERT().\r | |
155 | \r | |
156 | If Sections is specified, then each section name listed will be compared in a case sensitive\r | |
157 | manner to the section names described in Appendix B UEFI Shell 2.0 Specification. If the section exists,\r | |
158 | it is appended to the returned help text. If the section does not exist, no\r | |
159 | information is returned. If Sections is NULL, then all help text information\r | |
160 | available is returned.\r | |
161 | \r | |
4ff7e37b ED |
162 | @param[in] CommandString The pointer to the command name. This is the name\r |
163 | found on the command line in the shell.\r | |
164 | @param[in, out] RetVal The pointer to the return value from the command handler.\r | |
a405b86d | 165 | \r |
4ff7e37b ED |
166 | @param[in, out] CanAffectLE Indicates whether this command's return value\r |
167 | needs to be placed into LASTERROR environment variable.\r | |
a405b86d | 168 | \r |
169 | @retval RETURN_SUCCESS The handler was run.\r | |
170 | @retval RETURN_NOT_FOUND The CommandString did not match a registered\r | |
171 | command name.\r | |
172 | @sa SHELL_RUN_COMMAND\r | |
173 | **/\r | |
174 | RETURN_STATUS\r | |
175 | EFIAPI\r | |
176 | ShellCommandRunCommandHandler (\r | |
177 | IN CONST CHAR16 *CommandString,\r | |
178 | IN OUT SHELL_STATUS *RetVal,\r | |
179 | IN OUT BOOLEAN *CanAffectLE OPTIONAL\r | |
180 | );\r | |
181 | \r | |
182 | /**\r | |
183 | Checks if a command string has been registered for CommandString, and if so, it\r | |
184 | returns the MAN filename specified for that command.\r | |
185 | \r | |
186 | If CommandString is NULL, then ASSERT().\r | |
187 | \r | |
188 | @param[in] CommandString The pointer to the command name. This is the name\r | |
189 | found on the command line in the shell.\r | |
190 | \r | |
191 | @retval NULL The CommandString was not a registered command.\r | |
192 | @retval other The name of the MAN file.\r | |
193 | @sa SHELL_GET_MAN_FILENAME\r | |
194 | **/\r | |
195 | CONST CHAR16*\r | |
196 | EFIAPI\r | |
197 | ShellCommandGetManFileNameHandler (\r | |
198 | IN CONST CHAR16 *CommandString\r | |
199 | );\r | |
200 | \r | |
201 | \r | |
202 | typedef struct {\r | |
203 | LIST_ENTRY Link;\r | |
204 | CHAR16 *CommandString;\r | |
205 | } COMMAND_LIST;\r | |
206 | \r | |
207 | /**\r | |
208 | Get the list of all available shell internal commands. This is a linked list,\r | |
209 | via the LIST_ENTRY structure. Enumerate through it using the BaseLib linked\r | |
210 | list functions. Do not modify the values.\r | |
211 | \r | |
4bbdc0e1 | 212 | @param[in] Sort TRUE to alphabetically sort the values first. FALSE otherwise.\r |
213 | \r | |
a405b86d | 214 | @return A linked list of all available shell commands.\r |
215 | **/\r | |
216 | CONST COMMAND_LIST*\r | |
217 | EFIAPI\r | |
218 | ShellCommandGetCommandList (\r | |
4bbdc0e1 | 219 | IN CONST BOOLEAN Sort\r |
a405b86d | 220 | );\r |
221 | \r | |
222 | typedef struct {\r | |
223 | LIST_ENTRY Link;\r | |
224 | CHAR16 *CommandString;\r | |
225 | CHAR16 *Alias;\r | |
226 | } ALIAS_LIST;\r | |
227 | \r | |
228 | /**\r | |
229 | Registers aliases to be set as part of the initialization of the shell application.\r | |
230 | \r | |
231 | If Command is NULL, then ASSERT().\r | |
232 | If Alias is NULL, then ASSERT().\r | |
233 | \r | |
234 | @param[in] Command The pointer to the Command.\r | |
235 | @param[in] Alias The pointer to Alias.\r | |
236 | \r | |
237 | @retval RETURN_SUCCESS The handlers were registered.\r | |
238 | @retval RETURN_OUT_OF_RESOURCES There are not enough resources available to\r | |
239 | register the shell command.\r | |
240 | **/\r | |
241 | RETURN_STATUS\r | |
242 | EFIAPI\r | |
243 | ShellCommandRegisterAlias (\r | |
244 | IN CONST CHAR16 *Command,\r | |
245 | IN CONST CHAR16 *Alias\r | |
246 | );\r | |
247 | \r | |
248 | /**\r | |
249 | Get the list of all shell alias commands. This is a linked list,\r | |
250 | via LIST_ENTRY structure. Enumerate through it using the BaseLib linked\r | |
251 | list functions. Do not modify the values.\r | |
252 | \r | |
253 | @return A linked list of all requested shell aliases.\r | |
254 | **/\r | |
255 | CONST ALIAS_LIST*\r | |
256 | EFIAPI\r | |
257 | ShellCommandGetInitAliasList (\r | |
258 | VOID\r | |
259 | );\r | |
260 | \r | |
261 | /**\r | |
262 | Determine if a given alias is on the list of built in aliases.\r | |
263 | \r | |
264 | @param[in] Alias The alias to test for.\r | |
265 | \r | |
266 | @retval TRUE The alias is a built in alias.\r | |
267 | @retval FALSE The alias is not a built in alias.\r | |
268 | **/\r | |
269 | BOOLEAN\r | |
270 | EFIAPI\r | |
271 | ShellCommandIsOnAliasList (\r | |
272 | IN CONST CHAR16 *Alias\r | |
273 | );\r | |
274 | \r | |
275 | /**\r | |
276 | Checks if a command is already on the list.\r | |
277 | \r | |
278 | @param[in] CommandString The command string to check for on the list.\r | |
279 | \r | |
280 | @retval TRUE CommandString represents a registered command.\r | |
281 | @retval FALSE CommandString does not represent a registered command.\r | |
282 | **/\r | |
283 | BOOLEAN\r | |
284 | EFIAPI\r | |
285 | ShellCommandIsCommandOnList (\r | |
286 | IN CONST CHAR16 *CommandString\r | |
287 | );\r | |
288 | \r | |
289 | /**\r | |
290 | Get the help text for a command.\r | |
291 | \r | |
292 | @param[in] CommandString The command name.\r | |
293 | \r | |
294 | @retval NULL No help text was found.\r | |
295 | @return The string of the help text. The caller required to free.\r | |
296 | **/\r | |
297 | CHAR16*\r | |
298 | EFIAPI\r | |
299 | ShellCommandGetCommandHelp (\r | |
300 | IN CONST CHAR16 *CommandString\r | |
301 | );\r | |
302 | \r | |
303 | /**\r | |
304 | Function to make sure that the above pointers are valid.\r | |
305 | **/\r | |
306 | EFI_STATUS\r | |
307 | EFIAPI\r | |
308 | CommandInit (\r | |
309 | VOID\r | |
310 | );\r | |
311 | \r | |
312 | /**\r | |
313 | Function to determine current state of ECHO. Echo determines if lines from scripts\r | |
314 | and ECHO commands are enabled.\r | |
315 | \r | |
316 | @retval TRUE Echo is currently enabled.\r | |
317 | @retval FALSE Echo is currently disabled.\r | |
318 | **/\r | |
319 | BOOLEAN\r | |
320 | EFIAPI\r | |
321 | ShellCommandGetEchoState (\r | |
322 | VOID\r | |
323 | );\r | |
324 | \r | |
325 | /**\r | |
326 | Function to set current state of ECHO. Echo determines if lines from scripts\r | |
327 | and ECHO commands are enabled.\r | |
328 | \r | |
329 | @param[in] State TRUE to enable Echo, FALSE otherwise.\r | |
330 | **/\r | |
331 | VOID\r | |
332 | EFIAPI\r | |
333 | ShellCommandSetEchoState (\r | |
334 | IN BOOLEAN State\r | |
335 | );\r | |
336 | \r | |
337 | \r | |
338 | \r | |
339 | /**\r | |
340 | Indicate that the current shell or script should exit.\r | |
341 | \r | |
342 | @param[in] ScriptOnly TRUE if exiting a script; FALSE otherwise.\r | |
b6b22b13 | 343 | @param[in] ErrorCode The 64 bit error code to return.\r |
a405b86d | 344 | **/\r |
345 | VOID\r | |
346 | EFIAPI\r | |
347 | ShellCommandRegisterExit (\r | |
b6b22b13 | 348 | IN BOOLEAN ScriptOnly,\r |
349 | IN CONST UINT64 ErrorCode\r | |
350 | );\r | |
351 | \r | |
352 | /**\r | |
353 | Retrieve the Exit code.\r | |
354 | \r | |
355 | @return the value passed into RegisterExit.\r | |
356 | **/\r | |
357 | UINT64\r | |
358 | EFIAPI\r | |
359 | ShellCommandGetExitCode (\r | |
360 | VOID\r | |
a405b86d | 361 | );\r |
362 | \r | |
363 | /**\r | |
364 | Retrieve the Exit indicator.\r | |
365 | \r | |
366 | @retval TRUE Exit was indicated.\r | |
367 | @retval FALSE Exit was not indicated.\r | |
368 | **/\r | |
369 | BOOLEAN\r | |
370 | EFIAPI\r | |
371 | ShellCommandGetExit (\r | |
372 | VOID\r | |
373 | );\r | |
374 | \r | |
375 | /**\r | |
376 | Retrieve the Exit script indicator.\r | |
377 | \r | |
378 | If ShellCommandGetExit returns FALSE, then the return from this is undefined.\r | |
379 | \r | |
380 | @retval TRUE ScriptOnly was indicated.\r | |
381 | @retval FALSE ScriptOnly was not indicated.\r | |
382 | **/\r | |
383 | BOOLEAN\r | |
384 | EFIAPI\r | |
385 | ShellCommandGetScriptExit (\r | |
386 | VOID\r | |
387 | );\r | |
388 | \r | |
389 | typedef struct {\r | |
390 | LIST_ENTRY Link; ///< List enumerator items.\r | |
391 | UINTN Line; ///< What line of the script file this was on.\r | |
392 | CHAR16 *Cl; ///< The original command line.\r | |
393 | VOID *Data; ///< The data structure format dependant upon Command. (not always used)\r | |
394 | BOOLEAN Reset; ///< Reset the command (it must be treated like a initial run (but it may have data already))\r | |
395 | } SCRIPT_COMMAND_LIST;\r | |
396 | \r | |
397 | typedef struct {\r | |
398 | CHAR16 *ScriptName; ///< The filename of this script.\r | |
399 | CHAR16 **Argv; ///< The parmameters to the script file.\r | |
400 | UINTN Argc; ///< The count of parameters.\r | |
401 | LIST_ENTRY CommandList; ///< The script converted to a list of commands (SCRIPT_COMMAND_LIST objects).\r | |
402 | SCRIPT_COMMAND_LIST *CurrentCommand; ///< The command currently being operated. If !=NULL must be a member of CommandList.\r | |
403 | LIST_ENTRY SubstList; ///< A list of current script loop alias' (ALIAS_LIST objects) (Used for the for %-based replacement).\r | |
404 | } SCRIPT_FILE;\r | |
405 | \r | |
406 | /**\r | |
407 | Function to return a pointer to the currently running script file object.\r | |
408 | \r | |
409 | @retval NULL A script file is not currently running.\r | |
410 | @return A pointer to the current script file object.\r | |
411 | **/\r | |
412 | SCRIPT_FILE*\r | |
413 | EFIAPI\r | |
414 | ShellCommandGetCurrentScriptFile (\r | |
415 | VOID\r | |
416 | );\r | |
417 | \r | |
418 | /**\r | |
419 | Function to set a new script as the currently running one.\r | |
420 | \r | |
421 | This function will correctly stack and unstack nested scripts.\r | |
422 | \r | |
423 | @param[in] Script The pointer to new script information structure. If NULL,\r | |
424 | it removes and de-allocates the topmost Script structure.\r | |
425 | \r | |
426 | @return A pointer to the current running script file after this\r | |
427 | change. It is NULL if removing the final script.\r | |
428 | **/\r | |
429 | SCRIPT_FILE*\r | |
430 | EFIAPI\r | |
431 | ShellCommandSetNewScript (\r | |
432 | IN SCRIPT_FILE *Script OPTIONAL\r | |
433 | );\r | |
434 | \r | |
0ab85bef | 435 | /**\r |
436 | Function to cleanup all memory from a SCRIPT_FILE structure.\r | |
437 | \r | |
438 | @param[in] Script The pointer to the structure to cleanup.\r | |
439 | **/\r | |
440 | VOID\r | |
441 | EFIAPI\r | |
442 | DeleteScriptFileStruct (\r | |
443 | IN SCRIPT_FILE *Script\r | |
444 | );\r | |
445 | \r | |
a405b86d | 446 | /**\r |
447 | Function to get the current Profile string.\r | |
448 | \r | |
449 | This is used to retrieve what profiles were installed.\r | |
450 | \r | |
451 | @retval NULL There are no installed profiles.\r | |
452 | @return A semicolon-delimited list of profiles.\r | |
453 | **/\r | |
454 | CONST CHAR16 *\r | |
455 | EFIAPI\r | |
456 | ShellCommandGetProfileList (\r | |
457 | VOID\r | |
458 | );\r | |
459 | \r | |
460 | typedef enum {\r | |
461 | MappingTypeFileSystem,\r | |
462 | MappingTypeBlockIo,\r | |
463 | MappingTypeMax\r | |
464 | } SHELL_MAPPING_TYPE;\r | |
465 | \r | |
466 | /**\r | |
467 | Function to generate the next default mapping name.\r | |
468 | \r | |
469 | If the return value is not NULL then it must be callee freed.\r | |
470 | \r | |
471 | @param Type What kind of mapping name to make.\r | |
472 | \r | |
473 | @retval NULL a memory allocation failed.\r | |
474 | @return a new map name string\r | |
475 | **/\r | |
476 | CHAR16*\r | |
477 | EFIAPI\r | |
478 | ShellCommandCreateNewMappingName(\r | |
479 | IN CONST SHELL_MAPPING_TYPE Type\r | |
480 | );\r | |
481 | \r | |
482 | /**\r | |
483 | Function to initialize the table for creating consistent map names.\r | |
484 | \r | |
485 | @param[out] Table The pointer to pointer to pointer to DevicePathProtocol object.\r | |
486 | \r | |
487 | @retval EFI_SUCCESS The table was created successfully.\r | |
488 | **/\r | |
489 | EFI_STATUS\r | |
490 | EFIAPI\r | |
491 | ShellCommandConsistMappingInitialize (\r | |
492 | EFI_DEVICE_PATH_PROTOCOL ***Table\r | |
493 | );\r | |
494 | \r | |
495 | /**\r | |
496 | Function to uninitialize the table for creating consistent map names.\r | |
497 | \r | |
498 | The parameter must have been received from ShellCommandConsistMappingInitialize.\r | |
499 | \r | |
500 | @param[out] Table The pointer to pointer to DevicePathProtocol object.\r | |
501 | \r | |
502 | @retval EFI_SUCCESS The table was deleted successfully.\r | |
503 | **/\r | |
504 | EFI_STATUS\r | |
505 | EFIAPI\r | |
506 | ShellCommandConsistMappingUnInitialize (\r | |
507 | EFI_DEVICE_PATH_PROTOCOL **Table\r | |
508 | );\r | |
509 | \r | |
510 | /**\r | |
511 | Create a consistent mapped name for the device specified by DevicePath \r | |
512 | based on the Table.\r | |
513 | \r | |
514 | This must be called after ShellCommandConsistMappingInitialize() and \r | |
515 | before ShellCommandConsistMappingUnInitialize() is called.\r | |
516 | \r | |
4bbdc0e1 | 517 | @param[in] DevicePath The pointer to the dev path for the device.\r |
a405b86d | 518 | @param[in] Table The Table of mapping information.\r |
519 | \r | |
520 | @retval NULL A consistent mapped name could not be created.\r | |
521 | @return A pointer to a string allocated from pool with the device name.\r | |
522 | **/\r | |
523 | CHAR16*\r | |
524 | EFIAPI\r | |
525 | ShellCommandConsistMappingGenMappingName (\r | |
526 | IN EFI_DEVICE_PATH_PROTOCOL *DevicePath,\r | |
527 | IN EFI_DEVICE_PATH_PROTOCOL **Table\r | |
528 | );\r | |
529 | \r | |
530 | /**\r | |
531 | Function to search the list of mappings for the first matching node on the\r | |
532 | list based on the MapKey.\r | |
533 | \r | |
534 | @param[in] MapKey The pointer to the string key to search for in the map.\r | |
535 | \r | |
536 | @return the node on the list.\r | |
537 | **/\r | |
538 | SHELL_MAP_LIST*\r | |
539 | EFIAPI\r | |
540 | ShellCommandFindMapItem (\r | |
541 | IN CONST CHAR16 *MapKey\r | |
542 | );\r | |
543 | \r | |
544 | /**\r | |
545 | Function to add a map node to the list of map items and update the "path" environment variable (optionally).\r | |
546 | \r | |
547 | If Path is TRUE (during initialization only), the path environment variable will also be updated to include\r | |
548 | default paths on the new map name...\r | |
549 | \r | |
550 | Path should be FALSE when this function is called from the protocol SetMap function.\r | |
551 | \r | |
552 | @param[in] Name The human readable mapped name.\r | |
553 | @param[in] DevicePath The Device Path for this map.\r | |
554 | @param[in] Flags The Flags attribute for this map item.\r | |
555 | @param[in] Path TRUE to update path, FALSE to skip this step (should only be TRUE during initialization).\r | |
556 | \r | |
557 | @retval EFI_SUCCESS The addition was sucessful.\r | |
558 | @retval EFI_OUT_OF_RESOURCES A memory allocation failed.\r | |
559 | @retval EFI_INVALID_PARAMETER A parameter was invalid.\r | |
560 | **/\r | |
561 | EFI_STATUS\r | |
562 | EFIAPI\r | |
563 | ShellCommandAddMapItemAndUpdatePath(\r | |
564 | IN CONST CHAR16 *Name,\r | |
565 | IN CONST EFI_DEVICE_PATH_PROTOCOL *DevicePath,\r | |
566 | IN CONST UINT64 Flags,\r | |
567 | IN CONST BOOLEAN Path\r | |
568 | );\r | |
569 | \r | |
570 | /**\r | |
571 | Creates the default map names for each device path in the system with\r | |
572 | a protocol depending on the Type.\r | |
573 | \r | |
574 | Also sets up the default path environment variable if Type is FileSystem.\r | |
575 | \r | |
576 | @retval EFI_SUCCESS All map names were created sucessfully.\r | |
577 | @retval EFI_NOT_FOUND No protocols were found in the system.\r | |
578 | @return Error returned from gBS->LocateHandle().\r | |
579 | \r | |
580 | @sa LocateHandle\r | |
581 | **/\r | |
582 | EFI_STATUS\r | |
583 | EFIAPI\r | |
584 | ShellCommandCreateInitialMappingsAndPaths(\r | |
585 | VOID\r | |
586 | );\r | |
587 | \r | |
a405b86d | 588 | /**\r |
589 | Converts a SHELL_FILE_HANDLE to an EFI_FILE_PROTOCOL*.\r | |
590 | \r | |
591 | @param[in] Handle The SHELL_FILE_HANDLE to convert.\r | |
592 | \r | |
593 | @return a EFI_FILE_PROTOCOL* representing the same file.\r | |
594 | **/\r | |
595 | EFI_FILE_PROTOCOL*\r | |
596 | EFIAPI\r | |
597 | ConvertShellHandleToEfiFileProtocol(\r | |
598 | IN CONST SHELL_FILE_HANDLE Handle\r | |
599 | );\r | |
600 | \r | |
601 | /**\r | |
602 | Remove a SHELL_FILE_HANDLE frmo the list of SHELL_FILE_HANDLES.\r | |
603 | \r | |
604 | @param[in] Handle The SHELL_FILE_HANDLE to remove.\r | |
605 | \r | |
606 | @retval TRUE The item was removed.\r | |
607 | @retval FALSE The item was not found.\r | |
608 | **/\r | |
609 | BOOLEAN\r | |
610 | EFIAPI\r | |
611 | ShellFileHandleRemove(\r | |
612 | IN CONST SHELL_FILE_HANDLE Handle\r | |
613 | );\r | |
614 | \r | |
615 | /**\r | |
616 | Converts a EFI_FILE_PROTOCOL* to an SHELL_FILE_HANDLE.\r | |
617 | \r | |
618 | @param[in] Handle The pointer to EFI_FILE_PROTOCOL to convert.\r | |
619 | @param[in] Path The path to the file for verification.\r | |
620 | \r | |
621 | @return a SHELL_FILE_HANDLE representing the same file.\r | |
622 | **/\r | |
623 | SHELL_FILE_HANDLE\r | |
624 | EFIAPI\r | |
625 | ConvertEfiFileProtocolToShellHandle(\r | |
626 | IN CONST EFI_FILE_PROTOCOL *Handle,\r | |
627 | IN CONST CHAR16 *Path\r | |
628 | );\r | |
629 | \r | |
630 | /**\r | |
631 | Find the path that was logged with the specified SHELL_FILE_HANDLE.\r | |
632 | \r | |
633 | @param[in] Handle The SHELL_FILE_HANDLE to query on.\r | |
634 | \r | |
635 | @return A pointer to the path for the file.\r | |
636 | **/\r | |
637 | CONST CHAR16*\r | |
638 | EFIAPI\r | |
639 | ShellFileHandleGetPath(\r | |
640 | IN CONST SHELL_FILE_HANDLE Handle\r | |
641 | );\r | |
642 | \r | |
643 | \r | |
644 | /**\r | |
645 | Function to determine if a SHELL_FILE_HANDLE is at the end of the file.\r | |
646 | \r | |
647 | This will NOT work on directories.\r | |
648 | \r | |
649 | If Handle is NULL, then ASSERT.\r | |
650 | \r | |
651 | @param[in] Handle the file handle\r | |
652 | \r | |
653 | @retval TRUE the position is at the end of the file\r | |
654 | @retval FALSE the position is not at the end of the file\r | |
655 | **/\r | |
656 | BOOLEAN\r | |
657 | EFIAPI\r | |
658 | ShellFileHandleEof(\r | |
659 | IN SHELL_FILE_HANDLE Handle\r | |
660 | );\r | |
661 | \r | |
a405b86d | 662 | typedef struct {\r |
663 | LIST_ENTRY Link;\r | |
664 | void *Buffer;\r | |
665 | } BUFFER_LIST;\r | |
666 | \r | |
667 | /**\r | |
668 | Frees any BUFFER_LIST defined type.\r | |
669 | \r | |
670 | @param[in] List The pointer to the list head.\r | |
671 | **/\r | |
672 | VOID\r | |
673 | EFIAPI\r | |
674 | FreeBufferList (\r | |
675 | IN BUFFER_LIST *List\r | |
676 | );\r | |
677 | \r | |
a405b86d | 678 | #endif //_SHELL_COMMAND_LIB_\r |