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