TianoCore EDK2 master
Loading...
Searching...
No Matches
FileExplorer.c File Reference
#include "FileExplorer.h"

Go to the source code of this file.

Functions

EFI_STATUS LibCreateNewFile (IN CHAR16 *FileName, IN BOOLEAN CreateFile)
 
EFI_STATUS EFIAPI LibExtractConfig (IN CONST EFI_HII_CONFIG_ACCESS_PROTOCOL *This, IN CONST EFI_STRING Request, OUT EFI_STRING *Progress, OUT EFI_STRING *Results)
 
EFI_STATUS EFIAPI LibRouteConfig (IN CONST EFI_HII_CONFIG_ACCESS_PROTOCOL *This, IN CONST EFI_STRING Configuration, OUT EFI_STRING *Progress)
 
EFI_STATUS EFIAPI LibCallback (IN CONST EFI_HII_CONFIG_ACCESS_PROTOCOL *This, IN EFI_BROWSER_ACTION Action, IN EFI_QUESTION_ID QuestionId, IN UINT8 Type, IN EFI_IFR_TYPE_VALUE *Value, OUT EFI_BROWSER_ACTION_REQUEST *ActionRequest)
 
MENU_ENTRYLibCreateMenuEntry (VOID)
 
MENU_ENTRYLibGetMenuEntry (MENU_OPTION *MenuOption, UINTN MenuNumber)
 
VOID LibDestroyMenuEntry (MENU_ENTRY *MenuEntry)
 
VOID LibFreeMenu (MENU_OPTION *FreeMenu)
 
EFI_FILE_HANDLE LibOpenRoot (IN EFI_HANDLE DeviceHandle)
 
CHAR16 * LibDevicePathToStr (IN EFI_DEVICE_PATH_PROTOCOL *DevPath)
 
CHAR16 * LibStrDuplicate (IN CHAR16 *Src)
 
VOID * LibFileInfo (IN EFI_FILE_HANDLE FHand, IN EFI_GUID *InfoType)
 
CHAR16 * LibGetTypeFromName (IN CHAR16 *FileName)
 
VOID LibToLowerString (IN CHAR16 *String)
 
BOOLEAN LibIsSupportedFileType (IN UINT16 *FileName)
 
CHAR16 * LibAppendFileName (IN CHAR16 *Str1, IN CHAR16 *Str2)
 
EFI_STATUS LibFindFileSystem (VOID)
 
EFI_STATUS LibGetFileHandleFromMenu (IN MENU_ENTRY *MenuEntry, OUT EFI_FILE_HANDLE *RetFileHandle)
 
EFI_STATUS LibGetFileHandleFromDevicePath (IN EFI_DEVICE_PATH_PROTOCOL *RootDirectory, OUT EFI_FILE_HANDLE *RetFileHandle, OUT UINT16 **ParentFileName, OUT EFI_HANDLE *DeviceHandle)
 
EFI_STATUS LibFindFiles (IN EFI_FILE_HANDLE FileHandle, IN UINT16 *FileName, IN EFI_HANDLE DeviceHandle)
 
VOID LibRefreshUpdateData (VOID)
 
VOID LibUpdateFileExplorePage (VOID)
 
EFI_STATUS LibUpdateFileExplorer (IN UINT16 KeyValue)
 
VOID LibGetDevicePath (IN UINT16 KeyValue)
 
EFI_STATUS EFIAPI ChooseFile (IN EFI_DEVICE_PATH_PROTOCOL *RootDirectory, IN CHAR16 *FileType OPTIONAL, IN CHOOSE_HANDLER ChooseHandler OPTIONAL, OUT EFI_DEVICE_PATH_PROTOCOL **File OPTIONAL)
 
EFI_STATUS EFIAPI FileExplorerLibConstructor (IN EFI_HANDLE ImageHandle, IN EFI_SYSTEM_TABLE *SystemTable)
 
EFI_STATUS EFIAPI FileExplorerLibDestructor (IN EFI_HANDLE ImageHandle, IN EFI_SYSTEM_TABLE *SystemTable)
 

Variables

EFI_GUID FileExplorerGuid = EFI_FILE_EXPLORE_FORMSET_GUID
 
MENU_OPTION mFsOptionMenu
 
FILE_EXPLORER_CALLBACK_DATA gFileExplorerPrivate
 
HII_VENDOR_DEVICE_PATHgHiiVendorDevicePath
 
HII_VENDOR_DEVICE_PATH FeHiiVendorDevicePath
 
VOID * mLibStartOpCodeHandle = NULL
 
VOID * mLibEndOpCodeHandle = NULL
 
