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