2 The functions for Boot Maintainence Main menu.
4 Copyright (c) 2004 - 2011, Intel Corporation. All rights reserved.<BR>
5 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
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.
15 #include "BootMaint.h"
18 #include "FrontPage.h"
20 EFI_DEVICE_PATH_PROTOCOL EndDevicePath
[] = {
23 END_ENTIRE_DEVICE_PATH_SUBTYPE
,
25 END_DEVICE_PATH_LENGTH
,
31 HII_VENDOR_DEVICE_PATH mBmmHiiVendorDevicePath
= {
37 (UINT8
) (sizeof (VENDOR_DEVICE_PATH
)),
38 (UINT8
) ((sizeof (VENDOR_DEVICE_PATH
)) >> 8)
41 BOOT_MAINT_FORMSET_GUID
45 END_ENTIRE_DEVICE_PATH_SUBTYPE
,
47 (UINT8
) (END_DEVICE_PATH_LENGTH
),
48 (UINT8
) ((END_DEVICE_PATH_LENGTH
) >> 8)
53 HII_VENDOR_DEVICE_PATH mFeHiiVendorDevicePath
= {
59 (UINT8
) (sizeof (VENDOR_DEVICE_PATH
)),
60 (UINT8
) ((sizeof (VENDOR_DEVICE_PATH
)) >> 8)
63 FILE_EXPLORE_FORMSET_GUID
67 END_ENTIRE_DEVICE_PATH_SUBTYPE
,
69 (UINT8
) (END_DEVICE_PATH_LENGTH
),
70 (UINT8
) ((END_DEVICE_PATH_LENGTH
) >> 8)
75 CHAR16 mBootMaintStorageName
[] = L
"BmmData";
76 CHAR16 mFileExplorerStorageName
[] = L
"FeData";
81 @param CallbackData The BMM context data.
86 IN BMM_CALLBACK_DATA
*CallbackData
90 Free up all Menu Option list.
99 Create string tokens for a menu from its help strings and display strings
101 @param CallbackData The BMM context data.
102 @param HiiHandle Hii Handle of the package to be updated.
103 @param MenuOption The Menu whose string tokens need to be created
105 @retval EFI_SUCCESS String tokens created successfully
106 @retval others contain some errors
109 CreateMenuStringToken (
110 IN BMM_CALLBACK_DATA
*CallbackData
,
111 IN EFI_HII_HANDLE HiiHandle
,
112 IN BM_MENU_OPTION
*MenuOption
115 BM_MENU_ENTRY
*NewMenuEntry
;
118 for (Index
= 0; Index
< MenuOption
->MenuNumber
; Index
++) {
119 NewMenuEntry
= BOpt_GetMenuEntry (MenuOption
, Index
);
121 NewMenuEntry
->DisplayStringToken
= HiiSetString (
124 NewMenuEntry
->DisplayString
,
128 if (NULL
== NewMenuEntry
->HelpString
) {
129 NewMenuEntry
->HelpStringToken
= NewMenuEntry
->DisplayStringToken
;
131 NewMenuEntry
->HelpStringToken
= HiiSetString (
134 NewMenuEntry
->HelpString
,
144 This function allows a caller to extract the current configuration for one
145 or more named elements from the target driver.
148 @param This Points to the EFI_HII_CONFIG_ACCESS_PROTOCOL.
149 @param Request A null-terminated Unicode string in <ConfigRequest> format.
150 @param Progress On return, points to a character in the Request string.
151 Points to the string's null terminator if request was successful.
152 Points to the most recent '&' before the first failing name/value
153 pair (or the beginning of the string if the failure is in the
154 first name/value pair) if the request was not successful.
155 @param Results A null-terminated Unicode string in <ConfigAltResp> format which
156 has all values filled in for the names in the Request string.
157 String to be allocated by the called function.
159 @retval EFI_SUCCESS The Results is filled with the requested values.
160 @retval EFI_OUT_OF_RESOURCES Not enough memory to store the results.
161 @retval EFI_INVALID_PARAMETER Request is NULL, illegal syntax, or unknown name.
162 @retval EFI_NOT_FOUND Routing data doesn't match any storage in this driver.
167 BootMaintExtractConfig (
168 IN CONST EFI_HII_CONFIG_ACCESS_PROTOCOL
*This
,
169 IN CONST EFI_STRING Request
,
170 OUT EFI_STRING
*Progress
,
171 OUT EFI_STRING
*Results
176 BMM_CALLBACK_DATA
*Private
;
177 EFI_STRING ConfigRequestHdr
;
178 EFI_STRING ConfigRequest
;
179 BOOLEAN AllocatedRequest
;
182 if (Progress
== NULL
|| Results
== NULL
) {
183 return EFI_INVALID_PARAMETER
;
187 if ((Request
!= NULL
) && !HiiIsConfigHdrMatch (Request
, &gBootMaintFormSetGuid
, mBootMaintStorageName
)) {
188 return EFI_NOT_FOUND
;
191 ConfigRequestHdr
= NULL
;
192 ConfigRequest
= NULL
;
193 AllocatedRequest
= FALSE
;
196 Private
= BMM_CALLBACK_DATA_FROM_THIS (This
);
198 // Convert buffer data to <ConfigResp> by helper function BlockToConfig()
200 BufferSize
= sizeof (BMM_FAKE_NV_DATA
);
201 ConfigRequest
= Request
;
202 if ((Request
== NULL
) || (StrStr (Request
, L
"OFFSET") == NULL
)) {
204 // Request has no request element, construct full request string.
205 // Allocate and fill a buffer large enough to hold the <ConfigHdr> template
206 // followed by "&OFFSET=0&WIDTH=WWWWWWWWWWWWWWWW" followed by a Null-terminator
208 ConfigRequestHdr
= HiiConstructConfigHdr (&gBootMaintFormSetGuid
, mBootMaintStorageName
, Private
->BmmDriverHandle
);
209 Size
= (StrLen (ConfigRequestHdr
) + 32 + 1) * sizeof (CHAR16
);
210 ConfigRequest
= AllocateZeroPool (Size
);
211 ASSERT (ConfigRequest
!= NULL
);
212 AllocatedRequest
= TRUE
;
213 UnicodeSPrint (ConfigRequest
, Size
, L
"%s&OFFSET=0&WIDTH=%016LX", ConfigRequestHdr
, (UINT64
)BufferSize
);
214 FreePool (ConfigRequestHdr
);
217 Status
= gHiiConfigRouting
->BlockToConfig (
220 (UINT8
*) &Private
->BmmFakeNvData
,
226 // Free the allocated config request string.
228 if (AllocatedRequest
) {
229 FreePool (ConfigRequest
);
230 ConfigRequest
= NULL
;
233 // Set Progress string to the original request string.
235 if (Request
== NULL
) {
237 } else if (StrStr (Request
, L
"OFFSET") == NULL
) {
238 *Progress
= Request
+ StrLen (Request
);
245 This function processes the results of changes in configuration.
248 @param This Points to the EFI_HII_CONFIG_ACCESS_PROTOCOL.
249 @param Action Specifies the type of action taken by the browser.
250 @param QuestionId A unique value which is sent to the original exporting driver
251 so that it can identify the type of data to expect.
252 @param Type The type of value for the question.
253 @param Value A pointer to the data being sent to the original exporting driver.
254 @param ActionRequest On return, points to the action requested by the callback function.
256 @retval EFI_SUCCESS The callback successfully handled the action.
257 @retval EFI_OUT_OF_RESOURCES Not enough storage is available to hold the variable and its data.
258 @retval EFI_DEVICE_ERROR The variable could not be saved.
259 @retval EFI_UNSUPPORTED The specified Action is not supported by the callback.
260 @retval EFI_INVALID_PARAMETER The parameter of Value or ActionRequest is invalid.
265 IN CONST EFI_HII_CONFIG_ACCESS_PROTOCOL
*This
,
266 IN EFI_BROWSER_ACTION Action
,
267 IN EFI_QUESTION_ID QuestionId
,
269 IN EFI_IFR_TYPE_VALUE
*Value
,
270 OUT EFI_BROWSER_ACTION_REQUEST
*ActionRequest
273 BMM_CALLBACK_DATA
*Private
;
274 BM_MENU_ENTRY
*NewMenuEntry
;
275 BMM_FAKE_NV_DATA
*CurrentFakeNVMap
;
289 Status
= EFI_SUCCESS
;
291 if (Action
== EFI_BROWSER_ACTION_CHANGING
) {
292 if ((Value
== NULL
) || (ActionRequest
== NULL
)) {
293 return EFI_INVALID_PARAMETER
;
303 *ActionRequest
= EFI_BROWSER_ACTION_REQUEST_NONE
;
305 Private
= BMM_CALLBACK_DATA_FROM_THIS (This
);
306 UpdatePageId (Private
, QuestionId
);
309 // Retrive uncommitted data from Form Browser
311 CurrentFakeNVMap
= &Private
->BmmFakeNvData
;
312 HiiGetBrowserData (&gBootMaintFormSetGuid
, mBootMaintStorageName
, sizeof (BMM_FAKE_NV_DATA
), (UINT8
*) CurrentFakeNVMap
);
315 // need to be subtituded.
317 // Update Select FD/HD/CD/NET/BEV Order Form
319 if (FORM_SET_FD_ORDER_ID
== Private
->BmmPreviousPageId
||
320 FORM_SET_HD_ORDER_ID
== Private
->BmmPreviousPageId
||
321 FORM_SET_CD_ORDER_ID
== Private
->BmmPreviousPageId
||
322 FORM_SET_NET_ORDER_ID
== Private
->BmmPreviousPageId
||
323 FORM_SET_BEV_ORDER_ID
== Private
->BmmPreviousPageId
||
324 ((FORM_BOOT_SETUP_ID
== Private
->BmmPreviousPageId
) &&
325 (QuestionId
>= LEGACY_FD_QUESTION_ID
) &&
326 (QuestionId
< (LEGACY_BEV_QUESTION_ID
+ 100)) )
329 DisMap
= Private
->BmmOldFakeNVData
.DisableMap
;
331 FormId
= Private
->BmmPreviousPageId
;
332 if (FormId
== FORM_BOOT_SETUP_ID
) {
333 FormId
= Private
->BmmCurrentPageId
;
337 case FORM_SET_FD_ORDER_ID
:
338 Number
= (UINT16
) LegacyFDMenu
.MenuNumber
;
339 OldLegacyDev
= Private
->BmmOldFakeNVData
.LegacyFD
;
340 NewLegacyDev
= CurrentFakeNVMap
->LegacyFD
;
343 case FORM_SET_HD_ORDER_ID
:
344 Number
= (UINT16
) LegacyHDMenu
.MenuNumber
;
345 OldLegacyDev
= Private
->BmmOldFakeNVData
.LegacyHD
;
346 NewLegacyDev
= CurrentFakeNVMap
->LegacyHD
;
349 case FORM_SET_CD_ORDER_ID
:
350 Number
= (UINT16
) LegacyCDMenu
.MenuNumber
;
351 OldLegacyDev
= Private
->BmmOldFakeNVData
.LegacyCD
;
352 NewLegacyDev
= CurrentFakeNVMap
->LegacyCD
;
355 case FORM_SET_NET_ORDER_ID
:
356 Number
= (UINT16
) LegacyNETMenu
.MenuNumber
;
357 OldLegacyDev
= Private
->BmmOldFakeNVData
.LegacyNET
;
358 NewLegacyDev
= CurrentFakeNVMap
->LegacyNET
;
361 case FORM_SET_BEV_ORDER_ID
:
362 Number
= (UINT16
) LegacyBEVMenu
.MenuNumber
;
363 OldLegacyDev
= Private
->BmmOldFakeNVData
.LegacyBEV
;
364 NewLegacyDev
= CurrentFakeNVMap
->LegacyBEV
;
371 // First, find the different position
372 // if there is change, it should be only one
374 for (Index
= 0; Index
< Number
; Index
++) {
375 if (OldLegacyDev
[Index
] != NewLegacyDev
[Index
]) {
376 OldValue
= OldLegacyDev
[Index
];
377 NewValue
= NewLegacyDev
[Index
];
382 if (Index
!= Number
) {
384 // there is change, now process
386 if (0xFF == NewValue
) {
388 // This item will be disable
389 // Just move the items behind this forward to overlap it
392 Bit
= 7 - (OldValue
% 8);
393 DisMap
[Pos
] = (UINT8
) (DisMap
[Pos
] | (UINT8
) (1 << Bit
));
394 for (Index2
= Index
; Index2
< Number
- 1; Index2
++) {
395 NewLegacyDev
[Index2
] = NewLegacyDev
[Index2
+ 1];
398 NewLegacyDev
[Index2
] = 0xFF;
400 for (Index2
= 0; Index2
< Number
; Index2
++) {
401 if (Index2
== Index
) {
405 if (OldLegacyDev
[Index2
] == NewValue
) {
407 // If NewValue is in OldLegacyDev array
408 // remember its old position
410 NewValuePos
= Index2
;
415 if (Index2
!= Number
) {
417 // We will change current item to an existing item
418 // (It's hard to describe here, please read code, it's like a cycle-moving)
420 for (Index2
= NewValuePos
; Index2
!= Index
;) {
421 if (NewValuePos
< Index
) {
422 NewLegacyDev
[Index2
] = OldLegacyDev
[Index2
+ 1];
425 NewLegacyDev
[Index2
] = OldLegacyDev
[Index2
- 1];
431 // If NewValue is not in OldlegacyDev array, we are changing to a disabled item
432 // so we should modify DisMap to reflect the change
435 Bit
= 7 - (NewValue
% 8);
436 DisMap
[Pos
] = (UINT8
) (DisMap
[Pos
] & (~ (UINT8
) (1 << Bit
)));
437 if (0xFF != OldValue
) {
439 // Because NewValue is a item that was disabled before
440 // so after changing the OldValue should be disabled
441 // actually we are doing a swap of enable-disable states of two items
444 Bit
= 7 - (OldValue
% 8);
445 DisMap
[Pos
] = (UINT8
) (DisMap
[Pos
] | (UINT8
) (1 << Bit
));
450 // To prevent DISABLE appears in the middle of the list
451 // we should perform a re-ordering
454 while (Index
< Number
) {
455 if (0xFF != NewLegacyDev
[Index
]) {
462 while (Index2
< Number
) {
463 if (0xFF != NewLegacyDev
[Index2
]) {
470 if (Index2
< Number
) {
471 NewLegacyDev
[Index
] = NewLegacyDev
[Index2
];
472 NewLegacyDev
[Index2
] = 0xFF;
486 if (QuestionId
< FILE_OPTION_OFFSET
) {
487 if (QuestionId
< CONFIG_OPTION_OFFSET
) {
488 switch (QuestionId
) {
489 case KEY_VALUE_BOOT_FROM_FILE
:
490 Private
->FeCurrentState
= FileExplorerStateBootFromFile
;
493 // Exit Bmm main formset to send File Explorer formset.
495 *ActionRequest
= EFI_BROWSER_ACTION_REQUEST_EXIT
;
498 case FORM_BOOT_ADD_ID
:
499 Private
->FeCurrentState
= FileExplorerStateAddBootOption
;
502 // Exit Bmm main formset to send File Explorer formset.
504 *ActionRequest
= EFI_BROWSER_ACTION_REQUEST_EXIT
;
507 case FORM_DRV_ADD_FILE_ID
:
508 Private
->FeCurrentState
= FileExplorerStateAddDriverOptionState
;
511 // Exit Bmm main formset to send File Explorer formset.
513 *ActionRequest
= EFI_BROWSER_ACTION_REQUEST_EXIT
;
516 case FORM_DRV_ADD_HANDLE_ID
:
517 CleanUpPage (FORM_DRV_ADD_HANDLE_ID
, Private
);
518 UpdateDrvAddHandlePage (Private
);
521 case FORM_BOOT_DEL_ID
:
522 CleanUpPage (FORM_BOOT_DEL_ID
, Private
);
523 UpdateBootDelPage (Private
);
526 case FORM_BOOT_CHG_ID
:
527 case FORM_DRV_CHG_ID
:
528 UpdatePageBody (QuestionId
, Private
);
531 case FORM_DRV_DEL_ID
:
532 CleanUpPage (FORM_DRV_DEL_ID
, Private
);
533 UpdateDrvDelPage (Private
);
536 case FORM_BOOT_NEXT_ID
:
537 CleanUpPage (FORM_BOOT_NEXT_ID
, Private
);
538 UpdateBootNextPage (Private
);
541 case FORM_TIME_OUT_ID
:
542 CleanUpPage (FORM_TIME_OUT_ID
, Private
);
543 UpdateTimeOutPage (Private
);
547 gRT
->ResetSystem (EfiResetCold
, EFI_SUCCESS
, 0, NULL
);
548 return EFI_UNSUPPORTED
;
551 case FORM_CON_OUT_ID
:
552 case FORM_CON_ERR_ID
:
553 UpdatePageBody (QuestionId
, Private
);
556 case FORM_CON_MODE_ID
:
557 CleanUpPage (FORM_CON_MODE_ID
, Private
);
558 UpdateConModePage (Private
);
561 case FORM_CON_COM_ID
:
562 CleanUpPage (FORM_CON_COM_ID
, Private
);
563 UpdateConCOMPage (Private
);
566 case FORM_SET_FD_ORDER_ID
:
567 case FORM_SET_HD_ORDER_ID
:
568 case FORM_SET_CD_ORDER_ID
:
569 case FORM_SET_NET_ORDER_ID
:
570 case FORM_SET_BEV_ORDER_ID
:
571 CleanUpPage (QuestionId
, Private
);
572 UpdateSetLegacyDeviceOrderPage (QuestionId
, Private
);
575 case KEY_VALUE_SAVE_AND_EXIT
:
576 case KEY_VALUE_NO_SAVE_AND_EXIT
:
578 if (QuestionId
== KEY_VALUE_SAVE_AND_EXIT
) {
579 Status
= ApplyChangeHandler (Private
, CurrentFakeNVMap
, Private
->BmmPreviousPageId
);
580 if (EFI_ERROR (Status
)) {
583 } else if (QuestionId
== KEY_VALUE_NO_SAVE_AND_EXIT
) {
584 DiscardChangeHandler (Private
, CurrentFakeNVMap
);
588 // Tell browser not to ask for confirmation of changes,
589 // since we have already applied or discarded.
591 *ActionRequest
= EFI_BROWSER_ACTION_REQUEST_FORM_APPLY
;
597 } else if ((QuestionId
>= TERMINAL_OPTION_OFFSET
) && (QuestionId
< CONSOLE_OPTION_OFFSET
)) {
598 Index2
= (UINT16
) (QuestionId
- TERMINAL_OPTION_OFFSET
);
599 Private
->CurrentTerminal
= Index2
;
601 CleanUpPage (FORM_CON_COM_SETUP_ID
, Private
);
602 UpdateTerminalPage (Private
);
604 } else if (QuestionId
>= HANDLE_OPTION_OFFSET
) {
605 Index2
= (UINT16
) (QuestionId
- HANDLE_OPTION_OFFSET
);
607 NewMenuEntry
= BOpt_GetMenuEntry (&DriverMenu
, Index2
);
608 ASSERT (NewMenuEntry
!= NULL
);
609 Private
->HandleContext
= (BM_HANDLE_CONTEXT
*) NewMenuEntry
->VariableContext
;
611 CleanUpPage (FORM_DRV_ADD_HANDLE_DESC_ID
, Private
);
613 Private
->MenuEntry
= NewMenuEntry
;
614 Private
->LoadContext
->FilePathList
= Private
->HandleContext
->DevicePath
;
616 UpdateDriverAddHandleDescPage (Private
);
621 // Pass changed uncommitted data back to Form Browser
623 Status
= HiiSetBrowserData (&gBootMaintFormSetGuid
, mBootMaintStorageName
, sizeof (BMM_FAKE_NV_DATA
), (UINT8
*) CurrentFakeNVMap
, NULL
);
628 // All other action return unsupported.
630 return EFI_UNSUPPORTED
;
634 Function handling request to apply changes for BMM pages.
636 @param Private Pointer to callback data buffer.
637 @param CurrentFakeNVMap Pointer to buffer holding data of various values used by BMM
638 @param FormId ID of the form which has sent the request to apply change.
640 @retval EFI_SUCCESS Change successfully applied.
641 @retval Other Error occurs while trying to apply changes.
646 IN BMM_CALLBACK_DATA
*Private
,
647 IN BMM_FAKE_NV_DATA
*CurrentFakeNVMap
,
648 IN EFI_FORM_ID FormId
651 BM_CONSOLE_CONTEXT
*NewConsoleContext
;
652 BM_TERMINAL_CONTEXT
*NewTerminalContext
;
653 BM_LOAD_CONTEXT
*NewLoadContext
;
654 BM_MENU_ENTRY
*NewMenuEntry
;
658 Status
= EFI_SUCCESS
;
661 case FORM_SET_FD_ORDER_ID
:
662 case FORM_SET_HD_ORDER_ID
:
663 case FORM_SET_CD_ORDER_ID
:
664 case FORM_SET_NET_ORDER_ID
:
665 case FORM_SET_BEV_ORDER_ID
:
666 Var_UpdateBBSOption (Private
);
669 case FORM_BOOT_DEL_ID
:
671 ((Index
< BootOptionMenu
.MenuNumber
) && (Index
< (sizeof (CurrentFakeNVMap
->OptionDel
) / sizeof (CurrentFakeNVMap
->OptionDel
[0]))));
673 NewMenuEntry
= BOpt_GetMenuEntry (&BootOptionMenu
, Index
);
674 NewLoadContext
= (BM_LOAD_CONTEXT
*) NewMenuEntry
->VariableContext
;
675 NewLoadContext
->Deleted
= CurrentFakeNVMap
->OptionDel
[Index
];
678 Var_DelBootOption ();
681 case FORM_DRV_DEL_ID
:
683 ((Index
< DriverOptionMenu
.MenuNumber
) && (Index
< (sizeof (CurrentFakeNVMap
->OptionDel
) / sizeof (CurrentFakeNVMap
->OptionDel
[0]))));
685 NewMenuEntry
= BOpt_GetMenuEntry (&DriverOptionMenu
, Index
);
686 NewLoadContext
= (BM_LOAD_CONTEXT
*) NewMenuEntry
->VariableContext
;
687 NewLoadContext
->Deleted
= CurrentFakeNVMap
->OptionDel
[Index
];
690 Var_DelDriverOption ();
693 case FORM_BOOT_CHG_ID
:
694 Status
= Var_UpdateBootOrder (Private
);
697 case FORM_DRV_CHG_ID
:
698 Status
= Var_UpdateDriverOrder (Private
);
701 case FORM_TIME_OUT_ID
:
702 PcdSet16 (PcdPlatformBootTimeOut
, CurrentFakeNVMap
->BootTimeOut
);
704 Private
->BmmOldFakeNVData
.BootTimeOut
= CurrentFakeNVMap
->BootTimeOut
;
707 case FORM_BOOT_NEXT_ID
:
708 Status
= Var_UpdateBootNext (Private
);
711 case FORM_CON_MODE_ID
:
712 Status
= Var_UpdateConMode (Private
);
715 case FORM_CON_COM_SETUP_ID
:
716 NewMenuEntry
= BOpt_GetMenuEntry (&TerminalMenu
, Private
->CurrentTerminal
);
718 ASSERT (NewMenuEntry
!= NULL
);
720 NewTerminalContext
= (BM_TERMINAL_CONTEXT
*) NewMenuEntry
->VariableContext
;
722 NewTerminalContext
->BaudRateIndex
= CurrentFakeNVMap
->COMBaudRate
;
723 ASSERT (CurrentFakeNVMap
->COMBaudRate
< (sizeof (BaudRateList
) / sizeof (BaudRateList
[0])));
724 NewTerminalContext
->BaudRate
= BaudRateList
[CurrentFakeNVMap
->COMBaudRate
].Value
;
725 NewTerminalContext
->DataBitsIndex
= CurrentFakeNVMap
->COMDataRate
;
726 ASSERT (CurrentFakeNVMap
->COMDataRate
< (sizeof (DataBitsList
) / sizeof (DataBitsList
[0])));
727 NewTerminalContext
->DataBits
= (UINT8
) DataBitsList
[CurrentFakeNVMap
->COMDataRate
].Value
;
728 NewTerminalContext
->StopBitsIndex
= CurrentFakeNVMap
->COMStopBits
;
729 ASSERT (CurrentFakeNVMap
->COMStopBits
< (sizeof (StopBitsList
) / sizeof (StopBitsList
[0])));
730 NewTerminalContext
->StopBits
= (UINT8
) StopBitsList
[CurrentFakeNVMap
->COMStopBits
].Value
;
731 NewTerminalContext
->ParityIndex
= CurrentFakeNVMap
->COMParity
;
732 ASSERT (CurrentFakeNVMap
->COMParity
< (sizeof (ParityList
) / sizeof (ParityList
[0])));
733 NewTerminalContext
->Parity
= (UINT8
) ParityList
[CurrentFakeNVMap
->COMParity
].Value
;
734 NewTerminalContext
->TerminalType
= CurrentFakeNVMap
->COMTerminalType
;
735 NewTerminalContext
->FlowControl
= CurrentFakeNVMap
->COMFlowControl
;
737 ChangeTerminalDevicePath (
738 &(NewTerminalContext
->DevicePath
),
742 Var_UpdateConsoleInpOption ();
743 Var_UpdateConsoleOutOption ();
744 Var_UpdateErrorOutOption ();
748 for (Index
= 0; Index
< ConsoleInpMenu
.MenuNumber
; Index
++) {
749 NewMenuEntry
= BOpt_GetMenuEntry (&ConsoleInpMenu
, Index
);
750 NewConsoleContext
= (BM_CONSOLE_CONTEXT
*) NewMenuEntry
->VariableContext
;
751 ASSERT (Index
< MAX_MENU_NUMBER
);
752 NewConsoleContext
->IsActive
= CurrentFakeNVMap
->ConsoleCheck
[Index
];
755 for (Index
= 0; Index
< TerminalMenu
.MenuNumber
; Index
++) {
756 NewMenuEntry
= BOpt_GetMenuEntry (&TerminalMenu
, Index
);
757 NewTerminalContext
= (BM_TERMINAL_CONTEXT
*) NewMenuEntry
->VariableContext
;
758 ASSERT (Index
+ ConsoleInpMenu
.MenuNumber
< MAX_MENU_NUMBER
);
759 NewTerminalContext
->IsConIn
= CurrentFakeNVMap
->ConsoleCheck
[Index
+ ConsoleInpMenu
.MenuNumber
];
762 Var_UpdateConsoleInpOption ();
765 case FORM_CON_OUT_ID
:
766 for (Index
= 0; Index
< ConsoleOutMenu
.MenuNumber
; Index
++) {
767 NewMenuEntry
= BOpt_GetMenuEntry (&ConsoleOutMenu
, Index
);
768 NewConsoleContext
= (BM_CONSOLE_CONTEXT
*) NewMenuEntry
->VariableContext
;
769 ASSERT (Index
< MAX_MENU_NUMBER
);
770 NewConsoleContext
->IsActive
= CurrentFakeNVMap
->ConsoleCheck
[Index
];
773 for (Index
= 0; Index
< TerminalMenu
.MenuNumber
; Index
++) {
774 NewMenuEntry
= BOpt_GetMenuEntry (&TerminalMenu
, Index
);
775 NewTerminalContext
= (BM_TERMINAL_CONTEXT
*) NewMenuEntry
->VariableContext
;
776 ASSERT (Index
+ ConsoleOutMenu
.MenuNumber
< MAX_MENU_NUMBER
);
777 NewTerminalContext
->IsConOut
= CurrentFakeNVMap
->ConsoleCheck
[Index
+ ConsoleOutMenu
.MenuNumber
];
780 Var_UpdateConsoleOutOption ();
783 case FORM_CON_ERR_ID
:
784 for (Index
= 0; Index
< ConsoleErrMenu
.MenuNumber
; Index
++) {
785 NewMenuEntry
= BOpt_GetMenuEntry (&ConsoleErrMenu
, Index
);
786 NewConsoleContext
= (BM_CONSOLE_CONTEXT
*) NewMenuEntry
->VariableContext
;
787 ASSERT (Index
< MAX_MENU_NUMBER
);
788 NewConsoleContext
->IsActive
= CurrentFakeNVMap
->ConsoleCheck
[Index
];
791 for (Index
= 0; Index
< TerminalMenu
.MenuNumber
; Index
++) {
792 NewMenuEntry
= BOpt_GetMenuEntry (&TerminalMenu
, Index
);
793 NewTerminalContext
= (BM_TERMINAL_CONTEXT
*) NewMenuEntry
->VariableContext
;
794 ASSERT (Index
+ ConsoleErrMenu
.MenuNumber
< MAX_MENU_NUMBER
);
795 NewTerminalContext
->IsStdErr
= CurrentFakeNVMap
->ConsoleCheck
[Index
+ ConsoleErrMenu
.MenuNumber
];
798 Var_UpdateErrorOutOption ();
801 case FORM_DRV_ADD_HANDLE_DESC_ID
:
802 Status
= Var_UpdateDriverOption (
804 Private
->BmmHiiHandle
,
805 CurrentFakeNVMap
->DriverAddHandleDesc
,
806 CurrentFakeNVMap
->DriverAddHandleOptionalData
,
807 CurrentFakeNVMap
->DriverAddForceReconnect
809 if (EFI_ERROR (Status
)) {
813 BOpt_GetDriverOptions (Private
);
814 CreateMenuStringToken (Private
, Private
->BmmHiiHandle
, &DriverOptionMenu
);
826 Discard all changes done to the BMM pages such as Boot Order change,
829 @param Private The BMM context data.
830 @param CurrentFakeNVMap The current Fack NV Map.
834 DiscardChangeHandler (
835 IN BMM_CALLBACK_DATA
*Private
,
836 IN BMM_FAKE_NV_DATA
*CurrentFakeNVMap
841 switch (Private
->BmmPreviousPageId
) {
842 case FORM_BOOT_CHG_ID
:
843 case FORM_DRV_CHG_ID
:
844 CopyMem (CurrentFakeNVMap
->OptionOrder
, Private
->BmmOldFakeNVData
.OptionOrder
, sizeof (CurrentFakeNVMap
->OptionOrder
));
847 case FORM_BOOT_DEL_ID
:
848 ASSERT (BootOptionMenu
.MenuNumber
<= (sizeof (CurrentFakeNVMap
->OptionDel
) / sizeof (CurrentFakeNVMap
->OptionDel
[0])));
849 for (Index
= 0; Index
< BootOptionMenu
.MenuNumber
; Index
++) {
850 CurrentFakeNVMap
->OptionDel
[Index
] = FALSE
;
854 case FORM_DRV_DEL_ID
:
855 ASSERT (DriverOptionMenu
.MenuNumber
<= (sizeof (CurrentFakeNVMap
->OptionDel
) / sizeof (CurrentFakeNVMap
->OptionDel
[0])));
856 for (Index
= 0; Index
< DriverOptionMenu
.MenuNumber
; Index
++) {
857 CurrentFakeNVMap
->OptionDel
[Index
] = FALSE
;
861 case FORM_BOOT_NEXT_ID
:
862 CurrentFakeNVMap
->BootNext
= Private
->BmmOldFakeNVData
.BootNext
;
865 case FORM_TIME_OUT_ID
:
866 CurrentFakeNVMap
->BootTimeOut
= Private
->BmmOldFakeNVData
.BootTimeOut
;
869 case FORM_DRV_ADD_HANDLE_DESC_ID
:
870 case FORM_DRV_ADD_FILE_ID
:
871 case FORM_DRV_ADD_HANDLE_ID
:
872 CurrentFakeNVMap
->DriverAddHandleDesc
[0] = 0x0000;
873 CurrentFakeNVMap
->DriverAddHandleOptionalData
[0] = 0x0000;
882 Initialize the Boot Maintenance Utitliy.
885 @retval EFI_SUCCESS utility ended successfully
886 @retval others contain some errors
894 EFI_LEGACY_BIOS_PROTOCOL
*LegacyBios
;
895 BMM_CALLBACK_DATA
*BmmCallbackInfo
;
899 Status
= EFI_SUCCESS
;
902 // Create CallbackData structures for Driver Callback
904 BmmCallbackInfo
= AllocateZeroPool (sizeof (BMM_CALLBACK_DATA
));
905 if (BmmCallbackInfo
== NULL
) {
906 return EFI_OUT_OF_RESOURCES
;
910 // Create LoadOption in BmmCallbackInfo for Driver Callback
912 Ptr
= AllocateZeroPool (sizeof (BM_LOAD_CONTEXT
) + sizeof (BM_FILE_CONTEXT
) + sizeof (BM_HANDLE_CONTEXT
) + sizeof (BM_MENU_ENTRY
));
914 FreePool (BmmCallbackInfo
);
915 return EFI_OUT_OF_RESOURCES
;
919 // Initialize Bmm callback data.
921 BmmCallbackInfo
->LoadContext
= (BM_LOAD_CONTEXT
*) Ptr
;
922 Ptr
+= sizeof (BM_LOAD_CONTEXT
);
924 BmmCallbackInfo
->FileContext
= (BM_FILE_CONTEXT
*) Ptr
;
925 Ptr
+= sizeof (BM_FILE_CONTEXT
);
927 BmmCallbackInfo
->HandleContext
= (BM_HANDLE_CONTEXT
*) Ptr
;
928 Ptr
+= sizeof (BM_HANDLE_CONTEXT
);
930 BmmCallbackInfo
->MenuEntry
= (BM_MENU_ENTRY
*) Ptr
;
932 BmmCallbackInfo
->Signature
= BMM_CALLBACK_DATA_SIGNATURE
;
933 BmmCallbackInfo
->BmmConfigAccess
.ExtractConfig
= BootMaintExtractConfig
;
934 BmmCallbackInfo
->BmmConfigAccess
.RouteConfig
= FakeRouteConfig
;
935 BmmCallbackInfo
->BmmConfigAccess
.Callback
= BootMaintCallback
;
936 BmmCallbackInfo
->BmmPreviousPageId
= FORM_MAIN_ID
;
937 BmmCallbackInfo
->BmmCurrentPageId
= FORM_MAIN_ID
;
938 BmmCallbackInfo
->FeConfigAccess
.ExtractConfig
= FakeExtractConfig
;
939 BmmCallbackInfo
->FeConfigAccess
.RouteConfig
= FakeRouteConfig
;
940 BmmCallbackInfo
->FeConfigAccess
.Callback
= FileExplorerCallback
;
941 BmmCallbackInfo
->FeCurrentState
= FileExplorerStateInActive
;
942 BmmCallbackInfo
->FeDisplayContext
= FileExplorerDisplayUnknown
;
945 // Install Device Path Protocol and Config Access protocol to driver handle
947 Status
= gBS
->InstallMultipleProtocolInterfaces (
948 &BmmCallbackInfo
->BmmDriverHandle
,
949 &gEfiDevicePathProtocolGuid
,
950 &mBmmHiiVendorDevicePath
,
951 &gEfiHiiConfigAccessProtocolGuid
,
952 &BmmCallbackInfo
->BmmConfigAccess
,
955 if (EFI_ERROR (Status
)) {
960 // Install Device Path Protocol and Config Access protocol to driver handle
962 Status
= gBS
->InstallMultipleProtocolInterfaces (
963 &BmmCallbackInfo
->FeDriverHandle
,
964 &gEfiDevicePathProtocolGuid
,
965 &mFeHiiVendorDevicePath
,
966 &gEfiHiiConfigAccessProtocolGuid
,
967 &BmmCallbackInfo
->FeConfigAccess
,
970 if (EFI_ERROR (Status
)) {
975 // Post our Boot Maint VFR binary to the HII database.
977 BmmCallbackInfo
->BmmHiiHandle
= HiiAddPackages (
978 &gBootMaintFormSetGuid
,
979 BmmCallbackInfo
->BmmDriverHandle
,
984 ASSERT (BmmCallbackInfo
->BmmHiiHandle
!= NULL
);
987 // Post our File Explorer VFR binary to the HII database.
989 BmmCallbackInfo
->FeHiiHandle
= HiiAddPackages (
990 &gFileExploreFormSetGuid
,
991 BmmCallbackInfo
->FeDriverHandle
,
996 ASSERT (BmmCallbackInfo
->FeHiiHandle
!= NULL
);
999 // Init OpCode Handle and Allocate space for creation of Buffer
1001 mStartOpCodeHandle
= HiiAllocateOpCodeHandle ();
1002 if (mStartOpCodeHandle
== NULL
) {
1003 Status
= EFI_OUT_OF_RESOURCES
;
1007 mEndOpCodeHandle
= HiiAllocateOpCodeHandle ();
1008 if (mEndOpCodeHandle
== NULL
) {
1009 Status
= EFI_OUT_OF_RESOURCES
;
1014 // Create Hii Extend Label OpCode as the start opcode
1016 mStartLabel
= (EFI_IFR_GUID_LABEL
*) HiiCreateGuidOpCode (mStartOpCodeHandle
, &gEfiIfrTianoGuid
, NULL
, sizeof (EFI_IFR_GUID_LABEL
));
1017 mStartLabel
->ExtendOpCode
= EFI_IFR_EXTEND_OP_LABEL
;
1020 // Create Hii Extend Label OpCode as the end opcode
1022 mEndLabel
= (EFI_IFR_GUID_LABEL
*) HiiCreateGuidOpCode (mEndOpCodeHandle
, &gEfiIfrTianoGuid
, NULL
, sizeof (EFI_IFR_GUID_LABEL
));
1023 mEndLabel
->ExtendOpCode
= EFI_IFR_EXTEND_OP_LABEL
;
1024 mEndLabel
->Number
= LABEL_END
;
1026 InitializeStringDepository ();
1028 InitAllMenu (BmmCallbackInfo
);
1030 CreateMenuStringToken (BmmCallbackInfo
, BmmCallbackInfo
->BmmHiiHandle
, &ConsoleInpMenu
);
1031 CreateMenuStringToken (BmmCallbackInfo
, BmmCallbackInfo
->BmmHiiHandle
, &ConsoleOutMenu
);
1032 CreateMenuStringToken (BmmCallbackInfo
, BmmCallbackInfo
->BmmHiiHandle
, &ConsoleErrMenu
);
1033 CreateMenuStringToken (BmmCallbackInfo
, BmmCallbackInfo
->BmmHiiHandle
, &BootOptionMenu
);
1034 CreateMenuStringToken (BmmCallbackInfo
, BmmCallbackInfo
->BmmHiiHandle
, &DriverOptionMenu
);
1035 CreateMenuStringToken (BmmCallbackInfo
, BmmCallbackInfo
->BmmHiiHandle
, &TerminalMenu
);
1036 CreateMenuStringToken (BmmCallbackInfo
, BmmCallbackInfo
->BmmHiiHandle
, &DriverMenu
);
1038 UpdateBootDelPage (BmmCallbackInfo
);
1039 UpdateDrvDelPage (BmmCallbackInfo
);
1041 if (TerminalMenu
.MenuNumber
> 0) {
1042 BmmCallbackInfo
->CurrentTerminal
= 0;
1043 UpdateTerminalPage (BmmCallbackInfo
);
1046 Status
= EfiLibLocateProtocol (&gEfiLegacyBiosProtocolGuid
, (VOID
**) &LegacyBios
);
1047 if (!EFI_ERROR (Status
)) {
1048 RefreshUpdateData ();
1049 mStartLabel
->Number
= FORM_BOOT_LEGACY_DEVICE_ID
;
1052 // If LegacyBios Protocol is installed, add 3 tags about legacy boot option
1053 // in BootOption form: legacy FD/HD/CD/NET/BEV
1055 HiiCreateGotoOpCode (
1057 FORM_SET_FD_ORDER_ID
,
1058 STRING_TOKEN (STR_FORM_SET_FD_ORDER_TITLE
),
1059 STRING_TOKEN (STR_FORM_SET_FD_ORDER_TITLE
),
1060 EFI_IFR_FLAG_CALLBACK
,
1061 FORM_SET_FD_ORDER_ID
1064 HiiCreateGotoOpCode (
1066 FORM_SET_HD_ORDER_ID
,
1067 STRING_TOKEN (STR_FORM_SET_HD_ORDER_TITLE
),
1068 STRING_TOKEN (STR_FORM_SET_HD_ORDER_TITLE
),
1069 EFI_IFR_FLAG_CALLBACK
,
1070 FORM_SET_HD_ORDER_ID
1073 HiiCreateGotoOpCode (
1075 FORM_SET_CD_ORDER_ID
,
1076 STRING_TOKEN (STR_FORM_SET_CD_ORDER_TITLE
),
1077 STRING_TOKEN (STR_FORM_SET_CD_ORDER_TITLE
),
1078 EFI_IFR_FLAG_CALLBACK
,
1079 FORM_SET_CD_ORDER_ID
1082 HiiCreateGotoOpCode (
1084 FORM_SET_NET_ORDER_ID
,
1085 STRING_TOKEN (STR_FORM_SET_NET_ORDER_TITLE
),
1086 STRING_TOKEN (STR_FORM_SET_NET_ORDER_TITLE
),
1087 EFI_IFR_FLAG_CALLBACK
,
1088 FORM_SET_NET_ORDER_ID
1091 HiiCreateGotoOpCode (
1093 FORM_SET_BEV_ORDER_ID
,
1094 STRING_TOKEN (STR_FORM_SET_BEV_ORDER_TITLE
),
1095 STRING_TOKEN (STR_FORM_SET_BEV_ORDER_TITLE
),
1096 EFI_IFR_FLAG_CALLBACK
,
1097 FORM_SET_BEV_ORDER_ID
1101 BmmCallbackInfo
->BmmHiiHandle
,
1102 &gBootMaintFormSetGuid
,
1104 mStartOpCodeHandle
, // Label FORM_BOOT_LEGACY_DEVICE_ID
1105 mEndOpCodeHandle
// LABEL_END
1110 // Dispatch BMM main formset and File Explorer formset.
1112 FormSetDispatcher (BmmCallbackInfo
);
1115 // Remove our IFR data from HII database
1117 HiiRemovePackages (BmmCallbackInfo
->BmmHiiHandle
);
1118 HiiRemovePackages (BmmCallbackInfo
->FeHiiHandle
);
1120 CleanUpStringDepository ();
1125 if (mStartOpCodeHandle
!= NULL
) {
1126 HiiFreeOpCodeHandle (mStartOpCodeHandle
);
1129 if (mEndOpCodeHandle
!= NULL
) {
1130 HiiFreeOpCodeHandle (mEndOpCodeHandle
);
1133 if (BmmCallbackInfo
->FeDriverHandle
!= NULL
) {
1134 gBS
->UninstallMultipleProtocolInterfaces (
1135 BmmCallbackInfo
->FeDriverHandle
,
1136 &gEfiDevicePathProtocolGuid
,
1137 &mFeHiiVendorDevicePath
,
1138 &gEfiHiiConfigAccessProtocolGuid
,
1139 &BmmCallbackInfo
->FeConfigAccess
,
1144 if (BmmCallbackInfo
->BmmDriverHandle
!= NULL
) {
1145 gBS
->UninstallMultipleProtocolInterfaces (
1146 BmmCallbackInfo
->BmmDriverHandle
,
1147 &gEfiDevicePathProtocolGuid
,
1148 &mBmmHiiVendorDevicePath
,
1149 &gEfiHiiConfigAccessProtocolGuid
,
1150 &BmmCallbackInfo
->BmmConfigAccess
,
1155 FreePool (BmmCallbackInfo
->LoadContext
);
1156 FreePool (BmmCallbackInfo
);
1162 Initialized all Menu Option List.
1164 @param CallbackData The BMM context data.
1169 IN BMM_CALLBACK_DATA
*CallbackData
1172 InitializeListHead (&BootOptionMenu
.Head
);
1173 InitializeListHead (&DriverOptionMenu
.Head
);
1174 BOpt_GetBootOptions (CallbackData
);
1175 BOpt_GetDriverOptions (CallbackData
);
1176 BOpt_GetLegacyOptions ();
1177 InitializeListHead (&FsOptionMenu
.Head
);
1178 BOpt_FindDrivers ();
1179 InitializeListHead (&DirectoryMenu
.Head
);
1180 InitializeListHead (&ConsoleInpMenu
.Head
);
1181 InitializeListHead (&ConsoleOutMenu
.Head
);
1182 InitializeListHead (&ConsoleErrMenu
.Head
);
1183 InitializeListHead (&TerminalMenu
.Head
);
1189 Free up all Menu Option list.
1197 BOpt_FreeMenu (&DirectoryMenu
);
1198 BOpt_FreeMenu (&FsOptionMenu
);
1199 BOpt_FreeMenu (&BootOptionMenu
);
1200 BOpt_FreeMenu (&DriverOptionMenu
);
1201 BOpt_FreeMenu (&DriverMenu
);
1202 BOpt_FreeLegacyOptions ();
1207 Initialize all the string depositories.
1211 InitializeStringDepository (
1215 STRING_DEPOSITORY
*StringDepository
;
1216 StringDepository
= AllocateZeroPool (sizeof (STRING_DEPOSITORY
) * STRING_DEPOSITORY_NUMBER
);
1217 FileOptionStrDepository
= StringDepository
++;
1218 ConsoleOptionStrDepository
= StringDepository
++;
1219 BootOptionStrDepository
= StringDepository
++;
1220 BootOptionHelpStrDepository
= StringDepository
++;
1221 DriverOptionStrDepository
= StringDepository
++;
1222 DriverOptionHelpStrDepository
= StringDepository
++;
1223 TerminalStrDepository
= StringDepository
;
1227 Fetch a usable string node from the string depository and return the string token.
1229 @param CallbackData The BMM context data.
1230 @param StringDepository The string repository.
1232 @retval EFI_STRING_ID String token.
1236 GetStringTokenFromDepository (
1237 IN BMM_CALLBACK_DATA
*CallbackData
,
1238 IN STRING_DEPOSITORY
*StringDepository
1241 STRING_LIST_NODE
*CurrentListNode
;
1242 STRING_LIST_NODE
*NextListNode
;
1244 CurrentListNode
= StringDepository
->CurrentNode
;
1246 if ((NULL
!= CurrentListNode
) && (NULL
!= CurrentListNode
->Next
)) {
1248 // Fetch one reclaimed node from the list.
1250 NextListNode
= StringDepository
->CurrentNode
->Next
;
1253 // If there is no usable node in the list, update the list.
1255 NextListNode
= AllocateZeroPool (sizeof (STRING_LIST_NODE
));
1256 ASSERT (NextListNode
!= NULL
);
1257 NextListNode
->StringToken
= HiiSetString (CallbackData
->BmmHiiHandle
, 0, L
" ", NULL
);
1258 ASSERT (NextListNode
->StringToken
!= 0);
1260 StringDepository
->TotalNodeNumber
++;
1262 if (NULL
== CurrentListNode
) {
1263 StringDepository
->ListHead
= NextListNode
;
1265 CurrentListNode
->Next
= NextListNode
;
1269 StringDepository
->CurrentNode
= NextListNode
;
1271 return StringDepository
->CurrentNode
->StringToken
;
1275 Reclaim string depositories by moving the current node pointer to list head..
1279 ReclaimStringDepository (
1283 UINTN DepositoryIndex
;
1284 STRING_DEPOSITORY
*StringDepository
;
1286 StringDepository
= FileOptionStrDepository
;
1287 for (DepositoryIndex
= 0; DepositoryIndex
< STRING_DEPOSITORY_NUMBER
; DepositoryIndex
++) {
1288 StringDepository
->CurrentNode
= StringDepository
->ListHead
;
1294 Release resource for all the string depositories.
1298 CleanUpStringDepository (
1303 UINTN DepositoryIndex
;
1304 STRING_LIST_NODE
*CurrentListNode
;
1305 STRING_LIST_NODE
*NextListNode
;
1306 STRING_DEPOSITORY
*StringDepository
;
1309 // Release string list nodes.
1311 StringDepository
= FileOptionStrDepository
;
1312 for (DepositoryIndex
= 0; DepositoryIndex
< STRING_DEPOSITORY_NUMBER
; DepositoryIndex
++) {
1313 CurrentListNode
= StringDepository
->ListHead
;
1314 for (NodeIndex
= 0; NodeIndex
< StringDepository
->TotalNodeNumber
; NodeIndex
++) {
1315 NextListNode
= CurrentListNode
->Next
;
1316 FreePool (CurrentListNode
);
1317 CurrentListNode
= NextListNode
;
1323 // Release string depository.
1325 FreePool (FileOptionStrDepository
);
1329 Start boot maintenance manager
1331 @retval EFI_SUCCESS If BMM is invoked successfully.
1332 @return Other value if BMM return unsuccessfully.
1341 LIST_ENTRY BdsBootOptionList
;
1343 InitializeListHead (&BdsBootOptionList
);
1346 // Connect all prior to entering the platform setup menu.
1348 if (!gConnectAllHappened
) {
1349 BdsLibConnectAllDriversToAllControllers ();
1350 gConnectAllHappened
= TRUE
;
1353 // Have chance to enumerate boot device
1355 BdsLibEnumerateAllBootOption (&BdsBootOptionList
);
1360 Status
= InitializeBM ();
1366 Dispatch BMM formset and FileExplorer formset.
1369 @param CallbackData The BMM context data.
1371 @retval EFI_SUCCESS If function complete successfully.
1372 @return Other value if the Setup Browser process BMM's pages and
1373 return unsuccessfully.
1378 IN BMM_CALLBACK_DATA
*CallbackData
1382 EFI_BROWSER_ACTION_REQUEST ActionRequest
;
1385 UpdatePageId (CallbackData
, FORM_MAIN_ID
);
1387 ActionRequest
= EFI_BROWSER_ACTION_REQUEST_NONE
;
1388 Status
= gFormBrowser2
->SendForm (
1390 &CallbackData
->BmmHiiHandle
,
1392 &gBootMaintFormSetGuid
,
1397 if (ActionRequest
== EFI_BROWSER_ACTION_REQUEST_RESET
) {
1398 EnableResetRequired ();
1401 ReclaimStringDepository ();
1404 // When this Formset returns, check if we are going to explore files.
1406 if (FileExplorerStateInActive
!= CallbackData
->FeCurrentState
) {
1407 UpdateFileExplorer (CallbackData
, 0);
1409 ActionRequest
= EFI_BROWSER_ACTION_REQUEST_NONE
;
1410 Status
= gFormBrowser2
->SendForm (
1412 &CallbackData
->FeHiiHandle
,
1414 &gFileExploreFormSetGuid
,
1419 if (ActionRequest
== EFI_BROWSER_ACTION_REQUEST_RESET
) {
1420 EnableResetRequired ();
1423 CallbackData
->FeCurrentState
= FileExplorerStateInActive
;
1424 CallbackData
->FeDisplayContext
= FileExplorerDisplayUnknown
;
1425 ReclaimStringDepository ();
1436 Deletete the Boot Option from EFI Variable. The Boot Order Arrray
1439 @param OptionNumber The number of Boot option want to be deleted.
1440 @param BootOrder The Boot Order array.
1441 @param BootOrderSize The size of the Boot Order Array.
1443 @retval EFI_SUCCESS The Boot Option Variable was found and removed
1444 @retval EFI_UNSUPPORTED The Boot Option Variable store was inaccessible
1445 @retval EFI_NOT_FOUND The Boot Option Variable was not found
1449 BdsDeleteBootOption (
1450 IN UINTN OptionNumber
,
1451 IN OUT UINT16
*BootOrder
,
1452 IN OUT UINTN
*BootOrderSize
1455 UINT16 BootOption
[100];
1460 Status
= EFI_SUCCESS
;
1463 UnicodeSPrint (BootOption
, sizeof (BootOption
), L
"Boot%04x", OptionNumber
);
1464 Status
= EfiLibDeleteVariable (BootOption
, &gEfiGlobalVariableGuid
);
1467 // adjust boot order array
1469 for (Index
= 0; Index
< *BootOrderSize
/ sizeof (UINT16
); Index
++) {
1470 if (BootOrder
[Index
] == OptionNumber
) {
1476 if (Index
!= *BootOrderSize
/ sizeof (UINT16
)) {
1477 for (Index
= 0; Index
< *BootOrderSize
/ sizeof (UINT16
) - 1; Index
++) {
1478 if (Index
>= Index2Del
) {
1479 BootOrder
[Index
] = BootOrder
[Index
+ 1];
1483 *BootOrderSize
-= sizeof (UINT16
);