]> git.proxmox.com Git - mirror_edk2.git/commitdiff
MdeModulePkg, MdePkg, NetworkPkg, OvmfPkg, PerformancePkg, ShellPkg: Library Migration.
authorDaryl McDaniel <daryl.mcdaniel@intel.com>
Tue, 13 Jan 2015 01:04:07 +0000 (01:04 +0000)
committerdarylm503 <darylm503@Edk2>
Tue, 13 Jan 2015 01:04:07 +0000 (01:04 +0000)
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

38 files changed:
MdeModulePkg/Include/Library/SortLib.h [new file with mode: 0644]
MdeModulePkg/Library/BaseSortLib/BaseSortLib.c [new file with mode: 0644]
MdeModulePkg/Library/BaseSortLib/BaseSortLib.inf [new file with mode: 0644]
MdeModulePkg/Library/UefiSortLib/UefiSortLib.c [new file with mode: 0644]
MdeModulePkg/Library/UefiSortLib/UefiSortLib.inf [new file with mode: 0644]
MdeModulePkg/MdeModulePkg.dec
MdePkg/Include/Library/BaseLib.h
MdePkg/Include/Library/FileHandleLib.h [new file with mode: 0644]
MdePkg/Library/BaseLib/BaseLib.inf
MdePkg/Library/BaseLib/FilePaths.c [new file with mode: 0644]
MdePkg/Library/UefiFileHandleLib/UefiFileHandleLib.c [new file with mode: 0644]
MdePkg/Library/UefiFileHandleLib/UefiFileHandleLib.inf [new file with mode: 0644]
MdePkg/MdePkg.dec
NetworkPkg/NetworkPkg.dsc
OvmfPkg/OvmfPkgIa32.dsc
OvmfPkg/OvmfPkgIa32X64.dsc
OvmfPkg/OvmfPkgX64.dsc
PerformancePkg/PerformancePkg.dsc
ShellPkg/Application/Shell/Shell.h
ShellPkg/Application/Shell/Shell.inf
ShellPkg/Application/ShellSortTestApp/ShellSortTestApp.inf
ShellPkg/Include/Library/FileHandleLib.h [deleted file]
ShellPkg/Include/Library/PathLib.h [deleted file]
ShellPkg/Include/Library/SortLib.h [deleted file]
ShellPkg/Library/BasePathLib/BasePathLib.c [deleted file]
ShellPkg/Library/BasePathLib/BasePathLib.inf [deleted file]
ShellPkg/Library/BaseSortLib/BaseSortLib.c [deleted file]
ShellPkg/Library/BaseSortLib/BaseSortLib.inf [deleted file]
ShellPkg/Library/UefiFileHandleLib/UefiFileHandleLib.c [deleted file]
ShellPkg/Library/UefiFileHandleLib/UefiFileHandleLib.inf [deleted file]
ShellPkg/Library/UefiShellLevel1CommandsLib/If.c
ShellPkg/Library/UefiShellLevel1CommandsLib/UefiShellLevel1CommandsLib.inf
ShellPkg/Library/UefiShellLevel2CommandsLib/UefiShellLevel2CommandsLib.h
ShellPkg/Library/UefiShellLevel2CommandsLib/UefiShellLevel2CommandsLib.inf
ShellPkg/Library/UefiSortLib/UefiSortLib.c [deleted file]
ShellPkg/Library/UefiSortLib/UefiSortLib.inf [deleted file]
ShellPkg/ShellPkg.dec
ShellPkg/ShellPkg.dsc

diff --git a/MdeModulePkg/Include/Library/SortLib.h b/MdeModulePkg/Include/Library/SortLib.h
new file mode 100644 (file)
index 0000000..a891cab
--- /dev/null
@@ -0,0 +1,113 @@
+/** @file\r
+  Library used for sorting and comparison routines.\r
+\r
+  Copyright (c) 2009 - 2014, Intel Corporation. All rights reserved. <BR>\r
+  This program and the accompanying materials\r
+  are licensed and made available under the terms and conditions of the BSD License\r
+  which accompanies this distribution.  The full text of the license may be found at\r
+  http://opensource.org/licenses/bsd-license.php\r
+\r
+  THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
+  WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
+\r
+**/\r
+#ifndef __SORT_LIB_H__\r
+#define __SORT_LIB_H__\r
+\r
+/**\r
+  Prototype for comparison function for any two element types.\r
+\r
+  @param[in] Buffer1                  The pointer to first buffer.\r
+  @param[in] Buffer2                  The pointer to second buffer.\r
+\r
+  @retval 0                           Buffer1 equal to Buffer2.\r
+  @return <0                          Buffer1 is less than Buffer2.\r
+  @return >0                          Buffer1 is greater than Buffer2.\r
+**/\r
+typedef\r
+INTN\r
+(EFIAPI *SORT_COMPARE)(\r
+  IN CONST VOID                 *Buffer1,\r
+  IN CONST VOID                 *Buffer2\r
+  );\r
+\r
+/**\r
+  Function to perform a Quick Sort on a buffer of comparable elements.\r
+\r
+  Each element must be equally sized.\r
+\r
+  If BufferToSort is NULL, then ASSERT.\r
+  If CompareFunction is NULL, then ASSERT.\r
+\r
+  If Count is < 2 , then perform no action.\r
+  If Size is < 1 , then perform no action.\r
+\r
+  @param[in, out] BufferToSort   On call, a Buffer of (possibly sorted) elements;\r
+                                 on return, a buffer of sorted elements.\r
+  @param[in]  Count              The number of elements in the buffer to sort.\r
+  @param[in]  ElementSize        The size of an element in bytes.\r
+  @param[in]  CompareFunction    The function to call to perform the comparison\r
+                                 of any two elements.\r
+**/\r
+VOID\r
+EFIAPI\r
+PerformQuickSort (\r
+  IN OUT VOID                   *BufferToSort,\r
+  IN CONST UINTN                Count,\r
+  IN CONST UINTN                ElementSize,\r
+  IN       SORT_COMPARE         CompareFunction\r
+  );\r
+\r
+\r
+/**\r
+  Function to compare 2 device paths for use as CompareFunction.\r
+\r
+  @param[in] Buffer1            The pointer to Device Path to compare.\r
+  @param[in] Buffer2            The pointer to second DevicePath to compare.\r
+\r
+  @retval 0                     Buffer1 equal to Buffer2.\r
+  @return < 0                   Buffer1 is less than Buffer2.\r
+  @return > 0                   Buffer1 is greater than Buffer2.\r
+**/\r
+INTN\r
+EFIAPI\r
+DevicePathCompare (\r
+  IN  CONST VOID                *Buffer1,\r
+  IN  CONST VOID                *Buffer2\r
+  );\r
+\r
+/**\r
+  Function to compare 2 strings without regard to case of the characters.\r
+\r
+  @param[in] Buffer1            The pointer to String to compare (CHAR16**).\r
+  @param[in] Buffer2            The pointer to second String to compare (CHAR16**).\r
+\r
+  @retval 0                     Buffer1 equal to Buffer2.\r
+  @return < 0                   Buffer1 is less than Buffer2.\r
+  @return > 0                   Buffer1 is greater than Buffer2.\r
+**/\r
+INTN\r
+EFIAPI\r
+StringNoCaseCompare (\r
+  IN  CONST VOID                *Buffer1,\r
+  IN  CONST VOID                *Buffer2\r
+  );\r
+\r
+/**\r
+  Function to compare 2 strings.\r
+\r
+  @param[in] Buffer1            The pointer to String to compare (CHAR16**).\r
+  @param[in] Buffer2            The pointer to second String to compare (CHAR16**).\r
+\r
+  @retval 0                     Buffer1 equal to Buffer2.\r
+  @return < 0                   Buffer1 is less than Buffer2.\r
+  @return > 0                   Buffer1 is greater than Buffer2.\r
+**/\r
+INTN\r
+EFIAPI\r
+StringCompare (\r
+  IN  CONST VOID                *Buffer1,\r
+  IN  CONST VOID                *Buffer2\r
+  );\r
+\r
+#endif //__SORT_LIB_H__\r
diff --git a/MdeModulePkg/Library/BaseSortLib/BaseSortLib.c b/MdeModulePkg/Library/BaseSortLib/BaseSortLib.c
new file mode 100644 (file)
index 0000000..ab8a605
--- /dev/null
@@ -0,0 +1,238 @@
+/** @file\r
+  Library used for sorting routines.\r
+\r
+  Copyright (c) 2009 - 2014, Intel Corporation. All rights reserved. <BR>\r
+  This program and the accompanying materials\r
+  are licensed and made available under the terms and conditions of the BSD License\r
+  which accompanies this distribution.  The full text of the license may be found at\r
+  http://opensource.org/licenses/bsd-license.php\r
+\r
+  THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
+  WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
+\r
+**/\r
+#include <Uefi.h>\r
+\r
+#include <Library/BaseLib.h>\r
+#include <Library/BaseMemoryLib.h>\r
+#include <Library/DebugLib.h>\r
+#include <Library/MemoryAllocationLib.h>\r
+#include <Library/SortLib.h>\r
+\r
+/**\r
+  Worker function for QuickSorting.  This function is identical to PerformQuickSort,\r
+  except that is uses the pre-allocated buffer so the in place sorting does not need to\r
+  allocate and free buffers constantly.\r
+\r
+  Each element must be equal sized.\r
+\r
+  if BufferToSort is NULL, then ASSERT.\r
+  if CompareFunction is NULL, then ASSERT.\r
+  if Buffer is NULL, then ASSERT.\r
+\r
+  if Count is < 2 then perform no action.\r
+  if Size is < 1 then perform no action.\r
+\r
+  @param[in, out] BufferToSort   on call a Buffer of (possibly sorted) elements\r
+                                 on return a buffer of sorted elements\r
+  @param[in] Count               the number of elements in the buffer to sort\r
+  @param[in] ElementSize         Size of an element in bytes\r
+  @param[in] CompareFunction     The function to call to perform the comparison\r
+                                 of any 2 elements\r
+  @param[in] Buffer              Buffer of size ElementSize for use in swapping\r
+**/\r
+VOID\r
+EFIAPI\r
+QuickSortWorker (\r
+  IN OUT VOID                           *BufferToSort,\r
+  IN CONST UINTN                        Count,\r
+  IN CONST UINTN                        ElementSize,\r
+  IN       SORT_COMPARE                 CompareFunction,\r
+  IN VOID                               *Buffer\r
+  )\r
+{\r
+  VOID        *Pivot;\r
+  UINTN       LoopCount;\r
+  UINTN       NextSwapLocation;\r
+\r
+  ASSERT(BufferToSort     != NULL);\r
+  ASSERT(CompareFunction  != NULL);\r
+  ASSERT(Buffer  != NULL);\r
+\r
+  if ( Count < 2\r
+    || ElementSize  < 1\r
+   ){\r
+    return;\r
+  }\r
+\r
+  NextSwapLocation = 0;\r
+\r
+  //\r
+  // pick a pivot (we choose last element)\r
+  //\r
+  Pivot = ((UINT8*)BufferToSort+((Count-1)*ElementSize));\r
+\r
+  //\r
+  // Now get the pivot such that all on "left" are below it\r
+  // and everything "right" are above it\r
+  //\r
+  for ( LoopCount = 0\r
+      ; LoopCount < Count -1\r
+      ; LoopCount++\r
+     ){\r
+    //\r
+    // if the element is less than the pivot\r
+    //\r
+    if (CompareFunction((VOID*)((UINT8*)BufferToSort+((LoopCount)*ElementSize)),Pivot) <= 0){\r
+      //\r
+      // swap\r
+      //\r
+      CopyMem (Buffer, (UINT8*)BufferToSort+(NextSwapLocation*ElementSize), ElementSize);\r
+      CopyMem ((UINT8*)BufferToSort+(NextSwapLocation*ElementSize), (UINT8*)BufferToSort+((LoopCount)*ElementSize), ElementSize);\r
+      CopyMem ((UINT8*)BufferToSort+((LoopCount)*ElementSize), Buffer, ElementSize);\r
+\r
+      //\r
+      // increment NextSwapLocation\r
+      //\r
+      NextSwapLocation++;\r
+    }\r
+  }\r
+  //\r
+  // swap pivot to it's final position (NextSwapLocaiton)\r
+  //\r
+  CopyMem (Buffer, Pivot, ElementSize);\r
+  CopyMem (Pivot, (UINT8*)BufferToSort+(NextSwapLocation*ElementSize), ElementSize);\r
+  CopyMem ((UINT8*)BufferToSort+(NextSwapLocation*ElementSize), Buffer, ElementSize);\r
+\r
+  //\r
+  // Now recurse on 2 paritial lists.  neither of these will have the 'pivot' element\r
+  // IE list is sorted left half, pivot element, sorted right half...\r
+  //\r
+  if (NextSwapLocation >= 2) {\r
+    QuickSortWorker(\r
+      BufferToSort,\r
+      NextSwapLocation,\r
+      ElementSize,\r
+      CompareFunction,\r
+      Buffer);\r
+  }\r
+\r
+  if ((Count - NextSwapLocation - 1) >= 2) {\r
+    QuickSortWorker(\r
+      (UINT8 *)BufferToSort + (NextSwapLocation+1) * ElementSize,\r
+      Count - NextSwapLocation - 1,\r
+      ElementSize,\r
+      CompareFunction,\r
+      Buffer);\r
+  }\r
+  return;\r
+}\r
+/**\r
+  Function to perform a Quick Sort alogrithm on a buffer of comparable elements.\r
+\r
+  Each element must be equal sized.\r
+\r
+  if BufferToSort is NULL, then ASSERT.\r
+  if CompareFunction is NULL, then ASSERT.\r
+\r
+  if Count is < 2 then perform no action.\r
+  if Size is < 1 then perform no action.\r
+\r
+  @param[in, out] BufferToSort   on call a Buffer of (possibly sorted) elements\r
+                                 on return a buffer of sorted elements\r
+  @param[in] Count               the number of elements in the buffer to sort\r
+  @param[in] ElementSize         Size of an element in bytes\r
+  @param[in] CompareFunction     The function to call to perform the comparison\r
+                                 of any 2 elements\r
+**/\r
+VOID\r
+EFIAPI\r
+PerformQuickSort (\r
+  IN OUT VOID                           *BufferToSort,\r
+  IN CONST UINTN                        Count,\r
+  IN CONST UINTN                        ElementSize,\r
+  IN       SORT_COMPARE                 CompareFunction\r
+  )\r
+{\r
+  VOID  *Buffer;\r
+\r
+  ASSERT(BufferToSort     != NULL);\r
+  ASSERT(CompareFunction  != NULL);\r
+\r
+  Buffer = AllocateZeroPool(ElementSize);\r
+  ASSERT(Buffer != NULL);\r
+\r
+  QuickSortWorker(\r
+    BufferToSort,\r
+    Count,\r
+    ElementSize,\r
+    CompareFunction,\r
+    Buffer);\r
+\r
+  FreePool(Buffer);\r
+  return;\r
+}\r
+\r
+/**\r
+  Not supported in Base version.\r
+\r
+  @param[in] Buffer1  Ignored.\r
+  @param[in] Buffer2  Ignored.\r
+\r
+  ASSERT and return 0.\r
+**/\r
+INTN\r
+EFIAPI\r
+DevicePathCompare (\r
+  IN  CONST VOID             *Buffer1,\r
+  IN  CONST VOID             *Buffer2\r
+  )\r
+{\r
+  ASSERT(FALSE);\r
+  return 0;\r
+}\r
+\r
+/**\r
+  Function to compare 2 strings without regard to case of the characters.\r
+\r
+  @param[in] Buffer1            Pointer to String to compare.\r
+  @param[in] Buffer2            Pointer to second String to compare.\r
+\r
+  @retval 0                     Buffer1 equal to Buffer2.\r
+  @return < 0                   Buffer1 is less than Buffer2.\r
+  @return > 0                   Buffer1 is greater than Buffer2.\r
+**/\r
+INTN\r
+EFIAPI\r
+StringNoCaseCompare (\r
+  IN  CONST VOID             *Buffer1,\r
+  IN  CONST VOID             *Buffer2\r
+  )\r
+{\r
+  ASSERT(FALSE);\r
+  return 0;\r
+}\r
+\r
+\r
+/**\r
+  Function to compare 2 strings.\r
+\r
+  @param[in] Buffer1            Pointer to String to compare (CHAR16**).\r
+  @param[in] Buffer2            Pointer to second String to compare (CHAR16**).\r
+\r
+  @retval 0                     Buffer1 equal to Buffer2.\r
+  @return < 0                   Buffer1 is less than Buffer2.\r
+  @return > 0                   Buffer1 is greater than Buffer2.\r
+**/\r
+INTN\r
+EFIAPI\r
+StringCompare (\r
+  IN  CONST VOID                *Buffer1,\r
+  IN  CONST VOID                *Buffer2\r
+  )\r
+{\r
+  ASSERT(FALSE);\r
+  return 0;\r
+}\r
+\r
+\r
diff --git a/MdeModulePkg/Library/BaseSortLib/BaseSortLib.inf b/MdeModulePkg/Library/BaseSortLib/BaseSortLib.inf
new file mode 100644 (file)
index 0000000..e372248
--- /dev/null
@@ -0,0 +1,41 @@
+##  @file\r
+#   Library used for sorting routines.\r
+#\r
+#  Copyright (c) 2009 - 2014, Intel Corporation. All rights reserved. <BR>\r
+#\r
+#  This program and the accompanying materials\r
+#  are licensed and made available under the terms and conditions of the BSD License\r
+#  which accompanies this distribution. The full text of the license may be found at\r
+#  http://opensource.org/licenses/bsd-license.php\r
+#  THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
+#  WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
+#\r
+#\r
+##\r
+\r
+[Defines]\r
+  INF_VERSION                    = 0x00010006\r
+  BASE_NAME                      = BaseSortLib\r
+  FILE_GUID                      = 03F3331B-F12D-494f-BF37-E55A657F2497\r
+  MODULE_TYPE                    = UEFI_DRIVER\r
+  VERSION_STRING                 = 1.0\r
+  LIBRARY_CLASS                  = SortLib|UEFI_APPLICATION UEFI_DRIVER\r
+\r
+#\r
+#  VALID_ARCHITECTURES           = IA32 X64 IPF EBC\r
+#\r
+\r
+[Sources.common]\r
+  BaseSortLib.c\r
+\r
+[Packages]\r
+  MdePkg/MdePkg.dec\r
+  MdeModulePkg/MdeModulePkg.dec\r
+\r
+[LibraryClasses]\r
+  MemoryAllocationLib\r
+  BaseLib\r
+  BaseMemoryLib\r
+  DebugLib\r
+\r
+\r
diff --git a/MdeModulePkg/Library/UefiSortLib/UefiSortLib.c b/MdeModulePkg/Library/UefiSortLib/UefiSortLib.c
new file mode 100644 (file)
index 0000000..8a45cd0
--- /dev/null
@@ -0,0 +1,322 @@
+/** @file\r
+  Library used for sorting routines.\r
+\r
+  Copyright (c) 2009 - 2014, Intel Corporation. All rights reserved. <BR>\r
+  This program and the accompanying materials\r
+  are licensed and made available under the terms and conditions of the BSD License\r
+  which accompanies this distribution.  The full text of the license may be found at\r
+  http://opensource.org/licenses/bsd-license.php\r
+\r
+  THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
+  WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
+\r
+**/\r
+\r
+#include <Uefi.h>\r
+\r
+#include <Protocol/UnicodeCollation.h>\r
+#include <Protocol/DevicePath.h>\r
+\r
+#include <Library/UefiBootServicesTableLib.h>\r
+#include <Library/BaseLib.h>\r
+#include <Library/BaseMemoryLib.h>\r
+#include <Library/DebugLib.h>\r
+#include <Library/MemoryAllocationLib.h>\r
+#include <Library/SortLib.h>\r
+#include <Library/DevicePathLib.h>\r
+\r
+STATIC EFI_UNICODE_COLLATION_PROTOCOL   *mUnicodeCollation = NULL;\r
+\r
+#define USL_FREE_NON_NULL(Pointer)  \\r
+{                                     \\r
+  if ((Pointer) != NULL) {            \\r
+  FreePool((Pointer));                \\r
+  (Pointer) = NULL;                   \\r
+  }                                   \\r
+}\r
+\r
+/**\r
+  Worker function for QuickSorting.  This function is identical to PerformQuickSort,\r
+  except that is uses the pre-allocated buffer so the in place sorting does not need to\r
+  allocate and free buffers constantly.\r
+\r
+  Each element must be equal sized.\r
+\r
+  if BufferToSort is NULL, then ASSERT.\r
+  if CompareFunction is NULL, then ASSERT.\r
+  if Buffer is NULL, then ASSERT.\r
+\r
+  if Count is < 2 then perform no action.\r
+  if Size is < 1 then perform no action.\r
+\r
+  @param[in, out] BufferToSort   on call a Buffer of (possibly sorted) elements\r
+                                 on return a buffer of sorted elements\r
+  @param[in] Count               the number of elements in the buffer to sort\r
+  @param[in] ElementSize         Size of an element in bytes\r
+  @param[in] CompareFunction     The function to call to perform the comparison\r
+                                 of any 2 elements\r
+  @param[in] Buffer              Buffer of size ElementSize for use in swapping\r
+**/\r
+VOID\r
+EFIAPI\r
+QuickSortWorker (\r
+  IN OUT VOID                           *BufferToSort,\r
+  IN CONST UINTN                        Count,\r
+  IN CONST UINTN                        ElementSize,\r
+  IN       SORT_COMPARE                 CompareFunction,\r
+  IN VOID                               *Buffer\r
+  )\r
+{\r
+  VOID        *Pivot;\r
+  UINTN       LoopCount;\r
+  UINTN       NextSwapLocation;\r
+\r
+  ASSERT(BufferToSort     != NULL);\r
+  ASSERT(CompareFunction  != NULL);\r
+  ASSERT(Buffer  != NULL);\r
+\r
+  if ( Count < 2\r
+    || ElementSize  < 1\r
+   ){\r
+    return;\r
+  }\r
+\r
+  NextSwapLocation = 0;\r
+\r
+  //\r
+  // pick a pivot (we choose last element)\r
+  //\r
+  Pivot = ((UINT8*)BufferToSort+((Count-1)*ElementSize));\r
+\r
+  //\r
+  // Now get the pivot such that all on "left" are below it\r
+  // and everything "right" are above it\r
+  //\r
+  for ( LoopCount = 0\r
+      ; LoopCount < Count -1\r
+      ; LoopCount++\r
+     ){\r
+    //\r
+    // if the element is less than the pivot\r
+    //\r
+    if (CompareFunction((VOID*)((UINT8*)BufferToSort+((LoopCount)*ElementSize)),Pivot) <= 0){\r
+      //\r
+      // swap\r
+      //\r
+      CopyMem (Buffer, (UINT8*)BufferToSort+(NextSwapLocation*ElementSize), ElementSize);\r
+      CopyMem ((UINT8*)BufferToSort+(NextSwapLocation*ElementSize), (UINT8*)BufferToSort+((LoopCount)*ElementSize), ElementSize);\r
+      CopyMem ((UINT8*)BufferToSort+((LoopCount)*ElementSize), Buffer, ElementSize);\r
+\r
+      //\r
+      // increment NextSwapLocation\r
+      //\r
+      NextSwapLocation++;\r
+    }\r
+  }\r
+  //\r
+  // swap pivot to it's final position (NextSwapLocaiton)\r
+  //\r
+  CopyMem (Buffer, Pivot, ElementSize);\r
+  CopyMem (Pivot, (UINT8*)BufferToSort+(NextSwapLocation*ElementSize), ElementSize);\r
+  CopyMem ((UINT8*)BufferToSort+(NextSwapLocation*ElementSize), Buffer, ElementSize);\r
+\r
+  //\r
+  // Now recurse on 2 paritial lists.  neither of these will have the 'pivot' element\r
+  // IE list is sorted left half, pivot element, sorted right half...\r
+  //\r
+  if (NextSwapLocation >= 2) {\r
+    QuickSortWorker(\r
+      BufferToSort,\r
+      NextSwapLocation,\r
+      ElementSize,\r
+      CompareFunction,\r
+      Buffer);\r
+  }\r
+\r
+  if ((Count - NextSwapLocation - 1) >= 2) {\r
+    QuickSortWorker(\r
+      (UINT8 *)BufferToSort + (NextSwapLocation+1) * ElementSize,\r
+      Count - NextSwapLocation - 1,\r
+      ElementSize,\r
+      CompareFunction,\r
+      Buffer);\r
+  }\r
+\r
+  return;\r
+}\r
+/**\r
+  Function to perform a Quick Sort alogrithm on a buffer of comparable elements.\r
+\r
+  Each element must be equal sized.\r
+\r
+  if BufferToSort is NULL, then ASSERT.\r
+  if CompareFunction is NULL, then ASSERT.\r
+\r
+  if Count is < 2 then perform no action.\r
+  if Size is < 1 then perform no action.\r
+\r
+  @param[in, out] BufferToSort   on call a Buffer of (possibly sorted) elements\r
+                                 on return a buffer of sorted elements\r
+  @param[in] Count               the number of elements in the buffer to sort\r
+  @param[in] ElementSize         Size of an element in bytes\r
+  @param[in] CompareFunction     The function to call to perform the comparison\r
+                                 of any 2 elements\r
+**/\r
+VOID\r
+EFIAPI\r
+PerformQuickSort (\r
+  IN OUT VOID                           *BufferToSort,\r
+  IN CONST UINTN                        Count,\r
+  IN CONST UINTN                        ElementSize,\r
+  IN       SORT_COMPARE                 CompareFunction\r
+  )\r
+{\r
+  VOID  *Buffer;\r
+\r
+  ASSERT(BufferToSort     != NULL);\r
+  ASSERT(CompareFunction  != NULL);\r
+\r
+  Buffer = AllocateZeroPool(ElementSize);\r
+  ASSERT(Buffer != NULL);\r
+\r
+  QuickSortWorker(\r
+    BufferToSort,\r
+    Count,\r
+    ElementSize,\r
+    CompareFunction,\r
+    Buffer);\r
+\r
+  FreePool(Buffer);\r
+  return;\r
+}\r
+\r
+/**\r
+  Function to compare 2 device paths for use in QuickSort.\r
+\r
+  @param[in] Buffer1            pointer to Device Path poiner to compare\r
+  @param[in] Buffer2            pointer to second DevicePath pointer to compare\r
+\r
+  @retval 0                     Buffer1 equal to Buffer2\r
+  @retval <0                    Buffer1 is less than Buffer2\r
+  @retval >0                    Buffer1 is greater than Buffer2\r
+**/\r
+INTN\r
+EFIAPI\r
+DevicePathCompare (\r
+  IN  CONST VOID             *Buffer1,\r
+  IN  CONST VOID             *Buffer2\r
+  )\r
+{\r
+  EFI_DEVICE_PATH_PROTOCOL  *DevicePath1;\r
+  EFI_DEVICE_PATH_PROTOCOL  *DevicePath2;\r
+  CHAR16                    *TextPath1;\r
+  CHAR16                    *TextPath2;\r
+  EFI_STATUS                Status;\r
+  INTN                      RetVal;\r
+\r
+  DevicePath1 = *(EFI_DEVICE_PATH_PROTOCOL**)Buffer1;\r
+  DevicePath2 = *(EFI_DEVICE_PATH_PROTOCOL**)Buffer2;\r
+\r
+  if (DevicePath1 == NULL) {\r
+    if (DevicePath2 == NULL) {\r
+      return 0;\r
+    }\r
+\r
+    return -1;\r
+  }\r
+\r
+  if (DevicePath2 == NULL) {\r
+    return 1;\r
+  }\r
+\r
+  if (mUnicodeCollation == NULL) {\r
+    Status = gBS->LocateProtocol(\r
+      &gEfiUnicodeCollation2ProtocolGuid,\r
+      NULL,\r
+      (VOID**)&mUnicodeCollation);\r
+\r
+    ASSERT_EFI_ERROR(Status);\r
+  }\r
+\r
+  TextPath1 = ConvertDevicePathToText(\r
+    DevicePath1,\r
+    FALSE,\r
+    FALSE);\r
+\r
+  TextPath2 = ConvertDevicePathToText(\r
+    DevicePath2,\r
+    FALSE,\r
+    FALSE);\r
+\r
+  if (TextPath1 == NULL) {\r
+    RetVal = -1;\r
+  } else if (TextPath2 == NULL) {\r
+    RetVal = 1;\r
+  } else {\r
+    RetVal = mUnicodeCollation->StriColl(\r
+      mUnicodeCollation,\r
+      TextPath1,\r
+      TextPath2);\r
+  }\r
+\r
+  USL_FREE_NON_NULL(TextPath1);\r
+  USL_FREE_NON_NULL(TextPath2);\r
+\r
+  return (RetVal);\r
+}\r
+\r
+/**\r
+  Function to compare 2 strings without regard to case of the characters.\r
+\r
+  @param[in] Buffer1            Pointer to String to compare.\r
+  @param[in] Buffer2            Pointer to second String to compare.\r
+\r
+  @retval 0                     Buffer1 equal to Buffer2.\r
+  @retval <0                    Buffer1 is less than Buffer2.\r
+  @retval >0                    Buffer1 is greater than Buffer2.\r
+**/\r
+INTN\r
+EFIAPI\r
+StringNoCaseCompare (\r
+  IN  CONST VOID             *Buffer1,\r
+  IN  CONST VOID             *Buffer2\r
+  )\r
+{\r
+  EFI_STATUS                Status;\r
+  if (mUnicodeCollation == NULL) {\r
+    Status = gBS->LocateProtocol(\r
+      &gEfiUnicodeCollation2ProtocolGuid,\r
+      NULL,\r
+      (VOID**)&mUnicodeCollation);\r
+\r
+    ASSERT_EFI_ERROR(Status);\r
+  }\r
+\r
+  return (mUnicodeCollation->StriColl(\r
+    mUnicodeCollation,\r
+    *(CHAR16**)Buffer1,\r
+    *(CHAR16**)Buffer2));\r
+}\r
+\r
+\r
+/**\r
+  Function to compare 2 strings.\r
+\r
+  @param[in] Buffer1            Pointer to String to compare (CHAR16**).\r
+  @param[in] Buffer2            Pointer to second String to compare (CHAR16**).\r
+\r
+  @retval 0                     Buffer1 equal to Buffer2.\r
+  @retval <0                    Buffer1 is less than Buffer2.\r
+  @retval >0                    Buffer1 is greater than Buffer2.\r
+**/\r
+INTN\r
+EFIAPI\r
+StringCompare (\r
+  IN  CONST VOID                *Buffer1,\r
+  IN  CONST VOID                *Buffer2\r
+  )\r
+{\r
+  return (StrCmp(\r
+    *(CHAR16**)Buffer1,\r
+    *(CHAR16**)Buffer2));\r
+}\r
diff --git a/MdeModulePkg/Library/UefiSortLib/UefiSortLib.inf b/MdeModulePkg/Library/UefiSortLib/UefiSortLib.inf
new file mode 100644 (file)
index 0000000..4d3d9e0
--- /dev/null
@@ -0,0 +1,46 @@
+##  @file\r
+#   Library used for sorting routines.\r
+#\r
+#  Copyright (c) 2009 - 2014, Intel Corporation. All rights reserved. <BR>\r
+#\r
+#  This program and the accompanying materials\r
+#  are licensed and made available under the terms and conditions of the BSD License\r
+#  which accompanies this distribution. The full text of the license may be found at\r
+#  http://opensource.org/licenses/bsd-license.php\r
+#  THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
+#  WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
+#\r
+#\r
+##\r
+\r
+[Defines]\r
+  INF_VERSION                    = 0x00010006\r
+  BASE_NAME                      = UefiSortLib\r
+  FILE_GUID                      = 4264A823-45A3-42db-B92C-AA078555CBD3\r
+  MODULE_TYPE                    = UEFI_DRIVER\r
+  VERSION_STRING                 = 1.0\r
+  LIBRARY_CLASS                  = SortLib|UEFI_APPLICATION UEFI_DRIVER UEFI_DRIVER DXE_RUNTIME_DRIVER DXE_DRIVER\r
+\r
+#\r
+#  VALID_ARCHITECTURES           = IA32 X64 IPF EBC\r
+#\r
+\r
+[Sources.common]\r
+  UefiSortLib.c\r
+\r
+[Packages]\r
+  MdePkg/MdePkg.dec\r
+  MdeModulePkg/MdeModulePkg.dec\r
+\r
+[LibraryClasses]\r
+  MemoryAllocationLib\r
+  BaseLib\r
+  BaseMemoryLib\r
+  DebugLib\r
+  UefiBootServicesTableLib\r
+  DevicePathLib\r
+\r
+[Protocols]\r
+  gEfiUnicodeCollation2ProtocolGuid                       # ALWAYS_CONSUMED\r
+  gEfiDevicePathProtocolGuid                              # ALWAYS_CONSUMED\r
+\r
index 83906d21da9c7e44d29815a172568d5dec921307..2e7e461c0f69f6fb02920f5b9d319ac265be5306 100644 (file)
   #\r
   CustomizedDisplayLib|Include/Library/CustomizedDisplayLib.h\r
 \r
