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