EFI_IFR_GUID_LABELmLibStartLabel = NULL
 
EFI_IFR_GUID_LABELmLibEndLabel = NULL
 
UINT16 mQuestionIdUpdate
 
CHAR16 mNewFileName [MAX_FILE_NAME_LEN]
 
CHAR16 mNewFolderName [MAX_FOLDER_NAME_LEN]
 
UINTN mNewFileQuestionId = NEW_FILE_QUESTION_ID_BASE
 
UINTN mNewFolderQuestionId = NEW_FOLDER_QUESTION_ID_BASE
 

Detailed Description

File explorer related functions.

Copyright (c) 2004 - 2019, Intel Corporation. All rights reserved.
SPDX-License-Identifier: BSD-2-Clause-Patent

Definition in file FileExplorer.c.

Function Documentation

◆ ChooseFile()

EFI_STATUS EFIAPI ChooseFile ( IN EFI_DEVICE_PATH_PROTOCOL RootDirectory,
IN CHAR16 *FileType  OPTIONAL,
IN CHOOSE_HANDLER ChooseHandler  OPTIONAL,
OUT EFI_DEVICE_PATH_PROTOCOL **File  OPTIONAL 
)

Choose a file in the specified directory.

If user input NULL for the RootDirectory, will choose file in the system.

If user input *File != NULL, function will return the allocate device path info for the choosed file, caller has to free the memory after use it.

Parameters
RootDirectoryPointer to the root directory.
FileTypeThe file type need to choose.
ChooseHandlerFunction pointer to the extra task need to do after choose one file.
FileReturn the device path for the last time chosed file.
Return values
EFI_SUCESSChoose file success.
EFI_INVALID_PARAMETERBoth ChooseHandler and return device path are NULL One of them must not NULL.
Othererrors Choose file failed.

Definition at line 1488 of file FileExplorer.c.

◆ FileExplorerLibConstructor()

EFI_STATUS EFIAPI FileExplorerLibConstructor ( IN EFI_HANDLE  ImageHandle,
IN EFI_SYSTEM_TABLE SystemTable 
)

Install Boot Manager Menu driver.

Parameters
ImageHandleThe image handle.
SystemTableThe system table.
Return values
EFI_SUCEESSInstall File explorer library success.

Definition at line 1576 of file FileExplorer.c.

◆ FileExplorerLibDestructor()

EFI_STATUS EFIAPI FileExplorerLibDestructor ( IN EFI_HANDLE  ImageHandle,
IN EFI_SYSTEM_TABLE SystemTable 
)

Unloads the application and its installed protocol.

Parameters
[in]ImageHandleHandle that identifies the image to be unloaded.
[in]SystemTableThe system table.
Return values
EFI_SUCCESSThe image has been unloaded.

Definition at line 1639 of file FileExplorer.c.

◆ LibAppendFileName()

CHAR16 * LibAppendFileName ( IN CHAR16 *  Str1,
IN CHAR16 *  Str2 
)

Append file name to existing file name.

Parameters
Str1The existing file name
Str2The file name to be appended
Returns
Allocate a new string to hold the appended result. Caller is responsible to free the returned string.

Definition at line 676 of file FileExplorer.c.

◆ LibCallback()

EFI_STATUS EFIAPI LibCallback ( IN CONST EFI_HII_CONFIG_ACCESS_PROTOCOL This,
IN EFI_BROWSER_ACTION  Action,
IN EFI_QUESTION_ID  QuestionId,
IN UINT8  Type,
IN EFI_IFR_TYPE_VALUE Value,
OUT EFI_BROWSER_ACTION_REQUEST *  ActionRequest 
)

This function processes the results of changes in configuration. When user select a interactive opcode, this callback will be triggered. Based on the Question(QuestionId) that triggers the callback, the corresponding actions is performed. It handles:

1) Process the axtra action or exit file explorer when user select one file . 2) update of file content if a dir is selected.

Parameters
ThisPoints to the EFI_HII_CONFIG_ACCESS_PROTOCOL.
ActionSpecifies the type of action taken by the browser.
QuestionIdA unique value which is sent to the original exporting driver so that it can identify the type of data to expect.
TypeThe type of value for the question.
ValueA pointer to the data being sent to the original exporting driver.
ActionRequestOn return, points to the action requested by the callback function.
Return values
EFI_SUCCESSThe callback successfully handled the action.
othererror Error occur when parse one directory.

Definition at line 179 of file FileExplorer.c.

◆ LibCreateMenuEntry()

MENU_ENTRY * LibCreateMenuEntry ( VOID  )

Create a menu entry by given menu type.

Return values
NULLIf failed to create the menu.
Returns
the new menu entry.

