2 The functions for Boot Maintainence Main menu.
4 Copyright (c) 2004 - 2010, 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)
42 // {165A028F-0BB2-4b5f-8747-77592E3F6499}
44 { 0x165a028f, 0xbb2, 0x4b5f, { 0x87, 0x47, 0x77, 0x59, 0x2e, 0x3f, 0x64, 0x99 } }
48 END_ENTIRE_DEVICE_PATH_SUBTYPE
,
50 (UINT8
) (END_DEVICE_PATH_LENGTH
),
51 (UINT8
) ((END_DEVICE_PATH_LENGTH
) >> 8)
56 HII_VENDOR_DEVICE_PATH mFeHiiVendorDevicePath
= {
62 (UINT8
) (sizeof (VENDOR_DEVICE_PATH
)),
63 (UINT8
) ((sizeof (VENDOR_DEVICE_PATH
)) >> 8)
67 // {91DB4238-B0C8-472e-BBCF-F3A6541010F4}
69 { 0x91db4238, 0xb0c8, 0x472e, { 0xbb, 0xcf, 0xf3, 0xa6, 0x54, 0x10, 0x10, 0xf4 } }
73 END_ENTIRE_DEVICE_PATH_SUBTYPE
,
75 (UINT8
) (END_DEVICE_PATH_LENGTH
),
76 (UINT8
) ((END_DEVICE_PATH_LENGTH
) >> 8)
81 EFI_GUID EfiLegacyDevOrderGuid
= EFI_LEGACY_DEV_ORDER_VARIABLE_GUID
;
82 EFI_GUID mBootMaintGuid
= BOOT_MAINT_FORMSET_GUID
;
83 EFI_GUID mFileExplorerGuid
= FILE_EXPLORE_FORMSET_GUID
;
85 CHAR16 mBootMaintStorageName
[] = L
"BmmData";
86 CHAR16 mFileExplorerStorageName
[] = L
"FeData";
91 @param CallbackData The BMM context data.
96 IN BMM_CALLBACK_DATA
*CallbackData
100 Free up all Menu Option list.
109 Create string tokens for a menu from its help strings and display strings
111 @param CallbackData The BMM context data.
112 @param HiiHandle Hii Handle of the package to be updated.
113 @param MenuOption The Menu whose string tokens need to be created
115 @retval EFI_SUCCESS String tokens created successfully
116 @retval others contain some errors
119 CreateMenuStringToken (
120 IN BMM_CALLBACK_DATA
*CallbackData
,
121 IN EFI_HII_HANDLE HiiHandle
,
122 IN BM_MENU_OPTION
*MenuOption
125 BM_MENU_ENTRY
*NewMenuEntry
;
128 for (Index
= 0; Index
< MenuOption
->MenuNumber
; Index
++) {
129 NewMenuEntry
= BOpt_GetMenuEntry (MenuOption
, Index
);
131 NewMenuEntry
->DisplayStringToken
= HiiSetString (
134 NewMenuEntry
->DisplayString
,
138 if (NULL
== NewMenuEntry
->HelpString
) {
139 NewMenuEntry
->HelpStringToken
= NewMenuEntry
->DisplayStringToken
;
141 NewMenuEntry
->HelpStringToken
= HiiSetString (
144 NewMenuEntry
->HelpString
,
154 This function allows a caller to extract the current configuration for one
155 or more named elements from the target driver.
158 @param This Points to the EFI_HII_CONFIG_ACCESS_PROTOCOL.
159 @param Request A null-terminated Unicode string in <ConfigRequest> format.
160 @param Progress On return, points to a character in the Request string.
161 Points to the string's null terminator if request was successful.
162 Points to the most recent '&' before the first failing name/value
163 pair (or the beginning of the string if the failure is in the
164 first name/value pair) if the request was not successful.
165 @param Results A null-terminated Unicode string in <ConfigAltResp> format which
166 has all values filled in for the names in the Request string.
167 String to be allocated by the called function.
169 @retval EFI_SUCCESS The Results is filled with the requested values.
170 @retval EFI_OUT_OF_RESOURCES Not enough memory to store the results.
171 @retval EFI_INVALID_PARAMETER Request is NULL, illegal syntax, or unknown name.
172 @retval EFI_NOT_FOUND Routing data doesn't match any storage in this driver.
177 BootMaintExtractConfig (
178 IN CONST EFI_HII_CONFIG_ACCESS_PROTOCOL
*This
,
179 IN CONST EFI_STRING Request
,
180 OUT EFI_STRING
*Progress
,
181 OUT EFI_STRING
*Results
186 BMM_CALLBACK_DATA
*Private
;
187 EFI_STRING ConfigRequestHdr
;
188 EFI_STRING ConfigRequest
;
189 BOOLEAN AllocatedRequest
;
192 if (Progress
== NULL
|| Results
== NULL
) {
193 return EFI_INVALID_PARAMETER
;
197 if ((Request
!= NULL
) && !HiiIsConfigHdrMatch (Request
, &mBootMaintGuid
, mBootMaintStorageName
)) {
198 return EFI_NOT_FOUND
;
201 ConfigRequestHdr
= NULL
;
202 ConfigRequest
= NULL
;
203 AllocatedRequest
= FALSE
;
206 Private
= BMM_CALLBACK_DATA_FROM_THIS (This
);
208 // Convert buffer data to <ConfigResp> by helper function BlockToConfig()
210 BufferSize
= sizeof (BMM_FAKE_NV_DATA
);
211 ConfigRequest
= Request
;
212 if ((Request
== NULL
) || (StrStr (Request
, L
"OFFSET") == NULL
)) {
214 // Request has no request element, construct full request string.
215 // Allocate and fill a buffer large enough to hold the <ConfigHdr> template
216 // followed by "&OFFSET=0&WIDTH=WWWWWWWWWWWWWWWW" followed by a Null-terminator
218 ConfigRequestHdr
= HiiConstructConfigHdr (&mBootMaintGuid
, mBootMaintStorageName
, Private
->BmmDriverHandle
);
219 Size
= (StrLen (ConfigRequestHdr
) + 32 + 1) * sizeof (CHAR16
);
220 ConfigRequest
= AllocateZeroPool (Size
);
221 ASSERT (ConfigRequest
!= NULL
);
222 AllocatedRequest
= TRUE
;
223 UnicodeSPrint (ConfigRequest
, Size
, L
"%s&OFFSET=0&WIDTH=%016LX", ConfigRequestHdr
, (UINT64
)BufferSize
);
224 FreePool (ConfigRequestHdr
);
227 Status
= gHiiConfigRouting
->BlockToConfig (
230 (UINT8
*) &Private
->BmmFakeNvData
,
236 // Free the allocated config request string.
238 if (AllocatedRequest
) {
239 FreePool (ConfigRequest
);
240 ConfigRequest
= NULL
;
243 // Set Progress string to the original request string.
245 if (Request
== NULL
) {
247 } else if (StrStr (Request
, L
"OFFSET") == NULL
) {
248 *Progress
= Request
+ StrLen (Request
);
255 This function processes the results of changes in configuration.
258 @param This Points to the EFI_HII_CONFIG_ACCESS_PROTOCOL.
259 @param Action Specifies the type of action taken by the browser.
260 @param QuestionId A unique value which is sent to the original exporting driver
261 so that it can identify the type of data to expect.
262 @param Type The type of value for the question.
263 @param Value A pointer to the data being sent to the original exporting driver.
264 @param ActionRequest On return, points to the action requested by the callback function.
266 @retval EFI_SUCCESS The callback successfully handled the action.
267 @retval EFI_OUT_OF_RESOURCES Not enough storage is available to hold the variable and its data.
268 @retval EFI_DEVICE_ERROR The variable could not be saved.
269 @retval EFI_UNSUPPORTED The specified Action is not supported by the callback.
270 @retval EFI_INVALID_PARAMETER The parameter of Value or ActionRequest is invalid.
275 IN CONST EFI_HII_CONFIG_ACCESS_PROTOCOL
*This
,
276 IN EFI_BROWSER_ACTION Action
,
277 IN EFI_QUESTION_ID QuestionId
,
279 IN EFI_IFR_TYPE_VALUE
*Value
,
280 OUT EFI_BROWSER_ACTION_REQUEST
*ActionRequest
283 BMM_CALLBACK_DATA
*Private
;
284 BM_MENU_ENTRY
*NewMenuEntry
;
285 BMM_FAKE_NV_DATA
*CurrentFakeNVMap
;
300 if ((Value
== NULL
) || (ActionRequest
== NULL
)) {
301 return EFI_INVALID_PARAMETER
;
311 *ActionRequest
= EFI_BROWSER_ACTION_REQUEST_NONE
;
313 Private
= BMM_CALLBACK_DATA_FROM_THIS (This
);
314 UpdatePageId (Private
, QuestionId
);
317 // Retrive uncommitted data from Form Browser
319 CurrentFakeNVMap
= &Private
->BmmFakeNvData
;
320 HiiGetBrowserData (&mBootMaintGuid
, mBootMaintStorageName
, sizeof (BMM_FAKE_NV_DATA
), (UINT8
*) CurrentFakeNVMap
);
323 // need to be subtituded.
325 // Update Select FD/HD/CD/NET/BEV Order Form
327 if (FORM_SET_FD_ORDER_ID
== Private
->BmmPreviousPageId
||
328 FORM_SET_HD_ORDER_ID
== Private
->BmmPreviousPageId
||
329 FORM_SET_CD_ORDER_ID
== Private
->BmmPreviousPageId
||
330 FORM_SET_NET_ORDER_ID
== Private
->BmmPreviousPageId
||
331 FORM_SET_BEV_ORDER_ID
== Private
->BmmPreviousPageId
||
332 ((FORM_BOOT_SETUP_ID
== Private
->BmmPreviousPageId
) &&
333 (QuestionId
>= LEGACY_FD_QUESTION_ID
) &&
334 (QuestionId
< (LEGACY_BEV_QUESTION_ID
+ 100)) )
337 DisMap
= Private
->BmmOldFakeNVData
.DisableMap
;
339 FormId
= Private
->BmmPreviousPageId
;
340 if (FormId
== FORM_BOOT_SETUP_ID
) {
341 FormId
= Private
->BmmCurrentPageId
;
345 case FORM_SET_FD_ORDER_ID
:
346 Number
= (UINT16
) LegacyFDMenu
.MenuNumber
;
347 OldLegacyDev
= Private
->BmmOldFakeNVData
.LegacyFD
;
348 NewLegacyDev
= CurrentFakeNVMap
->LegacyFD
;
351 case FORM_SET_HD_ORDER_ID
:
352 Number
= (UINT16
) LegacyHDMenu
.MenuNumber
;
353 OldLegacyDev
= Private
->BmmOldFakeNVData
.LegacyHD
;
354 NewLegacyDev
= CurrentFakeNVMap
->LegacyHD
;
357 case FORM_SET_CD_ORDER_ID
:
358 Number
= (UINT16
) LegacyCDMenu
.MenuNumber
;
359 OldLegacyDev
= Private
->BmmOldFakeNVData
.LegacyCD
;
360 NewLegacyDev
= CurrentFakeNVMap
->LegacyCD
;
363 case FORM_SET_NET_ORDER_ID
:
364 Number
= (UINT16
) LegacyNETMenu
.MenuNumber
;
365 OldLegacyDev
= Private
->BmmOldFakeNVData
.LegacyNET
;
366 NewLegacyDev
= CurrentFakeNVMap
->LegacyNET
;
369 case FORM_SET_BEV_ORDER_ID
:
370 Number
= (UINT16
) LegacyBEVMenu
.MenuNumber
;
371 OldLegacyDev
= Private
->BmmOldFakeNVData
.LegacyBEV
;
372 NewLegacyDev
= CurrentFakeNVMap
->LegacyBEV
;
379 // First, find the different position
380 // if there is change, it should be only one
382 for (Index
= 0; Index
< Number
; Index
++) {
383 if (OldLegacyDev
[Index
] != NewLegacyDev
[Index
]) {
384 OldValue
= OldLegacyDev
[Index
];
385 NewValue
= NewLegacyDev
[Index
];
390 if (Index
!= Number
) {
392 // there is change, now process
394 if (0xFF == NewValue
) {
396 // This item will be disable
397 // Just move the items behind this forward to overlap it
400 Bit
= 7 - (OldValue
% 8);
401 DisMap
[Pos
] = (UINT8
) (DisMap
[Pos
] | (UINT8
) (1 << Bit
));
402 for (Index2
= Index
; Index2
< Number
- 1; Index2
++) {
403 NewLegacyDev
[Index2
] = NewLegacyDev
[Index2
+ 1];
406 NewLegacyDev
[Index2
] = 0xFF;
408 for (Index2
= 0; Index2
< Number
; Index2
++) {
409 if (Index2
== Index
) {
413 if (OldLegacyDev
[Index2
] == NewValue
) {
415 // If NewValue is in OldLegacyDev array
416 // remember its old position
418 NewValuePos
= Index2
;
423 if (Index2
!= Number
) {
425 // We will change current item to an existing item
426 // (It's hard to describe here, please read code, it's like a cycle-moving)
428 for (Index2
= NewValuePos
; Index2
!= Index
;) {
429 if (NewValuePos
< Index
) {
430 NewLegacyDev
[Index2
] = OldLegacyDev
[Index2
+ 1];
433 NewLegacyDev
[Index2
] = OldLegacyDev
[Index2
- 1];
439 // If NewValue is not in OldlegacyDev array, we are changing to a disabled item
440 // so we should modify DisMap to reflect the change
443 Bit
= 7 - (NewValue
% 8);
444 DisMap
[Pos
] = (UINT8
) (DisMap
[Pos
] & (~ (UINT8
) (1 << Bit
)));
445 if (0xFF != OldValue
) {
447 // Because NewValue is a item that was disabled before
448 // so after changing the OldValue should be disabled
449 // actually we are doing a swap of enable-disable states of two items
452 Bit
= 7 - (OldValue
% 8);
453 DisMap
[Pos
] = (UINT8
) (DisMap
[Pos
] | (UINT8
) (1 << Bit
));
458 // To prevent DISABLE appears in the middle of the list
459 // we should perform a re-ordering
462 while (Index
< Number
) {
463 if (0xFF != NewLegacyDev
[Index
]) {
470 while (Index2
< Number
) {
471 if (0xFF != NewLegacyDev
[Index2
]) {
478 if (Index2
< Number
) {
479 NewLegacyDev
[Index
] = NewLegacyDev
[Index2
];
480 NewLegacyDev
[Index2
] = 0xFF;
494 if (QuestionId
< FILE_OPTION_OFFSET
) {
495 if (QuestionId
< CONFIG_OPTION_OFFSET
) {
496 switch (QuestionId
) {
497 case KEY_VALUE_BOOT_FROM_FILE
:
498 Private
->FeCurrentState
= FileExplorerStateBootFromFile
;
501 // Exit Bmm main formset to send File Explorer formset.
503 *ActionRequest
= EFI_BROWSER_ACTION_REQUEST_EXIT
;
506 case FORM_BOOT_ADD_ID
:
507 Private
->FeCurrentState
= FileExplorerStateAddBootOption
;
510 // Exit Bmm main formset to send File Explorer formset.
512 *ActionRequest
= EFI_BROWSER_ACTION_REQUEST_EXIT
;
515 case FORM_DRV_ADD_FILE_ID
:
516 Private
->FeCurrentState
= FileExplorerStateAddDriverOptionState
;
519 // Exit Bmm main formset to send File Explorer formset.
521 *ActionRequest
= EFI_BROWSER_ACTION_REQUEST_EXIT
;
524 case FORM_DRV_ADD_HANDLE_ID
:
525 CleanUpPage (FORM_DRV_ADD_HANDLE_ID
, Private
);
526 UpdateDrvAddHandlePage (Private
);
529 case FORM_BOOT_DEL_ID
:
530 CleanUpPage (FORM_BOOT_DEL_ID
, Private
);
531 UpdateBootDelPage (Private
);
534 case FORM_BOOT_CHG_ID
:
535 case FORM_DRV_CHG_ID
:
536 UpdatePageBody (QuestionId
, Private
);
539 case FORM_DRV_DEL_ID
:
540 CleanUpPage (FORM_DRV_DEL_ID
, Private
);
541 UpdateDrvDelPage (Private
);
544 case FORM_BOOT_NEXT_ID
:
545 CleanUpPage (FORM_BOOT_NEXT_ID
, Private
);
546 UpdateBootNextPage (Private
);
549 case FORM_TIME_OUT_ID
:
550 CleanUpPage (FORM_TIME_OUT_ID
, Private
);
551 UpdateTimeOutPage (Private
);
555 gRT
->ResetSystem (EfiResetCold
, EFI_SUCCESS
, 0, NULL
);
556 return EFI_UNSUPPORTED
;
559 case FORM_CON_OUT_ID
:
560 case FORM_CON_ERR_ID
:
561 UpdatePageBody (QuestionId
, Private
);
564 case FORM_CON_MODE_ID
:
565 CleanUpPage (FORM_CON_MODE_ID
, Private
);
566 UpdateConModePage (Private
);
569 case FORM_CON_COM_ID
:
570 CleanUpPage (FORM_CON_COM_ID
, Private
);
571 UpdateConCOMPage (Private
);
574 case FORM_SET_FD_ORDER_ID
:
575 case FORM_SET_HD_ORDER_ID
:
576 case FORM_SET_CD_ORDER_ID
:
577 case FORM_SET_NET_ORDER_ID
:
578 case FORM_SET_BEV_ORDER_ID
:
579 CleanUpPage (QuestionId
, Private
);
580 UpdateSetLegacyDeviceOrderPage (QuestionId
, Private
);
583 case KEY_VALUE_SAVE_AND_EXIT
:
584 case KEY_VALUE_NO_SAVE_AND_EXIT
:
586 if (QuestionId
== KEY_VALUE_SAVE_AND_EXIT
) {
587 Status
= ApplyChangeHandler (Private
, CurrentFakeNVMap
, Private
->BmmPreviousPageId
);
588 if (EFI_ERROR (Status
)) {
591 } else if (QuestionId
== KEY_VALUE_NO_SAVE_AND_EXIT
) {
592 DiscardChangeHandler (Private
, CurrentFakeNVMap
);
596 // Tell browser not to ask for confirmation of changes,
597 // since we have already applied or discarded.
599 *ActionRequest
= EFI_BROWSER_ACTION_REQUEST_SUBMIT
;
605 } else if ((QuestionId
>= TERMINAL_OPTION_OFFSET
) && (QuestionId
< CONSOLE_OPTION_OFFSET
)) {
606 Index2
= (UINT16
) (QuestionId
- TERMINAL_OPTION_OFFSET
);
607 Private
->CurrentTerminal
= Index2
;
609 CleanUpPage (FORM_CON_COM_SETUP_ID
, Private
);
610 UpdateTerminalPage (Private
);
612 } else if (QuestionId
>= HANDLE_OPTION_OFFSET
) {
613 Index2
= (UINT16
) (QuestionId
- HANDLE_OPTION_OFFSET
);
615 NewMenuEntry
= BOpt_GetMenuEntry (&DriverMenu
, Index2
);
616 ASSERT (NewMenuEntry
!= NULL
);
617 Private
->HandleContext
= (BM_HANDLE_CONTEXT
*) NewMenuEntry
->VariableContext
;
619 CleanUpPage (FORM_DRV_ADD_HANDLE_DESC_ID
, Private
);
621 Private
->MenuEntry
= NewMenuEntry
;
622 Private
->LoadContext
->FilePathList
= Private
->HandleContext
->DevicePath
;
624 UpdateDriverAddHandleDescPage (Private
);
629 // Pass changed uncommitted data back to Form Browser
631 Status
= HiiSetBrowserData (&mBootMaintGuid
, mBootMaintStorageName
, sizeof (BMM_FAKE_NV_DATA
), (UINT8
*) CurrentFakeNVMap
, NULL
);
637 Function handling request to apply changes for BMM pages.
639 @param Private Pointer to callback data buffer.
640 @param CurrentFakeNVMap Pointer to buffer holding data of various values used by BMM
641 @param FormId ID of the form which has sent the request to apply change.
643 @retval EFI_SUCCESS Change successfully applied.
644 @retval Other Error occurs while trying to apply changes.
649 IN BMM_CALLBACK_DATA
*Private
,
650 IN BMM_FAKE_NV_DATA
*CurrentFakeNVMap
,
651 IN EFI_FORM_ID FormId
654 BM_CONSOLE_CONTEXT
*NewConsoleContext
;
655 BM_TERMINAL_CONTEXT
*NewTerminalContext
;
656 BM_LOAD_CONTEXT
*NewLoadContext
;
657 BM_MENU_ENTRY
*NewMenuEntry
;
661 Status
= EFI_SUCCESS
;
664 case FORM_SET_FD_ORDER_ID
:
665 case FORM_SET_HD_ORDER_ID
:
666 case FORM_SET_CD_ORDER_ID
:
667 case FORM_SET_NET_ORDER_ID
:
668 case FORM_SET_BEV_ORDER_ID
:
669 Var_UpdateBBSOption (Private
);
672 case FORM_BOOT_DEL_ID
:
674 ((Index
< BootOptionMenu
.MenuNumber
) && (Index
< (sizeof (CurrentFakeNVMap
->BootOptionDel
) / sizeof (UINT8
))));
676 NewMenuEntry
= BOpt_GetMenuEntry (&BootOptionMenu
, Index
);
677 NewLoadContext
= (BM_LOAD_CONTEXT
*) NewMenuEntry
->VariableContext
;
678 NewLoadContext
->Deleted
= CurrentFakeNVMap
->BootOptionDel
[Index
];
681 Var_DelBootOption ();
684 case FORM_DRV_DEL_ID
:
686 ((Index
< DriverOptionMenu
.MenuNumber
) && (Index
< (sizeof (CurrentFakeNVMap
->DriverOptionDel
) / sizeof (UINT8
))));
688 NewMenuEntry
= BOpt_GetMenuEntry (&DriverOptionMenu
, Index
);
689 NewLoadContext
= (BM_LOAD_CONTEXT
*) NewMenuEntry
->VariableContext
;
690 NewLoadContext
->Deleted
= CurrentFakeNVMap
->DriverOptionDel
[Index
];
693 Var_DelDriverOption ();
696 case FORM_BOOT_CHG_ID
:
697 Status
= Var_UpdateBootOrder (Private
);
700 case FORM_DRV_CHG_ID
:
701 Status
= Var_UpdateDriverOrder (Private
);
704 case FORM_TIME_OUT_ID
:
705 PcdSet16 (PcdPlatformBootTimeOut
, CurrentFakeNVMap
->BootTimeOut
);
707 Private
->BmmOldFakeNVData
.BootTimeOut
= CurrentFakeNVMap
->BootTimeOut
;
710 case FORM_BOOT_NEXT_ID
:
711 Status
= Var_UpdateBootNext (Private
);
714 case FORM_CON_MODE_ID
:
715 Status
= Var_UpdateConMode (Private
);
718 case FORM_CON_COM_SETUP_ID
:
719 NewMenuEntry
= BOpt_GetMenuEntry (&TerminalMenu
, Private
->CurrentTerminal
);
721 ASSERT (NewMenuEntry
!= NULL
);
723 NewTerminalContext
= (BM_TERMINAL_CONTEXT
*) NewMenuEntry
->VariableContext
;
725 NewTerminalContext
->BaudRateIndex
= CurrentFakeNVMap
->COMBaudRate
;
726 ASSERT (CurrentFakeNVMap
->COMBaudRate
< (sizeof (BaudRateList
) / sizeof (BaudRateList
[0])));
727 NewTerminalContext
->BaudRate
= BaudRateList
[CurrentFakeNVMap
->COMBaudRate
].Value
;
728 NewTerminalContext
->DataBitsIndex
= CurrentFakeNVMap
->COMDataRate
;
729 ASSERT (CurrentFakeNVMap
->COMDataRate
< (sizeof (DataBitsList
) / sizeof (DataBitsList
[0])));
730 NewTerminalContext
->DataBits
= (UINT8
) DataBitsList
[CurrentFakeNVMap
->COMDataRate
].Value
;
731 NewTerminalContext
->StopBitsIndex
= CurrentFakeNVMap
->COMStopBits
;
732 ASSERT (CurrentFakeNVMap
->COMStopBits
< (sizeof (StopBitsList
) / sizeof (StopBitsList
[0])));
733 NewTerminalContext
->StopBits
= (UINT8
) StopBitsList
[CurrentFakeNVMap
->COMStopBits
].Value
;
734 NewTerminalContext
->ParityIndex
= CurrentFakeNVMap
->COMParity
;
735 ASSERT (CurrentFakeNVMap
->COMParity
< (sizeof (ParityList
) / sizeof (ParityList
[0])));
736 NewTerminalContext
->Parity
= (UINT8
) ParityList
[CurrentFakeNVMap
->COMParity
].Value
;
737 NewTerminalContext
->TerminalType
= CurrentFakeNVMap
->COMTerminalType
;
739 ChangeTerminalDevicePath (
740 NewTerminalContext
->DevicePath
,
744 Var_UpdateConsoleInpOption ();
745 Var_UpdateConsoleOutOption ();
746 Var_UpdateErrorOutOption ();
750 for (Index
= 0; Index
< ConsoleInpMenu
.MenuNumber
; Index
++) {
751 NewMenuEntry
= BOpt_GetMenuEntry (&ConsoleInpMenu
, Index
);
752 NewConsoleContext
= (BM_CONSOLE_CONTEXT
*) NewMenuEntry
->VariableContext
;
753 ASSERT (Index
< MAX_MENU_NUMBER
);
754 NewConsoleContext
->IsActive
= CurrentFakeNVMap
->ConsoleCheck
[Index
];
757 for (Index
= 0; Index
< TerminalMenu
.MenuNumber
; Index
++) {
758 NewMenuEntry
= BOpt_GetMenuEntry (&TerminalMenu
, Index
);
759 NewTerminalContext
= (BM_TERMINAL_CONTEXT
*) NewMenuEntry
->VariableContext
;
760 ASSERT (Index
+ ConsoleInpMenu
.MenuNumber
< MAX_MENU_NUMBER
);
761 NewTerminalContext
->IsConIn
= CurrentFakeNVMap
->ConsoleCheck
[Index
+ ConsoleInpMenu
.MenuNumber
];
764 Var_UpdateConsoleInpOption ();
767 case FORM_CON_OUT_ID
:
768 for (Index
= 0; Index
< ConsoleOutMenu
.MenuNumber
; Index
++) {
769 NewMenuEntry
= BOpt_GetMenuEntry (&ConsoleOutMenu
, Index
);
770 NewConsoleContext
= (BM_CONSOLE_CONTEXT
*) NewMenuEntry
->VariableContext
;
771 ASSERT (Index
< MAX_MENU_NUMBER
);
772 NewConsoleContext
->IsActive
= CurrentFakeNVMap
->ConsoleCheck
[Index
];
775 for (Index
= 0; Index
< TerminalMenu
.MenuNumber
; Index
++) {
776 NewMenuEntry
= BOpt_GetMenuEntry (&TerminalMenu
, Index
);
777 NewTerminalContext
= (BM_TERMINAL_CONTEXT
*) NewMenuEntry
->VariableContext
;
778 ASSERT (Index
+ ConsoleOutMenu
.MenuNumber
< MAX_MENU_NUMBER
);
779 NewTerminalContext
->IsConOut
= CurrentFakeNVMap
->ConsoleCheck
[Index
+ ConsoleOutMenu
.MenuNumber
];
782 Var_UpdateConsoleOutOption ();
785 case FORM_CON_ERR_ID
:
786 for (Index
= 0; Index
< ConsoleErrMenu
.MenuNumber
; Index
++) {
787 NewMenuEntry
= BOpt_GetMenuEntry (&ConsoleErrMenu
, Index
);
788 NewConsoleContext
= (BM_CONSOLE_CONTEXT
*) NewMenuEntry
->VariableContext
;
789 ASSERT (Index
< MAX_MENU_NUMBER
);
790 NewConsoleContext
->IsActive
= CurrentFakeNVMap
->ConsoleCheck
[Index
];
793 for (Index
= 0; Index
< TerminalMenu
.MenuNumber
; Index
++) {
794 NewMenuEntry
= BOpt_GetMenuEntry (&TerminalMenu
, Index
);
795 NewTerminalContext
= (BM_TERMINAL_CONTEXT
*) NewMenuEntry
->VariableContext
;
796 ASSERT (Index
+ ConsoleErrMenu
.MenuNumber
< MAX_MENU_NUMBER
);
797 NewTerminalContext
->IsStdErr
= CurrentFakeNVMap
->ConsoleCheck
[Index
+ ConsoleErrMenu
.MenuNumber
];
800 Var_UpdateErrorOutOption ();
803 case FORM_DRV_ADD_HANDLE_DESC_ID
:
804 Status
= Var_UpdateDriverOption (
806 Private
->BmmHiiHandle
,
807 CurrentFakeNVMap
->DriverAddHandleDesc
,
808 CurrentFakeNVMap
->DriverAddHandleOptionalData
,
809 CurrentFakeNVMap
->DriverAddForceReconnect
811 if (EFI_ERROR (Status
)) {
815 BOpt_GetDriverOptions (Private
);
816 CreateMenuStringToken (Private
, Private
->BmmHiiHandle
, &DriverOptionMenu
);
828 Discard all changes done to the BMM pages such as Boot Order change,
831 @param Private The BMM context data.
832 @param CurrentFakeNVMap The current Fack NV Map.
836 DiscardChangeHandler (
837 IN BMM_CALLBACK_DATA
*Private
,
838 IN BMM_FAKE_NV_DATA
*CurrentFakeNVMap
843 switch (Private
->BmmPreviousPageId
) {
844 case FORM_BOOT_CHG_ID
:
845 case FORM_DRV_CHG_ID
:
846 CopyMem (CurrentFakeNVMap
->OptionOrder
, Private
->BmmOldFakeNVData
.OptionOrder
, 100);
849 case FORM_BOOT_DEL_ID
:
850 ASSERT (BootOptionMenu
.MenuNumber
<= (sizeof (CurrentFakeNVMap
->BootOptionDel
) / sizeof (CurrentFakeNVMap
->BootOptionDel
[0])));
851 for (Index
= 0; Index
< BootOptionMenu
.MenuNumber
; Index
++) {
852 CurrentFakeNVMap
->BootOptionDel
[Index
] = 0x00;
856 case FORM_DRV_DEL_ID
:
857 ASSERT (DriverOptionMenu
.MenuNumber
<= (sizeof (CurrentFakeNVMap
->DriverOptionDel
) / sizeof (CurrentFakeNVMap
->DriverOptionDel
[0])));
858 for (Index
= 0; Index
< DriverOptionMenu
.MenuNumber
; Index
++) {
859 CurrentFakeNVMap
->DriverOptionDel
[Index
] = 0x00;
863 case FORM_BOOT_NEXT_ID
:
864 CurrentFakeNVMap
->BootNext
= Private
->BmmOldFakeNVData
.BootNext
;
867 case FORM_TIME_OUT_ID
:
868 CurrentFakeNVMap
->BootTimeOut
= Private
->BmmOldFakeNVData
.BootTimeOut
;
871 case FORM_DRV_ADD_HANDLE_DESC_ID
:
872 case FORM_DRV_ADD_FILE_ID
:
873 case FORM_DRV_ADD_HANDLE_ID
:
874 CurrentFakeNVMap
->DriverAddHandleDesc
[0] = 0x0000;
875 CurrentFakeNVMap
->DriverAddHandleOptionalData
[0] = 0x0000;
884 Initialize the Boot Maintenance Utitliy.
887 @retval EFI_SUCCESS utility ended successfully
888 @retval others contain some errors
896 EFI_LEGACY_BIOS_PROTOCOL
*LegacyBios
;
897 BMM_CALLBACK_DATA
*BmmCallbackInfo
;
901 Status
= EFI_SUCCESS
;
904 // Create CallbackData structures for Driver Callback
906 BmmCallbackInfo
= AllocateZeroPool (sizeof (BMM_CALLBACK_DATA
));
907 if (BmmCallbackInfo
== NULL
) {
908 return EFI_OUT_OF_RESOURCES
;
912 // Create LoadOption in BmmCallbackInfo for Driver Callback
914 Ptr
= AllocateZeroPool (sizeof (BM_LOAD_CONTEXT
) + sizeof (BM_FILE_CONTEXT
) + sizeof (BM_HANDLE_CONTEXT
) + sizeof (BM_MENU_ENTRY
));
916 FreePool (BmmCallbackInfo
);
917 return EFI_OUT_OF_RESOURCES
;
921 // Initialize Bmm callback data.
923 BmmCallbackInfo
->LoadContext
= (BM_LOAD_CONTEXT
*) Ptr
;
924 Ptr
+= sizeof (BM_LOAD_CONTEXT
);
926 BmmCallbackInfo
->FileContext
= (BM_FILE_CONTEXT
*) Ptr
;
927 Ptr
+= sizeof (BM_FILE_CONTEXT
);
929 BmmCallbackInfo
->HandleContext
= (BM_HANDLE_CONTEXT
*) Ptr
;
930 Ptr
+= sizeof (BM_HANDLE_CONTEXT
);
932 BmmCallbackInfo
->MenuEntry
= (BM_MENU_ENTRY
*) Ptr
;
934 BmmCallbackInfo
->Signature
= BMM_CALLBACK_DATA_SIGNATURE
;
935 BmmCallbackInfo
->BmmConfigAccess
.ExtractConfig
= BootMaintExtractConfig
;
936 BmmCallbackInfo
->BmmConfigAccess
.RouteConfig
= FakeRouteConfig
;
937 BmmCallbackInfo
->BmmConfigAccess
.Callback
= BootMaintCallback
;
938 BmmCallbackInfo
->BmmPreviousPageId
= FORM_MAIN_ID
;
939 BmmCallbackInfo
->BmmCurrentPageId
= FORM_MAIN_ID
;
940 BmmCallbackInfo
->FeConfigAccess
.ExtractConfig
= FakeExtractConfig
;
941 BmmCallbackInfo
->FeConfigAccess
.RouteConfig
= FakeRouteConfig
;
942 BmmCallbackInfo
->FeConfigAccess
.Callback
= FileExplorerCallback
;
943 BmmCallbackInfo
->FeCurrentState
= FileExplorerStateInActive
;
944 BmmCallbackInfo
->FeDisplayContext
= FileExplorerDisplayUnknown
;
947 // Install Device Path Protocol and Config Access protocol to driver handle
949 Status
= gBS
->InstallMultipleProtocolInterfaces (
950 &BmmCallbackInfo
->BmmDriverHandle
,
951 &gEfiDevicePathProtocolGuid
,
952 &mBmmHiiVendorDevicePath
,
953 &gEfiHiiConfigAccessProtocolGuid
,
954 &BmmCallbackInfo
->BmmConfigAccess
,
957 if (EFI_ERROR (Status
)) {
962 // Install Device Path Protocol and Config Access protocol to driver handle
964 Status
= gBS
->InstallMultipleProtocolInterfaces (
965 &BmmCallbackInfo
->FeDriverHandle
,
966 &gEfiDevicePathProtocolGuid
,
967 &mFeHiiVendorDevicePath
,
968 &gEfiHiiConfigAccessProtocolGuid
,
969 &BmmCallbackInfo
->FeConfigAccess
,
972 if (EFI_ERROR (Status
)) {
977 // Post our Boot Maint VFR binary to the HII database.
979 BmmCallbackInfo
->BmmHiiHandle
= HiiAddPackages (
981 BmmCallbackInfo
->BmmDriverHandle
,
986 ASSERT (BmmCallbackInfo
->BmmHiiHandle
!= NULL
);
989 // Post our File Explorer VFR binary to the HII database.
991 BmmCallbackInfo
->FeHiiHandle
= HiiAddPackages (
993 BmmCallbackInfo
->FeDriverHandle
,
998 ASSERT (BmmCallbackInfo
->FeHiiHandle
!= NULL
);
1001 // Init OpCode Handle and Allocate space for creation of Buffer
1003 mStartOpCodeHandle
= HiiAllocateOpCodeHandle ();
1004 if (mStartOpCodeHandle
== NULL
) {
1005 Status
= EFI_OUT_OF_RESOURCES
;
1009 mEndOpCodeHandle
= HiiAllocateOpCodeHandle ();
1010 if (mEndOpCodeHandle
== NULL
) {
1011 Status
= EFI_OUT_OF_RESOURCES
;
1016 // Create Hii Extend Label OpCode as the start opcode
1018 mStartLabel
= (EFI_IFR_GUID_LABEL
*) HiiCreateGuidOpCode (mStartOpCodeHandle
, &gEfiIfrTianoGuid
, NULL
, sizeof (EFI_IFR_GUID_LABEL
));
1019 mStartLabel
->ExtendOpCode
= EFI_IFR_EXTEND_OP_LABEL
;
1022 // Create Hii Extend Label OpCode as the end opcode
1024 mEndLabel
= (EFI_IFR_GUID_LABEL
*) HiiCreateGuidOpCode (mEndOpCodeHandle
, &gEfiIfrTianoGuid
, NULL
, sizeof (EFI_IFR_GUID_LABEL
));
1025 mEndLabel
->ExtendOpCode
= EFI_IFR_EXTEND_OP_LABEL
;
1026 mEndLabel
->Number
= LABEL_END
;
1028 InitializeStringDepository ();
1030 InitAllMenu (BmmCallbackInfo
);
1032 CreateMenuStringToken (BmmCallbackInfo
, BmmCallbackInfo
->BmmHiiHandle
, &ConsoleInpMenu
);
1033 CreateMenuStringToken (BmmCallbackInfo
, BmmCallbackInfo
->BmmHiiHandle
, &ConsoleOutMenu
);
1034 CreateMenuStringToken (BmmCallbackInfo
, BmmCallbackInfo
->BmmHiiHandle
, &ConsoleErrMenu
);
1035 CreateMenuStringToken (BmmCallbackInfo
, BmmCallbackInfo
->BmmHiiHandle
, &BootOptionMenu
);
1036 CreateMenuStringToken (BmmCallbackInfo
, BmmCallbackInfo
->BmmHiiHandle
, &DriverOptionMenu
);
1037 CreateMenuStringToken (BmmCallbackInfo
, BmmCallbackInfo
->BmmHiiHandle
, &TerminalMenu
);
1038 CreateMenuStringToken (BmmCallbackInfo
, BmmCallbackInfo
->BmmHiiHandle
, &DriverMenu
);
1040 UpdateBootDelPage (BmmCallbackInfo
);
1041 UpdateDrvDelPage (BmmCallbackInfo
);
1043 if (TerminalMenu
.MenuNumber
> 0) {
1044 BmmCallbackInfo
->CurrentTerminal
= 0;
1045 UpdateTerminalPage (BmmCallbackInfo
);
1048 Status
= EfiLibLocateProtocol (&gEfiLegacyBiosProtocolGuid
, (VOID
**) &LegacyBios
);
1049 if (!EFI_ERROR (Status
)) {
1050 RefreshUpdateData ();
1051 mStartLabel
->Number
= FORM_BOOT_LEGACY_DEVICE_ID
;
1054 // If LegacyBios Protocol is installed, add 3 tags about legacy boot option
1055 // in BootOption form: legacy FD/HD/CD/NET/BEV
1057 HiiCreateGotoOpCode (
1059 FORM_SET_FD_ORDER_ID
,
1060 STRING_TOKEN (STR_FORM_SET_FD_ORDER_TITLE
),
1061 STRING_TOKEN (STR_FORM_SET_FD_ORDER_TITLE
),
1062 EFI_IFR_FLAG_CALLBACK
,
1063 FORM_SET_FD_ORDER_ID
1066 HiiCreateGotoOpCode (
1068 FORM_SET_HD_ORDER_ID
,
1069 STRING_TOKEN (STR_FORM_SET_HD_ORDER_TITLE
),
1070 STRING_TOKEN (STR_FORM_SET_HD_ORDER_TITLE
),
1071 EFI_IFR_FLAG_CALLBACK
,
1072 FORM_SET_HD_ORDER_ID
1075 HiiCreateGotoOpCode (
1077 FORM_SET_CD_ORDER_ID
,
1078 STRING_TOKEN (STR_FORM_SET_CD_ORDER_TITLE
),
1079 STRING_TOKEN (STR_FORM_SET_CD_ORDER_TITLE
),
1080 EFI_IFR_FLAG_CALLBACK
,
1081 FORM_SET_CD_ORDER_ID
1084 HiiCreateGotoOpCode (
1086 FORM_SET_NET_ORDER_ID
,
1087 STRING_TOKEN (STR_FORM_SET_NET_ORDER_TITLE
),
1088 STRING_TOKEN (STR_FORM_SET_NET_ORDER_TITLE
),
1089 EFI_IFR_FLAG_CALLBACK
,
1090 FORM_SET_NET_ORDER_ID
1093 HiiCreateGotoOpCode (
1095 FORM_SET_BEV_ORDER_ID
,
1096 STRING_TOKEN (STR_FORM_SET_BEV_ORDER_TITLE
),
1097 STRING_TOKEN (STR_FORM_SET_BEV_ORDER_TITLE
),
1098 EFI_IFR_FLAG_CALLBACK
,
1099 FORM_SET_BEV_ORDER_ID
1103 BmmCallbackInfo
->BmmHiiHandle
,
1106 mStartOpCodeHandle
, // Label FORM_BOOT_LEGACY_DEVICE_ID
1107 mEndOpCodeHandle
// LABEL_END
1112 // Dispatch BMM main formset and File Explorer formset.
1114 FormSetDispatcher (BmmCallbackInfo
);
1117 // Remove our IFR data from HII database
1119 HiiRemovePackages (BmmCallbackInfo
->BmmHiiHandle
);
1120 HiiRemovePackages (BmmCallbackInfo
->FeHiiHandle
);
1122 CleanUpStringDepository ();
1127 if (mStartOpCodeHandle
!= NULL
) {
1128 HiiFreeOpCodeHandle (mStartOpCodeHandle
);
1131 if (mEndOpCodeHandle
!= NULL
) {
1132 HiiFreeOpCodeHandle (mEndOpCodeHandle
);
1135 if (BmmCallbackInfo
->FeDriverHandle
!= NULL
) {
1136 gBS
->UninstallMultipleProtocolInterfaces (
1137 BmmCallbackInfo
->FeDriverHandle
,
1138 &gEfiDevicePathProtocolGuid
,
1139 &mFeHiiVendorDevicePath
,
1140 &gEfiHiiConfigAccessProtocolGuid
,
1141 &BmmCallbackInfo
->FeConfigAccess
,
1146 if (BmmCallbackInfo
->BmmDriverHandle
!= NULL
) {
1147 gBS
->UninstallMultipleProtocolInterfaces (
1148 BmmCallbackInfo
->BmmDriverHandle
,
1149 &gEfiDevicePathProtocolGuid
,
1150 &mBmmHiiVendorDevicePath
,
1151 &gEfiHiiConfigAccessProtocolGuid
,
1152 &BmmCallbackInfo
->BmmConfigAccess
,
1157 FreePool (BmmCallbackInfo
->LoadContext
);
1158 FreePool (BmmCallbackInfo
);
1164 Initialized all Menu Option List.
1166 @param CallbackData The BMM context data.
1171 IN BMM_CALLBACK_DATA
*CallbackData
1174 InitializeListHead (&BootOptionMenu
.Head
);
1175 InitializeListHead (&DriverOptionMenu
.Head
);
1176 BOpt_GetBootOptions (CallbackData
);
1177 BOpt_GetDriverOptions (CallbackData
);
1178 BOpt_GetLegacyOptions ();
1179 InitializeListHead (&FsOptionMenu
.Head
);
1180 BOpt_FindDrivers ();
1181 InitializeListHead (&DirectoryMenu
.Head
);
1182 InitializeListHead (&ConsoleInpMenu
.Head
);
1183 InitializeListHead (&ConsoleOutMenu
.Head
);
1184 InitializeListHead (&ConsoleErrMenu
.Head
);
1185 InitializeListHead (&TerminalMenu
.Head
);
1191 Free up all Menu Option list.
1199 BOpt_FreeMenu (&DirectoryMenu
);
1200 BOpt_FreeMenu (&FsOptionMenu
);
1201 BOpt_FreeMenu (&BootOptionMenu
);
1202 BOpt_FreeMenu (&DriverOptionMenu
);
1203 BOpt_FreeMenu (&DriverMenu
);
1204 BOpt_FreeLegacyOptions ();
1209 Initialize all the string depositories.
1213 InitializeStringDepository (
1217 STRING_DEPOSITORY
*StringDepository
;
1218 StringDepository
= AllocateZeroPool (sizeof (STRING_DEPOSITORY
) * STRING_DEPOSITORY_NUMBER
);
1219 FileOptionStrDepository
= StringDepository
++;
1220 ConsoleOptionStrDepository
= StringDepository
++;
1221 BootOptionStrDepository
= StringDepository
++;
1222 BootOptionHelpStrDepository
= StringDepository
++;
1223 DriverOptionStrDepository
= StringDepository
++;
1224 DriverOptionHelpStrDepository
= StringDepository
++;
1225 TerminalStrDepository
= StringDepository
;
1229 Fetch a usable string node from the string depository and return the string token.
1231 @param CallbackData The BMM context data.
1232 @param StringDepository The string repository.
1234 @retval EFI_STRING_ID String token.
1238 GetStringTokenFromDepository (
1239 IN BMM_CALLBACK_DATA
*CallbackData
,
1240 IN STRING_DEPOSITORY
*StringDepository
1243 STRING_LIST_NODE
*CurrentListNode
;
1244 STRING_LIST_NODE
*NextListNode
;
1246 CurrentListNode
= StringDepository
->CurrentNode
;
1248 if ((NULL
!= CurrentListNode
) && (NULL
!= CurrentListNode
->Next
)) {
1250 // Fetch one reclaimed node from the list.
1252 NextListNode
= StringDepository
->CurrentNode
->Next
;
1255 // If there is no usable node in the list, update the list.
1257 NextListNode
= AllocateZeroPool (sizeof (STRING_LIST_NODE
));
1258 ASSERT (NextListNode
!= NULL
);
1259 NextListNode
->StringToken
= HiiSetString (CallbackData
->BmmHiiHandle
, 0, L
" ", NULL
);
1260 ASSERT (NextListNode
->StringToken
!= 0);
1262 StringDepository
->TotalNodeNumber
++;
1264 if (NULL
== CurrentListNode
) {
1265 StringDepository
->ListHead
= NextListNode
;
1267 CurrentListNode
->Next
= NextListNode
;
1271 StringDepository
->CurrentNode
= NextListNode
;
1273 return StringDepository
->CurrentNode
->StringToken
;
1277 Reclaim string depositories by moving the current node pointer to list head..
1281 ReclaimStringDepository (
1285 UINTN DepositoryIndex
;
1286 STRING_DEPOSITORY
*StringDepository
;
1288 StringDepository
= FileOptionStrDepository
;
1289 for (DepositoryIndex
= 0; DepositoryIndex
< STRING_DEPOSITORY_NUMBER
; DepositoryIndex
++) {
1290 StringDepository
->CurrentNode
= StringDepository
->ListHead
;
1296 Release resource for all the string depositories.
1300 CleanUpStringDepository (
1305 UINTN DepositoryIndex
;
1306 STRING_LIST_NODE
*CurrentListNode
;
1307 STRING_LIST_NODE
*NextListNode
;
1308 STRING_DEPOSITORY
*StringDepository
;
1311 // Release string list nodes.
1313 StringDepository
= FileOptionStrDepository
;
1314 for (DepositoryIndex
= 0; DepositoryIndex
< STRING_DEPOSITORY_NUMBER
; DepositoryIndex
++) {
1315 CurrentListNode
= StringDepository
->ListHead
;
1316 for (NodeIndex
= 0; NodeIndex
< StringDepository
->TotalNodeNumber
; NodeIndex
++) {
1317 NextListNode
= CurrentListNode
->Next
;
1318 FreePool (CurrentListNode
);
1319 CurrentListNode
= NextListNode
;
1325 // Release string depository.
1327 FreePool (FileOptionStrDepository
);
1331 Start boot maintenance manager
1333 @retval EFI_SUCCESS If BMM is invoked successfully.
1334 @return Other value if BMM return unsuccessfully.
1343 LIST_ENTRY BdsBootOptionList
;
1345 InitializeListHead (&BdsBootOptionList
);
1348 // Connect all prior to entering the platform setup menu.
1350 if (!gConnectAllHappened
) {
1351 BdsLibConnectAllDriversToAllControllers ();
1352 gConnectAllHappened
= TRUE
;
1355 // Have chance to enumerate boot device
1357 BdsLibEnumerateAllBootOption (&BdsBootOptionList
);
1362 Status
= InitializeBM ();
1368 Dispatch BMM formset and FileExplorer formset.
1371 @param CallbackData The BMM context data.
1373 @retval EFI_SUCCESS If function complete successfully.
1374 @return Other value if the Setup Browser process BMM's pages and
1375 return unsuccessfully.
1380 IN BMM_CALLBACK_DATA
*CallbackData
1384 EFI_BROWSER_ACTION_REQUEST ActionRequest
;
1387 UpdatePageId (CallbackData
, FORM_MAIN_ID
);
1389 ActionRequest
= EFI_BROWSER_ACTION_REQUEST_NONE
;
1390 Status
= gFormBrowser2
->SendForm (
1392 &CallbackData
->BmmHiiHandle
,
1399 if (ActionRequest
== EFI_BROWSER_ACTION_REQUEST_RESET
) {
1400 EnableResetRequired ();
1403 ReclaimStringDepository ();
1406 // When this Formset returns, check if we are going to explore files.
1408 if (FileExplorerStateInActive
!= CallbackData
->FeCurrentState
) {
1409 UpdateFileExplorer (CallbackData
, 0);
1411 ActionRequest
= EFI_BROWSER_ACTION_REQUEST_NONE
;
1412 Status
= gFormBrowser2
->SendForm (
1414 &CallbackData
->FeHiiHandle
,
1421 if (ActionRequest
== EFI_BROWSER_ACTION_REQUEST_RESET
) {
1422 EnableResetRequired ();
1425 CallbackData
->FeCurrentState
= FileExplorerStateInActive
;
1426 CallbackData
->FeDisplayContext
= FileExplorerDisplayUnknown
;
1427 ReclaimStringDepository ();
1438 Deletete the Boot Option from EFI Variable. The Boot Order Arrray
1441 @param OptionNumber The number of Boot option want to be deleted.
1442 @param BootOrder The Boot Order array.
1443 @param BootOrderSize The size of the Boot Order Array.
1445 @retval EFI_SUCCESS The Boot Option Variable was found and removed
1446 @retval EFI_UNSUPPORTED The Boot Option Variable store was inaccessible
1447 @retval EFI_NOT_FOUND The Boot Option Variable was not found
1451 BdsDeleteBootOption (
1452 IN UINTN OptionNumber
,
1453 IN OUT UINT16
*BootOrder
,
1454 IN OUT UINTN
*BootOrderSize
1457 UINT16 BootOption
[100];
1462 Status
= EFI_SUCCESS
;
1465 UnicodeSPrint (BootOption
, sizeof (BootOption
), L
"Boot%04x", OptionNumber
);
1466 Status
= EfiLibDeleteVariable (BootOption
, &gEfiGlobalVariableGuid
);
1469 // adjust boot order array
1471 for (Index
= 0; Index
< *BootOrderSize
/ sizeof (UINT16
); Index
++) {
1472 if (BootOrder
[Index
] == OptionNumber
) {
1478 if (Index
!= *BootOrderSize
/ sizeof (UINT16
)) {
1479 for (Index
= 0; Index
< *BootOrderSize
/ sizeof (UINT16
) - 1; Index
++) {
1480 if (Index
>= Index2Del
) {
1481 BootOrder
[Index
] = BootOrder
[Index
+ 1];
1485 *BootOrderSize
-= sizeof (UINT16
);