+  ## @libraryclass   Provides sorting functions\r
+  SortLib|Include/Library/SortLib.h\r
+\r
 [Guids]\r
   ## MdeModule package token space guid\r
   # Include/Guid/MdeModulePkgTokenSpace.h\r
index bd3f9cfc601fefbdbe6e69423859c6033a504e48..750f82e8f70aa303d4fab42adcf329102905df47 100644 (file)
@@ -1,8 +1,8 @@
 /** @file\r
   Provides string functions, linked list functions, math functions, synchronization\r
-  functions, and CPU architecture-specific functions.\r
+  functions, file path functions, and CPU architecture-specific functions.\r
 \r
-Copyright (c) 2006 - 2014, Intel Corporation. All rights reserved.<BR>\r
+Copyright (c) 2006 - 2015, Intel Corporation. All rights reserved.<BR>\r
 Portions copyright (c) 2008 - 2009, Apple Inc. All rights reserved.<BR>\r
 This program and the accompanying materials\r
 are licensed and made available under the terms and conditions of the BSD License\r
@@ -484,7 +484,7 @@ AsciiStrnCatS (
 #ifndef DISABLE_NEW_DEPRECATED_INTERFACES\r
 \r
 /**\r
-  [ATTENTION] This function will be deprecated for security reason.\r
+  [ATTENTION] This function is deprecated for security reason.\r
 \r
   Copies one Null-terminated Unicode string to another Null-terminated Unicode\r
   string and returns the new Unicode string.\r
@@ -517,7 +517,7 @@ StrCpy (
 \r
 \r
 /**\r
-  [ATTENTION] This function will be deprecated for security reason.\r
+  [ATTENTION] This function is deprecated for security reason.\r
 \r
   Copies up to a specified length from one Null-terminated Unicode string to \r
   another Null-terminated Unicode string and returns the new Unicode string.\r
@@ -686,7 +686,7 @@ StrnCmp (
 #ifndef DISABLE_NEW_DEPRECATED_INTERFACES\r
 \r
 /**\r
-  [ATTENTION] This function will be deprecated for security reason.\r
+  [ATTENTION] This function is deprecated for security reason.\r
 \r
   Concatenates one Null-terminated Unicode string to another Null-terminated\r
   Unicode string, and returns the concatenated Unicode string.\r
@@ -728,7 +728,7 @@ StrCat (
 \r
 \r
 /**\r
-  [ATTENTION] This function will be deprecated for security reason.\r
+  [ATTENTION] This function is deprecated for security reason.\r
 \r
   Concatenates up to a specified length one Null-terminated Unicode to the end \r
   of another Null-terminated Unicode string, and returns the concatenated \r
@@ -1016,7 +1016,7 @@ UnicodeStrToAsciiStr (
 #ifndef DISABLE_NEW_DEPRECATED_INTERFACES\r
 \r
 /**\r
-  [ATTENTION] This function will be deprecated for security reason.\r
+  [ATTENTION] This function is deprecated for security reason.\r
 \r
   Copies one Null-terminated ASCII string to another Null-terminated ASCII\r
   string and returns the new ASCII string.\r
@@ -1047,7 +1047,7 @@ AsciiStrCpy (
 \r
 \r
 /**\r
-  [ATTENTION] This function will be deprecated for security reason.\r
+  [ATTENTION] This function is deprecated for security reason.\r
 \r
   Copies up to a specified length one Null-terminated ASCII string to another \r
   Null-terminated ASCII string and returns the new ASCII string.\r
@@ -1245,7 +1245,7 @@ AsciiStrnCmp (
 #ifndef DISABLE_NEW_DEPRECATED_INTERFACES\r
 \r
 /**\r
-  [ATTENTION] This function will be deprecated for security reason.\r
+  [ATTENTION] This function is deprecated for security reason.\r
 \r
   Concatenates one Null-terminated ASCII string to another Null-terminated\r
   ASCII string, and returns the concatenated ASCII string.\r
@@ -1282,7 +1282,7 @@ AsciiStrCat (
 \r
 \r
 /**\r
-  [ATTENTION] This function will be deprecated for security reason.\r
+  [ATTENTION] This function is deprecated for security reason.\r
 \r
   Concatenates up to a specified length one Null-terminated ASCII string to \r
   the end of another Null-terminated ASCII string, and returns the \r
@@ -1591,6 +1591,43 @@ BcdToDecimal8 (
   IN      UINT8                     Value\r
   );\r
 \r
+//\r
+//  File Path Manipulation Functions\r
+//\r
+\r
+/**\r
+  Removes the last directory or file entry in a path by changing the last\r
+  L'\' to a CHAR_NULL.\r
+\r
+  @param[in, out] Path    The pointer to the path to modify.\r
+\r
+  @retval FALSE     Nothing was found to remove.\r
+  @retval TRUE      A directory or file was removed.\r
+**/\r
+BOOLEAN\r
+EFIAPI\r
+PathRemoveLastItem(\r
+  IN OUT CHAR16 *Path\r
+  );\r
+\r
+/**\r
+  Function to clean up paths.\r
+    - Single periods in the path are removed.\r
+    - Double periods in the path are removed along with a single parent directory.\r
+    - Forward slashes L'/' are converted to backward slashes L'\'.\r
+\r
+  This will be done inline and the existing buffer may be larger than required\r
+  upon completion.\r
+\r
+  @param[in] Path       The pointer to the string containing the path.\r
+\r
+  @return       Returns Path, otherwise returns NULL to indicate that an error has occured.\r
+**/\r
+CHAR16*\r
+EFIAPI\r
+PathCleanUpDirectories(\r
+  IN CHAR16 *Path\r
+);\r
 \r
 //\r
 // Linked List Functions and Macros\r
diff --git a/MdePkg/Include/Library/FileHandleLib.h b/MdePkg/Include/Library/FileHandleLib.h
new file mode 100644 (file)
index 0000000..123cc8c
--- /dev/null
@@ -0,0 +1,498 @@
+/** @file\r
+  Provides interface to EFI_FILE_HANDLE functionality.\r
+\r
+  Copyright (c) 2009 - 2014, Intel Corporation. All rights reserved.<BR>\r
+  This program and the accompanying materials\r
+  are licensed and made available under the terms and conditions of the BSD License\r
+  which accompanies this distribution.  The full text of the license may be found at\r
+  http://opensource.org/licenses/bsd-license.php\r
+\r
+  THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
+  WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
+\r
+**/\r
+\r
+#ifndef _FILE_HANDLE_LIBRARY_HEADER_\r
+#define _FILE_HANDLE_LIBRARY_HEADER_\r
+\r
+#include <Protocol/SimpleFileSystem.h>\r
+\r
+/// The tag for use in identifying UNICODE files.\r
+/// If the file is UNICODE, the first 16 bits of the file will equal this value.\r
+extern CONST UINT16 gUnicodeFileTag;\r
+\r
+/**\r
+  This function retrieves information about the file for the handle\r
+  specified and stores it in the allocated pool memory.\r
+\r
+  This function allocates a buffer to store the file's information. It is the\r
+  caller's responsibility to free the buffer.\r
+\r
+  @param[in] FileHandle         The file handle of the file for which information is\r
+                                being requested.\r
+\r
+  @retval NULL                  Information could not be retrieved.\r
+  @retval !NULL                 The information about the file.\r
+**/\r
+EFI_FILE_INFO*\r
+EFIAPI\r
+FileHandleGetInfo (\r
+  IN EFI_FILE_HANDLE            FileHandle\r
+  );\r
+\r
+/**\r
+  This function sets the information about the file for the opened handle\r
+  specified.\r
+\r
+  @param[in]  FileHandle        The file handle of the file for which information\r
+                                is being set.\r
+\r
+  @param[in]  FileInfo          The information to set.\r
+\r
+  @retval EFI_SUCCESS           The information was set.\r
+  @retval EFI_INVALID_PARAMETER A parameter was out of range or invalid.\r
+  @retval EFI_UNSUPPORTED       The FileHandle does not support FileInfo.\r
+  @retval EFI_NO_MEDIA          The device has no medium.\r
+  @retval EFI_DEVICE_ERROR      The device reported an error.\r
+  @retval EFI_VOLUME_CORRUPTED  The file system structures are corrupted.\r
+  @retval EFI_WRITE_PROTECTED   The file or medium is write protected.\r
+  @retval EFI_ACCESS_DENIED     The file was opened read only.\r
+  @retval EFI_VOLUME_FULL       The volume is full.\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+FileHandleSetInfo (\r
+  IN EFI_FILE_HANDLE            FileHandle,\r
+  IN CONST EFI_FILE_INFO        *FileInfo\r
+  );\r
+\r
+/**\r
+  This function reads information from an opened file.\r
+\r
+  If FileHandle is not a directory, the function reads the requested number of\r
+  bytes from the file at the file's current position and returns them in Buffer.\r
+  If the read goes beyond the end of the file, the read length is truncated to the\r
+  end of the file. The file's current position is increased by the number of bytes\r
+  returned.  If FileHandle is a directory, the function reads the directory entry\r
+  at the file's current position and returns the entry in Buffer. If the Buffer\r
+  is not large enough to hold the current directory entry, then\r
+  EFI_BUFFER_TOO_SMALL is returned and the current file position is not updated.\r
+  BufferSize is set to be the size of the buffer needed to read the entry. On\r
+  success, the current position is updated to the next directory entry. If there\r
+  are no more directory entries, the read returns a zero-length buffer.\r
+  EFI_FILE_INFO is the structure returned as the directory entry.\r
+\r
+  @param[in] FileHandle          The opened file handle.\r
+  @param[in, out] BufferSize     On input, the size of buffer in bytes.  On return,\r
+                                 the number of bytes written.\r
+  @param[out] Buffer             The buffer to put read data into.\r
+\r
+  @retval EFI_SUCCESS         Data was read.\r
+  @retval EFI_NO_MEDIA          The device has no media.\r
+  @retval EFI_DEVICE_ERROR  The device reported an error.\r
+  @retval EFI_VOLUME_CORRUPTED  The file system structures are corrupted.\r
+  @retval EFI_BUFFER_TO_SMALL Buffer is too small. ReadSize contains required\r
+                                size.\r
+\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+FileHandleRead(\r
+  IN EFI_FILE_HANDLE            FileHandle,\r
+  IN OUT UINTN                  *BufferSize,\r
+  OUT VOID                      *Buffer\r
+  );\r
+\r
+/**\r
+  Write data to a file.\r
+\r
+  This function writes the specified number of bytes to the file at the current\r
+  file position. The current file position is advanced the actual number of bytes\r
+  written, which is returned in BufferSize. Partial writes only occur when there\r
+  has been a data error during the write attempt (such as "volume space full").\r
+  The file is automatically grown to hold the data if required. Direct writes to\r
+  opened directories are not supported.\r
+\r
+  @param[in] FileHandle          The opened file for writing.\r
+  @param[in, out] BufferSize     On input, the number of bytes in Buffer.  On output,\r
+                                 the number of bytes written.\r
+  @param[in] Buffer              The buffer containing data to write is stored.\r
+\r
+  @retval EFI_SUCCESS         Data was written.\r
+  @retval EFI_UNSUPPORTED       Writes to an open directory are not supported.\r
+  @retval EFI_NO_MEDIA          The device has no media.\r
+  @retval EFI_DEVICE_ERROR  The device reported an error.\r
+  @retval EFI_VOLUME_CORRUPTED  The file system structures are corrupted.\r
+  @retval EFI_WRITE_PROTECTED The device is write-protected.\r
+  @retval EFI_ACCESS_DENIED The file was opened for read only.\r
+  @retval EFI_VOLUME_FULL The volume is full.\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+FileHandleWrite(\r
+  IN EFI_FILE_HANDLE            FileHandle,\r
+  IN OUT UINTN                  *BufferSize,\r
+  IN VOID                       *Buffer\r
+  );\r
+\r
+/**\r
+  Close an open file handle.\r
+\r
+  This function closes a specified file handle. All "dirty" cached file data is\r
+  flushed to the device, and the file is closed. In all cases the handle is\r
+  closed.\r
+\r
+  @param[in] FileHandle           The file handle to close.\r
+\r
+  @retval EFI_SUCCESS             The file handle was closed successfully.\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+FileHandleClose (\r
+  IN EFI_FILE_HANDLE            FileHandle\r
+  );\r
+\r
+/**\r
+  Delete a file and close the handle.\r
+\r
+  This function closes and deletes a file. In all cases the file handle is closed.\r
+  If the file cannot be deleted, the warning code EFI_WARN_DELETE_FAILURE is\r
+  returned, but the handle is still closed.\r
+\r
+  @param[in] FileHandle             The file handle to delete.\r
+\r
+  @retval EFI_SUCCESS               The file was closed successfully.\r
+  @retval EFI_WARN_DELETE_FAILURE   The handle was closed, but the file was not\r
+                                    deleted.\r
+  @retval INVALID_PARAMETER         One of the parameters has an invalid value.\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+FileHandleDelete (\r
+  IN EFI_FILE_HANDLE    FileHandle\r
+  );\r
+\r
+/**\r
+  Set the current position in a file.\r
+\r
+  This function sets the current file position for the handle to the position\r
+  supplied. With the exception of moving to position 0xFFFFFFFFFFFFFFFF, only\r
+  absolute positioning is supported, and moving past the end of the file is\r
+  allowed (a subsequent write would grow the file). Moving to position\r
+  0xFFFFFFFFFFFFFFFF causes the current position to be set to the end of the file.\r
+  If FileHandle is a directory, the only position that may be set is zero. This\r
+  has the effect of starting the read process of the directory entries over again.\r
+\r
+  @param[in] FileHandle         The file handle on which the position is being set.\r
+  @param[in] Position           The byte position from the begining of the file.\r
+\r
+  @retval EFI_SUCCESS           The operation completed sucessfully.\r
+  @retval EFI_UNSUPPORTED       The request for non-zero is not valid on\r
+                                directories.\r
+  @retval INVALID_PARAMETER     One of the parameters has an invalid value.\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+FileHandleSetPosition (\r
+  IN EFI_FILE_HANDLE    FileHandle,\r
+  IN UINT64             Position\r
+  );\r
+\r
+/**\r
+  Gets a file's current position.\r
+\r
+  This function retrieves the current file position for the file handle. For\r
+  directories, the current file position has no meaning outside of the file\r
+  system driver. As such, the operation is not supported. An error is returned\r
+  if FileHandle is a directory.\r
+\r
+  @param[in] FileHandle         The open file handle on which to get the position.\r
+  @param[out] Position          The byte position from begining of file.\r
+\r
+  @retval EFI_SUCCESS           The operation completed successfully.\r
+  @retval INVALID_PARAMETER     One of the parameters has an invalid value.\r
+  @retval EFI_UNSUPPORTED       The request is not valid on directories.\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+FileHandleGetPosition (\r
+  IN EFI_FILE_HANDLE            FileHandle,\r
+  OUT UINT64                    *Position\r
+  );\r
+/**\r
+  Flushes data on a file.\r
+\r
+  This function flushes all modified data associated with a file to a device.\r
+\r
+  @param[in] FileHandle         The file handle on which to flush data.\r
+\r
+  @retval EFI_SUCCESS           The data was flushed.\r
+  @retval EFI_NO_MEDIA          The device has no media.\r
+  @retval EFI_DEVICE_ERROR      The device reported an error.\r
+  @retval EFI_VOLUME_CORRUPTED  The file system structures are corrupted.\r
+  @retval EFI_WRITE_PROTECTED   The file or medium is write protected.\r
+  @retval EFI_ACCESS_DENIED     The file was opened for read only.\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+FileHandleFlush (\r
+  IN EFI_FILE_HANDLE            FileHandle\r
+  );\r
+\r
+/**\r
+  Function to determine if a given handle is a directory handle.\r
+\r
+  If DirHandle is NULL, then ASSERT().\r
+\r
+  Open the file information on the DirHandle, and verify that the Attribute\r
+  includes EFI_FILE_DIRECTORY bit set.\r
+\r
+  @param[in] DirHandle          The handle to open the file.\r
+\r
+  @retval EFI_SUCCESS           DirHandle is a directory.\r
+  @retval EFI_INVALID_PARAMETER DirHandle did not have EFI_FILE_INFO available.\r
+  @retval EFI_NOT_FOUND         DirHandle is not a directory.\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+FileHandleIsDirectory (\r
+  IN EFI_FILE_HANDLE            DirHandle\r
+  );\r
+\r
+/** Retrieve first entry from a directory.\r
+\r
+  This function takes an open directory handle and gets information from the\r
+  first entry in the directory.  A buffer is allocated to contain\r
+  the information and a pointer to the buffer is returned in *Buffer.  The\r
+  caller can use FileHandleFindNextFile() to get subsequent directory entries.\r
+\r
+  The buffer will be freed by FileHandleFindNextFile() when the last directory\r
+  entry is read.  Otherwise, the caller must free the buffer, using FreePool,\r
+  when finished with it.\r
+\r
+  @param[in]  DirHandle         The file handle of the directory to search.\r
+  @param[out] Buffer            The pointer to pointer to buffer for file's information.\r
+\r
+  @retval EFI_SUCCESS           Found the first file.\r
+  @retval EFI_NOT_FOUND         Cannot find the directory.\r
+  @retval EFI_NO_MEDIA          The device has no media.\r
+  @retval EFI_DEVICE_ERROR      The device reported an error.\r
+  @retval EFI_VOLUME_CORRUPTED  The file system structures are corrupted.\r
+  @return Others                The status of FileHandleGetInfo, FileHandleSetPosition,\r
+                                or FileHandleRead.\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+FileHandleFindFirstFile (\r
+  IN EFI_FILE_HANDLE            DirHandle,\r
+  OUT EFI_FILE_INFO             **Buffer\r
+  );\r
+\r
+/** Retrieve next entries from a directory.\r
+\r
+  To use this function, the caller must first call the FileHandleFindFirstFile()\r
+  function to get the first directory entry.  Subsequent directory entries are\r
+  retrieved by using the FileHandleFindNextFile() function.  This function can\r
+  be called several times to get each entry from the directory.  If the call of\r
+  FileHandleFindNextFile() retrieved the last directory entry, the next call of\r
+  this function will set *NoFile to TRUE and free the buffer.\r
+\r
+  @param[in]  DirHandle         The file handle of the directory.\r
+  @param[out] Buffer            The pointer to buffer for file's information.\r
+  @param[out] NoFile            The pointer to boolean when last file is found.\r
+\r
+  @retval EFI_SUCCESS           Found the next file, or reached last file.\r
+  @retval EFI_NO_MEDIA          The device has no media.\r
+  @retval EFI_DEVICE_ERROR      The device reported an error.\r
+  @retval EFI_VOLUME_CORRUPTED  The file system structures are corrupted.\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+FileHandleFindNextFile(\r
+  IN EFI_FILE_HANDLE             DirHandle,\r
+  OUT EFI_FILE_INFO              *Buffer,\r
+  OUT BOOLEAN                    *NoFile\r
+  );\r
+\r
+/**\r
+  Retrieve the size of a file.\r
+\r
+  If FileHandle is NULL then ASSERT().\r
+  If Size is NULL then ASSERT().\r
+\r
+  This function extracts the file size info from the FileHandle's EFI_FILE_INFO\r
+  data.\r
+\r
+  @param[in] FileHandle         The file handle from which size is retrieved.\r
+  @param[out] Size              The pointer to size.\r
+\r
+  @retval EFI_SUCCESS           The operation completed successfully.\r
+  @retval EFI_DEVICE_ERROR      Cannot access the file.\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+FileHandleGetSize (\r
+  IN EFI_FILE_HANDLE            FileHandle,\r
+  OUT UINT64                    *Size\r
+  );\r
+\r
+/**\r
+  Set the size of a file.\r
+\r
+  If FileHandle is NULL then ASSERT().\r
+\r
+  This function changes the file size info from the FileHandle's EFI_FILE_INFO\r
+  data.\r
+\r
+  @param[in] FileHandle         The file handle whose size is to be changed.\r
+  @param[in] Size               The new size.\r
+\r
+  @retval EFI_SUCCESS           The operation completed successfully.\r
+  @retval EFI_DEVICE_ERROR      Cannot access the file.\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+FileHandleSetSize (\r
+  IN EFI_FILE_HANDLE            FileHandle,\r
+  IN UINT64                     Size\r
+  );\r
+\r
+/**\r
+  Function to get a full filename given a EFI_FILE_HANDLE somewhere lower on the\r
+  directory 'stack'.\r
+\r
+  @param[in] Handle             Handle to the Directory or File to create path to.\r
+  @param[out] FullFileName      Pointer to pointer to generated full file name.  It\r
+                                is the responsibility of the caller to free this memory\r
+                                with a call to FreePool().\r
+  @retval EFI_SUCCESS           The operation was successful and FullFileName is valid.\r
+  @retval EFI_INVALID_PARAMETER Handle was NULL.\r
+  @retval EFI_INVALID_PARAMETER FullFileName was NULL.\r
+  @retval EFI_OUT_OF_MEMORY     A memory allocation failed.\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+FileHandleGetFileName (\r
+  IN CONST EFI_FILE_HANDLE      Handle,\r
+  OUT CHAR16                    **FullFileName\r
+  );\r
+\r
+/**\r
+  Function to read a single line (up to but not including the \n) from a file.\r
+\r
+  If the position upon start is 0, then the Ascii Boolean will be set.  This should be\r
+  maintained and not changed for all operations with the same file.\r
+\r
+  @param[in]       Handle        FileHandle to read from.\r
+  @param[in, out]  Buffer        The pointer to buffer to read into.\r
+  @param[in, out]  Size          The pointer to number of bytes in Buffer.\r
+  @param[in]       Truncate      If the buffer is large enough, this has no effect.\r
+                                 If the buffer is is too small and Truncate is TRUE,\r
+                                 the line will be truncated.\r
+                                 If the buffer is is too small and Truncate is FALSE,\r
+                                 then no read will occur.\r
+\r
+  @param[in, out]  Ascii         Boolean value for indicating whether the file is\r
+                                 Ascii (TRUE) or UCS2 (FALSE).\r
+\r
+  @retval EFI_SUCCESS           The operation was successful.  The line is stored in\r
+                                Buffer.\r
+  @retval EFI_INVALID_PARAMETER Handle was NULL.\r
+  @retval EFI_INVALID_PARAMETER Size was NULL.\r
+  @retval EFI_BUFFER_TOO_SMALL  Size was not large enough to store the line.\r
+                                Size was updated to the minimum space required.\r
+  @sa FileHandleRead\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+FileHandleReadLine(\r
+  IN EFI_FILE_HANDLE            Handle,\r
+  IN OUT CHAR16                 *Buffer,\r
+  IN OUT UINTN                  *Size,\r
+  IN BOOLEAN                    Truncate,\r
+  IN OUT BOOLEAN                *Ascii\r
+  );\r
+\r
+/**\r
+  Function to read a single line from a file. The \n is not included in the returned\r
+  buffer.  The returned buffer must be callee freed.\r
+\r
+  If the position upon start is 0, then the Ascii Boolean will be set.  This should be\r
+  maintained and not changed for all operations with the same file.\r
+\r
+  @param[in]       Handle        FileHandle to read from.\r
+  @param[in, out]  Ascii         Boolean value for indicating whether the file is\r
+                                 Ascii (TRUE) or UCS2 (FALSE).\r
+\r
+  @return                       The line of text from the file.\r
+\r
+  @sa FileHandleReadLine\r
+**/\r
+CHAR16*\r
+EFIAPI\r
+FileHandleReturnLine(\r
+  IN EFI_FILE_HANDLE            Handle,\r
+  IN OUT BOOLEAN                *Ascii\r
+  );\r
+\r
+/**\r
+  Function to write a line of unicode text to a file.\r
+\r
+  If Handle is NULL, ASSERT.\r
+\r
+  @param[in]     Handle         FileHandle to write to.\r
+  @param[in]     Buffer         Buffer to write, if NULL the function will\r
+                                take no action and return EFI_SUCCESS.\r
+\r
+  @retval  EFI_SUCCESS          The data was written.\r
+  @retval  other                Failure.\r
+\r
+  @sa FileHandleWrite\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+FileHandleWriteLine(\r
+  IN EFI_FILE_HANDLE Handle,\r
+  IN CHAR16          *Buffer\r
+  );\r
+\r
+/**\r
+  Function to take a formatted argument and print it to a file.\r
+\r
+  @param[in] Handle   The file handle for the file to write to.\r
+  @param[in] Format   The format argument (see printlib for the format specifier).\r
+  @param[in] ...      The variable arguments for the format.\r
+\r
+  @retval EFI_SUCCESS The operation was successful.\r
+  @retval other       A return value from FileHandleWriteLine.\r
+\r
+  @sa FileHandleWriteLine\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+FileHandlePrintLine(\r
+  IN EFI_FILE_HANDLE  Handle,\r
+  IN CONST CHAR16     *Format,\r
+  ...\r
+  );\r
+\r
+/**\r
+  Function to determine if a FILE_HANDLE is at the end of the file.\r
+\r
+  This will NOT work on directories.\r
+\r
+  If Handle is NULL, then ASSERT().\r
+\r
+  @param[in] Handle     The file handle.\r
+\r
+  @retval TRUE          The position is at the end of the file.\r
+  @retval FALSE         The position is not at the end of the file.\r
+**/\r
+BOOLEAN\r
+EFIAPI\r
+FileHandleEof(\r
+  IN EFI_FILE_HANDLE Handle\r
+  );\r
+\r
+#endif //_FILE_HANDLE_LIBRARY_HEADER_\r
+\r
index 6d03f941fda23e2d1a377fee95f72d6797ff4365..fc0cb9638baaf23496b4589b0c08207299a54358 100644 (file)
@@ -63,6 +63,7 @@
   LinkedList.c\r
   SafeString.c\r
   String.c\r
+  FilePaths.c\r
   BaseLibInternals.h\r
 \r
 [Sources.Ia32]\r
