Move libraries from ShellPkg into MdeModulePkg and MdePkg.
The following libraries are being migrated out of ShellPkg in order to make
their functionality more widely available.
  • PathLib:        Incorporate into MdePkg/Library/BaseLib
  • FileHandleLib:  MdePkg/Library/UefiFileHandleLib
  • BaseSortLib:    MdeModulePkg/Library/BaseSortLib
  • UefiSortLib:    MdeModulePkg/Library/UefiSortLib
Diffs showing file changes are in the attached file, LibMigration.patch.
A description of the changes follows:
  • Move ShellPkg/Include/Library/FileHandleLib.h to MdePkg/Include/Library/FileHandleLib.h
  • Move ShellPkg/Include/Library/SortLib.h to MdeModulePkg/Include/Library/SortLib.h
  • Move ShellPkg/Library/BaseSortLib to MdeModulePkg/Library/BaseSortLib
  • Move ShellPkg/Library/UefiSortLib to MdeModulePkg/Library/UefiSortLib
  • Move ShellPkg/Library/BasePathLib/BasePathLib.c to MdePkg/Library/BaseLib/FilePaths.c
  • Merge ShellPkg/Include/Library/PathLib.h into MdePkg/Include/Library/BaseLib.h
  • Delete  ShellPkg/Library/BasePathLib; Includes BasePathLib.c and BasePathLib.inf
  • NetworkPkg/NetworkPkg.dsc
  • PerformancePkg.dsc
  • OvmfPkg/OvmfPkgX64.dsc
  • OvmfPkg/OvmfPkgIa32X64.dsc
  • OvmfPkg/OvmfPkgIa32.dsc
    o Update SortLib and FileHandleLib library classes to point to the new library locations.
    o Remove PathLib library class and make sure that BaseLib is described.
  • MdeModulePkg/MdeModulePkg.dec
    o Add SortLib library class
  • MdePkg/MdePkg.dec
    o Add FileHandleLib library class
    o Add PcdUefiFileHandleLibPrintBufferSize PCD
  • MdePkg/Library/BaseLib/BaseLib.inf
    o Add FilePaths.c to [Sources]
  • MdePkg/Include/Library/BaseLib.h
    o Update file description to include "file path functions"
  • ShellPkg/ShellPkg.dsc
    o Change PACKAGE_GUID to { C1014BB7-4092-43D4-984F-0738EB424DBF }
    o Update PACKAGE_VERSION to 1.0
    o Update SortLib and FileHandleLib library classes to point to the new library locations.
    o Remove PathLib library class and make sure that BaseLib is described.
    o Remove ShellPkg/Library/UefiFileHandleLib/UefiFileHandleLib.inf from [Components]
  • ShellPkg/ShellPkg.dec
    o Update PLATFORM_VERSION to 1.0
    o Remove declarations of the FileHandleLib, SortLib, and PathLib Library Classes
    o Update comment for the PcdShellPrintBufferSize PCD.
  • ShellPkg/Library/UefiShellLevel2CommandsLib/UefiShellLevel2CommandsLib.inf
  • ShellPkg/Application/Shell/Shell.inf
    o Remove PathLib from [LibraryClasses]
  • ShellPkg/Library/UefiShellLevel2CommandsLib/UefiShellLevel2CommandsLib.h
  • ShellPkg/Application/Shell/Shell.h
    o Remove #include <Library/PathLib.h>
  • ShellPkg/Library/UefiShellLevel1CommandsLib/UefiShellLevel1CommandsLib.inf
    o Add PathLib to [LibraryClasses]
  • ShellPkg/Library/UefiShellLevel1CommandsLib/If.c
    o Remove #include <Library/PathLib.h>
  • ShellPkg/Application/ShellSortTestApp/ShellSortTestApp.inf
    o Add MdeModulePkg/MdeModulePkg.dec to [Packages]
  • MdeModulePkg/Library/BaseSortLib/BaseSortLib.inf
  • MdeModulePkg/Library/UefiSortLib/UefiSortLib.inf
    o Replace ShellPkg.dec with MdeModulePkg.dec in [Packages]
  • MdeModulePkg/Library/UefiSortLib/UefiSortLib.c
    o Remove #include <ShellBase.h>
    o Define USL_FREE_NON_NULL() to replace SHELL_FREE_NON_NULL()
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Daryl McDaniel <daryl.mcdaniel@intel.com>
Reviewed-by: Jaben Carsey <jaben.carsey@intel.com>
Reviewed-by: Erik Bjorge <erik.c.bjorge@intel.com>
git-svn-id: https://svn.code.sf.net/p/edk2/code/trunk/edk2@16601 6f19259b-4bc3-4df7-8a09-765794883524
		
	
		
			
				
	
	
		
			373 lines
		
	
	
		
			9.7 KiB
		
	
	
	
		
			C
		
	
	
	
	
	
			
		
		
	
	
			373 lines
		
	
	
		
			9.7 KiB
		
	
	
	
		
			C
		
	
	
	
	
	
