2010-09-14 07:18:09 +02:00
|
|
|
/** @file
|
|
|
|
Main file for NULL named library for level 2 shell command functions.
|
|
|
|
|
|
|
|
these functions are:
|
|
|
|
attrib, cd, cp, date*, time*, rm, reset,
|
|
|
|
load, ls, map, mkdir, mv, parse, set, timezone*
|
|
|
|
|
|
|
|
|
|
|
|
* functions are non-interactive only
|
|
|
|
|
|
|
|
|
2018-06-27 15:13:38 +02:00
|
|
|
Copyright (c) 2009 - 2018, Intel Corporation. All rights reserved.<BR>
|
2019-04-04 01:07:06 +02:00
|
|
|
SPDX-License-Identifier: BSD-2-Clause-Patent
|
2010-09-14 07:18:09 +02:00
|
|
|
|
|
|
|
**/
|
|
|
|
|
2011-04-05 22:55:45 +02:00
|
|
|
#ifndef _UEFI_SHELL_LEVEL2_COMMANDS_LIB_H_
|
2011-03-25 21:58:08 +01:00
|
|
|
#define _UEFI_SHELL_LEVEL2_COMMANDS_LIB_H_
|
|
|
|
|
2010-09-14 07:18:09 +02:00
|
|
|
#include <Uefi.h>
|
|
|
|
|
2016-11-03 08:20:48 +01:00
|
|
|
#include <Guid/GlobalVariable.h>
|
2011-09-21 03:56:00 +02:00
|
|
|
#include <Guid/ShellLibHiiGuid.h>
|
|
|
|
|
2016-10-18 08:30:42 +02:00
|
|
|
#include <Protocol/Shell.h>
|
|
|
|
#include <Protocol/ShellParameters.h>
|
2010-09-14 07:18:09 +02:00
|
|
|
#include <Protocol/DevicePath.h>
|
|
|
|
#include <Protocol/LoadedImage.h>
|
|
|
|
#include <Protocol/UnicodeCollation.h>
|
|
|
|
|
|
|
|
#include <Library/BaseLib.h>
|
|
|
|
#include <Library/BaseMemoryLib.h>
|
|
|
|
#include <Library/DebugLib.h>
|
|
|
|
#include <Library/MemoryAllocationLib.h>
|
|
|
|
#include <Library/PcdLib.h>
|
|
|
|
#include <Library/ShellCommandLib.h>
|
|
|
|
#include <Library/ShellLib.h>
|
|
|
|
#include <Library/UefiLib.h>
|
|
|
|
#include <Library/UefiRuntimeServicesTableLib.h>
|
|
|
|
#include <Library/UefiBootServicesTableLib.h>
|
|
|
|
#include <Library/HiiLib.h>
|
|
|
|
#include <Library/SortLib.h>
|
|
|
|
#include <Library/FileHandleLib.h>
|
|
|
|
|
|
|
|
extern CONST CHAR16 mFileName[];
|
ShellPkg: stop using EFI_HANDLE in place of EFI_HII_HANDLE
The UefiShell*CommandsLib instances have constructor functions that do
something like:
gHiiHandle = HiiAddPackages (...);
...
ShellCommandRegisterCommandName (..., gHiiHandle, ...);
and destructor functions that implement the following pattern:
HiiRemovePackages (gHiiHandle);
The -- semantic, not functional -- problem is that "gHiiHandle" is
declared with type EFI_HANDLE, and not EFI_HII_HANDLE, in all of these
library instances, even though HiiAddPackages() correctly returns
EFI_HII_HANDLE, and HiiRemovePackages() takes EFI_HII_HANDLE.
Once we fix the type of "gHiiHandle", it causes sort of a butterfly
effect, because it is passed around widely. Track down and update all of
those locations.
The DynamicCommand lib instances use a similar pattern, so they are
affected too.
NOTE: in practice, this patch is a no-op, as both EFI_HII_HANDLE and
EFI_HANDLE are typedefs to (VOID*). However, we shouldn't use EFI_HANDLE
where semantically EFI_HII_HANDLE is passed around.
Cc: Jaben Carsey <jaben.carsey@intel.com>
Cc: Ray Ni <ray.ni@intel.com>
Cc: Zhichao Gao <zhichao.gao@intel.com>
Signed-off-by: Laszlo Ersek <lersek@redhat.com>
Reviewed-by: Philippe Mathieu-Daude <philmd@redhat.com>
Reviewed-by: Zhichao Gao <zhichao.gao@intel.com>
2019-09-06 23:15:42 +02:00
|
|
|
extern EFI_HII_HANDLE gShellLevel2HiiHandle;
|
2010-09-14 07:18:09 +02:00
|
|
|
|
|
|
|
/**
|
|
|
|
Function for 'attrib' command.
|
|
|
|
|
|
|
|
@param[in] ImageHandle Handle to the Image (NULL if Internal).
|
|
|
|
@param[in] SystemTable Pointer to the System Table (NULL if Internal).
|
|
|
|
**/
|
|
|
|
SHELL_STATUS
|
|
|
|
EFIAPI
|
|
|
|
ShellCommandRunAttrib (
|
|
|
|
IN EFI_HANDLE ImageHandle,
|
|
|
|
IN EFI_SYSTEM_TABLE *SystemTable
|
|
|
|
);
|
|
|
|
|
|
|
|
/**
|
|
|
|
Function for 'date' command.
|
|
|
|
|
|
|
|
@param[in] ImageHandle Handle to the Image (NULL if Internal).
|
|
|
|
@param[in] SystemTable Pointer to the System Table (NULL if Internal).
|
|
|
|
**/
|
|
|
|
SHELL_STATUS
|
|
|
|
EFIAPI
|
|
|
|
ShellCommandRunDate (
|
|
|
|
IN EFI_HANDLE ImageHandle,
|
|
|
|
IN EFI_SYSTEM_TABLE *SystemTable
|
|
|
|
);
|
|
|
|
|
|
|
|
/**
|
|
|
|
Function for 'time' command.
|
|
|
|
|
|
|
|
@param[in] ImageHandle Handle to the Image (NULL if Internal).
|
|
|
|
@param[in] SystemTable Pointer to the System Table (NULL if Internal).
|
|
|
|
**/
|
|
|
|
SHELL_STATUS
|
|
|
|
EFIAPI
|
|
|
|
ShellCommandRunTime (
|
|
|
|
IN EFI_HANDLE ImageHandle,
|
|
|
|
IN EFI_SYSTEM_TABLE *SystemTable
|
|
|
|
);
|
|
|
|
|
|
|
|
/**
|
|
|
|
Function for 'load' command.
|
|
|
|
|
|
|
|
@param[in] ImageHandle Handle to the Image (NULL if Internal).
|
|
|
|
@param[in] SystemTable Pointer to the System Table (NULL if Internal).
|
|
|
|
**/
|
|
|
|
SHELL_STATUS
|
|
|
|
EFIAPI
|
|
|
|
ShellCommandRunLoad (
|
|
|
|
IN EFI_HANDLE ImageHandle,
|
|
|
|
IN EFI_SYSTEM_TABLE *SystemTable
|
|
|
|
);
|
|
|
|
|
|
|
|
/**
|
|
|
|
Function for 'ls' command.
|
|
|
|
|
|
|
|
@param[in] ImageHandle Handle to the Image (NULL if Internal).
|
|
|
|
@param[in] SystemTable Pointer to the System Table (NULL if Internal).
|
|
|
|
**/
|
|
|
|
SHELL_STATUS
|
|
|
|
EFIAPI
|
|
|
|
ShellCommandRunLs (
|
|
|
|
IN EFI_HANDLE ImageHandle,
|
|
|
|
IN EFI_SYSTEM_TABLE *SystemTable
|
|
|
|
);
|
|
|
|
|
|
|
|
/**
|
|
|
|
Function for 'map' command.
|
|
|
|
|
|
|
|
@param[in] ImageHandle Handle to the Image (NULL if Internal).
|
|
|
|
@param[in] SystemTable Pointer to the System Table (NULL if Internal).
|
|
|
|
**/
|
|
|
|
SHELL_STATUS
|
|
|
|
EFIAPI
|
|
|
|
ShellCommandRunMap (
|
|
|
|
IN EFI_HANDLE ImageHandle,
|
|
|
|
IN EFI_SYSTEM_TABLE *SystemTable
|
|
|
|
);
|
|
|
|
|
|
|
|
/**
|
|
|
|
Function for 'reset' command.
|
|
|
|
|
|
|
|
@param[in] ImageHandle Handle to the Image (NULL if Internal).
|
|
|
|
@param[in] SystemTable Pointer to the System Table (NULL if Internal).
|
|
|
|
**/
|
|
|
|
SHELL_STATUS
|
|
|
|
EFIAPI
|
|
|
|
ShellCommandRunReset (
|
|
|
|
IN EFI_HANDLE ImageHandle,
|
|
|
|
IN EFI_SYSTEM_TABLE *SystemTable
|
|
|
|
);
|
|
|
|
|
|
|
|
/**
|
|
|
|
Function for 'timezone' command.
|
|
|
|
|
|
|
|
@param[in] ImageHandle Handle to the Image (NULL if Internal).
|
|
|
|
@param[in] SystemTable Pointer to the System Table (NULL if Internal).
|
|
|
|
**/
|
|
|
|
SHELL_STATUS
|
|
|
|
EFIAPI
|
|
|
|
ShellCommandRunTimeZone (
|
|
|
|
IN EFI_HANDLE ImageHandle,
|
|
|
|
IN EFI_SYSTEM_TABLE *SystemTable
|
|
|
|
);
|
|
|
|
|
|
|
|
/**
|
|
|
|
Function for 'set' command.
|
|
|
|
|
|
|
|
@param[in] ImageHandle Handle to the Image (NULL if Internal).
|
|
|
|
@param[in] SystemTable Pointer to the System Table (NULL if Internal).
|
|
|
|
**/
|
|
|
|
SHELL_STATUS
|
|
|
|
EFIAPI
|
|
|
|
ShellCommandRunSet (
|
|
|
|
IN EFI_HANDLE ImageHandle,
|
|
|
|
IN EFI_SYSTEM_TABLE *SystemTable
|
|
|
|
);
|
|
|
|
|
|
|
|
/**
|
|
|
|
Function for 'mkdir' command.
|
|
|
|
|
|
|
|
@param[in] ImageHandle Handle to the Image (NULL if Internal).
|
|
|
|
@param[in] SystemTable Pointer to the System Table (NULL if Internal).
|
|
|
|
**/
|
|
|
|
SHELL_STATUS
|
|
|
|
EFIAPI
|
|
|
|
ShellCommandRunMkDir (
|
|
|
|
IN EFI_HANDLE ImageHandle,
|
|
|
|
IN EFI_SYSTEM_TABLE *SystemTable
|
|
|
|
);
|
|
|
|
|
|
|
|
/**
|
|
|
|
Function for 'cd' command.
|
|
|
|
|
|
|
|
@param[in] ImageHandle Handle to the Image (NULL if Internal).
|
|
|
|
@param[in] SystemTable Pointer to the System Table (NULL if Internal).
|
|
|
|
**/
|
|
|
|
SHELL_STATUS
|
|
|
|
EFIAPI
|
|
|
|
ShellCommandRunCd (
|
|
|
|
IN EFI_HANDLE ImageHandle,
|
|
|
|
IN EFI_SYSTEM_TABLE *SystemTable
|
|
|
|
);
|
|
|
|
|
|
|
|
/**
|
|
|
|
Function for 'cp' command.
|
|
|
|
|
|
|
|
@param[in] ImageHandle Handle to the Image (NULL if Internal).
|
|
|
|
@param[in] SystemTable Pointer to the System Table (NULL if Internal).
|
|
|
|
**/
|
|
|
|
SHELL_STATUS
|
|
|
|
EFIAPI
|
|
|
|
ShellCommandRunCp (
|
|
|
|
IN EFI_HANDLE ImageHandle,
|
|
|
|
IN EFI_SYSTEM_TABLE *SystemTable
|
|
|
|
);
|
|
|
|
|
|
|
|
/**
|
|
|
|
Function for 'parse' command.
|
|
|
|
|
|
|
|
@param[in] ImageHandle Handle to the Image (NULL if Internal).
|
|
|
|
@param[in] SystemTable Pointer to the System Table (NULL if Internal).
|
|
|
|
**/
|
|
|
|
SHELL_STATUS
|
|
|
|
EFIAPI
|
|
|
|
ShellCommandRunParse (
|
|
|
|
IN EFI_HANDLE ImageHandle,
|
|
|
|
IN EFI_SYSTEM_TABLE *SystemTable
|
|
|
|
);
|
|
|
|
|
|
|
|
/**
|
|
|
|
Function for 'rm' command.
|
|
|
|
|
|
|
|
@param[in] ImageHandle Handle to the Image (NULL if Internal).
|
|
|
|
@param[in] SystemTable Pointer to the System Table (NULL if Internal).
|
|
|
|
**/
|
|
|
|
SHELL_STATUS
|
|
|
|
EFIAPI
|
|
|
|
ShellCommandRunRm (
|
|
|
|
IN EFI_HANDLE ImageHandle,
|
|
|
|
IN EFI_SYSTEM_TABLE *SystemTable
|
|
|
|
);
|
|
|
|
|
|
|
|
/**
|
|
|
|
Function for 'mv' command.
|
|
|
|
|
|
|
|
@param[in] ImageHandle Handle to the Image (NULL if Internal).
|
|
|
|
@param[in] SystemTable Pointer to the System Table (NULL if Internal).
|
|
|
|
**/
|
|
|
|
SHELL_STATUS
|
|
|
|
EFIAPI
|
|
|
|
ShellCommandRunMv (
|
|
|
|
IN EFI_HANDLE ImageHandle,
|
|
|
|
IN EFI_SYSTEM_TABLE *SystemTable
|
|
|
|
);
|
|
|
|
|
|
|
|
/**
|
|
|
|
returns a fully qualified directory (contains a map drive at the begining)
|
|
|
|
path from a unknown directory path.
|
|
|
|
|
|
|
|
If Path is already fully qualified this will return a duplicat otherwise this
|
|
|
|
will use get the current directory and use that to build the fully qualified
|
|
|
|
version.
|
|
|
|
|
|
|
|
if the return value is not NULL it must be caller freed.
|
|
|
|
|
|
|
|
@param[in] Path The unknown Path Value
|
|
|
|
|
|
|
|
@retval NULL A memory allocation failed
|
|
|
|
@retval NULL a fully qualified path could not be discovered.
|
|
|
|
@retval other pointer to a fuly qualified path.
|
|
|
|
**/
|
|
|
|
CHAR16*
|
|
|
|
GetFullyQualifiedPath(
|
|
|
|
IN CONST CHAR16* Path
|
|
|
|
);
|
|
|
|
|
|
|
|
/**
|
|
|
|
Function to verify all intermediate directories in the path.
|
|
|
|
|
|
|
|
@param[in] Path The pointer to the path to fix.
|
|
|
|
|
|
|
|
@retval EFI_SUCCESS The operation was successful.
|
|
|
|
**/
|
|
|
|
EFI_STATUS
|
|
|
|
VerifyIntermediateDirectories (
|
|
|
|
IN CONST CHAR16 *Path
|
|
|
|
);
|
|
|
|
|
|
|
|
/**
|
2018-01-26 09:43:22 +01:00
|
|
|
String comparison without regard to case for a limited number of characters.
|
2010-09-14 07:18:09 +02:00
|
|
|
|
2018-01-26 09:43:22 +01:00
|
|
|
@param[in] Source The first item to compare.
|
|
|
|
@param[in] Target The second item to compare.
|
|
|
|
@param[in] Count How many characters to compare.
|
2010-09-14 07:18:09 +02:00
|
|
|
|
2018-01-26 09:43:22 +01:00
|
|
|
@retval 0 Source and Target are identical strings without regard to case.
|
|
|
|
@retval !=0 Source is not identical to Target.
|
2018-06-27 15:13:38 +02:00
|
|
|
|
2010-09-14 07:18:09 +02:00
|
|
|
**/
|
2018-01-26 09:43:22 +01:00
|
|
|
INTN
|
2010-09-14 07:18:09 +02:00
|
|
|
StrniCmp(
|
|
|
|
IN CONST CHAR16 *Source,
|
|
|
|
IN CONST CHAR16 *Target,
|
|
|
|
IN CONST UINTN Count
|
|
|
|
);
|
2011-03-25 21:58:08 +01:00
|
|
|
|
2014-09-17 09:58:31 +02:00
|
|
|
/**
|
|
|
|
Cleans off all the quotes in the string.
|
|
|
|
|
|
|
|
@param[in] OriginalString pointer to the string to be cleaned.
|
2018-06-27 15:13:38 +02:00
|
|
|
@param[out] CleanString The new string with all quotes removed.
|
|
|
|
Memory allocated in the function and free
|
2014-09-17 09:58:31 +02:00
|
|
|
by caller.
|
|
|
|
|
|
|
|
@retval EFI_SUCCESS The operation was successful.
|
|
|
|
**/
|
|
|
|
EFI_STATUS
|
|
|
|
ShellLevel2StripQuotes (
|
|
|
|
IN CONST CHAR16 *OriginalString,
|
|
|
|
OUT CHAR16 **CleanString
|
|
|
|
);
|
|
|
|
|
2011-03-25 21:58:08 +01:00
|
|
|
/**
|
|
|
|
Function for 'Vol' command.
|
|
|
|
|
|
|
|
@param[in] ImageHandle Handle to the Image (NULL if Internal).
|
|
|
|
@param[in] SystemTable Pointer to the System Table (NULL if Internal).
|
|
|
|
**/
|
|
|
|
SHELL_STATUS
|
|
|
|
EFIAPI
|
|
|
|
ShellCommandRunVol (
|
|
|
|
IN EFI_HANDLE ImageHandle,
|
|
|
|
IN EFI_SYSTEM_TABLE *SystemTable
|
|
|
|
);
|
|
|
|
|
2014-10-02 18:40:49 +02:00
|
|
|
/**
|
|
|
|
Function to Copy one file to another location
|
|
|
|
|
|
|
|
If the destination exists the user will be prompted and the result put into *resp
|
|
|
|
|
|
|
|
@param[in] Source pointer to source file name
|
|
|
|
@param[in] Dest pointer to destination file name
|
|
|
|
@param[out] Resp pointer to response from question. Pass back on looped calling
|
|
|
|
@param[in] SilentMode whether to run in quiet mode or not
|
2015-04-07 22:39:22 +02:00
|
|
|
@param[in] CmdName Source command name requesting single file copy
|
2014-10-02 18:40:49 +02:00
|
|
|
|
|
|
|
@retval SHELL_SUCCESS The source file was copied to the destination
|
|
|
|
**/
|
|
|
|
SHELL_STATUS
|
|
|
|
CopySingleFile(
|
|
|
|
IN CONST CHAR16 *Source,
|
|
|
|
IN CONST CHAR16 *Dest,
|
|
|
|
OUT VOID **Resp,
|
2015-04-07 22:39:22 +02:00
|
|
|
IN BOOLEAN SilentMode,
|
|
|
|
IN CONST CHAR16 *CmdName
|
2014-10-02 18:40:49 +02:00
|
|
|
);
|
|
|
|
|
|
|
|
/**
|
|
|
|
Delete a node and all nodes under it (including sub directories).
|
|
|
|
|
|
|
|
@param[in] Node The node to start deleting with.
|
|
|
|
@param[in] Quiet TRUE to print no messages.
|
|
|
|
|
|
|
|
@retval SHELL_SUCCESS The operation was successful.
|
|
|
|
@retval SHELL_ACCESS_DENIED A file was read only.
|
|
|
|
@retval SHELL_ABORTED The abort message was received.
|
2020-08-01 02:52:32 +02:00
|
|
|
@retval SHELL_DEVICE_ERROR A device error occurred reading this Node.
|
2014-10-02 18:40:49 +02:00
|
|
|
**/
|
|
|
|
SHELL_STATUS
|
|
|
|
CascadeDelete(
|
|
|
|
IN EFI_SHELL_FILE_INFO *Node,
|
|
|
|
IN CONST BOOLEAN Quiet
|
|
|
|
);
|
|
|
|
|
2011-03-25 21:58:08 +01:00
|
|
|
#endif
|
|
|
|
|