Definition at line 296 of file FileExplorer.c.

◆ LibCreateNewFile()

EFI_STATUS LibCreateNewFile ( IN CHAR16 *  FileName,
IN BOOLEAN  CreateFile 
)

Create a new file or folder in current directory.

Parameters
FileNamePoint to the fileNmae or folder.
CreateFileCreateFile== TRUE means create a new file. CreateFile== FALSE means create a new Folder.

Create a new file or folder in current directory.

Parameters
FileNamePoint to the fileNmae or folder name.
CreateFileCreateFile== TRUE means create a new file. CreateFile== FALSE means create a new Folder.

Definition at line 1063 of file FileExplorer.c.

◆ LibDestroyMenuEntry()

VOID LibDestroyMenuEntry ( MENU_ENTRY MenuEntry)

Free up all resource allocated for a BM_MENU_ENTRY.

Parameters
MenuEntryA pointer to BM_MENU_ENTRY.

Definition at line 361 of file FileExplorer.c.

◆ LibDevicePathToStr()

CHAR16 * LibDevicePathToStr ( IN EFI_DEVICE_PATH_PROTOCOL DevPath)

This function converts an input device structure to a Unicode string.

Parameters
DevPathA pointer to the device path structure.
Returns
A new allocated Unicode string that represents the device path.

Definition at line 476 of file FileExplorer.c.

◆ LibExtractConfig()

EFI_STATUS EFIAPI LibExtractConfig ( IN CONST EFI_HII_CONFIG_ACCESS_PROTOCOL This,
IN CONST EFI_STRING  Request,
OUT EFI_STRING *  Progress,
OUT EFI_STRING *  Results 
)

This function allows a caller to extract the current configuration for one or more named elements from the target driver.

Parameters
ThisPoints to the EFI_HII_CONFIG_ACCESS_PROTOCOL.
RequestA null-terminated Unicode string in <ConfigRequest> format.
ProgressOn return, points to a character in the Request string. Points to the string's null terminator if request was successful. Points to the most recent '&' before the first failing name/value pair (or the beginning of the string if the failure is in the first name/value pair) if the request was not successful.
ResultsA null-terminated Unicode string in <ConfigAltResp> format which has all values filled in for the names in the Request string. String to be allocated by the called function.
Return values
EFI_INVALID_PARAMETERRequest is illegal syntax, or unknown name.
EFI_NOT_FOUNDRouting data doesn't match any storage in this driver.

Definition at line 111 of file FileExplorer.c.

◆ LibFileInfo()

VOID * LibFileInfo ( IN EFI_FILE_HANDLE  FHand,
IN EFI_GUID InfoType 
)

Function gets the file information from an open file descriptor, and stores it in a buffer allocated from pool.

Parameters
FHandFile Handle.
InfoTypeInfo type need to get.
Return values
Apointer to a buffer with file information or NULL is returned

Definition at line 543 of file FileExplorer.c.

◆ LibFindFiles()

EFI_STATUS LibFindFiles ( IN EFI_FILE_HANDLE  FileHandle,
IN UINT16 *  FileName,
IN EFI_HANDLE  DeviceHandle 
)

Find files under current directory.

All files and sub-directories in current directory will be stored in DirectoryMenu for future use.

Parameters
FileHandleParent file handle.
FileNameParent file name.
DeviceHandleDriver handle for this partition.
Return values
EFI_SUCCESSGet files from current dir successfully.
Returns
Other value if can't get files from current dir.

Definition at line 1138 of file FileExplorer.c.

◆ LibFindFileSystem()

EFI_STATUS LibFindFileSystem ( VOID  )

This function build the FsOptionMenu list which records all available file system in the system. They includes all instances of EFI_SIMPLE_FILE_SYSTEM_PROTOCOL, all instances of EFI_LOAD_FILE_SYSTEM.

Return values
EFI_SUCCESSSuccess find the file system
EFI_OUT_OF_RESOURCESCan not create menu entry

Definition at line 765 of file FileExplorer.c.

◆ LibFreeMenu()

VOID LibFreeMenu ( MENU_OPTION FreeMenu)

Free resources allocated in Allocate Rountine.

Parameters
FreeMenuMenu to be freed

Definition at line 402 of file FileExplorer.c.

◆ LibGetDevicePath()

VOID LibGetDevicePath ( IN UINT16  KeyValue)

Get the device path info saved in the menu structure.

Parameters
KeyValueKey value to identify the type of data to expect.

Definition at line 1446 of file FileExplorer.c.

◆ LibGetFileHandleFromDevicePath()

