]>
Commit | Line | Data |
---|---|---|
fd6a62f3 | 1 | /** @file\r |
2 | File explorer related functions.\r | |
93e3992d | 3 | \r |
fd6a62f3 | 4 | Copyright (c) 2004 - 2008, Intel Corporation. <BR>\r |
93e3992d | 5 | All rights reserved. This program and the accompanying materials\r |
6 | are licensed and made available under the terms and conditions of the BSD License\r | |
7 | which accompanies this distribution. The full text of the license may be found at\r | |
8 | http://opensource.org/licenses/bsd-license.php\r | |
9 | \r | |
10 | THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r | |
11 | WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r | |
12 | \r | |
fd6a62f3 | 13 | **/\r |
93e3992d | 14 | \r |
15 | #include "BootMaint.h"\r | |
16 | \r | |
b30312ba | 17 | /**\r |
18 | Update the File Explore page.\r | |
19 | \r | |
20 | \r | |
dce655e8 | 21 | @param CallbackData The BMM context data.\r |
b30312ba | 22 | @param MenuOption Pointer to menu options to display.\r |
23 | \r | |
dce655e8 | 24 | @return VOID\r |
b30312ba | 25 | \r |
26 | **/\r | |
93e3992d | 27 | VOID\r |
28 | UpdateFileExplorePage (\r | |
29 | IN BMM_CALLBACK_DATA *CallbackData,\r | |
30 | BM_MENU_OPTION *MenuOption\r | |
31 | )\r | |
93e3992d | 32 | {\r |
33 | UINTN Index;\r | |
34 | BM_MENU_ENTRY *NewMenuEntry;\r | |
35 | BM_FILE_CONTEXT *NewFileContext;\r | |
36 | EFI_FORM_ID FormId;\r | |
37 | \r | |
38 | NewMenuEntry = NULL;\r | |
39 | NewFileContext = NULL;\r | |
40 | FormId = 0;\r | |
41 | \r | |
42 | RefreshUpdateData ();\r | |
43 | \r | |
44 | for (Index = 0; Index < MenuOption->MenuNumber; Index++) {\r | |
45 | NewMenuEntry = BOpt_GetMenuEntry (MenuOption, Index);\r | |
46 | NewFileContext = (BM_FILE_CONTEXT *) NewMenuEntry->VariableContext;\r | |
47 | \r | |
48 | if (NewFileContext->IsBootLegacy) {\r | |
49 | continue;\r | |
50 | }\r | |
51 | \r | |
52 | if ((NewFileContext->IsDir) || (BOOT_FROM_FILE_STATE == CallbackData->FeCurrentState)) {\r | |
53 | //\r | |
54 | // Create Text opcode for directory, also create Text opcode for file in BOOT_FROM_FILE_STATE.\r | |
55 | //\r | |
56 | CreateActionOpCode (\r | |
57 | (UINT16) (FILE_OPTION_OFFSET + Index),\r | |
58 | NewMenuEntry->DisplayStringToken,\r | |
59 | STRING_TOKEN (STR_NULL_STRING),\r | |
60 | EFI_IFR_FLAG_CALLBACK,\r | |
61 | 0,\r | |
62 | &gUpdateData\r | |
63 | );\r | |
64 | } else {\r | |
65 | //\r | |
66 | // Create Goto opcode for file in ADD_BOOT_OPTION_STATE or ADD_DRIVER_OPTION_STATE.\r | |
67 | //\r | |
68 | if (ADD_BOOT_OPTION_STATE == CallbackData->FeCurrentState) {\r | |
69 | FormId = FORM_BOOT_ADD_DESCRIPTION_ID;\r | |
70 | } else if (ADD_DRIVER_OPTION_STATE == CallbackData->FeCurrentState) {\r | |
71 | FormId = FORM_DRIVER_ADD_FILE_DESCRIPTION_ID;\r | |
72 | }\r | |
73 | \r | |
74 | CreateGotoOpCode (\r | |
75 | FormId,\r | |
76 | NewMenuEntry->DisplayStringToken,\r | |
77 | STRING_TOKEN (STR_NULL_STRING),\r | |
78 | EFI_IFR_FLAG_CALLBACK,\r | |
79 | (UINT16) (FILE_OPTION_OFFSET + Index),\r | |
80 | &gUpdateData\r | |
81 | );\r | |
82 | }\r | |
83 | }\r | |
84 | \r | |
85 | IfrLibUpdateForm (\r | |
86 | CallbackData->FeHiiHandle,\r | |
87 | &mFileExplorerGuid,\r | |
88 | FORM_FILE_EXPLORER_ID,\r | |
89 | FORM_FILE_EXPLORER_ID,\r | |
90 | FALSE,\r | |
91 | &gUpdateData\r | |
92 | );\r | |
93 | }\r | |
94 | \r | |
b30312ba | 95 | /**\r |
96 | Update the file explower page with the refershed file system.\r | |
97 | \r | |
98 | \r | |
99 | @param CallbackData BMM context data\r | |
100 | @param KeyValue Key value to identify the type of data to expect.\r | |
101 | \r | |
102 | @retval TRUE Inform the caller to create a callback packet to exit file explorer.\r | |
103 | @retval FALSE Indicate that there is no need to exit file explorer.\r | |
104 | \r | |
105 | **/\r | |
93e3992d | 106 | BOOLEAN\r |
107 | UpdateFileExplorer (\r | |
108 | IN BMM_CALLBACK_DATA *CallbackData,\r | |
109 | IN UINT16 KeyValue\r | |
110 | )\r | |
93e3992d | 111 | {\r |
112 | UINT16 FileOptionMask;\r | |
113 | BM_MENU_ENTRY *NewMenuEntry;\r | |
114 | BM_FILE_CONTEXT *NewFileContext;\r | |
115 | EFI_FORM_ID FormId;\r | |
116 | BOOLEAN ExitFileExplorer;\r | |
117 | EFI_STATUS Status;\r | |
118 | \r | |
119 | NewMenuEntry = NULL;\r | |
120 | NewFileContext = NULL;\r | |
121 | ExitFileExplorer = FALSE;\r | |
122 | \r | |
123 | FileOptionMask = (UINT16) (FILE_OPTION_MASK & KeyValue);\r | |
124 | \r | |
125 | if (UNKNOWN_CONTEXT == CallbackData->FeDisplayContext) {\r | |
126 | //\r | |
127 | // First in, display file system.\r | |
128 | //\r | |
129 | BOpt_FreeMenu (&FsOptionMenu);\r | |
130 | BOpt_FindFileSystem (CallbackData);\r | |
131 | CreateMenuStringToken (CallbackData, CallbackData->FeHiiHandle, &FsOptionMenu);\r | |
132 | \r | |
133 | UpdateFileExplorePage (CallbackData, &FsOptionMenu);\r | |
134 | \r | |
135 | CallbackData->FeDisplayContext = FILE_SYSTEM;\r | |
136 | } else {\r | |
137 | if (FILE_SYSTEM == CallbackData->FeDisplayContext) {\r | |
138 | NewMenuEntry = BOpt_GetMenuEntry (&FsOptionMenu, FileOptionMask);\r | |
139 | } else if (DIRECTORY == CallbackData->FeDisplayContext) {\r | |
140 | NewMenuEntry = BOpt_GetMenuEntry (&DirectoryMenu, FileOptionMask);\r | |
141 | }\r | |
142 | \r | |
143 | CallbackData->FeDisplayContext = DIRECTORY;\r | |
144 | \r | |
145 | NewFileContext = (BM_FILE_CONTEXT *) NewMenuEntry->VariableContext;\r | |
146 | \r | |
147 | if (NewFileContext->IsDir ) {\r | |
148 | RemoveEntryList (&NewMenuEntry->Link);\r | |
149 | BOpt_FreeMenu (&DirectoryMenu);\r | |
150 | Status = BOpt_FindFiles (CallbackData, NewMenuEntry);\r | |
151 | if (EFI_ERROR (Status)) {\r | |
152 | ExitFileExplorer = TRUE;\r | |
153 | goto exit;\r | |
154 | }\r | |
155 | CreateMenuStringToken (CallbackData, CallbackData->FeHiiHandle, &DirectoryMenu);\r | |
156 | BOpt_DestroyMenuEntry (NewMenuEntry);\r | |
157 | \r | |
158 | UpdateFileExplorePage (CallbackData, &DirectoryMenu);\r | |
159 | \r | |
160 | } else {\r | |
161 | switch (CallbackData->FeCurrentState) {\r | |
162 | case BOOT_FROM_FILE_STATE:\r | |
163 | //\r | |
164 | // Here boot from file\r | |
165 | //\r | |
166 | BootThisFile (NewFileContext);\r | |
167 | ExitFileExplorer = TRUE;\r | |
168 | break;\r | |
169 | \r | |
170 | case ADD_BOOT_OPTION_STATE:\r | |
171 | case ADD_DRIVER_OPTION_STATE:\r | |
172 | if (ADD_BOOT_OPTION_STATE == CallbackData->FeCurrentState) {\r | |
173 | FormId = FORM_BOOT_ADD_DESCRIPTION_ID;\r | |
174 | } else {\r | |
175 | FormId = FORM_DRIVER_ADD_FILE_DESCRIPTION_ID;\r | |
176 | }\r | |
177 | \r | |
178 | CallbackData->MenuEntry = NewMenuEntry;\r | |
179 | CallbackData->LoadContext->FilePathList = ((BM_FILE_CONTEXT *) (CallbackData->MenuEntry->VariableContext))->DevicePath;\r | |
180 | \r | |
181 | //\r | |
182 | // Create Subtitle op-code for the display string of the option.\r | |
183 | //\r | |
184 | RefreshUpdateData ();\r | |
185 | \r | |
186 | CreateSubTitleOpCode (\r | |
187 | NewMenuEntry->DisplayStringToken,\r | |
188 | 0,\r | |
189 | 0,\r | |
190 | 0,\r | |
191 | &gUpdateData\r | |
192 | );\r | |
193 | \r | |
194 | IfrLibUpdateForm (\r | |
195 | CallbackData->FeHiiHandle,\r | |
196 | &mFileExplorerGuid,\r | |
197 | FormId,\r | |
198 | FormId,\r | |
199 | FALSE,\r | |
200 | &gUpdateData\r | |
201 | );\r | |
202 | break;\r | |
203 | \r | |
204 | default:\r | |
205 | break;\r | |
206 | }\r | |
207 | }\r | |
208 | }\r | |
209 | exit:\r | |
210 | return ExitFileExplorer;\r | |
211 | }\r | |
212 | \r | |
b30312ba | 213 | /**\r |
214 | This function processes the results of changes in configuration.\r | |
dce655e8 | 215 | When user select a interactive opcode, this callback will be triggered.\r |
216 | Based on the Question(QuestionId) that triggers the callback, the corresponding\r | |
217 | actions is performed. It handles:\r | |
218 | \r | |
219 | 1) the addition of boot option.\r | |
220 | 2) the addition of driver option.\r | |
221 | 3) exit from file browser\r | |
222 | 4) update of file content if a dir is selected.\r | |
223 | 5) boot the file if a file is selected in "boot from file"\r | |
b30312ba | 224 | \r |
225 | \r | |
226 | @param This Points to the EFI_HII_CONFIG_ACCESS_PROTOCOL.\r | |
227 | @param Action Specifies the type of action taken by the browser.\r | |
228 | @param QuestionId A unique value which is sent to the original exporting driver\r | |
229 | so that it can identify the type of data to expect.\r | |
230 | @param Type The type of value for the question.\r | |
231 | @param Value A pointer to the data being sent to the original exporting driver.\r | |
232 | @param ActionRequest On return, points to the action requested by the callback function.\r | |
233 | \r | |
234 | @retval EFI_SUCCESS The callback successfully handled the action.\r | |
235 | @retval EFI_OUT_OF_RESOURCES Not enough storage is available to hold the variable and its data.\r | |
236 | @retval EFI_DEVICE_ERROR The variable could not be saved.\r | |
237 | @retval EFI_UNSUPPORTED The specified Action is not supported by the callback.\r | |
238 | \r | |
239 | **/\r | |
93e3992d | 240 | EFI_STATUS\r |
241 | EFIAPI\r | |
242 | FileExplorerCallback (\r | |
243 | IN CONST EFI_HII_CONFIG_ACCESS_PROTOCOL *This,\r | |
244 | IN EFI_BROWSER_ACTION Action,\r | |
245 | IN EFI_QUESTION_ID QuestionId,\r | |
246 | IN UINT8 Type,\r | |
247 | IN EFI_IFR_TYPE_VALUE *Value,\r | |
248 | OUT EFI_BROWSER_ACTION_REQUEST *ActionRequest\r | |
249 | )\r | |
93e3992d | 250 | {\r |
251 | BMM_CALLBACK_DATA *Private;\r | |
252 | FILE_EXPLORER_NV_DATA *NvRamMap;\r | |
253 | EFI_STATUS Status;\r | |
254 | UINTN BufferSize;\r | |
255 | \r | |
256 | if ((Value == NULL) || (ActionRequest == NULL)) {\r | |
257 | return EFI_INVALID_PARAMETER;\r | |
258 | }\r | |
259 | \r | |
260 | Status = EFI_SUCCESS;\r | |
261 | Private = FE_CALLBACK_DATA_FROM_THIS (This);\r | |
262 | *ActionRequest = EFI_BROWSER_ACTION_REQUEST_NONE;\r | |
263 | \r | |
264 | //\r | |
265 | // Retrive uncommitted data from Form Browser\r | |
266 | //\r | |
267 | NvRamMap = &Private->FeFakeNvData;\r | |
268 | BufferSize = sizeof (FILE_EXPLORER_NV_DATA);\r | |
269 | Status = GetBrowserData (NULL, NULL, &BufferSize, (UINT8 *) NvRamMap);\r | |
270 | if (EFI_ERROR (Status)) {\r | |
271 | return Status;\r | |
272 | }\r | |
273 | \r | |
274 | if (QuestionId == KEY_VALUE_SAVE_AND_EXIT_BOOT || QuestionId == KEY_VALUE_SAVE_AND_EXIT_DRIVER) {\r | |
275 | //\r | |
276 | // Apply changes and exit formset\r | |
277 | //\r | |
278 | if (ADD_BOOT_OPTION_STATE == Private->FeCurrentState) {\r | |
279 | Status = Var_UpdateBootOption (Private, NvRamMap);\r | |
280 | if (EFI_ERROR (Status)) {\r | |
281 | return Status;\r | |
282 | }\r | |
283 | \r | |
284 | BOpt_GetBootOptions (Private);\r | |
285 | CreateMenuStringToken (Private, Private->FeHiiHandle, &BootOptionMenu);\r | |
286 | } else if (ADD_DRIVER_OPTION_STATE == Private->FeCurrentState) {\r | |
287 | Status = Var_UpdateDriverOption (\r | |
288 | Private,\r | |
289 | Private->FeHiiHandle,\r | |
290 | NvRamMap->DescriptionData,\r | |
291 | NvRamMap->OptionalData,\r | |
292 | NvRamMap->ForceReconnect\r | |
293 | );\r | |
294 | if (EFI_ERROR (Status)) {\r | |
295 | return Status;\r | |
296 | }\r | |
297 | \r | |
298 | BOpt_GetDriverOptions (Private);\r | |
299 | CreateMenuStringToken (Private, Private->FeHiiHandle, &DriverOptionMenu);\r | |
300 | }\r | |
301 | \r | |
302 | *ActionRequest = EFI_BROWSER_ACTION_REQUEST_EXIT;\r | |
303 | } else if (QuestionId == KEY_VALUE_NO_SAVE_AND_EXIT_BOOT || QuestionId == KEY_VALUE_NO_SAVE_AND_EXIT_DRIVER) {\r | |
304 | //\r | |
305 | // Discard changes and exit formset\r | |
306 | //\r | |
307 | NvRamMap->OptionalData[0] = 0x0000;\r | |
308 | NvRamMap->DescriptionData[0] = 0x0000;\r | |
309 | *ActionRequest = EFI_BROWSER_ACTION_REQUEST_EXIT;\r | |
310 | } else if (QuestionId < FILE_OPTION_OFFSET) {\r | |
311 | //\r | |
312 | // Exit File Explorer formset\r | |
313 | //\r | |
314 | *ActionRequest = EFI_BROWSER_ACTION_REQUEST_EXIT;\r | |
315 | } else {\r | |
316 | if (UpdateFileExplorer (Private, QuestionId)) {\r | |
317 | *ActionRequest = EFI_BROWSER_ACTION_REQUEST_EXIT;\r | |
318 | }\r | |
319 | }\r | |
320 | \r | |
321 | return Status;\r | |
322 | }\r |