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