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