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