]> git.proxmox.com Git - mirror_edk2.git/commitdiff
fixed to build under IPF.
authorjcarsey <jcarsey@6f19259b-4bc3-4df7-8a09-765794883524>
Mon, 11 May 2009 18:02:16 +0000 (18:02 +0000)
committerjcarsey <jcarsey@6f19259b-4bc3-4df7-8a09-765794883524>
Mon, 11 May 2009 18:02:16 +0000 (18:02 +0000)
Refactored some commands into FileHandleLib since they are used in many binaries.
Added .h for GUID that was missing.
Added PCD for initialization of shell apps and shell itself in shell library interaction.

git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@8295 6f19259b-4bc3-4df7-8a09-765794883524

14 files changed:
ShellPkg/Application/ShellLibTestApp/sa3.c
ShellPkg/Include/Guid/ShellEnvironment2Ext.h [new file with mode: 0644]
ShellPkg/Include/Guid/ShellPkgTokenSpace.h [new file with mode: 0644]
ShellPkg/Include/Library/FileHandleLib.h [new file with mode: 0644]
ShellPkg/Include/Library/ShellLib.h
ShellPkg/Include/Protocol/EfiShell.h
ShellPkg/Include/Protocol/EfiShellEnvironment2.h
ShellPkg/Library/BaseFileHandleLib/BaseFileHandleLib.c [new file with mode: 0644]
ShellPkg/Library/BaseFileHandleLib/BaseFileHandleLib.inf [new file with mode: 0644]
ShellPkg/Library/BaseShellLib/BaseShellLib.c
ShellPkg/Library/BaseShellLib/BaseShellLib.h [new file with mode: 0644]
ShellPkg/Library/BaseShellLib/BaseShellLib.inf
ShellPkg/ShellPkg.dec
ShellPkg/ShellPkg.dsc

