--- /dev/null
+/** @file\r
+ This is a simple shell application\r
+\r
+ Copyright (c) 2008, 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/UefiApplicationEntryPoint.h>\r
+#include <Library/UefiLib.h>\r
+\r
+/**\r
+ as the real entry point for the application.\r
+\r
+ @param[in] ImageHandle The firmware allocated handle for the EFI image. \r
+ @param[in] SystemTable A pointer to the EFI System Table.\r
+ \r
+ @retval EFI_SUCCESS The entry point is executed successfully.\r
+ @retval other Some error occurs when executing this entry point.\r
+\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+UefiMain (\r
+ IN EFI_HANDLE ImageHandle,\r
+ IN EFI_SYSTEM_TABLE *SystemTable\r
+ )\r
+{\r
+ Print(L"ShellExecute - Pass"); \r
+ return EFI_SUCCESS;\r
+}
\ No newline at end of file
--- /dev/null
+#/** @file\r
+# Sample UEFI Application Reference EDKII Module\r
+#\r
+# This is a simple shell application\r
+#\r
+# Copyright (c) 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 = 0x00010005\r
+ BASE_NAME = EmptyApplication\r
+ FILE_GUID = 8F7D7B1D-0E1C-4c98-B12E-4EC99C4081AC\r
+ MODULE_TYPE = UEFI_APPLICATION\r
+ VERSION_STRING = 1.0\r
+ ENTRY_POINT = UefiMain\r
+\r
+#\r
+# The following information is for reference only and not required by the build tools.\r
+#\r
+# VALID_ARCHITECTURES = IA32 X64 IPF EBC\r
+#\r
+\r
+[Sources]\r
+ SA.C\r
+\r
+[Packages]\r
+ MdePkg/MdePkg.dec\r
+ \r
+[LibraryClasses]\r
+ UefiApplicationEntryPoint\r
+ UefiLib\r
+ \r
+[Guids]\r
+\r
+[Ppis]\r
+\r
+[Protocols]\r
+\r
+[FeaturePcd]\r
+\r
+[Pcd]\r
--- /dev/null
+#/** @file\r
+# Sample UEFI Application Reference EDKII Module\r
+#\r
+# This is a simple shell application\r
+#\r
+# Copyright (c) 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 = 0x00010005\r
+ BASE_NAME = SimpleApplication\r
+ FILE_GUID = 10C75C00-3052-4467-9ED8-7196CAAF610F\r
+ MODULE_TYPE = UEFI_APPLICATION\r
+ VERSION_STRING = 1.0\r
+ ENTRY_POINT = UefiMain\r
+\r
+#\r
+# The following information is for reference only and not required by the build tools.\r
+#\r
+# VALID_ARCHITECTURES = IA32 X64 IPF EBC\r
+#\r
+\r
+[Sources]\r
+ sa3.c\r
+\r
+[Packages]\r
+ MdePkg/MdePkg.dec\r
+ ShellPkg/ShellPkg.dec\r
+ \r
+[LibraryClasses]\r
+ UefiApplicationEntryPoint\r
+ UefiLib\r
+ ShellLib\r
+ MemoryAllocationLib\r
+ DebugLib\r
+ \r
+[Guids]\r
+\r
+[Ppis]\r
+\r
+[Protocols]\r
+\r
+[FeaturePcd]\r
+\r
+[Pcd]\r
--- /dev/null
+/** @file\r
+ This is a simple shell application\r
+\r
+ This should be executed with "/Param2 Val1" and "/Param1" as the 2 command line options!\r
+\r
+ Copyright (c) 2008, 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/UefiApplicationEntryPoint.h>\r
+#include <Library/UefiLib.h>\r
+#include <Library/ShellLib.h>\r
+#include <Library/DebugLib.h>\r
+#include <Library/MemoryAllocationLib.h>\r
+\r
+SHELL_PARAM_ITEM ParamList[] = {\r
+ {L"/Param1", TypeFlag},\r
+ {L"/Param2", TypeValue},\r
+ {NULL, TypeMax}};\r
+\r
+/**\r
+ as the real entry point for the application.\r
+\r
+ @param[in] ImageHandle The firmware allocated handle for the EFI image. \r
+ @param[in] SystemTable A pointer to the EFI System Table.\r
+ \r
+ @retval EFI_SUCCESS The entry point is executed successfully.\r
+ @retval other Some error occurs when executing this entry point.\r
+\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+UefiMain (\r
+ IN EFI_HANDLE ImageHandle,\r
+ IN EFI_SYSTEM_TABLE *SystemTable\r
+ )\r
+{\r
+ EFI_FILE_HANDLE FileHandle;\r
+ EFI_STATUS Status;\r
+ CHAR16 FileName[100];\r
+ UINTN BufferSize;\r
+ UINT64 Position;\r
+ UINT8 Buffer[200];\r
+ EFI_FILE_INFO *pFileInfo;\r
+ UINT64 Size;\r
+ BOOLEAN NoFile;\r
+ EFI_SHELL_FILE_INFO *pShellFileInfo, *pShellFileInfo2;\r
+ LIST_ENTRY *List;\r
+ \r
+ FileHandle = NULL;\r
+ StrCpy(FileName, L"testfile.txt");\r
+ Position = 0;\r
+ pFileInfo = NULL;\r
+ Size = 0;\r
+ NoFile = FALSE;\r
+ pShellFileInfo = NULL;\r
+ List = NULL;\r
+\r
+ ASSERT(ShellGetExecutionBreakFlag() == FALSE);\r
+ ASSERT(StrCmp(ShellGetCurrentDir(NULL), L"f8:\\") == 0);\r
+ Print(L"execution break and get cur dir - pass\r\n");\r
+\r
+ ShellSetPageBreakMode(TRUE);\r
+\r
+ Status = ShellOpenFileByName(FileName, \r
+ &FileHandle, \r
+ EFI_FILE_MODE_CREATE|EFI_FILE_MODE_READ|EFI_FILE_MODE_WRITE, \r
+ 0\r
+ );\r
+ ASSERT_EFI_ERROR(Status);\r
+\r
+ BufferSize = StrSize(FileName);\r
+ Status = ShellWriteFile(FileHandle, &BufferSize, FileName);\r
+ ASSERT_EFI_ERROR(Status);\r
+ Status = ShellGetFilePosition(FileHandle, &Position);\r
+ ASSERT_EFI_ERROR(Status);\r
+ ASSERT(Position == 0x1A);\r
+ Status = ShellSetFilePosition(FileHandle, 0);\r
+ ASSERT_EFI_ERROR(Status);\r
+ BufferSize = sizeof(Buffer) * sizeof(Buffer[0]);\r
+ Status = ShellReadFile(FileHandle, &BufferSize, Buffer);\r
+ ASSERT_EFI_ERROR(Status);\r
+ ASSERT(BufferSize == 0x1A);\r
+ ASSERT(StrCmp((CHAR16*)Buffer, FileName) == 0);\r
+ pFileInfo = ShellGetFileInfo(FileHandle);\r
+ ASSERT(pFileInfo != NULL);\r
+ ASSERT(StrCmp(pFileInfo->FileName, FileName) == 0);\r
+ ASSERT(pFileInfo->FileSize == 0x1A);\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
+ Status = ShellOpenFileByName(FileName, \r
+ &FileHandle, \r
+ EFI_FILE_MODE_CREATE|EFI_FILE_MODE_READ|EFI_FILE_MODE_WRITE, \r
+ 0\r
+ );\r
+ ASSERT_EFI_ERROR(Status);\r
+ pFileInfo = ShellGetFileInfo(FileHandle);\r
+ ASSERT(pFileInfo != NULL);\r
+ pFileInfo->FileSize = 0x20;\r
+ Status = ShellSetFileInfo(FileHandle, pFileInfo);\r
+ FreePool(pFileInfo);\r
+ pFileInfo = NULL; \r
+ ASSERT_EFI_ERROR(Status);\r
+ pFileInfo = ShellGetFileInfo(FileHandle);\r
+ ASSERT(pFileInfo != NULL);\r
+ ASSERT(StrCmp(pFileInfo->FileName, FileName) == 0);\r
+ ASSERT(pFileInfo->PhysicalSize == 0x20);\r
+ ASSERT(pFileInfo->FileSize == 0x20);\r
+ ASSERT((pFileInfo->Attribute&EFI_FILE_DIRECTORY)==0);\r
+ FreePool(pFileInfo);\r
+ Status = ShellGetFileSize(FileHandle, &Size);\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
+ Status = ShellOpenFileByName(FileName, \r
+ &FileHandle, \r
+ EFI_FILE_MODE_CREATE|EFI_FILE_MODE_READ|EFI_FILE_MODE_WRITE, \r
+ 0\r
+ );\r
+ ASSERT_EFI_ERROR(Status);\r
+\r
+ pFileInfo = ShellGetFileInfo(FileHandle);\r
+ ASSERT(pFileInfo != NULL);\r
+ ASSERT(StrCmp(pFileInfo->FileName, FileName) == 0);\r
+ ASSERT(pFileInfo->PhysicalSize == 0x20);\r
+ ASSERT(pFileInfo->FileSize == 0x20);\r
+ ASSERT((pFileInfo->Attribute&EFI_FILE_DIRECTORY)==0);\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
+ Status = ShellOpenFileByName(FileName, \r
+ &FileHandle, \r
+ EFI_FILE_MODE_CREATE|EFI_FILE_MODE_READ|EFI_FILE_MODE_WRITE, \r
+ 0\r
+ );\r
+ ASSERT_EFI_ERROR(Status);\r
+ pFileInfo = ShellGetFileInfo(FileHandle);\r
+ ASSERT(pFileInfo != NULL);\r
+ ASSERT(StrCmp(pFileInfo->FileName, FileName) == 0);\r
+ ASSERT(pFileInfo->PhysicalSize == 0x0);\r
+ ASSERT(pFileInfo->FileSize == 0x0);\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
+ Status = ShellOpenFileByName(FileName, \r
+ &FileHandle, \r
+ EFI_FILE_MODE_READ|EFI_FILE_MODE_WRITE, \r
+ 0\r
+ );\r
+ ASSERT(Status == EFI_NOT_FOUND);\r
+ ASSERT(FileHandle == NULL);\r
+\r
+ Status = ShellCreateDirectory(FileName, &FileHandle);\r
+ ASSERT_EFI_ERROR(Status);\r
+ ASSERT(FileHandle != NULL);\r
+ pFileInfo = ShellGetFileInfo(FileHandle);\r
+ ASSERT(pFileInfo != NULL);\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
+ // FindFirst and FindNext\r
+ StrCpy(FileName, L"testDir");\r
+ Status = ShellCreateDirectory(FileName, &FileHandle);\r
+ Status = ShellCloseFile(&FileHandle);\r
+ StrCat(FileName, L"\\File.txt");\r
+ Status = ShellOpenFileByName(FileName, \r
+ &FileHandle, \r
+ EFI_FILE_MODE_CREATE|EFI_FILE_MODE_READ|EFI_FILE_MODE_WRITE, \r
+ 0\r
+ );\r
+ ASSERT_EFI_ERROR(Status);\r
+ Status = ShellCloseFile(&FileHandle);\r
+ StrCpy(FileName, L"testDir");\r
+ Status = ShellOpenFileByName(FileName, \r
+ &FileHandle, \r
+ EFI_FILE_MODE_CREATE|EFI_FILE_MODE_READ|EFI_FILE_MODE_WRITE, \r
+ 0\r
+ );\r
+ ASSERT_EFI_ERROR(Status);\r
+ Status = ShellFindFirstFile(FileHandle, pFileInfo);\r
+ ASSERT_EFI_ERROR(Status);\r
+ Status = ShellFindNextFile(FileHandle, pFileInfo, &NoFile);\r
+ ASSERT_EFI_ERROR(Status);\r
+ ASSERT(NoFile == FALSE);\r
+ Status = ShellFindNextFile(FileHandle, pFileInfo, &NoFile);\r
+ ASSERT_EFI_ERROR(Status);\r
+ ASSERT(NoFile == FALSE);\r
+ Status = ShellFindNextFile(FileHandle, pFileInfo, &NoFile);\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
+\r
+ // open and close meta arg\r
+ Status = ShellOpenFileMetaArg(L"testDir\\*.*", EFI_FILE_MODE_READ, &pShellFileInfo);\r
+ ASSERT_EFI_ERROR(Status);\r
+ ASSERT(pShellFileInfo->Status == 0);\r
+ ASSERT(StrCmp(pShellFileInfo->FileName, L"File.txt") == 0);\r
+ ASSERT(pShellFileInfo->Handle);\r
+ ASSERT(pShellFileInfo->Info);\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
+ Status = ShellCloseFileMetaArg(&pShellFileInfo);\r
+ ASSERT_EFI_ERROR(Status);\r
+ Print(L"Open/Close Meta Arg - pass\r\n");\r
+\r
+ // now delete that file and that directory\r
+ StrCat(FileName, L"\\File.txt");\r
+ Status = ShellOpenFileByName(FileName, \r
+ &FileHandle, \r
+ EFI_FILE_MODE_CREATE|EFI_FILE_MODE_READ|EFI_FILE_MODE_WRITE, \r
+ 0\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
+ &FileHandle, \r
+ EFI_FILE_MODE_CREATE|EFI_FILE_MODE_READ|EFI_FILE_MODE_WRITE, \r
+ 0\r
+ );\r
+ Status = ShellDeleteFile(&FileHandle);\r
+ ASSERT(FileHandle == NULL);\r
+ ASSERT_EFI_ERROR(Status);\r
+\r
+ // get environment variable\r
+ // made for testing under nt32\r
+ ASSERT(StrCmp(ShellGetEnvironmentVariable(L"path"), L".;f8:\\efi\\tools;f8:\\efi\\boot;f8:\\;f9:\\efi\\tools;f9:\\efi\\boot;f9:\\") == 0);\r
+ Print(L"ShellGetEnvironmentVariable - pass\r\n");\r
+\r
+ // set environment variable\r
+ Status = ShellSetEnvironmentVariable(L"", L"", FALSE);\r
+ ASSERT(Status == EFI_UNSUPPORTED);\r
+ Print(L"ShellSetEnvironmentVariable - pass\r\n");\r
+\r
+ // ShellExecute\r
+ Status = ShellExecute(&ImageHandle, L"EmptyApplication.efi", TRUE, NULL, NULL);\r
+ ASSERT_EFI_ERROR(Status);\r
+ // the pass printout for this is performed by EmptyApplication\r
+ Print(L"\r\n");\r
+ \r
+ // command line param functions\r
+ Status = ShellCommandLineParse(ParamList, &List, NULL, FALSE);\r
+ // if you put an invalid parameter you SHOULD hit this assert.\r
+ ASSERT_EFI_ERROR(Status);\r
+ if (List) {\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
+\r
+ ShellCommandLineFreeVarList(List);\r
+ } else {\r
+ Print(L"param checking skipped.\r\n");\r
+ }\r
+\r
+ // page break mode (done last so we can see the results)\r
+ // we set this true at the begining of the program\r
+ // this is enough lines to trigger the page...\r
+ Print(L"1\r\n2\r\n3\r\n4\r\n5\r\n6\r\n7\r\n8\r\n9\r\n10\r\n11\r\n12\r\n13\r\n14\r\n15\r\n16\r\n17\r\n18\r\n19\r\n20\r\n21\r\n22\r\n23\r\n24\r\n25\r\n26\r\n27\r\n28\r\n29\r\n30\r\n31\r\n");\r
+ ShellSetPageBreakMode(FALSE);\r
+ Print(L"1\r\n2\r\n3\r\n4\r\n5\r\n6\r\n7\r\n8\r\n9\r\n10\r\n11\r\n12\r\n13\r\n14\r\n15\r\n16\r\n17\r\n18\r\n19\r\n20\r\n21\r\n22\r\n23\r\n24\r\n25\r\n26\r\n27\r\n28\r\n29\r\n30\r\n31\r\n32\r\n33\r\n34\r\n35\r\n36\r\n37\r\n38\r\n39\r\n40\r\n41\r\n42\r\n43\r\n44\r\n45\r\n46\r\n47\r\n48\r\n49\r\n50\r\n51\r\n52\r\n53\r\n54\r\n55\r\n56\r\n57\r\n58\r\n59\r\n60\r\n");\r
+\r
+ return EFI_SUCCESS;\r
+}\r
+\r
+\r
+/*\r
+done - ShellGetFileInfo\r
+done - ShellSetFileInfo\r
+done - ShellOpenFileByDevicePath\r
+done - ShellOpenFileByName\r
+done - ShellCreateDirectory\r
+done - ShellReadFile\r
+done - ShellWriteFile\r
+done - ShellCloseFile\r
+done - ShellDeleteFile\r
+done - ShellSetFilePosition\r
+done - ShellGetFilePosition\r
+???? - ShellFlushFile\r
+done - ShellFindFirstFile\r
+done - ShellFindNextFile\r
+done - ShellGetFileSize\r
+done - ShellGetExecutionBreakFlag\r
+done - ShellGetEnvironmentVariable\r
+done - ShellSetEnvironmentVariable\r
+done - ShellExecute\r
+done - ShellGetCurrentDir\r
+done - ShellSetPageBreakMode\r
+done - ShellOpenFileMetaArg\r
+done - ShellCloseFileMetaArg\r
+done - ShellCommandLineParse\r
+done - ShellCommandLineFreeVarList\r
+done - ShellCommandLineGetFlag\r
+done - ShellCommandLineGetValue\r
+done - ShellCommandLineGetRawValue\r
+*/
\ No newline at end of file
--- /dev/null
+/** @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
+#if !defined(__SHELL_LIB__)\r
+#define __SHELL_LIB__\r
+\r
+#include <Protocol/SimpleFileSystem.h>\r
+#include <Guid/FileInfo.h>\r
+#include <Protocol/EfiShell.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
+ShellGetFileInfo (\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
+ShellSetFileInfo (\r
+ IN EFI_FILE_HANDLE FileHandle,\r
+ IN EFI_FILE_INFO *FileInfo\r
+ );\r
+\r
+/**\r
+ This function will open a file or directory referenced by DevicePath.\r
+\r
+ This function opens a file with the open mode according to the file path. The \r
+ Attributes is valid only for EFI_FILE_MODE_CREATE.\r
+\r
+ @param FilePath on input the device path to the file. On output \r
+ the remaining device path.\r
+ @param DeviceHandle pointer to the system device handle.\r
+ @param FileHandle pointer to the file handle.\r
+ @param OpenMode the mode to open the file with.\r
+ @param Attributes the file's file attributes.\r
+\r
+ @retval EFI_SUCCESS The information was set.\r
+ @retval EFI_INVALID_PARAMETER One of the parameters has an invalid value.\r
+ @retval EFI_UNSUPPORTED Could not open the file path. \r
+ @retval EFI_NOT_FOUND The specified file could not be found on the \r
+ device or the file system could not be found on \r
+ the device.\r
+ @retval EFI_NO_MEDIA The device has no medium.\r
+ @retval EFI_MEDIA_CHANGED The device has a different medium in it or the \r
+ medium is no longer supported.\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_OUT_OF_RESOURCES Not enough resources were available to open the \r
+ file.\r
+ @retval EFI_VOLUME_FULL The volume is full.\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+ShellOpenFileByDevicePath(\r
+ IN OUT EFI_DEVICE_PATH_PROTOCOL **FilePath,\r
+ OUT EFI_HANDLE *DeviceHandle,\r
+ OUT EFI_FILE_HANDLE *FileHandle,\r
+ IN UINT64 OpenMode,\r
+ IN UINT64 Attributes\r
+ );\r
+\r
+/**\r
+ This function will open a file or directory referenced by filename.\r
+\r
+ If return is EFI_SUCCESS, the Filehandle is the opened file\92s handle; \r
+ otherwise, the Filehandle is NULL. The Attributes is valid only for \r
+ EFI_FILE_MODE_CREATE.\r
+\r
+ @param FileName pointer to file name\r
+ @param FileHandle pointer to the file handle.\r
+ @param OpenMode the mode to open the file with.\r
+ @param Attributes the file's file attributes.\r
+\r
+ @retval EFI_SUCCESS The information was set.\r
+ @retval EFI_INVALID_PARAMETER One of the parameters has an invalid value.\r
+ @retval EFI_UNSUPPORTED Could not open the file path. \r
+ @retval EFI_NOT_FOUND The specified file could not be found on the \r
+ device or the file system could not be found \r
+ on the device.\r
+ @retval EFI_NO_MEDIA The device has no medium.\r
+ @retval EFI_MEDIA_CHANGED The device has a different medium in it or the \r
+ medium is no longer supported.\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_OUT_OF_RESOURCES Not enough resources were available to open the \r
+ file.\r
+ @retval EFI_VOLUME_FULL The volume is full.\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+ShellOpenFileByName(\r
+ IN CHAR16 *FilePath,\r
+ OUT EFI_FILE_HANDLE *FileHandle,\r
+ IN UINT64 OpenMode,\r
+ IN UINT64 Attributes\r
+ );\r
+\r
+/**\r
+ This function create a directory\r
+\r
+ If return is EFI_SUCCESS, the Filehandle is the opened directory's handle; \r
+ otherwise, the Filehandle is NULL. If the directory already existed, this \r
+ function opens the existing directory.\r
+\r
+ @param DirectoryName pointer to Directory name\r
+ @param FileHandle pointer to the file handle.\r
+\r
+ @retval EFI_SUCCESS The information was set.\r
+ @retval EFI_INVALID_PARAMETER One of the parameters has an invalid value.\r
+ @retval EFI_UNSUPPORTED Could not open the file path. \r
+ @retval EFI_NOT_FOUND The specified file could not be found on the \r
+ device or the file system could not be found \r
+ on the device.\r
+ @retval EFI_NO_MEDIA The device has no medium.\r
+ @retval EFI_MEDIA_CHANGED The device has a different medium in it or the \r
+ medium is no longer supported.\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_OUT_OF_RESOURCES Not enough resources were available to open the \r
+ file.\r
+ @retval EFI_VOLUME_FULL The volume is full.\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+ShellCreateDirectory(\r
+ IN CHAR16 *DirectoryName,\r
+ OUT EFI_FILE_HANDLE *FileHandle\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
+ \r
+ @param ReadSize on input the size of buffer in bytes. on return \r
+ the number of bytes written.\r
+\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
+ShellReadFile(\r
+ IN EFI_FILE_HANDLE FileHandle,\r
+ IN OUT UINTN *ReadSize,\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
+\r
+ @param BufferSize on input the number of bytes in Buffer. On output\r
+ the number of bytes written.\r
+\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
+ShellWriteFile(\r
+ IN EFI_FILE_HANDLE FileHandle,\r
+ IN OUT UINTN *BufferSize,\r
+ IN CONST 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
+@retval INVALID_PARAMETER One of the parameters has an invalid value.\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+ShellCloseFile (\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
+ShellDeleteFile (\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
+\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
+ShellSetFilePosition (\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
+ShellGetFilePosition (\r
+ IN EFI_FILE_HANDLE FileHandle,\r
+ OUT UINT64 *Position\r
+ );\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
+ShellFlushFile (\r
+ IN EFI_FILE_HANDLE FileHandle\r
+ );\r
+\r
+/**\r
+ Retrieves the first file from a directory\r
+\r
+ This function takes an open directory handle and gets the first file \r
+ in the directory's info. Caller can use ShellFindNextFile() to get \r
+ subsequent files.\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 ShellReadFile\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+ShellFindFirstFile (\r
+ IN EFI_FILE_HANDLE DirHandle,\r
+ OUT EFI_FILE_INFO *Buffer\r
+ );\r
+\r
+/**\r
+ Retrieves the next file in a directory.\r
+\r
+ To use this function, caller must call the ShellFindFirstFile() 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 ShellFindNextFile() 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
+ data in Buffer is meaningless. \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.\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
+ShellFindNextFile(\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
+ 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
+ShellGetFileSize (\r
+ IN EFI_FILE_HANDLE FileHandle,\r
+ OUT UINT64 *Size\r
+ );\r
+\r
+/**\r
+ Retrieves the status of the break execution flag\r
+\r
+ this function is useful to check whether the application is being asked to halt by the shell.\r
+\r
+ @retval TRUE the execution break is enabled\r
+ @retval FALSE the execution break is not enabled\r
+**/\r
+BOOLEAN\r
+EFIAPI\r
+ShellGetExecutionBreakFlag(\r
+ VOID\r
+ );\r
+\r
+/**\r
+ return the value of an environment variable\r
+\r
+ this function gets the value of the environment variable set by the \r
+ ShellSetEnvironmentVariable function\r
+\r
+ @param EnvKey The key name of the environment variable.\r
+\r
+ @retval NULL the named environment variable does not exist.\r
+ @return != NULL pointer to the value of the environment variable\r
+**/\r
+CONST CHAR16*\r
+EFIAPI\r
+ShellGetEnvironmentVariable (\r
+ IN CHAR16 *EnvKey\r
+ );\r
+\r
+/**\r
+ set the value of an environment variable\r
+\r
+This function changes the current value of the specified environment variable. If the\r
+environment variable exists and the Value is an empty string, then the environment\r
+variable is deleted. If the environment variable exists and the Value is not an empty\r
+string, then the value of the environment variable is changed. If the environment\r
+variable does not exist and the Value is an empty string, there is no action. If the\r
+environment variable does not exist and the Value is a non-empty string, then the\r
+environment variable is created and assigned the specified value.\r
+\r
+ This is not supported pre-UEFI Shell 2.0.\r
+\r
+ @param EnvKey The key name of the environment variable.\r
+ @param EnvVal The Value of the environment variable\r
+ @param Volatile Indicates whether the variable is non-volatile (FALSE) or volatile (TRUE).\r
+\r
+ @retval EFI_SUCCESS the operation was completed sucessfully\r
+ @retval EFI_UNSUPPORTED This operation is not allowed in pre UEFI 2.0 Shell environments\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+ShellSetEnvironmentVariable (\r
+ IN CONST CHAR16 *EnvKey,\r
+ IN CONST CHAR16 *EnvVal,\r
+ IN BOOLEAN Volatile\r
+ );\r
+\r
+/**\r
+ cause the shell to parse and execute a command line.\r
+\r
+ This function creates a nested instance of the shell and executes the specified\r
+command (CommandLine) with the specified environment (Environment). Upon return,\r
+the status code returned by the specified command is placed in StatusCode.\r
+If Environment is NULL, then the current environment is used and all changes made\r
+by the commands executed will be reflected in the current environment. If the\r
+Environment is non-NULL, then the changes made will be discarded.\r
+The CommandLine is executed from the current working directory on the current\r
+device.\r
+\r
+EnvironmentVariables and Status are only supported for UEFI Shell 2.0.\r
+Output is only supported for pre-UEFI Shell 2.0\r
+\r
+ @param ImageHandle Parent image that is starting the operation\r
+ @param CommandLine pointer to null terminated command line.\r
+ @param Output true to display debug output. false to hide it.\r
+ @param EnvironmentVariables optional pointer to array of environment variables\r
+ in the form "x=y". if NULL current set is used.\r
+ @param Status the status of the run command line.\r
+\r
+ @retval EFI_SUCCESS the operation completed sucessfully. Status\r
+ contains the status code returned.\r
+ @retval EFI_INVALID_PARAMETER a parameter contains an invalid value\r
+ @retval EFI_OUT_OF_RESOURCES out of resources\r
+ @retval EFI_UNSUPPORTED the operation is not allowed.\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+ShellExecute (\r
+ IN EFI_HANDLE *ParentHandle,\r
+ IN CHAR16 *CommandLine,\r
+ IN BOOLEAN Output,\r
+ IN CHAR16 **EnvironmentVariables,\r
+ OUT EFI_STATUS *Status\r
+ );\r
+\r
+/**\r
+ Retreives the current directory path\r
+\r
+ If the DeviceName is NULL, it returns the current device\92s current directory \r
+ name. If the DeviceName is not NULL, it returns the current directory name \r
+ on specified drive.\r
+\r
+ @param DeviceName the name of the drive to get directory on\r
+\r
+ @retval NULL the directory does not exist\r
+ @return != NULL the directory\r
+**/\r
+CONST CHAR16*\r
+EFIAPI\r
+ShellGetCurrentDir (\r
+ IN CHAR16 *DeviceName OPTIONAL\r
+ );\r
+\r
+/**\r
+ sets (enabled or disabled) the page break mode\r
+\r
+ when page break mode is enabled the screen will stop scrolling \r
+ and wait for operator input before scrolling a subsequent screen.\r
+\r
+ @param CurrentState TRUE to enable and FALSE to disable\r
+**/\r
+VOID \r
+EFIAPI\r
+ShellSetPageBreakMode (\r
+ IN BOOLEAN CurrentState\r
+ );\r
+\r
+/**\r
+ Opens a group of files based on a path.\r
+\r
+ This function uses the Arg to open all the matching files. Each matched \r
+ file has a SHELL_FILE_ARG structure to record the file information. These \r
+ structures are placed on the list ListHead. Users can get the SHELL_FILE_ARG \r
+ structures from ListHead to access each file. This function supports wildcards\r
+ and will process '?' and '*' as such. the list must be freed with a call to \r
+ ShellCloseFileMetaArg().\r
+\r
+ This function will fail if called sequentially without freeing the list in the middle.\r
+\r
+ @param Arg pointer to path string\r
+ @param OpenMode mode to open files with\r
+ @param ListHead head of linked list of results\r
+\r
+ @retval EFI_SUCCESS the operation was sucessful and the list head \r
+ contains the list of opened files\r
+ #retval EFI_UNSUPPORTED a previous ShellOpenFileMetaArg must be closed first.\r
+ *ListHead is set to NULL.\r
+ @return != EFI_SUCCESS the operation failed\r
+\r
+ @sa InternalShellConvertFileListType\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+ShellOpenFileMetaArg (\r
+ IN CHAR16 *Arg,\r
+ IN UINT64 OpenMode,\r
+ IN OUT EFI_SHELL_FILE_INFO **ListHead\r
+ );\r
+\r
+/**\r
+ Free the linked list returned from ShellOpenFileMetaArg\r
+\r
+ @param ListHead the pointer to free\r
+\r
+ @retval EFI_SUCCESS the operation was sucessful\r
+ @retval EFI_INVALID_PARAMETER A parameter was invalid\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+ShellCloseFileMetaArg (\r
+ IN OUT EFI_SHELL_FILE_INFO **ListHead\r
+ );\r
+\r
+typedef enum {\r
+ TypeFlag = 0,\r
+ TypeValue,\r
+ TypePosition,\r
+ TypeMax,\r
+} ParamType;\r
+\r
+typedef struct {\r
+ CHAR16 *Name;\r
+ ParamType Type;\r
+} SHELL_PARAM_ITEM;\r
+\r
+/**\r
+ Checks the command line arguments passed against the list of valid ones. \r
+ Optionally removes NULL values first.\r
+ \r
+ If no initialization is required, then return RETURN_SUCCESS.\r
+ \r
+ @param CheckList pointer to list of parameters to check\r
+ @param CheckPackage Package of checked values\r
+ @param ProblemParam optional pointer to pointer to unicode string for \r
+ the paramater that caused failure.\r
+ @param AutoPageBreak will automatically set PageBreakEnabled\r
+\r
+ @retval EFI_SUCCESS The operation completed sucessfully.\r
+ @retval EFI_OUT_OF_RESOURCES A memory allocation failed\r
+ @retval EFI_INVALID_PARAMETER A parameter was invalid\r
+ @retval EFI_VOLUME_CORRUPTED the command line was corrupt. an argument was \r
+ duplicated. the duplicated command line argument \r
+ was returned in ProblemParam if provided.\r
+ @retval EFI_DEVICE_ERROR the commands contained 2 opposing arguments. one\r
+ of the command line arguments was returned in \r
+ ProblemParam if provided.\r
+ @retval EFI_NOT_FOUND a argument required a value that was missing. \r
+ the invalid command line argument was returned in\r
+ ProblemParam if provided.\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+ShellCommandLineParse (\r
+ IN CONST SHELL_PARAM_ITEM *CheckList,\r
+ OUT LIST_ENTRY **CheckPackage,\r
+ OUT CHAR16 **ProblemParam OPTIONAL,\r
+ IN BOOLEAN AutoPageBreak\r
+ );\r
+\r
+/**\r
+ Frees shell variable list that was returned from ShellCommandLineParse.\r
+\r
+ This function will free all the memory that was used for the CheckPackage\r
+ list of postprocessed shell arguments.\r
+\r
+ this function has no return value.\r
+\r
+ if CheckPackage is NULL, then return\r
+\r
+ @param CheckPackage the list to de-allocate\r
+ **/\r
+VOID\r
+EFIAPI\r
+ShellCommandLineFreeVarList (\r
+ IN LIST_ENTRY *CheckPackage\r
+ );\r
+\r
+/**\r
+ Checks for presence of a flag parameter\r
+\r
+ flag arguments are in the form of "-<Key>" or "/<Key>", but do not have a value following the key\r
+\r
+ if CheckPackage is NULL then return FALSE.\r
+ if KeyString is NULL then ASSERT()\r
+ \r
+ @param CheckPackage The package of parsed command line arguments\r
+ @param KeyString the Key of the command line argument to check for\r
+\r
+ @retval TRUE the flag is on the command line\r
+ @retval FALSE the flag is not on the command line\r
+ **/\r
+BOOLEAN\r
+EFIAPI\r
+ShellCommandLineGetFlag (\r
+ IN CONST LIST_ENTRY *CheckPackage,\r
+ IN CHAR16 *KeyString\r
+ );\r
+\r
+/**\r
+ returns value from command line argument\r
+\r
+ value parameters are in the form of "-<Key> value" or "/<Key> value"\r
+ \r
+ if CheckPackage is NULL, then return NULL;\r
+\r
+ @param CheckPackage The package of parsed command line arguments\r
+ @param KeyString the Key of the command line argument to check for\r
+\r
+ @retval NULL the flag is not on the command line\r
+ @return !=NULL pointer to unicode string of the value\r
+ **/\r
+CONST CHAR16*\r
+EFIAPI\r
+ShellCommandLineGetValue (\r
+ IN CONST LIST_ENTRY *CheckPackage,\r
+ IN CHAR16 *KeyString\r
+ );\r
+\r
+/**\r
+ returns raw value from command line argument\r
+\r
+ raw value parameters are in the form of "value" in a specific position in the list\r
+ \r
+ if CheckPackage is NULL, then return NULL;\r
+\r
+ @param CheckPackage The package of parsed command line arguments\r
+ @param Position the position of the value \r
+\r
+ @retval NULL the flag is not on the command line\r
+ @return !=NULL pointer to unicode string of the value\r
+ **/\r
+CONST CHAR16*\r
+EFIAPI\r
+ShellCommandLineGetRawValue (\r
+ IN CONST LIST_ENTRY *CheckPackage,\r
+ IN UINT32 Position\r
+ );\r
+\r
+#endif // __SHELL_LIB__
\ No newline at end of file
--- /dev/null
+/** @file\r
+ EFI Shell protocol as defined in the UEFI Shell 2.0 specification.\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
+#ifndef __EFI_SHELL_PROTOCOL__\r
+#define __EFI_SHELL_PROTOCOL__\r
+\r
+#include <Protocol/SimpleFileSystem.h>\r
+#include <Guid/FileInfo.h>\r
+\r
+#define EFI_SHELL_PROTOCOL_GUID \\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
+typedef struct {\r
+ EFI_LIST_ENTRY Link;\r
+ EFI_STATUS Status;\r
+ CONST CHAR16 *FullName;\r
+ CONST CHAR16 *FileName;\r
+ EFI_FILE_HANDLE Handle;\r
+ EFI_FILE_INFO *Info;\r
+} EFI_SHELL_FILE_INFO;\r
+/**\r
+ Returns whether any script files are currently being processed.\r
+\r
+ @retval TRUE There is at least one script file active.\r
+ @retval FALSE No script files are active now.\r
+\r
+**/\r
+typedef\r
+BOOLEAN\r
+(EFIAPI *EFI_SHELL_BATCH_IS_ACTIVE) (\r
+ VOID\r
+ );\r
+\r
+/**\r
+ Closes the file handle.\r
+\r
+ This function closes a specified file handle. All 'dirty' cached file data is \r
+ flushed to the device, and the file is closed. In all cases, the handle is \r
+ closed.\r
+\r
+ @param FileHandle The file handle to be closed\r
+\r
+ @retval EFI_SUCCESS the file closed sucessfully\r
+**/\r
+typedef\r
+EFI_STATUS\r
+(EFIAPI *EFI_SHELL_CLOSE_FILE)(\r
+ IN EFI_FILE_HANDLE FileHandle\r
+ );\r
+\r
+/**\r
+ Creates a file or directory by name.\r
+\r
+ This function creates an empty new file or directory with the specified attributes and\r
+ returns the new file's handle. If the file already exists and is read-only, then\r
+ EFI_INVALID_PARAMETER will be returned.\r
+ \r
+ If the file already existed, it is truncated and its attributes updated. If the file is\r
+ created successfully, the FileHandle is the file's handle, else, the FileHandle is NULL.\r
+ \r
+ If the file name begins with >v, then the file handle which is returned refers to the\r
+ shell environment variable with the specified name. If the shell environment variable\r
+ already exists and is non-volatile then EFI_INVALID_PARAMETER is returned.\r
+\r
+ @param FileName Pointer to null-terminated file path\r
+ @param FileAttribs The new file's attrbiutes. the different attributes are\r
+ described in EFI_FILE_PROTOCOL.Open().\r
+ @param FileHandle On return, points to the created file handle or directory's handle\r
+\r
+ @retval EFI_SUCCESS The file was opened. FileHandle points to the new file's handle.\r
+ @retval EFI_INVALID_PARAMETER One of the parameters has an invalid value.\r
+ @retval EFI_UNSUPPORTED could not open the file path\r
+ @retval EFI_NOT_FOUND the specified file could not be found on the devide, or could not\r
+ file the file system on the device.\r
+ @retval EFI_NO_MEDIA the device has no medium.\r
+ @retval EFI_MEDIA_CHANGED The device has a different medium in it or the medium is no\r
+ longer supported.\r
+ @retval EFI_DEVICE_ERROR The device reported an error or can't get the file path according\r
+ the DirName.\r
+ @retval EFI_VOLUME_CORRUPTED The file system structures are corrupted.\r
+ @retval EFI_WRITE_PROTECTED An attempt was made to create a file, or open a file for write\r
+ when the media is write-protected.\r
+ @retval EFI_ACCESS_DENIED The service denied access to the file.\r
+ @retval EFI_OUT_OF_RESOURCES Not enough resources were available to open the file.\r
+ @retval EFI_VOLUME_FULL The volume is full.\r
+**/\r
+typedef\r
+EFI_STATUS\r
+(EFIAPI *EFI_SHELL_CREATE_FILE)(\r
+ IN CONST CHAR16 *FileName,\r
+ IN UINT64 FileAttribs,\r
+ OUT EFI_FILE_HANDLE *FileHandle\r
+ );\r
+\r
+/**\r
+ Deletes the file specified by the file handle.\r
+\r
+ This function closes and deletes a file. In all cases, the file handle is closed. If the file\r
+ cannot be deleted, the warning code EFI_WARN_DELETE_FAILURE is returned, but the\r
+ handle is still closed.\r
+\r
+ @param FileHandle The file handle to delete.\r
+\r
+ @retval EFI_SUCCESS The file was closed and deleted, and the handle was closed.\r
+ @retval EFI_WARN_DELETE_FAILURE The handle was closed but the file was not deleted.\r
+**/\r
+typedef\r
+EFI_STATUS\r
+(EFIAPI *EFI_SHELL_DELETE_FILE)(\r
+ IN EFI_FILE_HANDLE FileHandle\r
+ );\r
+\r
+/**\r
+ Deletes the file specified by the file name.\r
+\r
+ This function deletes a file.\r
+\r
+ @param FileName Points to the null-terminated file name.\r
+\r
+ @retval EFI_SUCCESS The file was closed and deleted, and the handle was closed.\r
+ @retval EFI_WARN_DELETE_FAILURE The handle was closed but the file was not deleted.\r
+**/\r
+typedef\r
+EFI_STATUS\r
+(EFIAPI *EFI_SHELL_DELETE_FILE_BY_NAME)(\r
+ IN CONST CHAR16 *FileName\r
+ );\r
+\r
+/**\r
+ Disables the page break output mode.\r
+**/\r
+typedef\r
+VOID\r
+(EFIAPI *EFI_SHELL_DISABLE_PAGE_BREAK) (\r
+VOID\r
+);\r
+\r
+/**\r
+ Enables the page break output mode.\r
+**/\r
+typedef\r
+VOID\r
+(EFIAPI *EFI_SHELL_ENABLE_PAGE_BREAK) (\r
+VOID\r
+);\r
+\r
+/**\r
+ Execute the command line.\r
+\r
+ This function creates a nested instance of the shell and executes the specified\r
+ command (CommandLine) with the specified environment (Environment). Upon return,\r
+ the status code returned by the specified command is placed in StatusCode.\r
+ \r
+ If Environment is NULL, then the current environment is used and all changes made\r
+ by the commands executed will be reflected in the current environment. If the\r
+ Environment is non-NULL, then the changes made will be discarded.\r
+ \r
+ The CommandLine is executed from the current working directory on the current\r
+ device.\r
+\r
+ @param ParentImageHandle A handle of the image that is executing the specified \r
+ command line. \r
+ @param CommandLine Points to the null-terminated UCS-2 encoded string \r
+ containing the command line. If NULL then the command-\r
+ line will be empty.\r
+ @param Environment Points to a null-terminated array of environment \r
+ variables with the format 'x=y', where x is the \r
+ environment variable name and y is the value. If this\r
+ is NULL, then the current shell environment is used.\r
+ @param ErrorCode Points to the status code returned by the command.\r
+\r
+ @retval EFI_SUCCESS The command executed successfully. The status code \r
+ returned by the command is pointed to by StatusCode.\r
+ @retval EFI_INVALID_PARAMETER The parameters are invalid.\r
+ @retval EFI_OUT_OF_RESOURCES Out of resources.\r
+ @retval EFI_UNSUPPORTED Nested shell invocations are not allowed.\r
+**/\r
+typedef\r
+EFI_STATUS\r
+(EFIAPI *EFI_SHELL_EXECUTE) (\r
+ IN EFI_HANDLE *ParentImageHandle,\r
+ IN CHAR16 *CommandLine OPTIONAL,\r
+ IN CHAR16 **Environment OPTIONAL,\r
+ OUT EFI_STATUS *StatusCode OPTIONAL\r
+ );\r
+\r
+/**\r
+ Find files that match a specified pattern.\r
+\r
+ This function searches for all files and directories that match the specified\r
+ FilePattern. The FilePattern can contain wild-card characters. The resulting file\r
+ information is placed in the file list FileList.\r
+\r
+ The files in the file list are not opened. The OpenMode field is set to 0 and the FileInfo\r
+ field is set to NULL.\r
+\r
+ @param FilePattern Points to a null-terminated shell file path, including wildcards.\r
+ @param FileList On return, points to the start of a file list containing the names \r
+ of all matching files or else points to NULL if no matching files \r
+ were found.\r
+\r
+ @retval EFI_SUCCESS Files found.\r
+ @retval EFI_NOT_FOUND No files found.\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
+typedef\r
+EFI_STATUS\r
+(EFIAPI *EFI_SHELL_FIND_FILES)(\r
+ IN CONST CHAR16 *FilePattern,\r
+ OUT EFI_SHELL_FILE_INFO **FileList\r
+ );\r
+\r
+/**\r
+ Find all files in a specified directory.\r
+\r
+ @param FileDirHandle Handle of the directory to search.\r
+ @param FileList On return, points to the list of files in the directory \r
+ or NULL if there are no files in the directory.\r
+\r
+ @retval EFI_SUCCESS File information was returned successfully.\r
+ @retval EFI_VOLUME_CORRUPTED The file system structures have been corrupted.\r
+ @retval EFI_DEVICE_ERROR The device reported an error.\r
+ @retval EFI_NO_MEDIA The device media is not present.\r
+**/\r
+typedef\r
+EFI_STATUS\r
+(EFIAPI *EFI_SHELL_FIND_FILES_IN_DIR)(\r
+IN EFI_FILE_HANDLE FileDirHandle,\r
+OUT EFI_SHELL_FILE_INFO **FileList\r
+);\r
+\r
+/**\r
+ Flushes data back to a device\r
+ \r
+ This function flushes all modified data associated with a file to a device.\r
+\r
+ @param FileHandle The handle of the file to flush\r
+\r
+ @retval EFI_SUCCESS The data was flushed.\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
+typedef\r
+EFI_STATUS\r
+(EFIAPI *EFI_SHELL_FLUSH_FILE)(\r
+ IN EFI_FILE_HANDLE FileHandle\r
+ );\r
+\r
+/**\r
+ Frees the file list.\r
+ \r
+ This function cleans up the file list and any related data structures. It has no\r
+ impact on the files themselves.\r
+\r
+ @param FileList The file list to free. Type EFI_SHELL_FILE_INFO is \r
+ defined in OpenFileList()\r
+\r
+ @retval EFI_SUCCESS Free the file list successfully.\r
+**/\r
+typedef\r
+EFI_STATUS\r
+(EFIAPI *EFI_SHELL_FREE_FILE_LIST) (\r
+ IN EFI_SHELL_FILE_INFO **FileList\r
+ );\r
+\r
+/**\r
+ Returns the current directory on the specified device.\r
+\r
+ If FileSystemMapping is NULL, it returns the current working directory. If the\r
+ FileSystemMapping is not NULL, it returns the current directory associated with the\r
+ FileSystemMapping. In both cases, the returned name includes the file system\r
+ mapping (i.e. fs0:\current-dir).\r
+\r
+ @param FileSystemMapping A pointer to the file system mapping. If NULL, \r
+ then the current working directory is returned.\r
+ \r
+ @retval !=NULL The current directory.\r
+ @retval NULL Current directory does not exist.\r
+**/\r
+typedef\r
+CONST CHAR16 *\r
+(EFIAPI *EFI_SHELL_GET_CUR_DIR) (\r
+ IN CONST CHAR16 *FileSystemMapping OPTIONAL\r
+ );\r
+\r
+typedef UINT32 EFI_SHELL_DEVICE_NAME_FLAGS;\r
+#define EFI_DEVICE_NAME_USE_COMPONENT_NAME 0x00000001\r
+#define EFI_DEVICE_NAME_USE_DEVICE_PATH 0x00000002\r
+/**\r
+ Gets the name of the device specified by the device handle.\r
+\r
+ This function gets the user-readable name of the device specified by the device\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
+ @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
+ name, in the same format as described in the UEFI \r
+ specification, Appendix M \r
+ @param BestDeviceName On return, points to the callee-allocated null-\r
+ terminated name of the device. If no device name \r
+ could be found, points to NULL. The name must be \r
+ freed by the caller...\r
+\r
+ @retval EFI_SUCCESS Get the name successfully.\r
+ @retval EFI_NOT_FOUND Fail to get the device name.\r
+**/\r
+typedef\r
+EFI_STATUS\r
+(*EFI_SHELL_GET_DEVICE_NAME) (\r
+ IN EFI_HANDLE DeviceHandle,\r
+ IN EFI_SHELL_DEVICE_NAME_FLAGS Flags,\r
+ IN CHAR8 *Language,\r
+ OUT CHAR16 **BestDeviceName\r
+ );\r
+\r
+/**\r
+ Gets the device path from the mapping.\r
+\r
+ This function gets the device path associated with a mapping.\r
+\r
+ @param Mapping A pointer to the mapping\r
+\r
+ @retval !=NULL Pointer to the device path that corresponds to the \r
+ device mapping. The returned pointer does not need \r
+ to be freed.\r
+ @retval NULL There is no device path associated with the \r
+ specified mapping.\r
+**/\r
+typedef\r
+CONST EFI_DEVICE_PATH_PROTOCOL *\r
+(EFIAPI *EFI_SHELL_GET_DEVICE_PATH_FROM_MAP) (\r
+ IN CONST CHAR16 *Mapping\r
+ );\r
+\r
+/**\r
+ Converts a file system style name to a device path.\r
+\r
+ This function converts a file system style name to a device path, by replacing any\r
+ mapping references to the associated device path.\r
+\r
+ @param Path the pointer to the path\r
+\r
+ @return all The pointer of the file path. The file path is callee \r
+ allocated and should be freed by the caller.\r
+**/\r
+typedef\r
+EFI_DEVICE_PATH_PROTOCOL *\r
+(EFIAPI *EFI_SHELL_GET_DEVICE_PATH_FROM_FILE_PATH) (\r
+ IN CONST CHAR16 *Path\r
+ );\r
+\r
+/**\r
+ Gets the environment variable.\r
+\r
+ This function returns the current value of the specified environment variable.\r
+\r
+ @param Name A pointer to the environment variable name\r
+\r
+ @return !=NULL The environment variable's value. The returned \r
+ pointer does not need to be freed by the caller.\r
+ @retval NULL The environment variable doesn't exist.\r
+**/\r
+typedef\r
+CONST CHAR16 *\r
+(EFIAPI *EFI_SHELL_GET_ENV) (\r
+ IN CONST CHAR16 *Name\r
+ );\r
+\r
+/**\r
+ Gets the file information from an open file handle.\r
+\r
+ This function allocates a buffer to store the file's information. It's the caller's\r
+ responsibility to free the buffer.\r
+\r
+ @param FileHandle A File Handle\r
+\r
+ @return !=NULL Cannot get the file info.\r
+ @return NULL A pointer to a buffer with file information.\r
+**/\r
+typedef\r
+EFI_FILE_INFO *\r
+(EFIAPI *EFI_SHELL_GET_FILE_INFO)(\r
+ IN EFI_FILE_HANDLE FileHandle\r
+ );\r
+\r
+/**\r
+ Converts a device path to a file system-style path.\r
+\r
+ This function converts a device path to a file system path by replacing part, or all, of\r
+ the device path with the file-system mapping. If there are more than one application\r
+ file system mappings, the one that most closely matches Path will be used.\r
+\r
+ @param Path The pointer to the device path\r
+\r
+ @return all The pointer of the null-terminated file path. The path \r
+ is callee-allocated and should be freed by the caller.\r
+**/\r
+typedef\r
+CHAR16 *\r
+(EFIAPI *EFI_SHELL_GET_FILE_PATH_FROM_DEVICE_PATH) (\r
+ IN CONST EFI_DEVICE_PATH_PROTOCOL *Path\r
+ );\r
+\r
+/**\r
+ Gets a file's current position\r
+\r
+ This function returns the current file position for the file handle. For directories, the\r
+ current file position has no meaning outside of the file system driver and as such, the\r
+ operation is not supported.\r
+\r
+ @param FileHandle The file handle on which to get the current position.\r
+ @param Position Byte position from the start of the file\r
+\r
+ @retval EFI_SUCCESS Data was accessed.\r
+ @retval EFI_UNSUPPORTED The request is not valid on open directories.\r
+**/\r
+typedef\r
+EFI_STATUS\r
+(EFIAPI *EFI_SHELL_GET_FILE_POSITION)(\r
+ IN EFI_FILE_HANDLE FileHandle,\r
+ OUT UINT64 *Position\r
+ );\r
+\r
+/**\r
+ Gets the size of a file.\r
+\r
+ This function returns the size of the file specified by FileHandle.\r
+\r
+ @param FileHandle The handle of the file.\r
+ @param Size The size of this file.\r
+\r
+ @retval EFI_SUCCESS Get the file's size.\r
+ @retval EFI_DEVICE_ERROR Can't access the file.\r
+**/\r
+typedef\r
+EFI_STATUS\r
+(EFIAPI *EFI_SHELL_GET_FILE_SIZE)(\r
+ IN EFI_FILE_HANDLE FileHandle,\r
+ OUT UINT64 *Size\r
+ );\r
+\r
+/**\r
+ Return help information about a specific command.\r
+\r
+ This function returns the help information for the specified command. The help text\r
+ can be internal to the shell or can be from a UEFI Shell manual page.\r
+ \r
+ If Sections is specified, then each section name listed will be compared in a casesensitive\r
+ manner, to the section names described in Appendix B. If the section exists,\r
+ it will be appended to the returned help text. If the section does not exist, no\r
+ information will be returned. If Sections is NULL, then all help text information\r
+ available will be returned.\r
+\r
+ @param Command Points to the null-terminated UEFI Shell command name.\r
+ @param Sections Points to the null-terminated comma-delimited \r
+ section names to return. If NULL, then all \r
+ sections will be returned.\r
+ @param HelpText On return, points to a callee-allocated buffer \r
+ containing all specified help text.\r
+\r
+ @retval EFI_SUCCESS The help text was returned.\r
+ @retval EFI_OUT_OF_RESOURCES The necessary buffer could not be allocated to hold the \r
+ returned help text.\r
+ @retval EFI_INVALID_PARAMETER HelpText is NULL\r
+ @retval EFI_NOT_FOUND There is no help text available for Command.\r
+**/\r
+typedef\r
+EFI_STATUS\r
+(EFIAPI *EFI_SHELL_GET_HELP_TEXT) (\r
+ IN CONST CHAR16 *Command,\r
+ IN CONST CHAR16 *Sections,\r
+ OUT CHAR16 **HelpText\r
+ );\r
+\r
+/**\r
+ Gets the mapping that most closely matches the device path.\r
+\r
+ This function gets the mapping which corresponds to the device path *DevicePath. If\r
+ there is no exact match, then the mapping which most closely matches *DevicePath\r
+ is returned, and *DevicePath is updated to point to the remaining portion of the\r
+ device path. If there is an exact match, the mapping is returned and *DevicePath\r
+ points to the end-of-device-path node.\r
+\r
+ @param DevicePath On entry, points to a device path pointer. On \r
+ exit, updates the pointer to point to the \r
+ portion of the device path after the mapping.\r
+\r
+ @retval NULL No mapping was found.\r
+ @return !=NULL Pointer to null-terminated mapping. The buffer \r
+ is callee allocated and should be freed by the caller.\r
+**/\r
+typedef\r
+CONST CHAR16 *\r
+(EFIAPI *EFI_SHELL_GET_MAP_FROM_DEVICE_PATH) (\r
+ IN OUT EFI_DEVICE_PATH_PROTOCOL **DevicePath\r
+ );\r
+\r
+/**\r
+ Gets the enable status of the page break output mode.\r
+\r
+ User can use this function to determine current page break mode.\r
+\r
+ @retval TRUE The page break output mode is enabled\r
+ @retval FALSE The page break output mode is disabled\r
+**/\r
+typedef\r
+BOOLEAN\r
+(EFIAPI *EFI_SHELL_GET_PAGE_BREAK) (\r
+ VOID\r
+ );\r
+\r
+/**\r
+ Judges whether the active shell is the root shell.\r
+\r
+ This function makes the user to know that whether the active Shell is the root shell.\r
+\r
+ @retval TRUE The active Shell is the root Shell.\r
+ @retval FALSE The active Shell is NOT the root Shell.\r
+**/\r
+typedef\r
+BOOLEAN\r
+(EFIAPI *EFI_SHELL_IS_ROOT_SHELL) (\r
+VOID\r
+);\r
+\r
+/**\r
+ Opens a file or a directory by file name.\r
+\r
+ This function opens the specified file in the specified OpenMode and returns a file\r
+ handle.\r
+ If the file name begins with >v, then the file handle which is returned refers to the\r
+ shell environment variable with the specified name. If the shell environment variable\r
+ exists, is non-volatile and the OpenMode indicates EFI_FILE_MODE_WRITE, then\r
+ EFI_INVALID_PARAMETER is returned.\r
+\r
+ If the file name is >i, then the file handle which is returned refers to the standard\r
+ input. If the OpenMode indicates EFI_FILE_MODE_WRITE, then EFI_INVALID_PARAMETER\r
+ is returned.\r
+\r
+ If the file name is >o, then the file handle which is returned refers to the standard\r
+ output. If the OpenMode indicates EFI_FILE_MODE_READ, then EFI_INVALID_PARAMETER\r
+ is returned.\r
+\r
+ If the file name is >e, then the file handle which is returned refers to the standard\r
+ error. If the OpenMode indicates EFI_FILE_MODE_READ, then EFI_INVALID_PARAMETER\r
+ is returned.\r
+\r
+ If the file name is NUL, then the file handle that is returned refers to the standard NUL\r
+ file. If the OpenMode indicates EFI_FILE_MODE_READ, then EFI_INVALID_PARAMETER is\r
+ returned.\r
+\r
+ If return EFI_SUCCESS, the FileHandle is the opened file's handle, else, the\r
+ FileHandle is NULL.\r
+\r
+ @param FileName Points to the null-terminated UCS-2 encoded file name.\r
+ @param FileHandle On return, points to the file handle.\r
+ @param OpenMode File open mode. Either EFI_FILE_MODE_READ or \r
+ EFI_FILE_MODE_WRITE from section 12.4 of the UEFI \r
+ Specification.\r
+ @retval EFI_SUCCESS The file was opened. FileHandle has the opened file's handle.\r
+ @retval EFI_INVALID_PARAMETER One of the parameters has an invalid value. FileHandle is NULL.\r
+ @retval EFI_UNSUPPORTED Could not open the file path. FileHandle is NULL.\r
+ @retval EFI_NOT_FOUND The specified file could not be found on the device or the file\r
+ system could not be found on the device. FileHandle is NULL.\r
+ @retval EFI_NO_MEDIA The device has no medium. FileHandle is NULL.\r
+ @retval EFI_MEDIA_CHANGED The device has a different medium in it or the medium is no\r
+ longer supported. FileHandle is NULL.\r
+ @retval EFI_DEVICE_ERROR The device reported an error or can't get the file path according\r
+ the FileName. FileHandle is NULL.\r
+ @retval EFI_VOLUME_CORRUPTED The file system structures are corrupted. FileHandle is NULL.\r
+ @retval EFI_WRITE_PROTECTED An attempt was made to create a file, or open a file for write\r
+ when the media is write-protected. FileHandle is NULL.\r
+ @retval EFI_ACCESS_DENIED The service denied access to the file. FileHandle is NULL.\r
+ @retval EFI_OUT_OF_RESOURCES Not enough resources were available to open the file. FileHandle\r
+ is NULL.\r
+ @retval EFI_VOLUME_FULL The volume is full. FileHandle is NULL.\r
+**/\r
+typedef\r
+EFI_STATUS\r
+(EFIAPI *EFI_SHELL_OPEN_FILE_BY_NAME) (\r
+ IN CONST CHAR16 *FileName,\r
+ OUT EFI_FILE_HANDLE *FileHandle,\r
+ IN UINT64 OpenMode\r
+ );\r
+\r
+/**\r
+ Opens the files that match the path specified.\r
+\r
+ This function opens all of the files specified by Path. Wildcards are processed\r
+ according to the rules specified in UEFI Shell 2.0 spec section 3.7.1. Each \r
+ matching file has an EFI_SHELL_FILE_INFO structure created in a linked list.\r
+\r
+ @param Path A pointer to the path string.\r
+ @param OpenMode Specifies the mode used to open each file, EFI_FILE_MODE_READ or\r
+ EFI_FILE_MODE_WRITE.\r
+ @param FileList Points to the start of a list of files opened.\r
+\r
+ @retval EFI_SUCCESS Create the file list successfully.\r
+ @return Others Can't create the file list.\r
+**/\r
+typedef\r
+EFI_STATUS\r
+(EFIAPI *EFI_SHELL_OPEN_FILE_LIST) (\r
+ IN CHAR16 *Path,\r
+ IN UINT64 OpenMode,\r
+ IN OUT EFI_SHELL_FILE_INFO **FileList\r
+ );\r
+\r
+/**\r
+ Opens the root directory of a device.\r
+\r
+ This function opens the root directory of a device and returns a file handle to it.\r
+\r
+ @param DevicePath Points to the device path corresponding to the device where the\r
+ EFI_SIMPLE_FILE_SYSTEM_PROTOCOL is installed.\r
+ @param FileHandle On exit, points to the file handle corresponding to the root directory on the\r
+ device.\r
+\r
+ @retval EFI_SUCCESS Root opened successfully.\r
+ @retval EFI_NOT_FOUND EFI_SIMPLE_FILE_SYSTEM could not be found or the root directory\r
+ could not be opened.\r
+ @retval EFI_VOLUME_CORRUPTED The data structures in the volume were corrupted.\r
+ @retval EFI_DEVICE_ERROR The device had an error\r
+**/\r
+typedef\r
+EFI_STATUS\r
+(EFIAPI *EFI_SHELL_OPEN_ROOT)(\r
+ IN EFI_DEVICE_PATH_PROTOCOL *DevicePath,\r
+ OUT EFI_FILE_HANDLE *FileHandle\r
+ );\r
+\r
+/**\r
+ Opens the root directory of a device on a handle\r
+\r
+ This function opens the root directory of a device and returns a file handle to it.\r
+\r
+ @param DeviceHandle The handle of the device that contains the volume.\r
+ @param FileHandle On exit, points to the file handle corresponding to the root directory on the\r
+ device.\r
+\r
+ @retval EFI_SUCCESS Root opened successfully.\r
+ @retval EFI_NOT_FOUND EFI_SIMPLE_FILE_SYSTEM could not be found or the root directory\r
+ could not be opened.\r
+ @retval EFI_VOLUME_CORRUPTED The data structures in the volume were corrupted.\r
+ @retval EFI_DEVICE_ERROR The device had an error\r
+**/\r
+typedef\r
+EFI_STATUS\r
+(EFIAPI *EFI_SHELL_OPEN_ROOT_BY_HANDLE)(\r
+ IN EFI_HANDLE DeviceHandle,\r
+ OUT EFI_FILE_HANDLE *FileHandle\r
+ );\r
+\r
+/**\r
+ Reads data from the file.\r
+\r
+ If FileHandle is not a directory, the function reads the requested number of bytes\r
+ from the file at the file's current position and returns them in Buffer. If the read goes\r
+ beyond the end of the file, the read length is truncated to the end of the file. The file's\r
+ current position is increased by the number of bytes returned.\r
+ If FileHandle is a directory, then an error is returned.\r
+\r
+ @param FileHandle The opened file handle for read\r
+ @param ReadSize On input, the size of Buffer, in bytes. On output, the amount of data read.\r
+ @param Buffer The buffer in which data is read.\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 size\r
+**/\r
+typedef\r
+EFI_STATUS\r
+(EFIAPI *EFI_SHELL_READ_FILE) (\r
+ IN EFI_FILE_HANDLE FileHandle,\r
+ IN OUT UINTN *ReadSize,\r
+ OUT VOID *Buffer\r
+ );\r
+\r
+/**\r
+ Deletes the duplicate file names files in the given file list.\r
+\r
+ This function deletes the reduplicate files in the given file list.\r
+\r
+ @param FileList A pointer to the first entry in the file list.\r
+\r
+ @retval EFI_SUCCESS Always success.\r
+**/\r
+typedef\r
+EFI_STATUS\r
+(EFIAPI *EFI_SHELL_REMOVE_DUP_IN_FILE_LIST) (\r
+ IN EFI_SHELL_FILE_INFO **FileList\r
+ );\r
+\r
+/**\r
+ Changes a shell command alias.\r
+\r
+ This function creates an alias for a shell command.\r
+\r
+ @param Command Points to the null-terminated shell command or existing alias.\r
+ @param Alias Points to the null-terminated alias for the shell command. If this is NULL, and\r
+ Command refers to an alias, that alias will be deleted.\r
+ @param Replace If TRUE and the alias already exists, then the existing alias will be replaced. If\r
+ FALSE and the alias already exists, then the existing alias is unchanged and\r
+ EFI_ACCESS_DENIED is returned.\r
+\r
+ @retval EFI_SUCCESS Alias created or deleted successfully.\r
+ @retval EFI_ACCESS_DENIED The alias is a built-in alias or already existed and Replace was set to\r
+ FALSE.\r
+**/\r
+typedef\r
+EFI_STATUS\r
+(EFIAPI *EFI_SHELL_SET_ALIAS)(\r
+ IN CONST CHAR16 *Command,\r
+ IN CONST CHAR16 *Alias,\r
+ IN BOOLEAN Replace\r
+ );\r
+\r
+/**\r
+ Changes the current directory on the specified device.\r
+\r
+ If the FileSystem is NULL, and the directory Dir does not contain a file system's\r
+ mapped name, this function changes the current working directory. If FileSystem is\r
+ NULL and the directory Dir contains a mapped name, then the current file system and\r
+ the current directory on that file system are changed.\r
+\r
+ If FileSystem is not NULL, and Dir is NULL, then this changes the current working file\r
+ system.\r
+\r
+ If FileSystem is not NULL and Dir is not NULL, then this function changes the current\r
+ directory on the specified file system.\r
+\r
+ If the current working directory or the current working file system is changed then the\r
+ %cwd% environment variable will be updated\r
+\r
+ @param FileSystem A pointer to the file system's mapped name. If NULL, then the current working\r
+ directory is changed.\r
+ @param Dir Points to the null-terminated directory on the device specified by FileSystem.\r
+\r
+ @return !=NULL The current directory.\r
+ @retval NULL Current directory does not exist.\r
+**/\r
+typedef\r
+EFI_STATUS\r
+(EFIAPI *EFI_SHELL_SET_CUR_DIR) (\r
+ IN CONST CHAR16 *FileSystem OPTIONAL,\r
+ IN CONST CHAR16 *Dir\r
+ );\r
+\r
+/**\r
+ Sets the environment variable.\r
+\r
+ This function changes the current value of the specified environment variable. If the\r
+ environment variable exists and the Value is an empty string, then the environment\r
+ variable is deleted. If the environment variable exists and the Value is not an empty\r
+ string, then the value of the environment variable is changed. If the environment\r
+ variable does not exist and the Value is an empty string, there is no action. If the\r
+ environment variable does not exist and the Value is a non-empty string, then the\r
+ environment variable is created and assigned the specified value.\r
+ \r
+ For a description of volatile and non-volatile environment variables, see UEFI Shell \r
+ 2.0 specification section 3.6.1.\r
+\r
+ @param Name Points to the null-terminated environment variable name.\r
+ @param Value Points to the null-terminated environment variable value. If the value is an\r
+ empty string then the environment variable is deleted.\r
+ @param Volatile Indicates whether the variable is non-volatile (FALSE) or volatile (TRUE).\r
+\r
+ @retval EFI_SUCCESS The environment variable was successfully updated.\r
+**/\r
+typedef\r
+EFI_STATUS\r
+(EFIAPI *EFI_SHELL_SET_ENV) (\r
+ IN CONST CHAR16 *Name,\r
+ IN CONST CHAR16 *Value,\r
+ IN BOOLEAN Volatile\r
+ );\r
+\r
+/**\r
+ Sets the file information to an opened file handle.\r
+\r
+ This function changes file information.\r
+\r
+ @param FileHandle A file handle\r
+ @param FileInfo Points to new file information.\r
+\r
+ @retval EFI_SUCCESS The information was set.\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
+ @retval EFI_BAD_BUFFER_SIZE BufferSize is smaller than the size of EFI_FILE_INFO.\r
+**/\r
+typedef\r
+EFI_STATUS\r
+(EFIAPI *EFI_SHELL_SET_FILE_INFO)(\r
+ IN EFI_FILE_HANDLE FileHandle,\r
+ IN CONST EFI_FILE_INFO *FileInfo\r
+ );\r
+\r
+/**\r
+ Sets a file's current position\r
+\r
+ This function sets the current file position for the handle to the position supplied. With\r
+ the exception of seeking to position 0xFFFFFFFFFFFFFFFF, only absolute positioning is\r
+ supported, and seeking past the end of the file is allowed (a subsequent write would\r
+ grow the file). Seeking to position 0xFFFFFFFFFFFFFFFF causes the current position\r
+ to be set to the end of the file.\r
+\r
+ @param FileHandle The file handle on which requested position will be set.\r
+ @param Position Byte position from the start of the file\r
+\r
+ @retval EFI_SUCCESS Data was written.\r
+ @retval EFI_UNSUPPORTED The seek request for nonzero is not valid on open directories.\r
+**/\r
+typedef\r
+EFI_STATUS\r
+(EFIAPI *EFI_SHELL_SET_FILE_POSITION)(\r
+ IN EFI_FILE_HANDLE FileHandle,\r
+ IN UINT64 Position\r
+ );\r
+\r
+/**\r
+ This function creates a mapping for a device path.\r
+\r
+ @param DevicePath Points to the device path. If this is NULL and Mapping points to a valid mapping,\r
+ then the mapping will be deleted.\r
+ @param Mapping Points to the null-terminated mapping for the device path.\r
+\r
+ @retval EFI_SUCCESS Mapping created or deleted successfully.\r
+ @retval EFI_NO_MAPPING There is no handle that corresponds exactly to DevicePath. See the\r
+ boot service function LocateDevicePath().\r
+ @retval EFI_ACCESS_DENIED The mapping is a built-in alias.\r
+**/\r
+typedef\r
+EFI_STATUS\r
+(EFIAPI *EFI_SHELL_SET_MAP)(\r
+ IN CONST EFI_DEVICE_PATH_PROTOCOL *DevicePath,\r
+ IN CONST CHAR16 *Mapping\r
+ );\r
+\r
+/**\r
+ Writes data to the file.\r
+\r
+ This function writes the specified number of bytes to the file at the current file position.\r
+ The current file position is advanced the actual number of bytes written, which is\r
+ returned in BufferSize. Partial writes only occur when there has been a data error\r
+ during the write attempt (such as "volume space full"). The file automatically grows to\r
+ hold the data, if required.\r
+\r
+ Direct writes to opened directories are not supported.\r
+\r
+ @param FileHandle The opened file handle for writing.\r
+ @param BufferSize On input, size of Buffer.\r
+ @param Buffer The buffer in which data to write.\r
+\r
+ @retval EFI_SUCCESS Data was written.\r
+ @retval EFI_UNSUPPORTED Writes to 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
+typedef\r
+EFI_STATUS\r
+(EFIAPI *EFI_SHELL_WRITE_FILE)(\r
+ IN EFI_FILE_HANDLE FileHandle,\r
+ IN OUT UINTN *BufferSize,\r
+ OUT VOID *Buffer\r
+ );\r
+\r
+typedef struct _EFI_SHELL_PROTOCOL {\r
+ EFI_SHELL_EXECUTE Execute;\r
+ EFI_SHELL_GET_ENV GetEnv;\r
+ EFI_SHELL_SET_ENV SetEnv;\r
+ EFI_SHELL_SET_ALIAS SetAlias;\r
+ EFI_SHELL_GET_HELP_TEXT GetHelpText;\r
+ EFI_SHELL_GET_DEVICE_PATH_FROM_MAP GetDevicePathFromMap;\r
+ EFI_SHELL_GET_MAP_FROM_DEVICE_PATH GetMapFromDevicePath;\r
+ EFI_SHELL_GET_DEVICE_PATH_FROM_FILE_PATH GetDevicePathFromFilePath;\r
+ EFI_SHELL_GET_FILE_PATH_FROM_DEVICE_PATH GetFilePathFromDevicePath;\r
+ EFI_SHELL_SET_MAP SetMap;\r
+ EFI_SHELL_GET_CUR_DIR GetCurDir;\r
+ EFI_SHELL_SET_CUR_DIR SetCurDir;\r
+ EFI_SHELL_OPEN_FILE_LIST OpenFileList;\r
+ EFI_SHELL_FREE_FILE_LIST FreeFileList;\r
+ EFI_SHELL_REMOVE_DUP_IN_FILE_LIST RemoveDupInFileList;\r
+ EFI_SHELL_BATCH_IS_ACTIVE BatchIsActive;\r
+ EFI_SHELL_IS_ROOT_SHELL IsRootShell;\r
+ EFI_SHELL_ENABLE_PAGE_BREAK EnablePageBreak;\r
+ EFI_SHELL_DISABLE_PAGE_BREAK DisablePageBreak;\r
+ EFI_SHELL_GET_PAGE_BREAK GetPageBreak;\r
+ EFI_SHELL_GET_DEVICE_NAME GetDeviceName;\r
+ EFI_SHELL_GET_FILE_INFO GetFileInfo;\r
+ EFI_SHELL_SET_FILE_INFO SetFileInfo;\r
+ EFI_SHELL_OPEN_FILE_BY_NAME OpenFileByName;\r
+ EFI_SHELL_CLOSE_FILE CloseFile;\r
+ EFI_SHELL_CREATE_FILE CreateFile;\r
+ EFI_SHELL_READ_FILE ReadFile;\r
+ EFI_SHELL_WRITE_FILE WriteFile;\r
+ EFI_SHELL_DELETE_FILE DeleteFile;\r
+ EFI_SHELL_DELETE_FILE_BY_NAME DeleteFileByName;\r
+ EFI_SHELL_GET_FILE_POSITION GetFilePosition;\r
+ EFI_SHELL_SET_FILE_POSITION SetFilePosition;\r
+ EFI_SHELL_FLUSH_FILE FlushFile;\r
+ EFI_SHELL_FIND_FILES FindFiles;\r
+ EFI_SHELL_FIND_FILES_IN_DIR FindFilesInDir;\r
+ EFI_SHELL_GET_FILE_SIZE GetFileSize;\r
+ EFI_SHELL_OPEN_ROOT OpenRoot;\r
+ EFI_SHELL_OPEN_ROOT_BY_HANDLE OpenRootByHandle;\r
+ EFI_EVENT ExecutionBreak;\r
+ UINT32 MajorVersion;\r
+ UINT32 MinorVersion;\r
+} EFI_SHELL_PROTOCOL;\r
+\r
+extern EFI_GUID gEfiShellProtocolGuid;\r
+\r
+#endif\r
--- /dev/null
+/** @file\r
+ Defines for EFI shell environment 2 ported to EDK II build environment.\r
+\r
+Copyright (c) 2005, 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
+ \r
+#ifndef _SHELLENV2_H_\r
+#define _SHELLENV2_H_\r
+\r
+#include <Protocol\SimpleTextIn.h>\r
+#include <Protocol\SimpleTextOut.h>\r
+#include <Protocol\EfiShellInterface.h>\r
+\r
+#define DEFAULT_INIT_ROW 1\r
+#define DEFAULT_AUTO_LF FALSE\r
+\r
+\r
+/**\r
+ this function is a prototype for a function that dumps information on a protocol \r
+ to a given location. the location is dependant on the implementation. This is \r
+ used when programatically adding shell commands.\r
+\r
+ @param Handle the handle the protocol is on\r
+ @param Interface the interface to the protocol\r
+\r
+**/\r
+typedef\r
+VOID\r
+(EFIAPI *SHELLENV_DUMP_PROTOCOL_INFO) (\r
+ IN EFI_HANDLE Handle,\r
+ IN VOID *Interface\r
+ );\r
+\r
+/**\r
+ this function is a prototype foe each command internal to the EFI shell \r
+ implementation. the specific command depends on the implementation. This is \r
+ used when programatically adding shell commands.\r
+\r
+ @param ImageHandle The handle to the binary shell\r
+ @param SystemTable pointer to the system table.\r
+\r
+ @retval EFI_SUCCESS the command ran to completion\r
+ @return other an error ocurred. any error is possible \r
+ depending on the implementation of the shell \r
+ command.\r
+\r
+**/\r
+typedef\r
+EFI_STATUS\r
+(EFIAPI *SHELLENV_INTERNAL_COMMAND) (\r
+ IN EFI_HANDLE ImageHandle,\r
+ IN EFI_SYSTEM_TABLE *SystemTable\r
+ );\r
+\r
+/**\r
+ This function is a prototype for one that gets a help string for a given command. \r
+ This is used when programatically adding shell commands. Upon successful return \r
+ the memory allocated is up to the caller to free.\r
+\r
+ @param Str pointer to pointer to string to display for help.\r
+\r
+ @retval EFI_SUCCESS the help string is in the parameter Str.\r
+\r
+**/\r
+typedef\r
+EFI_STATUS\r
+(EFIAPI *SHELLCMD_GET_LINE_HELP) (\r
+ IN OUT CHAR16 **Str\r
+ );\r
+\r
+/**\r
+* Structure returned from functions that open multiple files\r
+**/\r
+typedef struct {\r
+ UINT32 Signature; ///< SHELL_FILE_ARG_SIGNATURE\r
+ EFI_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
+ UINT64 OpenMode; ///< how was the file opened\r
+ CHAR16 *ParentName; ///< string representation of parent\r
+ EFI_DEVICE_PATH_PROTOCOL *ParentDevicePath; ///< DevicePath for Parent\r
+\r
+ CHAR16 *FullName; ///< path and file name for this file\r
+ CHAR16 *FileName; ///< file name for this file\r
+\r
+ EFI_FILE_HANDLE Handle; ///< handle to this file\r
+ EFI_FILE_INFO *Info; ///< pointer to file info for this file\r
+} SHELL_FILE_ARG;\r
+\r
+/// signature for SHELL_FILE_ARG\r
+#define SHELL_FILE_ARG_SIGNATURE SIGNATURE_32 ('g', 'r', 'a', 'f') \r
+\r
+/**\r
+* GUID for the shell environment2 and shell environment\r
+**/\r
+#define SHELL_ENVIRONMENT_PROTOCOL_GUID \\r
+ { \\r
+ 0x47c7b221, 0xc42a, 0x11d2, 0x8e, 0x57, 0x0, 0xa0, 0xc9, 0x69, 0x72, 0x3b \\r
+ }\r
+\r
+/**\r
+* GUID for the shell environment2 extension (main GUID same as shell environment)\r
+**/\r
+#define EFI_SE_EXT_SIGNATURE_GUID \\r
+ { \\r
+ 0xd2c18636, 0x40e5, 0x4eb5, {0xa3, 0x1b, 0x36, 0x69, 0x5f, 0xd4, 0x2c, 0x87} \\r
+ }\r
+\r
+#define EFI_SHELL_MAJOR_VER 0x00000001 ///< Major version of the EFI_SHELL_ENVIRONMENT2\r
+#define EFI_SHELL_MINOR_VER 0x00000000 ///< Minor version of the EFI_SHELL_ENVIRONMENT2\r
+\r
+/**\r
+ execute a command line\r
+\r
+ this function will run the CommandLine. This includes loading any required images, \r
+ parsing any requires scripts, and it DebugOutput is TRUE printing errors \r
+ encountered directly to the screen.\r
+ \r
+ @param ParentImageHandle Handle of image executing this operation\r
+ @param CommandLine string command line to execute\r
+ @param DebugOutput TRUE indicates that errors should be printed directly.\r
+ FALSE supresses error messages.\r
+\r
+ @retval EFI_SUCCESS the command line executed and completed.\r
+ @retval EFI_ABORTED the operation did not complete due to abort.\r
+ @retval EFI_INVALID_PARAMETER A parameter did not have a valid value.\r
+ @retval EFI_OUT_OF_RESOURCES A required memory allocation failed.\r
+\r
+@sa HandleProtocol\r
+**/\r
+typedef\r
+EFI_STATUS\r
+(EFIAPI *SHELLENV_EXECUTE) (\r
+ IN EFI_HANDLE *ParentImageHandle,\r
+ IN CHAR16 *CommandLine,\r
+ IN BOOLEAN DebugOutput\r
+ );\r
+\r
+/**\r
+ this function returns a shell environment variable value.\r
+\r
+ @param Name pointer to the string with the shell environment \r
+ variables name\r
+\r
+ @retval NULL the shell environment variable's value could not be found\r
+ @retval !NULL the value of the shell environment variable Name\r
+\r
+**/\r
+typedef \r
+CHAR16 * \r
+(EFIAPI *SHELLENV_GET_ENV) (\r
+ IN CHAR16 *Name\r
+ );\r
+\r
+/**\r
+ this function returns a shell environment map value.\r
+\r
+ @param Name pointer to the string with the shell environment \r
+ map name\r
+\r
+ @retval NULL the shell environment map's value could not be found\r
+ @retval !NULL the value of the shell environment map Name\r
+\r
+**/\r
+typedef \r
+CHAR16 * \r
+(EFIAPI *SHELLENV_GET_MAP) (\r
+ IN CHAR16 *Name\r
+ );\r
+\r
+/**\r
+ This function will add an internal command to the shell interface.\r
+\r
+ This will allocate all required memory, put the new command on the command\r
+ list in the correct location.\r
+\r
+ @param Handler the handler function to call when the command gets called\r
+ @param CmdStr The command name\r
+ @param GetLineHelp function to call of get help for this command\r
+\r
+ @retval EFI_SUCCESS the command is now part of the command list\r
+ @retval EFI_OUT_OF_RESOURCES a memory allocation failed.\r
+ @sa SHELLENV_INTERNAL_COMMAND\r
+ @sa SHELLCMD_GET_LINE_HELP\r
+**/\r
+typedef\r
+EFI_STATUS\r
+(EFIAPI *SHELLENV_ADD_CMD) (\r
+ IN SHELLENV_INTERNAL_COMMAND Handler,\r
+ IN CHAR16 *Cmd,\r
+ IN SHELLCMD_GET_LINE_HELP GetLineHelp\r
+ );\r
+\r
+/**\r
+ Internal interface to add protocol handlers.\r
+\r
+ This function is for internal shell use only. This is how protocol handlers are added.\r
+ This will get the current protocol info and add the new info or update existing info\r
+ and then resave the info.\r
+\r
+ @param SaveId save this change as an EFI variable\r
+ @param Protocol the protocol's GUID\r
+ @param DumpToken The function pointer to dump token function or \r
+ NULL\r
+ @param DumpInfo The function pointer to dump infomation function \r
+ or NULL\r
+ @param IdString The english name of the protocol\r
+**/\r
+typedef\r
+VOID\r
+(EFIAPI *SHELLENV_ADD_PROT) (\r
+ IN EFI_GUID *Protocol,\r
+ IN SHELLENV_DUMP_PROTOCOL_INFO DumpToken OPTIONAL,\r
+ IN SHELLENV_DUMP_PROTOCOL_INFO DumpInfo OPTIONAL,\r
+ IN CHAR16 *IdString\r
+ );\r
+\r
+/**\r
+ this function finds a protocol handle by a GUID. \r
+\r
+ This function will check for already known protocols by GUID and if one is \r
+ found it will return the name of that protocol. if no name is found and \r
+ GenId is TRUE it will generate ths string.\r
+\r
+ @param Protocol the GUID of the protocol to look for.\r
+ @param GenId whether to generate a name string if its not found.\r
+\r
+ @return !NULL the Name of the protocol.\r
+ @retval NULL the Name was not found and GenId was not TRUE.\r
+**/\r
+typedef \r
+CHAR16*\r
+(EFIAPI *SHELLENV_GET_PROT) (\r
+ IN EFI_GUID *Protocol, \r
+ IN BOOLEAN GenId\r
+ );\r
+\r
+/**\r
+ this function returns the current directory on a given device\r
+\r
+ If DeviceName is specified, then return the current shell directory on that \r
+ device. If DeviceName is NULL, then return the current directory on the \r
+ current device. The caller us responsible to free the returned string when\r
+ no londer required.\r
+\r
+ @param DeviceName the name of the device to get the current \r
+ directory on or NULL for current device\r
+\r
+ @return The current directory on the current or specified device.\r
+\r
+**/\r
+typedef \r
+CHAR16*\r
+(EFIAPI *SHELLENV_CUR_DIR) (\r
+ IN CHAR16 *DeviceName OPTIONAL\r
+ );\r
+\r
+/**\r
+ this function will open a group of files that match the Arg path, including \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
+ 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
+\r
+ @param Arg pointer Path to files to open\r
+ @param ListHead pointer to allocated and initialized list head \r
+ upon which to append all the opened file structures.\r
+\r
+ @retval EFI_SUCCESS 1 or more files was opened and a struct of each file's\r
+ information was appended to ListHead.\r
+ @retval EFI_OUT_OF_RESOURCES a memory allocation failed.\r
+ @retval EFI_NOT_FOUND no matching files could be found.\r
+ @sa SHELLENV_FREE_FILE_LIST\r
+**/typedef\r
+EFI_STATUS\r
+(EFIAPI *SHELLENV_FILE_META_ARG) (\r
+ IN CHAR16 *Arg,\r
+ IN OUT EFI_LIST_ENTRY *ListHead\r
+ );\r
+\r
+/**\r
+ this frees all of the nodes under the ListHead, but not ListHead itself.\r
+\r
+ @param ListHead Pointer to list to free all nodes of.\r
+\r
+ @retval EFI_SUCCESS always returned.\r
+**/\r
+typedef\r
+EFI_STATUS\r
+(EFIAPI *SHELLENV_FREE_FILE_LIST) (\r
+ IN OUT EFI_LIST_ENTRY *ListHead\r
+ );\r
+\r
+/**\r
+ this function creates a new instance of the ShellInterface protocol for use on \r
+ the ImageHandle.\r
+\r
+ This function is for internal shell usage. this will allocate and then populate \r
+ EFI_SHELL_INTERFACE protocol. it is the caller's responsibility to free the \r
+ memory.\r
+\r
+ @param ImageHandle the handle which will use the new ShellInterface \r
+ protocol.\r
+\r
+ @return the newly allocated shell interface protocol.\r
+\r
+**/\r
+typedef \r
+EFI_SHELL_INTERFACE* \r
+(EFIAPI *SHELLENV_NEW_SHELL) (\r
+ IN EFI_HANDLE ImageHandle\r
+ );\r
+\r
+/**\r
+ this function determins whether a script file is currently being processed.\r
+\r
+ a script file (.nsh file) can contain a series of commands and this is useful to \r
+ know for some shell commands whether they are being run manually or as part of a \r
+ script.\r
+\r
+ @retval TRUE A script file is being processed\r
+ @return FALSE A script file is not being processed\r
+**/\r
+typedef\r
+BOOLEAN\r
+(EFIAPI *SHELLENV_BATCH_IS_ACTIVE) (\r
+ IN VOID\r
+ );\r
+\r
+/**\r
+ This is an internal shell function to free any and all allocated resources. \r
+ This should be called just closing the shell.\r
+**/\r
+typedef\r
+VOID\r
+(EFIAPI *SHELLENV_FREE_RESOURCES) (\r
+ VOID\r
+ );\r
+\r
+/**\r
+ This function enables the page break mode.\r
+\r
+ This mode causes the output to pause after each complete screen to enable a \r
+ user to more easily read it. if AutoWrap is TRUE then rows with too many \r
+ characters will be chopped and divided into 2 rows. if FALSE then rows with \r
+ too many characters may not be fully visible to the user on the screen.\r
+\r
+ @param StartRow the row number to start this on.\r
+ @param AutoWrap whether to auto wrap rows that are \r
+**/\r
+typedef\r
+VOID\r
+(EFIAPI *SHELLENV_ENABLE_PAGE_BREAK) (\r
+ IN INT32 StartRow,\r
+ IN BOOLEAN AutoWrap\r
+ );\r
+\r
+/**\r
+ This function disables the page break mode.\r
+\r
+ disabling this causes the output to print out exactly as coded with no breaks \r
+ for readability.\r
+**/\r
+typedef\r
+VOID\r
+(EFIAPI *SHELLENV_DISABLE_PAGE_BREAK) (\r
+ IN VOID\r
+ );\r
+\r
+/**\r
+ Get the status of the page break output mode.\r
+\r
+ @retval FALSE page break output mode is not enabled\r
+ @retval TRUE page break output mode is enabled\r
+**/\r
+typedef\r
+BOOLEAN\r
+(EFIAPI *SHELLENV_GET_PAGE_BREAK) (\r
+ IN VOID\r
+ );\r
+\r
+/**\r
+ this function sets the keys to filter for for the console in. the valid \r
+ values to set are:\r
+\r
+ #define EFI_OUTPUT_SCROLL 0x00000001\r
+ #define EFI_OUTPUT_PAUSE 0x00000002\r
+ #define EFI_EXECUTION_BREAK 0x00000004\r
+\r
+ @param KeyFilter The new key filter to use.\r
+**/\r
+typedef\r
+VOID\r
+(EFIAPI *SHELLENV_SET_KEY_FILTER) (\r
+ IN UINT32 KeyFilter\r
+ );\r
+\r
+/**\r
+ this function gets the keys to filter for for the console in. the valid \r
+ values to get are:\r
+\r
+ #define EFI_OUTPUT_SCROLL 0x00000001\r
+ #define EFI_OUTPUT_PAUSE 0x00000002\r
+ #define EFI_EXECUTION_BREAK 0x00000004\r
+\r
+ @retval the current filter mask.\r
+**/\r
+typedef\r
+UINT32\r
+(EFIAPI *SHELLENV_GET_KEY_FILTER) (\r
+ IN VOID\r
+ );\r
+\r
+/**\r
+ this function determins if the shell application should break.\r
+\r
+ This is used to inform a shell application that a break condition has been \r
+ initiated. long loops should check this to prevent delays to the break.\r
+\r
+ @retval TRUE a break has been signaled. the application \r
+ should exit with EFI_ABORTED as soon as possible.\r
+ @retval FALSE continue as normal.\r
+**/\r
+typedef\r
+BOOLEAN\r
+(EFIAPI *SHELLENV_GET_EXECUTION_BREAK) (\r
+ IN VOID\r
+ );\r
+\r
+/**\r
+ This is an internal-shell function used to increment the shell nesting level.\r
+\r
+**/\r
+typedef\r
+VOID\r
+(EFIAPI *SHELLENV_INCREMENT_SHELL_NESTING_LEVEL) (\r
+ IN VOID\r
+ );\r
+\r
+/**\r
+ This is an internal-shell function used to decrement the shell nesting level.\r
+**/\r
+typedef\r
+VOID\r
+(EFIAPI *SHELLENV_DECREMENT_SHELL_NESTING_LEVEL) (\r
+ IN VOID\r
+ );\r
+\r
+/**\r
+ this function determins if the caller is running under the root shell.\r
+\r
+ @retval TRUE The caller is running under the root shell\r
+ @retval FALSE The caller is not running under the root shell\r
+\r
+**/\r
+typedef\r
+BOOLEAN\r
+(EFIAPI *SHELLENV_IS_ROOT_SHELL) (\r
+ IN VOID\r
+ );\r
+\r
+/**\r
+ Close the console proxy to restore the original console.\r
+\r
+ This is an internal shell function to handle shell cascading. it restores the \r
+ original set of console protocols.\r
+ \r
+ @param ConInHandle The handle of ConIn.\r
+ @param ConIn pointer to the location to return the pointer to \r
+ the original console input.\r
+ @param ConOutHandle The handle of ConOut\r
+ @param ConOut pointer to the location to return the pointer to \r
+ the original console output.\r
+**/\r
+typedef\r
+VOID\r
+(EFIAPI *SHELLENV_CLOSE_CONSOLE_PROXY) (\r
+ IN EFI_HANDLE ConInHandle,\r
+ IN OUT EFI_SIMPLE_TEXT_INPUT_PROTOCOL **ConIn,\r
+ IN EFI_HANDLE ConOutHandle,\r
+ IN OUT EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL **ConOut\r
+ );\r
+\r
+//\r
+// declarations of handle enumerator\r
+//\r
+/**\r
+ For ease of use the shell maps handle #'s to short numbers.\r
+ This is only done on request for various internal commands and the references \r
+ are immediately freed when the internal command completes.\r
+**/\r
+typedef\r
+VOID\r
+(EFIAPI *INIT_HANDLE_ENUMERATOR) (\r
+ VOID\r
+ );\r
+\r
+/**\r
+ this is an internal shell function to enumerate the handle database.\r
+\r
+ this function gets the next handle in the handle database. if no handles are \r
+ found EFI_NOT_FOUND is returned. if the previous Handle was the last handle \r
+ it is set to NULL before returning.\r
+\r
+ this must be called after INIT_HANDLE_ENUMERATOR and before CLOSE_HANDLE_ENUMERATOR.\r
+\r
+ @param Handle pointer to pointer to Handle. will be set\r
+ on a sucessful return.\r
+\r
+ @retval EFI_SUCCESS the next handle in the handle database is *Handle\r
+ @retval EFI_NOT_FOUND there is not another handle.\r
+**/\r
+typedef\r
+EFI_STATUS\r
+(EFIAPI *NEXT_HANDLE) (\r
+ IN OUT EFI_HANDLE **Handle\r
+ );\r
+\r
+/**\r
+ this is an internal shell function to enumerate the handle database.\r
+\r
+ this function skips the next SkipNum handles in the handle database. If there \r
+ are not enough handles left to skip that many EFI_ACCESS_DENIED is returned and \r
+ no skip is performed.\r
+\r
+ this must be called after INIT_HANDLE_ENUMERATOR and before CLOSE_HANDLE_ENUMERATOR.\r
+\r
+ @param SkipNum how many handles to skip\r
+\r
+ @retval EFI_SUCCESS the next handle in the handle database is *Handle\r
+ @retval EFI_ACCESS_DENIED there are not SkipNum handles left in the database\r
+**/\r
+typedef\r
+EFI_STATUS\r
+(EFIAPI *SKIP_HANDLE) (\r
+ IN UINTN SkipNum\r
+ );\r
+\r
+/**\r
+ this is an internal shell function to enumerate the handle database.\r
+\r
+ this function resets the the handle database so that NEXT_HANDLE and SKIP_HANDLE \r
+ will start from EnumIndex on the next call. \r
+ \r
+ this must be called after INIT_HANDLE_ENUMERATOR and before CLOSE_HANDLE_ENUMERATOR.\r
+\r
+ @param EnumIndex where to start.\r
+\r
+ @retval the number of handles either read out or skipped before this reset.\r
+**/\r
+typedef\r
+UINTN\r
+(EFIAPI *RESET_HANDLE_ENUMERATOR) (\r
+ IN UINTN EnumIndex\r
+ );\r
+\r
+/**\r
+ this is an internal shell function to enumerate the handle database.\r
+ \r
+ this must be called after INIT_HANDLE_ENUMERATOR.\r
+\r
+ this function releases all memory and resources associated with the handle database.\r
+ after this no other handle enumerator functions except INIT_HANDLE_ENUMERATOR will \r
+ function properly.\r
+**/\r
+typedef\r
+VOID\r
+(EFIAPI *CLOSE_HANDLE_ENUMERATOR) (\r
+ VOID\r
+ );\r
+\r
+/**\r
+ this is an internal shell function to enumerate the handle database.\r
+\r
+ this function returns the number of handles in the handle database.\r
+ \r
+ this must be called after INIT_HANDLE_ENUMERATOR and before CLOSE_HANDLE_ENUMERATOR.\r
+\r
+ @retval the number of handles in the handle database.\r
+**/\r
+typedef\r
+UINTN\r
+(EFIAPI *GET_NUM) (\r
+ VOID\r
+ );\r
+\r
+/**\r
+Handle Enumerator structure\r
+**/\r
+typedef struct {\r
+ INIT_HANDLE_ENUMERATOR Init; ///< pointer to INIT_HANDLE_ENUMERATOR function\r
+ NEXT_HANDLE Next; ///< pointer to NEXT_HANDLE function\r
+ SKIP_HANDLE Skip; ///< pointer to SKIP_HANDLE function\r
+ RESET_HANDLE_ENUMERATOR Reset; ///< pointer to RESET_HANDLE_ENUMERATOR function\r
+ CLOSE_HANDLE_ENUMERATOR Close; ///< pointer to CLOSE_HANDLE_ENUMERATOR function\r
+ GET_NUM GetNum; ///< pointer to GET_NUM function\r
+} HANDLE_ENUMERATOR;\r
+/**\r
+ signature for the PROTOCOL_INFO structure \r
+**/\r
+#define PROTOCOL_INFO_SIGNATURE SIGNATURE_32 ('s', 'p', 'i', 'n')\r
+/**\r
+ PROTOCOL_INFO structure for protocol enumerator functions.\r
+\r
+**/\r
+typedef struct {\r
+ UINTN Signature; ///< PROTOCOL_INFO_SIGNATURE \r
+ EFI_LIST_ENTRY Link; ///< standard lined list helper member\r
+ //\r
+ // parsing info for the protocol\r
+ //\r
+ EFI_GUID ProtocolId; ///< GUID for the protocol\r
+ CHAR16 *IdString; ///< Name of the protocol\r
+ SHELLENV_DUMP_PROTOCOL_INFO DumpToken; ///< pointer to DumpToken function for the protocol\r
+ SHELLENV_DUMP_PROTOCOL_INFO DumpInfo; ///< pointer to DumpInfo function for the protocol\r
+ //\r
+ // database info on which handles are supporting this protocol\r
+ //\r
+ UINTN NoHandles; ///< how many handles produce this protocol\r
+ EFI_HANDLE *Handles; ///< array of handles\r
+\r
+} PROTOCOL_INFO;\r
+\r
+//\r
+// declarations of protocol info enumerator\r
+//\r
+/**\r
+ this is an internal shell function to initialize the protocol enumerator.\r
+\r
+ this must be called before NEXT_PROTOCOL_INFO, SKIP_PROTOCOL_INFO, \r
+ RESET_PROTOCOL_INFO_ENUMERATOR, and CLOSE_PROTOCOL_INFO_ENUMERATOR are\r
+ called.\r
+**/\r
+typedef\r
+VOID\r
+(EFIAPI *INIT_PROTOCOL_INFO_ENUMERATOR) (\r
+ VOID\r
+ );\r
+\r
+/**\r
+ this function is an internal shell function for enumeration of protocols. \r
+\r
+ This functiol will return the next protocol in the list. If this is called \r
+ immediately after initialization it will return the first. If this is called\r
+ immediately after reset it will return the protocol first again.\r
+\r
+ This cannot be called after CLOSE_PROTOCOL_INFO_ENUMERATOR, but it must be \r
+ called after INIT_PROTOCOL_INFO_ENUMERATOR.\r
+\r
+ @param ProtocolInfo pointer to pointer to protocol information structure.\r
+\r
+ @retval EFI_SUCCESS the next protocol's information was sucessfully returned. \r
+ If there were no more protocols NULL was returned.\r
+**/\r
+typedef\r
+EFI_STATUS\r
+(EFIAPI *NEXT_PROTOCOL_INFO) (\r
+ IN OUT PROTOCOL_INFO **ProtocolInfo\r
+ );\r
+\r
+/**\r
+ this function is an internal shell function for enumeration of protocols. \r
+\r
+ This cannot be called after CLOSE_PROTOCOL_INFO_ENUMERATOR, but it must be \r
+ called after INIT_PROTOCOL_INFO_ENUMERATOR.\r
+\r
+ this function does nothing and always returns EFI_SUCCESS.\r
+\r
+ @retval EFI_SUCCESS always returned (see note).\r
+**/\r
+typedef\r
+EFI_STATUS\r
+(EFIAPI *SKIP_PROTOCOL_INFO) (\r
+ IN UINTN SkipNum\r
+ );\r
+\r
+/**\r
+ this function is an internal shell function for enumeration of protocols. \r
+\r
+ This cannot be called after CLOSE_PROTOCOL_INFO_ENUMERATOR, but it must be \r
+ called after INIT_PROTOCOL_INFO_ENUMERATOR.\r
+\r
+ this function resets the list of protocols such that the next one in the \r
+ list is the begining of the list.\r
+**/\r
+typedef\r
+VOID\r
+(EFIAPI *RESET_PROTOCOL_INFO_ENUMERATOR) (\r
+ VOID\r
+ );\r
+\r
+\r
+/**\r
+ this function is an internal shell function for enumeration of protocols. \r
+\r
+ This must be called after INIT_PROTOCOL_INFO_ENUMERATOR. After this call\r
+ no protocol enumerator calls except INIT_PROTOCOL_INFO_ENUMERATOR may be made.\r
+\r
+ this function frees any memory or resources associated with the protocol\r
+ enumerator.\r
+**/\r
+typedef\r
+VOID\r
+(EFIAPI *CLOSE_PROTOCOL_INFO_ENUMERATOR) (\r
+ VOID\r
+ );\r
+\r
+/**\r
+* protocol enumerator structure of function pointers.\r
+**/\r
+typedef struct {\r
+ INIT_PROTOCOL_INFO_ENUMERATOR Init; ///< pointer to INIT_PROTOCOL_INFO_ENUMERATOR function\r
+ NEXT_PROTOCOL_INFO Next; ///< pointer to NEXT_PROTOCOL_INFO function\r
+ SKIP_PROTOCOL_INFO Skip; ///< pointer to SKIP_PROTOCOL_INFO function\r
+ RESET_PROTOCOL_INFO_ENUMERATOR Reset; ///< pointer to RESET_PROTOCOL_INFO_ENUMERATOR function\r
+ CLOSE_PROTOCOL_INFO_ENUMERATOR Close; ///< pointer to CLOSE_PROTOCOL_INFO_ENUMERATOR function\r
+} PROTOCOL_INFO_ENUMERATOR;\r
+\r
+/**\r
+ this function is used to retrieve a user-friendly display name for a handle. \r
+\r
+ If UseComponentName is TRUE then the component name protocol for this device \r
+ or it's parent device (if required) will be used to obtain the name of the \r
+ device. If UseDevicePath is TRUE it will get the human readable device path\r
+ and return that. If both are TRUE it will try to use component name first\r
+ and device path if that fails. \r
+\r
+ It will use either ComponentName or ComponentName2 protocol, depending on \r
+ what is present.\r
+\r
+ This function will furthur verify whether the handle in question produced either\r
+ EFI_DRIVER_CONFIGRATION_PROTOCOL or EFI_DRIVER_CONFIGURATION2_PROTOCOL and also \r
+ whether the handle in question produced either EFI_DRIVER_DIAGNOSTICS_PROTOCOL or \r
+ EFI_DRIVER_DIAGNOSTICS2_PROTOCOL.\r
+ \r
+ Upon sucessful return the memory for *BestDeviceName is up to the caller to free.\r
+\r
+ @param DeviceHandle the device handle whose name is desired\r
+ @param UseComponentName whether to use the ComponentName protocol at all\r
+ @param UseDevicePath whether to use the DevicePath protocol at all\r
+ @param Language pointer to language string to use\r
+ @param BestDeviceName pointer to pointer to string allocated with the name\r
+ @param ConfigurationStatus pointer to status for opening a Configuration protocol\r
+ @param DiagnosticsStatus pointer to status for opening a Diagnostics protocol\r
+ @param Display Whether to Print this out to default Print location\r
+ @param Indent how many characters to indent the printing\r
+\r
+ @retval EFI_SUCCESS this function always returns EFI_SUCCESS\r
+**/\r
+typedef\r
+EFI_STATUS\r
+(EFIAPI *GET_DEVICE_NAME) (\r
+ EFI_HANDLE DeviceHandle,\r
+ BOOLEAN UseComponentName,\r
+ BOOLEAN UseDevicePath,\r
+ CHAR8 *Language,\r
+ CHAR16 **BestDeviceName,\r
+ EFI_STATUS *ConfigurationStatus,\r
+ EFI_STATUS *DiagnosticsStatus,\r
+ BOOLEAN Display,\r
+ UINTN Indent\r
+ );\r
+\r
+#define EFI_SHELL_COMPATIBLE_MODE_VER L"1.1.1" ///< string for lowest version this shell supports\r
+#define EFI_SHELL_ENHANCED_MODE_VER L"1.1.2" ///< string for highest version this shell supports\r
+\r
+/**\r
+ this function gets the shell mode as stored in the shell environment \r
+ "efishellmode". it will not fail.\r
+\r
+ @param Mode returns a string representing one of the \r
+ 2 supported modes of the shell.\r
+\r
+ @retval EFI_SUCCESS this function always returns success\r
+**/\r
+typedef\r
+EFI_STATUS\r
+(EFIAPI *GET_SHELL_MODE) (\r
+ OUT CHAR16 **Mode\r
+ );\r
+\r
+/**\r
+ Convert a file system style name to an file path\r
+\r
+ This function will convert a shell path name to a Device Path Protocol path.\r
+ This function will allocate any required memory for this operation and it \r
+ is the responsibility of the caller to free that memory when no longer required.\r
+\r
+ if anything prevents the complete conversion free any allocated memory and \r
+ return NULL.\r
+\r
+ @retval !NULL a pointer to the callee allocated Device Path\r
+ @retval NULL the operation could not be completed.\r
+**/\r
+typedef \r
+EFI_DEVICE_PATH_PROTOCOL* \r
+(EFIAPI *SHELLENV_NAME_TO_PATH) (\r
+ IN CHAR16 *Path\r
+ );\r
+\r
+/**\r
+ converts a device path into a file system map name.\r
+\r
+ if DevPath is NULL then ASSERT\r
+ This function looks through the shell environment map for a map whose device\r
+ path matches the DevPath parameter. If one is found the Name is returned via \r
+ Name parameter. If sucessful the caller must free the memory allocated for\r
+ Name.\r
+\r
+ this function will use the internal lock to prevent changes to the map during \r
+ the lookup operation.\r
+ \r
+ @param DevPath The device path to search for a name for\r
+ @param ConsistMapping what state to verify map flag VAR_ID_CONSIST\r
+ @param Name on sucessful return the name of that device path\r
+\r
+ @retval EFI_SUCCESS the DevPath was found and the name returned\r
+ in Name. \r
+ @retval EFI_OUT_OF_RESOURCES A required memory allocation failed.\r
+ @retval EFI_UNSUPPORTED the DevPath was not found in the map\r
+**/\r
+typedef\r
+EFI_STATUS\r
+(EFIAPI *SHELLENV_GET_FS_NAME) (\r
+ IN EFI_DEVICE_PATH_PROTOCOL * DevPath,\r
+ IN BOOLEAN ConsistMapping,\r
+ OUT CHAR16 **Name\r
+ );\r
+\r
+/**\r
+ this function will open a group of files that match the Arg path, but will not \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
+ 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
+\r
+ @param Arg pointer Path to files to open\r
+ @param ListHead pointer to allocated and initialized list head \r
+ upon which to append all the opened file structures.\r
+\r
+ @retval EFI_SUCCESS 1 or more files was opened and a struct of each file's\r
+ information was appended to ListHead.\r
+ @retval EFI_OUT_OF_RESOURCES a memory allocation failed.\r
+ @retval EFI_NOT_FOUND no matching files could be found.\r
+ @sa SHELLENV_FREE_FILE_LIST\r
+**/\r
+typedef\r
+EFI_STATUS\r
+(EFIAPI *SHELLENV_FILE_META_ARG_NO_WILDCARD) (\r
+ IN CHAR16 *Arg,\r
+ IN OUT EFI_LIST_ENTRY *ListHead\r
+ );\r
+\r
+/**\r
+ this function removes duplicate file listings from lists.\r
+\r
+ this is a function for use with SHELLENV_FILE_META_ARG_NO_WILDCARD and \r
+ SHELLENV_FILE_META_ARG. this function will verify that there are no duplicate\r
+ files in the list of returned files. any file listed twice will have one of its\r
+ instances removed.\r
+\r
+ @param ListHead pointer to linked list head that was returned from \r
+ SHELLENV_FILE_META_ARG_NO_WILDCARD or\r
+ SHELLENV_FILE_META_ARG.\r
+\r
+ @retval EFI_SUCCESS this function always returns success.\r
+\r
+**/\r
+typedef\r
+EFI_STATUS\r
+(EFIAPI *SHELLENV_DEL_DUP_FILE) (\r
+ IN EFI_LIST_ENTRY * ListHead\r
+ );\r
+\r
+/**\r
+ Converts a File System map name to a device path.\r
+\r
+ if DevPath is NULL then ASSERT()\r
+\r
+ This function looks through the shell environment map for a map whose Name \r
+ matches the Name parameter. If one is found the device path pointer is \r
+ updated to point to that file systems device path. the caller should not \r
+ free the memory from that device path.\r
+\r
+ this function will use the internal lock to prevent changes to the map during \r
+ the lookup operation.\r
+\r
+ @param Name pointer to NULL terminated UNICODE string of the \r
+ file system name\r
+ @param DevPath pointer to pointer to DevicePath. only valid on \r
+ OUT if sucessful\r
+\r
+ @retval EFI_SUCCESS the conversion was successful and the device \r
+ path was returned.\r
+ @retval EFI_NOT_FOUND the file system could not be found in the map.\r
+**/\r
+typedef\r
+EFI_STATUS\r
+(EFIAPI *SHELLENV_GET_FS_DEVICE_PATH) (\r
+ IN CHAR16 *Name,\r
+ OUT EFI_DEVICE_PATH_PROTOCOL **DevPath\r
+ );\r
+\r
+/// EFI_SHELL_ENVIRONMENT2 protocol structure\r
+/// contains pointers to functions\r
+typedef struct {\r
+ SHELLENV_EXECUTE Execute;\r
+ SHELLENV_GET_ENV GetEnv;\r
+ SHELLENV_GET_MAP GetMap;\r
+ SHELLENV_ADD_CMD AddCmd;\r
+ SHELLENV_ADD_PROT AddProt;\r
+ SHELLENV_GET_PROT GetProt;\r
+ SHELLENV_CUR_DIR CurDir;\r
+ SHELLENV_FILE_META_ARG FileMetaArg;\r
+ SHELLENV_FREE_FILE_LIST FreeFileList;\r
+\r
+ //\r
+ // The following services are only used by the shell itself\r
+ //\r
+ SHELLENV_NEW_SHELL NewShell;\r
+ SHELLENV_BATCH_IS_ACTIVE BatchIsActive;\r
+\r
+ SHELLENV_FREE_RESOURCES FreeResources;\r
+\r
+ //\r
+ // GUID to differentiate ShellEnvironment2 from ShellEnvironment\r
+ //\r
+ EFI_GUID SESGuid;\r
+ //\r
+ // Major Version grows if shell environment interface has been changes\r
+ //\r
+ UINT32 MajorVersion;\r
+ UINT32 MinorVersion;\r
+ SHELLENV_ENABLE_PAGE_BREAK EnablePageBreak;\r
+ SHELLENV_DISABLE_PAGE_BREAK DisablePageBreak;\r
+ SHELLENV_GET_PAGE_BREAK GetPageBreak;\r
+\r
+ SHELLENV_SET_KEY_FILTER SetKeyFilter;\r
+ SHELLENV_GET_KEY_FILTER GetKeyFilter;\r
+\r
+ SHELLENV_GET_EXECUTION_BREAK GetExecutionBreak;\r
+ SHELLENV_INCREMENT_SHELL_NESTING_LEVEL IncrementShellNestingLevel;\r
+ SHELLENV_DECREMENT_SHELL_NESTING_LEVEL DecrementShellNestingLevel;\r
+ SHELLENV_IS_ROOT_SHELL IsRootShell;\r
+\r
+ SHELLENV_CLOSE_CONSOLE_PROXY CloseConsoleProxy;\r
+ HANDLE_ENUMERATOR HandleEnumerator;\r
+ PROTOCOL_INFO_ENUMERATOR ProtocolInfoEnumerator;\r
+ GET_DEVICE_NAME GetDeviceName;\r
+ GET_SHELL_MODE GetShellMode;\r
+ SHELLENV_NAME_TO_PATH NameToPath;\r
+ SHELLENV_GET_FS_NAME GetFsName;\r
+ SHELLENV_FILE_META_ARG_NO_WILDCARD FileMetaArgNoWildCard;\r
+ SHELLENV_DEL_DUP_FILE DelDupFileArg;\r
+ SHELLENV_GET_FS_DEVICE_PATH GetFsDevicePath;\r
+} EFI_SHELL_ENVIRONMENT2;\r
+\r
+extern EFI_GUID gEfiShellEnvironment2Guid;\r
+extern EFI_GUID gEfiShellEnvironment2ExtGuid;\r
+#endif // _SHELLENV_H_\r
--- /dev/null
+/** @file\r
+ EFI Shell Interface protocol from EDK shell (no spec).\r
+\r
+ Shell Interface - additional information (over image_info) provided\r
+ to an application started by the shell.\r
+\r
+ ConIo - provides a file style interface to the console. Note that the\r
+ ConOut & ConIn interfaces in the system table will work as well, and both\r
+ all will be redirected to a file if needed on a command line\r
+\r
+ The shell interface's and data (including ConIo) are only valid during\r
+ the applications Entry Point. Once the application returns from it's\r
+ entry point the data is freed by the invoking shell.\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
+#ifndef _SHELLINTERFACE_H_\r
+#define _SHELLINTERFACE_H_\r
+\r
+#include <Protocol\LoadedImage.h>\r
+\r
+#define SHELL_INTERFACE_PROTOCOL_GUID \\r
+ { \\r
+ 0x47c7b223, 0xc42a, 0x11d2, 0x8e, 0x57, 0x0, 0xa0, 0xc9, 0x69, 0x72, 0x3b \\r
+ }\r
+\r
+///\r
+/// bit definitions for EFI_SHELL_ARG_INFO\r
+///\r
+typedef enum {\r
+ ARG_NO_ATTRIB = 0x0,\r
+ ARG_IS_QUOTED = 0x1,\r
+ ARG_PARTIALLY_QUOTED = 0x2,\r
+ ARG_FIRST_HALF_QUOTED = 0x4,\r
+ ARG_FIRST_CHAR_IS_ESC = 0x8\r
+};\r
+\r
+///\r
+/// attributes for an argument.\r
+///\r
+typedef struct _EFI_SHELL_ARG_INFO {\r
+ UINT32 Attributes;\r
+} EFI_SHELL_ARG_INFO;\r
+\r
+///\r
+/// This protocol provides access to additional information about a shell app.\r
+///\r
+typedef struct {\r
+ ///\r
+ /// Handle back to original image handle & image info\r
+ ///\r
+ EFI_HANDLE ImageHandle;\r
+ EFI_LOADED_IMAGE_PROTOCOL *Info;\r
+\r
+ ///\r
+ /// Parsed arg list converted more C like format\r
+ ///\r
+ CHAR16 **Argv;\r
+ UINTN Argc;\r
+\r
+ ///\r
+ /// Storage for file redirection args after parsing\r
+ ///\r
+ CHAR16 **RedirArgv;\r
+ UINTN RedirArgc;\r
+\r
+ ///\r
+ /// A file style handle for console io\r
+ ///\r
+ EFI_FILE_HANDLE StdIn;\r
+ EFI_FILE_HANDLE StdOut;\r
+ EFI_FILE_HANDLE StdErr;\r
+\r
+ ///\r
+ /// list of attributes for each argument\r
+ ///\r
+ EFI_SHELL_ARG_INFO *ArgInfo;\r
+\r
+ ///\r
+ /// whether we are echoing\r
+ ///\r
+ BOOLEAN EchoOn;\r
+} EFI_SHELL_INTERFACE;\r
+\r
+extern EFI_GUID gEfiShellInterfaceGuid;\r
+\r
+#endif\r
--- /dev/null
+/** @file\r
+ EFI Shell protocol as defined in the UEFI Shell 2.0 specification.\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
+#ifndef __EFI_SHELL_PARAMETERS_PROTOCOL__\r
+#define __EFI_SHELL_PARAMETERS_PROTOCOL__\r
+\r
+#define EFI_SHELL_PARAMETERS_PROTOCOL_GUID \\r
+ { \\r
+ 0x752f3136, 0x4e16, 0x4fdc, { 0xa2, 0x2a, 0xe5, 0xf4, 0x68, 0x12, 0xf4, 0xca } \\r
+ }\r
+\r
+typedef struct _EFI_SHELL_PARAMETERS_PROTOCOL {\r
+ CHAR16 **Argv;\r
+ UINTN Argc;\r
+ EFI_FILE_HANDLE StdIn;\r
+ EFI_FILE_HANDLE StdOut;\r
+ EFI_FILE_HANDLE StdErr;\r
+} EFI_SHELL_PARAMETERS_PROTOCOL;\r
+\r
+extern EFI_GUID gEfiShellParametersProtocolGuid;\r
+\r
+#endif\r
--- /dev/null
+/** @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
+#include <Uefi.h>\r
+#include <Library/ShellLib.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
+#include <Library/DevicePathLib.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
+#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
+/**\r
+ helper function to find ShellEnvironment2 for constructor\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+ShellFindSE2 (\r
+ IN EFI_HANDLE ImageHandle\r
+ )\r
+{\r
+ EFI_STATUS Status;\r
+ EFI_HANDLE *Buffer;\r
+ UINTN BufferSize;\r
+ UINTN HandleIndex;\r
+\r
+ BufferSize = 0;\r
+ Buffer = NULL;\r
+ Status = gBS->OpenProtocol(ImageHandle, \r
+ &gEfiShellEnvironment2Guid,\r
+ (VOID **)&mEfiShellEnvironment2,\r
+ ImageHandle,\r
+ NULL,\r
+ EFI_OPEN_PROTOCOL_GET_PROTOCOL\r
+ );\r
+ //\r
+ // look for the mEfiShellEnvironment2 protocol at a higher level\r
+ //\r
+ if (EFI_ERROR (Status) || !(CompareGuid (&mEfiShellEnvironment2->SESGuid, &gEfiShellEnvironment2ExtGuid) != FALSE &&\r
+ (mEfiShellEnvironment2->MajorVersion > EFI_SHELL_MAJOR_VER ||\r
+ (mEfiShellEnvironment2->MajorVersion == EFI_SHELL_MAJOR_VER && mEfiShellEnvironment2->MinorVersion >= EFI_SHELL_MINOR_VER)))) {\r
+ //\r
+ // figure out how big of a buffer we need.\r
+ //\r
+ Status = gBS->LocateHandle (ByProtocol,\r
+ &gEfiShellEnvironment2Guid,\r
+ NULL, // ignored for ByProtocol\r
+ &BufferSize,\r
+ Buffer\r
+ );\r
+ ASSERT(Status == EFI_BUFFER_TOO_SMALL);\r
+ Buffer = (EFI_HANDLE*)AllocatePool(BufferSize);\r
+ ASSERT(Buffer != NULL);\r
+ Status = gBS->LocateHandle (ByProtocol,\r
+ &gEfiShellEnvironment2Guid,\r
+ NULL, // ignored for ByProtocol\r
+ &BufferSize,\r
+ Buffer\r
+ );\r
+ if (!EFI_ERROR (Status)) {\r
+ //\r
+ // now parse the list of returned handles\r
+ //\r
+ Status = EFI_NOT_FOUND;\r
+ for (HandleIndex = 0; HandleIndex < (BufferSize/sizeof(Buffer[0])); HandleIndex++) {\r
+ Status = gBS->OpenProtocol(Buffer[HandleIndex], \r
+ &gEfiShellEnvironment2Guid,\r
+ (VOID **)&mEfiShellEnvironment2,\r
+ ImageHandle,\r
+ NULL,\r
+ EFI_OPEN_PROTOCOL_GET_PROTOCOL\r
+ );\r
+ if (CompareGuid (&mEfiShellEnvironment2->SESGuid, &gEfiShellEnvironment2ExtGuid) != FALSE &&\r
+ (mEfiShellEnvironment2->MajorVersion > EFI_SHELL_MAJOR_VER ||\r
+ (mEfiShellEnvironment2->MajorVersion == EFI_SHELL_MAJOR_VER && mEfiShellEnvironment2->MinorVersion >= EFI_SHELL_MINOR_VER))) {\r
+ mEfiShellEnvironment2Handle = Buffer[HandleIndex];\r
+ Status = EFI_SUCCESS;\r
+ break;\r
+ }\r
+ }\r
+ }\r
+ }\r
+ if (Buffer != NULL) {\r
+ FreePool (Buffer);\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
+ShellLibConstructor (\r
+ IN EFI_HANDLE ImageHandle,\r
+ IN EFI_SYSTEM_TABLE *SystemTable\r
+ )\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
+ Status = gBS->OpenProtocol(ImageHandle, \r
+ &gEfiShellProtocolGuid,\r
+ (VOID **)&mEfiShellProtocol,\r
+ ImageHandle,\r
+ NULL,\r
+ EFI_OPEN_PROTOCOL_GET_PROTOCOL\r
+ );\r
+ if (EFI_ERROR(Status)) {\r
+ mEfiShellProtocol = NULL;\r
+ }\r
+ Status = gBS->OpenProtocol(ImageHandle, \r
+ &gEfiShellParametersProtocolGuid,\r
+ (VOID **)&mEfiShellParametersProtocol,\r
+ ImageHandle,\r
+ NULL,\r
+ EFI_OPEN_PROTOCOL_GET_PROTOCOL\r
+ );\r
+ if (EFI_ERROR(Status)) {\r
+ mEfiShellParametersProtocol = NULL;\r
+ }\r
+\r
+ if (mEfiShellParametersProtocol == NULL || mEfiShellProtocol == NULL) {\r
+ //\r
+ // Moved to seperate function due to complexity\r
+ //\r
+ Status = ShellFindSE2(ImageHandle);\r
+\r
+ if (EFI_ERROR(Status)) {\r
+ DEBUG((DEBUG_ERROR, "Status: 0x%08x\r\n", Status));\r
+ mEfiShellEnvironment2 = NULL;\r
+ }\r
+ Status = gBS->OpenProtocol(ImageHandle, \r
+ &gEfiShellInterfaceGuid,\r
+ (VOID **)&mEfiShellInterface,\r
+ ImageHandle,\r
+ NULL,\r
+ EFI_OPEN_PROTOCOL_GET_PROTOCOL\r
+ );\r
+ if (EFI_ERROR(Status)) {\r
+ mEfiShellInterface = NULL;\r
+ }\r
+ }\r
+ //\r
+ // only success getting 2 of either the old or new, but no 1/2 and 1/2\r
+ //\r
+ if ((mEfiShellEnvironment2 != NULL && mEfiShellInterface != NULL) || \r
+ (mEfiShellProtocol != NULL && mEfiShellParametersProtocol != NULL) ) {\r
+ return (EFI_SUCCESS);\r
+ }\r
+ return (EFI_NOT_FOUND);\r
+}\r
+\r
+/**\r
+ Destructory for the library. free any resources.\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+ShellLibDestructor (\r
+ IN EFI_HANDLE ImageHandle,\r
+ IN EFI_SYSTEM_TABLE *SystemTable\r
+ )\r
+{\r
+ if (mEfiShellEnvironment2 != NULL) {\r
+ gBS->CloseProtocol(mEfiShellEnvironment2Handle==NULL?ImageHandle:mEfiShellEnvironment2Handle,\r
+ &gEfiShellEnvironment2Guid,\r
+ ImageHandle,\r
+ NULL);\r
+ }\r
+ if (mEfiShellInterface != NULL) {\r
+ gBS->CloseProtocol(ImageHandle,\r
+ &gEfiShellInterfaceGuid,\r
+ ImageHandle,\r
+ NULL); \r
+ }\r
+ if (mEfiShellProtocol != NULL) {\r
+ gBS->CloseProtocol(ImageHandle,\r
+ &gEfiShellProtocolGuid,\r
+ ImageHandle,\r
+ NULL); \r
+ }\r
+ if (mEfiShellParametersProtocol != NULL) {\r
+ gBS->CloseProtocol(ImageHandle,\r
+ &gEfiShellParametersProtocolGuid,\r
+ ImageHandle,\r
+ NULL); \r
+ }\r
+ return (EFI_SUCCESS);\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
+ShellGetFileInfo (\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
+ShellSetFileInfo (\r
+ IN EFI_FILE_HANDLE FileHandle,\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
+} \r
+ \r
+ /**\r
+ This function will open a file or directory referenced by DevicePath.\r
+\r
+ This function opens a file with the open mode according to the file path. The \r
+ Attributes is valid only for EFI_FILE_MODE_CREATE.\r
+\r
+ @param FilePath on input the device path to the file. On output \r
+ the remaining device path.\r
+ @param DeviceHandle pointer to the system device handle.\r
+ @param FileHandle pointer to the file handle.\r
+ @param OpenMode the mode to open the file with.\r
+ @param Attributes the file's file attributes.\r
+\r
+ @retval EFI_SUCCESS The information was set.\r
+ @retval EFI_INVALID_PARAMETER One of the parameters has an invalid value.\r
+ @retval EFI_UNSUPPORTED Could not open the file path. \r
+ @retval EFI_NOT_FOUND The specified file could not be found on the \r
+ device or the file system could not be found on \r
+ the device.\r
+ @retval EFI_NO_MEDIA The device has no medium.\r
+ @retval EFI_MEDIA_CHANGED The device has a different medium in it or the \r
+ medium is no longer supported.\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_OUT_OF_RESOURCES Not enough resources were available to open the \r
+ file.\r
+ @retval EFI_VOLUME_FULL The volume is full.\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+ShellOpenFileByDevicePath(\r
+ IN OUT EFI_DEVICE_PATH_PROTOCOL **FilePath,\r
+ OUT EFI_HANDLE *DeviceHandle,\r
+ OUT EFI_FILE_HANDLE *FileHandle,\r
+ IN UINT64 OpenMode,\r
+ IN UINT64 Attributes\r
+ )\r
+{\r
+ CHAR16 *FileName;\r
+ EFI_STATUS Status;\r
+ EFI_SIMPLE_FILE_SYSTEM_PROTOCOL *EfiSimpleFileSystemProtocol;\r
+ EFI_FILE_HANDLE LastHandle;\r
+\r
+ //\r
+ // ASERT for FileHandle, FilePath, and DeviceHandle being NULL\r
+ //\r
+ ASSERT(FilePath != NULL);\r
+ ASSERT(FileHandle != NULL);\r
+ ASSERT(DeviceHandle != NULL);\r
+ // \r
+ // which shell interface should we use\r
+ //\r
+ if (mEfiShellProtocol != NULL) {\r
+ //\r
+ // use UEFI Shell 2.0 method.\r
+ //\r
+ FileName = mEfiShellProtocol->GetFilePathFromDevicePath(*FilePath);\r
+ if (FileName == NULL) {\r
+ return (EFI_INVALID_PARAMETER);\r
+ }\r
+ Status = ShellOpenFileByName(FileName, FileHandle, OpenMode, Attributes);\r
+ FreePool(FileName);\r
+ return (Status);\r
+ } else {\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
+ // 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
+\r
+ //\r
+ // Try to test opening an existing file\r
+ //\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
+ // 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
+ }\r
+ return (EFI_SUCCESS);\r
+ }\r
+}\r
+\r
+/**\r
+ This function will open a file or directory referenced by filename.\r
+\r
+ If return is EFI_SUCCESS, the Filehandle is the opened file\92s handle; \r
+ otherwise, the Filehandle is NULL. The Attributes is valid only for \r
+ EFI_FILE_MODE_CREATE.\r
+\r
+ if FileNAme is NULL then ASSERT()\r
+\r
+ @param FileName pointer to file name\r
+ @param FileHandle pointer to the file handle.\r
+ @param OpenMode the mode to open the file with.\r
+ @param Attributes the file's file attributes.\r
+\r
+ @retval EFI_SUCCESS The information was set.\r
+ @retval EFI_INVALID_PARAMETER One of the parameters has an invalid value.\r
+ @retval EFI_UNSUPPORTED Could not open the file path. \r
+ @retval EFI_NOT_FOUND The specified file could not be found on the \r
+ device or the file system could not be found \r
+ on the device.\r
+ @retval EFI_NO_MEDIA The device has no medium.\r
+ @retval EFI_MEDIA_CHANGED The device has a different medium in it or the \r
+ medium is no longer supported.\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_OUT_OF_RESOURCES Not enough resources were available to open the \r
+ file.\r
+ @retval EFI_VOLUME_FULL The volume is full.\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+ShellOpenFileByName(\r
+ IN CHAR16 *FileName,\r
+ OUT EFI_FILE_HANDLE *FileHandle,\r
+ IN UINT64 OpenMode,\r
+ IN UINT64 Attributes\r
+ )\r
+{\r
+ EFI_HANDLE DeviceHandle;\r
+ EFI_DEVICE_PATH_PROTOCOL *FilePath;\r
+\r
+ //\r
+ // ASSERT if FileName is NULL\r
+ //\r
+ ASSERT(FileName != NULL);\r
+\r
+ if (mEfiShellProtocol != NULL) {\r
+ //\r
+ // Use UEFI Shell 2.0 method\r
+ //\r
+ return (mEfiShellProtocol->OpenFileByName(FileName,\r
+ FileHandle,\r
+ OpenMode));\r
+ } \r
+ //\r
+ // Using EFI Shell version\r
+ // this means convert name to path and call that function\r
+ // since this will use EFI method again that will open it.\r
+ //\r
+ ASSERT(mEfiShellEnvironment2 != NULL);\r
+ FilePath = mEfiShellEnvironment2->NameToPath (FileName);\r
+ if (FileDevicePath != NULL) {\r
+ return (ShellOpenFileByDevicePath(&FilePath,\r
+ &DeviceHandle,\r
+ FileHandle,\r
+ OpenMode,\r
+ Attributes ));\r
+ }\r
+ return (EFI_DEVICE_ERROR);\r
+}\r
+/**\r
+ This function create a directory\r
+\r
+ If return is EFI_SUCCESS, the Filehandle is the opened directory's handle; \r
+ otherwise, the Filehandle is NULL. If the directory already existed, this \r
+ function opens the existing directory.\r
+\r
+ @param DirectoryName pointer to directory name\r
+ @param FileHandle pointer to the file handle.\r
+\r
+ @retval EFI_SUCCESS The information was set.\r
+ @retval EFI_INVALID_PARAMETER One of the parameters has an invalid value.\r
+ @retval EFI_UNSUPPORTED Could not open the file path. \r
+ @retval EFI_NOT_FOUND The specified file could not be found on the \r
+ device or the file system could not be found \r
+ on the device.\r
+ @retval EFI_NO_MEDIA The device has no medium.\r
+ @retval EFI_MEDIA_CHANGED The device has a different medium in it or the \r
+ medium is no longer supported.\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_OUT_OF_RESOURCES Not enough resources were available to open the \r
+ file.\r
+ @retval EFI_VOLUME_FULL The volume is full.\r
+ @sa ShellOpenFileByName\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+ShellCreateDirectory(\r
+ IN CHAR16 *DirectoryName,\r
+ OUT EFI_FILE_HANDLE *FileHandle\r
+ )\r
+{\r
+ //\r
+ // this is a pass thru to the open file function with sepcific open mode and attributes\r
+ //\r
+ return (ShellOpenFileByName(DirectoryName,\r
+ FileHandle,\r
+ EFI_FILE_MODE_READ | EFI_FILE_MODE_WRITE | EFI_FILE_MODE_CREATE,\r
+ EFI_FILE_DIRECTORY\r
+ ));\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
+ShellReadFile(\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
+ShellWriteFile(\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
+ShellCloseFile (\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
+}\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
+ShellDeleteFile (\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
+}\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
+ShellSetFilePosition (\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
+ShellGetFilePosition (\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
+ShellFlushFile (\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
+}\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 ShellFindNextFile() 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 ShellGetFileInfo, ShellSetFilePosition,\r
+ or ShellReadFile\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+ShellFindFirstFile (\r
+ IN EFI_FILE_HANDLE DirHandle,\r
+ OUT EFI_FILE_INFO *Buffer\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
+ // 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 = 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
+}\r
+/**\r
+ Retrieves the next file in a directory.\r
+\r
+ To use this function, caller must call the LibFindFirstFile() 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 ShellFindNextFile() 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
+ShellFindNextFile(\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 = 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
+}\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
+ShellGetFileSize (\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 = 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
+}\r
+/**\r
+ Retrieves the status of the break execution flag\r
+\r
+ this function is useful to check whether the application is being asked to halt by the shell.\r
+\r
+ @retval TRUE the execution break is enabled\r
+ @retval FALSE the execution break is not enabled\r
+**/\r
+BOOLEAN\r
+EFIAPI\r
+ShellGetExecutionBreakFlag(\r
+ VOID\r
+ )\r
+{\r
+ // \r
+ // Check for UEFI Shell 2.0 protocols\r
+ //\r
+ if (mEfiShellProtocol != NULL) {\r
+\r
+ //\r
+ // We are using UEFI Shell 2.0; see if the event has been triggered\r
+ //\r
+ if (gBS->CheckEvent(mEfiShellProtocol->ExecutionBreak) != EFI_SUCCESS) {\r
+ return (FALSE);\r
+ }\r
+ return (TRUE);\r
+ } \r
+\r
+ //\r
+ // using EFI Shell; call the function to check\r
+ //\r
+ ASSERT(mEfiShellEnvironment2 != NULL);\r
+ return (mEfiShellEnvironment2->GetExecutionBreak());\r
+}\r
+/**\r
+ return the value of an environment variable\r
+\r
+ this function gets the value of the environment variable set by the \r
+ ShellSetEnvironmentVariable function\r
+\r
+ @param EnvKey The key name of the environment variable.\r
+\r
+ @retval NULL the named environment variable does not exist.\r
+ @return != NULL pointer to the value of the environment variable\r
+**/\r
+CONST CHAR16*\r
+EFIAPI\r
+ShellGetEnvironmentVariable (\r
+ IN CHAR16 *EnvKey\r
+ )\r
+{\r
+ // \r
+ // Check for UEFI Shell 2.0 protocols\r
+ //\r
+ if (mEfiShellProtocol != NULL) {\r
+ return (mEfiShellProtocol->GetEnv(EnvKey));\r
+ }\r
+\r
+ //\r
+ // ASSERT that we must have EFI shell\r
+ //\r
+ ASSERT(mEfiShellEnvironment2 != NULL);\r
+\r
+ //\r
+ // using EFI Shell\r
+ //\r
+ return (mEfiShellEnvironment2->GetEnv(EnvKey));\r
+}\r
+/**\r
+ set the value of an environment variable\r
+\r
+This function changes the current value of the specified environment variable. If the\r
+environment variable exists and the Value is an empty string, then the environment\r
+variable is deleted. If the environment variable exists and the Value is not an empty\r
+string, then the value of the environment variable is changed. If the environment\r
+variable does not exist and the Value is an empty string, there is no action. If the\r
+environment variable does not exist and the Value is a non-empty string, then the\r
+environment variable is created and assigned the specified value.\r
+\r
+ This is not supported pre-UEFI Shell 2.0.\r
+\r
+ @param EnvKey The key name of the environment variable.\r
+ @param EnvVal The Value of the environment variable\r
+ @param Volatile Indicates whether the variable is non-volatile (FALSE) or volatile (TRUE).\r
+\r
+ @retval EFI_SUCCESS the operation was completed sucessfully\r
+ @retval EFI_UNSUPPORTED This operation is not allowed in pre UEFI 2.0 Shell environments\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+ShellSetEnvironmentVariable (\r
+ IN CONST CHAR16 *EnvKey,\r
+ IN CONST CHAR16 *EnvVal,\r
+ IN BOOLEAN Volatile\r
+ )\r
+{\r
+ // \r
+ // Check for UEFI Shell 2.0 protocols\r
+ //\r
+ if (mEfiShellProtocol != NULL) {\r
+ return (mEfiShellProtocol->SetEnv(EnvKey, EnvVal, Volatile));\r
+ } \r
+\r
+ //\r
+ // This feature does not exist under EFI shell\r
+ //\r
+ return (EFI_UNSUPPORTED);\r
+}\r
+/**\r
+ cause the shell to parse and execute a command line.\r
+\r
+ This function creates a nested instance of the shell and executes the specified\r
+command (CommandLine) with the specified environment (Environment). Upon return,\r
+the status code returned by the specified command is placed in StatusCode.\r
+If Environment is NULL, then the current environment is used and all changes made\r
+by the commands executed will be reflected in the current environment. If the\r
+Environment is non-NULL, then the changes made will be discarded.\r
+The CommandLine is executed from the current working directory on the current\r
+device.\r
+\r
+EnvironmentVariables and Status are only supported for UEFI Shell 2.0.\r
+Output is only supported for pre-UEFI Shell 2.0\r
+\r
+ @param ImageHandle Parent image that is starting the operation\r
+ @param CommandLine pointer to null terminated command line.\r
+ @param Output true to display debug output. false to hide it.\r
+ @param EnvironmentVariables optional pointer to array of environment variables\r
+ in the form "x=y". if NULL current set is used.\r
+ @param Status the status of the run command line.\r
+\r
+ @retval EFI_SUCCESS the operation completed sucessfully. Status\r
+ contains the status code returned.\r
+ @retval EFI_INVALID_PARAMETER a parameter contains an invalid value\r
+ @retval EFI_OUT_OF_RESOURCES out of resources\r
+ @retval EFI_UNSUPPORTED the operation is not allowed.\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+ShellExecute (\r
+ IN EFI_HANDLE *ParentHandle,\r
+ IN CHAR16 *CommandLine OPTIONAL,\r
+ IN BOOLEAN Output OPTIONAL,\r
+ IN CHAR16 **EnvironmentVariables OPTIONAL,\r
+ OUT EFI_STATUS *Status OPTIONAL\r
+ )\r
+{\r
+ // \r
+ // Check for UEFI Shell 2.0 protocols\r
+ //\r
+ if (mEfiShellProtocol != NULL) {\r
+ //\r
+ // Call UEFI Shell 2.0 version (not using Output parameter)\r
+ //\r
+ return (mEfiShellProtocol->Execute(ParentHandle,\r
+ CommandLine,\r
+ EnvironmentVariables,\r
+ Status));\r
+ } \r
+ //\r
+ // ASSERT that we must have EFI shell\r
+ //\r
+ ASSERT(mEfiShellEnvironment2 != NULL);\r
+ //\r
+ // Call EFI Shell version (not using EnvironmentVariables or Status parameters)\r
+ // Due to oddity in the EFI shell we want to dereference the ParentHandle here\r
+ //\r
+ return (mEfiShellEnvironment2->Execute(*ParentHandle, \r
+ CommandLine, \r
+ Output));\r
+}\r
+/**\r
+ Retreives the current directory path\r
+\r
+ If the DeviceName is NULL, it returns the current device\92s current directory \r
+ name. If the DeviceName is not NULL, it returns the current directory name \r
+ on specified drive.\r
+\r
+ @param DeviceName the name of the drive to get directory on\r
+\r
+ @retval NULL the directory does not exist\r
+ @return != NULL the directory\r
+**/\r
+CONST CHAR16*\r
+EFIAPI\r
+ShellGetCurrentDir (\r
+ IN CHAR16 *DeviceName OPTIONAL\r
+ )\r
+{\r
+ // \r
+ // Check for UEFI Shell 2.0 protocols\r
+ //\r
+ if (mEfiShellProtocol != NULL) {\r
+ return (mEfiShellProtocol->GetCurDir(DeviceName));\r
+ } \r
+ //\r
+ // ASSERT that we must have EFI shell\r
+ //\r
+ ASSERT(mEfiShellEnvironment2 != NULL);\r
+ return (mEfiShellEnvironment2->CurDir(DeviceName));\r
+}\r
+/**\r
+ sets (enabled or disabled) the page break mode\r
+\r
+ when page break mode is enabled the screen will stop scrolling \r
+ and wait for operator input before scrolling a subsequent screen.\r
+\r
+ @param CurrentState TRUE to enable and FALSE to disable\r
+**/\r
+VOID \r
+EFIAPI\r
+ShellSetPageBreakMode (\r
+ IN BOOLEAN CurrentState\r
+ )\r
+{\r
+ //\r
+ // check for enabling\r
+ //\r
+ if (CurrentState != 0x00) {\r
+ // \r
+ // check for UEFI Shell 2.0\r
+ //\r
+ if (mEfiShellProtocol != NULL) {\r
+ //\r
+ // Enable with UEFI 2.0 Shell\r
+ //\r
+ mEfiShellProtocol->EnablePageBreak();\r
+ return;\r
+ } else {\r
+ // \r
+ // ASSERT that must have EFI Shell\r
+ //\r
+ ASSERT(mEfiShellEnvironment2 != NULL);\r
+ //\r
+ // Enable with EFI Shell\r
+ //\r
+ mEfiShellEnvironment2->EnablePageBreak (DEFAULT_INIT_ROW, DEFAULT_AUTO_LF);\r
+ return;\r
+ }\r
+ } else {\r
+ // \r
+ // check for UEFI Shell 2.0\r
+ //\r
+ if (mEfiShellProtocol != NULL) {\r
+ //\r
+ // Disable with UEFI 2.0 Shell\r
+ //\r
+ mEfiShellProtocol->DisablePageBreak();\r
+ return;\r
+ } else {\r
+ // \r
+ // ASSERT that must have EFI Shell\r
+ //\r
+ ASSERT(mEfiShellEnvironment2 != NULL);\r
+ //\r
+ // Disable with EFI Shell\r
+ //\r
+ mEfiShellEnvironment2->DisablePageBreak ();\r
+ return;\r
+ }\r
+ }\r
+}\r
+\r
+///\r
+/// version of EFI_SHELL_FILE_INFO struct, except has no CONST pointers.\r
+/// This allows for the struct to be populated.\r
+///\r
+typedef struct {\r
+ EFI_LIST_ENTRY Link;\r
+ EFI_STATUS Status;\r
+ CHAR16 *FullName;\r
+ CHAR16 *FileName;\r
+ EFI_FILE_HANDLE Handle;\r
+ EFI_FILE_INFO *Info;\r
+} EFI_SHELL_FILE_INFO_NO_CONST;\r
+\r
+/**\r
+ Converts a EFI shell list of structures to the coresponding UEFI Shell 2.0 type of list.\r
+\r
+ if OldStyleFileList is NULL then ASSERT()\r
+\r
+ this function will convert a SHELL_FILE_ARG based list into a callee allocated \r
+ EFI_SHELL_FILE_INFO based list. it is up to the caller to free the memory via\r
+ the ShellCloseFileMetaArg function.\r
+\r
+ @param FileList the EFI shell list type\r
+\r
+ @retval the resultant head of the double linked new format list;\r
+**/\r
+LIST_ENTRY*\r
+EFIAPI\r
+InternalShellConvertFileListType (\r
+ EFI_LIST_ENTRY *FileList\r
+ )\r
+{\r
+ LIST_ENTRY *ListHead;\r
+ SHELL_FILE_ARG *OldInfo;\r
+ EFI_LIST_ENTRY *Link;\r
+ EFI_SHELL_FILE_INFO_NO_CONST *NewInfo;\r
+\r
+ //\r
+ // ASSERT that FileList is not NULL\r
+ //\r
+ ASSERT(FileList != NULL);\r
+\r
+ //\r
+ // Allocate our list head and initialize the list\r
+ //\r
+ ListHead = AllocateZeroPool(sizeof(EFI_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
+ for (Link = FileList->Flink; Link != FileList; Link = Link->Flink) {\r
+ OldInfo = CR (Link, SHELL_FILE_ARG, Link, SHELL_FILE_ARG_SIGNATURE);\r
+\r
+ //\r
+ // make sure the old list was valid\r
+ //\r
+ ASSERT(OldInfo != NULL); \r
+ ASSERT(OldInfo->Info != NULL);\r
+ ASSERT(OldInfo->FullName != NULL);\r
+ ASSERT(OldInfo->FileName != NULL);\r
+\r
+ //\r
+ // allocate a new EFI_SHELL_FILE_INFO object\r
+ //\r
+ NewInfo = AllocateZeroPool(sizeof(EFI_SHELL_FILE_INFO));\r
+ \r
+ // \r
+ // copy the simple items\r
+ //\r
+ NewInfo->Handle = OldInfo->Handle;\r
+ NewInfo->Status = OldInfo->Status;\r
+\r
+ //\r
+ // allocate new space to copy strings and structure\r
+ //\r
+ NewInfo->FullName = AllocateZeroPool(StrSize(OldInfo->FullName));\r
+ NewInfo->FileName = AllocateZeroPool(StrSize(OldInfo->FileName));\r
+ NewInfo->Info = AllocateZeroPool((UINTN)OldInfo->Info->Size);\r
+ \r
+ //\r
+ // make sure all the memory allocations were sucessful\r
+ //\r
+ ASSERT(NewInfo->FullName != NULL);\r
+ ASSERT(NewInfo->FileName != NULL);\r
+ ASSERT(NewInfo->Info != NULL);\r
+\r
+ //\r
+ // Copt the strings and structure\r
+ //\r
+ StrCpy(NewInfo->FullName, OldInfo->FullName);\r
+ StrCpy(NewInfo->FileName, OldInfo->FileName);\r
+ gBS->CopyMem (NewInfo->Info, OldInfo->Info, (UINTN)OldInfo->Info->Size);\r
+\r
+ //\r
+ // add that to the list\r
+ //\r
+ InsertTailList(ListHead, (LIST_ENTRY*)NewInfo);\r
+ }\r
+ return (ListHead);\r
+}\r
+/**\r
+ Opens a group of files based on a path.\r
+\r
+ This function uses the Arg to open all the matching files. Each matched \r
+ file has a SHELL_FILE_ARG structure to record the file information. These \r
+ structures are placed on the list ListHead. Users can get the SHELL_FILE_ARG \r
+ structures from ListHead to access each file. This function supports wildcards\r
+ and will process '?' and '*' as such. the list must be freed with a call to \r
+ ShellCloseFileMetaArg().\r
+\r
+ This function will fail if called sequentially without freeing the list in the middle.\r
+\r
+ @param Arg pointer to path string\r
+ @param OpenMode mode to open files with\r
+ @param ListHead head of linked list of results\r
+\r
+ @retval EFI_SUCCESS the operation was sucessful and the list head \r
+ contains the list of opened files\r
+ #retval EFI_UNSUPPORTED a previous ShellOpenFileMetaArg must be closed first.\r
+ *ListHead is set to NULL.\r
+ @return != EFI_SUCCESS the operation failed\r
+\r
+ @sa InternalShellConvertFileListType\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+ShellOpenFileMetaArg (\r
+ IN CHAR16 *Arg,\r
+ IN UINT64 OpenMode,\r
+ IN OUT EFI_SHELL_FILE_INFO **ListHead\r
+ )\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
+ //\r
+ // ASSERT that Arg and ListHead are not NULL\r
+ //\r
+ ASSERT(Arg != NULL);\r
+ ASSERT(ListHead != NULL);\r
+\r
+ // \r
+ // Check for UEFI Shell 2.0 protocols\r
+ //\r
+ if (mEfiShellProtocol != NULL) {\r
+ return (mEfiShellProtocol->OpenFileList(Arg, \r
+ OpenMode, \r
+ ListHead));\r
+ } \r
+\r
+ //\r
+ // ASSERT that we must have EFI shell\r
+ //\r
+ ASSERT(mEfiShellEnvironment2 != NULL);\r
+\r
+ //\r
+ // allocate memory for old list head\r
+ //\r
+ mOldStyleFileList = (EFI_LIST_ENTRY*)AllocatePool(sizeof(EFI_LIST_ENTRY));\r
+ ASSERT(mOldStyleFileList != NULL);\r
+\r
+ //\r
+ // make sure the list head is initialized\r
+ //\r
+ InitializeListHead((LIST_ENTRY*)mOldStyleFileList);\r
+\r
+ //\r
+ // Get the EFI Shell list of files\r
+ //\r
+ Status = mEfiShellEnvironment2->FileMetaArg(Arg, mOldStyleFileList);\r
+ if (EFI_ERROR(Status)) {\r
+ *ListHead = NULL;\r
+ return (Status);\r
+ }\r
+\r
+ //\r
+ // Convert that to equivalent of UEFI Shell 2.0 structure\r
+ //\r
+ EmptyNode = InternalShellConvertFileListType(mOldStyleFileList);\r
+\r
+ //\r
+ // remove the empty head of the list\r
+ //\r
+ *ListHead = (EFI_SHELL_FILE_INFO*)RemoveEntryList(EmptyNode);\r
+ FreePool(EmptyNode); \r
+\r
+ return (Status);\r
+}\r
+/**\r
+ Free the linked list returned from ShellOpenFileMetaArg\r
+\r
+ if ListHead is NULL then ASSERT()\r
+\r
+ @param ListHead the pointer to free\r
+\r
+ @retval EFI_SUCCESS the operation was sucessful\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+ShellCloseFileMetaArg (\r
+ IN OUT EFI_SHELL_FILE_INFO **ListHead\r
+ )\r
+{\r
+ LIST_ENTRY *Node;\r
+\r
+ //\r
+ // ASSERT that ListHead is not NULL\r
+ //\r
+ ASSERT(ListHead != NULL);\r
+\r
+ // \r
+ // Check for UEFI Shell 2.0 protocols\r
+ //\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
+ 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);\r
+ }\r
+ return EFI_SUCCESS;\r
+ }\r
+}\r
+\r
+typedef struct {\r
+ EFI_LIST_ENTRY List;\r
+ CHAR16 *Name;\r
+ ParamType Type;\r
+ CHAR16 *Value;\r
+ UINTN OriginalPosition;\r
+} SHELL_PARAM_PACKAGE;\r
+\r
+/**\r
+ Checks the list of valid arguments and returns TRUE if the item was found. If the \r
+ return value is TRUE then the type parameter is set also.\r
+ \r
+ if CheckList is NULL then ASSERT();\r
+ if Name is NULL then ASSERT();\r
+ if Type is NULL then ASSERT();\r
+\r
+ @param Type pointer to type of parameter if it was found\r
+ @param Name pointer to Name of parameter found\r
+ @param CheckList List to check against\r
+\r
+ @retval TRUE the Parameter was found. Type is valid.\r
+ @retval FALSE the Parameter was not found. Type is not valid.\r
+**/\r
+BOOLEAN\r
+EFIAPI\r
+IsCheckList (\r
+ IN CONST CHAR16 *Name,\r
+ IN CONST SHELL_PARAM_ITEM *CheckList,\r
+ OUT ParamType *Type\r
+ )\r
+{\r
+ SHELL_PARAM_ITEM *TempListItem;\r
+\r
+ //\r
+ // ASSERT that all 3 pointer parameters aren't NULL\r
+ //\r
+ ASSERT(CheckList != NULL);\r
+ ASSERT(Type != NULL);\r
+ ASSERT(Name != NULL);\r
+\r
+ //\r
+ // Enumerate through the list\r
+ //\r
+ for (TempListItem = (SHELL_PARAM_ITEM*)CheckList ; TempListItem->Name != NULL ; TempListItem++) {\r
+ //\r
+ // If the Name matches set the type and return TRUE\r
+ //\r
+ if (StrCmp(Name, TempListItem->Name) == 0) {\r
+ *Type = TempListItem->Type;\r
+ return (TRUE);\r
+ }\r
+ }\r
+ return (FALSE);\r
+}\r
+/**\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
+ @retval TRUE the Parameter is a flag.\r
+ @retval FALSE the Parameter not a flag\r
+**/\r
+BOOLEAN\r
+EFIAPI\r
+IsFlag (\r
+ IN CONST CHAR16 *Name\r
+ )\r
+{\r
+ //\r
+ // ASSERT that Name isn't NULL\r
+ //\r
+ ASSERT(Name != NULL);\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
+ return (TRUE);\r
+ }\r
+ return (FALSE);\r
+}\r
+\r
+/**\r
+ Checks the command line arguments passed against the list of valid ones. \r
+\r
+ If no initialization is required, then return RETURN_SUCCESS.\r
+ \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
+ @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
+\r
+ @retval EFI_SUCCESS The operation completed sucessfully.\r
+ @retval EFI_OUT_OF_RESOURCES A memory allocation failed\r
+ @retval EFI_INVALID_PARAMETER A parameter was invalid\r
+ @retval EFI_VOLUME_CORRUPTED the command line was corrupt. an argument was \r
+ duplicated. the duplicated command line argument \r
+ was returned in ProblemParam if provided.\r
+ @retval EFI_NOT_FOUND a argument required a value that was missing. \r
+ the invalid command line argument was returned in\r
+ ProblemParam if provided.\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+InternalCommandLineParse (\r
+ IN CONST SHELL_PARAM_ITEM *CheckList,\r
+ OUT LIST_ENTRY **CheckPackage,\r
+ OUT CHAR16 **ProblemParam OPTIONAL,\r
+ IN BOOLEAN AutoPageBreak,\r
+ IN CONST CHAR16 **Argv,\r
+ IN UINTN Argc\r
+ )\r
+{\r
+ UINTN LoopCounter;\r
+ UINTN Count;\r
+ ParamType CurrentItemType;\r
+ SHELL_PARAM_PACKAGE *CurrentItemPackage;\r
+ BOOLEAN GetItemValue;\r
+\r
+ CurrentItemPackage = NULL;\r
+\r
+ //\r
+ // ASSERTs\r
+ //\r
+ ASSERT(CheckList != NULL);\r
+ ASSERT(Argv != NULL);\r
+\r
+ Count = 0;\r
+ GetItemValue = FALSE;\r
+\r
+ //\r
+ // If there is only 1 item we dont need to do anything\r
+ //\r
+ if (Argc <= 1) {\r
+ *CheckPackage = NULL;\r
+ return (EFI_SUCCESS);\r
+ }\r
+\r
+ //\r
+ // initialize the linked list\r
+ //\r
+ *CheckPackage = (LIST_ENTRY*)AllocateZeroPool(sizeof(LIST_ENTRY));\r
+ InitializeListHead(*CheckPackage);\r
+\r
+ //\r
+ // loop through each of the arguments\r
+ //\r
+ for (LoopCounter = 0 ; LoopCounter < Argc ; ++LoopCounter) {\r
+ if (Argv[LoopCounter] == NULL) {\r
+ //\r
+ // do nothing for NULL argv\r
+ //\r
+ } else if (GetItemValue == TRUE) {\r
+ ASSERT(CurrentItemPackage != NULL);\r
+ //\r
+ // get the item VALUE for the previous flag\r
+ //\r
+ GetItemValue = FALSE;\r
+ CurrentItemPackage->Value = AllocateZeroPool(StrSize(Argv[LoopCounter]));\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
+ //\r
+ // add this one as a non-flag\r
+ //\r
+ CurrentItemPackage = AllocatePool(sizeof(SHELL_PARAM_PACKAGE));\r
+ ASSERT(CurrentItemPackage != NULL);\r
+ CurrentItemPackage->Name = NULL;\r
+ CurrentItemPackage->Type = TypePosition;\r
+ CurrentItemPackage->Value = AllocatePool(StrSize(Argv[LoopCounter]));\r
+ ASSERT(CurrentItemPackage->Value != NULL);\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
+ //\r
+ // this is a flag\r
+ //\r
+ CurrentItemPackage = AllocatePool(sizeof(SHELL_PARAM_PACKAGE));\r
+ ASSERT(CurrentItemPackage != NULL);\r
+ CurrentItemPackage->Name = AllocatePool(StrSize(Argv[LoopCounter]));\r
+ ASSERT(CurrentItemPackage->Name != NULL);\r
+ StrCpy(CurrentItemPackage->Name, Argv[LoopCounter]);\r
+ CurrentItemPackage->Type = CurrentItemType;\r
+ CurrentItemPackage->OriginalPosition = (UINTN)(-1);\r
+\r
+ //\r
+ // Does this flag require a value\r
+ //\r
+ if (CurrentItemPackage->Type == TypeValue) {\r
+ //\r
+ // trigger the next loop to populate the value of this item\r
+ //\r
+ GetItemValue = TRUE; \r
+ } else {\r
+ //\r
+ // this item has no value expected; we are done\r
+ //\r
+ CurrentItemPackage->Value = NULL;\r
+ InsertTailList(*CheckPackage, (LIST_ENTRY*)CurrentItemPackage);\r
+ }\r
+ } else if (ProblemParam) {\r
+ //\r
+ // this was a non-recognised flag... error!\r
+ //\r
+ *ProblemParam = (CHAR16*)Argv[LoopCounter];\r
+ ShellCommandLineFreeVarList(*CheckPackage);\r
+ *CheckPackage = NULL;\r
+ return (EFI_VOLUME_CORRUPTED);\r
+ } else {\r
+ ShellCommandLineFreeVarList(*CheckPackage);\r
+ *CheckPackage = NULL;\r
+ return (EFI_VOLUME_CORRUPTED);\r
+ }\r
+ }\r
+ //\r
+ // support for AutoPageBreak\r
+ //\r
+ if (AutoPageBreak && ShellCommandLineGetFlag(*CheckPackage, L"-b")) {\r
+ ShellSetPageBreakMode(TRUE);\r
+ }\r
+ return (EFI_SUCCESS);\r
+}\r
+\r
+/**\r
+ Checks the command line arguments passed against the list of valid ones. \r
+ Optionally removes NULL values first.\r
+ \r
+ If no initialization is required, then return RETURN_SUCCESS.\r
+ \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
+ @param AutoPageBreak will automatically set PageBreakEnabled for "b" parameter\r
+\r
+ @retval EFI_SUCCESS The operation completed sucessfully.\r
+ @retval EFI_OUT_OF_RESOURCES A memory allocation failed\r
+ @retval EFI_INVALID_PARAMETER A parameter was invalid\r
+ @retval EFI_VOLUME_CORRUPTED the command line was corrupt. an argument was \r
+ duplicated. the duplicated command line argument \r
+ was returned in ProblemParam if provided.\r
+ @retval EFI_DEVICE_ERROR the commands contained 2 opposing arguments. one\r
+ of the command line arguments was returned in \r
+ ProblemParam if provided.\r
+ @retval EFI_NOT_FOUND a argument required a value that was missing. \r
+ the invalid command line argument was returned in\r
+ ProblemParam if provided.\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+ShellCommandLineParse (\r
+ IN CONST SHELL_PARAM_ITEM *CheckList,\r
+ OUT LIST_ENTRY **CheckPackage,\r
+ OUT CHAR16 **ProblemParam OPTIONAL,\r
+ IN BOOLEAN AutoPageBreak\r
+ )\r
+{\r
+ // \r
+ // ASSERT that CheckList and CheckPackage aren't NULL\r
+ //\r
+ ASSERT(CheckList != NULL);\r
+ ASSERT(CheckPackage != NULL);\r
+\r
+ // \r
+ // Check for UEFI Shell 2.0 protocols\r
+ //\r
+ if (mEfiShellParametersProtocol != NULL) {\r
+ return (InternalCommandLineParse(CheckList, \r
+ CheckPackage, \r
+ ProblemParam, \r
+ AutoPageBreak, \r
+ mEfiShellParametersProtocol->Argv,\r
+ mEfiShellParametersProtocol->Argc ));\r
+ }\r
+\r
+ // \r
+ // ASSERT That EFI Shell is not required\r
+ //\r
+ ASSERT (mEfiShellInterface != NULL);\r
+ return (InternalCommandLineParse(CheckList, \r
+ CheckPackage, \r
+ ProblemParam, \r
+ AutoPageBreak, \r
+ mEfiShellInterface->Argv,\r
+ mEfiShellInterface->Argc ));\r
+}\r
+\r
+/**\r
+ Frees shell variable list that was returned from ShellCommandLineParse.\r
+\r
+ This function will free all the memory that was used for the CheckPackage\r
+ list of postprocessed shell arguments.\r
+\r
+ this function has no return value.\r
+\r
+ if CheckPackage is NULL, then return\r
+\r
+ @param CheckPackage the list to de-allocate\r
+ **/\r
+VOID\r
+EFIAPI\r
+ShellCommandLineFreeVarList (\r
+ IN LIST_ENTRY *CheckPackage\r
+ )\r
+{\r
+ LIST_ENTRY *Node;\r
+\r
+ //\r
+ // check for CheckPackage == NULL\r
+ //\r
+ if (CheckPackage == NULL) {\r
+ return;\r
+ }\r
+\r
+ //\r
+ // for each node in the list\r
+ //\r
+ for (Node = GetFirstNode(CheckPackage); Node != CheckPackage ; Node = GetFirstNode(CheckPackage)) {\r
+ //\r
+ // Remove it from the list\r
+ //\r
+ RemoveEntryList(Node);\r
+\r
+ //\r
+ // if it has a name free the name\r
+ //\r
+ if (((SHELL_PARAM_PACKAGE*)Node)->Name != NULL) {\r
+ FreePool(((SHELL_PARAM_PACKAGE*)Node)->Name);\r
+ }\r
+\r
+ //\r
+ // if it has a value free the value\r
+ //\r
+ if (((SHELL_PARAM_PACKAGE*)Node)->Value != NULL) {\r
+ FreePool(((SHELL_PARAM_PACKAGE*)Node)->Value);\r
+ }\r
+ \r
+ //\r
+ // free the node structure\r
+ //\r
+ FreePool((SHELL_PARAM_PACKAGE*)Node);\r
+ }\r
+ //\r
+ // free the list head node\r
+ //\r
+ FreePool(CheckPackage);\r
+}\r
+/**\r
+ Checks for presence of a flag parameter\r
+\r
+ flag arguments are in the form of "-<Key>" or "/<Key>", but do not have a value following the key\r
+\r
+ if CheckPackage is NULL then return FALSE.\r
+ if KeyString is NULL then ASSERT()\r
+ \r
+ @param CheckPackage The package of parsed command line arguments\r
+ @param KeyString the Key of the command line argument to check for\r
+\r
+ @retval TRUE the flag is on the command line\r
+ @retval FALSE the flag is not on the command line\r
+ **/\r
+BOOLEAN\r
+EFIAPI\r
+ShellCommandLineGetFlag (\r
+ IN CONST LIST_ENTRY *CheckPackage,\r
+ IN CHAR16 *KeyString\r
+ )\r
+{\r
+ LIST_ENTRY *Node;\r
+\r
+ //\r
+ // ASSERT that both CheckPackage and KeyString aren't NULL\r
+ //\r
+ ASSERT(KeyString != NULL);\r
+\r
+ //\r
+ // return FALSE for no package\r
+ //\r
+ if (CheckPackage == NULL) {\r
+ return (FALSE);\r
+ }\r
+\r
+ //\r
+ // enumerate through the list of parametrs\r
+ //\r
+ for (Node = GetFirstNode(CheckPackage) ; Node != CheckPackage ; Node = GetNextNode(CheckPackage, Node) ) {\r
+ //\r
+ // If the Name matches, return TRUE (and there may be NULL name)\r
+ //\r
+ if (((SHELL_PARAM_PACKAGE*)Node)->Name != NULL) {\r
+ if (StrCmp(KeyString, ((SHELL_PARAM_PACKAGE*)Node)->Name) == 0) {\r
+ return (TRUE);\r
+ }\r
+ }\r
+ }\r
+ return (FALSE);\r
+}\r
+/**\r
+ returns value from command line argument\r
+\r
+ value parameters are in the form of "-<Key> value" or "/<Key> value"\r
+ \r
+ if CheckPackage is NULL, then return NULL;\r
+\r
+ @param CheckPackage The package of parsed command line arguments\r
+ @param KeyString the Key of the command line argument to check for\r
+\r
+ @retval NULL the flag is not on the command line\r
+ @return !=NULL pointer to unicode string of the value\r
+ **/\r
+CONST CHAR16*\r
+EFIAPI\r
+ShellCommandLineGetValue (\r
+ IN CONST LIST_ENTRY *CheckPackage,\r
+ IN CHAR16 *KeyString\r
+ )\r
+{\r
+ LIST_ENTRY *Node;\r
+\r
+ //\r
+ // check for CheckPackage == NULL\r
+ //\r
+ if (CheckPackage == NULL) {\r
+ return (NULL);\r
+ }\r
+\r
+ //\r
+ // enumerate through the list of parametrs\r
+ //\r
+ for (Node = GetFirstNode(CheckPackage) ; Node != NULL ; Node = GetNextNode(CheckPackage, Node) ) {\r
+ //\r
+ // If the Name matches, return the value (name can be NULL)\r
+ //\r
+ if (((SHELL_PARAM_PACKAGE*)Node)->Name != NULL) {\r
+ if (StrCmp(KeyString, ((SHELL_PARAM_PACKAGE*)Node)->Name) == 0) {\r
+ return (((SHELL_PARAM_PACKAGE*)Node)->Value);\r
+ }\r
+ }\r
+ }\r
+ return (NULL);\r
+}\r
+/**\r
+ returns raw value from command line argument\r
+\r
+ raw value parameters are in the form of "value" in a specific position in the list\r
+ \r
+ if CheckPackage is NULL, then return NULL;\r
+\r
+ @param CheckPackage The package of parsed command line arguments\r
+ @param Position the position of the value \r
+\r
+ @retval NULL the flag is not on the command line\r
+ @return !=NULL pointer to unicode string of the value\r
+ **/\r
+CONST CHAR16*\r
+EFIAPI\r
+ShellCommandLineGetRawValue (\r
+ IN CONST LIST_ENTRY *CheckPackage,\r
+ IN UINT32 Position\r
+ )\r
+{\r
+ LIST_ENTRY *Node;\r
+\r
+ //\r
+ // check for CheckPackage == NULL\r
+ //\r
+ if (CheckPackage == NULL) {\r
+ return (NULL);\r
+ }\r
+\r
+ //\r
+ // enumerate through the list of parametrs\r
+ //\r
+ for (Node = GetFirstNode(CheckPackage) ; Node != NULL ; Node = GetNextNode(CheckPackage, Node) ) {\r
+ //\r
+ // If the position matches, return the value\r
+ //\r
+ if (((SHELL_PARAM_PACKAGE*)Node)->OriginalPosition == Position) {\r
+ return (((SHELL_PARAM_PACKAGE*)Node)->Value);\r
+ }\r
+ }\r
+ return (NULL);\r
+}
\ No newline at end of file
--- /dev/null
+#/** @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 = BaseShellLib\r
+ FILE_GUID = 449D0F00-2148-4a43-9836-F10B3980ECF5\r
+ MODULE_TYPE = UEFI_DRIVER\r
+ VERSION_STRING = 1.0\r
+ LIBRARY_CLASS = ShellLib|UEFI_APPLICATION UEFI_DRIVER\r
+ CONSTRUCTOR = ShellLibConstructor\r
+ DESTRUCTOR = ShellLibDestructor\r
+\r
+#\r
+# VALID_ARCHITECTURES = IA32 X64 IPF EBC\r
+#\r
+\r
+[Sources.common]\r
+ BaseShellLib.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
+ gEfiSimpleFileSystemProtocolGuid # ALWAYS_CONSUMED\r
+ \r
+ # shell 2.0 \r
+ gEfiShellProtocolGuid # SOMETIMES_CONSUMED\r
+ gEfiShellParametersProtocolGuid # SOMETIMES_CONSUMED\r
+\r
+ # 'old' shell\r
+ gEfiShellEnvironment2Guid # SOMETIMES_CONSUMED\r
+ gEfiShellInterfaceGuid # SOMETIMES_CONSUMED\r
+\r
+[Guids]\r
+ gEfiFileInfoGuid # ALWAYS_CONSUMED\r
+ gEfiShellEnvironment2ExtGuid # ALWAYS_CONSUMED\r
+\r
+[Pcd.common]\r
+\r
--- /dev/null
+## @file ShellPkg.dec\r
+#\r
+# This Package provides all definitions for EFI and UEFI Shell\r
+#\r
+# Copyright (c) 2009, Intel Corporation.\r
+#\r
+# All rights reserved.\r
+# This program and the accompanying materials are licensed and made available under\r
+# the terms and conditions of the BSD License which accompanies this distribution.\r
+# 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
+\r
+[Defines]\r
+ DEC_SPECIFICATION = 0x00010005\r
+ PACKAGE_NAME = ShellPkg\r
+ PACKAGE_GUID = 9FB7587C-93F7-40a7-9C04-FD7BA94EE646\r
+ PACKAGE_VERSION = 0.1\r
+\r
+\r
+[Includes.common]\r
+ Include\r
+\r
+[LibraryClasses.common]\r
+ ## @libraryclass Provides most Shell APIs.\r
+ # Only available for Shell applications\r
+ ##\r
+ ShellLib|Include/Library/ShellLib.h\r
+\r
+[Guids.common]\r
+ gEfiShellEnvironment2ExtGuid = {0xd2c18636, 0x40e5, 0x4eb5, {0xa3, 0x1b, 0x36, 0x69, 0x5f, 0xd4, 0x2c, 0x87}}\r
+\r
+[Protocols.common]\r
+ gEfiShellProtocolGuid = {0x6302d008, 0x7f9b, 0x4f30, {0x87, 0xac, 0x60, 0xc9, 0xfe, 0xf5, 0xda, 0x4e}}\r
+ gEfiShellParametersProtocolGuid = {0x752f3136, 0x4e16, 0x4fdc, {0xa2, 0x2a, 0xe5, 0xf4, 0x68, 0x12, 0xf4, 0xca}}\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
--- /dev/null
+#/** @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
+# 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
+[Defines]\r
+ PLATFORM_NAME = Shell\r
+ PLATFORM_GUID = E1DC9BF8-7013-4c99-9437-795DAA45F3BD\r
+ PLATFORM_VERSION = 0.1\r
+ DSC_SPECIFICATION = 0x00010005\r
+ OUTPUT_DIRECTORY = Build/Shell\r
+ SUPPORTED_ARCHITECTURES = IA32|IPF|X64|EBC\r
+ BUILD_TARGETS = DEBUG|RELEASE\r
+ SKUID_IDENTIFIER = DEFAULT\r
+\r
+[LibraryClasses.common]\r
+ UefiApplicationEntryPoint|MdePkg/Library/UefiApplicationEntryPoint/UefiApplicationEntryPoint.inf\r
+ UefiBootServicesTableLib|MdePkg/Library/UefiBootServicesTableLib/UefiBootServicesTableLib.inf\r
+ DevicePathLib|MdePkg/Library/UefiDevicePathLib/UefiDevicePathLib.inf\r
+ DebugLib|MdePkg/Library/BaseDebugLibNull/BaseDebugLibNull.inf\r
+ PcdLib|MdePkg/Library/BasePcdLibNull/BasePcdLibNull.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
+ PrintLib|MdeModulePkg/Library/DxePrintLibPrint2Protocol/DxePrintLibPrint2Protocol.inf\r
+ UefiRuntimeServicesTableLib|MdePkg/Library/UefiRuntimeServicesTableLib/UefiRuntimeServicesTableLib.inf\r
+ ShellLib|ShellPkg/Library/BaseShellLib/BaseShellLib.inf\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