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