index ae677b4dfaeea0b74ec20448e5aad6a6189fb7bc..135590bed1847d0ce148ba28f8ac13c51a4afbe3 100644 (file)
@@ -52,7 +52,7 @@ UefiMain (
   EFI_FILE_INFO       *pFileInfo;\r
   UINT64              Size;\r
   BOOLEAN             NoFile;\r
   EFI_FILE_INFO       *pFileInfo;\r
   UINT64              Size;\r
   BOOLEAN             NoFile;\r
-  EFI_SHELL_FILE_INFO *pShellFileInfo, *pShellFileInfo2;\r
+  EFI_SHELL_FILE_INFO *pShellFileInfo;\r
   LIST_ENTRY          *List;\r
   \r
   FileHandle = NULL;\r
   LIST_ENTRY          *List;\r
   \r
   FileHandle = NULL;\r
@@ -97,7 +97,6 @@ UefiMain (
   FreePool(pFileInfo);\r
   pFileInfo = NULL;\r
   Status = ShellCloseFile(&FileHandle);\r
   FreePool(pFileInfo);\r
   pFileInfo = NULL;\r
   Status = ShellCloseFile(&FileHandle);\r
-  ASSERT(FileHandle == NULL);\r
   ASSERT_EFI_ERROR(Status);\r
   Print(L"read, write, create, getinfo - pass\r\n");\r
 \r
   ASSERT_EFI_ERROR(Status);\r
   Print(L"read, write, create, getinfo - pass\r\n");\r
 \r
@@ -125,7 +124,6 @@ UefiMain (
   ASSERT(Size == 0x20);\r
   ASSERT_EFI_ERROR(Status);\r
   Status = ShellCloseFile(&FileHandle);\r
   ASSERT(Size == 0x20);\r
   ASSERT_EFI_ERROR(Status);\r
   Status = ShellCloseFile(&FileHandle);\r
-  ASSERT(FileHandle == NULL);\r
   ASSERT_EFI_ERROR(Status);\r
   Print(L"setinfo and change size, getsize - pass\r\n");\r
   \r
   ASSERT_EFI_ERROR(Status);\r
   Print(L"setinfo and change size, getsize - pass\r\n");\r
   \r
@@ -145,7 +143,6 @@ UefiMain (
   FreePool(pFileInfo);\r
   pFileInfo = NULL;   \r
   Status = ShellDeleteFile(&FileHandle);\r
   FreePool(pFileInfo);\r
   pFileInfo = NULL;   \r
   Status = ShellDeleteFile(&FileHandle);\r
-  ASSERT(FileHandle == NULL);\r
   ASSERT_EFI_ERROR(Status);\r
   Print(L"reopen file - pass\r\n");\r
 \r
   ASSERT_EFI_ERROR(Status);\r
   Print(L"reopen file - pass\r\n");\r
 \r
@@ -163,7 +160,6 @@ UefiMain (
   ASSERT((pFileInfo->Attribute&EFI_FILE_DIRECTORY)==0);\r
   FreePool(pFileInfo);\r
   Status = ShellDeleteFile(&FileHandle);\r
   ASSERT((pFileInfo->Attribute&EFI_FILE_DIRECTORY)==0);\r
   FreePool(pFileInfo);\r
   Status = ShellDeleteFile(&FileHandle);\r
-  ASSERT(FileHandle == NULL);\r
   ASSERT_EFI_ERROR(Status);\r
   Print(L"size of empty - pass\r\n");\r
 \r
   ASSERT_EFI_ERROR(Status);\r
   Print(L"size of empty - pass\r\n");\r
 \r
@@ -183,7 +179,6 @@ UefiMain (
   ASSERT(StrCmp(pFileInfo->FileName, FileName) == 0);\r
   ASSERT(pFileInfo->Attribute&EFI_FILE_DIRECTORY);\r
   Status = ShellDeleteFile(&FileHandle);\r
   ASSERT(StrCmp(pFileInfo->FileName, FileName) == 0);\r
   ASSERT(pFileInfo->Attribute&EFI_FILE_DIRECTORY);\r
   Status = ShellDeleteFile(&FileHandle);\r
-  ASSERT(FileHandle == NULL);\r
   ASSERT_EFI_ERROR(Status);\r
   Print(L"Directory create - pass\r\n");\r
   \r
   ASSERT_EFI_ERROR(Status);\r
   Print(L"Directory create - pass\r\n");\r
   \r
@@ -206,7 +201,7 @@ UefiMain (
                                0\r
                                );\r
   ASSERT_EFI_ERROR(Status);\r
                                0\r
                                );\r
   ASSERT_EFI_ERROR(Status);\r
-  Status = ShellFindFirstFile(FileHandle, pFileInfo);\r
+  Status = ShellFindFirstFile(FileHandle, &pFileInfo);\r
   ASSERT_EFI_ERROR(Status);\r
   Status = ShellFindNextFile(FileHandle, pFileInfo, &NoFile);\r
   ASSERT_EFI_ERROR(Status);\r
   ASSERT_EFI_ERROR(Status);\r
   Status = ShellFindNextFile(FileHandle, pFileInfo, &NoFile);\r
   ASSERT_EFI_ERROR(Status);\r
@@ -218,7 +213,6 @@ UefiMain (
   ASSERT_EFI_ERROR(Status);\r
   /// @todo - why is NoFile never set? limitation of NT32 file system?\r
   Status = ShellDeleteFile(&FileHandle);\r
   ASSERT_EFI_ERROR(Status);\r
   /// @todo - why is NoFile never set? limitation of NT32 file system?\r
   Status = ShellDeleteFile(&FileHandle);\r
-  ASSERT(FileHandle == NULL);\r
   ASSERT(Status == RETURN_WARN_DELETE_FAILURE);\r
   Print(L"FindFirst - pass\r\n");\r
   Print(L"FindNext - Verify with real EFI system.  Cant verify NoFile under NT32\r\n");\r
   ASSERT(Status == RETURN_WARN_DELETE_FAILURE);\r
   Print(L"FindFirst - pass\r\n");\r
   Print(L"FindNext - Verify with real EFI system.  Cant verify NoFile under NT32\r\n");\r
@@ -233,10 +227,7 @@ UefiMain (
   ASSERT(pShellFileInfo->Info->FileSize == 0);\r
   ASSERT(StrCmp(pShellFileInfo->Info->FileName, L"File.txt") == 0);\r
   ASSERT(pShellFileInfo->Info->Attribute == 0);\r
   ASSERT(pShellFileInfo->Info->FileSize == 0);\r
   ASSERT(StrCmp(pShellFileInfo->Info->FileName, L"File.txt") == 0);\r
   ASSERT(pShellFileInfo->Info->Attribute == 0);\r
-  pShellFileInfo2 = (EFI_SHELL_FILE_INFO*)0x12345678;\r
-  Status = ShellOpenFileMetaArg(L"testDir\\*.*", EFI_FILE_MODE_READ, &pShellFileInfo2);\r
-  ASSERT(pShellFileInfo2 == NULL);\r
-  ASSERT(Status == EFI_UNSUPPORTED);\r
+\r
   Status = ShellCloseFileMetaArg(&pShellFileInfo);\r
   ASSERT_EFI_ERROR(Status);\r
   Print(L"Open/Close Meta Arg - pass\r\n");\r
   Status = ShellCloseFileMetaArg(&pShellFileInfo);\r
   ASSERT_EFI_ERROR(Status);\r
   Print(L"Open/Close Meta Arg - pass\r\n");\r
@@ -250,7 +241,6 @@ UefiMain (
                                );\r
   ASSERT_EFI_ERROR(Status);\r
   Status = ShellDeleteFile(&FileHandle);\r
                                );\r
   ASSERT_EFI_ERROR(Status);\r
   Status = ShellDeleteFile(&FileHandle);\r
-  ASSERT(FileHandle == NULL);\r
   StrCpy(FileName, L"testDir");\r
   ASSERT_EFI_ERROR(Status);\r
   Status = ShellOpenFileByName(FileName, \r
   StrCpy(FileName, L"testDir");\r
   ASSERT_EFI_ERROR(Status);\r
   Status = ShellOpenFileByName(FileName, \r
@@ -259,7 +249,6 @@ UefiMain (
                                0\r
                                );\r
   Status = ShellDeleteFile(&FileHandle);\r
                                0\r
                                );\r
   Status = ShellDeleteFile(&FileHandle);\r
-  ASSERT(FileHandle == NULL);\r
   ASSERT_EFI_ERROR(Status);\r
 \r
   // get environment variable\r
   ASSERT_EFI_ERROR(Status);\r
 \r
   // get environment variable\r
@@ -286,7 +275,7 @@ UefiMain (
     ASSERT(ShellCommandLineGetFlag(List, L"/Param5") == FALSE);\r
     ASSERT(ShellCommandLineGetFlag(List, L"/Param1") != FALSE);\r
     ASSERT(StrCmp(ShellCommandLineGetValue(List, L"/Param2"), L"Val1")==0);\r
     ASSERT(ShellCommandLineGetFlag(List, L"/Param5") == FALSE);\r
     ASSERT(ShellCommandLineGetFlag(List, L"/Param1") != FALSE);\r
     ASSERT(StrCmp(ShellCommandLineGetValue(List, L"/Param2"), L"Val1")==0);\r
-    ASSERT(StrCmp(ShellCommandLineGetRawValue(List, 0), L"SimpleApplication")==0);\r
+    ASSERT(StrCmp(ShellCommandLineGetRawValue(List, 0), L"SimpleApplication.efi")==0);\r
 \r
     ShellCommandLineFreeVarList(List);\r
   } else {\r
 \r
     ShellCommandLineFreeVarList(List);\r
   } else {\r
diff --git a/ShellPkg/Include/Guid/ShellEnvironment2Ext.h b/ShellPkg/Include/Guid/ShellEnvironment2Ext.h
new file mode 100644 (file)
index 0000000..4977005
--- /dev/null
@@ -0,0 +1,25 @@
+/** @file\r
+  GUID for EFI shell Environment2 Extension\r
+\r
+  Copyright (c) 2009, Intel Corporation\r
+  All rights reserved. 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 _SHELLPKG_SHELL_ENV2_EXT_GUID_H\r
+#define _SHELLPKG_SHELL_ENV2_EXT_GUID_H\r
+\r
+#define SHELLPKG_SHELL_ENV2_EXT_GUID \\r
+{ \\r
+  0xd2c18636, 0x40e5, 0x4eb5, {0xa3, 0x1b, 0x36, 0x69, 0x5f, 0xd4, 0x2c, 0x87} \\r
+};\r
+\r
+extern EFI_GUID gEfiShellEnvironment2ExtGuid;\r
+\r
+#endif\r
diff --git a/ShellPkg/Include/Guid/ShellPkgTokenSpace.h b/ShellPkg/Include/Guid/ShellPkgTokenSpace.h
new file mode 100644 (file)
index 0000000..9803e9c
--- /dev/null
@@ -0,0 +1,25 @@
+/** @file\r
+  GUID for ShellPkg PCD Token Space \r
+\r
+  Copyright (c) 2009, Intel Corporation\r
+  All rights reserved. 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 _SHELLPKG_TOKEN_SPACE_GUID_H_\r
+#define _SHELLPKG_TOKEN_SPACE_GUID_H_\r
+\r
+#define SHELLPKG_TOKEN_SPACE_GUID \\r
+{ \\r
+  0x171e9188, 0x31d3, 0x40f5, { 0xb1, 0xc, 0x53, 0x9b, 0x2d, 0xb9, 0x40, 0xcd } \\r
+};\r
+\r
+extern EFI_GUID gEfiShellPkgTokenSpaceGuid;\r
+\r
+#endif\r
diff --git a/ShellPkg/Include/Library/FileHandleLib.h b/ShellPkg/Include/Library/FileHandleLib.h
new file mode 100644 (file)
index 0000000..8140dae
--- /dev/null
@@ -0,0 +1,331 @@
+/** @file\r
+  Provides interface to EFI_FILE_HANDLE functionality.\r
+\r
+Copyright (c) 2006 - 2009, Intel Corporation\r
+All rights reserved. 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 <Library/UefiBootServicesTableLib.h>\r
+#include <Library/BaseLib.h>\r
+#include <Library/BaseMemoryLib.h>\r
+#include <Library/DebugLib.h>\r
+#include <Library/MemoryAllocationLib.h>\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\92s information. It is the \r
+  caller\92s 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
+/**\r
+  This function will set the information about the file for the opened handle \r
+  specified.\r
+\r
+  @param  FileHandle            The file handle of the file for which information \r
+  is being set\r
+\r
+  @param  FileInfo              The infotmation to set.\r
+\r
+  @retval EFI_SUCCESS          The information was set.\r
+  @retval EFI_UNSUPPORTED The InformationType is not known.\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\92s 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\92s 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\92s 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
+/**\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 \93volume space full\94). \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
+/** \r
+  Close an open file handle.\r
+\r
+  This function closes a specified file handle. All \93dirty\94 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
+/**\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
+/**\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
+/** \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
+  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
+/**\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 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
+/**\r
+  Retrieves the first file from a directory\r
+\r
+  This function opens a directory and gets the first file\92s info in the \r
+  directory. Caller can use FileHandleFindNextFile() to get other files.  When \r
+  complete the caller is responsible for calling FreePool() on *Buffer.\r
+\r
+  @param DirHandle              The file handle of the directory to search\r
+  @param Buffer                 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
+  Retrieves the next file in a directory.\r
+\r
+  To use this function, caller must call the FileHandleFindFirstFile() to get the \r
+  first file, and then use this function get other files. This function can be \r
+  called for several times to get each file's information in the directory. If \r
+  the call of FileHandleFindNextFile() got the last file in the directory, the next \r
+  call of this function has no file to get. *NoFile will be set to TRUE and the \r
+  Buffer memory will be automatically freed. \r
+\r
+  @param DirHandle              the file handle of the directory\r
+  @param Buffer                                    pointer to buffer for file's information\r
+  @param NoFile                                    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\92s 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
+  );
\ No newline at end of file
index f5e5ba60de0930900c702ab46748957da2707bc9..5614d7174f59063620b081aad3bbe57cc7d9a3ef 100644 (file)
@@ -16,7 +16,6 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
 #define __SHELL_LIB__\r
 \r
 #include <Protocol/SimpleFileSystem.h>\r
 #define __SHELL_LIB__\r
 \r
 #include <Protocol/SimpleFileSystem.h>\r
-#include <Guid/FileInfo.h>\r
 #include <Protocol/EfiShell.h>\r
 \r
 /**\r
 #include <Protocol/EfiShell.h>\r
 \r
 /**\r
@@ -363,8 +362,10 @@ ShellFlushFile (
   in the directory's info. Caller can use ShellFindNextFile() to get \r
   subsequent files.\r
 \r
   in the directory's info. Caller can use ShellFindNextFile() to get \r
   subsequent files.\r
 \r
+  Caller must use FreePool on *Buffer opon completion of all file searching.\r
+\r
   @param DirHandle              The file handle of the directory to search\r
   @param DirHandle              The file handle of the directory to search\r
-  @param Buffer                 Pointer to buffer for file's information\r
+  @param Buffer                 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
 \r
   @retval EFI_SUCCESS           Found the first file.\r
   @retval EFI_NOT_FOUND         Cannot find the directory.\r
@@ -377,7 +378,7 @@ EFI_STATUS
 EFIAPI\r
 ShellFindFirstFile (\r
   IN EFI_FILE_HANDLE            DirHandle,\r
 EFIAPI\r
 ShellFindFirstFile (\r
   IN EFI_FILE_HANDLE            DirHandle,\r
-  OUT EFI_FILE_INFO             *Buffer\r
+  OUT EFI_FILE_INFO             **Buffer\r
   );\r
 \r
 /**\r
   );\r
 \r
 /**\r
@@ -613,6 +614,10 @@ typedef struct {
   ParamType   Type;\r
 } SHELL_PARAM_ITEM;\r
 \r
   ParamType   Type;\r
 } SHELL_PARAM_ITEM;\r
 \r
+\r
+/// Helper structure for no parameters (besides -? and -b)\r
+extern SHELL_PARAM_ITEM EmptyParamList[];\r
+\r
 /**\r
   Checks the command line arguments passed against the list of valid ones.  \r
   Optionally removes NULL values first.\r
 /**\r
   Checks the command line arguments passed against the list of valid ones.  \r
   Optionally removes NULL values first.\r
@@ -726,4 +731,22 @@ ShellCommandLineGetRawValue (
   IN UINT32                        Position\r
   );\r
 \r
   IN UINT32                        Position\r
   );\r
 \r
+/**\r
+  This function causes the shell library to initialize itself.  If the shell library\r
+  is already initialized it will de-initialize all the current protocol poitners and\r
+  re-populate them again.\r
+\r
+  When the library is used with PcdShellLibAutoInitialize set to true this function\r
+  will return EFI_SUCCESS and perform no actions.\r
+\r
+  This function is intended for internal access for shell commands only.\r
+\r
+  @retval EFI_SUCCESS   the initialization was complete sucessfully\r
+\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+ShellInitialize (\r
+  );\r
+\r
 #endif // __SHELL_LIB__
\ No newline at end of file
 #endif // __SHELL_LIB__
\ No newline at end of file
index 8421056145d476b727b986dc89d0055a740e0ae8..bd0aebe1d8a7b83de22910e77c5254056963985b 100644 (file)
   0x6302d008, 0x7f9b, 0x4f30, { 0x87, 0xac, 0x60, 0xc9, 0xfe, 0xf5, 0xda, 0x4e } \\r
   }\r
 \r
   0x6302d008, 0x7f9b, 0x4f30, { 0x87, 0xac, 0x60, 0xc9, 0xfe, 0xf5, 0xda, 0x4e } \\r
   }\r
 \r
-typedef struct _EFI_LIST_ENTRY {\r
-  struct _EFI_LIST_ENTRY *Flink;\r
-  struct _EFI_LIST_ENTRY *Blink;\r
-} EFI_LIST_ENTRY;\r
-\r
+// replaced EFI_LIST_ENTRY with LIST_ENTRY for simplicity.\r
+// they are identical outside of the name.\r
 typedef struct {\r
 typedef struct {\r
-  EFI_LIST_ENTRY Link;\r
+  LIST_ENTRY Link;\r
   EFI_STATUS Status;\r
   CONST CHAR16 *FullName;\r
   CONST CHAR16 *FileName;\r
   EFI_STATUS Status;\r
   CONST CHAR16 *FullName;\r
   CONST CHAR16 *FileName;\r
@@ -317,6 +314,16 @@ typedef UINT32 EFI_SHELL_DEVICE_NAME_FLAGS;
   handle. If no user-readable name could be generated, then *BestDeviceName will be\r
   NULL and EFI_NOT_FOUND will be returned.\r
 \r
   handle. If no user-readable name could be generated, then *BestDeviceName will be\r
   NULL and EFI_NOT_FOUND will be returned.\r
 \r
+  If EFI_DEVICE_NAME_USE_COMPONENT_NAME is set, then the function will return the\r
+  device\92s name using the EFI_COMPONENT_NAME2_PROTOCOL, if present on\r
+  DeviceHandle.\r
+\r
+  If EFI_DEVICE_NAME_USE_DEVICE_PATH is set, then the function will return the\r
+  device\92s name using the EFI_DEVICE_PATH_PROTOCOL, if present on DeviceHandle.\r
+  If both EFI_DEVICE_NAME_USE_COMPONENT_NAME and\r
+  EFI_DEVICE_NAME_USE_DEVICE_PATH are set, then\r
+  EFI_DEVICE_NAME_USE_COMPONENT_NAME will have higher priority.\r
+\r
   @param DeviceHandle           The handle of the device.\r
   @param Flags                  Determines the possible sources of component names. \r
   @param Language               A pointer to the language specified for the device \r
   @param DeviceHandle           The handle of the device.\r
   @param Flags                  Determines the possible sources of component names. \r
   @param Language               A pointer to the language specified for the device \r
@@ -946,4 +953,9 @@ typedef struct _EFI_SHELL_PROTOCOL {
 \r
 extern EFI_GUID gEfiShellProtocolGuid;\r
 \r
 \r
 extern EFI_GUID gEfiShellProtocolGuid;\r
 \r
+enum ShellVersion {\r
+  SHELL_MAJOR_VERSION = 2,\r
+  SHELL_MINOR_VERSION = 0\r
+};\r
+\r
 #endif\r
 #endif\r
index 537b916071aafaad74ccb5e15ace68eb36ec10fb..cafecb0cf346f5d1297def3bbdea0ce75e2d40f9 100644 (file)
@@ -82,7 +82,7 @@ EFI_STATUS
 **/\r
 typedef struct {\r
   UINT32                    Signature;            ///< SHELL_FILE_ARG_SIGNATURE\r
 **/\r
 typedef struct {\r
   UINT32                    Signature;            ///< SHELL_FILE_ARG_SIGNATURE\r
-  EFI_LIST_ENTRY            Link;                 ///< linked list helper\r
+  LIST_ENTRY                Link;                 ///< linked list helper\r
   EFI_STATUS                Status;               ///< File's status\r
 \r
   EFI_FILE_HANDLE           Parent;               ///< what is the Parent file of this file\r
   EFI_STATUS                Status;               ///< File's status\r
 \r
   EFI_FILE_HANDLE           Parent;               ///< what is the Parent file of this file\r
@@ -270,7 +270,7 @@ CHAR16*
   support for wildcard characters ('?' and '*') in the Arg path.  if there are \r
   any wildcard characters in the path this function will find any and all files\r
   that match the wildcards.  the return is a double linked list based on the \r
   support for wildcard characters ('?' and '*') in the Arg path.  if there are \r
   any wildcard characters in the path this function will find any and all files\r
   that match the wildcards.  the return is a double linked list based on the \r
-  EFI_LIST_ENTRY linked list structure.  use this in conjunction with the \r
+  LIST_ENTRY linked list structure.  use this in conjunction with the \r
   SHELL_FILE_ARG_SIGNATURE to get the SHELL_FILE_ARG structures that are returned.\r
   The memory allocated by the callee for this list is freed by making a call to \r
   SHELLENV_FREE_FILE_LIST.\r
   SHELL_FILE_ARG_SIGNATURE to get the SHELL_FILE_ARG structures that are returned.\r
   The memory allocated by the callee for this list is freed by making a call to \r
   SHELLENV_FREE_FILE_LIST.\r
@@ -288,7 +288,7 @@ CHAR16*
 EFI_STATUS\r
 (EFIAPI *SHELLENV_FILE_META_ARG) (\r
   IN CHAR16               *Arg,\r
 EFI_STATUS\r
 (EFIAPI *SHELLENV_FILE_META_ARG) (\r
   IN CHAR16               *Arg,\r
-  IN OUT EFI_LIST_ENTRY   *ListHead\r
+  IN OUT LIST_ENTRY       *ListHead\r
   );\r
 \r
 /**\r
   );\r
 \r
 /**\r
@@ -301,7 +301,7 @@ EFI_STATUS
 typedef\r
 EFI_STATUS\r
 (EFIAPI *SHELLENV_FREE_FILE_LIST) (\r
 typedef\r
 EFI_STATUS\r
 (EFIAPI *SHELLENV_FREE_FILE_LIST) (\r
-  IN OUT EFI_LIST_ENTRY   *ListHead\r
+  IN OUT LIST_ENTRY       *ListHead\r
   );\r
 \r
 /**\r
   );\r
 \r
 /**\r
@@ -618,7 +618,7 @@ typedef struct {
 **/\r
 typedef struct {\r
   UINTN                       Signature;   ///< PROTOCOL_INFO_SIGNATURE \r
 **/\r
 typedef struct {\r
   UINTN                       Signature;   ///< PROTOCOL_INFO_SIGNATURE \r
-  EFI_LIST_ENTRY              Link;        ///< standard lined list helper member\r
+  LIST_ENTRY                  Link;        ///< standard lined list helper member\r
   //\r
   // parsing info for the protocol\r
   //\r
   //\r
   // parsing info for the protocol\r
   //\r
@@ -845,7 +845,7 @@ EFI_STATUS
   support the wildcard characters ('?' and '*') in the Arg path.  if there are \r
   any wildcard characters in the path this function will return \r
   EFI_INVALID_PARAMETER.  the return is a double linked list based on the \r
   support the wildcard characters ('?' and '*') in the Arg path.  if there are \r
   any wildcard characters in the path this function will return \r
   EFI_INVALID_PARAMETER.  the return is a double linked list based on the \r
-  EFI_LIST_ENTRY linked list structure.  use this in conjunction with the \r
+  LIST_ENTRY linked list structure.  use this in conjunction with the \r
   SHELL_FILE_ARG_SIGNATURE to get the SHELL_FILE_ARG structures that are returned.\r
   The memory allocated by the callee for this list is freed by making a call to \r
   SHELLENV_FREE_FILE_LIST.\r
   SHELL_FILE_ARG_SIGNATURE to get the SHELL_FILE_ARG structures that are returned.\r
   The memory allocated by the callee for this list is freed by making a call to \r
   SHELLENV_FREE_FILE_LIST.\r
@@ -864,7 +864,7 @@ typedef
 EFI_STATUS\r
 (EFIAPI *SHELLENV_FILE_META_ARG_NO_WILDCARD) (\r
   IN CHAR16               *Arg,\r
 EFI_STATUS\r
 (EFIAPI *SHELLENV_FILE_META_ARG_NO_WILDCARD) (\r
   IN CHAR16               *Arg,\r
-  IN OUT EFI_LIST_ENTRY   *ListHead\r
+  IN OUT LIST_ENTRY       *ListHead\r
   );\r
 \r
 /**\r
   );\r
 \r
 /**\r
@@ -885,7 +885,7 @@ EFI_STATUS
 typedef\r
 EFI_STATUS\r
 (EFIAPI *SHELLENV_DEL_DUP_FILE) (\r
 typedef\r
 EFI_STATUS\r
 (EFIAPI *SHELLENV_DEL_DUP_FILE) (\r
-  IN EFI_LIST_ENTRY   * ListHead\r
+  IN LIST_ENTRY   * ListHead\r
   );\r
 \r
 /**\r
   );\r
 \r
 /**\r
diff --git a/ShellPkg/Library/BaseFileHandleLib/BaseFileHandleLib.c b/ShellPkg/Library/BaseFileHandleLib/BaseFileHandleLib.c
new file mode 100644 (file)
index 0000000..6822b74
--- /dev/null
@@ -0,0 +1,623 @@
+/** @file\r
+  Provides interface to EFI_FILE_HANDLE functionality.\r
+\r
+Copyright (c) 2006 - 2009, Intel Corporation\r
+All rights reserved. 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/ShellLib.h>\r
+#include <Library/DebugLib.h>\r
+#include <Library/MemoryAllocationLib.h>\r
+\r
+#include <Protocol/SimpleFileSystem.h>\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\92s information. It is the \r
+  caller\92s 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_GUID        FileInfoGuid;\r
+  EFI_FILE_INFO   *pFileInfo;\r
+  UINTN           FileInfoSize;\r
+  EFI_STATUS      Status;\r
+\r
+  //\r
+  // ASSERT if FileHandle is NULL\r
+  //\r
+  ASSERT (FileHandle != NULL);\r
+\r
+  //\r
+  // Get the required size to allocate\r
+  //\r
+  FileInfoGuid = gEfiFileInfoGuid;\r
+  FileInfoSize = 0;\r
+  pFileInfo = NULL;\r
+  Status = FileHandle->GetInfo(FileHandle, \r
+                               &FileInfoGuid, \r
+                               &FileInfoSize, \r
+                               pFileInfo);\r
+  //\r
+  // error is expected.  getting size to allocate\r
+  //\r
+  ASSERT (Status == EFI_BUFFER_TOO_SMALL);\r
+  pFileInfo = AllocateZeroPool(FileInfoSize);\r
+  ASSERT (pFileInfo != NULL);\r
+  //\r
+  // now get the information\r
+  //\r
+  Status = FileHandle->GetInfo(FileHandle, \r
+                               &FileInfoGuid, \r
+                               &FileInfoSize, \r
+                               pFileInfo);\r
+  //\r
+  // if we got an error free the memory and return NULL\r
+  //\r
+  if (EFI_ERROR(Status)) {\r
+    FreePool(pFileInfo);\r
+    return NULL;\r
+  }\r
+  return (pFileInfo);\r
+}\r
+\r
+/**\r
+  This function will set the information about the file for the opened handle \r
+  specified.\r
+\r
+  @param  FileHandle            The file handle of the file for which information \r
+  is being set\r
+\r
+  @param  FileInfo              The infotmation to set.\r
+\r
+  @retval EFI_SUCCESS          The information was set.\r
+  @retval EFI_UNSUPPORTED The InformationType is not known.\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
+  EFI_GUID        FileInfoGuid;\r
+  \r
+  //\r
+  // ASSERT if the FileHandle or FileInfo is NULL\r
+  //\r
+  ASSERT (FileHandle != NULL);\r
+  ASSERT (FileInfo   != NULL);\r
+\r
+  FileInfoGuid = gEfiFileInfoGuid;\r
+  //\r
+  // Set the info\r
+  //\r
+  return (FileHandle->SetInfo(FileHandle, \r
+                              &FileInfoGuid,\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\92s 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\92s 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\92s 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
+  //\r
+  // ASSERT if FileHandle is NULL\r
+  //\r
+  ASSERT (FileHandle != NULL);\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 \93volume space full\94). \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
+  //\r
+  // ASSERT if FileHandle is NULL\r
+  //\r
+  ASSERT (FileHandle != NULL);\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 \93dirty\94 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
+  // ASSERT if FileHandle is NULL\r
+  //\r
+  ASSERT (FileHandle != NULL);\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
+  // ASSERT if FileHandle is NULL\r
+  //\r
+  ASSERT (FileHandle != NULL);\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
+  //\r
+  // ASSERT if FileHandle is NULL\r
+  //\r
+  ASSERT (FileHandle != NULL);\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
+  //\r
+  // ASSERT if FileHandle is NULL\r
+  //\r
+  ASSERT (FileHandle != NULL);\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
+  //\r
+  // ASSERT if FileHandle is NULL\r
+  //\r
+  ASSERT (FileHandle != NULL);\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 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 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
+  //\r
+  // ASSERT if DirHandle is NULL\r
+  //\r
+  ASSERT(DirHandle != NULL);\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
+/**\r
+  Retrieves the first file from a directory\r
+\r
+  This function opens a directory and gets the first file\92s info in the \r
+  directory. Caller can use FileHandleFindNextFile() to get other files.  When \r
+  complete the caller is responsible for calling FreePool() on Buffer.\r
+\r
+  @param DirHandle              The file handle of the directory to search\r
+  @param Buffer                 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
+  //\r
+  // ASSERTs\r
+  //\r
+  ASSERT (DirHandle != NULL);\r
+  ASSERT (Buffer != NULL);\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
+  // reset to the begining of the directory \r
+  //\r
+  Status = FileHandleSetPosition(DirHandle, 0);\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
+  ASSERT (*Buffer != NULL);\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)) {\r
+    FreePool(*Buffer);\r
+    *Buffer = NULL;\r
+    return (Status);\r
+  }\r
+  return (EFI_SUCCESS);\r
+}\r
+/**\r
+  Retrieves the next file in a directory.\r
+\r
+  To use this function, caller must call the FileHandleFindFirstFile() to get the \r
+  first file, and then use this function get other files. This function can be \r
+  called for several times to get each file's information in the directory. If \r
+  the call of FileHandleFindNextFile() got the last file in the directory, the next \r
+  call of this function has no file to get. *NoFile will be set to TRUE and the \r
+  Buffer memory will be automatically freed. \r
+\r
+  @param DirHandle              the file handle of the directory\r
+  @param Buffer                                    pointer to buffer for file's information\r
+  @param NoFile                                    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
+  //\r
+  // ASSERTs for DirHandle or Buffer or NoFile poitners being NULL\r
+  //\r
+  ASSERT (DirHandle != NULL);\r
+  ASSERT (Buffer    != NULL);\r
+  ASSERT (NoFile    != NULL);\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
+  // 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
+  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\92s 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
+  //\r
+  // ASSERT for FileHandle or Size being NULL\r
+  //\r
+  ASSERT (FileHandle != NULL);\r
+  ASSERT (Size != NULL);\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
+}
\ No newline at end of file
diff --git a/ShellPkg/Library/BaseFileHandleLib/BaseFileHandleLib.inf b/ShellPkg/Library/BaseFileHandleLib/BaseFileHandleLib.inf
new file mode 100644 (file)
index 0000000..48489b4
--- /dev/null
@@ -0,0 +1,49 @@
+#/** @file\r
+# Provides interface to shell functionality for shell commands and applications.\r
+#\r
+# Copyright (c) 2006 - 2009, Intel Corporation.\r
+#\r
+#  All rights reserved. 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                    = UEFI_DRIVER\r
+  VERSION_STRING                 = 1.0\r
+  LIBRARY_CLASS                  = FileHandleLib|UEFI_APPLICATION UEFI_DRIVER\r
+\r
+#\r
+#  VALID_ARCHITECTURES           = IA32 X64 IPF EBC\r
+#\r
+\r
+[Sources.common]\r
+  BaseFileHandleLib.c\r
+\r
+[Packages]\r
+  MdePkg/MdePkg.dec\r
+  ShellPkg/ShellPkg.dec\r
+\r
+[LibraryClasses]\r
+  UefiBootServicesTableLib\r
+  MemoryAllocationLib\r
+  DevicePathLib\r
+  BaseLib\r
+  BaseMemoryLib\r
+  DebugLib\r
+\r
+[Protocols]\r
+  \r
+[Guids]\r
+  gEfiFileInfoGuid                              # ALWAYS_CONSUMED\r
+\r
+[Pcd.common]\r
+\r
index 205974d519168435479176b70e56c7bcfc301436..a0e2e492e11028a2d9ab912f67dc53a088924d3a 100644 (file)
@@ -20,21 +20,35 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
 #include <Library/DebugLib.h>\r
 #include <Library/MemoryAllocationLib.h>\r
 #include <Library/DevicePathLib.h>\r
 #include <Library/DebugLib.h>\r
 #include <Library/MemoryAllocationLib.h>\r
 #include <Library/DevicePathLib.h>\r
+#include <Library/PcdLib.h>\r
+#include <Library/FileHandleLib.h>\r
 #include <Protocol/EfiShellEnvironment2.h>\r
 #include <Protocol/EfiShellInterface.h>\r
 #include <Protocol/EfiShell.h>\r
 #include <Protocol/EfiShellParameters.h>\r
 #include <Protocol/SimpleFileSystem.h>\r
 \r
 #include <Protocol/EfiShellEnvironment2.h>\r
 #include <Protocol/EfiShellInterface.h>\r
 #include <Protocol/EfiShell.h>\r
 #include <Protocol/EfiShellParameters.h>\r
 #include <Protocol/SimpleFileSystem.h>\r
 \r
+#include "BaseShellLib.h"\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
 #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
-EFI_SHELL_ENVIRONMENT2        *mEfiShellEnvironment2;\r
-EFI_SHELL_INTERFACE           *mEfiShellInterface;\r
-EFI_SHELL_PROTOCOL            *mEfiShellProtocol;\r
-EFI_SHELL_PARAMETERS_PROTOCOL *mEfiShellParametersProtocol;\r
-EFI_HANDLE                    mEfiShellEnvironment2Handle;\r
-EFI_LIST_ENTRY                *mOldStyleFileList;\r
+//\r
+// This is not static since it's extern in the .h file\r
+//\r
+SHELL_PARAM_ITEM EmptyParamList[] = {\r
+  {NULL, TypeMax}\r
+  };\r
+\r
+//\r
+// Static file globals for the shell library\r
+//\r
+STATIC EFI_SHELL_ENVIRONMENT2        *mEfiShellEnvironment2;\r
+STATIC EFI_SHELL_INTERFACE           *mEfiShellInterface;\r
+STATIC EFI_SHELL_PROTOCOL            *mEfiShellProtocol;\r
+STATIC EFI_SHELL_PARAMETERS_PROTOCOL *mEfiShellParametersProtocol;\r
+STATIC EFI_HANDLE                    mEfiShellEnvironment2Handle;\r
+STATIC FILE_HANDLE_FUNCTION_MAP      FileFunctionMap;\r
 \r
 /**\r
   helper function to find ShellEnvironment2 for constructor\r
 \r
 /**\r
   helper function to find ShellEnvironment2 for constructor\r
@@ -112,36 +126,14 @@ ShellFindSE2 (
   return (Status);\r
 }\r
 \r
   return (Status);\r
 }\r
 \r
-/**\r
-  Constructor for the Shell library.\r
-\r
-  Initialize the library and determine if the underlying is a UEFI Shell 2.0 or an EFI shell.\r
-\r
-  @param ImageHandle    the image handle of the process\r
-  @param SystemTable    the EFI System Table pointer\r
-\r
-  @retval EFI_SUCCESS   the initialization was complete sucessfully\r
-  @return others        an error ocurred during initialization\r
-**/\r
 EFI_STATUS\r
 EFIAPI\r
 EFI_STATUS\r
 EFIAPI\r
-ShellLibConstructor (\r
+ShellLibConstructorWorker (\r
   IN EFI_HANDLE        ImageHandle,\r
   IN EFI_SYSTEM_TABLE  *SystemTable\r
   IN EFI_HANDLE        ImageHandle,\r
   IN EFI_SYSTEM_TABLE  *SystemTable\r
-  )\r
-{\r
+){\r
   EFI_STATUS Status;\r
 \r
   EFI_STATUS Status;\r
 \r
-  ASSERT(SystemTable != NULL);\r
-  ASSERT(gBS != NULL);\r
-\r
-  mEfiShellEnvironment2       = NULL;\r
-  mEfiShellProtocol           = NULL;\r
-  mEfiShellParametersProtocol = NULL;\r
-  mEfiShellInterface          = NULL;\r
-  mEfiShellEnvironment2Handle = NULL;\r
-  mOldStyleFileList           = NULL;\r
-\r
   //\r
   // UEFI 2.0 shell interfaces (used preferentially)\r
   //\r
   //\r
   // UEFI 2.0 shell interfaces (used preferentially)\r
   //\r
@@ -192,10 +184,69 @@ ShellLibConstructor (
   //\r
   if ((mEfiShellEnvironment2 != NULL && mEfiShellInterface          != NULL) || \r
       (mEfiShellProtocol     != NULL && mEfiShellParametersProtocol != NULL)    ) {\r
   //\r
   if ((mEfiShellEnvironment2 != NULL && mEfiShellInterface          != NULL) || \r
       (mEfiShellProtocol     != NULL && mEfiShellParametersProtocol != NULL)    ) {\r
+    if (mEfiShellProtocol != NULL) {\r
+      FileFunctionMap.GetFileInfo     = mEfiShellProtocol->GetFileInfo;\r
+      FileFunctionMap.SetFileInfo     = mEfiShellProtocol->SetFileInfo;\r
+      FileFunctionMap.ReadFile        = mEfiShellProtocol->ReadFile;\r
+      FileFunctionMap.WriteFile       = mEfiShellProtocol->WriteFile;\r
+      FileFunctionMap.CloseFile       = mEfiShellProtocol->CloseFile;\r
+      FileFunctionMap.DeleteFile      = mEfiShellProtocol->DeleteFile;\r
+      FileFunctionMap.GetFilePosition = mEfiShellProtocol->GetFilePosition;\r
+      FileFunctionMap.SetFilePosition = mEfiShellProtocol->SetFilePosition;\r
+      FileFunctionMap.FlushFile       = mEfiShellProtocol->FlushFile;\r
+      FileFunctionMap.GetFileSize     = mEfiShellProtocol->GetFileSize;\r
+    } else {\r
+      FileFunctionMap.GetFileInfo     = FileHandleGetInfo;\r
+      FileFunctionMap.SetFileInfo     = FileHandleSetInfo;\r
+      FileFunctionMap.ReadFile        = FileHandleRead;\r
+      FileFunctionMap.WriteFile       = FileHandleWrite;\r
+      FileFunctionMap.CloseFile       = FileHandleClose;\r
+      FileFunctionMap.DeleteFile      = FileHandleDelete;\r
+      FileFunctionMap.GetFilePosition = FileHandleGetPosition;\r
+      FileFunctionMap.SetFilePosition = FileHandleSetPosition;\r
+      FileFunctionMap.FlushFile       = FileHandleFlush;\r
+      FileFunctionMap.GetFileSize     = FileHandleGetSize;\r
+    }\r
     return (EFI_SUCCESS);\r
   }\r
   return (EFI_NOT_FOUND);\r
 }\r
     return (EFI_SUCCESS);\r
   }\r
   return (EFI_NOT_FOUND);\r
 }\r
+/**\r
+  Constructor for the Shell library.\r
+\r
+  Initialize the library and determine if the underlying is a UEFI Shell 2.0 or an EFI shell.\r
+\r
+  @param ImageHandle    the image handle of the process\r
+  @param SystemTable    the EFI System Table pointer\r
+\r
+  @retval EFI_SUCCESS   the initialization was complete sucessfully\r
+  @return others        an error ocurred during initialization\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+ShellLibConstructor (\r
+  IN EFI_HANDLE        ImageHandle,\r
+  IN EFI_SYSTEM_TABLE  *SystemTable\r
+  )\r
+{\r
+\r
+\r
+  mEfiShellEnvironment2       = NULL;\r
+  mEfiShellProtocol           = NULL;\r
+  mEfiShellParametersProtocol = NULL;\r
+  mEfiShellInterface          = NULL;\r
+  mEfiShellEnvironment2Handle = NULL;\r
+\r
+  ///@todo make a worker constructor so initialize function works\r
+  //\r
+  // verify that auto initialize is not set false\r
+  // \r
+  if (PcdGetBool(PcdShellLibAutoInitialize) == 0) {\r
+    return (EFI_SUCCESS);\r
+  }\r
+  \r
+  return (ShellLibConstructorWorker(ImageHandle, SystemTable));\r
+}\r
 \r
 /**\r
   Destructory for the library.  free any resources.\r
 \r
 /**\r
   Destructory for the library.  free any resources.\r
@@ -212,27 +263,68 @@ ShellLibDestructor (
                        &gEfiShellEnvironment2Guid,\r
                        ImageHandle,\r
                        NULL);\r
                        &gEfiShellEnvironment2Guid,\r
                        ImageHandle,\r
                        NULL);\r
+    mEfiShellEnvironment2 = NULL;\r
   }\r
   if (mEfiShellInterface != NULL) {\r
     gBS->CloseProtocol(ImageHandle,\r
                        &gEfiShellInterfaceGuid,\r
                        ImageHandle,\r
                        NULL);  \r
   }\r
   if (mEfiShellInterface != NULL) {\r
     gBS->CloseProtocol(ImageHandle,\r
                        &gEfiShellInterfaceGuid,\r
                        ImageHandle,\r
                        NULL);  \r
+    mEfiShellInterface = NULL;\r
   }\r
   if (mEfiShellProtocol != NULL) {\r
     gBS->CloseProtocol(ImageHandle,\r
                        &gEfiShellProtocolGuid,\r
                        ImageHandle,\r
   }\r
   if (mEfiShellProtocol != NULL) {\r
     gBS->CloseProtocol(ImageHandle,\r
                        &gEfiShellProtocolGuid,\r
                        ImageHandle,\r
-                       NULL);    \r
+                       NULL);  \r
+    mEfiShellProtocol = NULL;\r
   }\r
   if (mEfiShellParametersProtocol != NULL) {\r
     gBS->CloseProtocol(ImageHandle,\r
                        &gEfiShellParametersProtocolGuid,\r
                        ImageHandle,\r
                        NULL);    \r
   }\r
   if (mEfiShellParametersProtocol != NULL) {\r
     gBS->CloseProtocol(ImageHandle,\r
                        &gEfiShellParametersProtocolGuid,\r
                        ImageHandle,\r
                        NULL);    \r
+    mEfiShellParametersProtocol = NULL;\r
   }\r
   }\r
+  mEfiShellEnvironment2Handle = NULL;\r
   return (EFI_SUCCESS);\r
 }\r
   return (EFI_SUCCESS);\r
 }\r
+\r
+/**\r
+  This function causes the shell library to initialize itself.  If the shell library\r
+  is already initialized it will de-initialize all the current protocol poitners and\r
+  re-populate them again.\r
+\r
+  When the library is used with PcdShellLibAutoInitialize set to true this function\r
+  will return EFI_SUCCESS and perform no actions.\r
+\r
+  This function is intended for internal access for shell commands only.\r
+\r
+  @retval EFI_SUCCESS   the initialization was complete sucessfully\r
+\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+ShellInitialize (\r
+  ) {\r
+  //\r
+  // if auto initialize is not false then skip\r
+  //\r
+  if (PcdGetBool(PcdShellLibAutoInitialize) != 0) {\r
+    return (EFI_SUCCESS);\r
+  }\r
+\r
+  //\r
+  // deinit the current stuff\r
+  //\r
+  ASSERT_EFI_ERROR(ShellLibDestructor(gImageHandle, gST));\r
+\r
+  //\r
+  // init the new stuff\r
+  //\r
+  return (ShellLibConstructorWorker(gImageHandle, gST));\r
+}\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 will retrieve the information about the file for the handle \r
   specified and store it in allocated pool memory.\r
@@ -253,47 +345,7 @@ ShellGetFileInfo (
   IN EFI_FILE_HANDLE            FileHandle\r
   )\r
 {\r
   IN EFI_FILE_HANDLE            FileHandle\r
   )\r
 {\r
-  EFI_GUID        FileInfoGuid;\r
-  EFI_FILE_INFO   *pFileInfo;\r
-  UINTN           FileInfoSize;\r
-  EFI_STATUS      Status;\r
-\r
-  //\r
-  // ASSERT if FileHandle is NULL\r
-  //\r
-  ASSERT (FileHandle != NULL);\r
-\r
-  //\r
-  // Get the required size to allocate\r
-  //\r
-  FileInfoGuid = gEfiFileInfoGuid;\r
-  FileInfoSize = 0;\r
-  pFileInfo = NULL;\r
-  Status = FileHandle->GetInfo(FileHandle, \r
-                               &FileInfoGuid, \r
-                               &FileInfoSize, \r
-                               pFileInfo);\r
-  //\r
-  // error is expected.  getting size to allocate\r
-  //\r
-  ASSERT (Status == EFI_BUFFER_TOO_SMALL);\r
-  pFileInfo = AllocateZeroPool(FileInfoSize);\r
-  ASSERT (pFileInfo != NULL);\r
-  //\r
-  // now get the information\r
-  //\r
-  Status = FileHandle->GetInfo(FileHandle, \r
-                               &FileInfoGuid, \r
-                               &FileInfoSize, \r
-                               pFileInfo);\r
-  //\r
-  // if we got an error free the memory and return NULL\r
-  //\r
-  if (EFI_ERROR(Status)) {\r
-    FreePool(pFileInfo);\r
-    return NULL;\r
-  }\r
-  return (pFileInfo);\r
+  return (FileFunctionMap.GetFileInfo(FileHandle));\r
 }\r
 \r
 /**\r
 }\r
 \r
 /**\r
@@ -321,22 +373,7 @@ ShellSetFileInfo (
   IN EFI_FILE_INFO              *FileInfo\r
   )\r
 {\r
   IN EFI_FILE_INFO              *FileInfo\r
   )\r
 {\r
-  EFI_GUID        FileInfoGuid;\r
-  \r
-  //\r
-  // ASSERT if the FileHandle or FileInfo is NULL\r
-  //\r
-  ASSERT (FileHandle != NULL);\r
-  ASSERT (FileInfo   != NULL);\r
-\r
-  FileInfoGuid = gEfiFileInfoGuid;\r
-  //\r
-  // Set the info\r
-  //\r
-  return (FileHandle->SetInfo(FileHandle, \r
-                              &FileInfoGuid,\r
-                              (UINTN)FileInfo->Size,\r
-                              FileInfo));\r
+  return (FileFunctionMap.SetFileInfo(FileHandle, FileInfo));\r
 }  \r
   \r
   /**\r
 }  \r
   \r
   /**\r
@@ -404,89 +441,90 @@ ShellOpenFileByDevicePath(
     Status = ShellOpenFileByName(FileName, FileHandle, OpenMode, Attributes);\r
     FreePool(FileName);\r
     return (Status);\r
     Status = ShellOpenFileByName(FileName, FileHandle, OpenMode, Attributes);\r
     FreePool(FileName);\r
     return (Status);\r
-  } else {\r
+  } \r
+\r
+\r
+  //\r
+  // use old shell method.\r
+  //\r
+  Status = gBS->LocateDevicePath (&gEfiSimpleFileSystemProtocolGuid, \r
+                                  FilePath, \r
+                                  DeviceHandle);\r
+  if (EFI_ERROR (Status)) {\r
+    return Status;\r
+  }\r
+  Status = gBS->OpenProtocol(*DeviceHandle,\r
+                             &gEfiSimpleFileSystemProtocolGuid,\r
+                             &EfiSimpleFileSystemProtocol,\r
+                             gImageHandle,\r
+                             NULL,\r
+                             EFI_OPEN_PROTOCOL_GET_PROTOCOL);\r
+  if (EFI_ERROR (Status)) {\r
+    return Status;\r
+  }\r
+  Status = EfiSimpleFileSystemProtocol->OpenVolume(EfiSimpleFileSystemProtocol, FileHandle);\r
+  if (EFI_ERROR (Status)) {\r
+    FileHandle = NULL;\r
+    return Status;\r
+  }\r
+\r
+  //\r
+  // go down directories one node at a time.\r
+  //\r
+  while (!IsDevicePathEnd (*FilePath)) {\r
     //\r
     //\r
-    // use old shell method.\r
+    // For file system access each node should be a file path component\r
     //\r
     //\r
-    Status = gBS->LocateDevicePath (&gEfiSimpleFileSystemProtocolGuid, \r
-                                    FilePath, \r
-                                    DeviceHandle);\r
-    if (EFI_ERROR (Status)) {\r
-      return Status;\r
-    }\r
-    Status = gBS->OpenProtocol(*DeviceHandle,\r
-                               &gEfiSimpleFileSystemProtocolGuid,\r
-                               &EfiSimpleFileSystemProtocol,\r
-                               gImageHandle,\r
-                               NULL,\r
-                               EFI_OPEN_PROTOCOL_GET_PROTOCOL);\r
-    if (EFI_ERROR (Status)) {\r
-      return Status;\r
-    }\r
-    Status = EfiSimpleFileSystemProtocol->OpenVolume(EfiSimpleFileSystemProtocol, FileHandle);\r
-    if (EFI_ERROR (Status)) {\r
+    if (DevicePathType    (*FilePath) != MEDIA_DEVICE_PATH ||\r
+        DevicePathSubType (*FilePath) != MEDIA_FILEPATH_DP\r
+        ) {\r
       FileHandle = NULL;\r
       FileHandle = NULL;\r
-      return Status;\r
+      return (EFI_INVALID_PARAMETER);\r
     }\r
     }\r
+    //\r
+    // Open this file path node\r
+    //\r
+    LastHandle  = *FileHandle;\r
+    *FileHandle = NULL;\r
 \r
     //\r
 \r
     //\r
-    // go down directories one node at a time.\r
+    // Try to test opening an existing file\r
     //\r
     //\r
-    while (!IsDevicePathEnd (*FilePath)) {\r
-      //\r
-      // For file system access each node should be a file path component\r
-      //\r
-      if (DevicePathType    (*FilePath) != MEDIA_DEVICE_PATH ||\r
-          DevicePathSubType (*FilePath) != MEDIA_FILEPATH_DP\r
-          ) {\r
-        FileHandle = NULL;\r
-        return (EFI_INVALID_PARAMETER);\r
-      }\r
-      //\r
-      // Open this file path node\r
-      //\r
-      LastHandle  = *FileHandle;\r
-      *FileHandle = NULL;\r
+    Status = LastHandle->Open (\r
+                          LastHandle,\r
+                          FileHandle,\r
+                          ((FILEPATH_DEVICE_PATH*)*FilePath)->PathName,\r
+                          OpenMode &~EFI_FILE_MODE_CREATE,\r
+                          0\r
+                          );\r
 \r
 \r
-      //\r
-      // Try to test opening an existing file\r
-      //\r
+    //\r
+    // see if the error was that it needs to be created\r
+    //\r
+    if ((EFI_ERROR (Status)) && (OpenMode != (OpenMode &~EFI_FILE_MODE_CREATE))) {\r
       Status = LastHandle->Open (\r
                             LastHandle,\r
                             FileHandle,\r
                             ((FILEPATH_DEVICE_PATH*)*FilePath)->PathName,\r
       Status = LastHandle->Open (\r
                             LastHandle,\r
                             FileHandle,\r
                             ((FILEPATH_DEVICE_PATH*)*FilePath)->PathName,\r
-                            OpenMode &~EFI_FILE_MODE_CREATE,\r
-                            0\r
+                            OpenMode,\r
+                            Attributes\r
                             );\r
                             );\r
+    }\r
+    //\r
+    // Close the last node\r
+    //\r
+    LastHandle->Close (LastHandle);\r
 \r
 \r
-      //\r
-      // see if the error was that it needs to be created\r
-      //\r
-      if ((EFI_ERROR (Status)) && (OpenMode != (OpenMode &~EFI_FILE_MODE_CREATE))) {\r
-        Status = LastHandle->Open (\r
-                              LastHandle,\r
-                              FileHandle,\r
-                              ((FILEPATH_DEVICE_PATH*)*FilePath)->PathName,\r
-                              OpenMode,\r
-                              Attributes\r
-                              );\r
-      }\r
-      //\r
-      // Close the last node\r
-      //\r
-      LastHandle->Close (LastHandle);\r
-\r
-      if (EFI_ERROR(Status)) {\r
-        return (Status);\r
-      }\r
-\r
-      //\r
-      // Get the next node\r
-      //\r
-      *FilePath = NextDevicePathNode (*FilePath);\r
+    if (EFI_ERROR(Status)) {\r
+      return (Status);\r
     }\r
     }\r
-    return (EFI_SUCCESS);\r
+\r
+    //\r
+    // Get the next node\r
+    //\r
+    *FilePath = NextDevicePathNode (*FilePath);\r
   }\r
   }\r
+  return (EFI_SUCCESS);\r
 }\r
 \r
 /**\r
 }\r
 \r
 /**\r
@@ -544,6 +582,8 @@ ShellOpenFileByName(
     return (mEfiShellProtocol->OpenFileByName(FileName,\r
                                              FileHandle,\r
                                              OpenMode));\r
     return (mEfiShellProtocol->OpenFileByName(FileName,\r
                                              FileHandle,\r
                                              OpenMode));\r
+\r
+    ///@todo add the attributes\r
   } \r
   //\r
   // Using EFI Shell version\r
   } \r
   //\r
   // Using EFI Shell version\r
@@ -643,15 +683,7 @@ ShellReadFile(
   OUT VOID                      *Buffer\r
   )\r
 {\r
   OUT VOID                      *Buffer\r
   )\r
 {\r
-  //\r
-  // ASSERT if FileHandle is NULL\r
-  //\r
-  ASSERT (FileHandle != NULL);\r
-\r
-  //\r
-  // Perform the read based on EFI_FILE_PROTOCOL\r
-  //\r
-  return (FileHandle->Read(FileHandle, BufferSize, Buffer));\r
+  return (FileFunctionMap.ReadFile(FileHandle, BufferSize, Buffer));\r
 }\r
 \r
 \r
 }\r
 \r
 \r
@@ -687,14 +719,7 @@ ShellWriteFile(
   IN VOID                       *Buffer\r
   )\r
 {\r
   IN VOID                       *Buffer\r
   )\r
 {\r
-  //\r
-  // ASSERT if FileHandle is NULL\r
-  //\r
-  ASSERT (FileHandle != NULL);\r
-  //\r
-  // Perform the write based on EFI_FILE_PROTOCOL\r
-  //\r
-  return (FileHandle->Write(FileHandle, BufferSize, Buffer));\r
+  return (FileFunctionMap.WriteFile(FileHandle, BufferSize, Buffer));\r
 }\r
 \r
 /** \r
 }\r
 \r
 /** \r
@@ -714,18 +739,7 @@ ShellCloseFile (
   IN EFI_FILE_HANDLE            *FileHandle\r
   )\r
 {\r
   IN EFI_FILE_HANDLE            *FileHandle\r
   )\r
 {\r
-  EFI_STATUS Status;\r
-  //\r
-  // ASSERT if FileHandle is NULL\r
-  //\r
-  ASSERT (FileHandle != NULL);\r
-  ASSERT (*FileHandle != NULL);\r
-  //\r
-  // Perform the Close based on EFI_FILE_PROTOCOL\r
-  //\r
-  Status = (*FileHandle)->Close(*FileHandle);\r
-  *FileHandle = NULL;\r
-  return Status;\r
+  return (FileFunctionMap.CloseFile(*FileHandle));\r
 }\r
 \r
 /**\r
 }\r
 \r
 /**\r
@@ -748,18 +762,7 @@ ShellDeleteFile (
   IN EFI_FILE_HANDLE           *FileHandle\r
   )\r
 {\r
   IN EFI_FILE_HANDLE           *FileHandle\r
   )\r
 {\r
-  EFI_STATUS Status;\r
-  //\r
-  // ASSERT if FileHandle is NULL\r
-  //\r
-  ASSERT (FileHandle != NULL);\r
-  ASSERT (*FileHandle != NULL);\r
-  //\r
-  // Perform the Delete based on EFI_FILE_PROTOCOL\r
-  //\r
-  Status = (*FileHandle)->Delete(*FileHandle);\r
-  *FileHandle = NULL;\r
-  return Status;\r
+  return (FileFunctionMap.DeleteFile(*FileHandle));\r
 }\r
 \r
 /**\r
 }\r
 \r
 /**\r
@@ -788,14 +791,7 @@ ShellSetFilePosition (
   IN UINT64            Position\r
   )\r
 {\r
   IN UINT64            Position\r
   )\r
 {\r
-  //\r
-  // ASSERT if FileHandle is NULL\r
-  //\r
-  ASSERT (FileHandle != NULL);\r
-  //\r
-  // Perform the SetPosition based on EFI_FILE_PROTOCOL\r
-  //\r
-  return (FileHandle->SetPosition(FileHandle, Position));\r
+  return (FileFunctionMap.SetFilePosition(FileHandle, Position));\r
 }\r
 \r
 /** \r
 }\r
 \r
 /** \r
@@ -820,14 +816,7 @@ ShellGetFilePosition (
   OUT UINT64                    *Position\r
   )\r
 {\r
   OUT UINT64                    *Position\r
   )\r
 {\r
-  //\r
-  // ASSERT if FileHandle is NULL\r
-  //\r
-  ASSERT (FileHandle != NULL);\r
-  //\r
-  // Perform the GetPosition based on EFI_FILE_PROTOCOL\r
-  //\r
-  return (FileHandle->GetPosition(FileHandle, Position));\r
+  return (FileFunctionMap.GetFilePosition(FileHandle, Position));\r
 }\r
 /**\r
   Flushes data on a file\r
 }\r
 /**\r
   Flushes data on a file\r
@@ -849,69 +838,7 @@ ShellFlushFile (
   IN EFI_FILE_HANDLE            FileHandle\r
   )\r
 {\r
   IN EFI_FILE_HANDLE            FileHandle\r
   )\r
 {\r
-  //\r
-  // ASSERT if FileHandle is NULL\r
-  //\r
-  ASSERT (FileHandle != NULL);\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 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 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
-InternalShellIsDirectory (\r
-  IN EFI_FILE_HANDLE            DirHandle\r
-  )\r
-{\r
-  EFI_FILE_INFO *DirInfo;\r
-\r
-  //\r
-  // ASSERT if DirHandle is NULL\r
-  //\r
-  ASSERT(DirHandle != NULL);\r
-  \r
-  //\r
-  // get the file information for DirHandle\r
-  //\r
-  DirInfo     = ShellGetFileInfo (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
+  return (FileFunctionMap.FlushFile(FileHandle));\r
 }\r
 \r
 /**\r
 }\r
 \r
 /**\r
@@ -936,49 +863,13 @@ EFI_STATUS
 EFIAPI\r
 ShellFindFirstFile (\r
   IN EFI_FILE_HANDLE            DirHandle,\r
 EFIAPI\r
 ShellFindFirstFile (\r
   IN EFI_FILE_HANDLE            DirHandle,\r
-  OUT EFI_FILE_INFO             *Buffer\r
+  OUT EFI_FILE_INFO             **Buffer\r
   )\r
 {\r
   )\r
 {\r
-  EFI_STATUS    Status;\r
-  UINTN         BufferSize;\r
-\r
-  //\r
-  // ASSERT if DirHandle is NULL\r
-  //\r
-  ASSERT (DirHandle != NULL);\r
-  \r
-  //\r
-  // verify that DirHandle is a directory\r
-  //\r
-  Status = InternalShellIsDirectory(DirHandle);\r
-  if (EFI_ERROR(Status)) {\r
-    return (Status);\r
-  } \r
-\r
-  //\r
-  // reset to the begining of the directory \r
-  //\r
-  Status = ShellSetFilePosition (DirHandle, 0);\r
-  if (EFI_ERROR(Status)) {\r
-    return (Status);\r
-  } \r
-\r
   //\r
   //\r
-  // Allocate a buffer sized to struct size + enough for the string at the end\r
+  // pass to file handle lib\r
   //\r
   //\r
-  BufferSize = FIND_XXXXX_FILE_BUFFER_SIZE;\r
-  Buffer = AllocateZeroPool(BufferSize);\r
-  ASSERT (Buffer != NULL);\r
-\r
-  //\r
-  // read in the info about the first file\r
-  //\r
-  Status = ShellReadFile (DirHandle, &BufferSize, Buffer);\r
-  ASSERT(Status != EFI_BUFFER_TOO_SMALL);\r
-  if (EFI_ERROR(Status)) {\r
-    return (Status);\r
-  }\r
-  return (EFI_SUCCESS);\r
+  return (FileHandleFindFirstFile(DirHandle, Buffer));\r
 }\r
 /**\r
   Retrieves the next file in a directory.\r
 }\r
 /**\r
   Retrieves the next file in a directory.\r
@@ -1007,47 +898,10 @@ ShellFindNextFile(
   OUT BOOLEAN                    *NoFile\r
   )\r
 {\r
   OUT BOOLEAN                    *NoFile\r
   )\r
 {\r
-  EFI_STATUS    Status;\r
-  UINTN         BufferSize;\r
-\r
   //\r
   //\r
-  // ASSERTs for DirHandle or Buffer or NoFile poitners being NULL\r
+  // pass to file handle lib\r
   //\r
   //\r
-  ASSERT (DirHandle != NULL);\r
-  ASSERT (Buffer    != NULL);\r
-  ASSERT (NoFile    != NULL);\r
-  \r
-  //\r
-  // verify that DirHandle is a directory\r
-  //\r
-  Status = InternalShellIsDirectory(DirHandle);\r
-  if (EFI_ERROR(Status)) {\r
-    return (Status);\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 = ShellReadFile (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
+  return (FileHandleFindNextFile(DirHandle, Buffer, NoFile));\r
 }\r
 /**\r
   Retrieve the size of a file.\r
 }\r
 /**\r
   Retrieve the size of a file.\r
@@ -1071,33 +925,7 @@ ShellGetFileSize (
   OUT UINT64                    *Size\r
   )\r
 {\r
   OUT UINT64                    *Size\r
   )\r
 {\r
-  EFI_FILE_INFO                 *FileInfo;\r
-\r
-  //\r
-  // ASSERT for FileHandle or Size being NULL\r
-  //\r
-  ASSERT (FileHandle != NULL);\r
-  ASSERT (Size != NULL);\r
-  \r
-  //\r
-  // get the FileInfo structure\r
-  //\r
-  FileInfo = ShellGetFileInfo(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
+  return (FileFunctionMap.GetFileSize(FileHandle, Size));\r
 }\r
 /**\r
   Retrieves the status of the break execution flag\r
 }\r
 /**\r
   Retrieves the status of the break execution flag\r
@@ -1366,7 +1194,7 @@ ShellSetPageBreakMode (
 /// This allows for the struct to be populated.\r
 ///\r
 typedef struct {\r
 /// This allows for the struct to be populated.\r
 ///\r
 typedef struct {\r
-  EFI_LIST_ENTRY Link;\r
+  LIST_ENTRY Link;\r
   EFI_STATUS Status;\r
   CHAR16 *FullName;\r
   CHAR16 *FileName;\r
   EFI_STATUS Status;\r
   CHAR16 *FullName;\r
   CHAR16 *FileName;\r
@@ -1390,12 +1218,12 @@ typedef struct {
 LIST_ENTRY*\r
 EFIAPI\r
 InternalShellConvertFileListType (\r
 LIST_ENTRY*\r
 EFIAPI\r
 InternalShellConvertFileListType (\r
-  EFI_LIST_ENTRY                *FileList\r
+  LIST_ENTRY                *FileList\r
   )\r
 {\r
   LIST_ENTRY                    *ListHead;\r
   SHELL_FILE_ARG                *OldInfo;\r
   )\r
 {\r
   LIST_ENTRY                    *ListHead;\r
   SHELL_FILE_ARG                *OldInfo;\r
-  EFI_LIST_ENTRY                *Link;\r
+  LIST_ENTRY                *Link;\r
   EFI_SHELL_FILE_INFO_NO_CONST  *NewInfo;\r
 \r
   //\r
   EFI_SHELL_FILE_INFO_NO_CONST  *NewInfo;\r
 \r
   //\r
@@ -1406,14 +1234,14 @@ InternalShellConvertFileListType (
   //\r
   // Allocate our list head and initialize the list\r
   //\r
   //\r
   // Allocate our list head and initialize the list\r
   //\r
-  ListHead = AllocateZeroPool(sizeof(EFI_LIST_ENTRY));\r
+  ListHead = AllocateZeroPool(sizeof(LIST_ENTRY));\r
   ASSERT (ListHead != NULL);\r
   ListHead = InitializeListHead (ListHead);\r
 \r
   //\r
   // enumerate through each member of the old list and copy\r
   //\r
   ASSERT (ListHead != NULL);\r
   ListHead = InitializeListHead (ListHead);\r
 \r
   //\r
   // enumerate through each member of the old list and copy\r
   //\r
-  for (Link = FileList->Flink; Link != FileList; Link = Link->Flink) {\r
+  for (Link = FileList->ForwardLink; Link != FileList; Link = Link->ForwardLink) {\r
     OldInfo = CR (Link, SHELL_FILE_ARG, Link, SHELL_FILE_ARG_SIGNATURE);\r
 \r
     //\r
     OldInfo = CR (Link, SHELL_FILE_ARG, Link, SHELL_FILE_ARG_SIGNATURE);\r
 \r
     //\r
@@ -1435,6 +1263,9 @@ InternalShellConvertFileListType (
     NewInfo->Handle       = OldInfo->Handle;\r
     NewInfo->Status       = OldInfo->Status;\r
 \r
     NewInfo->Handle       = OldInfo->Handle;\r
     NewInfo->Status       = OldInfo->Status;\r
 \r
+    // old shell checks for 0 not NULL\r
+    OldInfo->Handle = 0;\r
+\r
     //\r
     // allocate new space to copy strings and structure\r
     //\r
     //\r
     // allocate new space to copy strings and structure\r
     //\r
@@ -1497,15 +1328,8 @@ ShellOpenFileMetaArg (
 {\r
   EFI_STATUS                    Status;\r
   LIST_ENTRY                    *EmptyNode;\r
 {\r
   EFI_STATUS                    Status;\r
   LIST_ENTRY                    *EmptyNode;\r
-\r
-  //\r
-  // make sure we have no outstanding list\r
-  //\r
-  if (mOldStyleFileList != NULL) {\r
-    *ListHead = NULL;\r
-    return (EFI_UNSUPPORTED);\r
-  }\r
-\r
+  LIST_ENTRY                    *mOldStyleFileList;\r
+  \r
   //\r
   // ASSERT that Arg and ListHead are not NULL\r
   //\r
   //\r
   // ASSERT that Arg and ListHead are not NULL\r
   //\r
@@ -1529,7 +1353,7 @@ ShellOpenFileMetaArg (
   //\r
   // allocate memory for old list head\r
   //\r
   //\r
   // allocate memory for old list head\r
   //\r
-  mOldStyleFileList = (EFI_LIST_ENTRY*)AllocatePool(sizeof(EFI_LIST_ENTRY));\r
+  mOldStyleFileList = (LIST_ENTRY*)AllocatePool(sizeof(LIST_ENTRY));\r
   ASSERT(mOldStyleFileList != NULL);\r
 \r
   //\r
   ASSERT(mOldStyleFileList != NULL);\r
 \r
   //\r
@@ -1551,6 +1375,13 @@ ShellOpenFileMetaArg (
   //\r
   EmptyNode = InternalShellConvertFileListType(mOldStyleFileList);\r
 \r
   //\r
   EmptyNode = InternalShellConvertFileListType(mOldStyleFileList);\r
 \r
+  //\r
+  // Free the EFI Shell version that was converted.\r
+  //\r
+  ASSERT_EFI_ERROR(mEfiShellEnvironment2->FreeFileList(mOldStyleFileList));\r
+  FreePool(mOldStyleFileList);\r
+  mOldStyleFileList = NULL;\r
+\r
   //\r
   // remove the empty head of the list\r
   //\r
   //\r
   // remove the empty head of the list\r
   //\r
@@ -1587,19 +1418,13 @@ ShellCloseFileMetaArg (
   if (mEfiShellProtocol != NULL) {\r
     return (mEfiShellProtocol->FreeFileList(ListHead));\r
   } else {\r
   if (mEfiShellProtocol != NULL) {\r
     return (mEfiShellProtocol->FreeFileList(ListHead));\r
   } else {\r
-    //\r
-    // Free the EFI Shell version that was converted.\r
-    //\r
-    ASSERT_EFI_ERROR(mEfiShellEnvironment2->FreeFileList(mOldStyleFileList));\r
-    FreePool(mOldStyleFileList);\r
-    mOldStyleFileList = NULL;\r
-\r
     //\r
     // Since this is EFI Shell version we need to free our internally made copy \r
     // of the list\r
     //\r
     for (Node = GetFirstNode((LIST_ENTRY*)*ListHead) ; IsListEmpty((LIST_ENTRY*)*ListHead) == FALSE ; Node = GetFirstNode((LIST_ENTRY*)*ListHead)) {\r
       RemoveEntryList(Node);\r
     //\r
     // Since this is EFI Shell version we need to free our internally made copy \r
     // of the list\r
     //\r
     for (Node = GetFirstNode((LIST_ENTRY*)*ListHead) ; IsListEmpty((LIST_ENTRY*)*ListHead) == FALSE ; Node = GetFirstNode((LIST_ENTRY*)*ListHead)) {\r
       RemoveEntryList(Node);\r
+      ((EFI_SHELL_FILE_INFO_NO_CONST*)Node)->Handle->Close(((EFI_SHELL_FILE_INFO_NO_CONST*)Node)->Handle);\r
       FreePool(((EFI_SHELL_FILE_INFO_NO_CONST*)Node)->FullName);\r
       FreePool(((EFI_SHELL_FILE_INFO_NO_CONST*)Node)->FileName);\r
       FreePool(((EFI_SHELL_FILE_INFO_NO_CONST*)Node)->Info);\r
       FreePool(((EFI_SHELL_FILE_INFO_NO_CONST*)Node)->FullName);\r
       FreePool(((EFI_SHELL_FILE_INFO_NO_CONST*)Node)->FileName);\r
       FreePool(((EFI_SHELL_FILE_INFO_NO_CONST*)Node)->Info);\r
@@ -1610,7 +1435,7 @@ ShellCloseFileMetaArg (
 }\r
 \r
 typedef struct {\r
 }\r
 \r
 typedef struct {\r
-  EFI_LIST_ENTRY List;\r
+  LIST_ENTRY List;\r
   CHAR16         *Name;\r
   ParamType      Type;\r
   CHAR16         *Value;\r
   CHAR16         *Name;\r
   ParamType      Type;\r
   CHAR16         *Value;\r
@@ -1634,7 +1459,7 @@ typedef struct {
 **/\r
 BOOLEAN\r
 EFIAPI\r
 **/\r
 BOOLEAN\r
 EFIAPI\r
-IsCheckList (\r
+InternalIsOnCheckList (\r
   IN CONST CHAR16               *Name,\r
   IN CONST SHELL_PARAM_ITEM     *CheckList,\r
   OUT ParamType                 *Type\r
   IN CONST CHAR16               *Name,\r
   IN CONST SHELL_PARAM_ITEM     *CheckList,\r
   OUT ParamType                 *Type\r
@@ -1649,6 +1474,15 @@ IsCheckList (
   ASSERT(Type       != NULL);\r
   ASSERT(Name       != NULL);\r
 \r
   ASSERT(Type       != NULL);\r
   ASSERT(Name       != NULL);\r
 \r
+  //\r
+  // question mark and page break mode are always supported\r
+  //\r
+  if ((StrCmp(Name, L"-?") == 0) ||\r
+      (StrCmp(Name, L"-b") == 0)\r
+      ) {\r
+     return (TRUE);\r
+  }\r
+\r
   //\r
   // Enumerate through the list\r
   //\r
   //\r
   // Enumerate through the list\r
   //\r
@@ -1664,7 +1498,7 @@ IsCheckList (
   return (FALSE);\r
 }\r
 /**\r
   return (FALSE);\r
 }\r
 /**\r
-  Checks the string for indicators of "flag" status.  this is a leading '/' or '-'\r
+  Checks the string for indicators of "flag" status.  this is a leading '/', '-', or '+'\r
 \r
   @param Name                   pointer to Name of parameter found\r
 \r
 \r
   @param Name                   pointer to Name of parameter found\r
 \r
@@ -1673,7 +1507,7 @@ IsCheckList (
 **/\r
 BOOLEAN\r
 EFIAPI\r
 **/\r
 BOOLEAN\r
 EFIAPI\r
-IsFlag (\r
+InternalIsFlag (\r
   IN CONST CHAR16               *Name\r
   )\r
 {\r
   IN CONST CHAR16               *Name\r
   )\r
 {\r
@@ -1685,7 +1519,10 @@ IsFlag (
   //\r
   // If the Name has a / or - as the first character return TRUE\r
   //\r
   //\r
   // If the Name has a / or - as the first character return TRUE\r
   //\r
-  if ((Name[0] == L'/') || (Name[0] == L'-') ) {\r
+  if ((Name[0] == L'/') || \r
+      (Name[0] == L'-') ||\r
+      (Name[0] == L'+')\r
+      ) {\r
       return (TRUE);\r
   }\r
   return (FALSE);\r
       return (TRUE);\r
   }\r
   return (FALSE);\r
@@ -1699,7 +1536,8 @@ IsFlag (
   @param CheckList              pointer to list of parameters to check\r
   @param CheckPackage           pointer to pointer to list checked values\r
   @param ProblemParam           optional pointer to pointer to unicode string for \r
   @param CheckList              pointer to list of parameters to check\r
   @param CheckPackage           pointer to pointer to list checked values\r
   @param ProblemParam           optional pointer to pointer to unicode string for \r
-                                the paramater that caused failure.\r
+                                the paramater that caused failure.  If used then the\r
+                                caller is responsible for freeing the memory.\r
   @param AutoPageBreak          will automatically set PageBreakEnabled for "b" parameter\r
   @param Argc                   Count of parameters in Argv\r
   @param Argv                   pointer to array of parameters\r
   @param AutoPageBreak          will automatically set PageBreakEnabled for "b" parameter\r
   @param Argc                   Count of parameters in Argv\r
   @param Argv                   pointer to array of parameters\r
@@ -1774,7 +1612,7 @@ InternalCommandLineParse (
       ASSERT(CurrentItemPackage->Value != NULL);\r
       StrCpy(CurrentItemPackage->Value, Argv[LoopCounter]);\r
       InsertTailList(*CheckPackage, (LIST_ENTRY*)CurrentItemPackage);\r
       ASSERT(CurrentItemPackage->Value != NULL);\r
       StrCpy(CurrentItemPackage->Value, Argv[LoopCounter]);\r
       InsertTailList(*CheckPackage, (LIST_ENTRY*)CurrentItemPackage);\r
-    } else if (IsFlag(Argv[LoopCounter]) == FALSE) {\r
+    } else if (InternalIsFlag(Argv[LoopCounter]) == FALSE) {\r
       //\r
       // add this one as a non-flag\r
       //\r
       //\r
       // add this one as a non-flag\r
       //\r
@@ -1787,7 +1625,7 @@ InternalCommandLineParse (
       StrCpy(CurrentItemPackage->Value, Argv[LoopCounter]);\r
       CurrentItemPackage->OriginalPosition = Count++;\r
       InsertTailList(*CheckPackage, (LIST_ENTRY*)CurrentItemPackage);\r
       StrCpy(CurrentItemPackage->Value, Argv[LoopCounter]);\r
       CurrentItemPackage->OriginalPosition = Count++;\r
       InsertTailList(*CheckPackage, (LIST_ENTRY*)CurrentItemPackage);\r
-    } else if (IsCheckList(Argv[LoopCounter], CheckList, &CurrentItemType) == TRUE) {\r
+    } else if (InternalIsOnCheckList(Argv[LoopCounter], CheckList, &CurrentItemType) == TRUE) {\r
       //\r
       // this is a flag\r
       //\r
       //\r
       // this is a flag\r
       //\r
@@ -1818,7 +1656,9 @@ InternalCommandLineParse (
       //\r
       // this was a non-recognised flag... error!\r
       //\r
       //\r
       // this was a non-recognised flag... error!\r
       //\r
-      *ProblemParam = (CHAR16*)Argv[LoopCounter];\r
+      *ProblemParam = AllocatePool(StrSize(Argv[LoopCounter]));\r
+      ASSERT(*ProblemParam != NULL);\r
+      StrCpy(*ProblemParam, Argv[LoopCounter]);\r
       ShellCommandLineFreeVarList(*CheckPackage);\r
       *CheckPackage = NULL;\r
       return (EFI_VOLUME_CORRUPTED);\r
       ShellCommandLineFreeVarList(*CheckPackage);\r
       *CheckPackage = NULL;\r
       return (EFI_VOLUME_CORRUPTED);\r
diff --git a/ShellPkg/Library/BaseShellLib/BaseShellLib.h b/ShellPkg/Library/BaseShellLib/BaseShellLib.h
new file mode 100644 (file)
index 0000000..1620641
--- /dev/null
@@ -0,0 +1,26 @@
+/** @file\r
+  Provides interface to shell functionality for shell commands and applications.\r
+\r
+Copyright (c) 2006 - 2009, Intel Corporation\r
+All rights reserved. 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
+typedef struct  {\r
+  EFI_SHELL_GET_FILE_INFO                   GetFileInfo;\r
+  EFI_SHELL_SET_FILE_INFO                   SetFileInfo;\r
+  EFI_SHELL_READ_FILE                       ReadFile;\r
+  EFI_SHELL_WRITE_FILE                      WriteFile;\r
+  EFI_SHELL_CLOSE_FILE                      CloseFile;\r
+  EFI_SHELL_DELETE_FILE                     DeleteFile;\r
+  EFI_SHELL_GET_FILE_POSITION               GetFilePosition;\r
+  EFI_SHELL_SET_FILE_POSITION               SetFilePosition;\r
+  EFI_SHELL_FLUSH_FILE                      FlushFile;\r
+  EFI_SHELL_GET_FILE_SIZE                   GetFileSize;\r
+} FILE_HANDLE_FUNCTION_MAP;\r
index 8a2c33b8a1c4dd4dbbcb754f295afc3956e2ec9b..71c68cb280c3ccff288b39cd916d6a51dc3748d2 100644 (file)
@@ -29,6 +29,7 @@
 \r
 [Sources.common]\r
   BaseShellLib.c\r
 \r
 [Sources.common]\r
   BaseShellLib.c\r
+  BaseShellLib.h\r
 \r
 [Packages]\r
   MdePkg/MdePkg.dec\r
 \r
 [Packages]\r
   MdePkg/MdePkg.dec\r
@@ -41,6 +42,7 @@
   BaseLib\r
   BaseMemoryLib\r
   DebugLib\r
   BaseLib\r
   BaseMemoryLib\r
   DebugLib\r
+  FileHandleLib\r
 \r
 [Protocols]\r
   gEfiSimpleFileSystemProtocolGuid              # ALWAYS_CONSUMED\r
 \r
 [Protocols]\r
   gEfiSimpleFileSystemProtocolGuid              # ALWAYS_CONSUMED\r
@@ -58,4 +60,4 @@
   gEfiShellEnvironment2ExtGuid                  # ALWAYS_CONSUMED\r
 \r
 [Pcd.common]\r
   gEfiShellEnvironment2ExtGuid                  # ALWAYS_CONSUMED\r
 \r
 [Pcd.common]\r
-\r
+  gEfiShellPkgTokenSpaceGuid.PcdShellLibAutoInitialize  # ALWAYS_CONSUMED\r
index 922ad5e8ad19c1048a74e4d965739e4e528dc9ea..65b62a0827335e0fca6a78378e8dc97d69d13dd4 100644 (file)
@@ -20,7 +20,7 @@
   DEC_SPECIFICATION              = 0x00010005\r
   PACKAGE_NAME                   = ShellPkg\r
   PACKAGE_GUID                   = 9FB7587C-93F7-40a7-9C04-FD7BA94EE646\r
   DEC_SPECIFICATION              = 0x00010005\r
   PACKAGE_NAME                   = ShellPkg\r
   PACKAGE_GUID                   = 9FB7587C-93F7-40a7-9C04-FD7BA94EE646\r
-  PACKAGE_VERSION                = 0.1\r
+  PACKAGE_VERSION                = 0.2\r
 \r
 \r
 [Includes.common]\r
 \r
 \r
 [Includes.common]\r
   ##\r
   ShellLib|Include/Library/ShellLib.h\r
 \r
   ##\r
   ShellLib|Include/Library/ShellLib.h\r
 \r
+  ##  @libraryclass  provides EFI_FILE_HANDLE services\r
+  ##                 used by Shell and ShellLib\r
+  ##\r
+  FileHandleLib|Include/Library/FileHandleLib.h\r
+\r
+\r
 [Guids.common]\r
   gEfiShellEnvironment2ExtGuid    = {0xd2c18636, 0x40e5, 0x4eb5, {0xa3, 0x1b, 0x36, 0x69, 0x5f, 0xd4, 0x2c, 0x87}}\r
 [Guids.common]\r
   gEfiShellEnvironment2ExtGuid    = {0xd2c18636, 0x40e5, 0x4eb5, {0xa3, 0x1b, 0x36, 0x69, 0x5f, 0xd4, 0x2c, 0x87}}\r
+  gEfiShellPkgTokenSpaceGuid     = {0x171e9188, 0x31d3, 0x40f5, {0xb1, 0x0c, 0x53, 0x9b, 0x2d, 0xb9, 0x40, 0xcd}}\r
 \r
 [Protocols.common]\r
   gEfiShellProtocolGuid           = {0x6302d008, 0x7f9b, 0x4f30, {0x87, 0xac, 0x60, 0xc9, 0xfe, 0xf5, 0xda, 0x4e}}\r
 \r
 [Protocols.common]\r
   gEfiShellProtocolGuid           = {0x6302d008, 0x7f9b, 0x4f30, {0x87, 0xac, 0x60, 0xc9, 0xfe, 0xf5, 0xda, 0x4e}}\r
   gEfiShellEnvironment2Guid       = {0x47c7b221, 0xc42a, 0x11d2, {0x8e, 0x57, 0x00, 0xa0, 0xc9, 0x69, 0x72, 0x3b}}\r
   gEfiShellInterfaceGuid          = {0x47c7b223, 0xc42a, 0x11d2, {0x8e, 0x57, 0x00, 0xa0, 0xc9, 0x69, 0x72, 0x3b}}\r
 \r
   gEfiShellEnvironment2Guid       = {0x47c7b221, 0xc42a, 0x11d2, {0x8e, 0x57, 0x00, 0xa0, 0xc9, 0x69, 0x72, 0x3b}}\r
   gEfiShellInterfaceGuid          = {0x47c7b223, 0xc42a, 0x11d2, {0x8e, 0x57, 0x00, 0xa0, 0xc9, 0x69, 0x72, 0x3b}}\r
 \r
-[PcdsFeatureFlag.common]\r
-\r
-[PcdsFixedAtBuild.common]\r
-\r
-[PcdsPatchableInModule.common]\r
-\r
-[PcdsDynamic.common]
\ No newline at end of file
+[PcdsFixedAtBuild,PcdsPatchableInModule,PcdsDynamic]\r
+  ## This flag is used to control initialization of the shell library\r
+  ## This should be FALSE for compiling the shell application itself onlty.\r
+  gEfiShellPkgTokenSpaceGuid.PcdShellLibAutoInitialize|TRUE|BOOLEAN|0x00000005
\ No newline at end of file
index ebe872aa7b5045d5ed0671f1a9b9b6f48f012b12..787c37427056c4913e59bed9947593516b02d78b 100644 (file)
@@ -1,8 +1,5 @@
 #/** @file\r
 # Shell Package\r
 #/** @file\r
 # Shell Package\r
-# This is the first release of the Shell package.  Please be aware that there will \r
-# probably be higher than usual numbers of changes as the package gets used and issues, \r
-# enhancements, and bugs are found and fixed.\r
 #\r
 # Copyright (c) 2007 - 2008, Intel Corporation\r
 #\r
 #\r
 # Copyright (c) 2007 - 2008, Intel Corporation\r
 #\r
@@ -19,8 +16,8 @@
 [Defines]\r
   PLATFORM_NAME                  = Shell\r
   PLATFORM_GUID                  = E1DC9BF8-7013-4c99-9437-795DAA45F3BD\r
 [Defines]\r
   PLATFORM_NAME                  = Shell\r
   PLATFORM_GUID                  = E1DC9BF8-7013-4c99-9437-795DAA45F3BD\r
-  PLATFORM_VERSION               = 0.1\r
-  DSC_SPECIFICATION              = 0x00010005\r
+  PLATFORM_VERSION               = 0.2\r
+  DSC_SPECIFICATION              = 0x00010006\r
   OUTPUT_DIRECTORY               = Build/Shell\r
   SUPPORTED_ARCHITECTURES        = IA32|IPF|X64|EBC\r
   BUILD_TARGETS                  = DEBUG|RELEASE\r
   OUTPUT_DIRECTORY               = Build/Shell\r
   SUPPORTED_ARCHITECTURES        = IA32|IPF|X64|EBC\r
   BUILD_TARGETS                  = DEBUG|RELEASE\r
   MemoryAllocationLib|MdePkg/Library/UefiMemoryAllocationLib/UefiMemoryAllocationLib.inf\r
   UefiLib|MdePkg/Library/UefiLib/UefiLib.inf\r
   BaseLib|MdePkg/Library/BaseLib/BaseLib.inf\r
   MemoryAllocationLib|MdePkg/Library/UefiMemoryAllocationLib/UefiMemoryAllocationLib.inf\r
   UefiLib|MdePkg/Library/UefiLib/UefiLib.inf\r
   BaseLib|MdePkg/Library/BaseLib/BaseLib.inf\r
-  BaseMemoryLib|MdePkg/Library/BaseMemoryLibOptDxe/BaseMemoryLibOptDxe.inf\r
+  BaseMemoryLib|MdePkg/Library/BaseMemoryLib/BaseMemoryLib.inf\r
   PrintLib|MdeModulePkg/Library/DxePrintLibPrint2Protocol/DxePrintLibPrint2Protocol.inf\r
   UefiRuntimeServicesTableLib|MdePkg/Library/UefiRuntimeServicesTableLib/UefiRuntimeServicesTableLib.inf\r
   PrintLib|MdeModulePkg/Library/DxePrintLibPrint2Protocol/DxePrintLibPrint2Protocol.inf\r
   UefiRuntimeServicesTableLib|MdePkg/Library/UefiRuntimeServicesTableLib/UefiRuntimeServicesTableLib.inf\r
+  \r
   ShellLib|ShellPkg/Library/BaseShellLib/BaseShellLib.inf\r
   ShellLib|ShellPkg/Library/BaseShellLib/BaseShellLib.inf\r
+  FileHandleLib|ShellPkg/Library/BaseFileHandleLib/BaseFileHandleLib.inf\r
 \r
 [PcdsFixedAtBuild.common]\r
 \r
 [Components.common]\r
 \r
 [PcdsFixedAtBuild.common]\r
 \r
 [Components.common]\r
-  ShellPkg/Library/BaseShellLib/BaseShellLib.inf\r
   ShellPkg/Application/ShellExecTestApp/SA.inf\r
   ShellPkg/Application/ShellLibTestApp/SA3.inf
\ No newline at end of file
   ShellPkg/Application/ShellExecTestApp/SA.inf\r
   ShellPkg/Application/ShellLibTestApp/SA3.inf
\ No newline at end of file