1 | /** @file
|
---|
2 | Provides interface to shell functionality for shell commands and applications.
|
---|
3 |
|
---|
4 | Copyright (c) 2006 - 2011, Intel Corporation. All rights reserved.<BR>
|
---|
5 | This program and the accompanying materials
|
---|
6 | are licensed and made available under the terms and conditions of the BSD License
|
---|
7 | which accompanies this distribution. The full text of the license may be found at
|
---|
8 | http://opensource.org/licenses/bsd-license.php
|
---|
9 |
|
---|
10 | THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
|
---|
11 | WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
|
---|
12 |
|
---|
13 | **/
|
---|
14 |
|
---|
15 | #ifndef __SHELL_LIB__
|
---|
16 | #define __SHELL_LIB__
|
---|
17 |
|
---|
18 | #include <Uefi.h>
|
---|
19 | #include <Guid/FileInfo.h>
|
---|
20 | #include <Protocol/SimpleFileSystem.h>
|
---|
21 | #include <Protocol/LoadedImage.h>
|
---|
22 | #include <Protocol/EfiShellInterface.h>
|
---|
23 | #include <Protocol/EfiShellEnvironment2.h>
|
---|
24 | #include <Protocol/EfiShell.h>
|
---|
25 | #include <Protocol/EfiShellParameters.h>
|
---|
26 |
|
---|
27 | // (20 * (6+5+2))+1) unicode characters from EFI FAT spec (doubled for bytes)
|
---|
28 | #define MAX_FILE_NAME_LEN 512
|
---|
29 |
|
---|
30 | extern EFI_SHELL_PARAMETERS_PROTOCOL *gEfiShellParametersProtocol;
|
---|
31 | extern EFI_SHELL_PROTOCOL *gEfiShellProtocol;
|
---|
32 |
|
---|
33 | /**
|
---|
34 | This function will retrieve the information about the file for the handle
|
---|
35 | specified and store it in allocated pool memory.
|
---|
36 |
|
---|
37 | This function allocates a buffer to store the file's information. It is the
|
---|
38 | caller's responsibility to free the buffer.
|
---|
39 |
|
---|
40 | @param[in] FileHandle The file handle of the file for which information is
|
---|
41 | being requested.
|
---|
42 |
|
---|
43 | @retval NULL Information could not be retrieved.
|
---|
44 |
|
---|
45 | @return The information about the file.
|
---|
46 | **/
|
---|
47 | EFI_FILE_INFO*
|
---|
48 | EFIAPI
|
---|
49 | ShellGetFileInfo (
|
---|
50 | IN SHELL_FILE_HANDLE FileHandle
|
---|
51 | );
|
---|
52 |
|
---|
53 | /**
|
---|
54 | This function sets the information about the file for the opened handle
|
---|
55 | specified.
|
---|
56 |
|
---|
57 | @param[in] FileHandle The file handle of the file for which information
|
---|
58 | is being set.
|
---|
59 |
|
---|
60 | @param[in] FileInfo The information to set.
|
---|
61 |
|
---|
62 | @retval EFI_SUCCESS The information was set.
|
---|
63 | @retval EFI_INVALID_PARAMETER A parameter was out of range or invalid.
|
---|
64 | @retval EFI_UNSUPPORTED The FileHandle does not support FileInfo.
|
---|
65 | @retval EFI_NO_MEDIA The device has no medium.
|
---|
66 | @retval EFI_DEVICE_ERROR The device reported an error.
|
---|
67 | @retval EFI_VOLUME_CORRUPTED The file system structures are corrupted.
|
---|
68 | @retval EFI_WRITE_PROTECTED The file or medium is write protected.
|
---|
69 | @retval EFI_ACCESS_DENIED The file was opened read only.
|
---|
70 | @retval EFI_VOLUME_FULL The volume is full.
|
---|
71 | **/
|
---|
72 | EFI_STATUS
|
---|
73 | EFIAPI
|
---|
74 | ShellSetFileInfo (
|
---|
75 | IN SHELL_FILE_HANDLE FileHandle,
|
---|
76 | IN EFI_FILE_INFO *FileInfo
|
---|
77 | );
|
---|
78 |
|
---|
79 | /**
|
---|
80 | This function will open a file or directory referenced by DevicePath.
|
---|
81 |
|
---|
82 | This function opens a file with the open mode according to the file path. The
|
---|
83 | Attributes is valid only for EFI_FILE_MODE_CREATE.
|
---|
84 |
|
---|
85 | @param[in, out] FilePath On input, the device path to the file. On output,
|
---|
86 | the remaining device path.
|
---|
87 | @param[out] DeviceHandle Pointer to the system device handle.
|
---|
88 | @param[out] FileHandle Pointer to the file handle.
|
---|
89 | @param[in] OpenMode The mode to open the file with.
|
---|
90 | @param[in] Attributes The file's file attributes.
|
---|
91 |
|
---|
92 | @retval EFI_SUCCESS The information was set.
|
---|
93 | @retval EFI_INVALID_PARAMETER One of the parameters has an invalid value.
|
---|
94 | @retval EFI_UNSUPPORTED Could not open the file path.
|
---|
95 | @retval EFI_NOT_FOUND The specified file could not be found on the
|
---|
96 | device or the file system could not be found on
|
---|
97 | the device.
|
---|
98 | @retval EFI_NO_MEDIA The device has no medium.
|
---|
99 | @retval EFI_MEDIA_CHANGED The device has a different medium in it or the
|
---|
100 | medium is no longer supported.
|
---|
101 | @retval EFI_DEVICE_ERROR The device reported an error.
|
---|
102 | @retval EFI_VOLUME_CORRUPTED The file system structures are corrupted.
|
---|
103 | @retval EFI_WRITE_PROTECTED The file or medium is write protected.
|
---|
104 | @retval EFI_ACCESS_DENIED The file was opened read only.
|
---|
105 | @retval EFI_OUT_OF_RESOURCES Not enough resources were available to open the
|
---|
106 | file.
|
---|
107 | @retval EFI_VOLUME_FULL The volume is full.
|
---|
108 | **/
|
---|
109 | EFI_STATUS
|
---|
110 | EFIAPI
|
---|
111 | ShellOpenFileByDevicePath(
|
---|
112 | IN OUT EFI_DEVICE_PATH_PROTOCOL **FilePath,
|
---|
113 | OUT EFI_HANDLE *DeviceHandle,
|
---|
114 | OUT SHELL_FILE_HANDLE *FileHandle,
|
---|
115 | IN UINT64 OpenMode,
|
---|
116 | IN UINT64 Attributes
|
---|
117 | );
|
---|
118 |
|
---|
119 | /**
|
---|
120 | This function will open a file or directory referenced by filename.
|
---|
121 |
|
---|
122 | If return is EFI_SUCCESS, the Filehandle is the opened file's handle;
|
---|
123 | otherwise, the Filehandle is NULL. Attributes is valid only for
|
---|
124 | EFI_FILE_MODE_CREATE.
|
---|
125 |
|
---|
126 | @param[in] FilePath The pointer to file name.
|
---|
127 | @param[out] FileHandle The pointer to the file handle.
|
---|
128 | @param[in] OpenMode The mode to open the file with.
|
---|
129 | @param[in] Attributes The file's file attributes.
|
---|
130 |
|
---|
131 | @retval EFI_SUCCESS The information was set.
|
---|
132 | @retval EFI_INVALID_PARAMETER One of the parameters has an invalid value.
|
---|
133 | @retval EFI_UNSUPPORTED Could not open the file path.
|
---|
134 | @retval EFI_NOT_FOUND The specified file could not be found on the
|
---|
135 | device or the file system could not be found
|
---|
136 | on the device.
|
---|
137 | @retval EFI_NO_MEDIA The device has no medium.
|
---|
138 | @retval EFI_MEDIA_CHANGED The device has a different medium in it or the
|
---|
139 | medium is no longer supported.
|
---|
140 | @retval EFI_DEVICE_ERROR The device reported an error.
|
---|
141 | @retval EFI_VOLUME_CORRUPTED The file system structures are corrupted.
|
---|
142 | @retval EFI_WRITE_PROTECTED The file or medium is write protected.
|
---|
143 | @retval EFI_ACCESS_DENIED The file was opened read only.
|
---|
144 | @retval EFI_OUT_OF_RESOURCES Not enough resources were available to open the
|
---|
145 | file.
|
---|
146 | @retval EFI_VOLUME_FULL The volume is full.
|
---|
147 | **/
|
---|
148 | EFI_STATUS
|
---|
149 | EFIAPI
|
---|
150 | ShellOpenFileByName(
|
---|
151 | IN CONST CHAR16 *FilePath,
|
---|
152 | OUT SHELL_FILE_HANDLE *FileHandle,
|
---|
153 | IN UINT64 OpenMode,
|
---|
154 | IN UINT64 Attributes
|
---|
155 | );
|
---|
156 |
|
---|
157 | /**
|
---|
158 | This function creates a directory.
|
---|
159 |
|
---|
160 | If return is EFI_SUCCESS, the Filehandle is the opened directory's handle;
|
---|
161 | otherwise, the Filehandle is NULL. If the directory already existed, this
|
---|
162 | function opens the existing directory.
|
---|
163 |
|
---|
164 | @param[in] DirectoryName The pointer to Directory name.
|
---|
165 | @param[out] FileHandle The pointer to the file handle.
|
---|
166 |
|
---|
167 | @retval EFI_SUCCESS The information was set.
|
---|
168 | @retval EFI_INVALID_PARAMETER One of the parameters has an invalid value.
|
---|
169 | @retval EFI_UNSUPPORTED Could not open the file path.
|
---|
170 | @retval EFI_NOT_FOUND The specified file could not be found on the
|
---|
171 | device, or the file system could not be found
|
---|
172 | on the device.
|
---|
173 | @retval EFI_NO_MEDIA The device has no medium.
|
---|
174 | @retval EFI_MEDIA_CHANGED The device has a different medium in it or the
|
---|
175 | medium is no longer supported.
|
---|
176 | @retval EFI_DEVICE_ERROR The device reported an error.
|
---|
177 | @retval EFI_VOLUME_CORRUPTED The file system structures are corrupted.
|
---|
178 | @retval EFI_WRITE_PROTECTED The file or medium is write protected.
|
---|
179 | @retval EFI_ACCESS_DENIED The file was opened read only.
|
---|
180 | @retval EFI_OUT_OF_RESOURCES Not enough resources were available to open the
|
---|
181 | file.
|
---|
182 | @retval EFI_VOLUME_FULL The volume is full.
|
---|
183 | **/
|
---|
184 | EFI_STATUS
|
---|
185 | EFIAPI
|
---|
186 | ShellCreateDirectory(
|
---|
187 | IN CONST CHAR16 *DirectoryName,
|
---|
188 | OUT SHELL_FILE_HANDLE *FileHandle
|
---|
189 | );
|
---|
190 |
|
---|
191 | /**
|
---|
192 | This function reads information from an opened file.
|
---|
193 |
|
---|
194 | If FileHandle is not a directory, the function reads the requested number of
|
---|
195 | bytes from the file at the file's current position and returns them in Buffer.
|
---|
196 | If the read goes beyond the end of the file, the read length is truncated to the
|
---|
197 | end of the file. The file's current position is increased by the number of bytes
|
---|
198 | returned. If FileHandle is a directory, the function reads the directory entry
|
---|
199 | at the file's current position and returns the entry in Buffer. If the Buffer
|
---|
200 | is not large enough to hold the current directory entry, then
|
---|
201 | EFI_BUFFER_TOO_SMALL is returned and the current file position is not updated.
|
---|
202 | BufferSize is set to be the size of the buffer needed to read the entry. On
|
---|
203 | success, the current position is updated to the next directory entry. If there
|
---|
204 | are no more directory entries, the read returns a zero-length buffer.
|
---|
205 | EFI_FILE_INFO is the structure returned as the directory entry.
|
---|
206 |
|
---|
207 | @param[in] FileHandle The opened file handle.
|
---|
208 | @param[in, out] ReadSize On input the size of buffer in bytes. On return
|
---|
209 | the number of bytes written.
|
---|
210 | @param[out] Buffer The buffer to put read data into.
|
---|
211 |
|
---|
212 | @retval EFI_SUCCESS Data was read.
|
---|
213 | @retval EFI_NO_MEDIA The device has no media.
|
---|
214 | @retval EFI_DEVICE_ERROR The device reported an error.
|
---|
215 | @retval EFI_VOLUME_CORRUPTED The file system structures are corrupted.
|
---|
216 | @retval EFI_BUFFER_TO_SMALL Buffer is too small. ReadSize contains required
|
---|
217 | size.
|
---|
218 |
|
---|
219 | **/
|
---|
220 | EFI_STATUS
|
---|
221 | EFIAPI
|
---|
222 | ShellReadFile(
|
---|
223 | IN SHELL_FILE_HANDLE FileHandle,
|
---|
224 | IN OUT UINTN *ReadSize,
|
---|
225 | OUT VOID *Buffer
|
---|
226 | );
|
---|
227 |
|
---|
228 | /**
|
---|
229 | Write data to a file.
|
---|
230 |
|
---|
231 | This function writes the specified number of bytes to the file at the current
|
---|
232 | file position. The current file position is advanced the actual number of bytes
|
---|
233 | written, which is returned in BufferSize. Partial writes only occur when there
|
---|
234 | has been a data error during the write attempt (such as "volume space full").
|
---|
235 | The file is automatically grown to hold the data if required. Direct writes to
|
---|
236 | opened directories are not supported.
|
---|
237 |
|
---|
238 | @param[in] FileHandle The opened file for writing.
|
---|
239 |
|
---|
240 | @param[in, out] BufferSize On input the number of bytes in Buffer. On output
|
---|
241 | the number of bytes written.
|
---|
242 |
|
---|
243 | @param[in] Buffer The buffer containing data to write is stored.
|
---|
244 |
|
---|
245 | @retval EFI_SUCCESS Data was written.
|
---|
246 | @retval EFI_UNSUPPORTED Writes to an open directory are not supported.
|
---|
247 | @retval EFI_NO_MEDIA The device has no media.
|
---|
248 | @retval EFI_DEVICE_ERROR The device reported an error.
|
---|
249 | @retval EFI_VOLUME_CORRUPTED The file system structures are corrupted.
|
---|
250 | @retval EFI_WRITE_PROTECTED The device is write-protected.
|
---|
251 | @retval EFI_ACCESS_DENIED The file was open for read only.
|
---|
252 | @retval EFI_VOLUME_FULL The volume is full.
|
---|
253 | **/
|
---|
254 | EFI_STATUS
|
---|
255 | EFIAPI
|
---|
256 | ShellWriteFile(
|
---|
257 | IN SHELL_FILE_HANDLE FileHandle,
|
---|
258 | IN OUT UINTN *BufferSize,
|
---|
259 | IN VOID *Buffer
|
---|
260 | );
|
---|
261 |
|
---|
262 | /**
|
---|
263 | Close an open file handle.
|
---|
264 |
|
---|
265 | This function closes a specified file handle. All "dirty" cached file data is
|
---|
266 | flushed to the device, and the file is closed. In all cases the handle is
|
---|
267 | closed.
|
---|
268 |
|
---|
269 | @param[in] FileHandle The file handle to close.
|
---|
270 |
|
---|
271 | @retval EFI_SUCCESS The file handle was closed sucessfully.
|
---|
272 | @retval INVALID_PARAMETER One of the parameters has an invalid value.
|
---|
273 | **/
|
---|
274 | EFI_STATUS
|
---|
275 | EFIAPI
|
---|
276 | ShellCloseFile (
|
---|
277 | IN SHELL_FILE_HANDLE *FileHandle
|
---|
278 | );
|
---|
279 |
|
---|
280 | /**
|
---|
281 | Delete a file and close the handle
|
---|
282 |
|
---|
283 | This function closes and deletes a file. In all cases the file handle is closed.
|
---|
284 | If the file cannot be deleted, the warning code EFI_WARN_DELETE_FAILURE is
|
---|
285 | returned, but the handle is still closed.
|
---|
286 |
|
---|
287 | @param[in] FileHandle The file handle to delete.
|
---|
288 |
|
---|
289 | @retval EFI_SUCCESS The file was closed sucessfully.
|
---|
290 | @retval EFI_WARN_DELETE_FAILURE The handle was closed, but the file was not
|
---|
291 | deleted.
|
---|
292 | @retval INVALID_PARAMETER One of the parameters has an invalid value.
|
---|
293 | **/
|
---|
294 | EFI_STATUS
|
---|
295 | EFIAPI
|
---|
296 | ShellDeleteFile (
|
---|
297 | IN SHELL_FILE_HANDLE *FileHandle
|
---|
298 | );
|
---|
299 |
|
---|
300 | /**
|
---|
301 | Set the current position in a file.
|
---|
302 |
|
---|
303 | This function sets the current file position for the handle to the position
|
---|
304 | supplied. With the exception of seeking to position 0xFFFFFFFFFFFFFFFF, only
|
---|
305 | absolute positioning is supported, and moving past the end of the file is
|
---|
306 | allowed (a subsequent write would grow the file). Moving to position
|
---|
307 | 0xFFFFFFFFFFFFFFFF causes the current position to be set to the end of the file.
|
---|
308 | If FileHandle is a directory, the only position that may be set is zero. This
|
---|
309 | has the effect of starting the read process of the directory entries over.
|
---|
310 |
|
---|
311 | @param[in] FileHandle The file handle on which the position is being set.
|
---|
312 |
|
---|
313 | @param[in] Position The byte position from the begining of the file.
|
---|
314 |
|
---|
315 | @retval EFI_SUCCESS Operation completed sucessfully.
|
---|
316 | @retval EFI_UNSUPPORTED The seek request for non-zero is not valid on
|
---|
317 | directories.
|
---|
318 | @retval INVALID_PARAMETER One of the parameters has an invalid value.
|
---|
319 | **/
|
---|
320 | EFI_STATUS
|
---|
321 | EFIAPI
|
---|
322 | ShellSetFilePosition (
|
---|
323 | IN SHELL_FILE_HANDLE FileHandle,
|
---|
324 | IN UINT64 Position
|
---|
325 | );
|
---|
326 |
|
---|
327 | /**
|
---|
328 | Gets a file's current position
|
---|
329 |
|
---|
330 | This function retrieves the current file position for the file handle. For
|
---|
331 | directories, the current file position has no meaning outside of the file
|
---|
332 | system driver and as such the operation is not supported. An error is returned
|
---|
333 | if FileHandle is a directory.
|
---|
334 |
|
---|
335 | @param[in] FileHandle The open file handle on which to get the position.
|
---|
336 | @param[out] Position The byte position from the begining of the file.
|
---|
337 |
|
---|
338 | @retval EFI_SUCCESS The operation completed sucessfully.
|
---|
339 | @retval INVALID_PARAMETER One of the parameters has an invalid value.
|
---|
340 | @retval EFI_UNSUPPORTED The request is not valid on directories.
|
---|
341 | **/
|
---|
342 | EFI_STATUS
|
---|
343 | EFIAPI
|
---|
344 | ShellGetFilePosition (
|
---|
345 | IN SHELL_FILE_HANDLE FileHandle,
|
---|
346 | OUT UINT64 *Position
|
---|
347 | );
|
---|
348 |
|
---|
349 | /**
|
---|
350 | Flushes data on a file
|
---|
351 |
|
---|
352 | This function flushes all modified data associated with a file to a device.
|
---|
353 |
|
---|
354 | @param[in] FileHandle The file handle on which to flush data.
|
---|
355 |
|
---|
356 | @retval EFI_SUCCESS The data was flushed.
|
---|
357 | @retval EFI_NO_MEDIA The device has no media.
|
---|
358 | @retval EFI_DEVICE_ERROR The device reported an error.
|
---|
359 | @retval EFI_VOLUME_CORRUPTED The file system structures are corrupted.
|
---|
360 | @retval EFI_WRITE_PROTECTED The file or medium is write protected.
|
---|
361 | @retval EFI_ACCESS_DENIED The file was opened for read only.
|
---|
362 | **/
|
---|
363 | EFI_STATUS
|
---|
364 | EFIAPI
|
---|
365 | ShellFlushFile (
|
---|
366 | IN SHELL_FILE_HANDLE FileHandle
|
---|
367 | );
|
---|
368 |
|
---|
369 | /** Retrieve first entry from a directory.
|
---|
370 |
|
---|
371 | This function takes an open directory handle and gets information from the
|
---|
372 | first entry in the directory. A buffer is allocated to contain
|
---|
373 | the information and a pointer to the buffer is returned in *Buffer. The
|
---|
374 | caller can use ShellFindNextFile() to get subsequent directory entries.
|
---|
375 |
|
---|
376 | The buffer will be freed by ShellFindNextFile() when the last directory
|
---|
377 | entry is read. Otherwise, the caller must free the buffer, using FreePool,
|
---|
378 | when finished with it.
|
---|
379 |
|
---|
380 | @param[in] DirHandle The file handle of the directory to search.
|
---|
381 | @param[out] Buffer The pointer to the buffer for the file's information.
|
---|
382 |
|
---|
383 | @retval EFI_SUCCESS Found the first file.
|
---|
384 | @retval EFI_NOT_FOUND Cannot find the directory.
|
---|
385 | @retval EFI_NO_MEDIA The device has no media.
|
---|
386 | @retval EFI_DEVICE_ERROR The device reported an error.
|
---|
387 | @retval EFI_VOLUME_CORRUPTED The file system structures are corrupted.
|
---|
388 | @return Others Status of ShellGetFileInfo, ShellSetFilePosition,
|
---|
389 | or ShellReadFile.
|
---|
390 |
|
---|
391 | @sa ShellReadFile
|
---|
392 | **/
|
---|
393 | EFI_STATUS
|
---|
394 | EFIAPI
|
---|
395 | ShellFindFirstFile (
|
---|
396 | IN SHELL_FILE_HANDLE DirHandle,
|
---|
397 | OUT EFI_FILE_INFO **Buffer
|
---|
398 | );
|
---|
399 |
|
---|
400 | /** Retrieve next entries from a directory.
|
---|
401 |
|
---|
402 | To use this function, the caller must first call the ShellFindFirstFile()
|
---|
403 | function to get the first directory entry. Subsequent directory entries are
|
---|
404 | retrieved by using the ShellFindNextFile() function. This function can
|
---|
405 | be called several times to get each entry from the directory. If the call of
|
---|
406 | ShellFindNextFile() retrieved the last directory entry, the next call of
|
---|
407 | this function will set *NoFile to TRUE and free the buffer.
|
---|
408 |
|
---|
409 | @param[in] DirHandle The file handle of the directory.
|
---|
410 | @param[in, out] Buffer The pointer to buffer for file's information.
|
---|
411 | @param[in, out] NoFile The pointer to boolean when last file is found.
|
---|
412 |
|
---|
413 | @retval EFI_SUCCESS Found the next file.
|
---|
414 | @retval EFI_NO_MEDIA The device has no media.
|
---|
415 | @retval EFI_DEVICE_ERROR The device reported an error.
|
---|
416 | @retval EFI_VOLUME_CORRUPTED The file system structures are corrupted.
|
---|
417 |
|
---|
418 | @sa ShellReadFile
|
---|
419 | **/
|
---|
420 | EFI_STATUS
|
---|
421 | EFIAPI
|
---|
422 | ShellFindNextFile(
|
---|
423 | IN SHELL_FILE_HANDLE DirHandle,
|
---|
424 | IN OUT EFI_FILE_INFO *Buffer,
|
---|
425 | IN OUT BOOLEAN *NoFile
|
---|
426 | );
|
---|
427 |
|
---|
428 | /**
|
---|
429 | Retrieve the size of a file.
|
---|
430 |
|
---|
431 | This function extracts the file size info from the FileHandle's EFI_FILE_INFO
|
---|
432 | data.
|
---|
433 |
|
---|
434 | @param[in] FileHandle The file handle from which size is retrieved.
|
---|
435 | @param[out] Size The pointer to size.
|
---|
436 |
|
---|
437 | @retval EFI_SUCCESS The operation was completed sucessfully.
|
---|
438 | @retval EFI_DEVICE_ERROR Cannot access the file.
|
---|
439 | **/
|
---|
440 | EFI_STATUS
|
---|
441 | EFIAPI
|
---|
442 | ShellGetFileSize (
|
---|
443 | IN SHELL_FILE_HANDLE FileHandle,
|
---|
444 | OUT UINT64 *Size
|
---|
445 | );
|
---|
446 |
|
---|
447 | /**
|
---|
448 | Retrieves the status of the break execution flag
|
---|
449 |
|
---|
450 | This function is useful to check whether the application is being asked to halt by the shell.
|
---|
451 |
|
---|
452 | @retval TRUE The execution break is enabled.
|
---|
453 | @retval FALSE The execution break is not enabled.
|
---|
454 | **/
|
---|
455 | BOOLEAN
|
---|
456 | EFIAPI
|
---|
457 | ShellGetExecutionBreakFlag(
|
---|
458 | VOID
|
---|
459 | );
|
---|
460 |
|
---|
461 | /**
|
---|
462 | Return the value of an environment variable.
|
---|
463 |
|
---|
464 | This function gets the value of the environment variable set by the
|
---|
465 | ShellSetEnvironmentVariable function.
|
---|
466 |
|
---|
467 | @param[in] EnvKey The key name of the environment variable.
|
---|
468 |
|
---|
469 | @retval NULL The named environment variable does not exist.
|
---|
470 | @return != NULL The pointer to the value of the environment variable.
|
---|
471 | **/
|
---|
472 | CONST CHAR16*
|
---|
473 | EFIAPI
|
---|
474 | ShellGetEnvironmentVariable (
|
---|
475 | IN CONST CHAR16 *EnvKey
|
---|
476 | );
|
---|
477 |
|
---|
478 | /**
|
---|
479 | Set the value of an environment variable.
|
---|
480 |
|
---|
481 | This function changes the current value of the specified environment variable. If the
|
---|
482 | environment variable exists and the Value is an empty string, then the environment
|
---|
483 | variable is deleted. If the environment variable exists and the Value is not an empty
|
---|
484 | string, then the value of the environment variable is changed. If the environment
|
---|
485 | variable does not exist and the Value is an empty string, there is no action. If the
|
---|
486 | environment variable does not exist and the Value is a non-empty string, then the
|
---|
487 | environment variable is created and assigned the specified value.
|
---|
488 |
|
---|
489 | This is not supported pre-UEFI Shell 2.0.
|
---|
490 |
|
---|
491 | @param[in] EnvKey The key name of the environment variable.
|
---|
492 | @param[in] EnvVal The Value of the environment variable
|
---|
493 | @param[in] Volatile Indicates whether the variable is non-volatile (FALSE) or volatile (TRUE).
|
---|
494 |
|
---|
495 | @retval EFI_SUCCESS The operation completed sucessfully
|
---|
496 | @retval EFI_UNSUPPORTED This operation is not allowed in pre-UEFI 2.0 Shell environments.
|
---|
497 | **/
|
---|
498 | EFI_STATUS
|
---|
499 | EFIAPI
|
---|
500 | ShellSetEnvironmentVariable (
|
---|
501 | IN CONST CHAR16 *EnvKey,
|
---|
502 | IN CONST CHAR16 *EnvVal,
|
---|
503 | IN BOOLEAN Volatile
|
---|
504 | );
|
---|
505 |
|
---|
506 | /**
|
---|
507 | Cause the shell to parse and execute a command line.
|
---|
508 |
|
---|
509 | This function creates a nested instance of the shell and executes the specified
|
---|
510 | command (CommandLine) with the specified environment (Environment). Upon return,
|
---|
511 | the status code returned by the specified command is placed in StatusCode.
|
---|
512 | If Environment is NULL, then the current environment is used and all changes made
|
---|
513 | by the commands executed will be reflected in the current environment. If the
|
---|
514 | Environment is non-NULL, then the changes made will be discarded.
|
---|
515 | The CommandLine is executed from the current working directory on the current
|
---|
516 | device.
|
---|
517 |
|
---|
518 | The EnvironmentVariables and Status parameters are ignored in a pre-UEFI Shell 2.0
|
---|
519 | environment. The values pointed to by the parameters will be unchanged by the
|
---|
520 | ShellExecute() function. The Output parameter has no effect in a
|
---|
521 | UEFI Shell 2.0 environment.
|
---|
522 |
|
---|
523 | @param[in] ParentHandle The parent image starting the operation.
|
---|
524 | @param[in] CommandLine The pointer to a NULL terminated command line.
|
---|
525 | @param[in] Output True to display debug output. False to hide it.
|
---|
526 | @param[in] EnvironmentVariables Optional pointer to array of environment variables
|
---|
527 | in the form "x=y". If NULL, the current set is used.
|
---|
528 | @param[out] Status The status of the run command line.
|
---|
529 |
|
---|
530 | @retval EFI_SUCCESS The operation completed sucessfully. Status
|
---|
531 | contains the status code returned.
|
---|
532 | @retval EFI_INVALID_PARAMETER A parameter contains an invalid value.
|
---|
533 | @retval EFI_OUT_OF_RESOURCES Out of resources.
|
---|
534 | @retval EFI_UNSUPPORTED The operation is not allowed.
|
---|
535 | **/
|
---|
536 | EFI_STATUS
|
---|
537 | EFIAPI
|
---|
538 | ShellExecute (
|
---|
539 | IN EFI_HANDLE *ParentHandle,
|
---|
540 | IN CHAR16 *CommandLine,
|
---|
541 | IN BOOLEAN Output,
|
---|
542 | IN CHAR16 **EnvironmentVariables,
|
---|
543 | OUT EFI_STATUS *Status
|
---|
544 | );
|
---|
545 |
|
---|
546 | /**
|
---|
547 | Retreives the current directory path.
|
---|
548 |
|
---|
549 | If the DeviceName is NULL, it returns the current device's current directory
|
---|
550 | name. If the DeviceName is not NULL, it returns the current directory name
|
---|
551 | on specified drive.
|
---|
552 |
|
---|
553 | @param[in] DeviceName The name of the file system to get directory on.
|
---|
554 |
|
---|
555 | @retval NULL The directory does not exist.
|
---|
556 | @retval != NULL The directory.
|
---|
557 | **/
|
---|
558 | CONST CHAR16*
|
---|
559 | EFIAPI
|
---|
560 | ShellGetCurrentDir (
|
---|
561 | IN CHAR16 * CONST DeviceName OPTIONAL
|
---|
562 | );
|
---|
563 |
|
---|
564 | /**
|
---|
565 | Sets (enabled or disabled) the page break mode.
|
---|
566 |
|
---|
567 | When page break mode is enabled the screen will stop scrolling
|
---|
568 | and wait for operator input before scrolling a subsequent screen.
|
---|
569 |
|
---|
570 | @param[in] CurrentState TRUE to enable and FALSE to disable.
|
---|
571 | **/
|
---|
572 | VOID
|
---|
573 | EFIAPI
|
---|
574 | ShellSetPageBreakMode (
|
---|
575 | IN BOOLEAN CurrentState
|
---|
576 | );
|
---|
577 |
|
---|
578 | /**
|
---|
579 | Opens a group of files based on a path.
|
---|
580 |
|
---|
581 | This function uses the Arg to open all the matching files. Each matched
|
---|
582 | file has a SHELL_FILE_ARG structure to record the file information. These
|
---|
583 | structures are placed on the list ListHead. Users can get the SHELL_FILE_ARG
|
---|
584 | structures from ListHead to access each file. This function supports wildcards
|
---|
585 | and will process '?' and '*' as such. The list must be freed with a call to
|
---|
586 | ShellCloseFileMetaArg().
|
---|
587 |
|
---|
588 | If you are NOT appending to an existing list *ListHead must be NULL. If
|
---|
589 | *ListHead is NULL then it must be callee freed.
|
---|
590 |
|
---|
591 | @param[in] Arg The pointer to path string.
|
---|
592 | @param[in] OpenMode Mode to open files with.
|
---|
593 | @param[in, out] ListHead Head of linked list of results.
|
---|
594 |
|
---|
595 | @retval EFI_SUCCESS The operation was sucessful and the list head
|
---|
596 | contains the list of opened files.
|
---|
597 | @retval != EFI_SUCCESS The operation failed.
|
---|
598 |
|
---|
599 | @sa InternalShellConvertFileListType
|
---|
600 | **/
|
---|
601 | EFI_STATUS
|
---|
602 | EFIAPI
|
---|
603 | ShellOpenFileMetaArg (
|
---|
604 | IN CHAR16 *Arg,
|
---|
605 | IN UINT64 OpenMode,
|
---|
606 | IN OUT EFI_SHELL_FILE_INFO **ListHead
|
---|
607 | );
|
---|
608 |
|
---|
609 | /**
|
---|
610 | Free the linked list returned from ShellOpenFileMetaArg.
|
---|
611 |
|
---|
612 | @param[in, out] ListHead The pointer to free.
|
---|
613 |
|
---|
614 | @retval EFI_SUCCESS The operation was sucessful.
|
---|
615 | @retval EFI_INVALID_PARAMETER A parameter was invalid.
|
---|
616 | **/
|
---|
617 | EFI_STATUS
|
---|
618 | EFIAPI
|
---|
619 | ShellCloseFileMetaArg (
|
---|
620 | IN OUT EFI_SHELL_FILE_INFO **ListHead
|
---|
621 | );
|
---|
622 |
|
---|
623 | /**
|
---|
624 | Find a file by searching the CWD and then the path.
|
---|
625 |
|
---|
626 | If FileName is NULL, then ASSERT.
|
---|
627 |
|
---|
628 | If the return value is not NULL then the memory must be caller freed.
|
---|
629 |
|
---|
630 | @param[in] FileName Filename string.
|
---|
631 |
|
---|
632 | @retval NULL The file was not found.
|
---|
633 | @retval !NULL The path to the file.
|
---|
634 | **/
|
---|
635 | CHAR16 *
|
---|
636 | EFIAPI
|
---|
637 | ShellFindFilePath (
|
---|
638 | IN CONST CHAR16 *FileName
|
---|
639 | );
|
---|
640 |
|
---|
641 | /**
|
---|
642 | Find a file by searching the CWD and then the path with a variable set of file
|
---|
643 | extensions. If the file is not found it will append each extension in the list
|
---|
644 | in the order provided and return the first one that is successful.
|
---|
645 |
|
---|
646 | If FileName is NULL, then ASSERT.
|
---|
647 | If FileExtension is NULL, then the behavior is identical to ShellFindFilePath.
|
---|
648 |
|
---|
649 | If the return value is not NULL then the memory must be caller freed.
|
---|
650 |
|
---|
651 | @param[in] FileName The filename string.
|
---|
652 | @param[in] FileExtension Semicolon delimited list of possible extensions.
|
---|
653 |
|
---|
654 | @retval NULL The file was not found.
|
---|
655 | @retval !NULL The path to the file.
|
---|
656 | **/
|
---|
657 | CHAR16 *
|
---|
658 | EFIAPI
|
---|
659 | ShellFindFilePathEx (
|
---|
660 | IN CONST CHAR16 *FileName,
|
---|
661 | IN CONST CHAR16 *FileExtension
|
---|
662 | );
|
---|
663 |
|
---|
664 | typedef enum {
|
---|
665 | TypeFlag = 0, ///< A flag that is present or not present only (IE "-a").
|
---|
666 | TypeValue, ///< A flag that has some data following it with a space (IE "-a 1").
|
---|
667 | TypePosition, ///< Some data that did not follow a parameter (IE "filename.txt").
|
---|
668 | TypeStart, ///< A flag that has variable value appended to the end (IE "-ad", "-afd", "-adf", etc...).
|
---|
669 | TypeDoubleValue, ///< A flag that has 2 space seperated value data following it (IE "-a 1 2").
|
---|
670 | TypeMaxValue, ///< A flag followed by all the command line data before the next flag.
|
---|
671 | TypeMax,
|
---|
672 | } SHELL_PARAM_TYPE;
|
---|
673 |
|
---|
674 | typedef struct {
|
---|
675 | CHAR16 *Name;
|
---|
676 | SHELL_PARAM_TYPE Type;
|
---|
677 | } SHELL_PARAM_ITEM;
|
---|
678 |
|
---|
679 |
|
---|
680 | /// Helper structure for no parameters (besides -? and -b)
|
---|
681 | extern SHELL_PARAM_ITEM EmptyParamList[];
|
---|
682 |
|
---|
683 | /// Helper structure for -sfo only (besides -? and -b)
|
---|
684 | extern SHELL_PARAM_ITEM SfoParamList[];
|
---|
685 |
|
---|
686 | /**
|
---|
687 | Checks the command line arguments passed against the list of valid ones.
|
---|
688 | Optionally removes NULL values first.
|
---|
689 |
|
---|
690 | If no initialization is required, then return RETURN_SUCCESS.
|
---|
691 |
|
---|
692 | @param[in] CheckList The pointer to list of parameters to check.
|
---|
693 | @param[out] CheckPackage The package of checked values.
|
---|
694 | @param[out] ProblemParam Optional pointer to pointer to unicode string for
|
---|
695 | the paramater that caused failure.
|
---|
696 | @param[in] AutoPageBreak Will automatically set PageBreakEnabled.
|
---|
697 | @param[in] AlwaysAllowNumbers Will never fail for number based flags.
|
---|
698 |
|
---|
699 | @retval EFI_SUCCESS The operation completed sucessfully.
|
---|
700 | @retval EFI_OUT_OF_RESOURCES A memory allocation failed.
|
---|
701 | @retval EFI_INVALID_PARAMETER A parameter was invalid.
|
---|
702 | @retval EFI_VOLUME_CORRUPTED The command line was corrupt.
|
---|
703 | @retval EFI_DEVICE_ERROR The commands contained 2 opposing arguments. One
|
---|
704 | of the command line arguments was returned in
|
---|
705 | ProblemParam if provided.
|
---|
706 | @retval EFI_NOT_FOUND A argument required a value that was missing.
|
---|
707 | The invalid command line argument was returned in
|
---|
708 | ProblemParam if provided.
|
---|
709 | **/
|
---|
710 | EFI_STATUS
|
---|
711 | EFIAPI
|
---|
712 | ShellCommandLineParseEx (
|
---|
713 | IN CONST SHELL_PARAM_ITEM *CheckList,
|
---|
714 | OUT LIST_ENTRY **CheckPackage,
|
---|
715 | OUT CHAR16 **ProblemParam OPTIONAL,
|
---|
716 | IN BOOLEAN AutoPageBreak,
|
---|
717 | IN BOOLEAN AlwaysAllowNumbers
|
---|
718 | );
|
---|
719 |
|
---|
720 | /// Make it easy to upgrade from older versions of the shell library.
|
---|
721 | #define ShellCommandLineParse(CheckList,CheckPackage,ProblemParam,AutoPageBreak) ShellCommandLineParseEx(CheckList,CheckPackage,ProblemParam,AutoPageBreak,FALSE)
|
---|
722 |
|
---|
723 | /**
|
---|
724 | Frees shell variable list that was returned from ShellCommandLineParse.
|
---|
725 |
|
---|
726 | This function will free all the memory that was used for the CheckPackage
|
---|
727 | list of postprocessed shell arguments.
|
---|
728 |
|
---|
729 | If CheckPackage is NULL, then return.
|
---|
730 |
|
---|
731 | @param[in] CheckPackage The list to de-allocate.
|
---|
732 | **/
|
---|
733 | VOID
|
---|
734 | EFIAPI
|
---|
735 | ShellCommandLineFreeVarList (
|
---|
736 | IN LIST_ENTRY *CheckPackage
|
---|
737 | );
|
---|
738 |
|
---|
739 | /**
|
---|
740 | Checks for presence of a flag parameter.
|
---|
741 |
|
---|
742 | Flag arguments are in the form of "-<Key>" or "/<Key>", but do not have a value following the key.
|
---|
743 |
|
---|
744 | If CheckPackage is NULL then return FALSE.
|
---|
745 | If KeyString is NULL then ASSERT().
|
---|
746 |
|
---|
747 | @param[in] CheckPackage The package of parsed command line arguments.
|
---|
748 | @param[in] KeyString The Key of the command line argument to check for.
|
---|
749 |
|
---|
750 | @retval TRUE The flag is on the command line.
|
---|
751 | @retval FALSE The flag is not on the command line.
|
---|
752 | **/
|
---|
753 | BOOLEAN
|
---|
754 | EFIAPI
|
---|
755 | ShellCommandLineGetFlag (
|
---|
756 | IN CONST LIST_ENTRY * CONST CheckPackage,
|
---|
757 | IN CONST CHAR16 * CONST KeyString
|
---|
758 | );
|
---|
759 |
|
---|
760 | /**
|
---|
761 | Returns value from command line argument.
|
---|
762 |
|
---|
763 | Value parameters are in the form of "-<Key> value" or "/<Key> value".
|
---|
764 |
|
---|
765 | If CheckPackage is NULL, then return NULL.
|
---|
766 |
|
---|
767 | @param[in] CheckPackage The package of parsed command line arguments.
|
---|
768 | @param[in] KeyString The Key of the command line argument to check for.
|
---|
769 |
|
---|
770 | @retval NULL The flag is not on the command line.
|
---|
771 | @retval !=NULL The pointer to unicode string of the value.
|
---|
772 | **/
|
---|
773 | CONST CHAR16*
|
---|
774 | EFIAPI
|
---|
775 | ShellCommandLineGetValue (
|
---|
776 | IN CONST LIST_ENTRY *CheckPackage,
|
---|
777 | IN CHAR16 *KeyString
|
---|
778 | );
|
---|
779 |
|
---|
780 | /**
|
---|
781 | Returns raw value from command line argument.
|
---|
782 |
|
---|
783 | Raw value parameters are in the form of "value" in a specific position in the list.
|
---|
784 |
|
---|
785 | If CheckPackage is NULL, then return NULL.
|
---|
786 |
|
---|
787 | @param[in] CheckPackage The package of parsed command line arguments.
|
---|
788 | @param[in] Position The position of the value.
|
---|
789 |
|
---|
790 | @retval NULL The flag is not on the command line.
|
---|
791 | @retval !=NULL The pointer to unicode string of the value.
|
---|
792 | **/
|
---|
793 | CONST CHAR16*
|
---|
794 | EFIAPI
|
---|
795 | ShellCommandLineGetRawValue (
|
---|
796 | IN CONST LIST_ENTRY * CONST CheckPackage,
|
---|
797 | IN UINTN Position
|
---|
798 | );
|
---|
799 |
|
---|
800 | /**
|
---|
801 | Returns the number of command line value parameters that were parsed.
|
---|
802 |
|
---|
803 | This will not include flags.
|
---|
804 |
|
---|
805 | @param[in] CheckPackage The package of parsed command line arguments.
|
---|
806 |
|
---|
807 | @retval (UINTN)-1 No parsing has occurred.
|
---|
808 | @retval other The number of value parameters found.
|
---|
809 | **/
|
---|
810 | UINTN
|
---|
811 | EFIAPI
|
---|
812 | ShellCommandLineGetCount(
|
---|
813 | IN CONST LIST_ENTRY *CheckPackage
|
---|
814 | );
|
---|
815 |
|
---|
816 | /**
|
---|
817 | Determines if a parameter is duplicated.
|
---|
818 |
|
---|
819 | If Param is not NULL, then it will point to a callee-allocated string buffer
|
---|
820 | with the parameter value, if a duplicate is found.
|
---|
821 |
|
---|
822 | If CheckPackage is NULL, then ASSERT.
|
---|
823 |
|
---|
824 | @param[in] CheckPackage The package of parsed command line arguments.
|
---|
825 | @param[out] Param Upon finding one, a pointer to the duplicated parameter.
|
---|
826 |
|
---|
827 | @retval EFI_SUCCESS No parameters were duplicated.
|
---|
828 | @retval EFI_DEVICE_ERROR A duplicate was found.
|
---|
829 | **/
|
---|
830 | EFI_STATUS
|
---|
831 | EFIAPI
|
---|
832 | ShellCommandLineCheckDuplicate (
|
---|
833 | IN CONST LIST_ENTRY *CheckPackage,
|
---|
834 | OUT CHAR16 **Param
|
---|
835 | );
|
---|
836 |
|
---|
837 | /**
|
---|
838 | This function causes the shell library to initialize itself. If the shell library
|
---|
839 | is already initialized it will de-initialize all the current protocol pointers and
|
---|
840 | re-populate them again.
|
---|
841 |
|
---|
842 | When the library is used with PcdShellLibAutoInitialize set to true this function
|
---|
843 | will return EFI_SUCCESS and perform no actions.
|
---|
844 |
|
---|
845 | This function is intended for internal access for shell commands only.
|
---|
846 |
|
---|
847 | @retval EFI_SUCCESS The initialization was complete sucessfully.
|
---|
848 |
|
---|
849 | **/
|
---|
850 | EFI_STATUS
|
---|
851 | EFIAPI
|
---|
852 | ShellInitialize (
|
---|
853 | VOID
|
---|
854 | );
|
---|
855 |
|
---|
856 | /**
|
---|
857 | Print at a specific location on the screen.
|
---|
858 |
|
---|
859 | This function will move the cursor to a given screen location and print the specified string.
|
---|
860 |
|
---|
861 | If -1 is specified for either the Row or Col the current screen location for BOTH
|
---|
862 | will be used.
|
---|
863 |
|
---|
864 | If either Row or Col is out of range for the current console, then ASSERT.
|
---|
865 | If Format is NULL, then ASSERT.
|
---|
866 |
|
---|
867 | In addition to the standard %-based flags as supported by UefiLib Print() this supports
|
---|
868 | the following additional flags:
|
---|
869 | %N - Set output attribute to normal
|
---|
870 | %H - Set output attribute to highlight
|
---|
871 | %E - Set output attribute to error
|
---|
872 | %B - Set output attribute to blue color
|
---|
873 | %V - Set output attribute to green color
|
---|
874 |
|
---|
875 | Note: The background color is controlled by the shell command cls.
|
---|
876 |
|
---|
877 | @param[in] Col The column to print at.
|
---|
878 | @param[in] Row The row to print at.
|
---|
879 | @param[in] Format The format string.
|
---|
880 | @param[in] ... The variable argument list.
|
---|
881 |
|
---|
882 | @return EFI_SUCCESS The printing was successful.
|
---|
883 | @return EFI_DEVICE_ERROR The console device reported an error.
|
---|
884 | **/
|
---|
885 | EFI_STATUS
|
---|
886 | EFIAPI
|
---|
887 | ShellPrintEx(
|
---|
888 | IN INT32 Col OPTIONAL,
|
---|
889 | IN INT32 Row OPTIONAL,
|
---|
890 | IN CONST CHAR16 *Format,
|
---|
891 | ...
|
---|
892 | );
|
---|
893 |
|
---|
894 | /**
|
---|
895 | Print at a specific location on the screen.
|
---|
896 |
|
---|
897 | This function will move the cursor to a given screen location and print the specified string.
|
---|
898 |
|
---|
899 | If -1 is specified for either the Row or Col the current screen location for BOTH
|
---|
900 | will be used.
|
---|
901 |
|
---|
902 | If either Row or Col is out of range for the current console, then ASSERT.
|
---|
903 | If Format is NULL, then ASSERT.
|
---|
904 |
|
---|
905 | In addition to the standard %-based flags as supported by UefiLib Print() this supports
|
---|
906 | the following additional flags:
|
---|
907 | %N - Set output attribute to normal.
|
---|
908 | %H - Set output attribute to highlight.
|
---|
909 | %E - Set output attribute to error.
|
---|
910 | %B - Set output attribute to blue color.
|
---|
911 | %V - Set output attribute to green color.
|
---|
912 |
|
---|
913 | Note: The background color is controlled by the shell command cls.
|
---|
914 |
|
---|
915 | @param[in] Col The column to print at.
|
---|
916 | @param[in] Row The row to print at.
|
---|
917 | @param[in] Language The language of the string to retrieve. If this parameter
|
---|
918 | is NULL, then the current platform language is used.
|
---|
919 | @param[in] HiiFormatStringId The format string Id for getting from Hii.
|
---|
920 | @param[in] HiiFormatHandle The format string Handle for getting from Hii.
|
---|
921 | @param[in] ... The variable argument list.
|
---|
922 |
|
---|
923 | @return EFI_SUCCESS The printing was successful.
|
---|
924 | @return EFI_DEVICE_ERROR The console device reported an error.
|
---|
925 | **/
|
---|
926 | EFI_STATUS
|
---|
927 | EFIAPI
|
---|
928 | ShellPrintHiiEx(
|
---|
929 | IN INT32 Col OPTIONAL,
|
---|
930 | IN INT32 Row OPTIONAL,
|
---|
931 | IN CONST CHAR8 *Language OPTIONAL,
|
---|
932 | IN CONST EFI_STRING_ID HiiFormatStringId,
|
---|
933 | IN CONST EFI_HANDLE HiiFormatHandle,
|
---|
934 | ...
|
---|
935 | );
|
---|
936 |
|
---|
937 | /**
|
---|
938 | Function to determine if a given filename represents a directory.
|
---|
939 |
|
---|
940 | If DirName is NULL, then ASSERT.
|
---|
941 |
|
---|
942 | @param[in] DirName Path to directory to test.
|
---|
943 |
|
---|
944 | @retval EFI_SUCCESS The Path represents a directory.
|
---|
945 | @retval EFI_NOT_FOUND The Path does not represent a directory.
|
---|
946 | @retval other The path failed to open.
|
---|
947 | **/
|
---|
948 | EFI_STATUS
|
---|
949 | EFIAPI
|
---|
950 | ShellIsDirectory(
|
---|
951 | IN CONST CHAR16 *DirName
|
---|
952 | );
|
---|
953 |
|
---|
954 | /**
|
---|
955 | Function to determine if a given filename represents a file.
|
---|
956 |
|
---|
957 | This will search the CWD only.
|
---|
958 |
|
---|
959 | If Name is NULL, then ASSERT.
|
---|
960 |
|
---|
961 | @param[in] Name Path to file to test.
|
---|
962 |
|
---|
963 | @retval EFI_SUCCESS The Path represents a file.
|
---|
964 | @retval EFI_NOT_FOUND The Path does not represent a file.
|
---|
965 | @retval other The path failed to open.
|
---|
966 | **/
|
---|
967 | EFI_STATUS
|
---|
968 | EFIAPI
|
---|
969 | ShellIsFile(
|
---|
970 | IN CONST CHAR16 *Name
|
---|
971 | );
|
---|
972 |
|
---|
973 | /**
|
---|
974 | Function to determine if a given filename represents a file.
|
---|
975 |
|
---|
976 | This will search the CWD and then the Path.
|
---|
977 |
|
---|
978 | If Name is NULL, then ASSERT.
|
---|
979 |
|
---|
980 | @param[in] Name Path to file to test.
|
---|
981 |
|
---|
982 | @retval EFI_SUCCESS The Path represents a file.
|
---|
983 | @retval EFI_NOT_FOUND The Path does not represent a file.
|
---|
984 | @retval other The path failed to open.
|
---|
985 | **/
|
---|
986 | EFI_STATUS
|
---|
987 | EFIAPI
|
---|
988 | ShellIsFileInPath(
|
---|
989 | IN CONST CHAR16 *Name
|
---|
990 | );
|
---|
991 |
|
---|
992 | /**
|
---|
993 | Function to determine whether a string is decimal or hex representation of a number
|
---|
994 | and return the number converted from the string.
|
---|
995 |
|
---|
996 | Note: this function cannot be used when (UINTN)(-1), (0xFFFFFFFF) may be a valid
|
---|
997 | result. Use ShellConvertStringToUint64 instead.
|
---|
998 |
|
---|
999 | @param[in] String String representation of a number.
|
---|
1000 |
|
---|
1001 | @return The unsigned integer result of the conversion.
|
---|
1002 | @retval (UINTN)(-1) An error occured.
|
---|
1003 | **/
|
---|
1004 | UINTN
|
---|
1005 | EFIAPI
|
---|
1006 | ShellStrToUintn(
|
---|
1007 | IN CONST CHAR16 *String
|
---|
1008 | );
|
---|
1009 |
|
---|
1010 | /**
|
---|
1011 | Safely append with automatic string resizing given length of Destination and
|
---|
1012 | desired length of copy from Source.
|
---|
1013 |
|
---|
1014 | Append the first D characters of Source to the end of Destination, where D is
|
---|
1015 | the lesser of Count and the StrLen() of Source. If appending those D characters
|
---|
1016 | will fit within Destination (whose Size is given as CurrentSize) and
|
---|
1017 | still leave room for a NULL terminator, then those characters are appended,
|
---|
1018 | starting at the original terminating NULL of Destination, and a new terminating
|
---|
1019 | NULL is appended.
|
---|
1020 |
|
---|
1021 | If appending D characters onto Destination will result in a overflow of the size
|
---|
1022 | given in CurrentSize the string will be grown such that the copy can be performed
|
---|
1023 | and CurrentSize will be updated to the new size.
|
---|
1024 |
|
---|
1025 | If Source is NULL, there is nothing to append, so return the current buffer in
|
---|
1026 | Destination.
|
---|
1027 |
|
---|
1028 | If Destination is NULL, then ASSERT().
|
---|
1029 | If Destination's current length (including NULL terminator) is already more than
|
---|
1030 | CurrentSize, then ASSERT().
|
---|
1031 |
|
---|
1032 | @param[in, out] Destination The String to append onto.
|
---|
1033 | @param[in, out] CurrentSize On call, the number of bytes in Destination. On
|
---|
1034 | return, possibly the new size (still in bytes). If NULL,
|
---|
1035 | then allocate whatever is needed.
|
---|
1036 | @param[in] Source The String to append from.
|
---|
1037 | @param[in] Count The maximum number of characters to append. If 0, then
|
---|
1038 | all are appended.
|
---|
1039 |
|
---|
1040 | @return The Destination after appending the Source.
|
---|
1041 | **/
|
---|
1042 | CHAR16*
|
---|
1043 | EFIAPI
|
---|
1044 | StrnCatGrow (
|
---|
1045 | IN OUT CHAR16 **Destination,
|
---|
1046 | IN OUT UINTN *CurrentSize,
|
---|
1047 | IN CONST CHAR16 *Source,
|
---|
1048 | IN UINTN Count
|
---|
1049 | );
|
---|
1050 |
|
---|
1051 | /**
|
---|
1052 | This is a find and replace function. Upon successful return the NewString is a copy of
|
---|
1053 | SourceString with each instance of FindTarget replaced with ReplaceWith.
|
---|
1054 |
|
---|
1055 | If SourceString and NewString overlap the behavior is undefined.
|
---|
1056 |
|
---|
1057 | If the string would grow bigger than NewSize it will halt and return error.
|
---|
1058 |
|
---|
1059 | @param[in] SourceString The string with source buffer.
|
---|
1060 | @param[in, out] NewString The string with resultant buffer.
|
---|
1061 | @param[in] NewSize The size in bytes of NewString.
|
---|
1062 | @param[in] FindTarget The string to look for.
|
---|
1063 | @param[in] ReplaceWith The string to replace FindTarget with.
|
---|
1064 | @param[in] SkipPreCarrot If TRUE will skip a FindTarget that has a '^'
|
---|
1065 | immediately before it.
|
---|
1066 | @param[in] ParameterReplacing If TRUE will add "" around items with spaces.
|
---|
1067 |
|
---|
1068 | @retval EFI_INVALID_PARAMETER SourceString was NULL.
|
---|
1069 | @retval EFI_INVALID_PARAMETER NewString was NULL.
|
---|
1070 | @retval EFI_INVALID_PARAMETER FindTarget was NULL.
|
---|
1071 | @retval EFI_INVALID_PARAMETER ReplaceWith was NULL.
|
---|
1072 | @retval EFI_INVALID_PARAMETER FindTarget had length < 1.
|
---|
1073 | @retval EFI_INVALID_PARAMETER SourceString had length < 1.
|
---|
1074 | @retval EFI_BUFFER_TOO_SMALL NewSize was less than the minimum size to hold
|
---|
1075 | the new string (truncation occurred).
|
---|
1076 | @retval EFI_SUCCESS The string was successfully copied with replacement.
|
---|
1077 | **/
|
---|
1078 | EFI_STATUS
|
---|
1079 | EFIAPI
|
---|
1080 | ShellCopySearchAndReplace(
|
---|
1081 | IN CHAR16 CONST *SourceString,
|
---|
1082 | IN OUT CHAR16 *NewString,
|
---|
1083 | IN UINTN NewSize,
|
---|
1084 | IN CONST CHAR16 *FindTarget,
|
---|
1085 | IN CONST CHAR16 *ReplaceWith,
|
---|
1086 | IN CONST BOOLEAN SkipPreCarrot,
|
---|
1087 | IN CONST BOOLEAN ParameterReplacing
|
---|
1088 | );
|
---|
1089 |
|
---|
1090 | /**
|
---|
1091 | Check if a Unicode character is a hexadecimal character.
|
---|
1092 |
|
---|
1093 | This internal function checks if a Unicode character is a
|
---|
1094 | numeric character. The valid hexadecimal characters are
|
---|
1095 | L'0' to L'9', L'a' to L'f', or L'A' to L'F'.
|
---|
1096 |
|
---|
1097 |
|
---|
1098 | @param Char The character to check against.
|
---|
1099 |
|
---|
1100 | @retval TRUE The Char is a hexadecmial character.
|
---|
1101 | @retval FALSE The Char is not a hexadecmial character.
|
---|
1102 |
|
---|
1103 | **/
|
---|
1104 | BOOLEAN
|
---|
1105 | EFIAPI
|
---|
1106 | ShellIsHexaDecimalDigitCharacter (
|
---|
1107 | IN CHAR16 Char
|
---|
1108 | );
|
---|
1109 |
|
---|
1110 | /**
|
---|
1111 | Check if a Unicode character is a decimal character.
|
---|
1112 |
|
---|
1113 | This internal function checks if a Unicode character is a
|
---|
1114 | decimal character. The valid characters are
|
---|
1115 | L'0' to L'9'.
|
---|
1116 |
|
---|
1117 |
|
---|
1118 | @param Char The character to check against.
|
---|
1119 |
|
---|
1120 | @retval TRUE The Char is a hexadecmial character.
|
---|
1121 | @retval FALSE The Char is not a hexadecmial character.
|
---|
1122 |
|
---|
1123 | **/
|
---|
1124 | BOOLEAN
|
---|
1125 | EFIAPI
|
---|
1126 | ShellIsDecimalDigitCharacter (
|
---|
1127 | IN CHAR16 Char
|
---|
1128 | );
|
---|
1129 |
|
---|
1130 | ///
|
---|
1131 | /// What type of answer is requested.
|
---|
1132 | ///
|
---|
1133 | typedef enum {
|
---|
1134 | ShellPromptResponseTypeYesNo,
|
---|
1135 | ShellPromptResponseTypeYesNoCancel,
|
---|
1136 | ShellPromptResponseTypeFreeform,
|
---|
1137 | ShellPromptResponseTypeQuitContinue,
|
---|
1138 | ShellPromptResponseTypeYesNoAllCancel,
|
---|
1139 | ShellPromptResponseTypeEnterContinue,
|
---|
1140 | ShellPromptResponseTypeAnyKeyContinue,
|
---|
1141 | ShellPromptResponseTypeMax
|
---|
1142 | } SHELL_PROMPT_REQUEST_TYPE;
|
---|
1143 |
|
---|
1144 | ///
|
---|
1145 | /// What answer was given.
|
---|
1146 | ///
|
---|
1147 | typedef enum {
|
---|
1148 | ShellPromptResponseYes,
|
---|
1149 | ShellPromptResponseNo,
|
---|
1150 | ShellPromptResponseCancel,
|
---|
1151 | ShellPromptResponseQuit,
|
---|
1152 | ShellPromptResponseContinue,
|
---|
1153 | ShellPromptResponseAll,
|
---|
1154 | ShellPromptResponseMax
|
---|
1155 | } SHELL_PROMPT_RESPONSE;
|
---|
1156 |
|
---|
1157 | /**
|
---|
1158 | Prompt the user and return the resultant answer to the requestor.
|
---|
1159 |
|
---|
1160 | This function will display the requested question on the shell prompt and then
|
---|
1161 | wait for an apropriate answer to be input from the console.
|
---|
1162 |
|
---|
1163 | If the SHELL_PROMPT_REQUEST_TYPE is SHELL_PROMPT_REQUEST_TYPE_YESNO, ShellPromptResponseTypeQuitContinue
|
---|
1164 | or SHELL_PROMPT_REQUEST_TYPE_YESNOCANCEL then *Response is of type SHELL_PROMPT_RESPONSE.
|
---|
1165 |
|
---|
1166 | If the SHELL_PROMPT_REQUEST_TYPE is ShellPromptResponseTypeFreeform then *Response is of type
|
---|
1167 | CHAR16*.
|
---|
1168 |
|
---|
1169 | In either case *Response must be callee freed if Response was not NULL;
|
---|
1170 |
|
---|
1171 | @param Type What type of question is asked. This is used to filter the input
|
---|
1172 | to prevent invalid answers to question.
|
---|
1173 | @param Prompt The pointer to a string prompt used to request input.
|
---|
1174 | @param Response The pointer to Response, which will be populated upon return.
|
---|
1175 |
|
---|
1176 | @retval EFI_SUCCESS The operation was successful.
|
---|
1177 | @retval EFI_UNSUPPORTED The operation is not supported as requested.
|
---|
1178 | @retval EFI_INVALID_PARAMETER A parameter was invalid.
|
---|
1179 | @return other The operation failed.
|
---|
1180 | **/
|
---|
1181 | EFI_STATUS
|
---|
1182 | EFIAPI
|
---|
1183 | ShellPromptForResponse (
|
---|
1184 | IN SHELL_PROMPT_REQUEST_TYPE Type,
|
---|
1185 | IN CHAR16 *Prompt OPTIONAL,
|
---|
1186 | IN OUT VOID **Response OPTIONAL
|
---|
1187 | );
|
---|
1188 |
|
---|
1189 | /**
|
---|
1190 | Prompt the user and return the resultant answer to the requestor.
|
---|
1191 |
|
---|
1192 | This function is the same as ShellPromptForResponse, except that the prompt is
|
---|
1193 | automatically pulled from HII.
|
---|
1194 |
|
---|
1195 | @param[in] Type What type of question is asked. This is used to filter the input
|
---|
1196 | to prevent invalid answers to question.
|
---|
1197 | @param[in] HiiFormatStringId The format string Id for getting from Hii.
|
---|
1198 | @param[in] HiiFormatHandle The format string Handle for getting from Hii.
|
---|
1199 | @param[in, out] Response The pointer to Response, which will be populated upon return.
|
---|
1200 |
|
---|
1201 | @retval EFI_SUCCESS The operation was sucessful.
|
---|
1202 | @return other The operation failed.
|
---|
1203 |
|
---|
1204 | @sa ShellPromptForResponse
|
---|
1205 | **/
|
---|
1206 | EFI_STATUS
|
---|
1207 | EFIAPI
|
---|
1208 | ShellPromptForResponseHii (
|
---|
1209 | IN SHELL_PROMPT_REQUEST_TYPE Type,
|
---|
1210 | IN CONST EFI_STRING_ID HiiFormatStringId,
|
---|
1211 | IN CONST EFI_HANDLE HiiFormatHandle,
|
---|
1212 | IN OUT VOID **Response
|
---|
1213 | );
|
---|
1214 |
|
---|
1215 | /**
|
---|
1216 | Function to determin if an entire string is a valid number.
|
---|
1217 |
|
---|
1218 | If Hex it must be preceeded with a 0x, 0X, or has ForceHex set TRUE.
|
---|
1219 |
|
---|
1220 | @param[in] String The string to evaluate.
|
---|
1221 | @param[in] ForceHex TRUE - always assume hex.
|
---|
1222 | @param[in] StopAtSpace TRUE to halt upon finding a space, FALSE to keep going.
|
---|
1223 |
|
---|
1224 | @retval TRUE It is all numeric (dec/hex) characters.
|
---|
1225 | @retval FALSE There is a non-numeric character.
|
---|
1226 | **/
|
---|
1227 | BOOLEAN
|
---|
1228 | EFIAPI
|
---|
1229 | ShellIsHexOrDecimalNumber (
|
---|
1230 | IN CONST CHAR16 *String,
|
---|
1231 | IN CONST BOOLEAN ForceHex,
|
---|
1232 | IN CONST BOOLEAN StopAtSpace
|
---|
1233 | );
|
---|
1234 |
|
---|
1235 | /**
|
---|
1236 | Function to verify and convert a string to its numerical 64 bit representation.
|
---|
1237 |
|
---|
1238 | If Hex it must be preceeded with a 0x, 0X, or has ForceHex set TRUE.
|
---|
1239 |
|
---|
1240 | @param[in] String The string to evaluate.
|
---|
1241 | @param[out] Value Upon a successful return the value of the conversion.
|
---|
1242 | @param[in] ForceHex TRUE - always assume hex.
|
---|
1243 | @param[in] StopAtSpace TRUE to halt upon finding a space, FALSE to
|
---|
1244 | process the entire String.
|
---|
1245 |
|
---|
1246 | @retval EFI_SUCCESS The conversion was successful.
|
---|
1247 | @retval EFI_INVALID_PARAMETER String contained an invalid character.
|
---|
1248 | @retval EFI_NOT_FOUND String was a number, but Value was NULL.
|
---|
1249 | **/
|
---|
1250 | EFI_STATUS
|
---|
1251 | EFIAPI
|
---|
1252 | ShellConvertStringToUint64(
|
---|
1253 | IN CONST CHAR16 *String,
|
---|
1254 | OUT UINT64 *Value,
|
---|
1255 | IN CONST BOOLEAN ForceHex,
|
---|
1256 | IN CONST BOOLEAN StopAtSpace
|
---|
1257 | );
|
---|
1258 |
|
---|
1259 | /**
|
---|
1260 | Function to determine if a given filename exists.
|
---|
1261 |
|
---|
1262 | @param[in] Name Path to test.
|
---|
1263 |
|
---|
1264 | @retval EFI_SUCCESS The Path represents a file.
|
---|
1265 | @retval EFI_NOT_FOUND The Path does not represent a file.
|
---|
1266 | @retval other The path failed to open.
|
---|
1267 | **/
|
---|
1268 | EFI_STATUS
|
---|
1269 | EFIAPI
|
---|
1270 | ShellFileExists(
|
---|
1271 | IN CONST CHAR16 *Name
|
---|
1272 | );
|
---|
1273 |
|
---|
1274 | /**
|
---|
1275 | Function to read a single line from a SHELL_FILE_HANDLE. The \n is not included in the returned
|
---|
1276 | buffer. The returned buffer must be callee freed.
|
---|
1277 |
|
---|
1278 | If the position upon start is 0, then the Ascii Boolean will be set. This should be
|
---|
1279 | maintained and not changed for all operations with the same file.
|
---|
1280 |
|
---|
1281 | @param[in] Handle SHELL_FILE_HANDLE to read from.
|
---|
1282 | @param[in, out] Ascii Boolean value for indicating whether the file is
|
---|
1283 | Ascii (TRUE) or UCS2 (FALSE).
|
---|
1284 |
|
---|
1285 | @return The line of text from the file.
|
---|
1286 |
|
---|
1287 | @sa ShellFileHandleReadLine
|
---|
1288 | **/
|
---|
1289 | CHAR16*
|
---|
1290 | EFIAPI
|
---|
1291 | ShellFileHandleReturnLine(
|
---|
1292 | IN SHELL_FILE_HANDLE Handle,
|
---|
1293 | IN OUT BOOLEAN *Ascii
|
---|
1294 | );
|
---|
1295 |
|
---|
1296 | /**
|
---|
1297 | Function to read a single line (up to but not including the \n) from a SHELL_FILE_HANDLE.
|
---|
1298 |
|
---|
1299 | If the position upon start is 0, then the Ascii Boolean will be set. This should be
|
---|
1300 | maintained and not changed for all operations with the same file.
|
---|
1301 |
|
---|
1302 | @param[in] Handle SHELL_FILE_HANDLE to read from.
|
---|
1303 | @param[in, out] Buffer The pointer to buffer to read into.
|
---|
1304 | @param[in, out] Size The pointer to number of bytes in Buffer.
|
---|
1305 | @param[in] Truncate If the buffer is large enough, this has no effect.
|
---|
1306 | If the buffer is is too small and Truncate is TRUE,
|
---|
1307 | the line will be truncated.
|
---|
1308 | If the buffer is is too small and Truncate is FALSE,
|
---|
1309 | then no read will occur.
|
---|
1310 |
|
---|
1311 | @param[in, out] Ascii Boolean value for indicating whether the file is
|
---|
1312 | Ascii (TRUE) or UCS2 (FALSE).
|
---|
1313 |
|
---|
1314 | @retval EFI_SUCCESS The operation was successful. The line is stored in
|
---|
1315 | Buffer.
|
---|
1316 | @retval EFI_INVALID_PARAMETER Handle was NULL.
|
---|
1317 | @retval EFI_INVALID_PARAMETER Size was NULL.
|
---|
1318 | @retval EFI_BUFFER_TOO_SMALL Size was not large enough to store the line.
|
---|
1319 | Size was updated to the minimum space required.
|
---|
1320 | **/
|
---|
1321 | EFI_STATUS
|
---|
1322 | EFIAPI
|
---|
1323 | ShellFileHandleReadLine(
|
---|
1324 | IN SHELL_FILE_HANDLE Handle,
|
---|
1325 | IN OUT CHAR16 *Buffer,
|
---|
1326 | IN OUT UINTN *Size,
|
---|
1327 | IN BOOLEAN Truncate,
|
---|
1328 | IN OUT BOOLEAN *Ascii
|
---|
1329 | );
|
---|
1330 |
|
---|
1331 | #endif // __SHELL_LIB__
|
---|