| /** @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
 | |
| 
 | |
| 
 | |
|   Copyright (c) 2009 - 2014, Intel Corporation. All rights reserved.<BR>
 | |
|   This program and the accompanying materials
 | |
|   are licensed and made available under the terms and conditions of the BSD License
 | |
|   which accompanies this distribution.  The full text of the license may be found at
 | |
|   http://opensource.org/licenses/bsd-license.php
 | |
| 
 | |
|   THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
 | |
|   WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
 | |
| 
 | |
| **/
 | |
| 
 | |
| #ifndef _UEFI_SHELL_LEVEL2_COMMANDS_LIB_H_
 | |
| #define _UEFI_SHELL_LEVEL2_COMMANDS_LIB_H_
 | |
| 
 | |
| #include <Uefi.h>
 | |
| #include <ShellBase.h>
 | |
| 
 | |
| #include <Guid/ShellLibHiiGuid.h>
 | |
| 
 | |
| #include <Protocol/EfiShell.h>
 | |
| #include <Protocol/EfiShellParameters.h>
 | |
| #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[];
 | |
| extern        EFI_HANDLE                        gShellLevel2HiiHandle;
 | |
| 
 | |
| /**
 | |
|   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*
 | |
| EFIAPI
 | |
| 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
 | |
| EFIAPI
 | |
| VerifyIntermediateDirectories (
 | |
|   IN CONST CHAR16 *Path
 | |
|   );
 | |
| 
 | |
| /**
 | |
|   CaseInsensitive length limited string comparison.
 | |
| 
 | |
|   @param[in] Source   Pointer to first string.
 | |
|   @param[in] Target   Pointer to second string.
 | |
|   @param[in] Count    Number of characters to compare.
 | |
| 
 | |
|   @retval 0   The strings are the same.
 | |
|   @return     non-zero if the strings are different.
 | |
| **/
 | |
| CONST CHAR16*
 | |
| EFIAPI
 | |
| StrniCmp(
 | |
|   IN CONST CHAR16 *Source,
 | |
|   IN CONST CHAR16 *Target,
 | |
|   IN CONST UINTN  Count
 | |
|   );
 | |
| 
 | |
| /**
 | |
|   Cleans off all the quotes in the string.
 | |
| 
 | |
|   @param[in]     OriginalString   pointer to the string to be cleaned.
 | |
|   @param[out]   CleanString      The new string with all quotes removed. 
 | |
|                                                   Memory allocated in the function and free 
 | |
|                                                   by caller.
 | |
| 
 | |
|   @retval EFI_SUCCESS   The operation was successful.
 | |
| **/
 | |
| EFI_STATUS
 | |
| EFIAPI
 | |
| ShellLevel2StripQuotes (
 | |
|   IN  CONST CHAR16     *OriginalString,
 | |
|   OUT CHAR16           **CleanString
 | |
|   );
 | |
| 
 | |
| /**
 | |
|   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
 | |
|   );
 | |
| 
 | |
| /**
 | |
|   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
 | |
| 
 | |
|   @retval SHELL_SUCCESS   The source file was copied to the destination
 | |
| **/
 | |
| SHELL_STATUS
 | |
| EFIAPI
 | |
| CopySingleFile(
 | |
|   IN CONST CHAR16 *Source,
 | |
|   IN CONST CHAR16 *Dest,
 | |
|   OUT VOID        **Resp,
 | |
|   IN BOOLEAN      SilentMode
 | |
|   );
 | |
| 
 | |
| /**
 | |
|   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.
 | |
|   @retval SHELL_DEVICE_ERROR  A device error occured reading this Node.
 | |
| **/
 | |
| SHELL_STATUS
 | |
| EFIAPI
 | |
| CascadeDelete(
 | |
|   IN EFI_SHELL_FILE_INFO  *Node,
 | |
|   IN CONST BOOLEAN        Quiet
 | |
|   );
 | |
| 
 | |
| #endif
 | |
| 
 |