EFI_STATUS LibGetFileHandleFromDevicePath ( IN EFI_DEVICE_PATH_PROTOCOL RootDirectory,
OUT EFI_FILE_HANDLE RetFileHandle,
OUT UINT16 **  ParentFileName,
OUT EFI_HANDLE DeviceHandle 
)

Find the file handle from the input device path info.

Parameters
RootDirectoryDevice path info.
RetFileHandleReturn the file handle for the input device path.
ParentFileNameParent file name.
DeviceHandleDriver handle for this partition.
Return values
EFI_SUCESSFind the file handle success.
OtherFind the file handle failure.

Definition at line 925 of file FileExplorer.c.

◆ LibGetFileHandleFromMenu()

EFI_STATUS LibGetFileHandleFromMenu ( IN MENU_ENTRY MenuEntry,
OUT EFI_FILE_HANDLE RetFileHandle 
)

Find the file handle from the input menu info.

Parameters
MenuEntryInput Menu info.
RetFileHandleReturn the file handle for the input device path.
Return values
EFI_SUCESSFind the file handle success.
OtherFind the file handle failure.

Definition at line 877 of file FileExplorer.c.

◆ LibGetMenuEntry()

MENU_ENTRY * LibGetMenuEntry ( MENU_OPTION MenuOption,
UINTN  MenuNumber 
)

Get the Menu Entry from the list in Menu Entry List.

If MenuNumber is great or equal to the number of Menu Entry in the list, then ASSERT.

Parameters
MenuOptionThe Menu Entry List to read the menu entry.
MenuNumberThe index of Menu Entry.
Returns
The Menu Entry.

Definition at line 333 of file FileExplorer.c.

◆ LibGetTypeFromName()

CHAR16 * LibGetTypeFromName ( IN CHAR16 *  FileName)

Get file type base on the file name. Just cut the file name, from the ".". eg ".efi"

Parameters
FileNameFile need to be checked.
Return values
thefile type string.

Definition at line 587 of file FileExplorer.c.

◆ LibIsSupportedFileType()

BOOLEAN LibIsSupportedFileType ( IN UINT16 *  FileName)

Check whether current FileName point to a valid Efi Image File.

Parameters
FileNameFile need to be checked.
Return values
TRUEIs Efi Image
FALSENot a valid Efi Image

Definition at line 634 of file FileExplorer.c.

◆ LibOpenRoot()

EFI_FILE_HANDLE LibOpenRoot ( IN EFI_HANDLE  DeviceHandle)

Function opens and returns a file handle to the root directory of a volume.

Parameters
DeviceHandleA handle for a device
Returns
A valid file handle or NULL is returned

Definition at line 432 of file FileExplorer.c.

◆ LibRefreshUpdateData()

VOID LibRefreshUpdateData ( VOID  )

Refresh the global UpdateData structure.

Definition at line 1256 of file FileExplorer.c.

◆ LibRouteConfig()

EFI_STATUS EFIAPI LibRouteConfig ( IN CONST EFI_HII_CONFIG_ACCESS_PROTOCOL This,
IN CONST EFI_STRING  Configuration,
OUT EFI_STRING *  Progress 
)

This function processes the results of changes in configuration.

Parameters
ThisPoints to the EFI_HII_CONFIG_ACCESS_PROTOCOL.
ConfigurationA null-terminated Unicode string in <ConfigResp> format.
ProgressA pointer to a string filled in with the offset of the most recent '&' before the first failing name/value pair (or the beginning of the string if the failure is in the first name/value pair) or the terminating NULL if all was successful.
Return values
EFI_INVALID_PARAMETERConfiguration is NULL.
EFI_NOT_FOUNDRouting data doesn't match any storage in this driver.

Definition at line 143 of file FileExplorer.c.

◆ LibStrDuplicate()

CHAR16 * LibStrDuplicate ( IN CHAR16 *  Src)

Duplicate a string.

Parameters
SrcThe source.
Returns
A new string which is duplicated copy of the source.
Return values
NULLIf there is not enough memory.

Definition at line 514 of file FileExplorer.c.

◆ LibToLowerString()

VOID LibToLowerString ( IN CHAR16 *  String)

Converts the unicode character of the string from uppercase to lowercase. This is a internal function.

Parameters
ConfigStringString to be converted

Definition at line 609 of file FileExplorer.c.

◆ LibUpdateFileExplorePage()

VOID LibUpdateFileExplorePage ( VOID  )

Update the File Explore page.

Definition at line 1310 of file FileExplorer.c.

◆ LibUpdateFileExplorer()

EFI_STATUS LibUpdateFileExplorer ( IN UINT16  KeyValue)

Update the file explower page with the refershed file system.

