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
;
290 if (Action
!= EFI_BROWSER_ACTION_CHANGING
&& Action
!= EFI_BROWSER_ACTION_CHANGED
) {
292 // All other action return unsupported.
294 return EFI_UNSUPPORTED
;
297 Status
= EFI_SUCCESS
;
306 Private
= BMM_CALLBACK_DATA_FROM_THIS (This
);
308 // Retrive uncommitted data from Form Browser
310 CurrentFakeNVMap
= &Private
->BmmFakeNvData
;
311 HiiGetBrowserData (&gBootMaintFormSetGuid
, mBootMaintStorageName
, sizeof (BMM_FAKE_NV_DATA
), (UINT8
*) CurrentFakeNVMap
);
312 if (Action
== EFI_BROWSER_ACTION_CHANGING
) {
314 return EFI_INVALID_PARAMETER
;
317 UpdatePageId (Private
, QuestionId
);
320 // need to be subtituded.
322 // Update Select FD/HD/CD/NET/BEV Order Form
324 if ((QuestionId
>= LEGACY_FD_QUESTION_ID
) && (QuestionId
< LEGACY_BEV_QUESTION_ID
+ MAX_MENU_NUMBER
)) {
326 DisMap
= Private
->BmmOldFakeNVData
.DisableMap
;
328 if (QuestionId
>= LEGACY_FD_QUESTION_ID
&& QuestionId
< LEGACY_FD_QUESTION_ID
+ MAX_MENU_NUMBER
) {
329 Number
= (UINT16
) LegacyFDMenu
.MenuNumber
;
330 OldLegacyDev
= Private
->BmmOldFakeNVData
.LegacyFD
;
331 NewLegacyDev
= CurrentFakeNVMap
->LegacyFD
;
332 } else if (QuestionId
>= LEGACY_HD_QUESTION_ID
&& QuestionId
< LEGACY_HD_QUESTION_ID
+ MAX_MENU_NUMBER
) {
333 Number
= (UINT16
) LegacyHDMenu
.MenuNumber
;
334 OldLegacyDev
= Private
->BmmOldFakeNVData
.LegacyHD
;
335 NewLegacyDev
= CurrentFakeNVMap
->LegacyHD
;
336 } else if (QuestionId
>= LEGACY_CD_QUESTION_ID
&& QuestionId
< LEGACY_CD_QUESTION_ID
+ MAX_MENU_NUMBER
) {
337 Number
= (UINT16
) LegacyCDMenu
.MenuNumber
;
338 OldLegacyDev
= Private
->BmmOldFakeNVData
.LegacyCD
;
339 NewLegacyDev
= CurrentFakeNVMap
->LegacyCD
;
340 } else if (QuestionId
>= LEGACY_NET_QUESTION_ID
&& QuestionId
< LEGACY_NET_QUESTION_ID
+ MAX_MENU_NUMBER
) {
341 Number
= (UINT16
) LegacyNETMenu
.MenuNumber
;
342 OldLegacyDev
= Private
->BmmOldFakeNVData
.LegacyNET
;
343 NewLegacyDev
= CurrentFakeNVMap
->LegacyNET
;
344 } else if (QuestionId
>= LEGACY_BEV_QUESTION_ID
&& QuestionId
< LEGACY_BEV_QUESTION_ID
+ MAX_MENU_NUMBER
) {
345 Number
= (UINT16
) LegacyBEVMenu
.MenuNumber
;
346 OldLegacyDev
= Private
->BmmOldFakeNVData
.LegacyBEV
;
347 NewLegacyDev
= CurrentFakeNVMap
->LegacyBEV
;
350 // First, find the different position
351 // if there is change, it should be only one
353 for (Index
= 0; Index
< Number
; Index
++) {
354 if (OldLegacyDev
[Index
] != NewLegacyDev
[Index
]) {
355 OldValue
= OldLegacyDev
[Index
];
356 NewValue
= NewLegacyDev
[Index
];
361 if (Index
!= Number
) {
363 // there is change, now process
365 if (0xFF == NewValue
) {
367 // This item will be disable
368 // Just move the items behind this forward to overlap it
371 Bit
= 7 - (OldValue
% 8);
372 DisMap
[Pos
] = (UINT8
) (DisMap
[Pos
] | (UINT8
) (1 << Bit
));
373 for (Index2
= Index
; Index2
< Number
- 1; Index2
++) {
374 NewLegacyDev
[Index2
] = NewLegacyDev
[Index2
+ 1];
377 NewLegacyDev
[Index2
] = 0xFF;
379 for (Index2
= 0; Index2
< Number
; Index2
++) {
380 if (Index2
== Index
) {
384 if (OldLegacyDev
[Index2
] == NewValue
) {
386 // If NewValue is in OldLegacyDev array
387 // remember its old position
389 NewValuePos
= Index2
;
394 if (Index2
!= Number
) {
396 // We will change current item to an existing item
397 // (It's hard to describe here, please read code, it's like a cycle-moving)
399 for (Index2
= NewValuePos
; Index2
!= Index
;) {
400 if (NewValuePos
< Index
) {
401 NewLegacyDev
[Index2
] = OldLegacyDev
[Index2
+ 1];
404 NewLegacyDev
[Index2
] = OldLegacyDev
[Index2
- 1];
410 // If NewValue is not in OldlegacyDev array, we are changing to a disabled item
411 // so we should modify DisMap to reflect the change
414 Bit
= 7 - (NewValue
% 8);
415 DisMap
[Pos
] = (UINT8
) (DisMap
[Pos
] & (~ (UINT8
) (1 << Bit
)));
416 if (0xFF != OldValue
) {
418 // Because NewValue is a item that was disabled before
419 // so after changing the OldValue should be disabled
420 // actually we are doing a swap of enable-disable states of two items
423 Bit
= 7 - (OldValue
% 8);
424 DisMap
[Pos
] = (UINT8
) (DisMap
[Pos
] | (UINT8
) (1 << Bit
));
429 // To prevent DISABLE appears in the middle of the list
430 // we should perform a re-ordering
434 while (Index
< Number
) {
435 if (0xFF != NewLegacyDev
[Index
]) {
442 while (Index2
< Number
) {
443 if (0xFF != NewLegacyDev
[Index2
]) {
450 if (Index2
< Number
) {
451 NewLegacyDev
[Index
] = NewLegacyDev
[Index2
];
452 NewLegacyDev
[Index2
] = 0xFF;
465 // Return correct question value.
467 Value
->u8
= NewLegacyDev
[Index3
];
471 if (QuestionId
< FILE_OPTION_OFFSET
) {
472 if (QuestionId
< CONFIG_OPTION_OFFSET
) {
473 switch (QuestionId
) {
474 case KEY_VALUE_BOOT_FROM_FILE
:
475 Private
->FeCurrentState
= FileExplorerStateBootFromFile
;
478 case FORM_BOOT_ADD_ID
:
479 Private
->FeCurrentState
= FileExplorerStateAddBootOption
;
482 case FORM_DRV_ADD_FILE_ID
:
483 Private
->FeCurrentState
= FileExplorerStateAddDriverOptionState
;
486 case FORM_DRV_ADD_HANDLE_ID
:
487 CleanUpPage (FORM_DRV_ADD_HANDLE_ID
, Private
);
488 UpdateDrvAddHandlePage (Private
);
491 case FORM_BOOT_DEL_ID
:
492 CleanUpPage (FORM_BOOT_DEL_ID
, Private
);
493 UpdateBootDelPage (Private
);
496 case FORM_BOOT_CHG_ID
:
497 case FORM_DRV_CHG_ID
:
498 UpdatePageBody (QuestionId
, Private
);
501 case FORM_DRV_DEL_ID
:
502 CleanUpPage (FORM_DRV_DEL_ID
, Private
);
503 UpdateDrvDelPage (Private
);
506 case FORM_BOOT_NEXT_ID
:
507 CleanUpPage (FORM_BOOT_NEXT_ID
, Private
);
508 UpdateBootNextPage (Private
);
511 case FORM_TIME_OUT_ID
:
512 CleanUpPage (FORM_TIME_OUT_ID
, Private
);
513 UpdateTimeOutPage (Private
);
517 case FORM_CON_OUT_ID
:
518 case FORM_CON_ERR_ID
:
519 UpdatePageBody (QuestionId
, Private
);
522 case FORM_CON_MODE_ID
:
523 CleanUpPage (FORM_CON_MODE_ID
, Private
);
524 UpdateConModePage (Private
);
527 case FORM_CON_COM_ID
:
528 CleanUpPage (FORM_CON_COM_ID
, Private
);
529 UpdateConCOMPage (Private
);
532 case FORM_SET_FD_ORDER_ID
:
533 case FORM_SET_HD_ORDER_ID
:
534 case FORM_SET_CD_ORDER_ID
:
535 case FORM_SET_NET_ORDER_ID
:
536 case FORM_SET_BEV_ORDER_ID
:
537 CleanUpPage (QuestionId
, Private
);
538 UpdateSetLegacyDeviceOrderPage (QuestionId
, Private
);
544 } else if ((QuestionId
>= TERMINAL_OPTION_OFFSET
) && (QuestionId
< CONSOLE_OPTION_OFFSET
)) {
545 Index2
= (UINT16
) (QuestionId
- TERMINAL_OPTION_OFFSET
);
546 Private
->CurrentTerminal
= Index2
;
548 CleanUpPage (FORM_CON_COM_SETUP_ID
, Private
);
549 UpdateTerminalPage (Private
);
551 } else if (QuestionId
>= HANDLE_OPTION_OFFSET
) {
552 Index2
= (UINT16
) (QuestionId
- HANDLE_OPTION_OFFSET
);
554 NewMenuEntry
= BOpt_GetMenuEntry (&DriverMenu
, Index2
);
555 ASSERT (NewMenuEntry
!= NULL
);
556 Private
->HandleContext
= (BM_HANDLE_CONTEXT
*) NewMenuEntry
->VariableContext
;
558 CleanUpPage (FORM_DRV_ADD_HANDLE_DESC_ID
, Private
);
560 Private
->MenuEntry
= NewMenuEntry
;
561 Private
->LoadContext
->FilePathList
= Private
->HandleContext
->DevicePath
;
563 UpdateDriverAddHandleDescPage (Private
);
566 } else if (Action
== EFI_BROWSER_ACTION_CHANGED
) {
567 if ((Value
== NULL
) || (ActionRequest
== NULL
)) {
568 return EFI_INVALID_PARAMETER
;
571 switch (QuestionId
) {
572 case KEY_VALUE_SAVE_AND_EXIT
:
573 case KEY_VALUE_NO_SAVE_AND_EXIT
:
574 if (QuestionId
== KEY_VALUE_SAVE_AND_EXIT
) {
575 Status
= ApplyChangeHandler (Private
, CurrentFakeNVMap
, Private
->BmmPreviousPageId
);
576 if (EFI_ERROR (Status
)) {
579 } else if (QuestionId
== KEY_VALUE_NO_SAVE_AND_EXIT
) {
580 DiscardChangeHandler (Private
, CurrentFakeNVMap
);
584 // Tell browser not to ask for confirmation of changes,
585 // since we have already applied or discarded.
587 *ActionRequest
= EFI_BROWSER_ACTION_REQUEST_FORM_SUBMIT_EXIT
;
591 gRT
->ResetSystem (EfiResetCold
, EFI_SUCCESS
, 0, NULL
);
592 return EFI_UNSUPPORTED
;
600 // Pass changed uncommitted data back to Form Browser
602 HiiSetBrowserData (&gBootMaintFormSetGuid
, mBootMaintStorageName
, sizeof (BMM_FAKE_NV_DATA
), (UINT8
*) CurrentFakeNVMap
, NULL
);
607 Function handling request to apply changes for BMM pages.
609 @param Private Pointer to callback data buffer.
610 @param CurrentFakeNVMap Pointer to buffer holding data of various values used by BMM
611 @param FormId ID of the form which has sent the request to apply change.
613 @retval EFI_SUCCESS Change successfully applied.
614 @retval Other Error occurs while trying to apply changes.
619 IN BMM_CALLBACK_DATA
*Private
,
620 IN BMM_FAKE_NV_DATA
*CurrentFakeNVMap
,
621 IN EFI_FORM_ID FormId
624 BM_CONSOLE_CONTEXT
*NewConsoleContext
;
625 BM_TERMINAL_CONTEXT
*NewTerminalContext
;
626 BM_LOAD_CONTEXT
*NewLoadContext
;
627 BM_MENU_ENTRY
*NewMenuEntry
;
631 Status
= EFI_SUCCESS
;
634 case FORM_SET_FD_ORDER_ID
:
635 case FORM_SET_HD_ORDER_ID
:
636 case FORM_SET_CD_ORDER_ID
:
637 case FORM_SET_NET_ORDER_ID
:
638 case FORM_SET_BEV_ORDER_ID
:
639 Var_UpdateBBSOption (Private
);
642 case FORM_BOOT_DEL_ID
:
644 ((Index
< BootOptionMenu
.MenuNumber
) && (Index
< (sizeof (CurrentFakeNVMap
->OptionDel
) / sizeof (CurrentFakeNVMap
->OptionDel
[0]))));
646 NewMenuEntry
= BOpt_GetMenuEntry (&BootOptionMenu
, Index
);
647 NewLoadContext
= (BM_LOAD_CONTEXT
*) NewMenuEntry
->VariableContext
;
648 NewLoadContext
->Deleted
= CurrentFakeNVMap
->OptionDel
[Index
];
651 Var_DelBootOption ();
654 case FORM_DRV_DEL_ID
:
656 ((Index
< DriverOptionMenu
.MenuNumber
) && (Index
< (sizeof (CurrentFakeNVMap
->OptionDel
) / sizeof (CurrentFakeNVMap
->OptionDel
[0]))));
658 NewMenuEntry
= BOpt_GetMenuEntry (&DriverOptionMenu
, Index
);
659 NewLoadContext
= (BM_LOAD_CONTEXT
*) NewMenuEntry
->VariableContext
;
660 NewLoadContext
->Deleted
= CurrentFakeNVMap
->OptionDel
[Index
];
663 Var_DelDriverOption ();
666 case FORM_BOOT_CHG_ID
:
667 Status
= Var_UpdateBootOrder (Private
);
670 case FORM_DRV_CHG_ID
:
671 Status
= Var_UpdateDriverOrder (Private
);
674 case FORM_TIME_OUT_ID
:
675 PcdSet16 (PcdPlatformBootTimeOut
, CurrentFakeNVMap
->BootTimeOut
);
677 Private
->BmmOldFakeNVData
.BootTimeOut
= CurrentFakeNVMap
->BootTimeOut
;
680 case FORM_BOOT_NEXT_ID
:
681 Status
= Var_UpdateBootNext (Private
);
684 case FORM_CON_MODE_ID
:
685 Status
= Var_UpdateConMode (Private
);
688 case FORM_CON_COM_SETUP_ID
:
689 NewMenuEntry
= BOpt_GetMenuEntry (&TerminalMenu
, Private
->CurrentTerminal
);
691 ASSERT (NewMenuEntry
!= NULL
);
693 NewTerminalContext
= (BM_TERMINAL_CONTEXT
*) NewMenuEntry
->VariableContext
;
695 NewTerminalContext
->BaudRateIndex
= CurrentFakeNVMap
->COMBaudRate
;
696 ASSERT (CurrentFakeNVMap
->COMBaudRate
< (sizeof (BaudRateList
) / sizeof (BaudRateList
[0])));
697 NewTerminalContext
->BaudRate
= BaudRateList
[CurrentFakeNVMap
->COMBaudRate
].Value
;
698 NewTerminalContext
->DataBitsIndex
= CurrentFakeNVMap
->COMDataRate
;
699 ASSERT (CurrentFakeNVMap
->COMDataRate
< (sizeof (DataBitsList
) / sizeof (DataBitsList
[0])));
700 NewTerminalContext
->DataBits
= (UINT8
) DataBitsList
[CurrentFakeNVMap
->COMDataRate
].Value
;
701 NewTerminalContext
->StopBitsIndex
= CurrentFakeNVMap
->COMStopBits
;
702 ASSERT (CurrentFakeNVMap
->COMStopBits
< (sizeof (StopBitsList
) / sizeof (StopBitsList
[0])));
703 NewTerminalContext
->StopBits
= (UINT8
) StopBitsList
[CurrentFakeNVMap
->COMStopBits
].Value
;
704 NewTerminalContext
->ParityIndex
= CurrentFakeNVMap
->COMParity
;
705 ASSERT (CurrentFakeNVMap
->COMParity
< (sizeof (ParityList
) / sizeof (ParityList
[0])));
706 NewTerminalContext
->Parity
= (UINT8
) ParityList
[CurrentFakeNVMap
->COMParity
].Value
;
707 NewTerminalContext
->TerminalType
= CurrentFakeNVMap
->COMTerminalType
;
708 NewTerminalContext
->FlowControl
= CurrentFakeNVMap
->COMFlowControl
;
710 ChangeTerminalDevicePath (
711 &(NewTerminalContext
->DevicePath
),
715 Var_UpdateConsoleInpOption ();
716 Var_UpdateConsoleOutOption ();
717 Var_UpdateErrorOutOption ();
721 for (Index
= 0; Index
< ConsoleInpMenu
.MenuNumber
; Index
++) {
722 NewMenuEntry
= BOpt_GetMenuEntry (&ConsoleInpMenu
, Index
);
723 NewConsoleContext
= (BM_CONSOLE_CONTEXT
*) NewMenuEntry
->VariableContext
;
724 ASSERT (Index
< MAX_MENU_NUMBER
);
725 NewConsoleContext
->IsActive
= CurrentFakeNVMap
->ConsoleCheck
[Index
];
728 for (Index
= 0; Index
< TerminalMenu
.MenuNumber
; Index
++) {
729 NewMenuEntry
= BOpt_GetMenuEntry (&TerminalMenu
, Index
);
730 NewTerminalContext
= (BM_TERMINAL_CONTEXT
*) NewMenuEntry
->VariableContext
;
731 ASSERT (Index
+ ConsoleInpMenu
.MenuNumber
< MAX_MENU_NUMBER
);
732 NewTerminalContext
->IsConIn
= CurrentFakeNVMap
->ConsoleCheck
[Index
+ ConsoleInpMenu
.MenuNumber
];
735 Var_UpdateConsoleInpOption ();
738 case FORM_CON_OUT_ID
:
739 for (Index
= 0; Index
< ConsoleOutMenu
.MenuNumber
; Index
++) {
740 NewMenuEntry
= BOpt_GetMenuEntry (&ConsoleOutMenu
, Index
);
741 NewConsoleContext
= (BM_CONSOLE_CONTEXT
*) NewMenuEntry
->VariableContext
;
742 ASSERT (Index
< MAX_MENU_NUMBER
);
743 NewConsoleContext
->IsActive
= CurrentFakeNVMap
->ConsoleCheck
[Index
];
746 for (Index
= 0; Index
< TerminalMenu
.MenuNumber
; Index
++) {
747 NewMenuEntry
= BOpt_GetMenuEntry (&TerminalMenu
, Index
);
748 NewTerminalContext
= (BM_TERMINAL_CONTEXT
*) NewMenuEntry
->VariableContext
;
749 ASSERT (Index
+ ConsoleOutMenu
.MenuNumber
< MAX_MENU_NUMBER
);
750 NewTerminalContext
->IsConOut
= CurrentFakeNVMap
->ConsoleCheck
[Index
+ ConsoleOutMenu
.MenuNumber
];
753 Var_UpdateConsoleOutOption ();
756 case FORM_CON_ERR_ID
:
757 for (Index
= 0; Index
< ConsoleErrMenu
.MenuNumber
; Index
++) {
758 NewMenuEntry
= BOpt_GetMenuEntry (&ConsoleErrMenu
, Index
);
759 NewConsoleContext
= (BM_CONSOLE_CONTEXT
*) NewMenuEntry
->VariableContext
;
760 ASSERT (Index
< MAX_MENU_NUMBER
);
761 NewConsoleContext
->IsActive
= CurrentFakeNVMap
->ConsoleCheck
[Index
];
764 for (Index
= 0; Index
< TerminalMenu
.MenuNumber
; Index
++) {
765 NewMenuEntry
= BOpt_GetMenuEntry (&TerminalMenu
, Index
);
766 NewTerminalContext
= (BM_TERMINAL_CONTEXT
*) NewMenuEntry
->VariableContext
;
767 ASSERT (Index
+ ConsoleErrMenu
.MenuNumber
< MAX_MENU_NUMBER
);
768 NewTerminalContext
->IsStdErr
= CurrentFakeNVMap
->ConsoleCheck
[Index
+ ConsoleErrMenu
.MenuNumber
];
771 Var_UpdateErrorOutOption ();
774 case FORM_DRV_ADD_HANDLE_DESC_ID
:
775 Status
= Var_UpdateDriverOption (
777 Private
->BmmHiiHandle
,
778 CurrentFakeNVMap
->DriverAddHandleDesc
,
779 CurrentFakeNVMap
->DriverAddHandleOptionalData
,
780 CurrentFakeNVMap
->DriverAddForceReconnect
782 if (EFI_ERROR (Status
)) {
786 BOpt_GetDriverOptions (Private
);
787 CreateMenuStringToken (Private
, Private
->BmmHiiHandle
, &DriverOptionMenu
);
799 Discard all changes done to the BMM pages such as Boot Order change,
802 @param Private The BMM context data.
803 @param CurrentFakeNVMap The current Fack NV Map.
807 DiscardChangeHandler (
808 IN BMM_CALLBACK_DATA
*Private
,
809 IN BMM_FAKE_NV_DATA
*CurrentFakeNVMap
814 switch (Private
->BmmPreviousPageId
) {
815 case FORM_BOOT_CHG_ID
:
816 case FORM_DRV_CHG_ID
:
817 CopyMem (CurrentFakeNVMap
->OptionOrder
, Private
->BmmOldFakeNVData
.OptionOrder
, sizeof (CurrentFakeNVMap
->OptionOrder
));
820 case FORM_BOOT_DEL_ID
:
821 ASSERT (BootOptionMenu
.MenuNumber
<= (sizeof (CurrentFakeNVMap
->OptionDel
) / sizeof (CurrentFakeNVMap
->OptionDel
[0])));
822 for (Index
= 0; Index
< BootOptionMenu
.MenuNumber
; Index
++) {
823 CurrentFakeNVMap
->OptionDel
[Index
] = FALSE
;
827 case FORM_DRV_DEL_ID
:
828 ASSERT (DriverOptionMenu
.MenuNumber
<= (sizeof (CurrentFakeNVMap
->OptionDel
) / sizeof (CurrentFakeNVMap
->OptionDel
[0])));
829 for (Index
= 0; Index
< DriverOptionMenu
.MenuNumber
; Index
++) {
830 CurrentFakeNVMap
->OptionDel
[Index
] = FALSE
;
834 case FORM_BOOT_NEXT_ID
:
835 CurrentFakeNVMap
->BootNext
= Private
->BmmOldFakeNVData
.BootNext
;
838 case FORM_TIME_OUT_ID
:
839 CurrentFakeNVMap
->BootTimeOut
= Private
->BmmOldFakeNVData
.BootTimeOut
;
842 case FORM_DRV_ADD_HANDLE_DESC_ID
:
843 case FORM_DRV_ADD_FILE_ID
:
844 case FORM_DRV_ADD_HANDLE_ID
:
845 CurrentFakeNVMap
->DriverAddHandleDesc
[0] = 0x0000;
846 CurrentFakeNVMap
->DriverAddHandleOptionalData
[0] = 0x0000;
855 Initialize the Boot Maintenance Utitliy.
858 @retval EFI_SUCCESS utility ended successfully
859 @retval others contain some errors
867 EFI_LEGACY_BIOS_PROTOCOL
*LegacyBios
;
868 BMM_CALLBACK_DATA
*BmmCallbackInfo
;
872 Status
= EFI_SUCCESS
;
875 // Create CallbackData structures for Driver Callback
877 BmmCallbackInfo
= AllocateZeroPool (sizeof (BMM_CALLBACK_DATA
));
878 if (BmmCallbackInfo
== NULL
) {
879 return EFI_OUT_OF_RESOURCES
;
883 // Create LoadOption in BmmCallbackInfo for Driver Callback
885 Ptr
= AllocateZeroPool (sizeof (BM_LOAD_CONTEXT
) + sizeof (BM_FILE_CONTEXT
) + sizeof (BM_HANDLE_CONTEXT
) + sizeof (BM_MENU_ENTRY
));
887 FreePool (BmmCallbackInfo
);
888 return EFI_OUT_OF_RESOURCES
;
892 // Initialize Bmm callback data.
894 BmmCallbackInfo
->LoadContext
= (BM_LOAD_CONTEXT
*) Ptr
;
895 Ptr
+= sizeof (BM_LOAD_CONTEXT
);
897 BmmCallbackInfo
->FileContext
= (BM_FILE_CONTEXT
*) Ptr
;
898 Ptr
+= sizeof (BM_FILE_CONTEXT
);
900 BmmCallbackInfo
->HandleContext
= (BM_HANDLE_CONTEXT
*) Ptr
;
901 Ptr
+= sizeof (BM_HANDLE_CONTEXT
);
903 BmmCallbackInfo
->MenuEntry
= (BM_MENU_ENTRY
*) Ptr
;
905 BmmCallbackInfo
->Signature
= BMM_CALLBACK_DATA_SIGNATURE
;
906 BmmCallbackInfo
->BmmConfigAccess
.ExtractConfig
= BootMaintExtractConfig
;
907 BmmCallbackInfo
->BmmConfigAccess
.RouteConfig
= FakeRouteConfig
;
908 BmmCallbackInfo
->BmmConfigAccess
.Callback
= BootMaintCallback
;
909 BmmCallbackInfo
->BmmPreviousPageId
= FORM_MAIN_ID
;
910 BmmCallbackInfo
->BmmCurrentPageId
= FORM_MAIN_ID
;
911 BmmCallbackInfo
->FeConfigAccess
.ExtractConfig
= FakeExtractConfig
;
912 BmmCallbackInfo
->FeConfigAccess
.RouteConfig
= FakeRouteConfig
;
913 BmmCallbackInfo
->FeConfigAccess
.Callback
= FileExplorerCallback
;
914 BmmCallbackInfo
->FeCurrentState
= FileExplorerStateInActive
;
915 BmmCallbackInfo
->FeDisplayContext
= FileExplorerDisplayUnknown
;
918 // Install Device Path Protocol and Config Access protocol to driver handle
920 Status
= gBS
->InstallMultipleProtocolInterfaces (
921 &BmmCallbackInfo
->BmmDriverHandle
,
922 &gEfiDevicePathProtocolGuid
,
923 &mBmmHiiVendorDevicePath
,
924 &gEfiHiiConfigAccessProtocolGuid
,
925 &BmmCallbackInfo
->BmmConfigAccess
,
928 if (EFI_ERROR (Status
)) {
933 // Install Device Path Protocol and Config Access protocol to driver handle
935 Status
= gBS
->InstallMultipleProtocolInterfaces (
936 &BmmCallbackInfo
->FeDriverHandle
,
937 &gEfiDevicePathProtocolGuid
,
938 &mFeHiiVendorDevicePath
,
939 &gEfiHiiConfigAccessProtocolGuid
,
940 &BmmCallbackInfo
->FeConfigAccess
,
943 if (EFI_ERROR (Status
)) {
948 // Post our Boot Maint VFR binary to the HII database.
950 BmmCallbackInfo
->BmmHiiHandle
= HiiAddPackages (
951 &gBootMaintFormSetGuid
,
952 BmmCallbackInfo
->BmmDriverHandle
,
957 ASSERT (BmmCallbackInfo
->BmmHiiHandle
!= NULL
);
960 // Post our File Explorer VFR binary to the HII database.
962 BmmCallbackInfo
->FeHiiHandle
= HiiAddPackages (
963 &gFileExploreFormSetGuid
,
964 BmmCallbackInfo
->FeDriverHandle
,
969 ASSERT (BmmCallbackInfo
->FeHiiHandle
!= NULL
);
972 // Init OpCode Handle and Allocate space for creation of Buffer
974 mStartOpCodeHandle
= HiiAllocateOpCodeHandle ();
975 if (mStartOpCodeHandle
== NULL
) {
976 Status
= EFI_OUT_OF_RESOURCES
;
980 mEndOpCodeHandle
= HiiAllocateOpCodeHandle ();
981 if (mEndOpCodeHandle
== NULL
) {
982 Status
= EFI_OUT_OF_RESOURCES
;
987 // Create Hii Extend Label OpCode as the start opcode
989 mStartLabel
= (EFI_IFR_GUID_LABEL
*) HiiCreateGuidOpCode (mStartOpCodeHandle
, &gEfiIfrTianoGuid
, NULL
, sizeof (EFI_IFR_GUID_LABEL
));
990 mStartLabel
->ExtendOpCode
= EFI_IFR_EXTEND_OP_LABEL
;
993 // Create Hii Extend Label OpCode as the end opcode
995 mEndLabel
= (EFI_IFR_GUID_LABEL
*) HiiCreateGuidOpCode (mEndOpCodeHandle
, &gEfiIfrTianoGuid
, NULL
, sizeof (EFI_IFR_GUID_LABEL
));
996 mEndLabel
->ExtendOpCode
= EFI_IFR_EXTEND_OP_LABEL
;
997 mEndLabel
->Number
= LABEL_END
;
999 InitializeStringDepository ();
1001 InitAllMenu (BmmCallbackInfo
);
1003 CreateMenuStringToken (BmmCallbackInfo
, BmmCallbackInfo
->BmmHiiHandle
, &ConsoleInpMenu
);
1004 CreateMenuStringToken (BmmCallbackInfo
, BmmCallbackInfo
->BmmHiiHandle
, &ConsoleOutMenu
);
1005 CreateMenuStringToken (BmmCallbackInfo
, BmmCallbackInfo
->BmmHiiHandle
, &ConsoleErrMenu
);
1006 CreateMenuStringToken (BmmCallbackInfo
, BmmCallbackInfo
->BmmHiiHandle
, &BootOptionMenu
);
1007 CreateMenuStringToken (BmmCallbackInfo
, BmmCallbackInfo
->BmmHiiHandle
, &DriverOptionMenu
);
1008 CreateMenuStringToken (BmmCallbackInfo
, BmmCallbackInfo
->BmmHiiHandle
, &TerminalMenu
);
1009 CreateMenuStringToken (BmmCallbackInfo
, BmmCallbackInfo
->BmmHiiHandle
, &DriverMenu
);
1011 UpdateBootDelPage (BmmCallbackInfo
);
1012 UpdateDrvDelPage (BmmCallbackInfo
);
1014 if (TerminalMenu
.MenuNumber
> 0) {
1015 BmmCallbackInfo
->CurrentTerminal
= 0;
1016 UpdateTerminalPage (BmmCallbackInfo
);
1019 Status
= EfiLibLocateProtocol (&gEfiLegacyBiosProtocolGuid
, (VOID
**) &LegacyBios
);
1020 if (!EFI_ERROR (Status
)) {
1021 RefreshUpdateData ();
1022 mStartLabel
->Number
= FORM_BOOT_LEGACY_DEVICE_ID
;
1025 // If LegacyBios Protocol is installed, add 3 tags about legacy boot option
1026 // in BootOption form: legacy FD/HD/CD/NET/BEV
1028 HiiCreateGotoOpCode (
1030 FORM_SET_FD_ORDER_ID
,
1031 STRING_TOKEN (STR_FORM_SET_FD_ORDER_TITLE
),
1032 STRING_TOKEN (STR_FORM_SET_FD_ORDER_TITLE
),
1033 EFI_IFR_FLAG_CALLBACK
,
1034 FORM_SET_FD_ORDER_ID
1037 HiiCreateGotoOpCode (
1039 FORM_SET_HD_ORDER_ID
,
1040 STRING_TOKEN (STR_FORM_SET_HD_ORDER_TITLE
),
1041 STRING_TOKEN (STR_FORM_SET_HD_ORDER_TITLE
),
1042 EFI_IFR_FLAG_CALLBACK
,
1043 FORM_SET_HD_ORDER_ID
1046 HiiCreateGotoOpCode (
1048 FORM_SET_CD_ORDER_ID
,
1049 STRING_TOKEN (STR_FORM_SET_CD_ORDER_TITLE
),
1050 STRING_TOKEN (STR_FORM_SET_CD_ORDER_TITLE
),
1051 EFI_IFR_FLAG_CALLBACK
,
1052 FORM_SET_CD_ORDER_ID
1055 HiiCreateGotoOpCode (
1057 FORM_SET_NET_ORDER_ID
,
1058 STRING_TOKEN (STR_FORM_SET_NET_ORDER_TITLE
),
1059 STRING_TOKEN (STR_FORM_SET_NET_ORDER_TITLE
),
1060 EFI_IFR_FLAG_CALLBACK
,
1061 FORM_SET_NET_ORDER_ID
1064 HiiCreateGotoOpCode (
1066 FORM_SET_BEV_ORDER_ID
,
1067 STRING_TOKEN (STR_FORM_SET_BEV_ORDER_TITLE
),
1068 STRING_TOKEN (STR_FORM_SET_BEV_ORDER_TITLE
),
1069 EFI_IFR_FLAG_CALLBACK
,
1070 FORM_SET_BEV_ORDER_ID
1074 BmmCallbackInfo
->BmmHiiHandle
,
1075 &gBootMaintFormSetGuid
,
1077 mStartOpCodeHandle
, // Label FORM_BOOT_LEGACY_DEVICE_ID
1078 mEndOpCodeHandle
// LABEL_END
1083 // Dispatch BMM main formset and File Explorer formset.
1085 FormSetDispatcher (BmmCallbackInfo
);
1088 // Remove our IFR data from HII database
1090 HiiRemovePackages (BmmCallbackInfo
->BmmHiiHandle
);
1091 HiiRemovePackages (BmmCallbackInfo
->FeHiiHandle
);
1093 CleanUpStringDepository ();
1098 if (mStartOpCodeHandle
!= NULL
) {
1099 HiiFreeOpCodeHandle (mStartOpCodeHandle
);
1102 if (mEndOpCodeHandle
!= NULL
) {
1103 HiiFreeOpCodeHandle (mEndOpCodeHandle
);
1106 if (BmmCallbackInfo
->FeDriverHandle
!= NULL
) {
1107 gBS
->UninstallMultipleProtocolInterfaces (
1108 BmmCallbackInfo
->FeDriverHandle
,
1109 &gEfiDevicePathProtocolGuid
,
1110 &mFeHiiVendorDevicePath
,
1111 &gEfiHiiConfigAccessProtocolGuid
,
1112 &BmmCallbackInfo
->FeConfigAccess
,
1117 if (BmmCallbackInfo
->BmmDriverHandle
!= NULL
) {
1118 gBS
->UninstallMultipleProtocolInterfaces (
1119 BmmCallbackInfo
->BmmDriverHandle
,
1120 &gEfiDevicePathProtocolGuid
,
1121 &mBmmHiiVendorDevicePath
,
1122 &gEfiHiiConfigAccessProtocolGuid
,
1123 &BmmCallbackInfo
->BmmConfigAccess
,
1128 FreePool (BmmCallbackInfo
->LoadContext
);
1129 FreePool (BmmCallbackInfo
);
1135 Initialized all Menu Option List.
1137 @param CallbackData The BMM context data.
1142 IN BMM_CALLBACK_DATA
*CallbackData
1145 InitializeListHead (&BootOptionMenu
.Head
);
1146 InitializeListHead (&DriverOptionMenu
.Head
);
1147 BOpt_GetBootOptions (CallbackData
);
1148 BOpt_GetDriverOptions (CallbackData
);
1149 BOpt_GetLegacyOptions ();
1150 InitializeListHead (&FsOptionMenu
.Head
);
1151 BOpt_FindDrivers ();
1152 InitializeListHead (&DirectoryMenu
.Head
);
1153 InitializeListHead (&ConsoleInpMenu
.Head
);
1154 InitializeListHead (&ConsoleOutMenu
.Head
);
1155 InitializeListHead (&ConsoleErrMenu
.Head
);
1156 InitializeListHead (&TerminalMenu
.Head
);
1162 Free up all Menu Option list.
1170 BOpt_FreeMenu (&DirectoryMenu
);
1171 BOpt_FreeMenu (&FsOptionMenu
);
1172 BOpt_FreeMenu (&BootOptionMenu
);
1173 BOpt_FreeMenu (&DriverOptionMenu
);
1174 BOpt_FreeMenu (&DriverMenu
);
1175 BOpt_FreeLegacyOptions ();
1180 Initialize all the string depositories.
1184 InitializeStringDepository (
1188 STRING_DEPOSITORY
*StringDepository
;
1189 StringDepository
= AllocateZeroPool (sizeof (STRING_DEPOSITORY
) * STRING_DEPOSITORY_NUMBER
);
1190 FileOptionStrDepository
= StringDepository
++;
1191 ConsoleOptionStrDepository
= StringDepository
++;
1192 BootOptionStrDepository
= StringDepository
++;
1193 BootOptionHelpStrDepository
= StringDepository
++;
1194 DriverOptionStrDepository
= StringDepository
++;
1195 DriverOptionHelpStrDepository
= StringDepository
++;
1196 TerminalStrDepository
= StringDepository
;
1200 Fetch a usable string node from the string depository and return the string token.
1202 @param CallbackData The BMM context data.
1203 @param StringDepository The string repository.
1205 @retval EFI_STRING_ID String token.
1209 GetStringTokenFromDepository (
1210 IN BMM_CALLBACK_DATA
*CallbackData
,
1211 IN STRING_DEPOSITORY
*StringDepository
1214 STRING_LIST_NODE
*CurrentListNode
;
1215 STRING_LIST_NODE
*NextListNode
;
1217 CurrentListNode
= StringDepository
->CurrentNode
;
1219 if ((NULL
!= CurrentListNode
) && (NULL
!= CurrentListNode
->Next
)) {
1221 // Fetch one reclaimed node from the list.
1223 NextListNode
= StringDepository
->CurrentNode
->Next
;
1226 // If there is no usable node in the list, update the list.
1228 NextListNode
= AllocateZeroPool (sizeof (STRING_LIST_NODE
));
1229 ASSERT (NextListNode
!= NULL
);
1230 NextListNode
->StringToken
= HiiSetString (CallbackData
->BmmHiiHandle
, 0, L
" ", NULL
);
1231 ASSERT (NextListNode
->StringToken
!= 0);
1233 StringDepository
->TotalNodeNumber
++;
1235 if (NULL
== CurrentListNode
) {
1236 StringDepository
->ListHead
= NextListNode
;
1238 CurrentListNode
->Next
= NextListNode
;
1242 StringDepository
->CurrentNode
= NextListNode
;
1244 return StringDepository
->CurrentNode
->StringToken
;
1248 Reclaim string depositories by moving the current node pointer to list head..
1252 ReclaimStringDepository (
1256 UINTN DepositoryIndex
;
1257 STRING_DEPOSITORY
*StringDepository
;
1259 StringDepository
= FileOptionStrDepository
;
1260 for (DepositoryIndex
= 0; DepositoryIndex
< STRING_DEPOSITORY_NUMBER
; DepositoryIndex
++) {
1261 StringDepository
->CurrentNode
= StringDepository
->ListHead
;
1267 Release resource for all the string depositories.
1271 CleanUpStringDepository (
1276 UINTN DepositoryIndex
;
1277 STRING_LIST_NODE
*CurrentListNode
;
1278 STRING_LIST_NODE
*NextListNode
;
1279 STRING_DEPOSITORY
*StringDepository
;
1282 // Release string list nodes.
1284 StringDepository
= FileOptionStrDepository
;
1285 for (DepositoryIndex
= 0; DepositoryIndex
< STRING_DEPOSITORY_NUMBER
; DepositoryIndex
++) {
1286 CurrentListNode
= StringDepository
->ListHead
;
1287 for (NodeIndex
= 0; NodeIndex
< StringDepository
->TotalNodeNumber
; NodeIndex
++) {
1288 NextListNode
= CurrentListNode
->Next
;
1289 FreePool (CurrentListNode
);
1290 CurrentListNode
= NextListNode
;
1296 // Release string depository.
1298 FreePool (FileOptionStrDepository
);
1302 Start boot maintenance manager
1304 @retval EFI_SUCCESS If BMM is invoked successfully.
1305 @return Other value if BMM return unsuccessfully.
1314 LIST_ENTRY BdsBootOptionList
;
1316 InitializeListHead (&BdsBootOptionList
);
1319 // Connect all prior to entering the platform setup menu.
1321 if (!gConnectAllHappened
) {
1322 BdsLibConnectAllDriversToAllControllers ();
1323 gConnectAllHappened
= TRUE
;
1326 // Have chance to enumerate boot device
1328 BdsLibEnumerateAllBootOption (&BdsBootOptionList
);
1333 Status
= InitializeBM ();
1339 Dispatch BMM formset and FileExplorer formset.
1342 @param CallbackData The BMM context data.
1344 @retval EFI_SUCCESS If function complete successfully.
1345 @return Other value if the Setup Browser process BMM's pages and
1346 return unsuccessfully.
1351 IN BMM_CALLBACK_DATA
*CallbackData
1355 EFI_BROWSER_ACTION_REQUEST ActionRequest
;
1358 UpdatePageId (CallbackData
, FORM_MAIN_ID
);
1360 ActionRequest
= EFI_BROWSER_ACTION_REQUEST_NONE
;
1361 Status
= gFormBrowser2
->SendForm (
1363 &CallbackData
->BmmHiiHandle
,
1365 &gBootMaintFormSetGuid
,
1370 if (ActionRequest
== EFI_BROWSER_ACTION_REQUEST_RESET
) {
1371 EnableResetRequired ();
1374 ReclaimStringDepository ();
1377 // When this Formset returns, check if we are going to explore files.
1379 if (FileExplorerStateInActive
!= CallbackData
->FeCurrentState
) {
1380 UpdateFileExplorer (CallbackData
, 0);
1382 ActionRequest
= EFI_BROWSER_ACTION_REQUEST_NONE
;
1383 Status
= gFormBrowser2
->SendForm (
1385 &CallbackData
->FeHiiHandle
,
1387 &gFileExploreFormSetGuid
,
1392 if (ActionRequest
== EFI_BROWSER_ACTION_REQUEST_RESET
) {
1393 EnableResetRequired ();
1396 CallbackData
->FeCurrentState
= FileExplorerStateInActive
;
1397 CallbackData
->FeDisplayContext
= FileExplorerDisplayUnknown
;
1398 ReclaimStringDepository ();
1409 Deletete the Boot Option from EFI Variable. The Boot Order Arrray
1412 @param OptionNumber The number of Boot option want to be deleted.
1413 @param BootOrder The Boot Order array.
1414 @param BootOrderSize The size of the Boot Order Array.
1416 @retval EFI_SUCCESS The Boot Option Variable was found and removed
1417 @retval EFI_UNSUPPORTED The Boot Option Variable store was inaccessible
1418 @retval EFI_NOT_FOUND The Boot Option Variable was not found
1422 BdsDeleteBootOption (
1423 IN UINTN OptionNumber
,
1424 IN OUT UINT16
*BootOrder
,
1425 IN OUT UINTN
*BootOrderSize
1428 UINT16 BootOption
[100];
1433 Status
= EFI_SUCCESS
;
1436 UnicodeSPrint (BootOption
, sizeof (BootOption
), L
"Boot%04x", OptionNumber
);
1437 Status
= EfiLibDeleteVariable (BootOption
, &gEfiGlobalVariableGuid
);
1440 // adjust boot order array
1442 for (Index
= 0; Index
< *BootOrderSize
/ sizeof (UINT16
); Index
++) {
1443 if (BootOrder
[Index
] == OptionNumber
) {
1449 if (Index
!= *BootOrderSize
/ sizeof (UINT16
)) {
1450 for (Index
= 0; Index
< *BootOrderSize
/ sizeof (UINT16
) - 1; Index
++) {
1451 if (Index
>= Index2Del
) {
1452 BootOrder
[Index
] = BootOrder
[Index
+ 1];
1456 *BootOrderSize
-= sizeof (UINT16
);