diff --git a/MdePkg/Library/BaseLib/FilePaths.c b/MdePkg/Library/BaseLib/FilePaths.c
new file mode 100644 (file)
index 0000000..b7ff480
--- /dev/null
@@ -0,0 +1,126 @@
+/** @file\r
+  Defines file-path manipulation functions.\r
+\r
+  Copyright (c) 2011 - 2014, Intel Corporation. All rights reserved.<BR>\r
+  This program and the accompanying materials\r
+  are licensed and made available under the terms and conditions of the BSD License\r
+  which accompanies this distribution.  The full text of the license may be found at\r
+  http://opensource.org/licenses/bsd-license.php.\r
+\r
+  THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
+  WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
+**/\r
+#include  <Uefi/UefiBaseType.h>\r
+#include  <Library/BaseMemoryLib.h>\r
+#include  <Library/BaseLib.h>\r
+#include  <Protocol/SimpleTextIn.h>\r
+\r
+/**\r
+  Removes the last directory or file entry in a path by changing the last\r
+  L'\' to a CHAR_NULL.\r
+\r
+  @param[in,out] Path     A pointer to the path to modify.\r
+\r
+  @retval FALSE     Nothing was found to remove.\r
+  @retval TRUE      A directory or file was removed.\r
+**/\r
+BOOLEAN\r
+EFIAPI\r
+PathRemoveLastItem(\r
+  IN OUT CHAR16 *Path\r
+  )\r
+{\r
+  CHAR16        *Walker;\r
+  CHAR16        *LastSlash;\r
+  //\r
+  // get directory name from path... ('chop' off extra)\r
+  //\r
+  for ( Walker = Path, LastSlash = NULL\r
+      ; Walker != NULL && *Walker != CHAR_NULL\r
+      ; Walker++\r
+     ){\r
+    if (*Walker == L'\\' && *(Walker + 1) != CHAR_NULL) {\r
+      LastSlash = Walker+1;\r
+    }\r
+  }\r
+  if (LastSlash != NULL) {\r
+    *LastSlash = CHAR_NULL;\r
+    return (TRUE);\r
+  }\r
+  return (FALSE);\r
+}\r
+\r
+/**\r
+  Function to clean up paths.\r
+\r
+  - Single periods in the path are removed.\r
+  - Double periods in the path are removed along with a single parent directory.\r
+  - Forward slashes L'/' are converted to backward slashes L'\'.\r
+\r
+  This will be done inline and the existing buffer may be larger than required\r
+  upon completion.\r
+\r
+  @param[in] Path       The pointer to the string containing the path.\r
+\r
+  @return       Returns Path, otherwise returns NULL to indicate that an error has occured.\r
+**/\r
+CHAR16*\r
+EFIAPI\r
+PathCleanUpDirectories(\r
+  IN CHAR16 *Path\r
+  )\r
+{\r
+  CHAR16  *TempString;\r
+  UINTN   TempSize;\r
+\r
+  if (Path==NULL) {\r
+    return(NULL);\r
+  }\r
+  //\r
+  // Fix up the '/' vs '\'\r
+  //\r
+  for (TempString = Path ; TempString != NULL && *TempString != CHAR_NULL ; TempString++) {\r
+    if (*TempString == L'/') {\r
+      *TempString = L'\\';\r
+    }\r
+  }\r
+  //\r
+  // Fix up the ..\r
+  //\r
+  while ((TempString = StrStr(Path, L"\\..\\")) != NULL) {\r
+    *TempString = CHAR_NULL;\r
+    TempString  += 4;\r
+    PathRemoveLastItem(Path);\r
+    TempSize = StrSize(TempString);\r
+    CopyMem(Path+StrLen(Path), TempString, TempSize);\r
+  }\r
+  if ((TempString = StrStr(Path, L"\\..")) != NULL && *(TempString + 3) == CHAR_NULL) {\r
+    *TempString = CHAR_NULL;\r
+    PathRemoveLastItem(Path);\r
+  }\r
+  //\r
+  // Fix up the .\r
+  //\r
+  while ((TempString = StrStr(Path, L"\\.\\")) != NULL) {\r
+    *TempString = CHAR_NULL;\r
+    TempString  += 2;\r
+    TempSize = StrSize(TempString);\r
+    CopyMem(Path+StrLen(Path), TempString, TempSize);\r
+  }\r
+  if ((TempString = StrStr(Path, L"\\.")) != NULL && *(TempString + 2) == CHAR_NULL) {\r
+    *(TempString + 1) = CHAR_NULL;\r
+  }\r
+\r
+  while ((TempString = StrStr(Path, L"\\\\")) != NULL) {\r
+    *TempString = CHAR_NULL;\r
+    TempString  += 1;\r
+    TempSize = StrSize(TempString);\r
+    CopyMem(Path+StrLen(Path), TempString, TempSize);\r
+  }\r
+  if ((TempString = StrStr(Path, L"\\\\")) != NULL && *(TempString + 1) == CHAR_NULL) {\r
+    *(TempString) = CHAR_NULL;\r
+  }\r
+\r
+  return (Path);\r
+}\r
+\r
diff --git a/MdePkg/Library/UefiFileHandleLib/UefiFileHandleLib.c b/MdePkg/Library/UefiFileHandleLib/UefiFileHandleLib.c
new file mode 100644 (file)
index 0000000..be66c57
--- /dev/null
@@ -0,0 +1,1155 @@
+/** @file\r
+  Provides interface to EFI_FILE_HANDLE functionality.\r
+\r
+  Copyright (c) 2006 - 2014, Intel Corporation. All rights reserved. <BR>\r
+  This program and the accompanying materials\r
+  are licensed and made available under the terms and conditions of the BSD License\r
+  which accompanies this distribution.  The full text of the license may be found at\r
+  http://opensource.org/licenses/bsd-license.php\r
+\r
+  THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
+  WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
+\r
+**/\r
+\r
+#include <Uefi.h>\r
+\r
+#include <Protocol/SimpleFileSystem.h>\r
+#include <Protocol/UnicodeCollation.h>\r
+\r
+#include <Guid/FileInfo.h>\r
+\r
+#include <Library/DebugLib.h>\r
+#include <Library/MemoryAllocationLib.h>\r
+#include <Library/BaseLib.h>\r
+#include <Library/BaseMemoryLib.h>\r
+#include <Library/FileHandleLib.h>\r
+#include <Library/PcdLib.h>\r
+#include <Library/PrintLib.h>\r
+\r
+CONST UINT16 gUnicodeFileTag = EFI_UNICODE_BYTE_ORDER_MARK;\r
+\r
+#define MAX_FILE_NAME_LEN 522 // (20 * (6+5+2))+1) unicode characters from EFI FAT spec (doubled for bytes)\r
+#define FIND_XXXXX_FILE_BUFFER_SIZE (SIZE_OF_EFI_FILE_INFO + MAX_FILE_NAME_LEN)\r
+\r
+/**\r
+  This function will retrieve the information about the file for the handle\r
+  specified and store it in allocated pool memory.\r
+\r
+  This function allocates a buffer to store the file's information. It is the\r
+  caller's responsibility to free the buffer\r
+\r
+  @param  FileHandle  The file handle of the file for which information is\r
+  being requested.\r
+\r
+  @retval NULL information could not be retrieved.\r
+\r
+  @return the information about the file\r
+**/\r
+EFI_FILE_INFO*\r
+EFIAPI\r
+FileHandleGetInfo (\r
+  IN EFI_FILE_HANDLE            FileHandle\r
+  )\r
+{\r
+  EFI_FILE_INFO   *FileInfo;\r
+  UINTN           FileInfoSize;\r
+  EFI_STATUS      Status;\r
+\r
+  if (FileHandle == NULL) {\r
+    return (NULL);\r
+  }\r
+\r
+  //\r
+  // Get the required size to allocate\r
+  //\r
+  FileInfoSize = 0;\r
+  FileInfo = NULL;\r
+  Status = FileHandle->GetInfo(FileHandle,\r
+                               &gEfiFileInfoGuid,\r
+                               &FileInfoSize,\r
+                               NULL);\r
+  if (Status == EFI_BUFFER_TOO_SMALL){\r
+    //\r
+    // error is expected.  getting size to allocate\r
+    //\r
+    FileInfo = AllocateZeroPool(FileInfoSize);\r
+    //\r
+    // now get the information\r
+    //\r
+    Status = FileHandle->GetInfo(FileHandle,\r
+                                 &gEfiFileInfoGuid,\r
+                                 &FileInfoSize,\r
+                                 FileInfo);\r
+    //\r
+    // if we got an error free the memory and return NULL\r
+    //\r
+    if (EFI_ERROR(Status) && (FileInfo != NULL)) {\r
+      FreePool(FileInfo);\r
+      FileInfo = NULL;\r
+    }\r
+  }\r
+  return (FileInfo);\r
+}\r
+\r
+/**\r
+  This function sets the information about the file for the opened handle\r
+  specified.\r
+\r
+  @param[in]  FileHandle        The file handle of the file for which information\r
+                                is being set.\r
+\r
+  @param[in]  FileInfo          The information to set.\r
+\r
+  @retval EFI_SUCCESS           The information was set.\r
+  @retval EFI_INVALID_PARAMETER A parameter was out of range or invalid.\r
+  @retval EFI_UNSUPPORTED       The FileHandle does not support FileInfo.\r
+  @retval EFI_NO_MEDIA          The device has no medium.\r
+  @retval EFI_DEVICE_ERROR      The device reported an error.\r
+  @retval EFI_VOLUME_CORRUPTED  The file system structures are corrupted.\r
+  @retval EFI_WRITE_PROTECTED   The file or medium is write protected.\r
+  @retval EFI_ACCESS_DENIED     The file was opened read only.\r
+  @retval EFI_VOLUME_FULL       The volume is full.\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+FileHandleSetInfo (\r
+  IN EFI_FILE_HANDLE            FileHandle,\r
+  IN CONST EFI_FILE_INFO        *FileInfo\r
+  )\r
+{\r
+\r
+  if (FileHandle == NULL || FileInfo == NULL) {\r
+    return (EFI_INVALID_PARAMETER);\r
+  }\r
+\r
+  //\r
+  // Set the info\r
+  //\r
+  return (FileHandle->SetInfo(FileHandle,\r
+                              &gEfiFileInfoGuid,\r
+                              (UINTN)FileInfo->Size,\r
+                              (EFI_FILE_INFO*)FileInfo));\r
+}\r
+\r
+/**\r
+  This function reads information from an opened file.\r
+\r
+  If FileHandle is not a directory, the function reads the requested number of\r
+  bytes from the file at the file's current position and returns them in Buffer.\r
+  If the read goes beyond the end of the file, the read length is truncated to the\r
+  end of the file. The file's current position is increased by the number of bytes\r
+  returned.  If FileHandle is a directory, the function reads the directory entry\r
+  at the file's current position and returns the entry in Buffer. If the Buffer\r
+  is not large enough to hold the current directory entry, then\r
+  EFI_BUFFER_TOO_SMALL is returned and the current file position is not updated.\r
+  BufferSize is set to be the size of the buffer needed to read the entry. On\r
+  success, the current position is updated to the next directory entry. If there\r
+  are no more directory entries, the read returns a zero-length buffer.\r
+  EFI_FILE_INFO is the structure returned as the directory entry.\r
+\r
+  @param FileHandle             the opened file handle\r
+  @param BufferSize             on input the size of buffer in bytes.  on return\r
+                                the number of bytes written.\r
+  @param Buffer                 the buffer to put read data into.\r
+\r
+  @retval EFI_SUCCESS           Data was read.\r
+  @retval EFI_NO_MEDIA          The device has no media.\r
+  @retval EFI_DEVICE_ERROR      The device reported an error.\r
+  @retval EFI_VOLUME_CORRUPTED  The file system structures are corrupted.\r
+  @retval EFI_BUFFER_TO_SMALL   Buffer is too small. ReadSize contains required\r
+                                size.\r
+\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+FileHandleRead(\r
+  IN EFI_FILE_HANDLE            FileHandle,\r
+  IN OUT UINTN                  *BufferSize,\r
+  OUT VOID                      *Buffer\r
+  )\r
+{\r
+  if (FileHandle == NULL) {\r
+    return (EFI_INVALID_PARAMETER);\r
+  }\r
+\r
+  //\r
+  // Perform the read based on EFI_FILE_PROTOCOL\r
+  //\r
+  return (FileHandle->Read(FileHandle, BufferSize, Buffer));\r
+}\r
+\r
+\r
+/**\r
+  Write data to a file.\r
+\r
+  This function writes the specified number of bytes to the file at the current\r
+  file position. The current file position is advanced the actual number of bytes\r
+  written, which is returned in BufferSize. Partial writes only occur when there\r
+  has been a data error during the write attempt (such as "volume space full").\r
+  The file is automatically grown to hold the data if required. Direct writes to\r
+  opened directories are not supported.\r
+\r
+  @param FileHandle           The opened file for writing\r
+  @param BufferSize           on input the number of bytes in Buffer.  On output\r
+                              the number of bytes written.\r
+  @param Buffer               the buffer containing data to write is stored.\r
+\r
+ @retval EFI_SUCCESS          Data was written.\r
+ @retval EFI_UNSUPPORTED      Writes to an open directory are not supported.\r
+ @retval EFI_NO_MEDIA         The device has no media.\r
+ @retval EFI_DEVICE_ERROR     The device reported an error.\r
+ @retval EFI_VOLUME_CORRUPTED The file system structures are corrupted.\r
+ @retval EFI_WRITE_PROTECTED  The device is write-protected.\r
+ @retval EFI_ACCESS_DENIED    The file was open for read only.\r
+ @retval EFI_VOLUME_FULL      The volume is full.\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+FileHandleWrite(\r
+  IN EFI_FILE_HANDLE            FileHandle,\r
+  IN OUT UINTN                  *BufferSize,\r
+  IN VOID                       *Buffer\r
+  )\r
+{\r
+  if (FileHandle == NULL) {\r
+    return (EFI_INVALID_PARAMETER);\r
+  }\r
+\r
+  //\r
+  // Perform the write based on EFI_FILE_PROTOCOL\r
+  //\r
+  return (FileHandle->Write(FileHandle, BufferSize, Buffer));\r
+}\r
+\r
+/**\r
+  Close an open file handle.\r
+\r
+  This function closes a specified file handle. All "dirty" cached file data is\r
+  flushed to the device, and the file is closed. In all cases the handle is\r
+  closed.\r
+\r
+@param FileHandle               the file handle to close.\r
+\r
+@retval EFI_SUCCESS             the file handle was closed sucessfully.\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+FileHandleClose (\r
+  IN EFI_FILE_HANDLE            FileHandle\r
+  )\r
+{\r
+  EFI_STATUS Status;\r
+\r
+  if (FileHandle == NULL) {\r
+    return (EFI_INVALID_PARAMETER);\r
+  }\r
+\r
+  //\r
+  // Perform the Close based on EFI_FILE_PROTOCOL\r
+  //\r
+  Status = FileHandle->Close(FileHandle);\r
+  return Status;\r
+}\r
+\r
+/**\r
+  Delete a file and close the handle\r
+\r
+  This function closes and deletes a file. In all cases the file handle is closed.\r
+  If the file cannot be deleted, the warning code EFI_WARN_DELETE_FAILURE is\r
+  returned, but the handle is still closed.\r
+\r
+  @param FileHandle             the file handle to delete\r
+\r
+  @retval EFI_SUCCESS           the file was closed sucessfully\r
+  @retval EFI_WARN_DELETE_FAILURE the handle was closed, but the file was not\r
+                                deleted\r
+  @retval INVALID_PARAMETER     One of the parameters has an invalid value.\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+FileHandleDelete (\r
+  IN EFI_FILE_HANDLE    FileHandle\r
+  )\r
+{\r
+  EFI_STATUS Status;\r
+\r
+  if (FileHandle == NULL) {\r
+    return (EFI_INVALID_PARAMETER);\r
+  }\r
+\r
+  //\r
+  // Perform the Delete based on EFI_FILE_PROTOCOL\r
+  //\r
+  Status = FileHandle->Delete(FileHandle);\r
+  return Status;\r
+}\r
+\r
+/**\r
+  Set the current position in a file.\r
+\r
+  This function sets the current file position for the handle to the position\r
+  supplied. With the exception of seeking to position 0xFFFFFFFFFFFFFFFF, only\r
+  absolute positioning is supported, and seeking past the end of the file is\r
+  allowed (a subsequent write would grow the file). Seeking to position\r
+  0xFFFFFFFFFFFFFFFF causes the current position to be set to the end of the file.\r
+  If FileHandle is a directory, the only position that may be set is zero. This\r
+  has the effect of starting the read process of the directory entries over.\r
+\r
+  @param FileHandle             The file handle on which the position is being set\r
+  @param Position               Byte position from begining of file\r
+\r
+  @retval EFI_SUCCESS           Operation completed sucessfully.\r
+  @retval EFI_UNSUPPORTED       the seek request for non-zero is not valid on\r
+                                directories.\r
+  @retval INVALID_PARAMETER     One of the parameters has an invalid value.\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+FileHandleSetPosition (\r
+  IN EFI_FILE_HANDLE    FileHandle,\r
+  IN UINT64             Position\r
+  )\r
+{\r
+  if (FileHandle == NULL) {\r
+    return (EFI_INVALID_PARAMETER);\r
+  }\r
+\r
+  //\r
+  // Perform the SetPosition based on EFI_FILE_PROTOCOL\r
+  //\r
+  return (FileHandle->SetPosition(FileHandle, Position));\r
+}\r
+\r
+/**\r
+  Gets a file's current position\r
+\r
+  This function retrieves the current file position for the file handle. For\r
+  directories, the current file position has no meaning outside of the file\r
+  system driver and as such the operation is not supported. An error is returned\r
+  if FileHandle is a directory.\r
+\r
+  @param FileHandle             The open file handle on which to get the position.\r
+  @param Position               Byte position from begining of file.\r
+\r
+  @retval EFI_SUCCESS           the operation completed sucessfully.\r
+  @retval INVALID_PARAMETER     One of the parameters has an invalid value.\r
+  @retval EFI_UNSUPPORTED       the request is not valid on directories.\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+FileHandleGetPosition (\r
+  IN EFI_FILE_HANDLE            FileHandle,\r
+  OUT UINT64                    *Position\r
+  )\r
+{\r
+  if (Position == NULL || FileHandle == NULL) {\r
+    return (EFI_INVALID_PARAMETER);\r
+  }\r
+\r
+  //\r
+  // Perform the GetPosition based on EFI_FILE_PROTOCOL\r
+  //\r
+  return (FileHandle->GetPosition(FileHandle, Position));\r
+}\r
+/**\r
+  Flushes data on a file\r
+\r
+  This function flushes all modified data associated with a file to a device.\r
+\r
+  @param FileHandle             The file handle on which to flush data\r
+\r
+  @retval EFI_SUCCESS           The data was flushed.\r
+  @retval EFI_NO_MEDIA          The device has no media.\r
+  @retval EFI_DEVICE_ERROR      The device reported an error.\r
+  @retval EFI_VOLUME_CORRUPTED  The file system structures are corrupted.\r
+  @retval EFI_WRITE_PROTECTED   The file or medium is write protected.\r
+  @retval EFI_ACCESS_DENIED     The file was opened for read only.\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+FileHandleFlush (\r
+  IN EFI_FILE_HANDLE            FileHandle\r
+  )\r
+{\r
+  if (FileHandle == NULL) {\r
+    return (EFI_INVALID_PARAMETER);\r
+  }\r
+\r
+  //\r
+  // Perform the Flush based on EFI_FILE_PROTOCOL\r
+  //\r
+  return (FileHandle->Flush(FileHandle));\r
+}\r
+\r
+/**\r
+  function to determine if a given handle is a directory handle\r
+\r
+  if DirHandle is NULL then return error\r
+\r
+  open the file information on the DirHandle and verify that the Attribute\r
+  includes EFI_FILE_DIRECTORY bit set.\r
+\r
+  @param DirHandle              Handle to open file\r
+\r
+  @retval EFI_SUCCESS           DirHandle is a directory\r
+  @retval EFI_INVALID_PARAMETER DirHandle did not have EFI_FILE_INFO available\r
+  @retval EFI_NOT_FOUND         DirHandle is not a directory\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+FileHandleIsDirectory (\r
+  IN EFI_FILE_HANDLE            DirHandle\r
+  )\r
+{\r
+  EFI_FILE_INFO *DirInfo;\r
+\r
+  if (DirHandle == NULL) {\r
+    return (EFI_INVALID_PARAMETER);\r
+  }\r
+\r
+  //\r
+  // get the file information for DirHandle\r
+  //\r
+  DirInfo = FileHandleGetInfo (DirHandle);\r
+\r
+  //\r
+  // Parse DirInfo\r
+  //\r
+  if (DirInfo == NULL) {\r
+    //\r
+    // We got nothing...\r
+    //\r
+    return (EFI_INVALID_PARAMETER);\r
+  }\r
+  if ((DirInfo->Attribute & EFI_FILE_DIRECTORY) == 0) {\r
+    //\r
+    // Attributes say this is not a directory\r
+    //\r
+    FreePool (DirInfo);\r
+    return (EFI_NOT_FOUND);\r
+  }\r
+  //\r
+  // all good...\r
+  //\r
+  FreePool (DirInfo);\r
+  return (EFI_SUCCESS);\r
+}\r
+\r
+/** Retrieve first entry from a directory.\r
+\r
+  This function takes an open directory handle and gets information from the\r
+  first entry in the directory.  A buffer is allocated to contain\r
+  the information and a pointer to the buffer is returned in *Buffer.  The\r
+  caller can use FileHandleFindNextFile() to get subsequent directory entries.\r
+\r
+  The buffer will be freed by FileHandleFindNextFile() when the last directory\r
+  entry is read.  Otherwise, the caller must free the buffer, using FreePool,\r
+  when finished with it.\r
+\r
+  @param[in]  DirHandle         The file handle of the directory to search.\r
+  @param[out] Buffer            The pointer to pointer to buffer for file's information.\r
+\r
+  @retval EFI_SUCCESS           Found the first file.\r
+  @retval EFI_NOT_FOUND         Cannot find the directory.\r
+  @retval EFI_NO_MEDIA          The device has no media.\r
+  @retval EFI_DEVICE_ERROR      The device reported an error.\r
+  @retval EFI_VOLUME_CORRUPTED  The file system structures are corrupted.\r
+  @return Others                status of FileHandleGetInfo, FileHandleSetPosition,\r
+                                or FileHandleRead\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+FileHandleFindFirstFile (\r
+  IN EFI_FILE_HANDLE            DirHandle,\r
+  OUT EFI_FILE_INFO             **Buffer\r
+  )\r
+{\r
+  EFI_STATUS    Status;\r
+  UINTN         BufferSize;\r
+\r
+  if (Buffer == NULL || DirHandle == NULL) {\r
+    return (EFI_INVALID_PARAMETER);\r
+  }\r
+\r
+  //\r
+  // verify that DirHandle is a directory\r
+  //\r
+  Status = FileHandleIsDirectory(DirHandle);\r
+  if (EFI_ERROR(Status)) {\r
+    return (Status);\r
+  }\r
+\r
+  //\r
+  // Allocate a buffer sized to struct size + enough for the string at the end\r
+  //\r
+  BufferSize = FIND_XXXXX_FILE_BUFFER_SIZE;\r
+  *Buffer = AllocateZeroPool(BufferSize);\r
+  if (*Buffer == NULL){\r
+    return (EFI_OUT_OF_RESOURCES);\r
+  }\r
+\r
+  //\r
+  // reset to the begining of the directory\r
+  //\r
+  Status = FileHandleSetPosition(DirHandle, 0);\r
+  if (EFI_ERROR(Status)) {\r
+    FreePool(*Buffer);\r
+    *Buffer = NULL;\r
+    return (Status);\r
+  }\r
+\r
+  //\r
+  // read in the info about the first file\r
+  //\r
+  Status = FileHandleRead (DirHandle, &BufferSize, *Buffer);\r
+  ASSERT(Status != EFI_BUFFER_TOO_SMALL);\r
+  if (EFI_ERROR(Status) || BufferSize == 0) {\r
+    FreePool(*Buffer);\r
+    *Buffer = NULL;\r
+    if (BufferSize == 0) {\r
+      return (EFI_NOT_FOUND);\r
+    }\r
+    return (Status);\r
+  }\r
+  return (EFI_SUCCESS);\r
+}\r
+\r
+/** Retrieve next entries from a directory.\r
+\r
+  To use this function, the caller must first call the FileHandleFindFirstFile()\r
+  function to get the first directory entry.  Subsequent directory entries are\r
+  retrieved by using the FileHandleFindNextFile() function.  This function can\r
+  be called several times to get each entry from the directory.  If the call of\r
+  FileHandleFindNextFile() retrieved the last directory entry, the next call of\r
+  this function will set *NoFile to TRUE and free the buffer.\r
+\r
+  @param[in]  DirHandle         The file handle of the directory.\r
+  @param[out] Buffer            The pointer to buffer for file's information.\r
+  @param[out] NoFile            The pointer to boolean when last file is found.\r
+\r
+  @retval EFI_SUCCESS           Found the next file, or reached last file\r
+  @retval EFI_NO_MEDIA          The device has no media.\r
+  @retval EFI_DEVICE_ERROR      The device reported an error.\r
+  @retval EFI_VOLUME_CORRUPTED  The file system structures are corrupted.\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+FileHandleFindNextFile(\r
+  IN EFI_FILE_HANDLE          DirHandle,\r
+  OUT EFI_FILE_INFO          *Buffer,\r
+  OUT BOOLEAN                *NoFile\r
+  )\r
+{\r
+  EFI_STATUS    Status;\r
+  UINTN         BufferSize;\r
+\r
+  if (DirHandle == NULL || Buffer == NULL || NoFile == NULL) {\r
+    return (EFI_INVALID_PARAMETER);\r
+  }\r
+\r
+  //\r
+  // This BufferSize MUST stay equal to the originally allocated one in GetFirstFile\r
+  //\r
+  BufferSize = FIND_XXXXX_FILE_BUFFER_SIZE;\r
+\r
+  //\r
+  // read in the info about the next file\r
+  //\r
+  Status = FileHandleRead (DirHandle, &BufferSize, Buffer);\r
+  ASSERT(Status != EFI_BUFFER_TOO_SMALL);\r
+  if (EFI_ERROR(Status)) {\r
+    return (Status);\r
+  }\r
+\r
+  //\r
+  // If we read 0 bytes (but did not have erros) we already read in the last file.\r
+  //\r
+  if (BufferSize == 0) {\r
+    FreePool(Buffer);\r
+    *NoFile = TRUE;\r
+  }\r
+\r
+  return (EFI_SUCCESS);\r
+}\r
+\r
+/**\r
+  Retrieve the size of a file.\r
+\r
+  if FileHandle is NULL then return error\r
+  if Size is NULL then return error\r
+\r
+  This function extracts the file size info from the FileHandle's EFI_FILE_INFO\r
+  data.\r
+\r
+  @param FileHandle             file handle from which size is retrieved\r
+  @param Size                   pointer to size\r
+\r
+  @retval EFI_SUCCESS           operation was completed sucessfully\r
+  @retval EFI_DEVICE_ERROR      cannot access the file\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+FileHandleGetSize (\r
+  IN EFI_FILE_HANDLE            FileHandle,\r
+  OUT UINT64                    *Size\r
+  )\r
+{\r
+  EFI_FILE_INFO                 *FileInfo;\r
+\r
+  if (FileHandle == NULL || Size == NULL) {\r
+    return (EFI_INVALID_PARAMETER);\r
+  }\r
+\r
+  //\r
+  // get the FileInfo structure\r
+  //\r
+  FileInfo = FileHandleGetInfo(FileHandle);\r
+  if (FileInfo == NULL) {\r
+    return (EFI_DEVICE_ERROR);\r
+  }\r
+\r
+  //\r
+  // Assign the Size pointer to the correct value\r
+  //\r
+  *Size = FileInfo->FileSize;\r
+\r
+  //\r
+  // free the FileInfo memory\r
+  //\r
+  FreePool(FileInfo);\r
+\r
+  return (EFI_SUCCESS);\r
+}\r
+\r
+/**\r
+  Set the size of a file.\r
+\r
+  If FileHandle is NULL then return error.\r
+\r
+  This function changes the file size info from the FileHandle's EFI_FILE_INFO\r
+  data.\r
+\r
+  @param FileHandle             File handle whose size is to be changed.\r
+  @param Size                   New size.\r
+\r
+  @retval EFI_SUCCESS           operation was completed sucessfully.\r
+  @retval EFI_DEVICE_ERROR      cannot access the file.\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+FileHandleSetSize (\r
+  IN EFI_FILE_HANDLE            FileHandle,\r
+  IN UINT64                     Size\r
+  )\r
+{\r
+  EFI_FILE_INFO                 *FileInfo;\r
+  EFI_STATUS                    Status;\r
+\r
+  if (FileHandle == NULL) {\r
+    return (EFI_INVALID_PARAMETER);\r
+  }\r
+\r
+  //\r
+  // get the FileInfo structure\r
+  //\r
+  FileInfo = FileHandleGetInfo(FileHandle);\r
+  if (FileInfo == NULL) {\r
+    return (EFI_DEVICE_ERROR);\r
+  }\r
+\r
+  //\r
+  // Assign the FileSize pointer to the new value\r
+  //\r
+  FileInfo->FileSize = Size;\r
+\r
+  Status = FileHandleSetInfo(FileHandle, FileInfo);\r
+  //\r
+  // free the FileInfo memory\r
+  //\r
+  FreePool(FileInfo);\r
+\r
+  return (Status);\r
+}\r
+\r
+/**\r
+  Safely append (on the left) with automatic string resizing given length of Destination and\r
+  desired length of copy from Source.\r
+\r
+  append the first D characters of Source to the end of Destination, where D is\r
+  the lesser of Count and the StrLen() of Source. If appending those D characters\r
+  will fit within Destination (whose Size is given as CurrentSize) and\r
+  still leave room for a NULL terminator, then those characters are appended,\r
+  starting at the original terminating NULL of Destination, and a new terminating\r
+  NULL is appended.\r
+\r
+  If appending D characters onto Destination will result in a overflow of the size\r
+  given in CurrentSize the string will be grown such that the copy can be performed\r
+  and CurrentSize will be updated to the new size.\r
+\r
+  If Source is NULL, there is nothing to append, just return the current buffer in\r
+  Destination.\r
+\r
+  if Destination is NULL, then return error\r
+  if Destination's current length (including NULL terminator) is already more then\r
+  CurrentSize, then ASSERT()\r
+\r
+  @param[in, out] Destination   The String to append onto\r
+  @param[in, out] CurrentSize   on call the number of bytes in Destination.  On\r
+                                return possibly the new size (still in bytes).  if NULL\r
+                                then allocate whatever is needed.\r
+  @param[in]      Source        The String to append from\r
+  @param[in]      Count         Maximum number of characters to append.  if 0 then\r
+                                all are appended.\r
+\r
+  @return Destination           return the resultant string.\r
+**/\r
+CHAR16*\r
+EFIAPI\r
+StrnCatGrowLeft (\r
+  IN OUT CHAR16           **Destination,\r
+  IN OUT UINTN            *CurrentSize,\r
+  IN     CONST CHAR16     *Source,\r
+  IN     UINTN            Count\r
+  )\r
+{\r
+  UINTN DestinationStartSize;\r
+  UINTN NewSize;\r
+  UINTN CopySize;\r
+\r
+  if (Destination == NULL) {\r
+    return (NULL);\r
+  }\r
+\r
+  //\r
+  // If there's nothing to do then just return Destination\r
+  //\r
+  if (Source == NULL) {\r
+    return (*Destination);\r
+  }\r
+\r
+  //\r
+  // allow for NULL pointers address as Destination\r
+  //\r
+  if (*Destination != NULL) {\r
+    ASSERT(CurrentSize != 0);\r
+    DestinationStartSize = StrSize(*Destination);\r
+    ASSERT(DestinationStartSize <= *CurrentSize);\r
+  } else {\r
+    DestinationStartSize = 0;\r
+//    ASSERT(*CurrentSize == 0);\r
+  }\r
+\r
+  //\r
+  // Append all of Source?\r
+  //\r
+  if (Count == 0) {\r
+    Count = StrSize(Source);\r
+  }\r
+\r
+  //\r
+  // Test and grow if required\r
+  //\r
+  if (CurrentSize != NULL) {\r
+    NewSize = *CurrentSize;\r
+    while (NewSize < (DestinationStartSize + Count)) {\r
+      NewSize += 2 * Count;\r
+    }\r
+    *Destination = ReallocatePool(*CurrentSize, NewSize, *Destination);\r
+    *CurrentSize = NewSize;\r
+  } else {\r
+    *Destination = AllocateZeroPool(Count+sizeof(CHAR16));\r
+  }\r
+  if (*Destination == NULL) {\r
+    return NULL;\r
+  }\r
+\r
+  CopySize = StrSize(*Destination);\r
+  CopyMem((*Destination)+((Count-2)/sizeof(CHAR16)), *Destination, CopySize);\r
+  CopyMem(*Destination, Source, Count-2);\r
+  return (*Destination);\r
+}\r
+\r
+/**\r
+  Function to get a full filename given a EFI_FILE_HANDLE somewhere lower on the\r
+  directory 'stack'.\r
+\r
+  if Handle is NULL, return EFI_INVALID_PARAMETER\r
+\r
+  @param[in] Handle             Handle to the Directory or File to create path to.\r
+  @param[out] FullFileName      pointer to pointer to generated full file name.  It\r
+                                is the responsibility of the caller to free this memory\r
+                                with a call to FreePool().\r
+  @retval EFI_SUCCESS           the operation was sucessful and the FullFileName is valid.\r
+  @retval EFI_INVALID_PARAMETER Handle was NULL.\r
+  @retval EFI_INVALID_PARAMETER FullFileName was NULL.\r
+  @retval EFI_OUT_OF_RESOURCES  a memory allocation failed.\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+FileHandleGetFileName (\r
+  IN CONST EFI_FILE_HANDLE      Handle,\r
+  OUT CHAR16                    **FullFileName\r
+  )\r
+{\r
+  EFI_STATUS      Status;\r
+  UINTN           Size;\r
+  EFI_FILE_HANDLE CurrentHandle;\r
+  EFI_FILE_HANDLE NextHigherHandle;\r
+  EFI_FILE_INFO   *FileInfo;\r
+\r
+  Size = 0;\r
+\r
+  //\r
+  // Check our parameters\r
+  //\r
+  if (FullFileName == NULL || Handle == NULL) {\r
+    return (EFI_INVALID_PARAMETER);\r
+  }\r
+\r
+  *FullFileName = NULL;\r
+  CurrentHandle = NULL;\r
+\r
+  Status = Handle->Open(Handle, &CurrentHandle, L".", EFI_FILE_MODE_READ, 0);\r
+  if (!EFI_ERROR(Status)) {\r
+    //\r
+    // Reverse out the current directory on the device\r
+    //\r
+    for (;;) {\r
+      FileInfo = FileHandleGetInfo(CurrentHandle);\r
+      if (FileInfo == NULL) {\r
+        Status = EFI_OUT_OF_RESOURCES;\r
+        break;\r
+      } else {\r
+        //\r
+        // We got info... do we have a name? if yes preceed the current path with it...\r
+        //\r
+        if (StrLen (FileInfo->FileName) == 0) {\r
+          if (*FullFileName == NULL) {\r
+            ASSERT((*FullFileName == NULL && Size == 0) || (*FullFileName != NULL));\r
+            *FullFileName = StrnCatGrowLeft(FullFileName, &Size, L"\\", 0);\r
+          }\r
+          FreePool(FileInfo);\r
+          break;\r
+        } else {\r
+          if (*FullFileName == NULL) {\r
+            ASSERT((*FullFileName == NULL && Size == 0) || (*FullFileName != NULL));\r
+            *FullFileName = StrnCatGrowLeft(FullFileName, &Size, L"\\", 0);\r
+          }\r
+          ASSERT((*FullFileName == NULL && Size == 0) || (*FullFileName != NULL));\r
+          *FullFileName = StrnCatGrowLeft(FullFileName, &Size, FileInfo->FileName, 0);\r
+          *FullFileName = StrnCatGrowLeft(FullFileName, &Size, L"\\", 0);\r
+          FreePool(FileInfo);\r
+        }\r
+      }\r
+      //\r
+      // Move to the parent directory\r
+      //\r
+      Status = CurrentHandle->Open (CurrentHandle, &NextHigherHandle, L"..", EFI_FILE_MODE_READ, 0);\r
+      if (EFI_ERROR (Status)) {\r
+        break;\r
+      }\r
+\r
+      FileHandleClose(CurrentHandle);\r
+      CurrentHandle = NextHigherHandle;\r
+    }\r
+  } else if (Status == EFI_NOT_FOUND) {\r
+    Status = EFI_SUCCESS;\r
+    ASSERT((*FullFileName == NULL && Size == 0) || (*FullFileName != NULL));\r
+    *FullFileName = StrnCatGrowLeft(FullFileName, &Size, L"\\", 0);\r
+  }\r
+\r
+  if (CurrentHandle != NULL) {\r
+    CurrentHandle->Close (CurrentHandle);\r
+  }\r
+\r
+  if (EFI_ERROR(Status) && *FullFileName != NULL) {\r
+    FreePool(*FullFileName);\r
+  }\r
+\r
+  return (Status);\r
+}\r
+\r
+/**\r
+  Function to read a single line from a file. The \n is not included in the returned\r
+  buffer.  The returned buffer must be callee freed.\r
+\r
+  If the position upon start is 0, then the Ascii Boolean will be set.  This should be\r
+  maintained and not changed for all operations with the same file.\r
+\r
+  @param[in]       Handle        FileHandle to read from.\r
+  @param[in, out]  Ascii         Boolean value for indicating whether the file is Ascii (TRUE) or UCS2 (FALSE);\r
+\r
+  @return                       The line of text from the file.\r
+\r
+  @sa FileHandleReadLine\r
+**/\r
+CHAR16*\r
+EFIAPI\r
+FileHandleReturnLine(\r
+  IN EFI_FILE_HANDLE            Handle,\r
+  IN OUT BOOLEAN                *Ascii\r
+  )\r
+{\r
+  CHAR16          *RetVal;\r
+  UINTN           Size;\r
+  EFI_STATUS      Status;\r
+\r
+  Size = 0;\r
+  RetVal = NULL;\r
+\r
+  Status = FileHandleReadLine(Handle, RetVal, &Size, FALSE, Ascii);\r
+  if (Status == EFI_BUFFER_TOO_SMALL) {\r
+    RetVal = AllocateZeroPool(Size);\r
+    Status = FileHandleReadLine(Handle, RetVal, &Size, FALSE, Ascii);\r
+  }\r
+  ASSERT_EFI_ERROR(Status);\r
+  if (EFI_ERROR(Status) && (RetVal != NULL)) {\r
+    FreePool(RetVal);\r
+    RetVal = NULL;\r
+  }\r
+  return (RetVal);\r
+}\r
+\r
+/**\r
+  Function to read a single line (up to but not including the \n) from a EFI_FILE_HANDLE.\r
+\r
+  If the position upon start is 0, then the Ascii Boolean will be set.  This should be\r
+  maintained and not changed for all operations with the same file.\r
+\r
+  @param[in]       Handle        FileHandle to read from\r
+  @param[in, out]  Buffer        pointer to buffer to read into\r
+  @param[in, out]  Size          pointer to number of bytes in buffer\r
+  @param[in]       Truncate      if TRUE then allows for truncation of the line to fit.\r
+                                 if FALSE will reset the position to the begining of the\r
+                                 line if the buffer is not large enough.\r
+  @param[in, out]  Ascii         Boolean value for indicating whether the file is Ascii (TRUE) or UCS2 (FALSE);\r
+\r
+  @retval EFI_SUCCESS           the operation was sucessful.  the line is stored in\r
+                                Buffer.\r
+  @retval EFI_INVALID_PARAMETER Handle was NULL.\r
+  @retval EFI_INVALID_PARAMETER Size was NULL.\r
+  @retval EFI_BUFFER_TOO_SMALL  Size was not enough space to store the line.\r
+                                Size was updated to minimum space required.\r
+  @sa FileHandleRead\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+FileHandleReadLine(\r
+  IN EFI_FILE_HANDLE            Handle,\r
+  IN OUT CHAR16                 *Buffer,\r
+  IN OUT UINTN                  *Size,\r
+  IN BOOLEAN                    Truncate,\r
+  IN OUT BOOLEAN                *Ascii\r
+  )\r
+{\r
+  EFI_STATUS  Status;\r
+  CHAR16      CharBuffer;\r
+  UINTN       CharSize;\r
+  UINTN       CountSoFar;\r
+  UINT64      OriginalFilePosition;\r
+\r
+\r
+  if (Handle == NULL\r
+    ||Size   == NULL\r
+    ||(Buffer==NULL&&*Size!=0)\r
+   ){\r
+    return (EFI_INVALID_PARAMETER);\r
+  }\r
+  if (Buffer != NULL) {\r
+    *Buffer = CHAR_NULL;\r
+  }\r
+  FileHandleGetPosition(Handle, &OriginalFilePosition);\r
+  if (OriginalFilePosition == 0) {\r
+    CharSize = sizeof(CHAR16);\r
+    Status = FileHandleRead(Handle, &CharSize, &CharBuffer);\r
+    ASSERT_EFI_ERROR(Status);\r
+    if (CharBuffer == gUnicodeFileTag) {\r
+      *Ascii = FALSE;\r
+    } else {\r
+      *Ascii = TRUE;\r
+      FileHandleSetPosition(Handle, OriginalFilePosition);\r
+    }\r
+  }\r
+\r
+  for (CountSoFar = 0;;CountSoFar++){\r
+    CharBuffer = 0;\r
+    if (*Ascii) {\r
+      CharSize = sizeof(CHAR8);\r
+    } else {\r
+      CharSize = sizeof(CHAR16);\r
+    }\r
+    Status = FileHandleRead(Handle, &CharSize, &CharBuffer);\r
+    if (  EFI_ERROR(Status)\r
+       || CharSize == 0\r
+       || (CharBuffer == L'\n' && !(*Ascii))\r
+       || (CharBuffer ==  '\n' && *Ascii)\r
+     ){\r
+      break;\r
+    }\r
+    //\r
+    // if we have space save it...\r
+    //\r
+    if ((CountSoFar+1)*sizeof(CHAR16) < *Size){\r
+      ASSERT(Buffer != NULL);\r
+      ((CHAR16*)Buffer)[CountSoFar] = CharBuffer;\r
+      ((CHAR16*)Buffer)[CountSoFar+1] = CHAR_NULL;\r
+    }\r
+  }\r
+\r
+  //\r
+  // if we ran out of space tell when...\r
+  //\r
+  if ((CountSoFar+1)*sizeof(CHAR16) > *Size){\r
+    *Size = (CountSoFar+1)*sizeof(CHAR16);\r
+    if (!Truncate) {\r
+      FileHandleSetPosition(Handle, OriginalFilePosition);\r
+    } else {\r
+      DEBUG((DEBUG_WARN, "The line was truncated in FileHandleReadLine"));\r
+    }\r
+    return (EFI_BUFFER_TOO_SMALL);\r
+  }\r
+  while(Buffer[StrLen(Buffer)-1] == L'\r') {\r
+    Buffer[StrLen(Buffer)-1] = CHAR_NULL;\r
+  }\r
+\r
+  return (Status);\r
+}\r
+\r
+/**\r
+  function to write a line of unicode text to a file.\r
+\r
+  if Handle is NULL, return error.\r
+  if Buffer is NULL, do nothing.  (return SUCCESS)\r
+\r
+  @param[in]     Handle         FileHandle to write to\r
+  @param[in]     Buffer         Buffer to write\r
+\r
+  @retval  EFI_SUCCESS          the data was written.\r
+  @retval  other                failure.\r
+\r
+  @sa FileHandleWrite\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+FileHandleWriteLine(\r
+  IN EFI_FILE_HANDLE Handle,\r
+  IN CHAR16          *Buffer\r
+  )\r
+{\r
+  EFI_STATUS Status;\r
+  UINTN      Size;\r
+\r
+  if (Buffer == NULL) {\r
+    return (EFI_SUCCESS);\r
+  }\r
+\r
+  if (Handle == NULL) {\r
+    return (EFI_INVALID_PARAMETER);\r
+  }\r
+\r
+  Size = StrSize(Buffer) - sizeof(Buffer[0]);\r
+  Status = FileHandleWrite(Handle, &Size, Buffer);\r
+  if (EFI_ERROR(Status)) {\r
+    return (Status);\r
+  }\r
+  Size = StrSize(L"\r\n") - sizeof(CHAR16);\r
+  return FileHandleWrite(Handle, &Size, L"\r\n");\r
+}\r
+\r
+/**\r
+  function to take a formatted argument and print it to a file.\r
+\r
+  @param[in] Handle   the file handle for the file to write to\r
+  @param[in] Format   the format argument (see printlib for format specifier)\r
+  @param[in] ...      the variable arguments for the format\r
+\r
+  @retval EFI_SUCCESS the operation was sucessful\r
+  @return other       a return value from FileHandleWriteLine\r
+\r
+  @sa FileHandleWriteLine\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+FileHandlePrintLine(\r
+  IN EFI_FILE_HANDLE  Handle,\r
+  IN CONST CHAR16     *Format,\r
+  ...\r
+  )\r
+{\r
+  VA_LIST           Marker;\r
+  CHAR16            *Buffer;\r
+  EFI_STATUS        Status;\r
+\r
+  //\r
+  // Get a buffer to print into\r
+  //\r
+  Buffer = AllocateZeroPool (PcdGet16 (PcdUefiFileHandleLibPrintBufferSize));\r
+  if (Buffer == NULL) {\r
+    return (EFI_OUT_OF_RESOURCES);\r
+  }\r
+\r
+  //\r
+  // Print into our buffer\r
+  //\r
+  VA_START (Marker, Format);\r
+  UnicodeVSPrint (Buffer, PcdGet16 (PcdUefiFileHandleLibPrintBufferSize), Format, Marker);\r
+  VA_END (Marker);\r
+\r
+  //\r
+  // Print buffer into file\r
+  //\r
+  Status = FileHandleWriteLine(Handle, Buffer);\r
+\r
+  //\r
+  // Cleanup and return\r
+  //\r
+  FreePool(Buffer);\r
+  return (Status);\r
+}\r
+\r
+/**\r
+  Function to determine if a FILE_HANDLE is at the end of the file.\r
+\r
+  This will NOT work on directories.\r
+\r
+  If Handle is NULL, then return False.\r
+\r
+  @param[in] Handle     the file handle\r
+\r
+  @retval TRUE          the position is at the end of the file\r
+  @retval FALSE         the position is not at the end of the file\r
+**/\r
+BOOLEAN\r
+EFIAPI\r
+FileHandleEof(\r
+  IN EFI_FILE_HANDLE Handle\r
+  )\r
+{\r
+  EFI_FILE_INFO *Info;\r
+  UINT64        Pos;\r
+  BOOLEAN       RetVal;\r
+\r
+  if (Handle == NULL) {\r
+    return (FALSE);\r
+  }\r
+\r
+  FileHandleGetPosition(Handle, &Pos);\r
+  Info = FileHandleGetInfo (Handle);\r
+\r
+  if (Info == NULL) {\r
+    return (FALSE);\r
+  }\r
+\r
+  FileHandleSetPosition(Handle, Pos);\r
+\r
+  if (Pos == Info->FileSize) {\r
+    RetVal = TRUE;\r
+  } else {\r
+    RetVal = FALSE;\r
+  }\r
+\r
+  FreePool (Info);\r
+\r
+  return (RetVal);\r
+}\r
diff --git a/MdePkg/Library/UefiFileHandleLib/UefiFileHandleLib.inf b/MdePkg/Library/UefiFileHandleLib/UefiFileHandleLib.inf
new file mode 100644 (file)
index 0000000..832e949
--- /dev/null
@@ -0,0 +1,47 @@
+##  @file\r
+# Provides interface to shell functionality for shell commands and applications.\r
+#\r
+#   Copyright (c) 2006 - 2014, Intel Corporation. All rights reserved. <BR>\r
+#   This program and the accompanying materials\r
+#   are licensed and made available under the terms and conditions of the BSD License\r
+#   which accompanies this distribution. The full text of the license may be found at\r
+#   http://opensource.org/licenses/bsd-license.php\r
+#\r
+#  THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
+#  WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
+##\r
+\r
+[Defines]\r
+  INF_VERSION                    = 0x00010006\r
+  BASE_NAME                      = BaseFileHandleLib\r
+  FILE_GUID                      = 9495D344-9D8A-41f3-8D17-E2FD238C4E71\r
+  MODULE_TYPE                    = DXE_DRIVER\r
+  VERSION_STRING                 = 1.0\r
+  LIBRARY_CLASS                  = FileHandleLib|DXE_DRIVER UEFI_APPLICATION UEFI_DRIVER DXE_RUNTIME_DRIVER\r
+\r
+#\r
+#  VALID_ARCHITECTURES           = IA32 X64 IPF EBC\r
+#\r
+\r
+[Sources.common]\r
+  UefiFileHandleLib.c\r
+\r
+[Packages]\r
+  MdePkg/MdePkg.dec\r
+\r
+[LibraryClasses]\r
+  MemoryAllocationLib\r
+  BaseLib\r
+  BaseMemoryLib\r
+  DebugLib\r
+  PrintLib\r
+  PcdLib\r
+\r
+[Protocols]\r
+  gEfiSimpleFileSystemProtocolGuid             # ALWAYS_USED\r
+\r
+[Guids]\r
+  gEfiFileInfoGuid                              # ALWAYS_CONSUMED\r
+\r
+[Pcd.common]\r
+  gEfiMdePkgTokenSpaceGuid.PcdUefiFileHandleLibPrintBufferSize  # ALWAYS_CONSUMED\r
index 6dc696e5d9756b9b435e261cb6fb01ae18587bc2..1eb4346e1803906c01f897c90c32b1991c039d61 100644 (file)
   ##  @libraryclass  Defines library APIs used by modules to get/set print error level.\r
   DebugPrintErrorLevelLib|Include/Library/DebugPrintErrorLevelLib.h\r
 \r
