Fix the inconsistent guid for terminal driver which is used in GeneralBds libary.
[mirror_edk2.git] / EdkModulePkg / Library / EdkGenericPlatformBdsLib / BootMaint / UpdatePage.c
CommitLineData
9035a497 1/**@file\r
2 Dynamically Update the pages.\r
3 \r
4Copyright (c) 2006 - 2007 Intel Corporation.\r
52657feb 5All rights reserved. This program and the accompanying materials \r
6are licensed and made available under the terms and conditions of the BSD License \r
7which accompanies this distribution. The full text of the license may be found at \r
8http://opensource.org/licenses/bsd-license.php \r
9 \r
10THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, \r
11WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. \r
12\r
9035a497 13**/\r
52657feb 14\r
15#include "Bds.h"\r
16#include "BootMaint.h"\r
17\r
18EFI_GUID gTerminalDriverGuid = {\r
9035a497 19 0x9E863906, 0xA40F, 0x4875, {0x97, 0x7F, 0x5B, 0x93, 0xFF, 0x23, 0x7F, 0xC6}\r
52657feb 20};\r
21\r
22VOID\r
23RefreshUpdateData (\r
24 IN BOOLEAN FormSetUpdate,\r
25 IN EFI_PHYSICAL_ADDRESS FormCallbackHandle,\r
26 IN BOOLEAN FormUpdate,\r
27 IN STRING_REF FormTitle,\r
28 IN UINT16 DataCount\r
29 )\r
30/*++\r
31Routine Description:\r
32 Refresh the global UpdateData structure.\r
33\r
34Arguments:\r
35 FormSetUpdate - If TRUE, next variable is significant\r
36 FormCallbackHandle - If not 0, will update FormSet with this info\r
37 FormUpdate - If TRUE, next variable is significant\r
38 FormTitle - If not 0, will update Form with this info\r
39 DataCount - The number of Data entries in this structure\r
40\r
41Returns:\r
42 None.\r
43--*/\r
44{\r
45 UpdateData->FormSetUpdate = FormSetUpdate;\r
46 if (FormSetUpdate) {\r
47 ASSERT (0 != FormCallbackHandle);\r
48 UpdateData->FormCallbackHandle = FormCallbackHandle;\r
49 }\r
50\r
51 UpdateData->FormUpdate = FALSE;\r
52 UpdateData->FormTitle = FormTitle;\r
53 UpdateData->DataCount = DataCount;\r
54}\r
55\r
56VOID\r
57UpdatePageStart (\r
58 IN BMM_CALLBACK_DATA *CallbackData,\r
59 IN OUT UINT8 **CurrentLocation\r
60 )\r
61{\r
62 RefreshUpdateData (TRUE, (EFI_PHYSICAL_ADDRESS) (UINTN) CallbackData->BmmCallbackHandle, FALSE, 0, 0);\r
63\r
64 if (!(CallbackData->BmmAskSaveOrNot)) {\r
65 //\r
66 // Add a "Go back to main page" tag in front of the form when there are no\r
67 // "Apply changes" and "Discard changes" tags in the end of the form.\r
68 //\r
69 CreateGotoOpCode (\r
70 FORM_MAIN_ID,\r
71 STRING_TOKEN (STR_FORM_GOTO_MAIN),\r
72 STRING_TOKEN (STR_FORM_GOTO_MAIN),\r
73 EFI_IFR_FLAG_INTERACTIVE | EFI_IFR_FLAG_NV_ACCESS,\r
74 FORM_MAIN_ID,\r
75 *CurrentLocation\r
76 );\r
77\r
78 UpdateData->DataCount++;\r
79\r
80 *CurrentLocation = *CurrentLocation + ((EFI_IFR_OP_HEADER *) (*CurrentLocation))->Length;\r
81 }\r
82\r
83}\r
84\r
85VOID\r
86UpdatePageEnd (\r
87 IN BMM_CALLBACK_DATA *CallbackData,\r
88 IN UINT8 *CurrentLocation\r
89 )\r
90{\r
91 //\r
92 // Create the "Apply changes" and "Discard changes" tags.\r
93 //\r
94 if (CallbackData->BmmAskSaveOrNot) {\r
95 CreateGotoOpCode (\r
96 FORM_MAIN_ID,\r
97 STRING_TOKEN (STR_SAVE_AND_EXIT),\r
98 STRING_TOKEN (STR_NULL_STRING),\r
99 EFI_IFR_FLAG_INTERACTIVE | EFI_IFR_FLAG_NV_ACCESS,\r
100 KEY_VALUE_SAVE_AND_EXIT,\r
101 CurrentLocation\r
102 );\r
103\r
104 UpdateData->DataCount++;\r
105\r
106 CurrentLocation = CurrentLocation + ((EFI_IFR_OP_HEADER *) CurrentLocation)->Length;\r
107\r
108 CreateGotoOpCode (\r
109 FORM_MAIN_ID,\r
110 STRING_TOKEN (STR_NO_SAVE_AND_EXIT),\r
111 STRING_TOKEN (STR_NULL_STRING),\r
112 EFI_IFR_FLAG_INTERACTIVE | EFI_IFR_FLAG_NV_ACCESS,\r
113 KEY_VALUE_NO_SAVE_AND_EXIT,\r
114 CurrentLocation\r
115 );\r
116\r
117 UpdateData->DataCount++;\r
118 }\r
119 //\r
120 // Ensure user can return to the main page.\r
121 //\r
122 if (0 == UpdateData->DataCount) {\r
123 CreateGotoOpCode (\r
124 FORM_MAIN_ID,\r
125 STRING_TOKEN (STR_NO_SAVE_AND_EXIT),\r
126 STRING_TOKEN (STR_NULL_STRING),\r
127 EFI_IFR_FLAG_INTERACTIVE | EFI_IFR_FLAG_NV_ACCESS,\r
128 KEY_VALUE_NO_SAVE_AND_EXIT,\r
129 CurrentLocation\r
130 );\r
131\r
132 UpdateData->DataCount++;\r
133 }\r
134\r
135 CallbackData->Hii->UpdateForm (\r
136 CallbackData->Hii,\r
137 CallbackData->BmmHiiHandle,\r
138 CallbackData->BmmCurrentPageId,\r
139 TRUE,\r
140 UpdateData\r
141 );\r
142}\r
143\r
144VOID\r
145CleanUpPage (\r
146 IN EFI_FORM_LABEL LabelId,\r
147 IN BMM_CALLBACK_DATA *CallbackData\r
148 )\r
149{\r
150 RefreshUpdateData (FALSE, 0, FALSE, 0, 0xff);\r
151\r
152 //\r
153 // Remove all op-codes from dynamic page\r
154 //\r
155 CallbackData->Hii->UpdateForm (\r
156 CallbackData->Hii,\r
157 CallbackData->BmmHiiHandle,\r
158 LabelId,\r
159 FALSE,\r
160 UpdateData\r
161 );\r
162}\r
163\r
164EFI_STATUS\r
165BootThisFile (\r
166 IN BM_FILE_CONTEXT *FileContext\r
167 )\r
168{\r
169 EFI_STATUS Status;\r
170 UINTN ExitDataSize;\r
171 CHAR16 *ExitData;\r
172 BDS_COMMON_OPTION *Option;\r
173\r
174 Status = gBS->AllocatePool (EfiBootServicesData, sizeof (BDS_COMMON_OPTION), (VOID**) &Option);\r
175 Option->Description = FileContext->FileName;\r
176 Option->DevicePath = FileContext->DevicePath;\r
177 Option->LoadOptionsSize = 0;\r
178 Option->LoadOptions = NULL;\r
179\r
180 //\r
181 // Since current no boot from removable media directly is allowed */\r
182 //\r
183 gST->ConOut->ClearScreen (gST->ConOut);\r
184\r
185 ExitDataSize = 0;\r
186\r
187 Status = BdsLibBootViaBootOption (Option, Option->DevicePath, &ExitDataSize, &ExitData);\r
188\r
189 return Status;\r
190\r
191}\r
192\r
193VOID\r
194UpdateConCOMPage (\r
195 IN BMM_CALLBACK_DATA *CallbackData\r
196 )\r
197{\r
198 BM_MENU_ENTRY *NewMenuEntry;\r
199 UINT16 Index;\r
200 UINT8 *Location;\r
201 EFI_STATUS Status;\r
202 VOID *Interface;\r
203\r
204 Location = (UINT8 *) &UpdateData->Data;\r
205 CallbackData->BmmAskSaveOrNot = FALSE;\r
206\r
207 UpdatePageStart (CallbackData, &Location);\r
208\r
209 Status = EfiLibLocateProtocol (&gTerminalDriverGuid, &Interface);\r
210 if (!EFI_ERROR (Status)) {\r
211 for (Index = 0; Index < TerminalMenu.MenuNumber; Index++) {\r
212 NewMenuEntry = BOpt_GetMenuEntry (&TerminalMenu, Index);\r
213 \r
214 CreateGotoOpCode (\r
215 FORM_CON_COM_SETUP_ID,\r
216 NewMenuEntry->DisplayStringToken,\r
217 STRING_TOKEN (STR_NULL_STRING),\r
218 EFI_IFR_FLAG_INTERACTIVE | EFI_IFR_FLAG_NV_ACCESS,\r
219 (UINT16) (TERMINAL_OPTION_OFFSET + Index),\r
220 Location\r
221 );\r
222 Location = Location + ((EFI_IFR_OP_HEADER *) Location)->Length;\r
223 UpdateData->DataCount++;\r
224 }\r
225 }\r
226\r
227 UpdatePageEnd (CallbackData, Location);\r
228}\r
229\r
230VOID\r
231UpdateBootDelPage (\r
232 IN BMM_CALLBACK_DATA *CallbackData\r
233 )\r
234{\r
235 BM_MENU_ENTRY *NewMenuEntry;\r
236 BM_LOAD_CONTEXT *NewLoadContext;\r
237 UINT16 Index;\r
238 UINT8 *Location;\r
239\r
240 Location = (UINT8 *) &UpdateData->Data;\r
241 CallbackData->BmmAskSaveOrNot = TRUE;\r
242\r
243 UpdatePageStart (CallbackData, &Location);\r
244 CreateMenuStringToken (CallbackData, CallbackData->BmmHiiHandle, &BootOptionMenu);\r
245\r
246 for (Index = 0; Index < BootOptionMenu.MenuNumber; Index++) {\r
247 NewMenuEntry = BOpt_GetMenuEntry (&BootOptionMenu, Index);\r
248 NewLoadContext = (BM_LOAD_CONTEXT *) NewMenuEntry->VariableContext;\r
249 if (NewLoadContext->IsLegacy) {\r
250 continue;\r
251 }\r
252\r
253 NewLoadContext->Deleted = FALSE;\r
254 CallbackData->BmmFakeNvData->BootOptionDel[Index] = 0x00;\r
255\r
256 CreateCheckBoxOpCode (\r
257 (UINT16) (BOOT_OPTION_DEL_QUESTION_ID + Index),\r
258 (UINT8) 1,\r
259 NewMenuEntry->DisplayStringToken,\r
260 NewMenuEntry->HelpStringToken,\r
261 EFI_IFR_FLAG_INTERACTIVE | EFI_IFR_FLAG_NV_ACCESS,\r
262 (UINT16) BOOT_OPTION_DEL_QUESTION_ID,\r
263 Location\r
264 );\r
265\r
266 Location = Location + ((EFI_IFR_OP_HEADER *) Location)->Length;\r
267 UpdateData->DataCount++;\r
268 }\r
269\r
270 UpdatePageEnd (CallbackData, Location);\r
271}\r
272\r
273VOID\r
274UpdateDrvAddHandlePage (\r
275 IN BMM_CALLBACK_DATA *CallbackData\r
276 )\r
277{\r
278 BM_MENU_ENTRY *NewMenuEntry;\r
279 UINT16 Index;\r
280 UINT8 *Location;\r
281\r
282 Location = (UINT8 *) &UpdateData->Data;\r
283 CallbackData->BmmAskSaveOrNot = FALSE;\r
284\r
285 UpdatePageStart (CallbackData, &Location);\r
286\r
287 for (Index = 0; Index < DriverMenu.MenuNumber; Index++) {\r
288 NewMenuEntry = BOpt_GetMenuEntry (&DriverMenu, Index);\r
289\r
290 CreateGotoOpCode (\r
291 FORM_DRV_ADD_HANDLE_DESC_ID,\r
292 NewMenuEntry->DisplayStringToken,\r
293 STRING_TOKEN (STR_NULL_STRING),\r
294 EFI_IFR_FLAG_INTERACTIVE | EFI_IFR_FLAG_NV_ACCESS,\r
295 (UINT16) (HANDLE_OPTION_OFFSET + Index),\r
296 Location\r
297 );\r
298\r
299 Location = Location + ((EFI_IFR_OP_HEADER *) Location)->Length;\r
300 UpdateData->DataCount++;\r
301 }\r
302\r
303 UpdatePageEnd (CallbackData, Location);\r
304}\r
305\r
306VOID\r
307UpdateDrvDelPage (\r
308 IN BMM_CALLBACK_DATA *CallbackData\r
309 )\r
310{\r
311 BM_MENU_ENTRY *NewMenuEntry;\r
312 BM_LOAD_CONTEXT *NewLoadContext;\r
313 UINT16 Index;\r
314 UINT8 *Location;\r
315\r
316 Location = (UINT8 *) &UpdateData->Data;\r
317 CallbackData->BmmAskSaveOrNot = TRUE;\r
318\r
319 UpdatePageStart (CallbackData, &Location);\r
320\r
321 CreateMenuStringToken (CallbackData, CallbackData->BmmHiiHandle, &DriverOptionMenu);\r
322\r
323 for (Index = 0; Index < DriverOptionMenu.MenuNumber; Index++) {\r
324 NewMenuEntry = BOpt_GetMenuEntry (&DriverOptionMenu, Index);\r
325\r
326 NewLoadContext = (BM_LOAD_CONTEXT *) NewMenuEntry->VariableContext;\r
327 NewLoadContext->Deleted = FALSE;\r
328 CallbackData->BmmFakeNvData->DriverOptionDel[Index] = 0x00;\r
329\r
330 CreateCheckBoxOpCode (\r
331 (UINT16) (DRIVER_OPTION_DEL_QUESTION_ID + Index),\r
332 (UINT8) 1,\r
333 NewMenuEntry->DisplayStringToken,\r
334 NewMenuEntry->HelpStringToken,\r
335 EFI_IFR_FLAG_INTERACTIVE | EFI_IFR_FLAG_NV_ACCESS,\r
336 (UINT16) DRIVER_OPTION_DEL_QUESTION_ID,\r
337 Location\r
338 );\r
339\r
340 Location = Location + ((EFI_IFR_OP_HEADER *) Location)->Length;\r
341 UpdateData->DataCount++;\r
342 }\r
343\r
344 UpdatePageEnd (CallbackData, Location);\r
345}\r
346\r
347VOID\r
348UpdateDriverAddHandleDescPage (\r
349 IN BMM_CALLBACK_DATA *CallbackData\r
350 )\r
351{\r
352 BM_MENU_ENTRY *NewMenuEntry;\r
353 UINT8 *Location;\r
354\r
355 Location = (UINT8 *) &UpdateData->Data;\r
356 CallbackData->BmmFakeNvData->DriverAddActive = 0x01;\r
357 CallbackData->BmmFakeNvData->DriverAddForceReconnect = 0x00;\r
358 CallbackData->BmmAskSaveOrNot = TRUE;\r
359 NewMenuEntry = CallbackData->MenuEntry;\r
360\r
361 UpdatePageStart (CallbackData, &Location);\r
362\r
363 UpdateData->DataCount += (UINT16) 4;\r
364\r
365 CreateSubTitleOpCode (\r
366 NewMenuEntry->DisplayStringToken,\r
367 Location\r
368 );\r
369\r
370 Location = Location + ((EFI_IFR_OP_HEADER *) Location)->Length;\r
371\r
372 CreateStringOpCode (\r
373 DRV_ADD_HANDLE_DESC_QUESTION_ID,\r
374 (UINT8) 150,\r
375 STRING_TOKEN (STR_LOAD_OPTION_DESC),\r
376 STRING_TOKEN (STR_NULL_STRING),\r
377 6,\r
378 75,\r
379 EFI_IFR_FLAG_INTERACTIVE | EFI_IFR_FLAG_NV_ACCESS,\r
380 KEY_VALUE_DRIVER_ADD_DESC_DATA,\r
381 Location\r
382 );\r
383\r
384 Location = Location + ((EFI_IFR_OP_HEADER *) Location)->Length;\r
385\r
386 CreateCheckBoxOpCode (\r
387 DRV_ADD_RECON_QUESTION_ID,\r
388 (UINT8) 1,\r
389 STRING_TOKEN (STR_LOAD_OPTION_FORCE_RECON),\r
390 STRING_TOKEN (STR_LOAD_OPTION_FORCE_RECON),\r
391 EFI_IFR_FLAG_INTERACTIVE | EFI_IFR_FLAG_NV_ACCESS,\r
392 DRV_ADD_RECON_QUESTION_ID,\r
393 Location\r
394 );\r
395 Location = Location + ((EFI_IFR_OP_HEADER *) Location)->Length;\r
396\r
397 CreateStringOpCode (\r
398 DRIVER_ADD_OPTION_QUESTION_ID,\r
399 (UINT8) 150,\r
400 STRING_TOKEN (STR_OPTIONAL_DATA),\r
401 STRING_TOKEN (STR_NULL_STRING),\r
402 6,\r
403 75,\r
404 EFI_IFR_FLAG_INTERACTIVE | EFI_IFR_FLAG_NV_ACCESS,\r
405 KEY_VALUE_DRIVER_ADD_OPT_DATA,\r
406 Location\r
407 );\r
408\r
409 Location = Location + ((EFI_IFR_OP_HEADER *) Location)->Length;\r
410 UpdatePageEnd (CallbackData, Location);\r
411}\r
412\r
413VOID\r
414UpdateConsolePage (\r
415 IN UINT16 UpdatePageId,\r
416 IN BM_MENU_OPTION *ConsoleMenu,\r
417 IN BMM_CALLBACK_DATA *CallbackData\r
418 )\r
419{\r
420 BM_MENU_ENTRY *NewMenuEntry;\r
421 BM_CONSOLE_CONTEXT *NewConsoleContext;\r
422 BM_TERMINAL_CONTEXT *NewTerminalContext;\r
423 UINT16 Index;\r
424 UINT16 Index2;\r
425 UINT8 *Location;\r
426 UINT8 CheckFlags;\r
427 EFI_STATUS Status;\r
428 VOID *Interface;\r
429\r
430 Location = (UINT8 *) &UpdateData->Data;\r
431 CallbackData->BmmAskSaveOrNot = TRUE;\r
432\r
433 UpdatePageStart (CallbackData, &Location);\r
434\r
435 for (Index = 0; Index < ConsoleMenu->MenuNumber; Index++) {\r
436 NewMenuEntry = BOpt_GetMenuEntry (ConsoleMenu, Index);\r
437 NewConsoleContext = (BM_CONSOLE_CONTEXT *) NewMenuEntry->VariableContext;\r
438 CheckFlags = EFI_IFR_FLAG_INTERACTIVE;\r
439 if (NewConsoleContext->IsActive) {\r
440 CheckFlags |= EFI_IFR_FLAG_DEFAULT;\r
441 CallbackData->BmmFakeNvData->ConsoleCheck[Index] = TRUE;\r
442 } else {\r
443 CallbackData->BmmFakeNvData->ConsoleCheck[Index] = FALSE;\r
444 }\r
445\r
446 CreateCheckBoxOpCode (\r
447 (UINT16) (CON_DEVICE_QUESTION_ID + Index),\r
448 (UINT8) 1,\r
449 NewMenuEntry->DisplayStringToken,\r
450 NewMenuEntry->HelpStringToken,\r
451 CheckFlags,\r
452 (UINT16) (CONSOLE_OPTION_OFFSET + Index),\r
453 Location\r
454 );\r
455 Location = Location + ((EFI_IFR_OP_HEADER *) Location)->Length;\r
456 UpdateData->DataCount++;\r
457 }\r
458\r
459 Status = EfiLibLocateProtocol (&gTerminalDriverGuid, &Interface);\r
460 if (!EFI_ERROR (Status)) {\r
461 for (Index2 = 0; Index2 < TerminalMenu.MenuNumber; Index2++) {\r
462 CheckFlags = EFI_IFR_FLAG_INTERACTIVE;\r
463 NewMenuEntry = BOpt_GetMenuEntry (&TerminalMenu, Index2);\r
464 NewTerminalContext = (BM_TERMINAL_CONTEXT *) NewMenuEntry->VariableContext;\r
465\r
466 if ((NewTerminalContext->IsConIn && (UpdatePageId == FORM_CON_IN_ID)) ||\r
467 (NewTerminalContext->IsConOut && (UpdatePageId == FORM_CON_OUT_ID)) ||\r
468 (NewTerminalContext->IsStdErr && (UpdatePageId == FORM_CON_ERR_ID))\r
469 ) {\r
470 CheckFlags |= EFI_IFR_FLAG_DEFAULT;\r
471 CallbackData->BmmFakeNvData->ConsoleCheck[Index] = TRUE;\r
472 } else {\r
473 CallbackData->BmmFakeNvData->ConsoleCheck[Index] = FALSE;\r
474 }\r
475\r
476 CreateCheckBoxOpCode (\r
477 (UINT16) (CON_DEVICE_QUESTION_ID + Index),\r
478 (UINT8) 1,\r
479 NewMenuEntry->DisplayStringToken,\r
480 NewMenuEntry->HelpStringToken,\r
481 CheckFlags,\r
482 (UINT16) (CONSOLE_OPTION_OFFSET + Index),\r
483 Location\r
484 );\r
485 Location = Location + ((EFI_IFR_OP_HEADER *) Location)->Length;\r
486 UpdateData->DataCount++;\r
487 Index++;\r
488 }\r
489 }\r
490\r
491 UpdatePageEnd (CallbackData, Location);\r
492}\r
493\r
494VOID\r
495UpdateOrderPage (\r
496 IN UINT16 UpdatePageId,\r
497 IN BM_MENU_OPTION *OptionMenu,\r
498 IN BMM_CALLBACK_DATA *CallbackData\r
499 )\r
500{\r
501 BM_MENU_ENTRY *NewMenuEntry;\r
502 UINT16 Index;\r
503 UINT8 *Location;\r
504 IFR_OPTION *IfrOptionList;\r
505\r
506 Location = (UINT8 *) &UpdateData->Data;\r
507 CallbackData->BmmAskSaveOrNot = TRUE;\r
508\r
509 UpdatePageStart (CallbackData, &Location);\r
510\r
511 CreateMenuStringToken (CallbackData, CallbackData->BmmHiiHandle, OptionMenu);\r
512\r
513 ZeroMem (CallbackData->BmmFakeNvData->OptionOrder, 100);\r
514\r
515 IfrOptionList = AllocateZeroPool (sizeof (IFR_OPTION) * OptionMenu->MenuNumber);\r
516 if (NULL == IfrOptionList) {\r
517 return ;\r
518 }\r
519\r
520 for (Index = 0; Index < OptionMenu->MenuNumber; Index++) {\r
521 NewMenuEntry = BOpt_GetMenuEntry (OptionMenu, Index);\r
522 IfrOptionList[Index].StringToken = NewMenuEntry->DisplayStringToken;\r
523 IfrOptionList[Index].Value = (UINT16) (NewMenuEntry->OptionNumber + 1);\r
524 IfrOptionList[Index].OptionString = NULL;\r
525 CallbackData->BmmFakeNvData->OptionOrder[Index] = (UINT8) (IfrOptionList[Index].Value);\r
526 }\r
527\r
528 if (OptionMenu->MenuNumber > 0) {\r
529 CreateOrderedListOpCode (\r
530 (UINT16) OPTION_ORDER_QUESTION_ID,\r
531 (UINT8) 100,\r
532 STRING_TOKEN (STR_CHANGE_ORDER),\r
533 STRING_TOKEN (STR_CHANGE_ORDER),\r
534 IfrOptionList,\r
535 OptionMenu->MenuNumber,\r
536 Location\r
537 );\r
538\r
539 for (Index = 0; Index < OptionMenu->MenuNumber + 2; Index++) {\r
540 Location = Location + ((EFI_IFR_OP_HEADER *) Location)->Length;\r
541 }\r
542\r
543 UpdateData->DataCount = (UINT16) (UpdateData->DataCount + OptionMenu->MenuNumber + 2);\r
544 }\r
545\r
546 SafeFreePool (IfrOptionList);\r
547\r
548 UpdatePageEnd (CallbackData, Location);\r
549\r
550 CopyMem (\r
551 CallbackData->BmmOldFakeNVData.OptionOrder,\r
552 CallbackData->BmmFakeNvData->OptionOrder,\r
553 100\r
554 );\r
555}\r
556\r
557VOID\r
558UpdateBootNextPage (\r
559 IN BMM_CALLBACK_DATA *CallbackData\r
560 )\r
561{\r
562 UINT8 *Location;\r
563 BM_MENU_ENTRY *NewMenuEntry;\r
564 BM_LOAD_CONTEXT *NewLoadContext;\r
565 IFR_OPTION *IfrOptionList;\r
566 UINTN NumberOfOptions;\r
567 UINT16 Index;\r
568\r
569 Location = (UINT8 *) &UpdateData->Data;\r
570 IfrOptionList = NULL;\r
571 NumberOfOptions = BootOptionMenu.MenuNumber;\r
572 CallbackData->BmmAskSaveOrNot = TRUE;\r
573\r
574 UpdatePageStart (CallbackData, &Location);\r
575 CreateMenuStringToken (CallbackData, CallbackData->BmmHiiHandle, &BootOptionMenu);\r
576\r
577 if (NumberOfOptions > 0) {\r
578 UpdateData->DataCount = (UINT8) (UpdateData->DataCount + NumberOfOptions);\r
579 IfrOptionList = AllocateZeroPool ((NumberOfOptions + 1) * sizeof (IFR_OPTION));\r
580\r
581 ASSERT (IfrOptionList);\r
582\r
583 CallbackData->BmmFakeNvData->BootNext = (UINT16) (BootOptionMenu.MenuNumber);\r
584\r
585 for (Index = 0; Index < BootOptionMenu.MenuNumber; Index++) {\r
586 NewMenuEntry = BOpt_GetMenuEntry (&BootOptionMenu, Index);\r
587 NewLoadContext = (BM_LOAD_CONTEXT *) NewMenuEntry->VariableContext;\r
588 if (NewLoadContext->IsBootNext) {\r
589 IfrOptionList[Index].Flags = EFI_IFR_FLAG_DEFAULT | EFI_IFR_FLAG_INTERACTIVE;\r
590 CallbackData->BmmFakeNvData->BootNext = Index;\r
591 } else {\r
592 IfrOptionList[Index].Flags = EFI_IFR_FLAG_INTERACTIVE;\r
593 }\r
594\r
595 IfrOptionList[Index].Key = (UINT16) KEY_VALUE_MAIN_BOOT_NEXT;\r
596 IfrOptionList[Index].Value = Index;\r
597 IfrOptionList[Index].StringToken = NewMenuEntry->DisplayStringToken;\r
598 IfrOptionList[Index].OptionString = NULL;\r
599 }\r
600\r
601 IfrOptionList[Index].Key = (UINT16) KEY_VALUE_MAIN_BOOT_NEXT;\r
602 IfrOptionList[Index].Value = Index;\r
603 IfrOptionList[Index].StringToken = STRING_TOKEN (STR_NONE);\r
604 IfrOptionList[Index].Flags = EFI_IFR_FLAG_INTERACTIVE;\r
605 if (CallbackData->BmmFakeNvData->BootNext == Index) {\r
606 IfrOptionList[Index].Flags |= EFI_IFR_FLAG_DEFAULT;\r
607 }\r
608\r
609 IfrOptionList[Index].OptionString = NULL;\r
610\r
611 CreateOneOfOpCode (\r
612 (UINT16) BOOT_NEXT_QUESTION_ID,\r
613 (UINT8) 2,\r
614 STRING_TOKEN (STR_BOOT_NEXT),\r
615 STRING_TOKEN (STR_BOOT_NEXT_HELP),\r
616 IfrOptionList,\r
617 (UINTN) (NumberOfOptions + 1),\r
618 Location\r
619 );\r
620 Location = Location + (NumberOfOptions + 2) * ((EFI_IFR_OP_HEADER *) Location)->Length;\r
621 Location = Location + ((EFI_IFR_OP_HEADER *) Location)->Length;\r
622\r
623 UpdateData->DataCount += 3;\r
624 SafeFreePool (IfrOptionList);\r
625 IfrOptionList = NULL;\r
626 }\r
627\r
628 UpdatePageEnd (CallbackData, Location);\r
629}\r
630\r
631VOID\r
632UpdateTimeOutPage (\r
633 IN BMM_CALLBACK_DATA *CallbackData\r
634 )\r
635{\r
636 UINT8 *Location;\r
637 UINT16 BootTimeOut;\r
638\r
639 Location = (UINT8 *) &UpdateData->Data;\r
640 CallbackData->BmmAskSaveOrNot = TRUE;\r
641\r
642 UpdatePageStart (CallbackData, &Location);\r
643\r
644 BootTimeOut = BdsLibGetTimeout ();\r
645\r
646 CreateNumericOpCode (\r
647 (UINT16) BOOT_TIME_OUT_QUESTION_ID,\r
648 (UINT8) 2,\r
649 STRING_TOKEN (STR_NUM_AUTO_BOOT),\r
650 STRING_TOKEN (STR_HLP_AUTO_BOOT),\r
651 0,\r
652 65535,\r
653 0,\r
654 10,\r
655 0,\r
656 0,\r
657 Location\r
658 );\r
659\r
660 CallbackData->BmmFakeNvData->BootTimeOut = (UINT16) BootTimeOut;\r
661 UpdateData->DataCount++;\r
662 Location = Location + ((EFI_IFR_OP_HEADER *) Location)->Length;\r
663\r
664 UpdatePageEnd (CallbackData, Location);\r
665}\r
666\r
667VOID\r
668UpdateTerminalPage (\r
669 IN BMM_CALLBACK_DATA *CallbackData\r
670 )\r
671{\r
672 UINT16 Index;\r
673 UINT8 *Location;\r
674 UINT8 CheckFlags;\r
675 IFR_OPTION *IfrOptionList;\r
676 BM_MENU_ENTRY *NewMenuEntry;\r
677 BM_TERMINAL_CONTEXT *NewTerminalContext;\r
678\r
679 ZeroMem (UpdateData, UPDATE_DATA_SIZE);\r
680 Location = (UINT8 *) &UpdateData->Data;\r
681 UpdatePageStart (CallbackData, &Location);\r
682\r
683 NewMenuEntry = BOpt_GetMenuEntry (\r
684 &TerminalMenu,\r
685 CallbackData->CurrentTerminal\r
686 );\r
687\r
688 if (!NewMenuEntry) {\r
689 return ;\r
690 }\r
691\r
692 NewTerminalContext = (BM_TERMINAL_CONTEXT *) NewMenuEntry->VariableContext;\r
693\r
694 IfrOptionList = AllocateZeroPool (sizeof (IFR_OPTION) * 19);\r
695 if (!IfrOptionList) {\r
696 return ;\r
697 }\r
698\r
699 for (Index = 0; Index < 19; Index++) {\r
700 CheckFlags = EFI_IFR_FLAG_INTERACTIVE;\r
701 if (NewTerminalContext->BaudRate == (UINT64) (BaudRateList[Index].Value)) {\r
702 CheckFlags |= EFI_IFR_FLAG_DEFAULT;\r
703 NewTerminalContext->BaudRateIndex = (UINT8) Index;\r
704 CallbackData->BmmFakeNvData->COMBaudRate = NewTerminalContext->BaudRateIndex;\r
705 }\r
706\r
707 IfrOptionList[Index].Flags = CheckFlags;\r
708 IfrOptionList[Index].Key = KEY_VALUE_COM_SET_BAUD_RATE;\r
709 IfrOptionList[Index].StringToken = BaudRateList[Index].StringToken;\r
710 IfrOptionList[Index].Value = Index;\r
711 }\r
712\r
713 CreateOneOfOpCode (\r
714 (UINT16) COM_BAUD_RATE_QUESTION_ID,\r
715 (UINT8) 1,\r
716 STRING_TOKEN (STR_COM_BAUD_RATE),\r
717 STRING_TOKEN (STR_COM_BAUD_RATE),\r
718 IfrOptionList,\r
719 19,\r
720 Location\r
721 );\r
722\r
723 Location = Location + (Index + 1) * ((EFI_IFR_OP_HEADER *) Location)->Length;\r
724 Location = Location + ((EFI_IFR_OP_HEADER *) Location)->Length;\r
725 UpdateData->DataCount = (UINT8) (UpdateData->DataCount + Index);\r
726 UpdateData->DataCount += 2;\r
727\r
728 SafeFreePool (IfrOptionList);\r
729\r
730 IfrOptionList = AllocateZeroPool (sizeof (IFR_OPTION) * 4);\r
731 if (!IfrOptionList) {\r
732 return ;\r
733 }\r
734\r
735 for (Index = 0; Index < 4; Index++) {\r
736 CheckFlags = EFI_IFR_FLAG_INTERACTIVE;\r
737\r
738 if (NewTerminalContext->DataBits == DataBitsList[Index].Value) {\r
739 NewTerminalContext->DataBitsIndex = (UINT8) Index;\r
740 CallbackData->BmmFakeNvData->COMDataRate = NewTerminalContext->DataBitsIndex;\r
741 CheckFlags |= EFI_IFR_FLAG_DEFAULT;\r
742 }\r
743\r
744 IfrOptionList[Index].Flags = CheckFlags;\r
745 IfrOptionList[Index].Key = KEY_VALUE_COM_SET_DATA_BITS;\r
746 IfrOptionList[Index].StringToken = DataBitsList[Index].StringToken;\r
747 IfrOptionList[Index].Value = Index;\r
748 }\r
749\r
750 CreateOneOfOpCode (\r
751 (UINT16) COM_DATA_RATE_QUESTION_ID,\r
752 (UINT8) 1,\r
753 STRING_TOKEN (STR_COM_DATA_BITS),\r
754 STRING_TOKEN (STR_COM_DATA_BITS),\r
755 IfrOptionList,\r
756 4,\r
757 Location\r
758 );\r
759\r
760 Location = Location + (Index + 1) * ((EFI_IFR_OP_HEADER *) Location)->Length;\r
761 Location = Location + ((EFI_IFR_OP_HEADER *) Location)->Length;\r
762 UpdateData->DataCount = (UINT8) (UpdateData->DataCount + Index);\r
763 UpdateData->DataCount += 2;\r
764\r
765 SafeFreePool (IfrOptionList);\r
766\r
767 IfrOptionList = AllocateZeroPool (sizeof (IFR_OPTION) * 5);\r
768 if (!IfrOptionList) {\r
769 return ;\r
770 }\r
771\r
772 for (Index = 0; Index < 5; Index++) {\r
773 CheckFlags = EFI_IFR_FLAG_INTERACTIVE;\r
774 if (NewTerminalContext->Parity == ParityList[Index].Value) {\r
775 CheckFlags |= EFI_IFR_FLAG_DEFAULT;\r
776 NewTerminalContext->ParityIndex = (UINT8) Index;\r
777 CallbackData->BmmFakeNvData->COMParity = NewTerminalContext->ParityIndex;\r
778 }\r
779\r
780 IfrOptionList[Index].Flags = CheckFlags;\r
781 IfrOptionList[Index].Key = KEY_VALUE_COM_SET_PARITY;\r
782 IfrOptionList[Index].StringToken = ParityList[Index].StringToken;\r
783 IfrOptionList[Index].Value = Index;\r
784 }\r
785\r
786 CreateOneOfOpCode (\r
787 (UINT16) COM_PARITY_QUESTION_ID,\r
788 (UINT8) 1,\r
789 STRING_TOKEN (STR_COM_PARITY),\r
790 STRING_TOKEN (STR_COM_PARITY),\r
791 IfrOptionList,\r
792 5,\r
793 Location\r
794 );\r
795\r
796 Location = Location + (Index + 1) * ((EFI_IFR_OP_HEADER *) Location)->Length;\r
797 Location = Location + ((EFI_IFR_OP_HEADER *) Location)->Length;\r
798 UpdateData->DataCount = (UINT8) (UpdateData->DataCount + Index);\r
799 UpdateData->DataCount += 2;\r
800\r
801 SafeFreePool (IfrOptionList);\r
802\r
803 IfrOptionList = AllocateZeroPool (sizeof (IFR_OPTION) * 3);\r
804 if (!IfrOptionList) {\r
805 return ;\r
806 }\r
807\r
808 for (Index = 0; Index < 3; Index++) {\r
809 CheckFlags = EFI_IFR_FLAG_INTERACTIVE;\r
810 if (NewTerminalContext->StopBits == StopBitsList[Index].Value) {\r
811 CheckFlags |= EFI_IFR_FLAG_DEFAULT;\r
812 NewTerminalContext->StopBitsIndex = (UINT8) Index;\r
813 CallbackData->BmmFakeNvData->COMStopBits = NewTerminalContext->StopBitsIndex;\r
814 }\r
815\r
816 IfrOptionList[Index].Flags = CheckFlags;\r
817 IfrOptionList[Index].Key = KEY_VALUE_COM_SET_STOP_BITS;\r
818 IfrOptionList[Index].StringToken = StopBitsList[Index].StringToken;\r
819 IfrOptionList[Index].Value = Index;\r
820 }\r
821\r
822 CreateOneOfOpCode (\r
823 (UINT16) COM_STOP_BITS_QUESTION_ID,\r
824 (UINT8) 1,\r
825 STRING_TOKEN (STR_COM_STOP_BITS),\r
826 STRING_TOKEN (STR_COM_STOP_BITS),\r
827 IfrOptionList,\r
828 3,\r
829 Location\r
830 );\r
831\r
832 Location = Location + (Index + 1) * ((EFI_IFR_OP_HEADER *) Location)->Length;\r
833 Location = Location + ((EFI_IFR_OP_HEADER *) Location)->Length;\r
834 UpdateData->DataCount = (UINT8) (UpdateData->DataCount + Index);\r
835 UpdateData->DataCount += 2;\r
836\r
837 SafeFreePool (IfrOptionList);\r
838\r
839 IfrOptionList = AllocateZeroPool (sizeof (IFR_OPTION) * 4);\r
840 if (!IfrOptionList) {\r
841 return ;\r
842 }\r
843\r
844 for (Index = 0; Index < 4; Index++) {\r
845 CheckFlags = EFI_IFR_FLAG_INTERACTIVE;\r
846 if (NewTerminalContext->TerminalType == Index) {\r
847 CheckFlags |= EFI_IFR_FLAG_DEFAULT;\r
848 CallbackData->BmmFakeNvData->COMTerminalType = NewTerminalContext->TerminalType;\r
849 }\r
850\r
851 IfrOptionList[Index].Flags = CheckFlags;\r
852 IfrOptionList[Index].Key = KEY_VALUE_COM_SET_TERMI_TYPE;\r
853 IfrOptionList[Index].StringToken = (STRING_REF) TerminalType[Index];\r
854 IfrOptionList[Index].Value = Index;\r
855 }\r
856\r
857 CreateOneOfOpCode (\r
858 (UINT16) COM_TERMINAL_QUESTION_ID,\r
859 (UINT8) 1,\r
860 STRING_TOKEN (STR_COM_TERMI_TYPE),\r
861 STRING_TOKEN (STR_COM_TERMI_TYPE),\r
862 IfrOptionList,\r
863 4,\r
864 Location\r
865 );\r
866\r
867 Location = Location + (Index + 1) * ((EFI_IFR_OP_HEADER *) Location)->Length;\r
868 Location = Location + ((EFI_IFR_OP_HEADER *) Location)->Length;\r
869 UpdateData->DataCount = (UINT8) (UpdateData->DataCount + Index);\r
870 UpdateData->DataCount += 2;\r
871\r
872 SafeFreePool (IfrOptionList);\r
873\r
874 CreateGotoOpCode (\r
875 FORM_MAIN_ID,\r
876 STRING_TOKEN (STR_SAVE_AND_EXIT),\r
877 STRING_TOKEN (STR_NULL_STRING),\r
878 EFI_IFR_FLAG_INTERACTIVE | EFI_IFR_FLAG_NV_ACCESS,\r
879 KEY_VALUE_SAVE_AND_EXIT,\r
880 Location\r
881 );\r
882\r
883 Location = Location + ((EFI_IFR_OP_HEADER *) Location)->Length;\r
884 UpdateData->DataCount++;\r
885\r
886 CreateGotoOpCode (\r
887 FORM_MAIN_ID,\r
888 STRING_TOKEN (STR_NO_SAVE_AND_EXIT),\r
889 STRING_TOKEN (STR_NULL_STRING),\r
890 EFI_IFR_FLAG_INTERACTIVE | EFI_IFR_FLAG_NV_ACCESS,\r
891 KEY_VALUE_NO_SAVE_AND_EXIT,\r
892 Location\r
893 );\r
894\r
895 UpdateData->DataCount++;\r
896\r
897 CallbackData->Hii->UpdateForm (\r
898 CallbackData->Hii,\r
899 CallbackData->BmmHiiHandle,\r
900 (EFI_FORM_LABEL) FORM_CON_COM_SETUP_ID,\r
901 TRUE,\r
902 UpdateData\r
903 );\r
904\r
905}\r
906\r
907VOID\r
908UpdatePageBody (\r
909 IN UINT16 UpdatePageId,\r
910 IN BMM_CALLBACK_DATA *CallbackData\r
911 )\r
912{\r
913 CleanUpPage (UpdatePageId, CallbackData);\r
914 switch (UpdatePageId) {\r
915 case FORM_CON_IN_ID:\r
916 UpdateConsolePage (UpdatePageId, &ConsoleInpMenu, CallbackData);\r
917 break;\r
918\r
919 case FORM_CON_OUT_ID:\r
920 UpdateConsolePage (UpdatePageId, &ConsoleOutMenu, CallbackData);\r
921 break;\r
922\r
923 case FORM_CON_ERR_ID:\r
924 UpdateConsolePage (UpdatePageId, &ConsoleErrMenu, CallbackData);\r
925 break;\r
926\r
927 case FORM_BOOT_CHG_ID:\r
928 UpdateOrderPage (UpdatePageId, &BootOptionMenu, CallbackData);\r
929 break;\r
930\r
931 case FORM_DRV_CHG_ID:\r
932 UpdateOrderPage (UpdatePageId, &DriverOptionMenu, CallbackData);\r
933 break;\r
934\r
935 default:\r
936 break;\r
937 }\r
938}\r
939\r
940VOID *\r
941GetLegacyBootOptionVar (\r
942 IN UINTN DeviceType,\r
943 OUT UINTN *OptionIndex,\r
944 OUT UINTN *OptionSize\r
945 )\r
946{\r
947 EFI_DEVICE_PATH_PROTOCOL *DevicePath;\r
948 VOID *OptionBuffer;\r
949 UINTN OrderSize;\r
950 UINTN Index;\r
951 UINT32 Attribute;\r
952 UINT16 *OrderBuffer;\r
953 CHAR16 StrTemp[100];\r
954 UINT16 FilePathSize;\r
955 CHAR16 *Description;\r
956 UINT8 *Ptr;\r
957 UINT8 *OptionalData;\r
958\r
959 //\r
960 // Get Boot Option number from the size of BootOrder\r
961 //\r
962 OrderBuffer = BdsLibGetVariableAndSize (\r
963 L"BootOrder",\r
964 &gEfiGlobalVariableGuid,\r
965 &OrderSize\r
966 );\r
967\r
968 for (Index = 0; Index < OrderSize / sizeof (UINT16); Index++) {\r
969 UnicodeSPrint (StrTemp, 100, L"Boot%04x", OrderBuffer[Index]);\r
970 OptionBuffer = BdsLibGetVariableAndSize (\r
971 StrTemp,\r
972 &gEfiGlobalVariableGuid,\r
973 OptionSize\r
974 );\r
975 if (NULL == OptionBuffer) {\r
976 continue;\r
977 }\r
978\r
979 Ptr = (UINT8 *) OptionBuffer;\r
980 Attribute = *(UINT32 *) Ptr;\r
981 Ptr += sizeof (UINT32);\r
982\r
983 FilePathSize = *(UINT16 *) Ptr;\r
984 Ptr += sizeof (UINT16);\r
985\r
986 Description = (CHAR16 *) Ptr;\r
987 Ptr += StrSize ((CHAR16 *) Ptr);\r
988\r
989 //\r
990 // Now Ptr point to Device Path\r
991 //\r
992 DevicePath = (EFI_DEVICE_PATH_PROTOCOL *) Ptr;\r
993 Ptr += FilePathSize;\r
994\r
995 //\r
996 // Now Ptr point to Optional Data\r
997 //\r
998 OptionalData = Ptr;\r
999\r
1000 if ((DeviceType == ((BBS_TABLE *) OptionalData)->DeviceType) &&\r
1001 (BBS_DEVICE_PATH == DevicePath->Type) &&\r
1002 (BBS_BBS_DP == DevicePath->SubType)\r
1003 ) {\r
1004 *OptionIndex = OrderBuffer[Index];\r
1005 SafeFreePool (OrderBuffer);\r
1006 return OptionBuffer;\r
1007 } else {\r
1008 SafeFreePool (OptionBuffer);\r
1009 }\r
1010 }\r
1011\r
1012 SafeFreePool (OrderBuffer);\r
1013 return NULL;\r
1014}\r
1015\r
1016VOID\r
1017UpdateSetLegacyDeviceOrderPage (\r
1018 IN UINT16 UpdatePageId,\r
1019 IN BMM_CALLBACK_DATA *CallbackData\r
1020 )\r
1021{\r
1022 BM_LEGACY_DEV_ORDER_CONTEXT *DevOrder;\r
1023 BM_MENU_OPTION *OptionMenu;\r
1024 BM_MENU_ENTRY *NewMenuEntry;\r
1025 IFR_OPTION *IfrOptionList;\r
1026 STRING_REF StrRef;\r
1027 STRING_REF StrRefHelp;\r
1028 BBS_TYPE BbsType;\r
1029 UINTN VarSize;\r
1030 UINTN Pos;\r
1031 UINTN Bit;\r
1032 UINT16 Index;\r
1033 UINT16 Index2;\r
1034 UINT16 Key;\r
1035 CHAR16 String[100];\r
1036 CHAR16 *TypeStr;\r
1037 CHAR16 *TypeStrHelp;\r
1038 UINT16 VarDevOrder;\r
1039 UINT8 *Location;\r
1040 UINT8 *VarData;\r
1041 UINT8 *OriginalPtr;\r
1042 UINT8 *LegacyOrder;\r
1043 UINT8 *OldData;\r
1044 UINT8 *DisMap;\r
1045\r
1046 OptionMenu = NULL;\r
1047 Key = 0;\r
1048 StrRef = 0;\r
1049 StrRefHelp = 0;\r
1050 TypeStr = NULL;\r
1051 TypeStrHelp = NULL;\r
1052 BbsType = BBS_FLOPPY;\r
1053 LegacyOrder = NULL;\r
1054 OldData = NULL;\r
1055 DisMap = NULL;\r
1056\r
1057 Location = (UINT8 *) &UpdateData->Data;\r
1058 CallbackData->BmmAskSaveOrNot = TRUE;\r
1059\r
1060 UpdatePageStart (CallbackData, &Location);\r
1061\r
1062 DisMap = CallbackData->BmmOldFakeNVData.DisableMap;\r
1063\r
1064 SetMem (DisMap, 32, 0);\r
1065 //\r
1066 // Create oneof option list\r
1067 //\r
1068 switch (UpdatePageId) {\r
1069 case FORM_SET_FD_ORDER_ID:\r
1070 OptionMenu = (BM_MENU_OPTION *) &LegacyFDMenu;\r
1071 Key = LEGACY_FD_QUESTION_ID;\r
1072 TypeStr = StrFloppy;\r
1073 TypeStrHelp = StrFloppyHelp;\r
1074 BbsType = BBS_FLOPPY;\r
1075 LegacyOrder = CallbackData->BmmFakeNvData->LegacyFD;\r
1076 OldData = CallbackData->BmmOldFakeNVData.LegacyFD;\r
1077 break;\r
1078\r
1079 case FORM_SET_HD_ORDER_ID:\r
1080 OptionMenu = (BM_MENU_OPTION *) &LegacyHDMenu;\r
1081 Key = LEGACY_HD_QUESTION_ID;\r
1082 TypeStr = StrHardDisk;\r
1083 TypeStrHelp = StrHardDiskHelp;\r
1084 BbsType = BBS_HARDDISK;\r
1085 LegacyOrder = CallbackData->BmmFakeNvData->LegacyHD;\r
1086 OldData = CallbackData->BmmOldFakeNVData.LegacyHD;\r
1087 break;\r
1088\r
1089 case FORM_SET_CD_ORDER_ID:\r
1090 OptionMenu = (BM_MENU_OPTION *) &LegacyCDMenu;\r
1091 Key = LEGACY_CD_QUESTION_ID;\r
1092 TypeStr = StrCDROM;\r
1093 TypeStrHelp = StrCDROMHelp;\r
1094 BbsType = BBS_CDROM;\r
1095 LegacyOrder = CallbackData->BmmFakeNvData->LegacyCD;\r
1096 OldData = CallbackData->BmmOldFakeNVData.LegacyCD;\r
1097 break;\r
1098\r
1099 case FORM_SET_NET_ORDER_ID:\r
1100 OptionMenu = (BM_MENU_OPTION *) &LegacyNETMenu;\r
1101 Key = LEGACY_NET_QUESTION_ID;\r
1102 TypeStr = StrNET;\r
1103 TypeStrHelp = StrNETHelp;\r
1104 BbsType = BBS_EMBED_NETWORK;\r
1105 LegacyOrder = CallbackData->BmmFakeNvData->LegacyNET;\r
1106 OldData = CallbackData->BmmOldFakeNVData.LegacyNET;\r
1107 break;\r
1108\r
1109 case FORM_SET_BEV_ORDER_ID:\r
1110 OptionMenu = (BM_MENU_OPTION *) &LegacyBEVMenu;\r
1111 Key = LEGACY_BEV_QUESTION_ID;\r
1112 TypeStr = StrBEV;\r
1113 TypeStrHelp = StrBEVHelp;\r
1114 BbsType = BBS_BEV_DEVICE;\r
1115 LegacyOrder = CallbackData->BmmFakeNvData->LegacyBEV;\r
1116 OldData = CallbackData->BmmOldFakeNVData.LegacyBEV;\r
1117 break;\r
1118\r
1119 }\r
1120\r
1121 CreateMenuStringToken (CallbackData, CallbackData->BmmHiiHandle, OptionMenu);\r
1122\r
1123 IfrOptionList = AllocateZeroPool (sizeof (IFR_OPTION) * (OptionMenu->MenuNumber + 1));\r
1124 if (NULL == IfrOptionList) {\r
1125 return ;\r
1126 }\r
1127\r
1128 for (Index = 0; Index < OptionMenu->MenuNumber; Index++) {\r
1129 NewMenuEntry = BOpt_GetMenuEntry (OptionMenu, Index);\r
1130 IfrOptionList[Index].Flags = EFI_IFR_FLAG_INTERACTIVE;\r
1131 if (0 == Index) {\r
1132 IfrOptionList[Index].Flags |= EFI_IFR_FLAG_DEFAULT;\r
1133 }\r
1134\r
1135 IfrOptionList[Index].Key = Key;\r
1136 IfrOptionList[Index].StringToken = NewMenuEntry->DisplayStringToken;\r
1137 IfrOptionList[Index].Value = (UINT16) ((BM_LEGACY_DEVICE_CONTEXT *) NewMenuEntry->VariableContext)->Index;\r
1138 IfrOptionList[Index].OptionString = NULL;\r
1139 }\r
1140 //\r
1141 // for item "Disabled"\r
1142 //\r
1143 IfrOptionList[Index].Flags = EFI_IFR_FLAG_INTERACTIVE;\r
1144 IfrOptionList[Index].Key = Key;\r
1145 IfrOptionList[Index].StringToken = STRING_TOKEN (STR_DISABLE_LEGACY_DEVICE);\r
1146 IfrOptionList[Index].Value = 0xFF;\r
1147 IfrOptionList[Index].OptionString = NULL;\r
1148\r
1149 //\r
1150 // Get Device Order from variable\r
1151 //\r
1152 VarData = BdsLibGetVariableAndSize (\r
1153 VarLegacyDevOrder,\r
1154 &EfiLegacyDevOrderGuid,\r
1155 &VarSize\r
1156 );\r
1157\r
1158 if (NULL != VarData) {\r
1159 OriginalPtr = VarData;\r
1160 DevOrder = (BM_LEGACY_DEV_ORDER_CONTEXT *) VarData;\r
1161 while (VarData < VarData + VarSize) {\r
1162 if (DevOrder->BbsType == BbsType) {\r
1163 break;\r
1164 }\r
1165\r
1166 VarData += sizeof (BBS_TYPE);\r
1167 VarData += *(UINT16 *) VarData;\r
1168 DevOrder = (BM_LEGACY_DEV_ORDER_CONTEXT *) VarData;\r
1169 }\r
1170 //\r
1171 // Create oneof tag here for FD/HD/CD #1 #2\r
1172 //\r
1173 for (Index = 0; Index < OptionMenu->MenuNumber; Index++) {\r
1174 for (Index2 = 0; Index2 <= OptionMenu->MenuNumber; Index2++) {\r
1175 IfrOptionList[Index2].Key = (UINT16) (Key + Index);\r
1176 }\r
1177 //\r
1178 // Create the string for oneof tag\r
1179 //\r
1180 UnicodeSPrint (String, sizeof (String), TypeStr, Index);\r
1181 StrRef = 0;\r
1182 CallbackData->Hii->NewString (\r
1183 CallbackData->Hii,\r
1184 NULL,\r
1185 CallbackData->BmmHiiHandle,\r
1186 &StrRef,\r
1187 String\r
1188 );\r
1189\r
1190 UnicodeSPrint (String, sizeof (String), TypeStrHelp, Index);\r
1191 StrRefHelp = 0;\r
1192 CallbackData->Hii->NewString (\r
1193 CallbackData->Hii,\r
1194 NULL,\r
1195 CallbackData->BmmHiiHandle,\r
1196 &StrRefHelp,\r
1197 String\r
1198 );\r
1199\r
1200 CreateOneOfOpCode (\r
1201 (UINT16) (Key + Index),\r
1202 (UINT8) 1,\r
1203 StrRef,\r
1204 StrRefHelp,\r
1205 IfrOptionList,\r
1206 OptionMenu->MenuNumber + 1,\r
1207 Location\r
1208 );\r
1209\r
1210 VarDevOrder = *(UINT16 *) ((UINT8 *) DevOrder + sizeof (BBS_TYPE) + sizeof (UINT16) + Index * sizeof (UINT16));\r
1211\r
1212 if (0xFF00 == (VarDevOrder & 0xFF00)) {\r
1213 LegacyOrder[Index] = 0xFF;\r
1214 Pos = (VarDevOrder & 0xFF) / 8;\r
1215 Bit = 7 - ((VarDevOrder & 0xFF) % 8);\r
1216 DisMap[Pos] |= (UINT8) (1 << Bit);\r
1217 } else {\r
1218 LegacyOrder[Index] = (UINT8) (VarDevOrder & 0xFF);\r
1219 }\r
1220\r
1221 Location = Location + (OptionMenu->MenuNumber + 2) * ((EFI_IFR_OP_HEADER *) Location)->Length;\r
1222 Location = Location + ((EFI_IFR_OP_HEADER *) Location)->Length;\r
1223 UpdateData->DataCount = (UINT16) (UpdateData->DataCount + (OptionMenu->MenuNumber + 3));\r
1224 }\r
1225 }\r
1226\r
1227 CopyMem (\r
1228 OldData,\r
1229 LegacyOrder,\r
1230 100\r
1231 );\r
1232\r
1233 if (IfrOptionList != NULL) {\r
1234 SafeFreePool (IfrOptionList);\r
1235 IfrOptionList = NULL;\r
1236 }\r
1237\r
1238 UpdatePageEnd (CallbackData, Location);\r
1239}\r
1240\r
1241VOID\r
1242UpdatePageId (\r
1243 BMM_CALLBACK_DATA *Private,\r
1244 UINT16 NewPageId\r
1245 )\r
1246{\r
1247 UINT16 FileOptionMask;\r
1248\r
1249 FileOptionMask = (UINT16) (FILE_OPTION_MASK & NewPageId);\r
1250\r
1251 if ((NewPageId < FILE_OPTION_OFFSET) && (NewPageId >= HANDLE_OPTION_OFFSET)) {\r
1252 //\r
1253 // If we select a handle to add driver option, advance to the add handle description page.\r
1254 //\r
1255 NewPageId = FORM_DRV_ADD_HANDLE_DESC_ID;\r
1256 } else if ((NewPageId == KEY_VALUE_SAVE_AND_EXIT) || (NewPageId == KEY_VALUE_NO_SAVE_AND_EXIT)) {\r
1257 //\r
1258 // Return to main page after "Save Changes" or "Discard Changes".\r
1259 //\r
1260 NewPageId = FORM_MAIN_ID;\r
1261 }\r
1262\r
1263 if ((NewPageId > 0) && (NewPageId < MAXIMUM_FORM_ID)) {\r
1264 Private->BmmPreviousPageId = Private->BmmCurrentPageId;\r
1265 Private->BmmCurrentPageId = NewPageId;\r
1266 }\r
1267}\r