]> git.proxmox.com Git - mirror_edk2.git/blame - MdeModulePkg/Library/FileExplorerLib/FileExplorer.h
MdeModulePkg/FileExplorerLib: remove redundant null pointer check
[mirror_edk2.git] / MdeModulePkg / Library / FileExplorerLib / FileExplorer.h
CommitLineData
4c8274a0
ED
1/** @file\r
2 File explorer lib.\r
3\r
d1102dba 4Copyright (c) 2015 - 2018, Intel Corporation. All rights reserved.<BR>\r
9d510e61 5SPDX-License-Identifier: BSD-2-Clause-Patent\r
4c8274a0
ED
6**/\r
7\r
8#ifndef _FILE_EXPLORER_H_\r
9#define _FILE_EXPLORER_H_\r
10\r
11#include <PiDxe.h>\r
12#include <Guid/FileSystemVolumeLabelInfo.h>\r
13#include <Guid/FileInfo.h>\r
14#include <Guid/MdeModuleHii.h>\r
15\r
16#include <Protocol/HiiConfigAccess.h>\r
17#include <Protocol/DevicePath.h>\r
18#include <Protocol/SimpleFileSystem.h>\r
19#include <Protocol/DevicePathToText.h>\r
4c8274a0
ED
20#include <Protocol/FormBrowser2.h>\r
21\r
22#include <Library/DebugLib.h>\r
23#include <Library/BaseMemoryLib.h>\r
24#include <Library/UefiBootServicesTableLib.h>\r
25#include <Library/MemoryAllocationLib.h>\r
26#include <Library/BaseLib.h>\r
27#include <Library/UefiLib.h>\r
28#include <Library/DevicePathLib.h>\r
29#include <Library/FileExplorerLib.h>\r
30#include <Library/HiiLib.h>\r
31#include <Library/PrintLib.h>\r
32\r
33#include "FormGuid.h"\r
34\r
35#define FILE_EXPLORER_CALLBACK_DATA_SIGNATURE SIGNATURE_32 ('f', 'e', 'c', 'k')\r
36\r
37\r
38#pragma pack(1)\r
39\r
40///\r
41/// HII specific Vendor Device Path definition.\r
42///\r
43typedef struct {\r
44 VENDOR_DEVICE_PATH VendorDevicePath;\r
45 EFI_DEVICE_PATH_PROTOCOL End;\r
46} HII_VENDOR_DEVICE_PATH;\r
47\r
765fb87c
AB
48#pragma pack()\r
49\r
4c8274a0
ED
50typedef struct {\r
51 EFI_HANDLE DeviceHandle;\r
52 EFI_DEVICE_PATH_PROTOCOL *DevicePath;\r
53 EFI_FILE_HANDLE FileHandle;\r
54 UINT16 *FileName;\r
55\r
56 BOOLEAN IsRoot;\r
57 BOOLEAN IsDir;\r
58} FILE_CONTEXT;\r
59\r
60typedef struct {\r
61 UINTN Signature;\r
62 LIST_ENTRY Link;\r
63 UINT16 *DisplayString;\r
64 UINT16 *HelpString;\r
65 EFI_STRING_ID DisplayStringToken;\r
66 EFI_STRING_ID HelpStringToken;\r
67 VOID *VariableContext;\r
68} MENU_ENTRY;\r
69\r
70typedef struct {\r
71 UINTN Signature;\r
72 LIST_ENTRY Head;\r
73 UINTN MenuNumber;\r
74 BOOLEAN Used;\r
75} MENU_OPTION;\r
76\r
77typedef struct {\r
78 //\r
79 // Shared callback data.\r
80 //\r
81 UINTN Signature;\r
82\r
83 //\r
84 // File explorer formset callback data.\r
85 //\r
86 EFI_HII_HANDLE FeHiiHandle;\r
87 EFI_HANDLE FeDriverHandle;\r
88 EFI_HII_CONFIG_ACCESS_PROTOCOL FeConfigAccess;\r
89 EFI_FORM_BROWSER2_PROTOCOL *FormBrowser2;\r
90 MENU_OPTION *FsOptionMenu;\r
91 CHAR16 *FileType;\r
92 CHOOSE_HANDLER ChooseHandler;\r
93 EFI_DEVICE_PATH_PROTOCOL *RetDevicePath;\r
94\r
95} FILE_EXPLORER_CALLBACK_DATA;\r
96\r
97#define FILE_EXPLORER_PRIVATE_FROM_THIS(a) CR (a, FILE_EXPLORER_CALLBACK_DATA, FeConfigAccess, FILE_EXPLORER_CALLBACK_DATA_SIGNATURE)\r
98\r
4c8274a0
ED
99extern UINT8 FileExplorerVfrBin[];\r
100\r
101#define MENU_OPTION_SIGNATURE SIGNATURE_32 ('m', 'e', 'n', 'u')\r
102#define MENU_ENTRY_SIGNATURE SIGNATURE_32 ('e', 'n', 't', 'r')\r
103\r
104///\r
105/// Define the maximum characters that will be accepted.\r
106///\r
107#define MAX_CHAR 480\r
108#define FILE_OPTION_OFFSET 0x8000\r
109#define FILE_OPTION_MASK 0x7FFF\r
9cf1aa29 110#define QUESTION_ID_UPDATE_STEP 200\r
a4098755
DB
111#define MAX_FILE_NAME_LEN 20\r
112#define MAX_FOLDER_NAME_LEN 20\r
113#define NEW_FILE_QUESTION_ID_BASE 0x5000;\r
114#define NEW_FOLDER_QUESTION_ID_BASE 0x6000;\r
4c8274a0
ED
115\r
116/**\r
117 This function processes the results of changes in configuration.\r
118 When user select a interactive opcode, this callback will be triggered.\r
119 Based on the Question(QuestionId) that triggers the callback, the corresponding\r
120 actions is performed. It handles:\r
121\r
122 1) the addition of boot option.\r
123 2) the addition of driver option.\r
124 3) exit from file browser\r
125 4) update of file content if a dir is selected.\r
126 5) boot the file if a file is selected in "boot from file"\r
127\r
128\r
129 @param This Points to the EFI_HII_CONFIG_ACCESS_PROTOCOL.\r
130 @param Action Specifies the type of action taken by the browser.\r
131 @param QuestionId A unique value which is sent to the original exporting driver\r
132 so that it can identify the type of data to expect.\r
133 @param Type The type of value for the question.\r
134 @param Value A pointer to the data being sent to the original exporting driver.\r
135 @param ActionRequest On return, points to the action requested by the callback function.\r
136\r
137 @retval EFI_SUCCESS The callback successfully handled the action.\r
138 @retval EFI_OUT_OF_RESOURCES Not enough storage is available to hold the variable and its data.\r
139 @retval EFI_DEVICE_ERROR The variable could not be saved.\r
140 @retval EFI_UNSUPPORTED The specified Action is not supported by the callback.\r
141\r
142**/\r
143EFI_STATUS\r
144EFIAPI\r
145LibCallback (\r
146 IN CONST EFI_HII_CONFIG_ACCESS_PROTOCOL *This,\r
147 IN EFI_BROWSER_ACTION Action,\r
148 IN EFI_QUESTION_ID QuestionId,\r
149 IN UINT8 Type,\r
150 IN EFI_IFR_TYPE_VALUE *Value,\r
151 OUT EFI_BROWSER_ACTION_REQUEST *ActionRequest\r
152 );\r
153\r
154\r
155/**\r
156 This function allows a caller to extract the current configuration for one\r
157 or more named elements from the target driver.\r
158\r
159\r
160 @param This - Points to the EFI_HII_CONFIG_ACCESS_PROTOCOL.\r
161 @param Request - A null-terminated Unicode string in <ConfigRequest> format.\r
162 @param Progress - On return, points to a character in the Request string.\r
163 Points to the string's null terminator if request was successful.\r
164 Points to the most recent '&' before the first failing name/value\r
165 pair (or the beginning of the string if the failure is in the\r
166 first name/value pair) if the request was not successful.\r
167 @param Results - A null-terminated Unicode string in <ConfigAltResp> format which\r
168 has all values filled in for the names in the Request string.\r
169 String to be allocated by the called function.\r
170\r
171 @retval EFI_SUCCESS The Results is filled with the requested values.\r
172 @retval EFI_OUT_OF_RESOURCES Not enough memory to store the results.\r
173 @retval EFI_INVALID_PARAMETER Request is NULL, illegal syntax, or unknown name.\r
174 @retval EFI_NOT_FOUND Routing data doesn't match any storage in this driver.\r
175\r
176**/\r
177EFI_STATUS\r
178EFIAPI\r
179LibExtractConfig (\r
180 IN CONST EFI_HII_CONFIG_ACCESS_PROTOCOL *This,\r
181 IN CONST EFI_STRING Request,\r
182 OUT EFI_STRING *Progress,\r
183 OUT EFI_STRING *Results\r
184 );\r
185\r
186/**\r
187 This function processes the results of changes in configuration.\r
188\r
189\r
190 @param This - Points to the EFI_HII_CONFIG_ACCESS_PROTOCOL.\r
191 @param Configuration - A null-terminated Unicode string in <ConfigResp> format.\r
192 @param Progress - A pointer to a string filled in with the offset of the most\r
193 recent '&' before the first failing name/value pair (or the\r
194 beginning of the string if the failure is in the first\r
195 name/value pair) or the terminating NULL if all was successful.\r
196\r
197 @retval EFI_SUCCESS The Results is processed successfully.\r
198 @retval EFI_INVALID_PARAMETER Configuration is NULL.\r
199 @retval EFI_NOT_FOUND Routing data doesn't match any storage in this driver.\r
200\r
201**/\r
202EFI_STATUS\r
203EFIAPI\r
204LibRouteConfig (\r
205 IN CONST EFI_HII_CONFIG_ACCESS_PROTOCOL *This,\r
206 IN CONST EFI_STRING Configuration,\r
207 OUT EFI_STRING *Progress\r
208 );\r
209\r
210/**\r
211 Update the file explower page with the refershed file system.\r
212\r
213 @param KeyValue Key value to identify the type of data to expect.\r
214\r
215 @retval EFI_SUCCESS Update the file explorer form success.\r
216 @retval other errors Error occur when parse one directory.\r
217\r
218**/\r
219EFI_STATUS\r
220LibUpdateFileExplorer (\r
221 IN UINT16 KeyValue\r
222 );\r
d1102dba
LG
223\r
224\r
4c8274a0
ED
225/**\r
226 Get the device path info saved in the menu structure.\r
227\r
228 @param KeyValue Key value to identify the type of data to expect.\r
229\r
230**/\r
231VOID\r
232LibGetDevicePath (\r
233 IN UINT16 KeyValue\r
234 );\r
235\r
d1102dba 236#endif\r