Parameters
KeyValueKey value to identify the type of data to expect.
Return values
EFI_SUCCESSUpdate the file explorer form success.
othererrors Error occur when parse one directory.

Definition at line 1405 of file FileExplorer.c.

Variable Documentation

◆ FeHiiVendorDevicePath

HII_VENDOR_DEVICE_PATH FeHiiVendorDevicePath
Initial value:
= {
{
{
{
(UINT8)(sizeof (VENDOR_DEVICE_PATH)),
(UINT8)((sizeof (VENDOR_DEVICE_PATH)) >> 8)
}
},
{ 0x0, 0x0, 0x0, { 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0 }
}
},
{
END_DEVICE_PATH_TYPE,
END_ENTIRE_DEVICE_PATH_SUBTYPE,
{
(UINT8)(END_DEVICE_PATH_LENGTH),
(UINT8)((END_DEVICE_PATH_LENGTH) >> 8)
}
}
}
#define HARDWARE_DEVICE_PATH
Definition: DevicePath.h:68
#define HW_VENDOR_DP
Definition: DevicePath.h:133

Definition at line 39 of file FileExplorer.c.

◆ FileExplorerGuid

EFI_GUID FileExplorerGuid = EFI_FILE_EXPLORE_FORMSET_GUID

Definition at line 11 of file FileExplorer.c.

◆ gFileExplorerPrivate

FILE_EXPLORER_CALLBACK_DATA gFileExplorerPrivate
Initial value:
= {
FILE_EXPLORER_CALLBACK_DATA_SIGNATURE,
{
},
0
}
EFI_STATUS EFIAPI LibExtractConfig(IN CONST EFI_HII_CONFIG_ACCESS_PROTOCOL *This, IN CONST EFI_STRING Request, OUT EFI_STRING *Progress, OUT EFI_STRING *Results)
Definition: FileExplorer.c:111
MENU_OPTION mFsOptionMenu
Definition: FileExplorer.c:16
EFI_STATUS EFIAPI LibCallback(IN CONST EFI_HII_CONFIG_ACCESS_PROTOCOL *This, IN EFI_BROWSER_ACTION Action, IN EFI_QUESTION_ID QuestionId, IN UINT8 Type, IN EFI_IFR_TYPE_VALUE *Value, OUT EFI_BROWSER_ACTION_REQUEST *ActionRequest)
Definition: FileExplorer.c:179
EFI_STATUS EFIAPI LibRouteConfig(IN CONST EFI_HII_CONFIG_ACCESS_PROTOCOL *This, IN CONST EFI_STRING Configuration, OUT EFI_STRING *Progress)
Definition: FileExplorer.c:143
#define NULL
Definition: Base.h:319

Definition at line 23 of file FileExplorer.c.

◆ gHiiVendorDevicePath

HII_VENDOR_DEVICE_PATH* gHiiVendorDevicePath

Definition at line 37 of file FileExplorer.c.

◆ mFsOptionMenu

MENU_OPTION mFsOptionMenu
Initial value:
= {
MENU_OPTION_SIGNATURE,
{ NULL },
0,
}
#define FALSE
Definition: Base.h:307

File system selection menu

Definition at line 16 of file FileExplorer.c.

◆ mLibEndLabel

EFI_IFR_GUID_LABEL* mLibEndLabel = NULL

Definition at line 68 of file FileExplorer.c.

◆ mLibEndOpCodeHandle

VOID* mLibEndOpCodeHandle = NULL

Definition at line 66 of file FileExplorer.c.

◆ mLibStartLabel

EFI_IFR_GUID_LABEL* mLibStartLabel = NULL

Definition at line 67 of file FileExplorer.c.

◆ mLibStartOpCodeHandle

VOID* mLibStartOpCodeHandle = NULL

Definition at line 65 of file FileExplorer.c.

◆ mNewFileName

CHAR16 mNewFileName[MAX_FILE_NAME_LEN]

Definition at line 70 of file FileExplorer.c.

◆ mNewFileQuestionId

UINTN mNewFileQuestionId = NEW_FILE_QUESTION_ID_BASE

Definition at line 72 of file FileExplorer.c.

◆ mNewFolderName

CHAR16 mNewFolderName[MAX_FOLDER_NAME_LEN]

Definition at line 71 of file FileExplorer.c.

◆ mNewFolderQuestionId

UINTN mNewFolderQuestionId = NEW_FOLDER_QUESTION_ID_BASE

Definition at line 73 of file FileExplorer.c.

◆ mQuestionIdUpdate

UINT16 mQuestionIdUpdate

Definition at line 69 of file FileExplorer.c.