+  ##  @libraryclass  provides EFI_FILE_HANDLE services\r
+  FileHandleLib|Include/Library/FileHandleLib.h\r
+\r
 [LibraryClasses.IA32, LibraryClasses.X64]\r
   ##  @libraryclass  Abstracts both S/W SMI generation and detection.\r
   ##\r
   # @Prompt Maximum Printable Number of Characters.\r
   gEfiMdePkgTokenSpaceGuid.PcdUefiLibMaxPrintBufferSize|320|UINT32|0x101\r
 \r
+  ## This is the print buffer length for FileHandleLib.\r
+  #  FileHandlePrintLine() sizes buffers based on this PCD value for printing.\r
+  # @Prompt Number of Printable Characters.\r
+  gEfiMdePkgTokenSpaceGuid.PcdUefiFileHandleLibPrintBufferSize|1536|UINT16|0x201\r
+\r
   ## Indicates the allowable maximum number in extract handler table.\r
   # @Prompt Maximum Number of GuidedExtractHandler.\r
   gEfiMdePkgTokenSpaceGuid.PcdMaximumGuidedExtractHandler|0x10|UINT32|0x00000025\r
   gEfiMdePkgTokenSpaceGuid.PcdDefaultTerminalType|0|UINT8|0x00000024\r
 \r
 [UserExtensions.TianoCore."ExtraFiles"]\r
-  MdePkgExtra.uni
\ No newline at end of file
+  MdePkgExtra.uni\r
index 80685dd6459d546159d1853cad5f26c3a702fc30..b97d31a7b335fb24d5e95e8516400d2e2fa1726c 100644 (file)
   OpensslLib|CryptoPkg/Library/OpensslLib/OpensslLib.inf\r
   IntrinsicLib|CryptoPkg/Library/IntrinsicLib/IntrinsicLib.inf\r
   DebugPrintErrorLevelLib|MdePkg/Library/BaseDebugPrintErrorLevelLib/BaseDebugPrintErrorLevelLib.inf  \r
+  FileHandleLib|MdePkg/Library/UefiFileHandleLib/UefiFileHandleLib.inf\r
+  SortLib|MdeModulePkg/Library/UefiSortLib/UefiSortLib.inf\r
 \r
 [LibraryClasses.common.UEFI_DRIVER]\r
   DebugLib|MdePkg/Library/UefiDebugLibConOut/UefiDebugLibConOut.inf\r
 \r
 [LibraryClasses.common.UEFI_APPLICATION]\r
   DebugLib|MdePkg/Library/UefiDebugLibStdErr/UefiDebugLibStdErr.inf\r
-  FileHandleLib|ShellPkg/Library/UefiFileHandleLib/UefiFileHandleLib.inf\r
-  SortLib|ShellPkg/Library/UefiSortLib/UefiSortLib.inf\r
   ShellLib|ShellPkg/Library/UefiShellLib/UefiShellLib.inf\r
 \r
 [LibraryClasses.ARM, LibraryClasses.AARCH64]\r
index d7bf609b328287b1da005df593e3a5814c25fe9a..ca656698754b9db8cf9f6e280ee74c04a0388b7c 100644 (file)
@@ -88,7 +88,7 @@
   UefiApplicationEntryPoint|MdePkg/Library/UefiApplicationEntryPoint/UefiApplicationEntryPoint.inf\r
   DevicePathLib|MdePkg/Library/UefiDevicePathLibDevicePathProtocol/UefiDevicePathLibDevicePathProtocol.inf\r
   NvVarsFileLib|OvmfPkg/Library/NvVarsFileLib/NvVarsFileLib.inf\r
-  FileHandleLib|ShellPkg/Library/UefiFileHandleLib/UefiFileHandleLib.inf\r
+  FileHandleLib|MdePkg/Library/UefiFileHandleLib/UefiFileHandleLib.inf\r
   UefiCpuLib|UefiCpuPkg/Library/BaseUefiCpuLib/BaseUefiCpuLib.inf\r
   SecurityManagementLib|MdeModulePkg/Library/DxeSecurityManagementLib/DxeSecurityManagementLib.inf\r
   NetLib|MdeModulePkg/Library/DxeNetLib/DxeNetLib.inf\r
       NULL|ShellPkg/Library/UefiShellInstall1CommandsLib/UefiShellInstall1CommandsLib.inf\r
       NULL|ShellPkg/Library/UefiShellNetwork1CommandsLib/UefiShellNetwork1CommandsLib.inf\r
       HandleParsingLib|ShellPkg/Library/UefiHandleParsingLib/UefiHandleParsingLib.inf\r
-      FileHandleLib|ShellPkg/Library/UefiFileHandleLib/UefiFileHandleLib.inf\r
       ShellLib|ShellPkg/Library/UefiShellLib/UefiShellLib.inf\r
-      SortLib|ShellPkg/Library/UefiSortLib/UefiSortLib.inf\r
+      FileHandleLib|MdePkg/Library/UefiFileHandleLib/UefiFileHandleLib.inf\r
+      SortLib|MdeModulePkg/Library/UefiSortLib/UefiSortLib.inf\r
       PrintLib|MdePkg/Library/BasePrintLib/BasePrintLib.inf\r
-      PathLib|ShellPkg/Library/BasePathLib/BasePathLib.inf\r
 #      SafeBlockIoLib|ShellPkg/Library/SafeBlockIoLib/SafeBlockIoLib.inf\r
 #      SafeOpenProtocolLib|ShellPkg/Library/SafeOpenProtocolLib/SafeOpenProtocolLib.inf\r
       BcfgCommandLib|ShellPkg/Library/UefiShellBcfgCommandLib/UefiShellBcfgCommandLib.inf\r
index 4c921740e8e43e621c0f1fb7b17fa37033f5083d..4b4a1da717c1112039f282ff9cde3f60384f8b13 100644 (file)
@@ -93,7 +93,7 @@
   UefiApplicationEntryPoint|MdePkg/Library/UefiApplicationEntryPoint/UefiApplicationEntryPoint.inf\r
   DevicePathLib|MdePkg/Library/UefiDevicePathLibDevicePathProtocol/UefiDevicePathLibDevicePathProtocol.inf\r
   NvVarsFileLib|OvmfPkg/Library/NvVarsFileLib/NvVarsFileLib.inf\r
-  FileHandleLib|ShellPkg/Library/UefiFileHandleLib/UefiFileHandleLib.inf\r
+  FileHandleLib|MdePkg/Library/UefiFileHandleLib/UefiFileHandleLib.inf\r
   UefiCpuLib|UefiCpuPkg/Library/BaseUefiCpuLib/BaseUefiCpuLib.inf\r
   SecurityManagementLib|MdeModulePkg/Library/DxeSecurityManagementLib/DxeSecurityManagementLib.inf\r
   NetLib|MdeModulePkg/Library/DxeNetLib/DxeNetLib.inf\r
       NULL|ShellPkg/Library/UefiShellInstall1CommandsLib/UefiShellInstall1CommandsLib.inf\r
       NULL|ShellPkg/Library/UefiShellNetwork1CommandsLib/UefiShellNetwork1CommandsLib.inf\r
       HandleParsingLib|ShellPkg/Library/UefiHandleParsingLib/UefiHandleParsingLib.inf\r
-      FileHandleLib|ShellPkg/Library/UefiFileHandleLib/UefiFileHandleLib.inf\r
       ShellLib|ShellPkg/Library/UefiShellLib/UefiShellLib.inf\r
-      SortLib|ShellPkg/Library/UefiSortLib/UefiSortLib.inf\r
+      FileHandleLib|MdePkg/Library/UefiFileHandleLib/UefiFileHandleLib.inf\r
+      SortLib|MdeModulePkg/Library/UefiSortLib/UefiSortLib.inf\r
       PrintLib|MdePkg/Library/BasePrintLib/BasePrintLib.inf\r
-      PathLib|ShellPkg/Library/BasePathLib/BasePathLib.inf\r
 #      SafeBlockIoLib|ShellPkg/Library/SafeBlockIoLib/SafeBlockIoLib.inf\r
 #      SafeOpenProtocolLib|ShellPkg/Library/SafeOpenProtocolLib/SafeOpenProtocolLib.inf\r
       BcfgCommandLib|ShellPkg/Library/UefiShellBcfgCommandLib/UefiShellBcfgCommandLib.inf\r
index 457774efcb0c814b5a96517ab15999dbeac6dcc0..eb3f34b8350b9c474cb56161acc778c3787843db 100644 (file)
@@ -93,7 +93,7 @@
   UefiApplicationEntryPoint|MdePkg/Library/UefiApplicationEntryPoint/UefiApplicationEntryPoint.inf\r
   DevicePathLib|MdePkg/Library/UefiDevicePathLibDevicePathProtocol/UefiDevicePathLibDevicePathProtocol.inf\r
   NvVarsFileLib|OvmfPkg/Library/NvVarsFileLib/NvVarsFileLib.inf\r
-  FileHandleLib|ShellPkg/Library/UefiFileHandleLib/UefiFileHandleLib.inf\r
+  FileHandleLib|MdePkg/Library/UefiFileHandleLib/UefiFileHandleLib.inf\r
   UefiCpuLib|UefiCpuPkg/Library/BaseUefiCpuLib/BaseUefiCpuLib.inf\r
   SecurityManagementLib|MdeModulePkg/Library/DxeSecurityManagementLib/DxeSecurityManagementLib.inf\r
   NetLib|MdeModulePkg/Library/DxeNetLib/DxeNetLib.inf\r
       NULL|ShellPkg/Library/UefiShellInstall1CommandsLib/UefiShellInstall1CommandsLib.inf\r
       NULL|ShellPkg/Library/UefiShellNetwork1CommandsLib/UefiShellNetwork1CommandsLib.inf\r
       HandleParsingLib|ShellPkg/Library/UefiHandleParsingLib/UefiHandleParsingLib.inf\r
