]>
Commit | Line | Data |
---|---|---|
bc11b829 | 1 | /*++\r |
2 | \r | |
3 | Copyright (c) 2006 - 2007, Intel Corporation\r | |
4 | All rights reserved. This program and the accompanying materials\r | |
5 | are licensed and made available under the terms and conditions of the BSD License\r | |
6 | which accompanies this distribution. The full text of the license may be found at\r | |
7 | http://opensource.org/licenses/bsd-license.php\r | |
8 | \r | |
9 | THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r | |
10 | WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r | |
11 | \r | |
12 | Module Name:\r | |
13 | \r | |
14 | BootMaint.c\r | |
15 | \r | |
16 | Abstract:\r | |
17 | \r | |
18 | Boot Maintainence Main File\r | |
19 | \r | |
20 | --*/\r | |
21 | \r | |
bc11b829 | 22 | #include "Generic/Bds.h"\r |
23 | #include "BootMaint.h"\r | |
bc11b829 | 24 | #include "formguid.h"\r |
25 | \r | |
26 | //\r | |
27 | // Form binary for Boot Maintenance\r | |
28 | //\r | |
29 | extern UINT8 bmBin[];\r | |
30 | extern UINT8 FEBin[];\r | |
bc11b829 | 31 | extern BOOLEAN gConnectAllHappened;\r |
32 | \r | |
33 | EFI_GUID EfiLegacyDevOrderGuid = EFI_LEGACY_DEV_ORDER_VARIABLE_GUID;\r | |
34 | \r | |
35 | VOID\r | |
36 | InitAllMenu (\r | |
37 | IN BMM_CALLBACK_DATA *CallbackData\r | |
38 | );\r | |
39 | \r | |
40 | VOID\r | |
41 | FreeAllMenu (\r | |
42 | VOID\r | |
43 | );\r | |
44 | \r | |
45 | EFI_STATUS\r | |
46 | CreateMenuStringToken (\r | |
47 | IN BMM_CALLBACK_DATA *CallbackData,\r | |
5fd5fcd3 | 48 | IN FRAMEWORK_EFI_HII_HANDLE HiiHandle,\r |
bc11b829 | 49 | IN BM_MENU_OPTION *MenuOption\r |
50 | )\r | |
51 | /*++\r | |
52 | Routine Description:\r | |
53 | \r | |
54 | Create string tokens for a menu from its help strings and display strings\r | |
55 | \r | |
56 | Arguments:\r | |
57 | \r | |
58 | HiiHandle - Hii Handle of the package to be updated.\r | |
59 | \r | |
60 | MenuOption - The Menu whose string tokens need to be created\r | |
61 | \r | |
62 | Returns:\r | |
63 | \r | |
64 | EFI_SUCCESS - string tokens created successfully\r | |
65 | \r | |
66 | others - contain some errors\r | |
67 | \r | |
68 | --*/\r | |
69 | {\r | |
70 | BM_MENU_ENTRY *NewMenuEntry;\r | |
71 | UINTN Index;\r | |
72 | \r | |
73 | for (Index = 0; Index < MenuOption->MenuNumber; Index++) {\r | |
74 | NewMenuEntry = BOpt_GetMenuEntry (MenuOption, Index);\r | |
75 | CallbackData->Hii->NewString (\r | |
76 | CallbackData->Hii,\r | |
77 | NULL,\r | |
78 | HiiHandle,\r | |
79 | &NewMenuEntry->DisplayStringToken,\r | |
80 | NewMenuEntry->DisplayString\r | |
81 | );\r | |
82 | \r | |
83 | if (NULL == NewMenuEntry->HelpString) {\r | |
84 | NewMenuEntry->HelpStringToken = NewMenuEntry->DisplayStringToken;\r | |
85 | } else {\r | |
86 | CallbackData->Hii->NewString (\r | |
87 | CallbackData->Hii,\r | |
88 | NULL,\r | |
89 | HiiHandle,\r | |
90 | &NewMenuEntry->HelpStringToken,\r | |
91 | NewMenuEntry->HelpString\r | |
92 | );\r | |
93 | }\r | |
94 | }\r | |
95 | \r | |
96 | return EFI_SUCCESS;\r | |
97 | }\r | |
98 | \r | |
99 | EFI_STATUS\r | |
100 | EFIAPI\r | |
101 | DriverCallback (\r | |
102 | IN EFI_FORM_CALLBACK_PROTOCOL *This,\r | |
103 | IN UINT16 KeyValue,\r | |
5fd5fcd3 | 104 | IN FRAMEWORK_EFI_IFR_DATA_ARRAY *Data,\r |
bc11b829 | 105 | OUT EFI_HII_CALLBACK_PACKET **Packet\r |
106 | )\r | |
107 | /*++\r | |
108 | Routine Description:\r | |
109 | \r | |
110 | Callback Function for boot maintenance utility user interface interaction.\r | |
111 | \r | |
112 | Arguments:\r | |
113 | \r | |
114 | This - File explorer callback protocol pointer.\r | |
115 | KeyValue - Key value to identify the type of data to expect.\r | |
116 | Data - A pointer to the data being sent to the original exporting driver.\r | |
117 | Packet - A pointer to a packet of information which a driver passes back to the browser.\r | |
118 | \r | |
119 | Returns:\r | |
120 | \r | |
121 | EFI_SUCCESS - Callback ended successfully.\r | |
122 | Others - Contain some errors.\r | |
123 | \r | |
124 | --*/\r | |
125 | {\r | |
126 | BMM_CALLBACK_DATA *Private;\r | |
127 | BM_MENU_ENTRY *NewMenuEntry;\r | |
128 | BMM_FAKE_NV_DATA *CurrentFakeNVMap;\r | |
129 | EFI_STATUS Status;\r | |
130 | UINTN OldValue;\r | |
131 | UINTN NewValue;\r | |
132 | UINTN Number;\r | |
133 | UINTN Pos;\r | |
134 | UINTN Bit;\r | |
135 | UINT16 NewValuePos;\r | |
136 | UINT16 Index2;\r | |
137 | UINT16 Index;\r | |
138 | UINT8 *OldLegacyDev;\r | |
139 | UINT8 *NewLegacyDev;\r | |
140 | UINT8 *Location;\r | |
141 | UINT8 *DisMap;\r | |
142 | FORM_ID FormId;\r | |
143 | \r | |
144 | OldValue = 0;\r | |
145 | NewValue = 0;\r | |
146 | Number = 0;\r | |
147 | OldLegacyDev = NULL;\r | |
148 | NewLegacyDev = NULL;\r | |
149 | NewValuePos = 0;\r | |
150 | DisMap = NULL;\r | |
151 | \r | |
152 | Private = BMM_CALLBACK_DATA_FROM_THIS (This);\r | |
153 | UpdateData->FormCallbackHandle = (EFI_PHYSICAL_ADDRESS) (UINTN) Private->BmmCallbackHandle;\r | |
154 | CurrentFakeNVMap = (BMM_FAKE_NV_DATA *) Data->NvRamMap;\r | |
155 | Private->BmmFakeNvData = CurrentFakeNVMap;\r | |
156 | Location = (UINT8 *) &UpdateData->Data;\r | |
157 | \r | |
158 | UpdatePageId (Private, KeyValue);\r | |
159 | \r | |
160 | //\r | |
161 | // need to be subtituded.\r | |
162 | //\r | |
163 | // Update Select FD/HD/CD/NET/BEV Order Form\r | |
164 | //\r | |
165 | if (FORM_SET_FD_ORDER_ID == Private->BmmPreviousPageId ||\r | |
166 | FORM_SET_HD_ORDER_ID == Private->BmmPreviousPageId ||\r | |
167 | FORM_SET_CD_ORDER_ID == Private->BmmPreviousPageId ||\r | |
168 | FORM_SET_NET_ORDER_ID == Private->BmmPreviousPageId ||\r | |
169 | FORM_SET_BEV_ORDER_ID == Private->BmmPreviousPageId ||\r | |
170 | ((FORM_BOOT_SETUP_ID == Private->BmmPreviousPageId) &&\r | |
171 | (KeyValue >= LEGACY_FD_QUESTION_ID) &&\r | |
172 | (KeyValue < (LEGACY_BEV_QUESTION_ID + 100)) )\r | |
173 | ) {\r | |
174 | \r | |
175 | DisMap = Private->BmmOldFakeNVData.DisableMap;\r | |
176 | \r | |
177 | FormId = Private->BmmPreviousPageId;\r | |
178 | if (FormId == FORM_BOOT_SETUP_ID) {\r | |
179 | FormId = Private->BmmCurrentPageId;\r | |
180 | }\r | |
181 | \r | |
182 | switch (FormId) {\r | |
183 | case FORM_SET_FD_ORDER_ID:\r | |
184 | Number = (UINT16) LegacyFDMenu.MenuNumber;\r | |
185 | OldLegacyDev = Private->BmmOldFakeNVData.LegacyFD;\r | |
186 | NewLegacyDev = CurrentFakeNVMap->LegacyFD;\r | |
187 | break;\r | |
188 | \r | |
189 | case FORM_SET_HD_ORDER_ID:\r | |
190 | Number = (UINT16) LegacyHDMenu.MenuNumber;\r | |
191 | OldLegacyDev = Private->BmmOldFakeNVData.LegacyHD;\r | |
192 | NewLegacyDev = CurrentFakeNVMap->LegacyHD;\r | |
193 | break;\r | |
194 | \r | |
195 | case FORM_SET_CD_ORDER_ID:\r | |
196 | Number = (UINT16) LegacyCDMenu.MenuNumber;\r | |
197 | OldLegacyDev = Private->BmmOldFakeNVData.LegacyCD;\r | |
198 | NewLegacyDev = CurrentFakeNVMap->LegacyCD;\r | |
199 | break;\r | |
200 | \r | |
201 | case FORM_SET_NET_ORDER_ID:\r | |
202 | Number = (UINT16) LegacyNETMenu.MenuNumber;\r | |
203 | OldLegacyDev = Private->BmmOldFakeNVData.LegacyNET;\r | |
204 | NewLegacyDev = CurrentFakeNVMap->LegacyNET;\r | |
205 | break;\r | |
206 | \r | |
207 | case FORM_SET_BEV_ORDER_ID:\r | |
208 | Number = (UINT16) LegacyBEVMenu.MenuNumber;\r | |
209 | OldLegacyDev = Private->BmmOldFakeNVData.LegacyBEV;\r | |
210 | NewLegacyDev = CurrentFakeNVMap->LegacyBEV;\r | |
211 | break;\r | |
212 | \r | |
213 | default:\r | |
214 | break;\r | |
215 | }\r | |
216 | //\r | |
217 | // First, find the different position\r | |
218 | // if there is change, it should be only one\r | |
219 | //\r | |
220 | for (Index = 0; Index < Number; Index++) {\r | |
221 | if (OldLegacyDev[Index] != NewLegacyDev[Index]) {\r | |
222 | OldValue = OldLegacyDev[Index];\r | |
223 | NewValue = NewLegacyDev[Index];\r | |
224 | break;\r | |
225 | }\r | |
226 | }\r | |
227 | \r | |
228 | if (Index != Number) {\r | |
229 | //\r | |
230 | // there is change, now process\r | |
231 | //\r | |
232 | if (0xFF == NewValue) {\r | |
233 | //\r | |
234 | // This item will be disable\r | |
235 | // Just move the items behind this forward to overlap it\r | |
236 | //\r | |
237 | Pos = OldValue / 8;\r | |
238 | Bit = 7 - (OldValue % 8);\r | |
239 | DisMap[Pos] |= (UINT8) (1 << Bit);\r | |
240 | for (Index2 = Index; Index2 < Number - 1; Index2++) {\r | |
241 | NewLegacyDev[Index2] = NewLegacyDev[Index2 + 1];\r | |
242 | }\r | |
243 | \r | |
244 | NewLegacyDev[Index2] = 0xFF;\r | |
245 | } else {\r | |
246 | for (Index2 = 0; Index2 < Number; Index2++) {\r | |
247 | if (Index2 == Index) {\r | |
248 | continue;\r | |
249 | }\r | |
250 | \r | |
251 | if (OldLegacyDev[Index2] == NewValue) {\r | |
252 | //\r | |
253 | // If NewValue is in OldLegacyDev array\r | |
254 | // remember its old position\r | |
255 | //\r | |
256 | NewValuePos = Index2;\r | |
257 | break;\r | |
258 | }\r | |
259 | }\r | |
260 | \r | |
261 | if (Index2 != Number) {\r | |
262 | //\r | |
263 | // We will change current item to an existing item\r | |
264 | // (It's hard to describe here, please read code, it's like a cycle-moving)\r | |
265 | //\r | |
266 | for (Index2 = NewValuePos; Index2 != Index;) {\r | |
267 | if (NewValuePos < Index) {\r | |
268 | NewLegacyDev[Index2] = OldLegacyDev[Index2 + 1];\r | |
269 | Index2++;\r | |
270 | } else {\r | |
271 | NewLegacyDev[Index2] = OldLegacyDev[Index2 - 1];\r | |
272 | Index2--;\r | |
273 | }\r | |
274 | }\r | |
275 | } else {\r | |
276 | //\r | |
277 | // If NewValue is not in OldlegacyDev array, we are changing to a disabled item\r | |
278 | // so we should modify DisMap to reflect the change\r | |
279 | //\r | |
280 | Pos = NewValue / 8;\r | |
281 | Bit = 7 - (NewValue % 8);\r | |
282 | DisMap[Pos] &= ~ (UINT8) (1 << Bit);\r | |
283 | if (0xFF != OldValue) {\r | |
284 | //\r | |
285 | // Because NewValue is a item that was disabled before\r | |
286 | // so after changing the OldValue should be disabled\r | |
287 | // actually we are doing a swap of enable-disable states of two items\r | |
288 | //\r | |
289 | Pos = OldValue / 8;\r | |
290 | Bit = 7 - (OldValue % 8);\r | |
291 | DisMap[Pos] |= (UINT8) (1 << Bit);\r | |
292 | }\r | |
293 | }\r | |
294 | }\r | |
295 | //\r | |
296 | // To prevent DISABLE appears in the middle of the list\r | |
297 | // we should perform a re-ordering\r | |
298 | //\r | |
299 | Index = 0;\r | |
300 | while (Index < Number) {\r | |
301 | if (0xFF != NewLegacyDev[Index]) {\r | |
302 | Index++;\r | |
303 | continue;\r | |
304 | }\r | |
305 | \r | |
306 | Index2 = Index;\r | |
307 | Index2++;\r | |
308 | while (Index2 < Number) {\r | |
309 | if (0xFF != NewLegacyDev[Index2]) {\r | |
310 | break;\r | |
311 | }\r | |
312 | \r | |
313 | Index2++;\r | |
314 | }\r | |
315 | \r | |
316 | if (Index2 < Number) {\r | |
317 | NewLegacyDev[Index] = NewLegacyDev[Index2];\r | |
318 | NewLegacyDev[Index2] = 0xFF;\r | |
319 | }\r | |
320 | \r | |
321 | Index++;\r | |
322 | }\r | |
323 | \r | |
324 | CopyMem (\r | |
325 | OldLegacyDev,\r | |
326 | NewLegacyDev,\r | |
327 | Number\r | |
328 | );\r | |
329 | }\r | |
330 | }\r | |
331 | \r | |
332 | if (KeyValue < FILE_OPTION_OFFSET) {\r | |
333 | if (KeyValue < NORMAL_GOTO_OFFSET) {\r | |
334 | switch (KeyValue) {\r | |
335 | case KEY_VALUE_BOOT_FROM_FILE:\r | |
336 | Private->FeCurrentState = BOOT_FROM_FILE_STATE;\r | |
337 | \r | |
338 | //\r | |
339 | // Exit Bmm main formset to send File Explorer formset.\r | |
340 | //\r | |
341 | CreateCallbackPacket (Packet, EXIT_REQUIRED);\r | |
342 | \r | |
343 | break;\r | |
344 | \r | |
345 | case FORM_BOOT_ADD_ID:\r | |
346 | Private->FeCurrentState = ADD_BOOT_OPTION_STATE;\r | |
347 | \r | |
348 | //\r | |
349 | // Exit Bmm main formset to send File Explorer formset.\r | |
350 | //\r | |
351 | CreateCallbackPacket (Packet, EXIT_REQUIRED);\r | |
352 | break;\r | |
353 | \r | |
354 | case FORM_DRV_ADD_FILE_ID:\r | |
355 | Private->FeCurrentState = ADD_DRIVER_OPTION_STATE;\r | |
356 | \r | |
357 | //\r | |
358 | // Exit Bmm main formset to send File Explorer formset.\r | |
359 | //\r | |
360 | CreateCallbackPacket (Packet, EXIT_REQUIRED);\r | |
361 | \r | |
362 | break;\r | |
363 | \r | |
364 | case FORM_DRV_ADD_HANDLE_ID:\r | |
365 | CleanUpPage (FORM_DRV_ADD_HANDLE_ID, Private);\r | |
366 | UpdateDrvAddHandlePage (Private);\r | |
367 | break;\r | |
368 | \r | |
369 | case FORM_BOOT_DEL_ID:\r | |
370 | CleanUpPage (FORM_BOOT_DEL_ID, Private);\r | |
371 | UpdateBootDelPage (Private);\r | |
372 | break;\r | |
373 | \r | |
374 | case FORM_BOOT_CHG_ID:\r | |
375 | case FORM_DRV_CHG_ID:\r | |
376 | UpdatePageBody (KeyValue, Private);\r | |
377 | break;\r | |
378 | \r | |
379 | case FORM_DRV_DEL_ID:\r | |
380 | CleanUpPage (FORM_DRV_DEL_ID, Private);\r | |
381 | UpdateDrvDelPage (Private);\r | |
382 | break;\r | |
383 | \r | |
384 | case FORM_BOOT_NEXT_ID:\r | |
385 | CleanUpPage (FORM_BOOT_NEXT_ID, Private);\r | |
386 | UpdateBootNextPage (Private);\r | |
387 | break;\r | |
388 | \r | |
389 | case FORM_TIME_OUT_ID:\r | |
390 | CleanUpPage (FORM_TIME_OUT_ID, Private);\r | |
391 | UpdateTimeOutPage (Private);\r | |
392 | break;\r | |
393 | \r | |
394 | case FORM_RESET:\r | |
395 | gRT->ResetSystem (EfiResetCold, EFI_SUCCESS, 0, NULL);\r | |
396 | return EFI_UNSUPPORTED;\r | |
397 | \r | |
398 | case FORM_CON_IN_ID:\r | |
399 | case FORM_CON_OUT_ID:\r | |
400 | case FORM_CON_ERR_ID:\r | |
401 | UpdatePageBody (KeyValue, Private);\r | |
402 | break;\r | |
403 | \r | |
404 | case FORM_CON_COM_ID:\r | |
405 | CleanUpPage (FORM_CON_COM_ID, Private);\r | |
406 | UpdateConCOMPage (Private);\r | |
407 | break;\r | |
408 | \r | |
409 | case FORM_SET_FD_ORDER_ID:\r | |
410 | case FORM_SET_HD_ORDER_ID:\r | |
411 | case FORM_SET_CD_ORDER_ID:\r | |
412 | case FORM_SET_NET_ORDER_ID:\r | |
413 | case FORM_SET_BEV_ORDER_ID:\r | |
414 | CleanUpPage (KeyValue, Private);\r | |
415 | UpdateSetLegacyDeviceOrderPage (KeyValue, Private);\r | |
416 | break;\r | |
417 | \r | |
418 | case KEY_VALUE_SAVE_AND_EXIT:\r | |
419 | case KEY_VALUE_NO_SAVE_AND_EXIT:\r | |
420 | \r | |
421 | if (KeyValue == KEY_VALUE_SAVE_AND_EXIT) {\r | |
422 | Status = ApplyChangeHandler (Private, CurrentFakeNVMap, Private->BmmPreviousPageId);\r | |
423 | if (EFI_ERROR (Status)) {\r | |
424 | return Status;\r | |
425 | }\r | |
426 | } else if (KeyValue == KEY_VALUE_NO_SAVE_AND_EXIT) {\r | |
427 | DiscardChangeHandler (Private, CurrentFakeNVMap);\r | |
428 | }\r | |
429 | //\r | |
430 | // Tell browser not to ask for confirmation of changes,\r | |
431 | // since we have already applied or discarded.\r | |
432 | //\r | |
433 | CreateCallbackPacket (Packet, NV_NOT_CHANGED);\r | |
434 | break;\r | |
435 | \r | |
436 | default:\r | |
437 | break;\r | |
438 | }\r | |
439 | } else if ((KeyValue >= TERMINAL_OPTION_OFFSET) && (KeyValue < CONSOLE_OPTION_OFFSET)) {\r | |
440 | Index2 = (UINT16) (KeyValue - TERMINAL_OPTION_OFFSET);\r | |
441 | Private->CurrentTerminal = Index2;\r | |
442 | \r | |
443 | CleanUpPage (FORM_CON_COM_SETUP_ID, Private);\r | |
444 | UpdateTerminalPage (Private);\r | |
445 | \r | |
446 | } else if (KeyValue >= HANDLE_OPTION_OFFSET) {\r | |
447 | Index2 = (UINT16) (KeyValue - HANDLE_OPTION_OFFSET);\r | |
448 | \r | |
449 | NewMenuEntry = BOpt_GetMenuEntry (&DriverMenu, Index2);\r | |
450 | ASSERT (NewMenuEntry != NULL);\r | |
451 | Private->HandleContext = (BM_HANDLE_CONTEXT *) NewMenuEntry->VariableContext;\r | |
452 | \r | |
453 | CleanUpPage (FORM_DRV_ADD_HANDLE_DESC_ID, Private);\r | |
454 | \r | |
455 | Private->MenuEntry = NewMenuEntry;\r | |
456 | Private->LoadContext->FilePathList = Private->HandleContext->DevicePath;\r | |
457 | \r | |
458 | UpdateDriverAddHandleDescPage (Private);\r | |
459 | }\r | |
460 | }\r | |
461 | \r | |
462 | return EFI_SUCCESS;\r | |
463 | }\r | |
464 | \r | |
465 | EFI_STATUS\r | |
466 | ApplyChangeHandler (\r | |
467 | IN BMM_CALLBACK_DATA *Private,\r | |
468 | IN BMM_FAKE_NV_DATA *CurrentFakeNVMap,\r | |
469 | IN FORM_ID FormId\r | |
470 | )\r | |
471 | /*++\r | |
472 | \r | |
473 | Routine Description:\r | |
474 | \r | |
475 | Function handling request to apply changes for BMM pages.\r | |
476 | \r | |
477 | Arguments:\r | |
478 | \r | |
479 | Private - Pointer to callback data buffer.\r | |
480 | CurrentFakeNVMap - Pointer to buffer holding data of various values used by BMM\r | |
481 | FormId - ID of the form which has sent the request to apply change.\r | |
482 | \r | |
483 | Returns:\r | |
484 | \r | |
485 | EFI_SUCCESS - Change successfully applied.\r | |
486 | Other - Error occurs while trying to apply changes.\r | |
487 | \r | |
488 | --*/\r | |
489 | {\r | |
490 | BM_CONSOLE_CONTEXT *NewConsoleContext;\r | |
491 | BM_TERMINAL_CONTEXT *NewTerminalContext;\r | |
492 | BM_LOAD_CONTEXT *NewLoadContext;\r | |
493 | BM_MENU_ENTRY *NewMenuEntry;\r | |
494 | EFI_STATUS Status;\r | |
495 | UINT16 Index;\r | |
496 | \r | |
497 | Status = EFI_SUCCESS;\r | |
498 | \r | |
499 | switch (FormId) {\r | |
500 | case FORM_SET_FD_ORDER_ID:\r | |
501 | case FORM_SET_HD_ORDER_ID:\r | |
502 | case FORM_SET_CD_ORDER_ID:\r | |
503 | case FORM_SET_NET_ORDER_ID:\r | |
504 | case FORM_SET_BEV_ORDER_ID:\r | |
505 | Var_UpdateBBSOption (Private);\r | |
506 | break;\r | |
507 | \r | |
508 | case FORM_BOOT_DEL_ID:\r | |
509 | for (Index = 0; Index < BootOptionMenu.MenuNumber; Index++) {\r | |
510 | NewMenuEntry = BOpt_GetMenuEntry (&BootOptionMenu, Index);\r | |
511 | NewLoadContext = (BM_LOAD_CONTEXT *) NewMenuEntry->VariableContext;\r | |
512 | NewLoadContext->Deleted = CurrentFakeNVMap->BootOptionDel[Index];\r | |
513 | }\r | |
514 | \r | |
515 | Var_DelBootOption ();\r | |
516 | break;\r | |
517 | \r | |
518 | case FORM_DRV_DEL_ID:\r | |
519 | for (Index = 0; Index < DriverOptionMenu.MenuNumber; Index++) {\r | |
520 | NewMenuEntry = BOpt_GetMenuEntry (&DriverOptionMenu, Index);\r | |
521 | NewLoadContext = (BM_LOAD_CONTEXT *) NewMenuEntry->VariableContext;\r | |
522 | NewLoadContext->Deleted = CurrentFakeNVMap->DriverOptionDel[Index];\r | |
523 | }\r | |
524 | \r | |
525 | Var_DelDriverOption ();\r | |
526 | break;\r | |
527 | \r | |
528 | case FORM_BOOT_CHG_ID:\r | |
529 | Status = Var_UpdateBootOrder (Private);\r | |
530 | break;\r | |
531 | \r | |
532 | case FORM_DRV_CHG_ID:\r | |
533 | Status = Var_UpdateDriverOrder (Private);\r | |
534 | break;\r | |
535 | \r | |
536 | case FORM_TIME_OUT_ID:\r | |
537 | Status = gRT->SetVariable (\r | |
538 | L"Timeout",\r | |
539 | &gEfiGlobalVariableGuid,\r | |
540 | VAR_FLAG,\r | |
541 | sizeof (UINT16),\r | |
542 | &(CurrentFakeNVMap->BootTimeOut)\r | |
543 | );\r | |
544 | if (EFI_ERROR (Status)) {\r | |
545 | goto Error;\r | |
546 | }\r | |
547 | \r | |
548 | Private->BmmOldFakeNVData.BootTimeOut = CurrentFakeNVMap->BootTimeOut;\r | |
549 | break;\r | |
550 | \r | |
551 | case FORM_BOOT_NEXT_ID:\r | |
552 | Status = Var_UpdateBootNext (Private);\r | |
553 | break;\r | |
554 | \r | |
555 | case FORM_CON_COM_ID:\r | |
556 | NewMenuEntry = BOpt_GetMenuEntry (&TerminalMenu, Private->CurrentTerminal);\r | |
557 | \r | |
558 | ASSERT (NewMenuEntry != NULL);\r | |
559 | \r | |
560 | NewTerminalContext = (BM_TERMINAL_CONTEXT *) NewMenuEntry->VariableContext;\r | |
561 | \r | |
562 | NewTerminalContext->BaudRateIndex = CurrentFakeNVMap->COMBaudRate;\r | |
563 | NewTerminalContext->BaudRate = BaudRateList[CurrentFakeNVMap->COMBaudRate].Value;\r | |
564 | NewTerminalContext->DataBitsIndex = CurrentFakeNVMap->COMDataRate;\r | |
565 | NewTerminalContext->DataBits = (UINT8) DataBitsList[CurrentFakeNVMap->COMDataRate].Value;\r | |
566 | NewTerminalContext->StopBitsIndex = CurrentFakeNVMap->COMStopBits;\r | |
567 | NewTerminalContext->StopBits = (UINT8) StopBitsList[CurrentFakeNVMap->COMStopBits].Value;\r | |
568 | NewTerminalContext->ParityIndex = CurrentFakeNVMap->COMParity;\r | |
569 | NewTerminalContext->Parity = (UINT8) ParityList[CurrentFakeNVMap->COMParity].Value;\r | |
570 | NewTerminalContext->TerminalType = CurrentFakeNVMap->COMTerminalType;\r | |
571 | \r | |
572 | ChangeTerminalDevicePath (\r | |
573 | NewTerminalContext->DevicePath,\r | |
574 | FALSE\r | |
575 | );\r | |
576 | \r | |
577 | Var_UpdateConsoleInpOption ();\r | |
578 | Var_UpdateConsoleOutOption ();\r | |
579 | Var_UpdateErrorOutOption ();\r | |
580 | break;\r | |
581 | \r | |
582 | case FORM_CON_IN_ID:\r | |
583 | for (Index = 0; Index < ConsoleInpMenu.MenuNumber; Index++) {\r | |
584 | NewMenuEntry = BOpt_GetMenuEntry (&ConsoleInpMenu, Index);\r | |
585 | NewConsoleContext = (BM_CONSOLE_CONTEXT *) NewMenuEntry->VariableContext;\r | |
586 | NewConsoleContext->IsActive = CurrentFakeNVMap->ConsoleCheck[Index];\r | |
587 | }\r | |
588 | \r | |
589 | for (Index = 0; Index < TerminalMenu.MenuNumber; Index++) {\r | |
590 | NewMenuEntry = BOpt_GetMenuEntry (&TerminalMenu, Index);\r | |
591 | NewTerminalContext = (BM_TERMINAL_CONTEXT *) NewMenuEntry->VariableContext;\r | |
592 | NewTerminalContext->IsConIn = CurrentFakeNVMap->ConsoleCheck[Index + ConsoleInpMenu.MenuNumber];\r | |
593 | }\r | |
594 | \r | |
595 | Var_UpdateConsoleInpOption ();\r | |
596 | break;\r | |
597 | \r | |
598 | case FORM_CON_OUT_ID:\r | |
599 | for (Index = 0; Index < ConsoleOutMenu.MenuNumber; Index++) {\r | |
600 | NewMenuEntry = BOpt_GetMenuEntry (&ConsoleOutMenu, Index);\r | |
601 | NewConsoleContext = (BM_CONSOLE_CONTEXT *) NewMenuEntry->VariableContext;\r | |
602 | NewConsoleContext->IsActive = CurrentFakeNVMap->ConsoleCheck[Index];\r | |
603 | }\r | |
604 | \r | |
605 | for (Index = 0; Index < TerminalMenu.MenuNumber; Index++) {\r | |
606 | NewMenuEntry = BOpt_GetMenuEntry (&TerminalMenu, Index);\r | |
607 | NewTerminalContext = (BM_TERMINAL_CONTEXT *) NewMenuEntry->VariableContext;\r | |
608 | NewTerminalContext->IsConOut = CurrentFakeNVMap->ConsoleCheck[Index + ConsoleOutMenu.MenuNumber];\r | |
609 | }\r | |
610 | \r | |
611 | Var_UpdateConsoleOutOption ();\r | |
612 | break;\r | |
613 | \r | |
614 | case FORM_CON_ERR_ID:\r | |
615 | for (Index = 0; Index < ConsoleErrMenu.MenuNumber; Index++) {\r | |
616 | NewMenuEntry = BOpt_GetMenuEntry (&ConsoleErrMenu, Index);\r | |
617 | NewConsoleContext = (BM_CONSOLE_CONTEXT *) NewMenuEntry->VariableContext;\r | |
618 | NewConsoleContext->IsActive = CurrentFakeNVMap->ConsoleCheck[Index];\r | |
619 | }\r | |
620 | \r | |
621 | for (Index = 0; Index < TerminalMenu.MenuNumber; Index++) {\r | |
622 | NewMenuEntry = BOpt_GetMenuEntry (&TerminalMenu, Index);\r | |
623 | NewTerminalContext = (BM_TERMINAL_CONTEXT *) NewMenuEntry->VariableContext;\r | |
624 | NewTerminalContext->IsStdErr = CurrentFakeNVMap->ConsoleCheck[Index + ConsoleErrMenu.MenuNumber];\r | |
625 | }\r | |
626 | \r | |
627 | Var_UpdateErrorOutOption ();\r | |
628 | break;\r | |
629 | \r | |
630 | case FORM_DRV_ADD_HANDLE_DESC_ID:\r | |
631 | Status = Var_UpdateDriverOption (\r | |
632 | Private,\r | |
633 | Private->BmmHiiHandle,\r | |
634 | CurrentFakeNVMap->DriverAddHandleDesc,\r | |
635 | CurrentFakeNVMap->DriverAddHandleOptionalData,\r | |
636 | CurrentFakeNVMap->DriverAddForceReconnect\r | |
637 | );\r | |
638 | if (EFI_ERROR (Status)) {\r | |
639 | goto Error;\r | |
640 | }\r | |
641 | \r | |
642 | BOpt_GetDriverOptions (Private);\r | |
643 | CreateMenuStringToken (Private, Private->BmmHiiHandle, &DriverOptionMenu);\r | |
644 | break;\r | |
645 | \r | |
646 | default:\r | |
647 | break;\r | |
648 | }\r | |
649 | \r | |
650 | Error:\r | |
651 | return Status;\r | |
652 | }\r | |
653 | \r | |
654 | VOID\r | |
655 | DiscardChangeHandler (\r | |
656 | IN BMM_CALLBACK_DATA *Private,\r | |
657 | IN BMM_FAKE_NV_DATA *CurrentFakeNVMap\r | |
658 | )\r | |
659 | {\r | |
660 | UINT16 Index;\r | |
661 | \r | |
662 | switch (Private->BmmPreviousPageId) {\r | |
663 | case FORM_BOOT_CHG_ID:\r | |
664 | case FORM_DRV_CHG_ID:\r | |
665 | CopyMem (CurrentFakeNVMap->OptionOrder, Private->BmmOldFakeNVData.OptionOrder, 100);\r | |
666 | break;\r | |
667 | \r | |
668 | case FORM_BOOT_DEL_ID:\r | |
669 | for (Index = 0; Index < BootOptionMenu.MenuNumber; Index++) {\r | |
670 | CurrentFakeNVMap->BootOptionDel[Index] = 0x00;\r | |
671 | }\r | |
672 | break;\r | |
673 | \r | |
674 | case FORM_DRV_DEL_ID:\r | |
675 | for (Index = 0; Index < DriverOptionMenu.MenuNumber; Index++) {\r | |
676 | CurrentFakeNVMap->DriverOptionDel[Index] = 0x00;\r | |
677 | }\r | |
678 | break;\r | |
679 | \r | |
680 | case FORM_BOOT_NEXT_ID:\r | |
681 | CurrentFakeNVMap->BootNext = Private->BmmOldFakeNVData.BootNext;\r | |
682 | break;\r | |
683 | \r | |
684 | case FORM_TIME_OUT_ID:\r | |
685 | CurrentFakeNVMap->BootTimeOut = Private->BmmOldFakeNVData.BootTimeOut;\r | |
686 | break;\r | |
687 | \r | |
688 | case FORM_DRV_ADD_HANDLE_DESC_ID:\r | |
689 | case FORM_DRV_ADD_FILE_ID:\r | |
690 | case FORM_DRV_ADD_HANDLE_ID:\r | |
691 | CurrentFakeNVMap->DriverAddHandleDesc[0] = 0x0000;\r | |
692 | CurrentFakeNVMap->DriverAddHandleOptionalData[0] = 0x0000;\r | |
693 | break;\r | |
694 | \r | |
695 | default:\r | |
696 | break;\r | |
697 | }\r | |
698 | }\r | |
699 | \r | |
700 | EFI_STATUS\r | |
701 | EFIAPI\r | |
702 | NvWrite (\r | |
703 | IN EFI_FORM_CALLBACK_PROTOCOL *This,\r | |
704 | IN CHAR16 *VariableName,\r | |
705 | IN EFI_GUID *VendorGuid,\r | |
706 | OUT UINT32 Attributes OPTIONAL,\r | |
707 | IN OUT UINTN DataSize,\r | |
708 | OUT VOID *Buffer,\r | |
709 | OUT BOOLEAN *ResetRequired\r | |
710 | )\r | |
711 | {\r | |
712 | //\r | |
713 | // Do nothing here. Just to catch the F10, we use "Apply Changes" tag to save.\r | |
714 | //\r | |
715 | return EFI_SUCCESS;\r | |
716 | }\r | |
717 | \r | |
718 | EFI_STATUS\r | |
719 | InitializeBM (\r | |
720 | VOID\r | |
721 | )\r | |
722 | /*++\r | |
723 | Routine Description:\r | |
724 | \r | |
725 | Initialize the Boot Maintenance Utitliy\r | |
726 | \r | |
727 | Arguments:\r | |
728 | \r | |
729 | ImageHandle - caller provided handle\r | |
730 | \r | |
731 | SystemTable - caller provided system tables\r | |
732 | \r | |
733 | Returns:\r | |
734 | \r | |
735 | EFI_SUCCESS - utility ended successfully\r | |
736 | \r | |
737 | others - contain some errors\r | |
738 | \r | |
739 | --*/\r | |
740 | {\r | |
741 | EFI_LEGACY_BIOS_PROTOCOL *LegacyBios;\r | |
742 | EFI_HII_PACKAGES *PackageList;\r | |
743 | BMM_CALLBACK_DATA *BmmCallbackInfo;\r | |
744 | EFI_HII_PROTOCOL *Hii;\r | |
5fd5fcd3 | 745 | FRAMEWORK_EFI_HII_HANDLE HiiHandle;\r |
bc11b829 | 746 | EFI_STATUS Status;\r |
747 | EFI_HANDLE Handle;\r | |
748 | UINT8 *Ptr;\r | |
749 | UINT8 *Location;\r | |
750 | \r | |
751 | Status = EFI_SUCCESS;\r | |
752 | UpdateData = NULL;\r | |
753 | //\r | |
754 | // Initialize EfiUtilityLib and EfiDriverLib\r | |
755 | // Since many functions in UtilityLib must be used and\r | |
756 | // SetupBrowser use DriverLib\r | |
757 | //\r | |
758 | //\r | |
759 | // There should be only one EFI_HII_PROTOCOL Image\r | |
760 | //\r | |
761 | Status = EfiLibLocateProtocol (&gEfiHiiProtocolGuid, &Hii);\r | |
762 | if (EFI_ERROR (Status)) {\r | |
763 | return Status;\r | |
764 | }\r | |
765 | //\r | |
766 | // Create CallbackData structures for Driver Callback\r | |
767 | //\r | |
768 | BmmCallbackInfo = AllocateZeroPool (sizeof (BMM_CALLBACK_DATA));\r | |
769 | if (!BmmCallbackInfo) {\r | |
770 | return EFI_OUT_OF_RESOURCES;\r | |
771 | }\r | |
772 | //\r | |
773 | // Create LoadOption in BmmCallbackInfo for Driver Callback\r | |
774 | //\r | |
775 | Ptr = AllocateZeroPool (sizeof (BM_LOAD_CONTEXT) + sizeof (BM_FILE_CONTEXT) + sizeof (BM_HANDLE_CONTEXT) + sizeof (BM_MENU_ENTRY));\r | |
776 | if (!Ptr) {\r | |
777 | SafeFreePool (BmmCallbackInfo);\r | |
778 | return EFI_OUT_OF_RESOURCES;\r | |
779 | }\r | |
780 | //\r | |
781 | // Initialize Bmm callback data.\r | |
782 | //\r | |
783 | BmmCallbackInfo->LoadContext = (BM_LOAD_CONTEXT *) Ptr;\r | |
784 | Ptr += sizeof (BM_LOAD_CONTEXT);\r | |
785 | \r | |
786 | BmmCallbackInfo->FileContext = (BM_FILE_CONTEXT *) Ptr;\r | |
787 | Ptr += sizeof (BM_FILE_CONTEXT);\r | |
788 | \r | |
789 | BmmCallbackInfo->HandleContext = (BM_HANDLE_CONTEXT *) Ptr;\r | |
790 | Ptr += sizeof (BM_HANDLE_CONTEXT);\r | |
791 | \r | |
792 | BmmCallbackInfo->MenuEntry = (BM_MENU_ENTRY *) Ptr;\r | |
793 | \r | |
794 | BmmCallbackInfo->BmmFakeNvData = &BmmCallbackInfo->BmmOldFakeNVData;\r | |
795 | \r | |
796 | ZeroMem (BmmCallbackInfo->BmmFakeNvData, sizeof (BMM_FAKE_NV_DATA));\r | |
797 | \r | |
798 | BmmCallbackInfo->Signature = BMM_CALLBACK_DATA_SIGNATURE;\r | |
799 | BmmCallbackInfo->Hii = Hii;\r | |
800 | BmmCallbackInfo->BmmDriverCallback.NvRead = NULL;\r | |
801 | BmmCallbackInfo->BmmDriverCallback.NvWrite = NvWrite;\r | |
802 | BmmCallbackInfo->BmmDriverCallback.Callback = DriverCallback;\r | |
803 | BmmCallbackInfo->BmmPreviousPageId = FORM_MAIN_ID;\r | |
804 | BmmCallbackInfo->BmmCurrentPageId = FORM_MAIN_ID;\r | |
805 | BmmCallbackInfo->FeDriverCallback.NvRead = NULL;\r | |
806 | BmmCallbackInfo->FeDriverCallback.NvWrite = NvWrite;\r | |
807 | BmmCallbackInfo->FeDriverCallback.Callback = FileExplorerCallback;\r | |
808 | BmmCallbackInfo->FeCurrentState = INACTIVE_STATE;\r | |
809 | BmmCallbackInfo->FeDisplayContext = UNKNOWN_CONTEXT;\r | |
810 | \r | |
811 | //\r | |
812 | // Install bmm callback protocol interface\r | |
813 | //\r | |
814 | Handle = NULL;\r | |
815 | Status = gBS->InstallProtocolInterface (\r | |
816 | &Handle,\r | |
817 | &gEfiFormCallbackProtocolGuid,\r | |
818 | EFI_NATIVE_INTERFACE,\r | |
819 | &BmmCallbackInfo->BmmDriverCallback\r | |
820 | );\r | |
821 | \r | |
822 | if (EFI_ERROR (Status)) {\r | |
823 | return Status;\r | |
824 | }\r | |
825 | \r | |
826 | BmmCallbackInfo->BmmCallbackHandle = Handle;\r | |
827 | \r | |
828 | //\r | |
829 | // Install file explorer callback protocol interface\r | |
830 | //\r | |
831 | Handle = NULL;\r | |
832 | Status = gBS->InstallProtocolInterface (\r | |
833 | &Handle,\r | |
834 | &gEfiFormCallbackProtocolGuid,\r | |
835 | EFI_NATIVE_INTERFACE,\r | |
836 | &BmmCallbackInfo->FeDriverCallback\r | |
837 | );\r | |
838 | \r | |
839 | if (EFI_ERROR (Status)) {\r | |
840 | return Status;\r | |
841 | }\r | |
842 | \r | |
843 | BmmCallbackInfo->FeCallbackHandle = Handle;\r | |
844 | \r | |
845 | //\r | |
846 | // Post our VFR to the HII database.\r | |
847 | //\r | |
d1477e4d | 848 | PackageList = PreparePackages (1, &gEfiCallerIdGuid, bmBin);\r |
bc11b829 | 849 | Status = Hii->NewPack (Hii, PackageList, &HiiHandle);\r |
850 | FreePool (PackageList);\r | |
851 | \r | |
852 | BmmCallbackInfo->BmmHiiHandle = HiiHandle;\r | |
853 | \r | |
d1477e4d | 854 | PackageList = PreparePackages (1, &gEfiCallerIdGuid, FEBin);\r |
bc11b829 | 855 | Status = Hii->NewPack (Hii, PackageList, &HiiHandle);\r |
856 | FreePool (PackageList);\r | |
857 | \r | |
858 | BmmCallbackInfo->FeHiiHandle = HiiHandle;\r | |
859 | \r | |
860 | //\r | |
861 | // Allocate space for creation of Buffer\r | |
862 | //\r | |
863 | UpdateData = AllocateZeroPool (UPDATE_DATA_SIZE);\r | |
864 | if (!UpdateData) {\r | |
865 | SafeFreePool (BmmCallbackInfo->LoadContext);\r | |
866 | SafeFreePool (BmmCallbackInfo);\r | |
867 | return EFI_OUT_OF_RESOURCES;\r | |
868 | }\r | |
869 | //\r | |
870 | // Initialize UpdateData structure\r | |
871 | //\r | |
872 | RefreshUpdateData (TRUE, (EFI_PHYSICAL_ADDRESS) (UINTN) BmmCallbackInfo->BmmCallbackHandle, FALSE, 0, 0);\r | |
873 | \r | |
874 | Location = (UINT8 *) &UpdateData->Data;\r | |
875 | \r | |
876 | InitializeStringDepository ();\r | |
877 | \r | |
878 | InitAllMenu (BmmCallbackInfo);\r | |
879 | \r | |
880 | CreateMenuStringToken (BmmCallbackInfo, BmmCallbackInfo->BmmHiiHandle, &ConsoleInpMenu);\r | |
881 | CreateMenuStringToken (BmmCallbackInfo, BmmCallbackInfo->BmmHiiHandle, &ConsoleOutMenu);\r | |
882 | CreateMenuStringToken (BmmCallbackInfo, BmmCallbackInfo->BmmHiiHandle, &ConsoleErrMenu);\r | |
883 | CreateMenuStringToken (BmmCallbackInfo, BmmCallbackInfo->BmmHiiHandle, &BootOptionMenu);\r | |
884 | CreateMenuStringToken (BmmCallbackInfo, BmmCallbackInfo->BmmHiiHandle, &DriverOptionMenu);\r | |
885 | CreateMenuStringToken (BmmCallbackInfo, BmmCallbackInfo->BmmHiiHandle, &TerminalMenu);\r | |
886 | CreateMenuStringToken (BmmCallbackInfo, BmmCallbackInfo->BmmHiiHandle, &DriverMenu);\r | |
887 | \r | |
888 | UpdateBootDelPage (BmmCallbackInfo);\r | |
889 | UpdateDrvDelPage (BmmCallbackInfo);\r | |
890 | \r | |
891 | if (TerminalMenu.MenuNumber > 0) {\r | |
892 | BmmCallbackInfo->CurrentTerminal = 0;\r | |
893 | UpdateTerminalPage (BmmCallbackInfo);\r | |
894 | }\r | |
895 | \r | |
896 | Location = (UINT8 *) &UpdateData->Data;\r | |
897 | Status = EfiLibLocateProtocol (&gEfiLegacyBiosProtocolGuid, &LegacyBios);\r | |
898 | if (!EFI_ERROR (Status)) {\r | |
899 | //\r | |
900 | // If LegacyBios Protocol is installed, add 3 tags about legacy boot option\r | |
901 | // in BootOption form: legacy FD/HD/CD/NET/BEV\r | |
902 | //\r | |
903 | UpdateData->DataCount = 5;\r | |
904 | CreateGotoOpCode (\r | |
905 | FORM_SET_FD_ORDER_ID,\r | |
906 | STRING_TOKEN (STR_FORM_SET_FD_ORDER_TITLE),\r | |
907 | STRING_TOKEN (STR_FORM_SET_FD_ORDER_TITLE),\r | |
5fd5fcd3 | 908 | FRAMEWORK_EFI_IFR_FLAG_INTERACTIVE | FRAMEWORK_EFI_IFR_FLAG_NV_ACCESS,\r |
bc11b829 | 909 | FORM_SET_FD_ORDER_ID,\r |
910 | Location\r | |
911 | );\r | |
912 | \r | |
5fd5fcd3 | 913 | Location = Location + ((FRAMEWORK_EFI_IFR_OP_HEADER *) Location)->Length;\r |
bc11b829 | 914 | \r |
915 | CreateGotoOpCode (\r | |
916 | FORM_SET_HD_ORDER_ID,\r | |
917 | STRING_TOKEN (STR_FORM_SET_HD_ORDER_TITLE),\r | |
918 | STRING_TOKEN (STR_FORM_SET_HD_ORDER_TITLE),\r | |
5fd5fcd3 | 919 | FRAMEWORK_EFI_IFR_FLAG_INTERACTIVE | FRAMEWORK_EFI_IFR_FLAG_NV_ACCESS,\r |
bc11b829 | 920 | FORM_SET_HD_ORDER_ID,\r |
921 | Location\r | |
922 | );\r | |
923 | \r | |
5fd5fcd3 | 924 | Location = Location + ((FRAMEWORK_EFI_IFR_OP_HEADER *) Location)->Length;\r |
bc11b829 | 925 | \r |
926 | CreateGotoOpCode (\r | |
927 | FORM_SET_CD_ORDER_ID,\r | |
928 | STRING_TOKEN (STR_FORM_SET_CD_ORDER_TITLE),\r | |
929 | STRING_TOKEN (STR_FORM_SET_CD_ORDER_TITLE),\r | |
5fd5fcd3 | 930 | FRAMEWORK_EFI_IFR_FLAG_INTERACTIVE | FRAMEWORK_EFI_IFR_FLAG_NV_ACCESS,\r |
bc11b829 | 931 | FORM_SET_CD_ORDER_ID,\r |
932 | Location\r | |
933 | );\r | |
934 | \r | |
5fd5fcd3 | 935 | Location = Location + ((FRAMEWORK_EFI_IFR_OP_HEADER *) Location)->Length;\r |
bc11b829 | 936 | \r |
937 | CreateGotoOpCode (\r | |
938 | FORM_SET_NET_ORDER_ID,\r | |
939 | STRING_TOKEN (STR_FORM_SET_NET_ORDER_TITLE),\r | |
940 | STRING_TOKEN (STR_FORM_SET_NET_ORDER_TITLE),\r | |
5fd5fcd3 | 941 | FRAMEWORK_EFI_IFR_FLAG_INTERACTIVE | FRAMEWORK_EFI_IFR_FLAG_NV_ACCESS,\r |
bc11b829 | 942 | FORM_SET_NET_ORDER_ID,\r |
943 | Location\r | |
944 | );\r | |
945 | \r | |
5fd5fcd3 | 946 | Location = Location + ((FRAMEWORK_EFI_IFR_OP_HEADER *) Location)->Length;\r |
bc11b829 | 947 | \r |
948 | CreateGotoOpCode (\r | |
949 | FORM_SET_BEV_ORDER_ID,\r | |
950 | STRING_TOKEN (STR_FORM_SET_BEV_ORDER_TITLE),\r | |
951 | STRING_TOKEN (STR_FORM_SET_BEV_ORDER_TITLE),\r | |
5fd5fcd3 | 952 | FRAMEWORK_EFI_IFR_FLAG_INTERACTIVE | FRAMEWORK_EFI_IFR_FLAG_NV_ACCESS,\r |
bc11b829 | 953 | FORM_SET_BEV_ORDER_ID,\r |
954 | Location\r | |
955 | );\r | |
956 | \r | |
957 | Hii->UpdateForm (\r | |
958 | Hii,\r | |
959 | BmmCallbackInfo->BmmHiiHandle,\r | |
960 | (EFI_FORM_LABEL) FORM_BOOT_LEGACY_DEVICE_ID,\r | |
961 | TRUE,\r | |
962 | UpdateData\r | |
963 | );\r | |
964 | }\r | |
965 | //\r | |
966 | // Dispatch BMM main formset and File Explorer formset.\r | |
967 | //\r | |
968 | FormSetDispatcher (BmmCallbackInfo);\r | |
969 | \r | |
970 | Hii->ResetStrings (Hii, HiiHandle);\r | |
971 | \r | |
972 | CleanUpStringDepository ();\r | |
973 | \r | |
974 | if (EFI_ERROR (Status)) {\r | |
975 | return Status;\r | |
976 | }\r | |
977 | \r | |
978 | FreeAllMenu ();\r | |
979 | \r | |
980 | SafeFreePool (BmmCallbackInfo->LoadContext);\r | |
981 | BmmCallbackInfo->LoadContext = NULL;\r | |
982 | SafeFreePool (BmmCallbackInfo);\r | |
983 | BmmCallbackInfo = NULL;\r | |
984 | SafeFreePool (UpdateData);\r | |
985 | UpdateData = NULL;\r | |
986 | \r | |
987 | return Status;\r | |
988 | }\r | |
989 | \r | |
990 | VOID\r | |
991 | InitAllMenu (\r | |
992 | IN BMM_CALLBACK_DATA *CallbackData\r | |
993 | )\r | |
994 | {\r | |
995 | InitializeListHead (&BootOptionMenu.Head);\r | |
996 | InitializeListHead (&DriverOptionMenu.Head);\r | |
997 | BOpt_GetBootOptions (CallbackData);\r | |
998 | BOpt_GetDriverOptions (CallbackData);\r | |
999 | BOpt_GetLegacyOptions ();\r | |
1000 | InitializeListHead (&FsOptionMenu.Head);\r | |
1001 | BOpt_FindDrivers ();\r | |
1002 | InitializeListHead (&DirectoryMenu.Head);\r | |
1003 | InitializeListHead (&ConsoleInpMenu.Head);\r | |
1004 | InitializeListHead (&ConsoleOutMenu.Head);\r | |
1005 | InitializeListHead (&ConsoleErrMenu.Head);\r | |
1006 | InitializeListHead (&TerminalMenu.Head);\r | |
1007 | LocateSerialIo ();\r | |
1008 | GetAllConsoles ();\r | |
1009 | }\r | |
1010 | \r | |
1011 | VOID\r | |
1012 | FreeAllMenu (\r | |
1013 | VOID\r | |
1014 | )\r | |
1015 | {\r | |
1016 | BOpt_FreeMenu (&DirectoryMenu);\r | |
1017 | BOpt_FreeMenu (&FsOptionMenu);\r | |
1018 | BOpt_FreeMenu (&BootOptionMenu);\r | |
1019 | BOpt_FreeMenu (&DriverOptionMenu);\r | |
1020 | BOpt_FreeMenu (&DriverMenu);\r | |
1021 | BOpt_FreeLegacyOptions ();\r | |
1022 | FreeAllConsoles ();\r | |
1023 | }\r | |
1024 | \r | |
1025 | VOID\r | |
1026 | InitializeStringDepository (\r | |
1027 | VOID\r | |
1028 | )\r | |
1029 | /*++\r | |
1030 | Routine Description:\r | |
1031 | Intialize all the string depositories.\r | |
1032 | \r | |
1033 | Arguments:\r | |
1034 | None.\r | |
1035 | \r | |
1036 | Returns:\r | |
1037 | None.\r | |
1038 | --*/\r | |
1039 | {\r | |
1040 | STRING_DEPOSITORY *StringDepository;\r | |
1041 | StringDepository = AllocateZeroPool (sizeof (STRING_DEPOSITORY) * STRING_DEPOSITORY_NUMBER);\r | |
1042 | FileOptionStrDepository = StringDepository++;\r | |
1043 | ConsoleOptionStrDepository = StringDepository++;\r | |
1044 | BootOptionStrDepository = StringDepository++;\r | |
1045 | BootOptionHelpStrDepository = StringDepository++;\r | |
1046 | DriverOptionStrDepository = StringDepository++;\r | |
1047 | DriverOptionHelpStrDepository = StringDepository++;\r | |
1048 | TerminalStrDepository = StringDepository;\r | |
1049 | }\r | |
1050 | \r | |
1051 | STRING_REF\r | |
1052 | GetStringTokenFromDepository (\r | |
1053 | IN BMM_CALLBACK_DATA *CallbackData,\r | |
1054 | IN STRING_DEPOSITORY *StringDepository\r | |
1055 | )\r | |
1056 | /*++\r | |
1057 | Routine Description:\r | |
1058 | Fetch a usable string node from the string depository and return the string token.\r | |
1059 | \r | |
1060 | Arguments:\r | |
1061 | StringDepository - Pointer of the string depository.\r | |
1062 | \r | |
1063 | Returns:\r | |
1064 | STRING_REF - String token.\r | |
1065 | --*/\r | |
1066 | {\r | |
1067 | STRING_LIST_NODE *CurrentListNode;\r | |
1068 | STRING_LIST_NODE *NextListNode;\r | |
1069 | \r | |
1070 | CurrentListNode = StringDepository->CurrentNode;\r | |
1071 | \r | |
1072 | if ((NULL != CurrentListNode) && (NULL != CurrentListNode->Next)) {\r | |
1073 | //\r | |
1074 | // Fetch one reclaimed node from the list.\r | |
1075 | //\r | |
1076 | NextListNode = StringDepository->CurrentNode->Next;\r | |
1077 | } else {\r | |
1078 | //\r | |
1079 | // If there is no usable node in the list, update the list.\r | |
1080 | //\r | |
1081 | NextListNode = AllocateZeroPool (sizeof (STRING_LIST_NODE));\r | |
1082 | \r | |
1083 | CallbackData->Hii->NewString (\r | |
1084 | CallbackData->Hii,\r | |
1085 | NULL,\r | |
1086 | CallbackData->BmmHiiHandle,\r | |
1087 | &(NextListNode->StringToken),\r | |
1088 | L" "\r | |
1089 | );\r | |
1090 | \r | |
1091 | ASSERT (NextListNode->StringToken != 0);\r | |
1092 | \r | |
1093 | StringDepository->TotalNodeNumber++;\r | |
1094 | \r | |
1095 | if (NULL == CurrentListNode) {\r | |
1096 | StringDepository->ListHead = NextListNode;\r | |
1097 | } else {\r | |
1098 | CurrentListNode->Next = NextListNode;\r | |
1099 | }\r | |
1100 | }\r | |
1101 | \r | |
1102 | StringDepository->CurrentNode = NextListNode;\r | |
1103 | \r | |
1104 | return StringDepository->CurrentNode->StringToken;\r | |
1105 | }\r | |
1106 | \r | |
1107 | VOID\r | |
1108 | ReclaimStringDepository (\r | |
1109 | VOID\r | |
1110 | )\r | |
1111 | /*++\r | |
1112 | Routine Description:\r | |
1113 | Reclaim string depositories by moving the current node pointer to list head..\r | |
1114 | \r | |
1115 | Arguments:\r | |
1116 | None.\r | |
1117 | \r | |
1118 | Returns:\r | |
1119 | None.\r | |
1120 | --*/\r | |
1121 | {\r | |
1122 | UINTN DepositoryIndex;\r | |
1123 | STRING_DEPOSITORY *StringDepository;\r | |
1124 | \r | |
1125 | StringDepository = FileOptionStrDepository;\r | |
1126 | for (DepositoryIndex = 0; DepositoryIndex < STRING_DEPOSITORY_NUMBER; DepositoryIndex++) {\r | |
1127 | StringDepository->CurrentNode = StringDepository->ListHead;\r | |
1128 | StringDepository++;\r | |
1129 | }\r | |
1130 | }\r | |
1131 | \r | |
1132 | VOID\r | |
1133 | CleanUpStringDepository (\r | |
1134 | VOID\r | |
1135 | )\r | |
1136 | /*++\r | |
1137 | Routine Description:\r | |
1138 | Release resource for all the string depositories.\r | |
1139 | \r | |
1140 | Arguments:\r | |
1141 | None.\r | |
1142 | \r | |
1143 | Returns:\r | |
1144 | None.\r | |
1145 | --*/\r | |
1146 | {\r | |
1147 | UINTN NodeIndex;\r | |
1148 | UINTN DepositoryIndex;\r | |
1149 | STRING_LIST_NODE *CurrentListNode;\r | |
1150 | STRING_LIST_NODE *NextListNode;\r | |
1151 | STRING_DEPOSITORY *StringDepository;\r | |
1152 | \r | |
1153 | //\r | |
1154 | // Release string list nodes.\r | |
1155 | //\r | |
1156 | StringDepository = FileOptionStrDepository;\r | |
1157 | for (DepositoryIndex = 0; DepositoryIndex < STRING_DEPOSITORY_NUMBER; DepositoryIndex++) {\r | |
1158 | CurrentListNode = StringDepository->ListHead;\r | |
1159 | for (NodeIndex = 0; NodeIndex < StringDepository->TotalNodeNumber; NodeIndex++) {\r | |
1160 | NextListNode = CurrentListNode->Next;\r | |
1161 | SafeFreePool (CurrentListNode);\r | |
1162 | CurrentListNode = NextListNode;\r | |
1163 | }\r | |
1164 | \r | |
1165 | StringDepository++;\r | |
1166 | }\r | |
1167 | //\r | |
1168 | // Release string depository.\r | |
1169 | //\r | |
1170 | SafeFreePool (FileOptionStrDepository);\r | |
1171 | }\r | |
1172 | \r | |
1173 | EFI_STATUS\r | |
1174 | BdsStartBootMaint (\r | |
1175 | VOID\r | |
1176 | )\r | |
1177 | /*++\r | |
1178 | \r | |
1179 | Routine Description:\r | |
1180 | Start boot maintenance manager\r | |
1181 | \r | |
1182 | Arguments:\r | |
1183 | \r | |
1184 | Returns:\r | |
1185 | \r | |
1186 | --*/\r | |
1187 | {\r | |
1188 | EFI_STATUS Status;\r | |
1189 | LIST_ENTRY BdsBootOptionList;\r | |
1190 | \r | |
1191 | InitializeListHead (&BdsBootOptionList);\r | |
1192 | \r | |
1193 | //\r | |
1194 | // Connect all prior to entering the platform setup menu.\r | |
1195 | //\r | |
1196 | if (!gConnectAllHappened) {\r | |
1197 | BdsLibConnectAllDriversToAllControllers ();\r | |
1198 | gConnectAllHappened = TRUE;\r | |
1199 | }\r | |
1200 | //\r | |
1201 | // Have chance to enumerate boot device\r | |
1202 | //\r | |
1203 | BdsLibEnumerateAllBootOption (&BdsBootOptionList);\r | |
1204 | \r | |
1205 | //\r | |
1206 | // Init the BMM\r | |
1207 | //\r | |
1208 | Status = InitializeBM ();\r | |
1209 | \r | |
1210 | return Status;\r | |
1211 | }\r | |
1212 | \r | |
1213 | EFI_STATUS\r | |
1214 | FormSetDispatcher (\r | |
1215 | IN BMM_CALLBACK_DATA *CallbackData\r | |
1216 | )\r | |
1217 | /*++\r | |
1218 | \r | |
1219 | Routine Description:\r | |
1220 | Dispatch BMM formset and FileExplorer formset.\r | |
1221 | \r | |
1222 | Arguments:\r | |
1223 | \r | |
1224 | Returns:\r | |
1225 | \r | |
1226 | --*/\r | |
1227 | {\r | |
1228 | EFI_FORM_BROWSER_PROTOCOL *FormConfig;\r | |
1229 | UINT8 *Location;\r | |
1230 | EFI_STATUS Status;\r | |
1231 | UINTN Index;\r | |
1232 | BM_MENU_ENTRY *NewMenuEntry;\r | |
1233 | BM_FILE_CONTEXT *NewFileContext;\r | |
1234 | BOOLEAN BootMaintMenuResetRequired;\r | |
1235 | \r | |
1236 | Location = NULL;\r | |
1237 | Index = 0;\r | |
1238 | NewMenuEntry = NULL;\r | |
1239 | NewFileContext = NULL;\r | |
1240 | \r | |
1241 | //\r | |
1242 | // There should only be one Form Configuration protocol\r | |
1243 | //\r | |
1244 | Status = EfiLibLocateProtocol (&gEfiFormBrowserProtocolGuid, &FormConfig);\r | |
1245 | if (EFI_ERROR (Status)) {\r | |
1246 | return Status;\r | |
1247 | }\r | |
1248 | \r | |
1249 | while (1) {\r | |
1250 | UpdatePageId (CallbackData, FORM_MAIN_ID);\r | |
1251 | \r | |
1252 | BootMaintMenuResetRequired = FALSE;\r | |
1253 | Status = FormConfig->SendForm (\r | |
1254 | FormConfig,\r | |
1255 | TRUE,\r | |
1256 | &(CallbackData->BmmHiiHandle),\r | |
1257 | 1,\r | |
1258 | NULL,\r | |
1259 | NULL,\r | |
1260 | (UINT8 *) CallbackData->BmmFakeNvData,\r | |
1261 | NULL,\r | |
1262 | &BootMaintMenuResetRequired\r | |
1263 | );\r | |
1264 | \r | |
1265 | if (BootMaintMenuResetRequired) {\r | |
1266 | EnableResetRequired ();\r | |
1267 | }\r | |
1268 | \r | |
1269 | ReclaimStringDepository ();\r | |
1270 | \r | |
1271 | //\r | |
1272 | // When this Formset returns, check if we are going to explore files.\r | |
1273 | //\r | |
1274 | if (INACTIVE_STATE != CallbackData->FeCurrentState) {\r | |
1275 | UpdateFileExplorer (CallbackData, 0);\r | |
1276 | \r | |
1277 | BootMaintMenuResetRequired = FALSE;\r | |
1278 | Status = FormConfig->SendForm (\r | |
1279 | FormConfig,\r | |
1280 | TRUE,\r | |
1281 | &(CallbackData->FeHiiHandle),\r | |
1282 | 1,\r | |
1283 | NULL,\r | |
1284 | NULL,\r | |
1285 | NULL,\r | |
1286 | NULL,\r | |
1287 | &BootMaintMenuResetRequired\r | |
1288 | );\r | |
1289 | \r | |
1290 | if (BootMaintMenuResetRequired) {\r | |
1291 | EnableResetRequired ();\r | |
1292 | }\r | |
1293 | \r | |
1294 | CallbackData->FeCurrentState = INACTIVE_STATE;\r | |
1295 | CallbackData->FeDisplayContext = UNKNOWN_CONTEXT;\r | |
1296 | ReclaimStringDepository ();\r | |
1297 | } else {\r | |
1298 | break;\r | |
1299 | }\r | |
1300 | }\r | |
1301 | \r | |
1302 | return Status;\r | |
1303 | }\r | |
1304 | \r | |
1305 | VOID\r | |
1306 | CreateCallbackPacket (\r | |
1307 | OUT EFI_HII_CALLBACK_PACKET **Packet,\r | |
1308 | IN UINT16 Flags\r | |
1309 | )\r | |
1310 | {\r | |
1311 | *Packet = (EFI_HII_CALLBACK_PACKET *) AllocateZeroPool (sizeof (EFI_HII_CALLBACK_PACKET) + 2);\r | |
1312 | ASSERT (*Packet != NULL);\r | |
1313 | \r | |
1314 | (*Packet)->DataArray.EntryCount = 1;\r | |
1315 | (*Packet)->DataArray.NvRamMap = NULL;\r | |
5fd5fcd3 | 1316 | ((FRAMEWORK_EFI_IFR_DATA_ENTRY *) (&((*Packet)->DataArray) + 1))->Flags = Flags;\r |
bc11b829 | 1317 | }\r |