-      FileHandleLib|ShellPkg/Library/UefiFileHandleLib/UefiFileHandleLib.inf\r
       ShellLib|ShellPkg/Library/UefiShellLib/UefiShellLib.inf\r
-      SortLib|ShellPkg/Library/UefiSortLib/UefiSortLib.inf\r
+      FileHandleLib|MdePkg/Library/UefiFileHandleLib/UefiFileHandleLib.inf\r
+      SortLib|MdeModulePkg/Library/UefiSortLib/UefiSortLib.inf\r
       PrintLib|MdePkg/Library/BasePrintLib/BasePrintLib.inf\r
-      PathLib|ShellPkg/Library/BasePathLib/BasePathLib.inf\r
 #      SafeBlockIoLib|ShellPkg/Library/SafeBlockIoLib/SafeBlockIoLib.inf\r
 #      SafeOpenProtocolLib|ShellPkg/Library/SafeOpenProtocolLib/SafeOpenProtocolLib.inf\r
       BcfgCommandLib|ShellPkg/Library/UefiShellBcfgCommandLib/UefiShellBcfgCommandLib.inf\r
index 8c0890e85e8c29113a49637e775a78a28c52747e..d03ea3623ff059b7afb0ccfd6d4b8eac7ac5b9a1 100644 (file)
@@ -1,7 +1,7 @@
 ## @file\r
 # Build description file to generate Shell DP application.\r
 #\r
-# Copyright (c) 2009 - 2013, Intel Corporation. All rights reserved.<BR>\r
+# Copyright (c) 2009 - 2014, Intel Corporation. All rights reserved.<BR>\r
 # This program and the accompanying materials\r
 # are licensed and made available under the terms and conditions of the BSD License\r
 # which accompanies this distribution.  The full text of the license may be found at\r
   UefiHiiServicesLib|MdeModulePkg/Library/UefiHiiServicesLib/UefiHiiServicesLib.inf\r
   PerformanceLib|MdeModulePkg/Library/DxePerformanceLib/DxePerformanceLib.inf\r
   IoLib|MdePkg/Library/BaseIoLibIntrinsic/BaseIoLibIntrinsic.inf\r
+  FileHandleLib|MdePkg/Library/UefiFileHandleLib/UefiFileHandleLib.inf\r
+  SortLib|MdeModulePkg/Library/UefiSortLib/UefiSortLib.inf\r
 \r
-  SortLib|ShellPkg/Library/UefiSortLib/UefiSortLib.inf\r
   ShellLib|ShellPkg/Library/UefiShellLib/UefiShellLib.inf\r
-  FileHandleLib|ShellPkg/Library/UefiFileHandleLib/UefiFileHandleLib.inf\r
 \r
   PciLib|MdePkg/Library/BasePciLibCf8/BasePciLibCf8.inf\r
   PciCf8Lib|MdePkg/Library/BasePciCf8Lib/BasePciCf8Lib.inf\r
index c20ee3a803bf3c871aceee4132caaab8da202b6d..95d9669f7cf66de70bbdbea320dd2dd0c6af5a30 100644 (file)
@@ -46,7 +46,6 @@
 #include <Library/HiiLib.h>\r
 #include <Library/PrintLib.h>\r
 #include <Library/HandleParsingLib.h>\r
-#include <Library/PathLib.h>\r
 #include <Library/FileHandleLib.h>\r
 \r
 #include "ShellParametersProtocol.h"\r
index c3e09a6cf1f2267e5677bac7b2286d9dbb58244c..e20ac08a7eb06dd09a0f2429166823f6a978dc5e 100644 (file)
@@ -2,7 +2,7 @@
 #  This is the shell application\r
 #\r
 #  Copyright (c) 2013, Hewlett-Packard Development Company, L.P.\r
-#  Copyright (c) 2009 - 2013, Intel Corporation. All rights reserved.<BR>\r
+#  Copyright (c) 2009 - 2014, Intel Corporation. All rights reserved.<BR>\r
 #\r
 #  This program and the accompanying materials\r
 #  are licensed and made available under the terms and conditions of the BSD License\r
@@ -70,7 +70,6 @@
   HiiLib\r
   SortLib\r
   HandleParsingLib\r
-  PathLib\r
 \r
 [Guids]\r
   gShellVariableGuid                                      # ALWAYS_CONSUMES\r
index ab13244215414ae86f2e24d0f476d7cae6f63790..70130c1c06a1c0386673e08073861649fd324161 100644 (file)
@@ -1,7 +1,7 @@
 ## @file\r
 #  This is the shell sorting testing application\r
 #\r
-#  Copyright (c) 2009 - 2010, Intel Corporation. All rights reserved.<BR>\r
+#  Copyright (c) 2009 - 2014, Intel Corporation. All rights reserved.<BR>\r
 #\r
 #  This program and the accompanying materials\r
 #  are licensed and made available under the terms and conditions of the BSD License\r
@@ -33,6 +33,7 @@
 [Packages]\r
   MdePkg/MdePkg.dec\r
   ShellPkg/ShellPkg.dec\r
+  MdeModulePkg/MdeModulePkg.dec\r
 \r
 [LibraryClasses]\r
   ShellCEntryLib\r
diff --git a/ShellPkg/Include/Library/FileHandleLib.h b/ShellPkg/Include/Library/FileHandleLib.h
deleted file mode 100644 (file)
index 6c79397..0000000
+++ /dev/null
@@ -1,498 +0,0 @@
-/** @file\r
-  Provides interface to EFI_FILE_HANDLE functionality.\r
-\r
-  Copyright (c) 2009 - 2011, Intel Corporation. All rights reserved.<BR>\r
-  This program and the accompanying materials\r
-  are licensed and made available under the terms and conditions of the BSD License\r
-  which accompanies this distribution.  The full text of the license may be found at\r
-  http://opensource.org/licenses/bsd-license.php\r
-\r
-  THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
-  WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
-\r
-**/\r
-\r
-#ifndef _FILE_HANDLE_LIBRARY_HEADER_\r
-#define _FILE_HANDLE_LIBRARY_HEADER_\r
-\r
-#include <Protocol/SimpleFileSystem.h>\r
-\r
-/// The tag for use in identifying UNICODE files.\r
-/// If the file is UNICODE, the first 16 bits of the file will equal this value.\r
-extern CONST UINT16 gUnicodeFileTag;\r
-\r
-/**\r
-  This function retrieves information about the file for the handle\r
-  specified and stores it in the allocated pool memory.\r
-\r
-  This function allocates a buffer to store the file's information. It is the\r
-  caller's responsibility to free the buffer.\r
-\r
-  @param[in] FileHandle         The file handle of the file for which information is\r
-                                being requested.\r
-\r
-  @retval NULL                  Information could not be retrieved.\r
-  @retval !NULL                 The information about the file.\r
-**/\r
-EFI_FILE_INFO*\r
-EFIAPI\r
-FileHandleGetInfo (\r
-  IN EFI_FILE_HANDLE            FileHandle\r
-  );\r
-\r
-/**\r
-  This function sets the information about the file for the opened handle\r
-  specified.\r
-\r
-  @param[in]  FileHandle        The file handle of the file for which information\r
-                                is being set.\r
-\r
-  @param[in]  FileInfo          The information to set.\r
-\r
-  @retval EFI_SUCCESS           The information was set.\r
-  @retval EFI_INVALID_PARAMETER A parameter was out of range or invalid.\r
-  @retval EFI_UNSUPPORTED       The FileHandle does not support FileInfo.\r
-  @retval EFI_NO_MEDIA          The device has no medium.\r
-  @retval EFI_DEVICE_ERROR      The device reported an error.\r
-  @retval EFI_VOLUME_CORRUPTED  The file system structures are corrupted.\r
-  @retval EFI_WRITE_PROTECTED   The file or medium is write protected.\r
-  @retval EFI_ACCESS_DENIED     The file was opened read only.\r
-  @retval EFI_VOLUME_FULL       The volume is full.\r
-**/\r
-EFI_STATUS\r
-EFIAPI\r
-FileHandleSetInfo (\r
-  IN EFI_FILE_HANDLE            FileHandle,\r
-  IN CONST EFI_FILE_INFO        *FileInfo\r
-  );\r
-\r
-/**\r
-  This function reads information from an opened file.\r
-\r
-  If FileHandle is not a directory, the function reads the requested number of\r
-  bytes from the file at the file's current position and returns them in Buffer.\r
-  If the read goes beyond the end of the file, the read length is truncated to the\r
-  end of the file. The file's current position is increased by the number of bytes\r
-  returned.  If FileHandle is a directory, the function reads the directory entry\r
-  at the file's current position and returns the entry in Buffer. If the Buffer\r
-  is not large enough to hold the current directory entry, then\r
-  EFI_BUFFER_TOO_SMALL is returned and the current file position is not updated.\r
-  BufferSize is set to be the size of the buffer needed to read the entry. On\r
-  success, the current position is updated to the next directory entry. If there\r
-  are no more directory entries, the read returns a zero-length buffer.\r
-  EFI_FILE_INFO is the structure returned as the directory entry.\r
-\r
-  @param[in] FileHandle          The opened file handle.\r
-  @param[in, out] BufferSize     On input, the size of buffer in bytes.  On return,\r
-                                 the number of bytes written.\r
-  @param[out] Buffer             The buffer to put read data into.\r
-\r
-  @retval EFI_SUCCESS         Data was read.\r
-  @retval EFI_NO_MEDIA          The device has no media.\r
-  @retval EFI_DEVICE_ERROR  The device reported an error.\r
-  @retval EFI_VOLUME_CORRUPTED  The file system structures are corrupted.\r
-  @retval EFI_BUFFER_TO_SMALL Buffer is too small. ReadSize contains required\r
-                                size.\r
-\r
-**/\r
-EFI_STATUS\r
-EFIAPI\r
-FileHandleRead(\r
-  IN EFI_FILE_HANDLE            FileHandle,\r
-  IN OUT UINTN                  *BufferSize,\r
-  OUT VOID                      *Buffer\r
-  );\r
-\r
-/**\r
-  Write data to a file.\r
-\r
-  This function writes the specified number of bytes to the file at the current\r
-  file position. The current file position is advanced the actual number of bytes\r
-  written, which is returned in BufferSize. Partial writes only occur when there\r
-  has been a data error during the write attempt (such as "volume space full").\r
-  The file is automatically grown to hold the data if required. Direct writes to\r
-  opened directories are not supported.\r
-\r
-  @param[in] FileHandle          The opened file for writing.\r
-  @param[in, out] BufferSize     On input, the number of bytes in Buffer.  On output,\r
-                                 the number of bytes written.\r
-  @param[in] Buffer              The buffer containing data to write is stored.\r
-\r
-  @retval EFI_SUCCESS         Data was written.\r
-  @retval EFI_UNSUPPORTED       Writes to an open directory are not supported.\r
-  @retval EFI_NO_MEDIA          The device has no media.\r
-  @retval EFI_DEVICE_ERROR  The device reported an error.\r
-  @retval EFI_VOLUME_CORRUPTED  The file system structures are corrupted.\r
-  @retval EFI_WRITE_PROTECTED The device is write-protected.\r
-  @retval EFI_ACCESS_DENIED The file was opened for read only.\r
-  @retval EFI_VOLUME_FULL The volume is full.\r
-**/\r
-EFI_STATUS\r
-EFIAPI\r
-FileHandleWrite(\r
-  IN EFI_FILE_HANDLE            FileHandle,\r
-  IN OUT UINTN                  *BufferSize,\r
-  IN VOID                       *Buffer\r
-  );\r
-\r
-/**\r
-  Close an open file handle.\r
-\r
-  This function closes a specified file handle. All "dirty" cached file data is\r
-  flushed to the device, and the file is closed. In all cases the handle is\r
-  closed.\r
-\r
-  @param[in] FileHandle           The file handle to close.\r
-\r
-  @retval EFI_SUCCESS             The file handle was closed successfully.\r
-**/\r
-EFI_STATUS\r
-EFIAPI\r
-FileHandleClose (\r
-  IN EFI_FILE_HANDLE            FileHandle\r
-  );\r
-\r
-/**\r
-  Delete a file and close the handle.\r
-\r
-  This function closes and deletes a file. In all cases the file handle is closed.\r
-  If the file cannot be deleted, the warning code EFI_WARN_DELETE_FAILURE is\r
-  returned, but the handle is still closed.\r
-\r
-  @param[in] FileHandle             The file handle to delete.\r
-\r
-  @retval EFI_SUCCESS               The file was closed successfully.\r
-  @retval EFI_WARN_DELETE_FAILURE   The handle was closed, but the file was not\r
-                                    deleted.\r
-  @retval INVALID_PARAMETER         One of the parameters has an invalid value.\r
-**/\r
-EFI_STATUS\r
-EFIAPI\r
-FileHandleDelete (\r
-  IN EFI_FILE_HANDLE    FileHandle\r
-  );\r
-\r
-/**\r
-  Set the current position in a file.\r
-\r
-  This function sets the current file position for the handle to the position\r
-  supplied. With the exception of moving to position 0xFFFFFFFFFFFFFFFF, only\r
-  absolute positioning is supported, and moving past the end of the file is\r
-  allowed (a subsequent write would grow the file). Moving to position\r
-  0xFFFFFFFFFFFFFFFF causes the current position to be set to the end of the file.\r
-  If FileHandle is a directory, the only position that may be set is zero. This\r
-  has the effect of starting the read process of the directory entries over again.\r
-\r
-  @param[in] FileHandle         The file handle on which the position is being set.\r
-  @param[in] Position           The byte position from the begining of the file.\r
-\r
-  @retval EFI_SUCCESS           The operation completed sucessfully.\r
-  @retval EFI_UNSUPPORTED       The request for non-zero is not valid on\r
-                                directories.\r
-  @retval INVALID_PARAMETER     One of the parameters has an invalid value.\r
-**/\r
-EFI_STATUS\r
-EFIAPI\r
-FileHandleSetPosition (\r
-  IN EFI_FILE_HANDLE    FileHandle,\r
-  IN UINT64             Position\r
-  );\r
-\r
-/**\r
-  Gets a file's current position.\r
-\r
-  This function retrieves the current file position for the file handle. For\r
-  directories, the current file position has no meaning outside of the file\r
-  system driver. As such, the operation is not supported. An error is returned\r
-  if FileHandle is a directory.\r
-\r
-  @param[in] FileHandle         The open file handle on which to get the position.\r
-  @param[out] Position          The byte position from begining of file.\r
-\r
-  @retval EFI_SUCCESS           The operation completed successfully.\r
-  @retval INVALID_PARAMETER     One of the parameters has an invalid value.\r
-  @retval EFI_UNSUPPORTED       The request is not valid on directories.\r
-**/\r
-EFI_STATUS\r
-EFIAPI\r
-FileHandleGetPosition (\r
-  IN EFI_FILE_HANDLE            FileHandle,\r
-  OUT UINT64                    *Position\r
-  );\r
-/**\r
-  Flushes data on a file.\r
-\r
-  This function flushes all modified data associated with a file to a device.\r
-\r
-  @param[in] FileHandle         The file handle on which to flush data.\r
-\r
-  @retval EFI_SUCCESS           The data was flushed.\r
-  @retval EFI_NO_MEDIA          The device has no media.\r
-  @retval EFI_DEVICE_ERROR      The device reported an error.\r
-  @retval EFI_VOLUME_CORRUPTED  The file system structures are corrupted.\r
-  @retval EFI_WRITE_PROTECTED   The file or medium is write protected.\r
-  @retval EFI_ACCESS_DENIED     The file was opened for read only.\r
-**/\r
-EFI_STATUS\r
-EFIAPI\r
-FileHandleFlush (\r
-  IN EFI_FILE_HANDLE            FileHandle\r
-  );\r
-\r
-/**\r
-  Function to determine if a given handle is a directory handle.\r
-\r
-  If DirHandle is NULL, then ASSERT().\r
-\r
-  Open the file information on the DirHandle, and verify that the Attribute\r
-  includes EFI_FILE_DIRECTORY bit set.\r
-\r
-  @param[in] DirHandle          The handle to open the file.\r
-\r
-  @retval EFI_SUCCESS           DirHandle is a directory.\r
-  @retval EFI_INVALID_PARAMETER DirHandle did not have EFI_FILE_INFO available.\r
-  @retval EFI_NOT_FOUND         DirHandle is not a directory.\r
-**/\r
-EFI_STATUS\r
-EFIAPI\r
-FileHandleIsDirectory (\r
-  IN EFI_FILE_HANDLE            DirHandle\r
-  );\r
-\r
-/** Retrieve first entry from a directory.\r
-\r
-  This function takes an open directory handle and gets information from the\r
-  first entry in the directory.  A buffer is allocated to contain\r
-  the information and a pointer to the buffer is returned in *Buffer.  The\r
-  caller can use FileHandleFindNextFile() to get subsequent directory entries.\r
-\r
-  The buffer will be freed by FileHandleFindNextFile() when the last directory\r
-  entry is read.  Otherwise, the caller must free the buffer, using FreePool,\r
-  when finished with it.\r
-\r
-  @param[in]  DirHandle         The file handle of the directory to search.\r
-  @param[out] Buffer            The pointer to pointer to buffer for file's information.\r
-\r
-  @retval EFI_SUCCESS           Found the first file.\r
-  @retval EFI_NOT_FOUND         Cannot find the directory.\r
-  @retval EFI_NO_MEDIA          The device has no media.\r
-  @retval EFI_DEVICE_ERROR      The device reported an error.\r
-  @retval EFI_VOLUME_CORRUPTED  The file system structures are corrupted.\r
-  @return Others                The status of FileHandleGetInfo, FileHandleSetPosition,\r
-                                or FileHandleRead.\r
-**/\r
-EFI_STATUS\r
-EFIAPI\r
-FileHandleFindFirstFile (\r
-  IN EFI_FILE_HANDLE            DirHandle,\r
-  OUT EFI_FILE_INFO             **Buffer\r
-  );\r
-\r
-/** Retrieve next entries from a directory.\r
-\r
-  To use this function, the caller must first call the FileHandleFindFirstFile()\r
-  function to get the first directory entry.  Subsequent directory entries are\r
-  retrieved by using the FileHandleFindNextFile() function.  This function can\r
-  be called several times to get each entry from the directory.  If the call of\r
-  FileHandleFindNextFile() retrieved the last directory entry, the next call of\r
-  this function will set *NoFile to TRUE and free the buffer.\r
-\r
-  @param[in]  DirHandle         The file handle of the directory.\r
-  @param[out] Buffer            The pointer to buffer for file's information.\r
-  @param[out] NoFile            The pointer to boolean when last file is found.\r
-\r
-  @retval EFI_SUCCESS           Found the next file, or reached last file.\r
-  @retval EFI_NO_MEDIA          The device has no media.\r
-  @retval EFI_DEVICE_ERROR      The device reported an error.\r
-  @retval EFI_VOLUME_CORRUPTED  The file system structures are corrupted.\r
-**/\r
-EFI_STATUS\r
-EFIAPI\r
-FileHandleFindNextFile(\r
-  IN EFI_FILE_HANDLE             DirHandle,\r
-  OUT EFI_FILE_INFO              *Buffer,\r
-  OUT BOOLEAN                    *NoFile\r
-  );\r
-\r
-/**\r
-  Retrieve the size of a file.\r
-\r
-  If FileHandle is NULL then ASSERT().\r
-  If Size is NULL then ASSERT().\r
-\r
-  This function extracts the file size info from the FileHandle's EFI_FILE_INFO\r
-  data.\r
-\r
-  @param[in] FileHandle         The file handle from which size is retrieved.\r
-  @param[out] Size              The pointer to size.\r
-\r
-  @retval EFI_SUCCESS           The operation completed successfully.\r
-  @retval EFI_DEVICE_ERROR      Cannot access the file.\r
-**/\r
-EFI_STATUS\r
-EFIAPI\r
-FileHandleGetSize (\r
-  IN EFI_FILE_HANDLE            FileHandle,\r
-  OUT UINT64                    *Size\r
-  );\r
-\r
-/**\r
-  Set the size of a file.\r
-\r
-  If FileHandle is NULL then ASSERT().\r
-\r
-  This function changes the file size info from the FileHandle's EFI_FILE_INFO\r
-  data.\r
-\r
-  @param[in] FileHandle         The file handle whose size is to be changed.\r
-  @param[in] Size               The new size.\r
-\r
-  @retval EFI_SUCCESS           The operation completed successfully.\r
-  @retval EFI_DEVICE_ERROR      Cannot access the file.\r
-**/\r
-EFI_STATUS\r
-EFIAPI\r
-FileHandleSetSize (\r
-  IN EFI_FILE_HANDLE            FileHandle,\r
-  IN UINT64                     Size\r
-  );\r
-\r
-/**\r
-  Function to get a full filename given a EFI_FILE_HANDLE somewhere lower on the\r
-  directory 'stack'.\r
-\r
-  @param[in] Handle             Handle to the Directory or File to create path to.\r
-  @param[out] FullFileName      Pointer to pointer to generated full file name.  It\r
-                                is the responsibility of the caller to free this memory\r
-                                with a call to FreePool().\r
-  @retval EFI_SUCCESS           The operation was successful and FullFileName is valid.\r
-  @retval EFI_INVALID_PARAMETER Handle was NULL.\r
-  @retval EFI_INVALID_PARAMETER FullFileName was NULL.\r
-  @retval EFI_OUT_OF_MEMORY     A memory allocation failed.\r
-**/\r
-EFI_STATUS\r
-EFIAPI\r
-FileHandleGetFileName (\r
-  IN CONST EFI_FILE_HANDLE      Handle,\r
-  OUT CHAR16                    **FullFileName\r
-  );\r
-\r
-/**\r
-  Function to read a single line (up to but not including the \n) from a file.\r
-\r
-  If the position upon start is 0, then the Ascii Boolean will be set.  This should be\r
-  maintained and not changed for all operations with the same file.\r
-\r
-  @param[in]       Handle        FileHandle to read from.\r
-  @param[in, out]  Buffer        The pointer to buffer to read into.\r
-  @param[in, out]  Size          The pointer to number of bytes in Buffer.\r
-  @param[in]       Truncate      If the buffer is large enough, this has no effect.\r
-                                 If the buffer is is too small and Truncate is TRUE,\r
-                                 the line will be truncated.\r
-                                 If the buffer is is too small and Truncate is FALSE,\r
-                                 then no read will occur.\r
-\r
-  @param[in, out]  Ascii         Boolean value for indicating whether the file is\r
-                                 Ascii (TRUE) or UCS2 (FALSE).\r
-\r
-  @retval EFI_SUCCESS           The operation was successful.  The line is stored in\r
-                                Buffer.\r
-  @retval EFI_INVALID_PARAMETER Handle was NULL.\r
-  @retval EFI_INVALID_PARAMETER Size was NULL.\r
-  @retval EFI_BUFFER_TOO_SMALL  Size was not large enough to store the line.\r
-                                Size was updated to the minimum space required.\r
-  @sa FileHandleRead\r
-**/\r
-EFI_STATUS\r
-EFIAPI\r
-FileHandleReadLine(\r
-  IN EFI_FILE_HANDLE            Handle,\r
-  IN OUT CHAR16                 *Buffer,\r
-  IN OUT UINTN                  *Size,\r
-  IN BOOLEAN                    Truncate,\r
-  IN OUT BOOLEAN                *Ascii\r
-  );\r
-\r
-/**\r
-  Function to read a single line from a file. The \n is not included in the returned\r
-  buffer.  The returned buffer must be callee freed.\r
-\r
-  If the position upon start is 0, then the Ascii Boolean will be set.  This should be\r
-  maintained and not changed for all operations with the same file.\r
-\r
-  @param[in]       Handle        FileHandle to read from.\r
-  @param[in, out]  Ascii         Boolean value for indicating whether the file is\r
-                                 Ascii (TRUE) or UCS2 (FALSE).\r
-\r
-  @return                       The line of text from the file.\r
-\r
-  @sa FileHandleReadLine\r
-**/\r
-CHAR16*\r
-EFIAPI\r
-FileHandleReturnLine(\r
-  IN EFI_FILE_HANDLE            Handle,\r
-  IN OUT BOOLEAN                *Ascii\r
-  );\r
-\r
-/**\r
-  Function to write a line of unicode text to a file.\r
-\r
-  If Handle is NULL, ASSERT.\r
-\r
-  @param[in]     Handle         FileHandle to write to.\r
-  @param[in]     Buffer         Buffer to write, if NULL the function will\r
-                                take no action and return EFI_SUCCESS.\r
-\r
-  @retval  EFI_SUCCESS          The data was written.\r
-  @retval  other                Failure.\r
-\r
-  @sa FileHandleWrite\r
-**/\r
-EFI_STATUS\r
-EFIAPI\r
-FileHandleWriteLine(\r
-  IN EFI_FILE_HANDLE Handle,\r
-  IN CHAR16          *Buffer\r
-  );\r
-\r
-/**\r
-  Function to take a formatted argument and print it to a file.\r
-\r
-  @param[in] Handle   The file handle for the file to write to.\r
-  @param[in] Format   The format argument (see printlib for the format specifier).\r
-  @param[in] ...      The variable arguments for the format.\r
-\r
-  @retval EFI_SUCCESS The operation was successful.\r
-  @retval other       A return value from FileHandleWriteLine.\r
-\r
-  @sa FileHandleWriteLine\r
-**/\r
-EFI_STATUS\r
-EFIAPI\r
-FileHandlePrintLine(\r
-  IN EFI_FILE_HANDLE  Handle,\r
-  IN CONST CHAR16     *Format,\r
-  ...\r
-  );\r
-\r
-/**\r
-  Function to determine if a FILE_HANDLE is at the end of the file.\r
-\r
-  This will NOT work on directories.\r
-\r
-  If Handle is NULL, then ASSERT().\r
-\r
-  @param[in] Handle     The file handle.\r
-\r
-  @retval TRUE          The position is at the end of the file.\r
-  @retval FALSE         The position is not at the end of the file.\r
-**/\r
-BOOLEAN\r
-EFIAPI\r
-FileHandleEof(\r
-  IN EFI_FILE_HANDLE Handle\r
-  );\r
-\r
-#endif //_FILE_HANDLE_LIBRARY_HEADER_\r
-\r
diff --git a/ShellPkg/Include/Library/PathLib.h b/ShellPkg/Include/Library/PathLib.h
deleted file mode 100644 (file)
index ee47352..0000000
+++ /dev/null
@@ -1,56 +0,0 @@
-/** @file\r
-  Provides interface to path manipulation functions.\r
-\r
-  Copyright (c) 2011, Intel Corporation. All rights reserved.<BR>\r
-  This program and the accompanying materials\r
-  are licensed and made available under the terms and conditions of the BSD License\r
-  which accompanies this distribution.  The full text of the license may be found at\r
-  http://opensource.org/licenses/bsd-license.php.\r
-\r
-  THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
-  WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
-**/\r
-\r
-#ifndef _PATH_LIB_\r
-#define _PATH_LIB_\r
-\r
-#include <Base.h>\r
-#include <Library/BaseMemoryLib.h>\r
-\r
-/**\r
-  Removes the last directory or file entry in a path by changing the last\r
-  L'\' to a CHAR_NULL.\r
-\r
-  @param[in, out] Path    The pointer to the path to modify.\r
-\r
-  @retval FALSE     Nothing was found to remove.\r
-  @retval TRUE      A directory or file was removed.\r
-**/\r
-BOOLEAN\r
-EFIAPI\r
-PathRemoveLastItem(\r
-  IN OUT CHAR16 *Path\r
-  );\r
-\r
-/**\r
-  Function to clean up paths.  \r
-  \r
-  - Single periods in the path are removed.\r
-  - Double periods in the path are removed along with a single parent directory.\r
-  - Forward slashes L'/' are converted to backward slashes L'\'.\r
-\r
-  This will be done inline and the existing buffer may be larger than required \r
-  upon completion.\r
-\r
-  @param[in] Path       The pointer to the string containing the path.\r
-\r
-  @retval NULL          An error occured.\r
-  @return Path in all other instances.\r
-**/\r
-CHAR16*\r
-EFIAPI\r
-PathCleanUpDirectories(\r
-  IN CHAR16 *Path\r
-  );\r
-\r
-#endif //_PATH_LIB_\r
diff --git a/ShellPkg/Include/Library/SortLib.h b/ShellPkg/Include/Library/SortLib.h
deleted file mode 100644 (file)
index a3e0fd9..0000000
+++ /dev/null
@@ -1,114 +0,0 @@
-/** @file\r
-  Library used for sorting and comparison routines.\r
-\r
-  Copyright (c) 2009 - 2010, Intel Corporation. All rights reserved. <BR>\r
-  This program and the accompanying materials\r
-  are licensed and made available under the terms and conditions of the BSD License\r
-  which accompanies this distribution.  The full text of the license may be found at\r
-  http://opensource.org/licenses/bsd-license.php\r
-\r
-  THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
-  WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
-\r
-**/\r
-\r
-#ifndef __SORT_LIB_H__\r
-#define __SORT_LIB_H__\r
-\r
-/**\r
-  Prototype for comparison function for any two element types.\r
-\r
-  @param[in] Buffer1                  The pointer to first buffer.\r
-  @param[in] Buffer2                  The pointer to second buffer.\r
-\r
-  @retval 0                           Buffer1 equal to Buffer2.\r
-  @return <0                          Buffer1 is less than Buffer2.\r
-  @return >0                          Buffer1 is greater than Buffer2.\r
-**/\r
-typedef\r
-INTN\r
-(EFIAPI *SORT_COMPARE)(\r
-  IN CONST VOID                 *Buffer1,\r
-  IN CONST VOID                 *Buffer2\r
-  );\r
-\r
-/**\r
-  Function to perform a Quick Sort on a buffer of comparable elements.\r
-\r
-  Each element must be equally sized.\r
-\r
-  If BufferToSort is NULL, then ASSERT.\r
-  If CompareFunction is NULL, then ASSERT.\r
-\r
-  If Count is < 2 , then perform no action.\r
-  If Size is < 1 , then perform no action.\r
-\r
-  @param[in, out] BufferToSort   On call, a Buffer of (possibly sorted) elements;\r
-                                 on return, a buffer of sorted elements.\r
-  @param[in]  Count              The number of elements in the buffer to sort.\r
-  @param[in]  ElementSize        The size of an element in bytes.\r
-  @param[in]  CompareFunction    The function to call to perform the comparison\r
-                                 of any two elements.\r
-**/\r
-VOID\r
-EFIAPI\r
-PerformQuickSort (\r
-  IN OUT VOID                   *BufferToSort,\r
-  IN CONST UINTN                Count,\r
-  IN CONST UINTN                ElementSize,\r
-  IN       SORT_COMPARE         CompareFunction\r
-  );\r
-\r
-\r
-/**\r
-  Function to compare 2 device paths for use as CompareFunction.\r
-\r
-  @param[in] Buffer1            The pointer to Device Path to compare.\r
-  @param[in] Buffer2            The pointer to second DevicePath to compare.\r
-\r
-  @retval 0                     Buffer1 equal to Buffer2.\r
-  @return < 0                   Buffer1 is less than Buffer2.\r
-  @return > 0                   Buffer1 is greater than Buffer2.\r
-**/\r
-INTN\r
-EFIAPI\r
-DevicePathCompare (\r
-  IN  CONST VOID                *Buffer1,\r
-  IN  CONST VOID                *Buffer2\r
-  );\r
-\r
-/**\r
-  Function to compare 2 strings without regard to case of the characters.\r
-\r
-  @param[in] Buffer1            The pointer to String to compare (CHAR16**).\r
-  @param[in] Buffer2            The pointer to second String to compare (CHAR16**).\r
-\r
-  @retval 0                     Buffer1 equal to Buffer2.\r
-  @return < 0                   Buffer1 is less than Buffer2.\r
-  @return > 0                   Buffer1 is greater than Buffer2.\r
-**/\r
-INTN\r
-EFIAPI\r
-StringNoCaseCompare (\r
-  IN  CONST VOID                *Buffer1,\r
-  IN  CONST VOID                *Buffer2\r
-  );\r
-\r
-/**\r
-  Function to compare 2 strings.\r
-\r
-  @param[in] Buffer1            The pointer to String to compare (CHAR16**).\r
-  @param[in] Buffer2            The pointer to second String to compare (CHAR16**).\r
-\r
-  @retval 0                     Buffer1 equal to Buffer2.\r
-  @return < 0                   Buffer1 is less than Buffer2.\r
-  @return > 0                   Buffer1 is greater than Buffer2.\r
-**/\r
-INTN\r
-EFIAPI\r
-StringCompare (\r
-  IN  CONST VOID                *Buffer1,\r
-  IN  CONST VOID                *Buffer2\r
-  );\r
-\r
-#endif //__SORT_LIB_H__\r
diff --git a/ShellPkg/Library/BasePathLib/BasePathLib.c b/ShellPkg/Library/BasePathLib/BasePathLib.c
deleted file mode 100644 (file)
index 301bd3b..0000000
+++ /dev/null
@@ -1,131 +0,0 @@
-/** @file\r
-  Provides interface to path manipulation functions.\r
-\r
-  Copyright (c) 2011 - 2014, Intel Corporation. All rights reserved.<BR>\r
-  This program and the accompanying materials\r
-  are licensed and made available under the terms and conditions of the BSD License\r
-  which accompanies this distribution.  The full text of the license may be found at\r
-  http://opensource.org/licenses/bsd-license.php.\r
-\r
-  THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
-  WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
-**/\r
-\r
-#include <Base.h>\r
-#include <Library/BaseMemoryLib.h>\r
-#include <Library/PathLib.h>\r
-#include <Library/BaseLib.h>\r
-#include <Protocol/SimpleTextIn.h> \r
-\r
-/**\r
-  Removes the last directory or file entry in a path by changing the last\r
-  L'\' to a CHAR_NULL.\r
-\r
-  @param[in, out] Path    The pointer to the path to modify.\r
-\r
-  @retval FALSE     Nothing was found to remove.\r
-  @retval TRUE      A directory or file was removed.\r
-**/\r
-BOOLEAN\r
-EFIAPI\r
-PathRemoveLastItem(\r
-  IN OUT CHAR16 *Path\r
-  )\r
-{\r
-  CHAR16        *Walker;\r
-  CHAR16        *LastSlash;\r
-  //\r
-  // get directory name from path... ('chop' off extra)\r
-  //\r
-  for ( Walker = Path, LastSlash = NULL\r
-      ; Walker != NULL && *Walker != CHAR_NULL\r
-      ; Walker++\r
-     ){\r
-    if (*Walker == L'\\' && *(Walker + 1) != CHAR_NULL) {\r
-      LastSlash = Walker+1;\r
-    }\r
-  }\r
-  if (LastSlash != NULL) {\r
-    *LastSlash = CHAR_NULL;\r
-    return (TRUE);\r
-  }\r
-  return (FALSE);\r
-}\r
-\r
-/**\r
-  Function to clean up paths.  \r
-  \r
-  - Single periods in the path are removed.\r
-  - Double periods in the path are removed along with a single parent directory.\r
-  - Forward slashes L'/' are converted to backward slashes L'\'.\r
-\r
-  This will be done inline and the existing buffer may be larger than required \r
-  upon completion.\r
-\r
-  @param[in] Path       The pointer to the string containing the path.\r
-\r
-  @retval NULL          An error occured.\r
-  @return Path in all other instances.\r
-**/\r
-CHAR16*\r
-EFIAPI\r
-PathCleanUpDirectories(\r
-  IN CHAR16 *Path\r
-  )\r
-{\r
-  CHAR16  *TempString;\r
-  UINTN   TempSize;\r
-  if (Path==NULL) {\r
-    return(NULL);\r
-  }\r
-\r
-  //\r
-  // Fix up the '/' vs '\'\r
-  //\r
-  for (TempString = Path ; TempString != NULL && *TempString != CHAR_NULL ; TempString++) {\r
-    if (*TempString == L'/') {\r
-      *TempString = L'\\';\r
-    }\r
-  }\r
-\r
-  //\r
-  // Fix up the ..\r
-  //\r
-  while ((TempString = StrStr(Path, L"\\..\\")) != NULL) {\r
-    *TempString = CHAR_NULL;\r
-    TempString  += 4;\r
-    PathRemoveLastItem(Path);\r
-    TempSize = StrSize(TempString);\r
-    CopyMem(Path+StrLen(Path), TempString, TempSize);\r
-  }\r
-  if ((TempString = StrStr(Path, L"\\..")) != NULL && *(TempString + 3) == CHAR_NULL) {\r
-    *TempString = CHAR_NULL;\r
-    PathRemoveLastItem(Path);\r
-  }\r
-\r
-  //\r
-  // Fix up the .\r
-  //\r
-  while ((TempString = StrStr(Path, L"\\.\\")) != NULL) {\r
-    *TempString = CHAR_NULL;\r
-    TempString  += 2;\r
-    TempSize = StrSize(TempString);\r
-    CopyMem(Path+StrLen(Path), TempString, TempSize);\r
-  }\r
-  if ((TempString = StrStr(Path, L"\\.")) != NULL && *(TempString + 2) == CHAR_NULL) {\r
-    *(TempString + 1) = CHAR_NULL;\r
-  }\r
-\r
-  while ((TempString = StrStr(Path, L"\\\\")) != NULL) {\r
-    *TempString = CHAR_NULL;\r
-    TempString  += 1;\r
-    TempSize = StrSize(TempString);\r
-    CopyMem(Path+StrLen(Path), TempString, TempSize);\r
-  }\r
-  if ((TempString = StrStr(Path, L"\\\\")) != NULL && *(TempString + 1) == CHAR_NULL) {\r
-    *(TempString) = CHAR_NULL;\r
-  }\r
-\r
-  return (Path);\r
-}\r
-\r
diff --git a/ShellPkg/Library/BasePathLib/BasePathLib.inf b/ShellPkg/Library/BasePathLib/BasePathLib.inf
deleted file mode 100644 (file)
index a9bd6a8..0000000
+++ /dev/null
@@ -1,38 +0,0 @@
-##  @file\r
-#  Provides interface to path manipulation functions.\r
-#\r
-#  Copyright (c) 2011, Intel Corporation. All rights reserved. <BR>\r
-#\r
-#  This program and the accompanying materials\r
-#  are licensed and made available under the terms and conditions of the BSD License\r
-#  which accompanies this distribution. The full text of the license may be found at\r
-#  http://opensource.org/licenses/bsd-license.php\r
-#  THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
-#  WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
-#\r
-#\r
-##\r
-\r
-[Defines]\r
-  INF_VERSION                    = 0x00010006\r
-  BASE_NAME                      = BasePathLib\r
-  FILE_GUID                      = ED244F93-B97A-4a17-83E0-A03CF2A7F7B4\r
-  MODULE_TYPE                    = UEFI_DRIVER\r
-  VERSION_STRING                 = 1.0\r
-  LIBRARY_CLASS                  = PathLib|UEFI_APPLICATION UEFI_DRIVER\r
-\r
-#\r
-#  VALID_ARCHITECTURES           = IA32 X64 IPF EBC\r
-#\r
-\r
-[Sources.common]\r
-  BasePathLib.c\r
-\r
-[Packages]\r
-  MdePkg/MdePkg.dec\r
-  ShellPkg/ShellPkg.dec\r
-  \r
-\r
-[LibraryClasses]\r
-  BaseMemoryLib\r
-  BaseLib
\ No newline at end of file
diff --git a/ShellPkg/Library/BaseSortLib/BaseSortLib.c b/ShellPkg/Library/BaseSortLib/BaseSortLib.c
deleted file mode 100644 (file)
index 0b7e8f3..0000000
+++ /dev/null
@@ -1,239 +0,0 @@
-/** @file\r
-  Library used for sorting routines.\r
-\r
-  Copyright (c) 2009 - 2011, Intel Corporation. All rights reserved. <BR>\r
-  This program and the accompanying materials\r
-  are licensed and made available under the terms and conditions of the BSD License\r
-  which accompanies this distribution.  The full text of the license may be found at\r
-  http://opensource.org/licenses/bsd-license.php\r
-\r
-  THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
-  WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
-\r
-**/\r
-\r
-#include <Uefi.h>\r
-\r
-#include <Library/BaseLib.h>\r
-#include <Library/BaseMemoryLib.h>\r
-#include <Library/DebugLib.h>\r
-#include <Library/MemoryAllocationLib.h>\r
-#include <Library/SortLib.h>\r
-\r
-/**\r
-  Worker function for QuickSorting.  This function is identical to PerformQuickSort,\r
-  except that is uses the pre-allocated buffer so the in place sorting does not need to\r
-  allocate and free buffers constantly.\r
-\r
-  Each element must be equal sized.\r
-\r
-  if BufferToSort is NULL, then ASSERT.\r
-  if CompareFunction is NULL, then ASSERT.\r
-  if Buffer is NULL, then ASSERT.\r
-\r
-  if Count is < 2 then perform no action.\r
-  if Size is < 1 then perform no action.\r
-\r
-  @param[in, out] BufferToSort   on call a Buffer of (possibly sorted) elements\r
-                                 on return a buffer of sorted elements\r
-  @param[in] Count               the number of elements in the buffer to sort\r
-  @param[in] ElementSize         Size of an element in bytes\r
-  @param[in] CompareFunction     The function to call to perform the comparison\r
-                                 of any 2 elements\r
-  @param[in] Buffer              Buffer of size ElementSize for use in swapping\r
-**/\r
-VOID\r
-EFIAPI\r
-QuickSortWorker (\r
-  IN OUT VOID                           *BufferToSort,\r
-  IN CONST UINTN                        Count,\r
-  IN CONST UINTN                        ElementSize,\r
-  IN       SORT_COMPARE                 CompareFunction,\r
-  IN VOID                               *Buffer\r
-  )\r
-{\r
-  VOID        *Pivot;\r
-  UINTN       LoopCount;\r
-  UINTN       NextSwapLocation;\r
-\r
-  ASSERT(BufferToSort     != NULL);\r
-  ASSERT(CompareFunction  != NULL);\r
-  ASSERT(Buffer  != NULL);\r
-\r
-  if ( Count < 2\r
-    || ElementSize  < 1\r
-   ){\r
-    return;\r
-  }\r
-\r
-  NextSwapLocation = 0;\r
-\r
-  //\r
-  // pick a pivot (we choose last element)\r
-  //\r
-  Pivot = ((UINT8*)BufferToSort+((Count-1)*ElementSize));\r
-\r
-  //\r
-  // Now get the pivot such that all on "left" are below it\r
-  // and everything "right" are above it\r
-  //\r
-  for ( LoopCount = 0\r
-      ; LoopCount < Count -1\r
-      ; LoopCount++\r
-     ){\r
-    //\r
-    // if the element is less than the pivot\r
-    //\r
-    if (CompareFunction((VOID*)((UINT8*)BufferToSort+((LoopCount)*ElementSize)),Pivot) <= 0){\r
-      //\r
-      // swap\r
-      //\r
-      CopyMem (Buffer, (UINT8*)BufferToSort+(NextSwapLocation*ElementSize), ElementSize);\r
-      CopyMem ((UINT8*)BufferToSort+(NextSwapLocation*ElementSize), (UINT8*)BufferToSort+((LoopCount)*ElementSize), ElementSize);\r
-      CopyMem ((UINT8*)BufferToSort+((LoopCount)*ElementSize), Buffer, ElementSize);\r
-\r
-      //\r
-      // increment NextSwapLocation\r
-      //\r
-      NextSwapLocation++;\r
-    }\r
-  }\r
-  //\r
-  // swap pivot to it's final position (NextSwapLocaiton)\r
-  //\r
-  CopyMem (Buffer, Pivot, ElementSize);\r
-  CopyMem (Pivot, (UINT8*)BufferToSort+(NextSwapLocation*ElementSize), ElementSize);\r
-  CopyMem ((UINT8*)BufferToSort+(NextSwapLocation*ElementSize), Buffer, ElementSize);\r
-\r
-  //\r
-  // Now recurse on 2 paritial lists.  neither of these will have the 'pivot' element\r
-  // IE list is sorted left half, pivot element, sorted right half...\r
-  //\r
-  if (NextSwapLocation >= 2) {\r
-    QuickSortWorker(\r
-      BufferToSort,\r
-      NextSwapLocation,\r
-      ElementSize,\r
-      CompareFunction,\r
-      Buffer);\r
-  }\r
-\r
-  if ((Count - NextSwapLocation - 1) >= 2) {\r
-    QuickSortWorker(\r
-      (UINT8 *)BufferToSort + (NextSwapLocation+1) * ElementSize,\r
-      Count - NextSwapLocation - 1,\r
-      ElementSize,\r
-      CompareFunction,\r
-      Buffer);\r
-  }\r
-  return;\r
-}\r
-/**\r
-  Function to perform a Quick Sort alogrithm on a buffer of comparable elements.\r
-\r
-  Each element must be equal sized.\r
-\r
-  if BufferToSort is NULL, then ASSERT.\r
-  if CompareFunction is NULL, then ASSERT.\r
-\r
-  if Count is < 2 then perform no action.\r
-  if Size is < 1 then perform no action.\r
-\r
-  @param[in, out] BufferToSort   on call a Buffer of (possibly sorted) elements\r
-                                 on return a buffer of sorted elements\r
-  @param[in] Count               the number of elements in the buffer to sort\r
-  @param[in] ElementSize         Size of an element in bytes\r
-  @param[in] CompareFunction     The function to call to perform the comparison\r
-                                 of any 2 elements\r
-**/\r
-VOID\r
-EFIAPI\r
-PerformQuickSort (\r
-  IN OUT VOID                           *BufferToSort,\r
-  IN CONST UINTN                        Count,\r
-  IN CONST UINTN                        ElementSize,\r
-  IN       SORT_COMPARE                 CompareFunction\r
-  )\r
-{\r
-  VOID  *Buffer;\r
-\r
-  ASSERT(BufferToSort     != NULL);\r
-  ASSERT(CompareFunction  != NULL);\r
-\r
-  Buffer = AllocateZeroPool(ElementSize);\r
-  ASSERT(Buffer != NULL);\r
-\r
-  QuickSortWorker(\r
-    BufferToSort,\r
-    Count,\r
-    ElementSize,\r
-    CompareFunction,\r
-    Buffer);\r
-\r
-  FreePool(Buffer);\r
-  return;\r
-}\r
-\r
-/**\r
-  Not supported in Base version.\r
-\r
-  @param[in] Buffer1  Ignored.\r
-  @param[in] Buffer2  Ignored.\r
-\r
-  ASSERT and return 0.\r
-**/\r
-INTN\r
-EFIAPI\r
-DevicePathCompare (\r
-  IN  CONST VOID             *Buffer1,\r
-  IN  CONST VOID             *Buffer2\r
-  )\r
-{\r
-  ASSERT(FALSE);\r
-  return 0;\r
-}\r
-\r
-/**\r
-  Function to compare 2 strings without regard to case of the characters.\r
-\r
-  @param[in] Buffer1            Pointer to String to compare.\r
-  @param[in] Buffer2            Pointer to second String to compare.\r
-\r
-  @retval 0                     Buffer1 equal to Buffer2.\r
-  @return < 0                   Buffer1 is less than Buffer2.\r
-  @return > 0                   Buffer1 is greater than Buffer2.\r
-**/\r
-INTN\r
-EFIAPI\r
-StringNoCaseCompare (\r
-  IN  CONST VOID             *Buffer1,\r
-  IN  CONST VOID             *Buffer2\r
-  )\r
-{\r
-  ASSERT(FALSE);\r
-  return 0;\r
-}\r
-\r
-\r
-/**\r
-  Function to compare 2 strings.\r
-\r
-  @param[in] Buffer1            Pointer to String to compare (CHAR16**).\r
-  @param[in] Buffer2            Pointer to second String to compare (CHAR16**).\r
-\r
-  @retval 0                     Buffer1 equal to Buffer2.\r
-  @return < 0                   Buffer1 is less than Buffer2.\r
-  @return > 0                   Buffer1 is greater than Buffer2.\r
-**/\r
-INTN\r
-EFIAPI\r
-StringCompare (\r
-  IN  CONST VOID                *Buffer1,\r
-  IN  CONST VOID                *Buffer2\r
-  )\r
-{\r
-  ASSERT(FALSE);\r
-  return 0;\r
-}\r
-\r
-\r
diff --git a/ShellPkg/Library/BaseSortLib/BaseSortLib.inf b/ShellPkg/Library/BaseSortLib/BaseSortLib.inf
deleted file mode 100644 (file)
index 3d2b259..0000000
+++ /dev/null
@@ -1,41 +0,0 @@
-##  @file\r
-#   Library used for sorting routines.\r
-#\r
-#  Copyright (c) 2009 - 2010, Intel Corporation. All rights reserved. <BR>\r
-#\r
-#  This program and the accompanying materials\r
-#  are licensed and made available under the terms and conditions of the BSD License\r
-#  which accompanies this distribution. The full text of the license may be found at\r
-#  http://opensource.org/licenses/bsd-license.php\r
-#  THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
-#  WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
-#\r
-#\r
-##\r
-\r
-[Defines]\r
-  INF_VERSION                    = 0x00010006\r
-  BASE_NAME                      = BaseSortLib\r
-  FILE_GUID                      = 03F3331B-F12D-494f-BF37-E55A657F2497\r
-  MODULE_TYPE                    = UEFI_DRIVER\r
-  VERSION_STRING                 = 1.0\r
-  LIBRARY_CLASS                  = SortLib|UEFI_APPLICATION UEFI_DRIVER\r
-\r
-#\r
-#  VALID_ARCHITECTURES           = IA32 X64 IPF EBC\r
-#\r
-\r
-[Sources.common]\r
-  BaseSortLib.c\r
-\r
-[Packages]\r
-  MdePkg/MdePkg.dec\r
-  ShellPkg/ShellPkg.dec\r
-\r
-[LibraryClasses]\r
-  MemoryAllocationLib\r
-  BaseLib\r
-  BaseMemoryLib\r
-  DebugLib\r
-\r
-\r
diff --git a/ShellPkg/Library/UefiFileHandleLib/UefiFileHandleLib.c b/ShellPkg/Library/UefiFileHandleLib/UefiFileHandleLib.c
deleted file mode 100644 (file)
index 5af75c5..0000000
+++ /dev/null
@@ -1,1155 +0,0 @@
-/** @file\r
-  Provides interface to EFI_FILE_HANDLE functionality.\r
-\r
-  Copyright (c) 2006 - 2014, Intel Corporation. All rights reserved. <BR>\r
-  This program and the accompanying materials\r
-  are licensed and made available under the terms and conditions of the BSD License\r
-  which accompanies this distribution.  The full text of the license may be found at\r
-  http://opensource.org/licenses/bsd-license.php\r
-\r
-  THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
-  WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
-\r
-**/\r
-\r
-#include <Uefi.h>\r
-\r
-#include <Protocol/SimpleFileSystem.h>\r
-#include <Protocol/UnicodeCollation.h>\r
-\r
-#include <Guid/FileInfo.h>\r
-\r
-#include <Library/DebugLib.h>\r
-#include <Library/MemoryAllocationLib.h>\r
-#include <Library/BaseLib.h>\r
-#include <Library/BaseMemoryLib.h>\r
-#include <Library/FileHandleLib.h>\r
-#include <Library/PcdLib.h>\r
-#include <Library/PrintLib.h>\r
-\r
-CONST UINT16 gUnicodeFileTag = EFI_UNICODE_BYTE_ORDER_MARK;\r
-\r
-#define MAX_FILE_NAME_LEN 522 // (20 * (6+5+2))+1) unicode characters from EFI FAT spec (doubled for bytes)\r
-#define FIND_XXXXX_FILE_BUFFER_SIZE (SIZE_OF_EFI_FILE_INFO + MAX_FILE_NAME_LEN)\r
-\r
-/**\r
-  This function will retrieve the information about the file for the handle\r
-  specified and store it in allocated pool memory.\r
-\r
-  This function allocates a buffer to store the file's information. It is the\r
-  caller's responsibility to free the buffer\r
-\r
-  @param  FileHandle  The file handle of the file for which information is\r
-  being requested.\r
-\r
-  @retval NULL information could not be retrieved.\r
-\r
-  @return the information about the file\r
-**/\r
-EFI_FILE_INFO*\r
-EFIAPI\r
-FileHandleGetInfo (\r
-  IN EFI_FILE_HANDLE            FileHandle\r
-  )\r
-{\r
-  EFI_FILE_INFO   *FileInfo;\r
-  UINTN           FileInfoSize;\r
-  EFI_STATUS      Status;\r
-\r
-  if (FileHandle == NULL) {\r
-    return (NULL);\r
-  }\r
-\r
-  //\r
-  // Get the required size to allocate\r
-  //\r
-  FileInfoSize = 0;\r
-  FileInfo = NULL;\r
-  Status = FileHandle->GetInfo(FileHandle,\r
-                               &gEfiFileInfoGuid,\r
-                               &FileInfoSize,\r
-                               NULL);\r
-  if (Status == EFI_BUFFER_TOO_SMALL){\r
-    //\r
-    // error is expected.  getting size to allocate\r
-    //\r
-    FileInfo = AllocateZeroPool(FileInfoSize);\r
-    //\r
-    // now get the information\r
-    //\r
-    Status = FileHandle->GetInfo(FileHandle,\r
-                                 &gEfiFileInfoGuid,\r
-                                 &FileInfoSize,\r
-                                 FileInfo);\r
-    //\r
-    // if we got an error free the memory and return NULL\r
-    //\r
-    if (EFI_ERROR(Status) && (FileInfo != NULL)) {\r
-      FreePool(FileInfo);\r
-      FileInfo = NULL;\r
-    }\r
-  }\r
-  return (FileInfo);\r
-}\r
-\r
-/**\r
-  This function sets the information about the file for the opened handle\r
-  specified.\r
-\r
-  @param[in]  FileHandle        The file handle of the file for which information\r
-                                is being set.\r
-\r
-  @param[in]  FileInfo          The information to set.\r
-\r
-  @retval EFI_SUCCESS           The information was set.\r
-  @retval EFI_INVALID_PARAMETER A parameter was out of range or invalid.\r
-  @retval EFI_UNSUPPORTED       The FileHandle does not support FileInfo.\r
-  @retval EFI_NO_MEDIA          The device has no medium.\r
-  @retval EFI_DEVICE_ERROR      The device reported an error.\r
-  @retval EFI_VOLUME_CORRUPTED  The file system structures are corrupted.\r
-  @retval EFI_WRITE_PROTECTED   The file or medium is write protected.\r
-  @retval EFI_ACCESS_DENIED     The file was opened read only.\r
-  @retval EFI_VOLUME_FULL       The volume is full.\r
-**/\r
-EFI_STATUS\r
-EFIAPI\r
-FileHandleSetInfo (\r
-  IN EFI_FILE_HANDLE            FileHandle,\r
-  IN CONST EFI_FILE_INFO        *FileInfo\r
-  )\r
-{\r
-\r
-  if (FileHandle == NULL || FileInfo == NULL) {\r
-    return (EFI_INVALID_PARAMETER);\r
-  }\r
-\r
-  //\r
-  // Set the info\r
-  //\r
-  return (FileHandle->SetInfo(FileHandle,\r
-                              &gEfiFileInfoGuid,\r
-                              (UINTN)FileInfo->Size,\r
-                              (EFI_FILE_INFO*)FileInfo));\r
-}\r
-\r
-/**\r
-  This function reads information from an opened file.\r
-\r
-  If FileHandle is not a directory, the function reads the requested number of\r
-  bytes from the file at the file's current position and returns them in Buffer.\r
-  If the read goes beyond the end of the file, the read length is truncated to the\r
-  end of the file. The file's current position is increased by the number of bytes\r
-  returned.  If FileHandle is a directory, the function reads the directory entry\r
-  at the file's current position and returns the entry in Buffer. If the Buffer\r
-  is not large enough to hold the current directory entry, then\r
-  EFI_BUFFER_TOO_SMALL is returned and the current file position is not updated.\r
-  BufferSize is set to be the size of the buffer needed to read the entry. On\r
-  success, the current position is updated to the next directory entry. If there\r
-  are no more directory entries, the read returns a zero-length buffer.\r
-  EFI_FILE_INFO is the structure returned as the directory entry.\r
-\r
-  @param FileHandle             the opened file handle\r
-  @param BufferSize             on input the size of buffer in bytes.  on return\r
-                                the number of bytes written.\r
-  @param Buffer                 the buffer to put read data into.\r
-\r
-  @retval EFI_SUCCESS           Data was read.\r
-  @retval EFI_NO_MEDIA          The device has no media.\r
-  @retval EFI_DEVICE_ERROR      The device reported an error.\r
-  @retval EFI_VOLUME_CORRUPTED  The file system structures are corrupted.\r
-  @retval EFI_BUFFER_TO_SMALL   Buffer is too small. ReadSize contains required\r
-                                size.\r
-\r
-**/\r
-EFI_STATUS\r
-EFIAPI\r
-FileHandleRead(\r
-  IN EFI_FILE_HANDLE            FileHandle,\r
-  IN OUT UINTN                  *BufferSize,\r
-  OUT VOID                      *Buffer\r
-  )\r
-{\r
-  if (FileHandle == NULL) {\r
-    return (EFI_INVALID_PARAMETER);\r
-  }\r
-\r
-  //\r
-  // Perform the read based on EFI_FILE_PROTOCOL\r
-  //\r
-  return (FileHandle->Read(FileHandle, BufferSize, Buffer));\r
-}\r
-\r
-\r
-/**\r
-  Write data to a file.\r
-\r
-  This function writes the specified number of bytes to the file at the current\r
-  file position. The current file position is advanced the actual number of bytes\r
-  written, which is returned in BufferSize. Partial writes only occur when there\r
-  has been a data error during the write attempt (such as "volume space full").\r
-  The file is automatically grown to hold the data if required. Direct writes to\r
-  opened directories are not supported.\r
-\r
-  @param FileHandle           The opened file for writing\r
-  @param BufferSize           on input the number of bytes in Buffer.  On output\r
-                              the number of bytes written.\r
-  @param Buffer               the buffer containing data to write is stored.\r
-\r
- @retval EFI_SUCCESS          Data was written.\r
- @retval EFI_UNSUPPORTED      Writes to an open directory are not supported.\r
- @retval EFI_NO_MEDIA         The device has no media.\r
- @retval EFI_DEVICE_ERROR     The device reported an error.\r
- @retval EFI_VOLUME_CORRUPTED The file system structures are corrupted.\r
- @retval EFI_WRITE_PROTECTED  The device is write-protected.\r
- @retval EFI_ACCESS_DENIED    The file was open for read only.\r
- @retval EFI_VOLUME_FULL      The volume is full.\r
-**/\r
-EFI_STATUS\r
-EFIAPI\r
-FileHandleWrite(\r
-  IN EFI_FILE_HANDLE            FileHandle,\r
-  IN OUT UINTN                  *BufferSize,\r
-  IN VOID                       *Buffer\r
-  )\r
-{\r
-  if (FileHandle == NULL) {\r
-    return (EFI_INVALID_PARAMETER);\r
-  }\r
-\r
-  //\r
-  // Perform the write based on EFI_FILE_PROTOCOL\r
-  //\r
-  return (FileHandle->Write(FileHandle, BufferSize, Buffer));\r
-}\r
-\r
-/**\r
-  Close an open file handle.\r
-\r
-  This function closes a specified file handle. All "dirty" cached file data is\r
-  flushed to the device, and the file is closed. In all cases the handle is\r
-  closed.\r
-\r
-@param FileHandle               the file handle to close.\r
-\r
-@retval EFI_SUCCESS             the file handle was closed sucessfully.\r
-**/\r
-EFI_STATUS\r
-EFIAPI\r
-FileHandleClose (\r
-  IN EFI_FILE_HANDLE            FileHandle\r
-  )\r
-{\r
-  EFI_STATUS Status;\r
-\r
-  if (FileHandle == NULL) {\r
-    return (EFI_INVALID_PARAMETER);\r
-  }\r
-\r
-  //\r
-  // Perform the Close based on EFI_FILE_PROTOCOL\r
-  //\r
-  Status = FileHandle->Close(FileHandle);\r
-  return Status;\r
-}\r
-\r
-/**\r
-  Delete a file and close the handle\r
-\r
-  This function closes and deletes a file. In all cases the file handle is closed.\r
-  If the file cannot be deleted, the warning code EFI_WARN_DELETE_FAILURE is\r
-  returned, but the handle is still closed.\r
-\r
-  @param FileHandle             the file handle to delete\r
-\r
-  @retval EFI_SUCCESS           the file was closed sucessfully\r
-  @retval EFI_WARN_DELETE_FAILURE the handle was closed, but the file was not\r
-                                deleted\r
-  @retval INVALID_PARAMETER     One of the parameters has an invalid value.\r
-**/\r
-EFI_STATUS\r
-EFIAPI\r
-FileHandleDelete (\r
-  IN EFI_FILE_HANDLE    FileHandle\r
-  )\r
-{\r
-  EFI_STATUS Status;\r
-\r
-  if (FileHandle == NULL) {\r
-    return (EFI_INVALID_PARAMETER);\r
-  }\r
-\r
-  //\r
-  // Perform the Delete based on EFI_FILE_PROTOCOL\r
-  //\r
-  Status = FileHandle->Delete(FileHandle);\r
-  return Status;\r
-}\r
-\r
-/**\r
-  Set the current position in a file.\r
-\r
-  This function sets the current file position for the handle to the position\r
-  supplied. With the exception of seeking to position 0xFFFFFFFFFFFFFFFF, only\r
-  absolute positioning is supported, and seeking past the end of the file is\r
-  allowed (a subsequent write would grow the file). Seeking to position\r
-  0xFFFFFFFFFFFFFFFF causes the current position to be set to the end of the file.\r
-  If FileHandle is a directory, the only position that may be set is zero. This\r
-  has the effect of starting the read process of the directory entries over.\r
-\r
-  @param FileHandle             The file handle on which the position is being set\r
-  @param Position               Byte position from begining of file\r
-\r
-  @retval EFI_SUCCESS           Operation completed sucessfully.\r
-  @retval EFI_UNSUPPORTED       the seek request for non-zero is not valid on\r
-                                directories.\r
-  @retval INVALID_PARAMETER     One of the parameters has an invalid value.\r
-**/\r
-EFI_STATUS\r
-EFIAPI\r
-FileHandleSetPosition (\r
-  IN EFI_FILE_HANDLE    FileHandle,\r
-  IN UINT64             Position\r
-  )\r
-{\r
-  if (FileHandle == NULL) {\r
-    return (EFI_INVALID_PARAMETER);\r
-  }\r
-\r
-  //\r
-  // Perform the SetPosition based on EFI_FILE_PROTOCOL\r
-  //\r
-  return (FileHandle->SetPosition(FileHandle, Position));\r
-}\r
-\r
-/**\r
-  Gets a file's current position\r
-\r
-  This function retrieves the current file position for the file handle. For\r
-  directories, the current file position has no meaning outside of the file\r
-  system driver and as such the operation is not supported. An error is returned\r
-  if FileHandle is a directory.\r
-\r
-  @param FileHandle             The open file handle on which to get the position.\r
-  @param Position               Byte position from begining of file.\r
-\r
-  @retval EFI_SUCCESS           the operation completed sucessfully.\r
-  @retval INVALID_PARAMETER     One of the parameters has an invalid value.\r
-  @retval EFI_UNSUPPORTED       the request is not valid on directories.\r
-**/\r
-EFI_STATUS\r
-EFIAPI\r
-FileHandleGetPosition (\r
-  IN EFI_FILE_HANDLE            FileHandle,\r
-  OUT UINT64                    *Position\r
-  )\r
-{\r
-  if (Position == NULL || FileHandle == NULL) {\r
-    return (EFI_INVALID_PARAMETER);\r
-  }\r
-\r
-  //\r
-  // Perform the GetPosition based on EFI_FILE_PROTOCOL\r
-  //\r
-  return (FileHandle->GetPosition(FileHandle, Position));\r
-}\r
-/**\r
-  Flushes data on a file\r
-\r
-  This function flushes all modified data associated with a file to a device.\r
-\r
-  @param FileHandle             The file handle on which to flush data\r
-\r
-  @retval EFI_SUCCESS           The data was flushed.\r
-  @retval EFI_NO_MEDIA          The device has no media.\r
-  @retval EFI_DEVICE_ERROR      The device reported an error.\r
-  @retval EFI_VOLUME_CORRUPTED  The file system structures are corrupted.\r
-  @retval EFI_WRITE_PROTECTED   The file or medium is write protected.\r
-  @retval EFI_ACCESS_DENIED     The file was opened for read only.\r
-**/\r
-EFI_STATUS\r
-EFIAPI\r
-FileHandleFlush (\r
-  IN EFI_FILE_HANDLE            FileHandle\r
-  )\r
-{\r
-  if (FileHandle == NULL) {\r
-    return (EFI_INVALID_PARAMETER);\r
-  }\r
-\r
-  //\r
-  // Perform the Flush based on EFI_FILE_PROTOCOL\r
-  //\r
-  return (FileHandle->Flush(FileHandle));\r
-}\r
-\r
-/**\r
-  function to determine if a given handle is a directory handle\r
-\r
-  if DirHandle is NULL then return error\r
-\r
-  open the file information on the DirHandle and verify that the Attribute\r
-  includes EFI_FILE_DIRECTORY bit set.\r
-\r
-  @param DirHandle              Handle to open file\r
-\r
-  @retval EFI_SUCCESS           DirHandle is a directory\r
-  @retval EFI_INVALID_PARAMETER DirHandle did not have EFI_FILE_INFO available\r
-  @retval EFI_NOT_FOUND         DirHandle is not a directory\r
-**/\r
-EFI_STATUS\r
-EFIAPI\r
-FileHandleIsDirectory (\r
-  IN EFI_FILE_HANDLE            DirHandle\r
-  )\r
-{\r
-  EFI_FILE_INFO *DirInfo;\r
-\r
-  if (DirHandle == NULL) {\r
-    return (EFI_INVALID_PARAMETER);\r
-  }\r
-\r
-  //\r
-  // get the file information for DirHandle\r
-  //\r
-  DirInfo = FileHandleGetInfo (DirHandle);\r
-\r
-  //\r
-  // Parse DirInfo\r
-  //\r
-  if (DirInfo == NULL) {\r
-    //\r
-    // We got nothing...\r
-    //\r
-    return (EFI_INVALID_PARAMETER);\r
-  }\r
-  if ((DirInfo->Attribute & EFI_FILE_DIRECTORY) == 0) {\r
-    //\r
-    // Attributes say this is not a directory\r
-    //\r
-    FreePool (DirInfo);\r
-    return (EFI_NOT_FOUND);\r
-  }\r
-  //\r
-  // all good...\r
-  //\r
-  FreePool (DirInfo);\r
-  return (EFI_SUCCESS);\r
-}\r
-\r
-/** Retrieve first entry from a directory.\r
-\r
-  This function takes an open directory handle and gets information from the\r
-  first entry in the directory.  A buffer is allocated to contain\r
-  the information and a pointer to the buffer is returned in *Buffer.  The\r
-  caller can use FileHandleFindNextFile() to get subsequent directory entries.\r
-\r
-  The buffer will be freed by FileHandleFindNextFile() when the last directory\r
-  entry is read.  Otherwise, the caller must free the buffer, using FreePool,\r
-  when finished with it.\r
-\r
-  @param[in]  DirHandle         The file handle of the directory to search.\r
-  @param[out] Buffer            The pointer to pointer to buffer for file's information.\r
-\r
-  @retval EFI_SUCCESS           Found the first file.\r
-  @retval EFI_NOT_FOUND         Cannot find the directory.\r
-  @retval EFI_NO_MEDIA          The device has no media.\r
-  @retval EFI_DEVICE_ERROR      The device reported an error.\r
-  @retval EFI_VOLUME_CORRUPTED  The file system structures are corrupted.\r
-  @return Others                status of FileHandleGetInfo, FileHandleSetPosition,\r
-                                or FileHandleRead\r
-**/\r
-EFI_STATUS\r
-EFIAPI\r
-FileHandleFindFirstFile (\r
-  IN EFI_FILE_HANDLE            DirHandle,\r
-  OUT EFI_FILE_INFO             **Buffer\r
-  )\r
-{\r
-  EFI_STATUS    Status;\r
-  UINTN         BufferSize;\r
-\r
-  if (Buffer == NULL || DirHandle == NULL) {\r
-    return (EFI_INVALID_PARAMETER);\r
-  }\r
-\r
-  //\r
-  // verify that DirHandle is a directory\r
-  //\r
-  Status = FileHandleIsDirectory(DirHandle);\r
-  if (EFI_ERROR(Status)) {\r
-    return (Status);\r
-  }\r
-\r
-  //\r
-  // Allocate a buffer sized to struct size + enough for the string at the end\r
-  //\r
-  BufferSize = FIND_XXXXX_FILE_BUFFER_SIZE;\r
-  *Buffer = AllocateZeroPool(BufferSize);\r
-  if (*Buffer == NULL){\r
-    return (EFI_OUT_OF_RESOURCES);\r
-  }\r
-\r
-  //\r
-  // reset to the begining of the directory\r
-  //\r
-  Status = FileHandleSetPosition(DirHandle, 0);\r
-  if (EFI_ERROR(Status)) {\r
-    FreePool(*Buffer);\r
-    *Buffer = NULL;\r
-    return (Status);\r
-  }\r
-\r
-  //\r
-  // read in the info about the first file\r
-  //\r
-  Status = FileHandleRead (DirHandle, &BufferSize, *Buffer);\r
-  ASSERT(Status != EFI_BUFFER_TOO_SMALL);\r
-  if (EFI_ERROR(Status) || BufferSize == 0) {\r
-    FreePool(*Buffer);\r
-    *Buffer = NULL;\r
-    if (BufferSize == 0) {\r
-      return (EFI_NOT_FOUND);\r
-    }\r
-    return (Status);\r
-  }\r
-  return (EFI_SUCCESS);\r
-}\r
-\r
-/** Retrieve next entries from a directory.\r
-\r
-  To use this function, the caller must first call the FileHandleFindFirstFile()\r
-  function to get the first directory entry.  Subsequent directory entries are\r
-  retrieved by using the FileHandleFindNextFile() function.  This function can\r
-  be called several times to get each entry from the directory.  If the call of\r
-  FileHandleFindNextFile() retrieved the last directory entry, the next call of\r
-  this function will set *NoFile to TRUE and free the buffer.\r
-\r
-  @param[in]  DirHandle         The file handle of the directory.\r
-  @param[out] Buffer            The pointer to buffer for file's information.\r
-  @param[out] NoFile            The pointer to boolean when last file is found.\r
-\r
-  @retval EFI_SUCCESS           Found the next file, or reached last file\r
-  @retval EFI_NO_MEDIA          The device has no media.\r
-  @retval EFI_DEVICE_ERROR      The device reported an error.\r
-  @retval EFI_VOLUME_CORRUPTED  The file system structures are corrupted.\r
-**/\r
-EFI_STATUS\r
-EFIAPI\r
-FileHandleFindNextFile(\r
-  IN EFI_FILE_HANDLE          DirHandle,\r
-  OUT EFI_FILE_INFO          *Buffer,\r
-  OUT BOOLEAN                *NoFile\r
-  )\r
-{\r
-  EFI_STATUS    Status;\r
-  UINTN         BufferSize;\r
-\r
-  if (DirHandle == NULL || Buffer == NULL || NoFile == NULL) {\r
-    return (EFI_INVALID_PARAMETER);\r
-  }\r
-\r
-  //\r
-  // This BufferSize MUST stay equal to the originally allocated one in GetFirstFile\r
-  //\r
-  BufferSize = FIND_XXXXX_FILE_BUFFER_SIZE;\r
-\r
-  //\r
-  // read in the info about the next file\r
-  //\r
-  Status = FileHandleRead (DirHandle, &BufferSize, Buffer);\r
-  ASSERT(Status != EFI_BUFFER_TOO_SMALL);\r
-  if (EFI_ERROR(Status)) {\r
-    return (Status);\r
-  }\r
-\r
-  //\r
-  // If we read 0 bytes (but did not have erros) we already read in the last file.\r
-  //\r
-  if (BufferSize == 0) {\r
-    FreePool(Buffer);\r
-    *NoFile = TRUE;\r
-  }\r
-\r
-  return (EFI_SUCCESS);\r
-}\r
-\r
-/**\r
-  Retrieve the size of a file.\r
-\r
-  if FileHandle is NULL then return error\r
-  if Size is NULL then return error\r
-\r
-  This function extracts the file size info from the FileHandle's EFI_FILE_INFO\r
-  data.\r
-\r
-  @param FileHandle             file handle from which size is retrieved\r
-  @param Size                   pointer to size\r
-\r
-  @retval EFI_SUCCESS           operation was completed sucessfully\r
-  @retval EFI_DEVICE_ERROR      cannot access the file\r
-**/\r
-EFI_STATUS\r
-EFIAPI\r
-FileHandleGetSize (\r
-  IN EFI_FILE_HANDLE            FileHandle,\r
-  OUT UINT64                    *Size\r
-  )\r
-{\r
-  EFI_FILE_INFO                 *FileInfo;\r
-\r
-  if (FileHandle == NULL || Size == NULL) {\r
-    return (EFI_INVALID_PARAMETER);\r
-  }\r
-\r
-  //\r
-  // get the FileInfo structure\r
-  //\r
-  FileInfo = FileHandleGetInfo(FileHandle);\r
-  if (FileInfo == NULL) {\r
-    return (EFI_DEVICE_ERROR);\r
-  }\r
-\r
-  //\r
-  // Assign the Size pointer to the correct value\r
-  //\r
-  *Size = FileInfo->FileSize;\r
-\r
-  //\r
-  // free the FileInfo memory\r
-  //\r
-  FreePool(FileInfo);\r
-\r
-  return (EFI_SUCCESS);\r
-}\r
-\r
-/**\r
-  Set the size of a file.\r
-\r
-  If FileHandle is NULL then return error.\r
-\r
-  This function changes the file size info from the FileHandle's EFI_FILE_INFO\r
-  data.\r
-\r
-  @param FileHandle             File handle whose size is to be changed.\r
-  @param Size                   New size.\r
-\r
-  @retval EFI_SUCCESS           operation was completed sucessfully.\r
-  @retval EFI_DEVICE_ERROR      cannot access the file.\r
-**/\r
-EFI_STATUS\r
-EFIAPI\r
-FileHandleSetSize (\r
-  IN EFI_FILE_HANDLE            FileHandle,\r
-  IN UINT64                     Size\r
-  )\r
-{\r
-  EFI_FILE_INFO                 *FileInfo;\r
-  EFI_STATUS                    Status;\r
-\r
-  if (FileHandle == NULL) {\r
-    return (EFI_INVALID_PARAMETER);\r
-  }\r
-\r
-  //\r
-  // get the FileInfo structure\r
-  //\r
-  FileInfo = FileHandleGetInfo(FileHandle);\r
-  if (FileInfo == NULL) {\r
-    return (EFI_DEVICE_ERROR);\r
-  }\r
-\r
-  //\r
-  // Assign the FileSize pointer to the new value\r
-  //\r
-  FileInfo->FileSize = Size;\r
-\r
-  Status = FileHandleSetInfo(FileHandle, FileInfo);\r
-  //\r
-  // free the FileInfo memory\r
-  //\r
-  FreePool(FileInfo);\r
-\r
-  return (Status);\r
-}\r
-\r
-/**\r
-  Safely append (on the left) with automatic string resizing given length of Destination and\r
-  desired length of copy from Source.\r
-\r
-  append the first D characters of Source to the end of Destination, where D is\r
-  the lesser of Count and the StrLen() of Source. If appending those D characters\r
-  will fit within Destination (whose Size is given as CurrentSize) and\r
-  still leave room for a NULL terminator, then those characters are appended,\r
-  starting at the original terminating NULL of Destination, and a new terminating\r
-  NULL is appended.\r
-\r
-  If appending D characters onto Destination will result in a overflow of the size\r
-  given in CurrentSize the string will be grown such that the copy can be performed\r
-  and CurrentSize will be updated to the new size.\r
-\r
-  If Source is NULL, there is nothing to append, just return the current buffer in\r
-  Destination.\r
-\r
-  if Destination is NULL, then return error\r
-  if Destination's current length (including NULL terminator) is already more then\r
-  CurrentSize, then ASSERT()\r
-\r
-  @param[in, out] Destination   The String to append onto\r
-  @param[in, out] CurrentSize   on call the number of bytes in Destination.  On\r
-                                return possibly the new size (still in bytes).  if NULL\r
-                                then allocate whatever is needed.\r
-  @param[in]      Source        The String to append from\r
-  @param[in]      Count         Maximum number of characters to append.  if 0 then\r
-                                all are appended.\r
-\r
-  @return Destination           return the resultant string.\r
-**/\r
-CHAR16*\r
-EFIAPI\r
-StrnCatGrowLeft (\r
-  IN OUT CHAR16           **Destination,\r
-  IN OUT UINTN            *CurrentSize,\r
-  IN     CONST CHAR16     *Source,\r
-  IN     UINTN            Count\r
-  )\r
-{\r
-  UINTN DestinationStartSize;\r
-  UINTN NewSize;\r
-  UINTN CopySize;\r
-\r
-  if (Destination == NULL) {\r
-    return (NULL);\r
-  }\r
-\r
-  //\r
-  // If there's nothing to do then just return Destination\r
-  //\r
-  if (Source == NULL) {\r
-    return (*Destination);\r
-  }\r
-\r
-  //\r
-  // allow for NULL pointers address as Destination\r
-  //\r
-  if (*Destination != NULL) {\r
-    ASSERT(CurrentSize != 0);\r
-    DestinationStartSize = StrSize(*Destination);\r
-    ASSERT(DestinationStartSize <= *CurrentSize);\r
-  } else {\r
-    DestinationStartSize = 0;\r
-//    ASSERT(*CurrentSize == 0);\r
-  }\r
-\r
-  //\r
-  // Append all of Source?\r
-  //\r
-  if (Count == 0) {\r
-    Count = StrSize(Source);\r
-  }\r
-\r
-  //\r
-  // Test and grow if required\r
-  //\r
-  if (CurrentSize != NULL) {\r
-    NewSize = *CurrentSize;\r
-    while (NewSize < (DestinationStartSize + Count)) {\r
-      NewSize += 2 * Count;\r
-    }\r
-    *Destination = ReallocatePool(*CurrentSize, NewSize, *Destination);\r
-    *CurrentSize = NewSize;\r
-  } else {\r
-    *Destination = AllocateZeroPool(Count+sizeof(CHAR16));\r
-  }\r
-  if (*Destination == NULL) {\r
-    return NULL;\r
-  }\r
-\r
-  CopySize = StrSize(*Destination);\r
-  CopyMem((*Destination)+((Count-2)/sizeof(CHAR16)), *Destination, CopySize);\r
-  CopyMem(*Destination, Source, Count-2);\r
-  return (*Destination);\r
-}\r
-\r
-/**\r
-  Function to get a full filename given a EFI_FILE_HANDLE somewhere lower on the\r
-  directory 'stack'.\r
-\r
-  if Handle is NULL, return EFI_INVALID_PARAMETER\r
-\r
-  @param[in] Handle             Handle to the Directory or File to create path to.\r
-  @param[out] FullFileName      pointer to pointer to generated full file name.  It\r
-                                is the responsibility of the caller to free this memory\r
-                                with a call to FreePool().\r
-  @retval EFI_SUCCESS           the operation was sucessful and the FullFileName is valid.\r
-  @retval EFI_INVALID_PARAMETER Handle was NULL.\r
-  @retval EFI_INVALID_PARAMETER FullFileName was NULL.\r
-  @retval EFI_OUT_OF_RESOURCES  a memory allocation failed.\r
-**/\r
-EFI_STATUS\r
-EFIAPI\r
-FileHandleGetFileName (\r
-  IN CONST EFI_FILE_HANDLE      Handle,\r
-  OUT CHAR16                    **FullFileName\r
-  )\r
-{\r
-  EFI_STATUS      Status;\r
-  UINTN           Size;\r
-  EFI_FILE_HANDLE CurrentHandle;\r
-  EFI_FILE_HANDLE NextHigherHandle;\r
-  EFI_FILE_INFO   *FileInfo;\r
-\r
-  Size = 0;\r
-\r
-  //\r
-  // Check our parameters\r
-  //\r
-  if (FullFileName == NULL || Handle == NULL) {\r
-    return (EFI_INVALID_PARAMETER);\r
-  }\r
-\r
-  *FullFileName = NULL;\r
-  CurrentHandle = NULL;\r
-\r
-  Status = Handle->Open(Handle, &CurrentHandle, L".", EFI_FILE_MODE_READ, 0);\r
-  if (!EFI_ERROR(Status)) {\r
-    //\r
-    // Reverse out the current directory on the device\r
-    //\r
-    for (;;) {\r
-      FileInfo = FileHandleGetInfo(CurrentHandle);\r
-      if (FileInfo == NULL) {\r
-        Status = EFI_OUT_OF_RESOURCES;\r
-        break;\r
-      } else {\r
-        //\r
-        // We got info... do we have a name? if yes preceed the current path with it...\r
-        //\r
-        if (StrLen (FileInfo->FileName) == 0) {\r
-          if (*FullFileName == NULL) {\r
-            ASSERT((*FullFileName == NULL && Size == 0) || (*FullFileName != NULL));\r
-            *FullFileName = StrnCatGrowLeft(FullFileName, &Size, L"\\", 0);\r
-          }\r
-          FreePool(FileInfo);\r
-          break;\r
-        } else {\r
-          if (*FullFileName == NULL) {\r
-            ASSERT((*FullFileName == NULL && Size == 0) || (*FullFileName != NULL));\r
-            *FullFileName = StrnCatGrowLeft(FullFileName, &Size, L"\\", 0);\r
-          }\r
-          ASSERT((*FullFileName == NULL && Size == 0) || (*FullFileName != NULL));\r
-          *FullFileName = StrnCatGrowLeft(FullFileName, &Size, FileInfo->FileName, 0);\r
-          *FullFileName = StrnCatGrowLeft(FullFileName, &Size, L"\\", 0);\r
-          FreePool(FileInfo);\r
-        }\r
-      }\r
-      //\r
-      // Move to the parent directory\r
-      //\r
-      Status = CurrentHandle->Open (CurrentHandle, &NextHigherHandle, L"..", EFI_FILE_MODE_READ, 0);\r
-      if (EFI_ERROR (Status)) {\r
-        break;\r
-      }\r
-\r
-      FileHandleClose(CurrentHandle);\r
-      CurrentHandle = NextHigherHandle;\r
-    }\r
-  } else if (Status == EFI_NOT_FOUND) {\r
-    Status = EFI_SUCCESS;\r
-    ASSERT((*FullFileName == NULL && Size == 0) || (*FullFileName != NULL));\r
-    *FullFileName = StrnCatGrowLeft(FullFileName, &Size, L"\\", 0);\r
-  }\r
-\r
-  if (CurrentHandle != NULL) {\r
-    CurrentHandle->Close (CurrentHandle);\r
-  }\r
-\r
-  if (EFI_ERROR(Status) && *FullFileName != NULL) {\r
-    FreePool(*FullFileName);\r
-  }\r
-\r
-  return (Status);\r
-}\r
-\r
-/**\r
-  Function to read a single line from a file. The \n is not included in the returned\r
-  buffer.  The returned buffer must be callee freed.\r
-\r
-  If the position upon start is 0, then the Ascii Boolean will be set.  This should be\r
-  maintained and not changed for all operations with the same file.\r
-\r
-  @param[in]       Handle        FileHandle to read from.\r
-  @param[in, out]  Ascii         Boolean value for indicating whether the file is Ascii (TRUE) or UCS2 (FALSE);\r
-\r
-  @return                       The line of text from the file.\r
-\r
-  @sa FileHandleReadLine\r
-**/\r
-CHAR16*\r
-EFIAPI\r
-FileHandleReturnLine(\r
-  IN EFI_FILE_HANDLE            Handle,\r
-  IN OUT BOOLEAN                *Ascii\r
-  )\r
-{\r
-  CHAR16          *RetVal;\r
-  UINTN           Size;\r
-  EFI_STATUS      Status;\r
-\r
-  Size = 0;\r
-  RetVal = NULL;\r
-\r
-  Status = FileHandleReadLine(Handle, RetVal, &Size, FALSE, Ascii);\r
-  if (Status == EFI_BUFFER_TOO_SMALL) {\r
-    RetVal = AllocateZeroPool(Size);\r
-    Status = FileHandleReadLine(Handle, RetVal, &Size, FALSE, Ascii);\r
-  }\r
-  ASSERT_EFI_ERROR(Status);\r
-  if (EFI_ERROR(Status) && (RetVal != NULL)) {\r
-    FreePool(RetVal);\r
-    RetVal = NULL;\r
-  }\r
-  return (RetVal);\r
-}\r
-\r
-/**\r
-  Function to read a single line (up to but not including the \n) from a EFI_FILE_HANDLE.\r
-\r
-  If the position upon start is 0, then the Ascii Boolean will be set.  This should be\r
-  maintained and not changed for all operations with the same file.\r
-\r
-  @param[in]       Handle        FileHandle to read from\r
-  @param[in, out]  Buffer        pointer to buffer to read into\r
-  @param[in, out]  Size          pointer to number of bytes in buffer\r
-  @param[in]       Truncate      if TRUE then allows for truncation of the line to fit.\r
-                                 if FALSE will reset the position to the begining of the\r
-                                 line if the buffer is not large enough.\r
-  @param[in, out]  Ascii         Boolean value for indicating whether the file is Ascii (TRUE) or UCS2 (FALSE);\r
-\r
-  @retval EFI_SUCCESS           the operation was sucessful.  the line is stored in\r
-                                Buffer.\r
-  @retval EFI_INVALID_PARAMETER Handle was NULL.\r
-  @retval EFI_INVALID_PARAMETER Size was NULL.\r
-  @retval EFI_BUFFER_TOO_SMALL  Size was not enough space to store the line.\r
-                                Size was updated to minimum space required.\r
-  @sa FileHandleRead\r
-**/\r
-EFI_STATUS\r
-EFIAPI\r
-FileHandleReadLine(\r
-  IN EFI_FILE_HANDLE            Handle,\r
-  IN OUT CHAR16                 *Buffer,\r
-  IN OUT UINTN                  *Size,\r
-  IN BOOLEAN                    Truncate,\r
-  IN OUT BOOLEAN                *Ascii\r
-  )\r
-{\r
-  EFI_STATUS  Status;\r
-  CHAR16      CharBuffer;\r
-  UINTN       CharSize;\r
-  UINTN       CountSoFar;\r
-  UINT64      OriginalFilePosition;\r
-\r
-\r
-  if (Handle == NULL\r
-    ||Size   == NULL\r
-    ||(Buffer==NULL&&*Size!=0)\r
-   ){\r
-    return (EFI_INVALID_PARAMETER);\r
-  }\r
-  if (Buffer != NULL) {\r
-    *Buffer = CHAR_NULL;\r
-  }\r
-  FileHandleGetPosition(Handle, &OriginalFilePosition);\r
-  if (OriginalFilePosition == 0) {\r
-    CharSize = sizeof(CHAR16);\r
-    Status = FileHandleRead(Handle, &CharSize, &CharBuffer);\r
-    ASSERT_EFI_ERROR(Status);\r
-    if (CharBuffer == gUnicodeFileTag) {\r
-      *Ascii = FALSE;\r
-    } else {\r
-      *Ascii = TRUE;\r
-      FileHandleSetPosition(Handle, OriginalFilePosition);\r
-    }\r
-  }\r
-\r
-  for (CountSoFar = 0;;CountSoFar++){\r
-    CharBuffer = 0;\r
-    if (*Ascii) {\r
-      CharSize = sizeof(CHAR8);\r
-    } else {\r
-      CharSize = sizeof(CHAR16);\r
-    }\r
-    Status = FileHandleRead(Handle, &CharSize, &CharBuffer);\r
-    if (  EFI_ERROR(Status)\r
-       || CharSize == 0\r
-       || (CharBuffer == L'\n' && !(*Ascii))\r
-       || (CharBuffer ==  '\n' && *Ascii)\r
-     ){\r
-      break;\r
-    }\r
-    //\r
-    // if we have space save it...\r
-    //\r
-    if ((CountSoFar+1)*sizeof(CHAR16) < *Size){\r
-      ASSERT(Buffer != NULL);\r
-      ((CHAR16*)Buffer)[CountSoFar] = CharBuffer;\r
-      ((CHAR16*)Buffer)[CountSoFar+1] = CHAR_NULL;\r
-    }\r
-  }\r
-\r
-  //\r
-  // if we ran out of space tell when...\r
-  //\r
-  if ((CountSoFar+1)*sizeof(CHAR16) > *Size){\r
-    *Size = (CountSoFar+1)*sizeof(CHAR16);\r
-    if (!Truncate) {\r
-      FileHandleSetPosition(Handle, OriginalFilePosition);\r
-    } else {\r
-      DEBUG((DEBUG_WARN, "The line was truncated in FileHandleReadLine"));\r
-    }\r
-    return (EFI_BUFFER_TOO_SMALL);\r
-  }\r
-  while(Buffer[StrLen(Buffer)-1] == L'\r') {\r
-    Buffer[StrLen(Buffer)-1] = CHAR_NULL;\r
-  }\r
-\r
-  return (Status);\r
-}\r
-\r
-/**\r
-  function to write a line of unicode text to a file.\r
-\r
-  if Handle is NULL, return error.\r
-  if Buffer is NULL, do nothing.  (return SUCCESS)\r
-\r
-  @param[in]     Handle         FileHandle to write to\r
-  @param[in]     Buffer         Buffer to write\r
-\r
-  @retval  EFI_SUCCESS          the data was written.\r
-  @retval  other                failure.\r
-\r
-  @sa FileHandleWrite\r
-**/\r
-EFI_STATUS\r
-EFIAPI\r
-FileHandleWriteLine(\r
-  IN EFI_FILE_HANDLE Handle,\r
-  IN CHAR16          *Buffer\r
-  )\r
-{\r
-  EFI_STATUS Status;\r
-  UINTN      Size;\r
-\r
-  if (Buffer == NULL) {\r
-    return (EFI_SUCCESS);\r
-  }\r
-\r
-  if (Handle == NULL) {\r
-    return (EFI_INVALID_PARAMETER);\r
-  }\r
-\r
-  Size = StrSize(Buffer) - sizeof(Buffer[0]);\r
-  Status = FileHandleWrite(Handle, &Size, Buffer);\r
-  if (EFI_ERROR(Status)) {\r
-    return (Status);\r
-  }\r
-  Size = StrSize(L"\r\n") - sizeof(CHAR16);\r
-  return FileHandleWrite(Handle, &Size, L"\r\n");\r
-}\r
-\r
-/**\r
-  function to take a formatted argument and print it to a file.\r
-\r
-  @param[in] Handle   the file handle for the file to write to\r
-  @param[in] Format   the format argument (see printlib for format specifier)\r
-  @param[in] ...      the variable arguments for the format\r
-\r
-  @retval EFI_SUCCESS the operation was sucessful\r
-  @return other       a return value from FileHandleWriteLine\r
-\r
-  @sa FileHandleWriteLine\r
-**/\r
-EFI_STATUS\r
-EFIAPI\r
-FileHandlePrintLine(\r
-  IN EFI_FILE_HANDLE  Handle,\r
-  IN CONST CHAR16     *Format,\r
-  ...\r
-  )\r
-{\r
-  VA_LIST           Marker;\r
-  CHAR16            *Buffer;\r
-  EFI_STATUS        Status;\r
-\r
-  //\r
-  // Get a buffer to print into\r
-  //\r
-  Buffer = AllocateZeroPool (PcdGet16 (PcdShellPrintBufferSize));\r
-  if (Buffer == NULL) {\r
-    return (EFI_OUT_OF_RESOURCES);\r
-  }\r
-\r
-  //\r
-  // Print into our buffer\r
-  //\r
-  VA_START (Marker, Format);\r
-  UnicodeVSPrint (Buffer, PcdGet16 (PcdShellPrintBufferSize), Format, Marker);\r
-  VA_END (Marker);\r
-\r
-  //\r
-  // Print buffer into file\r
-  //\r
-  Status = FileHandleWriteLine(Handle, Buffer);\r
-\r
-  //\r
-  // Cleanup and return\r
-  //\r
-  FreePool(Buffer);\r
-  return (Status);\r
-}\r
-\r
-/**\r
-  Function to determine if a FILE_HANDLE is at the end of the file.\r
-\r
-  This will NOT work on directories.\r
-\r
-  If Handle is NULL, then return False.\r
-\r
-  @param[in] Handle     the file handle\r
-\r
-  @retval TRUE          the position is at the end of the file\r
-  @retval FALSE         the position is not at the end of the file\r
-**/\r
-BOOLEAN\r
-EFIAPI\r
-FileHandleEof(\r
-  IN EFI_FILE_HANDLE Handle\r
-  )\r
-{\r
-  EFI_FILE_INFO *Info;\r
-  UINT64        Pos;\r
-  BOOLEAN       RetVal;\r
-\r
-  if (Handle == NULL) {\r
-    return (FALSE);\r
-  }\r
-\r
-  FileHandleGetPosition(Handle, &Pos);\r
-  Info = FileHandleGetInfo (Handle);\r
-\r
-  if (Info == NULL) {\r
-    return (FALSE);\r
-  }\r
-\r
-  FileHandleSetPosition(Handle, Pos);\r
-\r
-  if (Pos == Info->FileSize) {\r
-    RetVal = TRUE;\r
-  } else {\r
-    RetVal = FALSE;\r
-  }\r
-\r
-  FreePool (Info);\r
-\r
-  return (RetVal);\r
-}\r
diff --git a/ShellPkg/Library/UefiFileHandleLib/UefiFileHandleLib.inf b/ShellPkg/Library/UefiFileHandleLib/UefiFileHandleLib.inf
deleted file mode 100644 (file)
index 1d27c6d..0000000
+++ /dev/null
@@ -1,50 +0,0 @@
-##  @file\r
-# Provides interface to shell functionality for shell commands and applications.\r
-#\r
-# Copyright (c) 2006 - 2010, Intel Corporation. All rights reserved. <BR>\r
-#\r
-#  This program and the accompanying materials\r
-#  are licensed and made available under the terms and conditions of the BSD License\r
-#  which accompanies this distribution. The full text of the license may be found at\r
-#  http://opensource.org/licenses/bsd-license.php\r
-#  THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
-#  WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
-#\r
-#\r
-##\r
-\r
-[Defines]\r
-  INF_VERSION                    = 0x00010006\r
-  BASE_NAME                      = BaseFileHandleLib\r
-  FILE_GUID                      = 9495D344-9D8A-41f3-8D17-E2FD238C4E71\r
-  MODULE_TYPE                    = DXE_DRIVER\r
-  VERSION_STRING                 = 1.0\r
-  LIBRARY_CLASS                  = FileHandleLib|DXE_DRIVER UEFI_APPLICATION UEFI_DRIVER DXE_RUNTIME_DRIVER\r
-\r
-#\r
-#  VALID_ARCHITECTURES           = IA32 X64 IPF EBC\r
-#\r
-\r
-[Sources.common]\r
-  UefiFileHandleLib.c\r
-\r
-[Packages]\r
-  MdePkg/MdePkg.dec\r
-  ShellPkg/ShellPkg.dec\r
-\r
-[LibraryClasses]\r
-  MemoryAllocationLib\r
-  BaseLib\r
-  BaseMemoryLib\r
-  DebugLib\r
-  PrintLib\r
-  PcdLib\r
-\r
-[Protocols]\r
-  gEfiSimpleFileSystemProtocolGuid             # ALWAYS_USED\r
-\r
-[Guids]\r
-  gEfiFileInfoGuid                              # ALWAYS_CONSUMED\r
-\r
-[Pcd.common]\r
-  gEfiShellPkgTokenSpaceGuid.PcdShellPrintBufferSize # ALWAYS_CONSUMED\r
index 791b1aed8faa06bd8352ad69a4a2f191a4b5581f..5d9ccdd9444ccc594d20b78e9177d693cc35b309 100644 (file)
@@ -2,7 +2,7 @@
   Main file for If and else shell level 1 function.\r
 \r
   Copyright (c) 2013, Hewlett-Packard Development Company, L.P.\r
-  Copyright (c) 2009 - 2011, Intel Corporation. All rights reserved.<BR>\r
+  Copyright (c) 2009 - 2014, Intel Corporation. All rights reserved.<BR>\r
   This program and the accompanying materials\r
   are licensed and made available under the terms and conditions of the BSD License\r
   which accompanies this distribution.  The full text of the license may be found at\r
@@ -15,7 +15,6 @@
 \r
 #include "UefiShellLevel1CommandsLib.h"\r
 #include <Library/PrintLib.h>\r
-#include <Library/PathLib.h>\r
 \r
 typedef enum {\r
   EndTagOr,\r
index 02b1627b4ff13b2b529d86ade784dfa021ff57ff..617fc50197d4c1dd50f3d3257618def9d039f842 100644 (file)
@@ -50,7 +50,6 @@
   UefiBootServicesTableLib\r
   SortLib\r
   PrintLib\r
-  PathLib\r
 \r
 [Pcd.common]\r
   gEfiShellPkgTokenSpaceGuid.PcdShellSupportLevel # ALWAYS_CONSUMED\r
index f1549b91627947bd6a1eec9b79d93145d514d243..05582da3ca8dcb76694428d315f2fb0d84ed3575 100644 (file)
@@ -47,7 +47,6 @@
 #include <Library/HiiLib.h>\r
 #include <Library/SortLib.h>\r
 #include <Library/FileHandleLib.h>\r
-#include <Library/PathLib.h>\r
 \r
 extern CONST  CHAR16                            mFileName[];\r
 extern        EFI_HANDLE                        gShellLevel2HiiHandle;\r
index 52844429eaff88be10f71e65763c93e2d63148e2..7060c7738f06376997c091ffc5a6fe68e04d38bb 100644 (file)
@@ -1,7 +1,7 @@
 ##  @file\r
 # Provides shell level 2 functions\r
 #\r
-# Copyright (c) 2009 - 2013, Intel Corporation. All rights reserved. <BR>\r
+# Copyright (c) 2009 - 2014, Intel Corporation. All rights reserved. <BR>\r
 #\r
 #  This program and the accompanying materials\r
 #  are licensed and made available under the terms and conditions of the BSD License\r
@@ -64,7 +64,6 @@
   PcdLib\r
   HiiLib\r
   HandleParsingLib\r
-  PathLib\r
   DevicePathLib\r
 \r
 [Protocols]\r
@@ -82,4 +81,4 @@
 [Guids]\r
   gEfiFileSystemInfoGuid\r
   gEfiFileInfoGuid\r
-  gShellLevel2HiiGuid
\ No newline at end of file
+  gShellLevel2HiiGuid\r
diff --git a/ShellPkg/Library/UefiSortLib/UefiSortLib.c b/ShellPkg/Library/UefiSortLib/UefiSortLib.c
deleted file mode 100644 (file)
index 2aab9d2..0000000
+++ /dev/null
@@ -1,316 +0,0 @@
-/** @file\r
-  Library used for sorting routines.\r
-\r
-  Copyright (c) 2009 - 2011, Intel Corporation. All rights reserved. <BR>\r
-  This program and the accompanying materials\r
-  are licensed and made available under the terms and conditions of the BSD License\r
-  which accompanies this distribution.  The full text of the license may be found at\r
-  http://opensource.org/licenses/bsd-license.php\r
-\r
-  THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
-  WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
-\r
-**/\r
-\r
-#include <Uefi.h>\r
-#include <ShellBase.h>\r
-\r
-#include <Protocol/UnicodeCollation.h>\r
-#include <Protocol/DevicePath.h>\r
-\r
-#include <Library/UefiBootServicesTableLib.h>\r
-#include <Library/BaseLib.h>\r
-#include <Library/BaseMemoryLib.h>\r
-#include <Library/DebugLib.h>\r
-#include <Library/MemoryAllocationLib.h>\r
-#include <Library/SortLib.h>\r
-#include <Library/DevicePathLib.h>\r
-\r
-STATIC EFI_UNICODE_COLLATION_PROTOCOL   *mUnicodeCollation = NULL;\r
-\r
-\r
-/**\r
-  Worker function for QuickSorting.  This function is identical to PerformQuickSort,\r
-  except that is uses the pre-allocated buffer so the in place sorting does not need to\r
-  allocate and free buffers constantly.\r
-\r
-  Each element must be equal sized.\r
-\r
-  if BufferToSort is NULL, then ASSERT.\r
-  if CompareFunction is NULL, then ASSERT.\r
-  if Buffer is NULL, then ASSERT.\r
-\r
-  if Count is < 2 then perform no action.\r
-  if Size is < 1 then perform no action.\r
-\r
-  @param[in, out] BufferToSort   on call a Buffer of (possibly sorted) elements\r
-                                 on return a buffer of sorted elements\r
-  @param[in] Count               the number of elements in the buffer to sort\r
-  @param[in] ElementSize         Size of an element in bytes\r
-  @param[in] CompareFunction     The function to call to perform the comparison\r
-                                 of any 2 elements\r
-  @param[in] Buffer              Buffer of size ElementSize for use in swapping\r
-**/\r
-VOID\r
-EFIAPI\r
-QuickSortWorker (\r
-  IN OUT VOID                           *BufferToSort,\r
-  IN CONST UINTN                        Count,\r
-  IN CONST UINTN                        ElementSize,\r
-  IN       SORT_COMPARE                 CompareFunction,\r
-  IN VOID                               *Buffer\r
-  )\r
-{\r
-  VOID        *Pivot;\r
-  UINTN       LoopCount;\r
-  UINTN       NextSwapLocation;\r
-\r
-  ASSERT(BufferToSort     != NULL);\r
-  ASSERT(CompareFunction  != NULL);\r
-  ASSERT(Buffer  != NULL);\r
-\r
-  if ( Count < 2\r
-    || ElementSize  < 1\r
-   ){\r
-    return;\r
-  }\r
-\r
-  NextSwapLocation = 0;\r
-\r
-  //\r
-  // pick a pivot (we choose last element)\r
-  //\r
-  Pivot = ((UINT8*)BufferToSort+((Count-1)*ElementSize));\r
-\r
-  //\r
-  // Now get the pivot such that all on "left" are below it\r
-  // and everything "right" are above it\r
-  //\r
-  for ( LoopCount = 0\r
-      ; LoopCount < Count -1\r
-      ; LoopCount++\r
-     ){\r
-    //\r
-    // if the element is less than the pivot\r
-    //\r
-    if (CompareFunction((VOID*)((UINT8*)BufferToSort+((LoopCount)*ElementSize)),Pivot) <= 0){\r
-      //\r
-      // swap\r
-      //\r
-      CopyMem (Buffer, (UINT8*)BufferToSort+(NextSwapLocation*ElementSize), ElementSize);\r
-      CopyMem ((UINT8*)BufferToSort+(NextSwapLocation*ElementSize), (UINT8*)BufferToSort+((LoopCount)*ElementSize), ElementSize);\r
-      CopyMem ((UINT8*)BufferToSort+((LoopCount)*ElementSize), Buffer, ElementSize);\r
-\r
-      //\r
-      // increment NextSwapLocation\r
-      //\r
-      NextSwapLocation++;\r
-    }\r
-  }\r
-  //\r
-  // swap pivot to it's final position (NextSwapLocaiton)\r
-  //\r
-  CopyMem (Buffer, Pivot, ElementSize);\r
-  CopyMem (Pivot, (UINT8*)BufferToSort+(NextSwapLocation*ElementSize), ElementSize);\r
-  CopyMem ((UINT8*)BufferToSort+(NextSwapLocation*ElementSize), Buffer, ElementSize);\r
-\r
-  //\r
-  // Now recurse on 2 paritial lists.  neither of these will have the 'pivot' element\r
-  // IE list is sorted left half, pivot element, sorted right half...\r
-  //\r
-  if (NextSwapLocation >= 2) {\r
-    QuickSortWorker(\r
-      BufferToSort,\r
-      NextSwapLocation,\r
-      ElementSize,\r
-      CompareFunction,\r
-      Buffer);\r
-  }\r
-\r
-  if ((Count - NextSwapLocation - 1) >= 2) {\r
-    QuickSortWorker(\r
-      (UINT8 *)BufferToSort + (NextSwapLocation+1) * ElementSize,\r
-      Count - NextSwapLocation - 1,\r
-      ElementSize,\r
-      CompareFunction,\r
-      Buffer);\r
-  }\r
-\r
-  return;\r
-}\r
-/**\r
-  Function to perform a Quick Sort alogrithm on a buffer of comparable elements.\r
-\r
-  Each element must be equal sized.\r
-\r
-  if BufferToSort is NULL, then ASSERT.\r
-  if CompareFunction is NULL, then ASSERT.\r
-\r
-  if Count is < 2 then perform no action.\r
-  if Size is < 1 then perform no action.\r
-\r
-  @param[in, out] BufferToSort   on call a Buffer of (possibly sorted) elements\r
-                                 on return a buffer of sorted elements\r
-  @param[in] Count               the number of elements in the buffer to sort\r
-  @param[in] ElementSize         Size of an element in bytes\r
-  @param[in] CompareFunction     The function to call to perform the comparison\r
-                                 of any 2 elements\r
-**/\r
-VOID\r
-EFIAPI\r
-PerformQuickSort (\r
-  IN OUT VOID                           *BufferToSort,\r
-  IN CONST UINTN                        Count,\r
-  IN CONST UINTN                        ElementSize,\r
-  IN       SORT_COMPARE                 CompareFunction\r
-  )\r
-{\r
-  VOID  *Buffer;\r
-\r
-  ASSERT(BufferToSort     != NULL);\r
-  ASSERT(CompareFunction  != NULL);\r
-\r
-  Buffer = AllocateZeroPool(ElementSize);\r
-  ASSERT(Buffer != NULL);\r
-\r
-  QuickSortWorker(\r
-    BufferToSort,\r
-    Count,\r
-    ElementSize,\r
-    CompareFunction,\r
-    Buffer);\r
-\r
-  FreePool(Buffer);\r
-  return;\r
-}\r
-\r
-/**\r
-  Function to compare 2 device paths for use in QuickSort.\r
-\r
-  @param[in] Buffer1            pointer to Device Path poiner to compare\r
-  @param[in] Buffer2            pointer to second DevicePath pointer to compare\r
-\r
-  @retval 0                     Buffer1 equal to Buffer2\r
-  @return < 0                   Buffer1 is less than Buffer2\r
-  @return > 0                   Buffer1 is greater than Buffer2\r
-**/\r
-INTN\r
-EFIAPI\r
-DevicePathCompare (\r
-  IN  CONST VOID             *Buffer1,\r
-  IN  CONST VOID             *Buffer2\r
-  )\r
-{\r
-  EFI_DEVICE_PATH_PROTOCOL  *DevicePath1;\r
-  EFI_DEVICE_PATH_PROTOCOL  *DevicePath2;\r
-  CHAR16                    *TextPath1;\r
-  CHAR16                    *TextPath2;\r
-  EFI_STATUS                Status;\r
-  INTN                      RetVal;\r
-\r
-  DevicePath1 = *(EFI_DEVICE_PATH_PROTOCOL**)Buffer1;\r
-  DevicePath2 = *(EFI_DEVICE_PATH_PROTOCOL**)Buffer2;\r
-\r
-  if (DevicePath1 == NULL) {\r
-    if (DevicePath2 == NULL) {\r
-      return 0;\r
-    }\r
-\r
-    return -1;\r
-  }\r
-\r
-  if (DevicePath2 == NULL) {\r
-    return 1;\r
-  }\r
-\r
-  if (mUnicodeCollation == NULL) {\r
-    Status = gBS->LocateProtocol(\r
-      &gEfiUnicodeCollation2ProtocolGuid,\r
-      NULL,\r
-      (VOID**)&mUnicodeCollation);\r
-\r
-    ASSERT_EFI_ERROR(Status);\r
-  }\r
-\r
-  TextPath1 = ConvertDevicePathToText(\r
-    DevicePath1,\r
-    FALSE,\r
-    FALSE);\r
-\r
-  TextPath2 = ConvertDevicePathToText(\r
-    DevicePath2,\r
-    FALSE,\r
-    FALSE);\r
-\r
-  if (TextPath1 == NULL) {\r
-    RetVal = -1;\r
-  } else if (TextPath2 == NULL) {\r
-    RetVal = 1;\r
-  } else {\r
-    RetVal = mUnicodeCollation->StriColl(\r
-      mUnicodeCollation,\r
-      TextPath1,\r
-      TextPath2);\r
-  }\r
-\r
-  SHELL_FREE_NON_NULL(TextPath1);\r
-  SHELL_FREE_NON_NULL(TextPath2);\r
-\r
-  return (RetVal);\r
-}\r
-\r
-/**\r
-  Function to compare 2 strings without regard to case of the characters.\r
-\r
-  @param[in] Buffer1            Pointer to String to compare.\r
-  @param[in] Buffer2            Pointer to second String to compare.\r
-\r
-  @retval 0                     Buffer1 equal to Buffer2.\r
-  @return < 0                   Buffer1 is less than Buffer2.\r
-  @return > 0                   Buffer1 is greater than Buffer2.\r
-**/\r
-INTN\r
-EFIAPI\r
-StringNoCaseCompare (\r
-  IN  CONST VOID             *Buffer1,\r
-  IN  CONST VOID             *Buffer2\r
-  )\r
-{\r
-  EFI_STATUS                Status;\r
-  if (mUnicodeCollation == NULL) {\r
-    Status = gBS->LocateProtocol(\r
-      &gEfiUnicodeCollation2ProtocolGuid,\r
-      NULL,\r
-      (VOID**)&mUnicodeCollation);\r
-\r
-    ASSERT_EFI_ERROR(Status);\r
-  }\r
-\r
-  return (mUnicodeCollation->StriColl(\r
-    mUnicodeCollation,\r
-    *(CHAR16**)Buffer1,\r
-    *(CHAR16**)Buffer2));\r
-}\r
-\r
-\r
-/**\r
-  Function to compare 2 strings.\r
-\r
-  @param[in] Buffer1            Pointer to String to compare (CHAR16**).\r
-  @param[in] Buffer2            Pointer to second String to compare (CHAR16**).\r
-\r
-  @retval 0                     Buffer1 equal to Buffer2.\r
-  @return < 0                   Buffer1 is less than Buffer2.\r
-  @return > 0                   Buffer1 is greater than Buffer2.\r
-**/\r
-INTN\r
-EFIAPI\r
-StringCompare (\r
-  IN  CONST VOID                *Buffer1,\r
-  IN  CONST VOID                *Buffer2\r
-  )\r
-{\r
-  return (StrCmp(\r
-    *(CHAR16**)Buffer1,\r
-    *(CHAR16**)Buffer2));\r
-}\r
diff --git a/ShellPkg/Library/UefiSortLib/UefiSortLib.inf b/ShellPkg/Library/UefiSortLib/UefiSortLib.inf
deleted file mode 100644 (file)
index b227b3b..0000000
+++ /dev/null
@@ -1,46 +0,0 @@
-##  @file\r
-#   Library used for sorting routines.\r
-#\r
-#  Copyright (c) 2009 - 2013, Intel Corporation. All rights reserved. <BR>\r
-#\r
-#  This program and the accompanying materials\r
-#  are licensed and made available under the terms and conditions of the BSD License\r
-#  which accompanies this distribution. The full text of the license may be found at\r
-#  http://opensource.org/licenses/bsd-license.php\r
-#  THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
-#  WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
-#\r
-#\r
-##\r
-\r
-[Defines]\r
-  INF_VERSION                    = 0x00010006\r
-  BASE_NAME                      = UefiSortLib\r
-  FILE_GUID                      = 4264A823-45A3-42db-B92C-AA078555CBD3\r
-  MODULE_TYPE                    = UEFI_DRIVER\r
-  VERSION_STRING                 = 1.0\r
-  LIBRARY_CLASS                  = SortLib|UEFI_APPLICATION UEFI_DRIVER UEFI_DRIVER DXE_RUNTIME_DRIVER DXE_DRIVER\r
-\r
-#\r
-#  VALID_ARCHITECTURES           = IA32 X64 IPF EBC\r
-#\r
-\r
-[Sources.common]\r
-  UefiSortLib.c\r
-\r
-[Packages]\r
-  MdePkg/MdePkg.dec\r
-  ShellPkg/ShellPkg.dec\r
-\r
-[LibraryClasses]\r
-  MemoryAllocationLib\r
-  BaseLib\r
-  BaseMemoryLib\r
-  DebugLib\r
-  UefiBootServicesTableLib\r
-  DevicePathLib\r
-\r
-[Protocols]\r
-  gEfiUnicodeCollation2ProtocolGuid                       # ALWAYS_CONSUMED\r
-  gEfiDevicePathProtocolGuid                              # ALWAYS_CONSUMED\r
-\r
index a99f9a688d22df08d21584bcb7e99be01175fb5d..0fece091230af6b8280b1d69c538dd4ee050029b 100644 (file)
@@ -18,8 +18,8 @@
 [Defines]\r
   DEC_SPECIFICATION              = 0x00010005\r
   PACKAGE_NAME                   = ShellPkg\r
-  PACKAGE_GUID                   = 9FB7587C-93F7-40a7-9C04-FD7BA94EE646\r
-  PACKAGE_VERSION                = 0.50\r
+  PACKAGE_GUID                   = C1014BB7-4092-43D4-984F-0738EB424DBF\r
+  PACKAGE_VERSION                = 1.0\r
 \r
 [Includes]\r
   Include\r
   ##  @libraryclass  Provides shell internal support Only available for shell internal commands\r
   ShellCommandLib|Include/Library/ShellCommandLib.h\r
 \r
-  ##  @libraryclass  provides EFI_FILE_HANDLE services used by Shell and ShellLib\r
-  FileHandleLib|Include/Library/FileHandleLib.h\r
-\r
   ## @libraryclass   Allows for a shell application to have a C style entry point\r
   ShellCEntryLib|Include/Library/ShellCEntryLib.h\r
 \r
-  ## @libraryclass   Provides sorting functions\r
-  SortLib|Include/Library/SortLib.h\r
-\r
   ## @libraryclass   Provides advanced parsing functions\r
   HandleParsingLib|Include/Library/HandleParsingLib.h\r
 \r
-  ## @libraryclass   Provides path manipulation functions\r
-  PathLib|Include/Library/PathLib.h\r
-\r
   ## @libraryclass   provides BCFG command\r
   BcfgCommandLib|Include/Library/BcfgCommandLib.h\r
 \r
@@ -91,7 +82,7 @@
   #  This should be FALSE for compiling the shell application itself only.\r
   gEfiShellPkgTokenSpaceGuid.PcdShellLibAutoInitialize|TRUE|BOOLEAN|0x00000005\r
 \r
-  ## This is the max buffer for ShellLib, FileHandleLib, and internal Shell printings.\r
+  ## This is the max buffer for ShellLib and internal Shell printings.\r
   gEfiShellPkgTokenSpaceGuid.PcdShellPrintBufferSize|16000|UINT16|0x0000000C\r
 \r
   ## This flag is used to control the commands available in the shell\r
index 75a50ddd693c0f9f01d08e9d53f6253f522ee159..9d54acc81f380a597ed9d9ecb7c3c7cc259d3f4a 100644 (file)
@@ -16,7 +16,7 @@
 [Defines]\r
   PLATFORM_NAME                  = Shell\r
   PLATFORM_GUID                  = E1DC9BF8-7013-4c99-9437-795DAA45F3BD\r
-  PLATFORM_VERSION               = 0.50\r
+  PLATFORM_VERSION               = 1.0\r
   DSC_SPECIFICATION              = 0x00010006\r
   OUTPUT_DIRECTORY               = Build/Shell\r
   SUPPORTED_ARCHITECTURES        = IA32|IPF|X64|EBC|ARM|AARCH64\r
@@ -35,6 +35,8 @@
   BaseLib|MdePkg/Library/BaseLib/BaseLib.inf\r
   BaseMemoryLib|MdePkg/Library/BaseMemoryLib/BaseMemoryLib.inf\r
   PrintLib|MdePkg/Library/BasePrintLib/BasePrintLib.inf\r
+  FileHandleLib|MdePkg/Library/UefiFileHandleLib/UefiFileHandleLib.inf\r
+  SortLib|MdeModulePkg/Library/UefiSortLib/UefiSortLib.inf\r
   UefiRuntimeServicesTableLib|MdePkg/Library/UefiRuntimeServicesTableLib/UefiRuntimeServicesTableLib.inf\r
   UefiHiiServicesLib|MdeModulePkg/Library/UefiHiiServicesLib/UefiHiiServicesLib.inf\r
   HiiLib|MdeModulePkg/Library/UefiHiiLib/UefiHiiLib.inf\r
 \r
   ShellLib|ShellPkg/Library/UefiShellLib/UefiShellLib.inf\r
   ShellCommandLib|ShellPkg/Library/UefiShellCommandLib/UefiShellCommandLib.inf\r
-  FileHandleLib|ShellPkg/Library/UefiFileHandleLib/UefiFileHandleLib.inf\r
   ShellCEntryLib|ShellPkg/Library/UefiShellCEntryLib/UefiShellCEntryLib.inf\r
-  SortLib|ShellPkg/Library/UefiSortLib/UefiSortLib.inf\r
   HandleParsingLib|ShellPkg/Library/UefiHandleParsingLib/UefiHandleParsingLib.inf\r
   \r
   PeCoffGetEntryPointLib|MdePkg/Library/BasePeCoffGetEntryPointLib/BasePeCoffGetEntryPointLib.inf\r
-  PathLib|ShellPkg/Library/BasePathLib/BasePathLib.inf\r
   BcfgCommandLib|ShellPkg/Library/UefiShellBcfgCommandLib/UefiShellBcfgCommandLib.inf\r
 \r
 [LibraryClasses.ARM]\r
@@ -74,7 +73,6 @@
 !endif #$(NO_SHELL_PROFILES)\r
 \r
 [Components]\r
-  ShellPkg/Library/UefiFileHandleLib/UefiFileHandleLib.inf\r
   ShellPkg/Library/UefiShellLib/UefiShellLib.inf\r
   ShellPkg/Library/UefiShellCommandLib/UefiShellCommandLib.inf\r
   ShellPkg/Library/UefiShellLevel2CommandsLib/UefiShellLevel2CommandsLib.inf\r