2 The functions for Boot Maintainence Main menu.
4 Copyright (c) 2004 - 2009, Intel Corporation. <BR>
5 All rights reserved. This program and the accompanying materials
6 are licensed and made available under the terms and conditions of the BSD License
7 which accompanies this distribution. The full text of the license may be found at
8 http://opensource.org/licenses/bsd-license.php
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
;
188 if (Request
== NULL
) {
189 return EFI_INVALID_PARAMETER
;
192 Private
= BMM_CALLBACK_DATA_FROM_THIS (This
);
195 // Convert buffer data to <ConfigResp> by helper function BlockToConfig()
197 BufferSize
= sizeof (BMM_FAKE_NV_DATA
);
198 Status
= gHiiConfigRouting
->BlockToConfig (
201 (UINT8
*) &Private
->BmmFakeNvData
,
210 This function processes the results of changes in configuration.
213 @param This Points to the EFI_HII_CONFIG_ACCESS_PROTOCOL.
214 @param Action Specifies the type of action taken by the browser.
215 @param QuestionId A unique value which is sent to the original exporting driver
216 so that it can identify the type of data to expect.
217 @param Type The type of value for the question.
218 @param Value A pointer to the data being sent to the original exporting driver.
219 @param ActionRequest On return, points to the action requested by the callback function.
221 @retval EFI_SUCCESS The callback successfully handled the action.
222 @retval EFI_OUT_OF_RESOURCES Not enough storage is available to hold the variable and its data.
223 @retval EFI_DEVICE_ERROR The variable could not be saved.
224 @retval EFI_UNSUPPORTED The specified Action is not supported by the callback.
225 @retval EFI_INVALID_PARAMETER The parameter of Value or ActionRequest is invalid.
230 IN CONST EFI_HII_CONFIG_ACCESS_PROTOCOL
*This
,
231 IN EFI_BROWSER_ACTION Action
,
232 IN EFI_QUESTION_ID QuestionId
,
234 IN EFI_IFR_TYPE_VALUE
*Value
,
235 OUT EFI_BROWSER_ACTION_REQUEST
*ActionRequest
238 BMM_CALLBACK_DATA
*Private
;
239 BM_MENU_ENTRY
*NewMenuEntry
;
240 BMM_FAKE_NV_DATA
*CurrentFakeNVMap
;
255 if ((Value
== NULL
) || (ActionRequest
== NULL
)) {
256 return EFI_INVALID_PARAMETER
;
266 *ActionRequest
= EFI_BROWSER_ACTION_REQUEST_NONE
;
268 Private
= BMM_CALLBACK_DATA_FROM_THIS (This
);
269 UpdatePageId (Private
, QuestionId
);
272 // Retrive uncommitted data from Form Browser
274 CurrentFakeNVMap
= &Private
->BmmFakeNvData
;
275 HiiGetBrowserData (&mBootMaintGuid
, mBootMaintStorageName
, sizeof (BMM_FAKE_NV_DATA
), (UINT8
*) CurrentFakeNVMap
);
278 // need to be subtituded.
280 // Update Select FD/HD/CD/NET/BEV Order Form
282 if (FORM_SET_FD_ORDER_ID
== Private
->BmmPreviousPageId
||
283 FORM_SET_HD_ORDER_ID
== Private
->BmmPreviousPageId
||
284 FORM_SET_CD_ORDER_ID
== Private
->BmmPreviousPageId
||
285 FORM_SET_NET_ORDER_ID
== Private
->BmmPreviousPageId
||
286 FORM_SET_BEV_ORDER_ID
== Private
->BmmPreviousPageId
||
287 ((FORM_BOOT_SETUP_ID
== Private
->BmmPreviousPageId
) &&
288 (QuestionId
>= LEGACY_FD_QUESTION_ID
) &&
289 (QuestionId
< (LEGACY_BEV_QUESTION_ID
+ 100)) )
292 DisMap
= Private
->BmmOldFakeNVData
.DisableMap
;
294 FormId
= Private
->BmmPreviousPageId
;
295 if (FormId
== FORM_BOOT_SETUP_ID
) {
296 FormId
= Private
->BmmCurrentPageId
;
300 case FORM_SET_FD_ORDER_ID
:
301 Number
= (UINT16
) LegacyFDMenu
.MenuNumber
;
302 OldLegacyDev
= Private
->BmmOldFakeNVData
.LegacyFD
;
303 NewLegacyDev
= CurrentFakeNVMap
->LegacyFD
;
306 case FORM_SET_HD_ORDER_ID
:
307 Number
= (UINT16
) LegacyHDMenu
.MenuNumber
;
308 OldLegacyDev
= Private
->BmmOldFakeNVData
.LegacyHD
;
309 NewLegacyDev
= CurrentFakeNVMap
->LegacyHD
;
312 case FORM_SET_CD_ORDER_ID
:
313 Number
= (UINT16
) LegacyCDMenu
.MenuNumber
;
314 OldLegacyDev
= Private
->BmmOldFakeNVData
.LegacyCD
;
315 NewLegacyDev
= CurrentFakeNVMap
->LegacyCD
;
318 case FORM_SET_NET_ORDER_ID
:
319 Number
= (UINT16
) LegacyNETMenu
.MenuNumber
;
320 OldLegacyDev
= Private
->BmmOldFakeNVData
.LegacyNET
;
321 NewLegacyDev
= CurrentFakeNVMap
->LegacyNET
;
324 case FORM_SET_BEV_ORDER_ID
:
325 Number
= (UINT16
) LegacyBEVMenu
.MenuNumber
;
326 OldLegacyDev
= Private
->BmmOldFakeNVData
.LegacyBEV
;
327 NewLegacyDev
= CurrentFakeNVMap
->LegacyBEV
;
334 // First, find the different position
335 // if there is change, it should be only one
337 for (Index
= 0; Index
< Number
; Index
++) {
338 if (OldLegacyDev
[Index
] != NewLegacyDev
[Index
]) {
339 OldValue
= OldLegacyDev
[Index
];
340 NewValue
= NewLegacyDev
[Index
];
345 if (Index
!= Number
) {
347 // there is change, now process
349 if (0xFF == NewValue
) {
351 // This item will be disable
352 // Just move the items behind this forward to overlap it
355 Bit
= 7 - (OldValue
% 8);
356 DisMap
[Pos
] = (UINT8
) (DisMap
[Pos
] | (UINT8
) (1 << Bit
));
357 for (Index2
= Index
; Index2
< Number
- 1; Index2
++) {
358 NewLegacyDev
[Index2
] = NewLegacyDev
[Index2
+ 1];
361 NewLegacyDev
[Index2
] = 0xFF;
363 for (Index2
= 0; Index2
< Number
; Index2
++) {
364 if (Index2
== Index
) {
368 if (OldLegacyDev
[Index2
] == NewValue
) {
370 // If NewValue is in OldLegacyDev array
371 // remember its old position
373 NewValuePos
= Index2
;
378 if (Index2
!= Number
) {
380 // We will change current item to an existing item
381 // (It's hard to describe here, please read code, it's like a cycle-moving)
383 for (Index2
= NewValuePos
; Index2
!= Index
;) {
384 if (NewValuePos
< Index
) {
385 NewLegacyDev
[Index2
] = OldLegacyDev
[Index2
+ 1];
388 NewLegacyDev
[Index2
] = OldLegacyDev
[Index2
- 1];
394 // If NewValue is not in OldlegacyDev array, we are changing to a disabled item
395 // so we should modify DisMap to reflect the change
398 Bit
= 7 - (NewValue
% 8);
399 DisMap
[Pos
] = (UINT8
) (DisMap
[Pos
] & (~ (UINT8
) (1 << Bit
)));
400 if (0xFF != OldValue
) {
402 // Because NewValue is a item that was disabled before
403 // so after changing the OldValue should be disabled
404 // actually we are doing a swap of enable-disable states of two items
407 Bit
= 7 - (OldValue
% 8);
408 DisMap
[Pos
] = (UINT8
) (DisMap
[Pos
] | (UINT8
) (1 << Bit
));
413 // To prevent DISABLE appears in the middle of the list
414 // we should perform a re-ordering
417 while (Index
< Number
) {
418 if (0xFF != NewLegacyDev
[Index
]) {
425 while (Index2
< Number
) {
426 if (0xFF != NewLegacyDev
[Index2
]) {
433 if (Index2
< Number
) {
434 NewLegacyDev
[Index
] = NewLegacyDev
[Index2
];
435 NewLegacyDev
[Index2
] = 0xFF;
449 if (QuestionId
< FILE_OPTION_OFFSET
) {
450 if (QuestionId
< CONFIG_OPTION_OFFSET
) {
451 switch (QuestionId
) {
452 case KEY_VALUE_BOOT_FROM_FILE
:
453 Private
->FeCurrentState
= FileExplorerStateBootFromFile
;
456 // Exit Bmm main formset to send File Explorer formset.
458 *ActionRequest
= EFI_BROWSER_ACTION_REQUEST_EXIT
;
461 case FORM_BOOT_ADD_ID
:
462 Private
->FeCurrentState
= FileExplorerStateAddBootOption
;
465 // Exit Bmm main formset to send File Explorer formset.
467 *ActionRequest
= EFI_BROWSER_ACTION_REQUEST_EXIT
;
470 case FORM_DRV_ADD_FILE_ID
:
471 Private
->FeCurrentState
= FileExplorerStateAddDriverOptionState
;
474 // Exit Bmm main formset to send File Explorer formset.
476 *ActionRequest
= EFI_BROWSER_ACTION_REQUEST_EXIT
;
479 case FORM_DRV_ADD_HANDLE_ID
:
480 CleanUpPage (FORM_DRV_ADD_HANDLE_ID
, Private
);
481 UpdateDrvAddHandlePage (Private
);
484 case FORM_BOOT_DEL_ID
:
485 CleanUpPage (FORM_BOOT_DEL_ID
, Private
);
486 UpdateBootDelPage (Private
);
489 case FORM_BOOT_CHG_ID
:
490 case FORM_DRV_CHG_ID
:
491 UpdatePageBody (QuestionId
, Private
);
494 case FORM_DRV_DEL_ID
:
495 CleanUpPage (FORM_DRV_DEL_ID
, Private
);
496 UpdateDrvDelPage (Private
);
499 case FORM_BOOT_NEXT_ID
:
500 CleanUpPage (FORM_BOOT_NEXT_ID
, Private
);
501 UpdateBootNextPage (Private
);
504 case FORM_TIME_OUT_ID
:
505 CleanUpPage (FORM_TIME_OUT_ID
, Private
);
506 UpdateTimeOutPage (Private
);
510 gRT
->ResetSystem (EfiResetCold
, EFI_SUCCESS
, 0, NULL
);
511 return EFI_UNSUPPORTED
;
514 case FORM_CON_OUT_ID
:
515 case FORM_CON_ERR_ID
:
516 UpdatePageBody (QuestionId
, Private
);
519 case FORM_CON_MODE_ID
:
520 CleanUpPage (FORM_CON_MODE_ID
, Private
);
521 UpdateConModePage (Private
);
524 case FORM_CON_COM_ID
:
525 CleanUpPage (FORM_CON_COM_ID
, Private
);
526 UpdateConCOMPage (Private
);
529 case FORM_SET_FD_ORDER_ID
:
530 case FORM_SET_HD_ORDER_ID
:
531 case FORM_SET_CD_ORDER_ID
:
532 case FORM_SET_NET_ORDER_ID
:
533 case FORM_SET_BEV_ORDER_ID
:
534 CleanUpPage (QuestionId
, Private
);
535 UpdateSetLegacyDeviceOrderPage (QuestionId
, Private
);
538 case KEY_VALUE_SAVE_AND_EXIT
:
539 case KEY_VALUE_NO_SAVE_AND_EXIT
:
541 if (QuestionId
== KEY_VALUE_SAVE_AND_EXIT
) {
542 Status
= ApplyChangeHandler (Private
, CurrentFakeNVMap
, Private
->BmmPreviousPageId
);
543 if (EFI_ERROR (Status
)) {
546 } else if (QuestionId
== KEY_VALUE_NO_SAVE_AND_EXIT
) {
547 DiscardChangeHandler (Private
, CurrentFakeNVMap
);
551 // Tell browser not to ask for confirmation of changes,
552 // since we have already applied or discarded.
554 *ActionRequest
= EFI_BROWSER_ACTION_REQUEST_SUBMIT
;
560 } else if ((QuestionId
>= TERMINAL_OPTION_OFFSET
) && (QuestionId
< CONSOLE_OPTION_OFFSET
)) {
561 Index2
= (UINT16
) (QuestionId
- TERMINAL_OPTION_OFFSET
);
562 Private
->CurrentTerminal
= Index2
;
564 CleanUpPage (FORM_CON_COM_SETUP_ID
, Private
);
565 UpdateTerminalPage (Private
);
567 } else if (QuestionId
>= HANDLE_OPTION_OFFSET
) {
568 Index2
= (UINT16
) (QuestionId
- HANDLE_OPTION_OFFSET
);
570 NewMenuEntry
= BOpt_GetMenuEntry (&DriverMenu
, Index2
);
571 ASSERT (NewMenuEntry
!= NULL
);
572 Private
->HandleContext
= (BM_HANDLE_CONTEXT
*) NewMenuEntry
->VariableContext
;
574 CleanUpPage (FORM_DRV_ADD_HANDLE_DESC_ID
, Private
);
576 Private
->MenuEntry
= NewMenuEntry
;
577 Private
->LoadContext
->FilePathList
= Private
->HandleContext
->DevicePath
;
579 UpdateDriverAddHandleDescPage (Private
);
584 // Pass changed uncommitted data back to Form Browser
586 Status
= HiiSetBrowserData (&mBootMaintGuid
, mBootMaintStorageName
, sizeof (BMM_FAKE_NV_DATA
), (UINT8
*) CurrentFakeNVMap
, NULL
);
592 Function handling request to apply changes for BMM pages.
594 @param Private Pointer to callback data buffer.
595 @param CurrentFakeNVMap Pointer to buffer holding data of various values used by BMM
596 @param FormId ID of the form which has sent the request to apply change.
598 @retval EFI_SUCCESS Change successfully applied.
599 @retval Other Error occurs while trying to apply changes.
604 IN BMM_CALLBACK_DATA
*Private
,
605 IN BMM_FAKE_NV_DATA
*CurrentFakeNVMap
,
606 IN EFI_FORM_ID FormId
609 BM_CONSOLE_CONTEXT
*NewConsoleContext
;
610 BM_TERMINAL_CONTEXT
*NewTerminalContext
;
611 BM_LOAD_CONTEXT
*NewLoadContext
;
612 BM_MENU_ENTRY
*NewMenuEntry
;
616 Status
= EFI_SUCCESS
;
619 case FORM_SET_FD_ORDER_ID
:
620 case FORM_SET_HD_ORDER_ID
:
621 case FORM_SET_CD_ORDER_ID
:
622 case FORM_SET_NET_ORDER_ID
:
623 case FORM_SET_BEV_ORDER_ID
:
624 Var_UpdateBBSOption (Private
);
627 case FORM_BOOT_DEL_ID
:
629 ((Index
< BootOptionMenu
.MenuNumber
) && (Index
< (sizeof (CurrentFakeNVMap
->BootOptionDel
) / sizeof (UINT8
))));
631 NewMenuEntry
= BOpt_GetMenuEntry (&BootOptionMenu
, Index
);
632 NewLoadContext
= (BM_LOAD_CONTEXT
*) NewMenuEntry
->VariableContext
;
633 NewLoadContext
->Deleted
= CurrentFakeNVMap
->BootOptionDel
[Index
];
636 Var_DelBootOption ();
639 case FORM_DRV_DEL_ID
:
641 ((Index
< DriverOptionMenu
.MenuNumber
) && (Index
< (sizeof (CurrentFakeNVMap
->DriverOptionDel
) / sizeof (UINT8
))));
643 NewMenuEntry
= BOpt_GetMenuEntry (&DriverOptionMenu
, Index
);
644 NewLoadContext
= (BM_LOAD_CONTEXT
*) NewMenuEntry
->VariableContext
;
645 NewLoadContext
->Deleted
= CurrentFakeNVMap
->DriverOptionDel
[Index
];
648 Var_DelDriverOption ();
651 case FORM_BOOT_CHG_ID
:
652 Status
= Var_UpdateBootOrder (Private
);
655 case FORM_DRV_CHG_ID
:
656 Status
= Var_UpdateDriverOrder (Private
);
659 case FORM_TIME_OUT_ID
:
660 PcdSet16 (PcdPlatformBootTimeOut
, CurrentFakeNVMap
->BootTimeOut
);
662 Private
->BmmOldFakeNVData
.BootTimeOut
= CurrentFakeNVMap
->BootTimeOut
;
665 case FORM_BOOT_NEXT_ID
:
666 Status
= Var_UpdateBootNext (Private
);
669 case FORM_CON_MODE_ID
:
670 Status
= Var_UpdateConMode (Private
);
673 case FORM_CON_COM_SETUP_ID
:
674 NewMenuEntry
= BOpt_GetMenuEntry (&TerminalMenu
, Private
->CurrentTerminal
);
676 ASSERT (NewMenuEntry
!= NULL
);
678 NewTerminalContext
= (BM_TERMINAL_CONTEXT
*) NewMenuEntry
->VariableContext
;
680 NewTerminalContext
->BaudRateIndex
= CurrentFakeNVMap
->COMBaudRate
;
681 ASSERT (CurrentFakeNVMap
->COMBaudRate
< (sizeof (BaudRateList
) / sizeof (BaudRateList
[0])));
682 NewTerminalContext
->BaudRate
= BaudRateList
[CurrentFakeNVMap
->COMBaudRate
].Value
;
683 NewTerminalContext
->DataBitsIndex
= CurrentFakeNVMap
->COMDataRate
;
684 ASSERT (CurrentFakeNVMap
->COMDataRate
< (sizeof (DataBitsList
) / sizeof (DataBitsList
[0])));
685 NewTerminalContext
->DataBits
= (UINT8
) DataBitsList
[CurrentFakeNVMap
->COMDataRate
].Value
;
686 NewTerminalContext
->StopBitsIndex
= CurrentFakeNVMap
->COMStopBits
;
687 ASSERT (CurrentFakeNVMap
->COMStopBits
< (sizeof (StopBitsList
) / sizeof (StopBitsList
[0])));
688 NewTerminalContext
->StopBits
= (UINT8
) StopBitsList
[CurrentFakeNVMap
->COMStopBits
].Value
;
689 NewTerminalContext
->ParityIndex
= CurrentFakeNVMap
->COMParity
;
690 ASSERT (CurrentFakeNVMap
->COMParity
< (sizeof (ParityList
) / sizeof (ParityList
[0])));
691 NewTerminalContext
->Parity
= (UINT8
) ParityList
[CurrentFakeNVMap
->COMParity
].Value
;
692 NewTerminalContext
->TerminalType
= CurrentFakeNVMap
->COMTerminalType
;
694 ChangeTerminalDevicePath (
695 NewTerminalContext
->DevicePath
,
699 Var_UpdateConsoleInpOption ();
700 Var_UpdateConsoleOutOption ();
701 Var_UpdateErrorOutOption ();
705 for (Index
= 0; Index
< ConsoleInpMenu
.MenuNumber
; Index
++) {
706 NewMenuEntry
= BOpt_GetMenuEntry (&ConsoleInpMenu
, Index
);
707 NewConsoleContext
= (BM_CONSOLE_CONTEXT
*) NewMenuEntry
->VariableContext
;
708 ASSERT (Index
< MAX_MENU_NUMBER
);
709 NewConsoleContext
->IsActive
= CurrentFakeNVMap
->ConsoleCheck
[Index
];
712 for (Index
= 0; Index
< TerminalMenu
.MenuNumber
; Index
++) {
713 NewMenuEntry
= BOpt_GetMenuEntry (&TerminalMenu
, Index
);
714 NewTerminalContext
= (BM_TERMINAL_CONTEXT
*) NewMenuEntry
->VariableContext
;
715 ASSERT (Index
+ ConsoleInpMenu
.MenuNumber
< MAX_MENU_NUMBER
);
716 NewTerminalContext
->IsConIn
= CurrentFakeNVMap
->ConsoleCheck
[Index
+ ConsoleInpMenu
.MenuNumber
];
719 Var_UpdateConsoleInpOption ();
722 case FORM_CON_OUT_ID
:
723 for (Index
= 0; Index
< ConsoleOutMenu
.MenuNumber
; Index
++) {
724 NewMenuEntry
= BOpt_GetMenuEntry (&ConsoleOutMenu
, Index
);
725 NewConsoleContext
= (BM_CONSOLE_CONTEXT
*) NewMenuEntry
->VariableContext
;
726 ASSERT (Index
< MAX_MENU_NUMBER
);
727 NewConsoleContext
->IsActive
= CurrentFakeNVMap
->ConsoleCheck
[Index
];
730 for (Index
= 0; Index
< TerminalMenu
.MenuNumber
; Index
++) {
731 NewMenuEntry
= BOpt_GetMenuEntry (&TerminalMenu
, Index
);
732 NewTerminalContext
= (BM_TERMINAL_CONTEXT
*) NewMenuEntry
->VariableContext
;
733 ASSERT (Index
+ ConsoleOutMenu
.MenuNumber
< MAX_MENU_NUMBER
);
734 NewTerminalContext
->IsConOut
= CurrentFakeNVMap
->ConsoleCheck
[Index
+ ConsoleOutMenu
.MenuNumber
];
737 Var_UpdateConsoleOutOption ();
740 case FORM_CON_ERR_ID
:
741 for (Index
= 0; Index
< ConsoleErrMenu
.MenuNumber
; Index
++) {
742 NewMenuEntry
= BOpt_GetMenuEntry (&ConsoleErrMenu
, Index
);
743 NewConsoleContext
= (BM_CONSOLE_CONTEXT
*) NewMenuEntry
->VariableContext
;
744 ASSERT (Index
< MAX_MENU_NUMBER
);
745 NewConsoleContext
->IsActive
= CurrentFakeNVMap
->ConsoleCheck
[Index
];
748 for (Index
= 0; Index
< TerminalMenu
.MenuNumber
; Index
++) {
749 NewMenuEntry
= BOpt_GetMenuEntry (&TerminalMenu
, Index
);
750 NewTerminalContext
= (BM_TERMINAL_CONTEXT
*) NewMenuEntry
->VariableContext
;
751 ASSERT (Index
+ ConsoleErrMenu
.MenuNumber
< MAX_MENU_NUMBER
);
752 NewTerminalContext
->IsStdErr
= CurrentFakeNVMap
->ConsoleCheck
[Index
+ ConsoleErrMenu
.MenuNumber
];
755 Var_UpdateErrorOutOption ();
758 case FORM_DRV_ADD_HANDLE_DESC_ID
:
759 Status
= Var_UpdateDriverOption (
761 Private
->BmmHiiHandle
,
762 CurrentFakeNVMap
->DriverAddHandleDesc
,
763 CurrentFakeNVMap
->DriverAddHandleOptionalData
,
764 CurrentFakeNVMap
->DriverAddForceReconnect
766 if (EFI_ERROR (Status
)) {
770 BOpt_GetDriverOptions (Private
);
771 CreateMenuStringToken (Private
, Private
->BmmHiiHandle
, &DriverOptionMenu
);
783 Discard all changes done to the BMM pages such as Boot Order change,
786 @param Private The BMM context data.
787 @param CurrentFakeNVMap The current Fack NV Map.
791 DiscardChangeHandler (
792 IN BMM_CALLBACK_DATA
*Private
,
793 IN BMM_FAKE_NV_DATA
*CurrentFakeNVMap
798 switch (Private
->BmmPreviousPageId
) {
799 case FORM_BOOT_CHG_ID
:
800 case FORM_DRV_CHG_ID
:
801 CopyMem (CurrentFakeNVMap
->OptionOrder
, Private
->BmmOldFakeNVData
.OptionOrder
, 100);
804 case FORM_BOOT_DEL_ID
:
805 ASSERT (BootOptionMenu
.MenuNumber
<= (sizeof (CurrentFakeNVMap
->BootOptionDel
) / sizeof (CurrentFakeNVMap
->BootOptionDel
[0])));
806 for (Index
= 0; Index
< BootOptionMenu
.MenuNumber
; Index
++) {
807 CurrentFakeNVMap
->BootOptionDel
[Index
] = 0x00;
811 case FORM_DRV_DEL_ID
:
812 ASSERT (DriverOptionMenu
.MenuNumber
<= (sizeof (CurrentFakeNVMap
->DriverOptionDel
) / sizeof (CurrentFakeNVMap
->DriverOptionDel
[0])));
813 for (Index
= 0; Index
< DriverOptionMenu
.MenuNumber
; Index
++) {
814 CurrentFakeNVMap
->DriverOptionDel
[Index
] = 0x00;
818 case FORM_BOOT_NEXT_ID
:
819 CurrentFakeNVMap
->BootNext
= Private
->BmmOldFakeNVData
.BootNext
;
822 case FORM_TIME_OUT_ID
:
823 CurrentFakeNVMap
->BootTimeOut
= Private
->BmmOldFakeNVData
.BootTimeOut
;
826 case FORM_DRV_ADD_HANDLE_DESC_ID
:
827 case FORM_DRV_ADD_FILE_ID
:
828 case FORM_DRV_ADD_HANDLE_ID
:
829 CurrentFakeNVMap
->DriverAddHandleDesc
[0] = 0x0000;
830 CurrentFakeNVMap
->DriverAddHandleOptionalData
[0] = 0x0000;
839 Initialize the Boot Maintenance Utitliy.
842 @retval EFI_SUCCESS utility ended successfully
843 @retval others contain some errors
851 EFI_LEGACY_BIOS_PROTOCOL
*LegacyBios
;
852 BMM_CALLBACK_DATA
*BmmCallbackInfo
;
856 Status
= EFI_SUCCESS
;
859 // Create CallbackData structures for Driver Callback
861 BmmCallbackInfo
= AllocateZeroPool (sizeof (BMM_CALLBACK_DATA
));
862 if (BmmCallbackInfo
== NULL
) {
863 return EFI_OUT_OF_RESOURCES
;
867 // Create LoadOption in BmmCallbackInfo for Driver Callback
869 Ptr
= AllocateZeroPool (sizeof (BM_LOAD_CONTEXT
) + sizeof (BM_FILE_CONTEXT
) + sizeof (BM_HANDLE_CONTEXT
) + sizeof (BM_MENU_ENTRY
));
871 FreePool (BmmCallbackInfo
);
872 return EFI_OUT_OF_RESOURCES
;
876 // Initialize Bmm callback data.
878 BmmCallbackInfo
->LoadContext
= (BM_LOAD_CONTEXT
*) Ptr
;
879 Ptr
+= sizeof (BM_LOAD_CONTEXT
);
881 BmmCallbackInfo
->FileContext
= (BM_FILE_CONTEXT
*) Ptr
;
882 Ptr
+= sizeof (BM_FILE_CONTEXT
);
884 BmmCallbackInfo
->HandleContext
= (BM_HANDLE_CONTEXT
*) Ptr
;
885 Ptr
+= sizeof (BM_HANDLE_CONTEXT
);
887 BmmCallbackInfo
->MenuEntry
= (BM_MENU_ENTRY
*) Ptr
;
889 BmmCallbackInfo
->Signature
= BMM_CALLBACK_DATA_SIGNATURE
;
890 BmmCallbackInfo
->BmmConfigAccess
.ExtractConfig
= BootMaintExtractConfig
;
891 BmmCallbackInfo
->BmmConfigAccess
.RouteConfig
= FakeRouteConfig
;
892 BmmCallbackInfo
->BmmConfigAccess
.Callback
= BootMaintCallback
;
893 BmmCallbackInfo
->BmmPreviousPageId
= FORM_MAIN_ID
;
894 BmmCallbackInfo
->BmmCurrentPageId
= FORM_MAIN_ID
;
895 BmmCallbackInfo
->FeConfigAccess
.ExtractConfig
= FakeExtractConfig
;
896 BmmCallbackInfo
->FeConfigAccess
.RouteConfig
= FakeRouteConfig
;
897 BmmCallbackInfo
->FeConfigAccess
.Callback
= FileExplorerCallback
;
898 BmmCallbackInfo
->FeCurrentState
= FileExplorerStateInActive
;
899 BmmCallbackInfo
->FeDisplayContext
= FileExplorerDisplayUnknown
;
902 // Install Device Path Protocol and Config Access protocol to driver handle
904 Status
= gBS
->InstallMultipleProtocolInterfaces (
905 &BmmCallbackInfo
->BmmDriverHandle
,
906 &gEfiDevicePathProtocolGuid
,
907 &mBmmHiiVendorDevicePath
,
908 &gEfiHiiConfigAccessProtocolGuid
,
909 &BmmCallbackInfo
->BmmConfigAccess
,
912 if (EFI_ERROR (Status
)) {
917 // Install Device Path Protocol and Config Access protocol to driver handle
919 Status
= gBS
->InstallMultipleProtocolInterfaces (
920 &BmmCallbackInfo
->FeDriverHandle
,
921 &gEfiDevicePathProtocolGuid
,
922 &mFeHiiVendorDevicePath
,
923 &gEfiHiiConfigAccessProtocolGuid
,
924 &BmmCallbackInfo
->FeConfigAccess
,
927 if (EFI_ERROR (Status
)) {
932 // Post our Boot Maint VFR binnary to the HII database.
934 BmmCallbackInfo
->BmmHiiHandle
= HiiAddPackages (
936 BmmCallbackInfo
->BmmDriverHandle
,
941 ASSERT (BmmCallbackInfo
->BmmHiiHandle
!= NULL
);
944 // Post our File Explorer VFR binary to the HII database.
946 BmmCallbackInfo
->FeHiiHandle
= HiiAddPackages (
948 BmmCallbackInfo
->FeDriverHandle
,
953 ASSERT (BmmCallbackInfo
->FeHiiHandle
!= NULL
);
956 // Init OpCode Handle and Allocate space for creation of Buffer
958 mStartOpCodeHandle
= HiiAllocateOpCodeHandle ();
959 if (mStartOpCodeHandle
== NULL
) {
960 Status
= EFI_OUT_OF_RESOURCES
;
964 mEndOpCodeHandle
= HiiAllocateOpCodeHandle ();
965 if (mEndOpCodeHandle
== NULL
) {
966 Status
= EFI_OUT_OF_RESOURCES
;
971 // Create Hii Extend Label OpCode as the start opcode
973 mStartLabel
= (EFI_IFR_GUID_LABEL
*) HiiCreateGuidOpCode (mStartOpCodeHandle
, &gEfiIfrTianoGuid
, NULL
, sizeof (EFI_IFR_GUID_LABEL
));
974 mStartLabel
->ExtendOpCode
= EFI_IFR_EXTEND_OP_LABEL
;
977 // Create Hii Extend Label OpCode as the end opcode
979 mEndLabel
= (EFI_IFR_GUID_LABEL
*) HiiCreateGuidOpCode (mEndOpCodeHandle
, &gEfiIfrTianoGuid
, NULL
, sizeof (EFI_IFR_GUID_LABEL
));
980 mEndLabel
->ExtendOpCode
= EFI_IFR_EXTEND_OP_LABEL
;
981 mEndLabel
->Number
= LABEL_END
;
983 InitializeStringDepository ();
985 InitAllMenu (BmmCallbackInfo
);
987 CreateMenuStringToken (BmmCallbackInfo
, BmmCallbackInfo
->BmmHiiHandle
, &ConsoleInpMenu
);
988 CreateMenuStringToken (BmmCallbackInfo
, BmmCallbackInfo
->BmmHiiHandle
, &ConsoleOutMenu
);
989 CreateMenuStringToken (BmmCallbackInfo
, BmmCallbackInfo
->BmmHiiHandle
, &ConsoleErrMenu
);
990 CreateMenuStringToken (BmmCallbackInfo
, BmmCallbackInfo
->BmmHiiHandle
, &BootOptionMenu
);
991 CreateMenuStringToken (BmmCallbackInfo
, BmmCallbackInfo
->BmmHiiHandle
, &DriverOptionMenu
);
992 CreateMenuStringToken (BmmCallbackInfo
, BmmCallbackInfo
->BmmHiiHandle
, &TerminalMenu
);
993 CreateMenuStringToken (BmmCallbackInfo
, BmmCallbackInfo
->BmmHiiHandle
, &DriverMenu
);
995 UpdateBootDelPage (BmmCallbackInfo
);
996 UpdateDrvDelPage (BmmCallbackInfo
);
998 if (TerminalMenu
.MenuNumber
> 0) {
999 BmmCallbackInfo
->CurrentTerminal
= 0;
1000 UpdateTerminalPage (BmmCallbackInfo
);
1003 Status
= EfiLibLocateProtocol (&gEfiLegacyBiosProtocolGuid
, (VOID
**) &LegacyBios
);
1004 if (!EFI_ERROR (Status
)) {
1005 RefreshUpdateData ();
1006 mStartLabel
->Number
= FORM_BOOT_LEGACY_DEVICE_ID
;
1009 // If LegacyBios Protocol is installed, add 3 tags about legacy boot option
1010 // in BootOption form: legacy FD/HD/CD/NET/BEV
1012 HiiCreateGotoOpCode (
1014 FORM_SET_FD_ORDER_ID
,
1015 STRING_TOKEN (STR_FORM_SET_FD_ORDER_TITLE
),
1016 STRING_TOKEN (STR_FORM_SET_FD_ORDER_TITLE
),
1017 EFI_IFR_FLAG_CALLBACK
,
1018 FORM_SET_FD_ORDER_ID
1021 HiiCreateGotoOpCode (
1023 FORM_SET_HD_ORDER_ID
,
1024 STRING_TOKEN (STR_FORM_SET_HD_ORDER_TITLE
),
1025 STRING_TOKEN (STR_FORM_SET_HD_ORDER_TITLE
),
1026 EFI_IFR_FLAG_CALLBACK
,
1027 FORM_SET_HD_ORDER_ID
1030 HiiCreateGotoOpCode (
1032 FORM_SET_CD_ORDER_ID
,
1033 STRING_TOKEN (STR_FORM_SET_CD_ORDER_TITLE
),
1034 STRING_TOKEN (STR_FORM_SET_CD_ORDER_TITLE
),
1035 EFI_IFR_FLAG_CALLBACK
,
1036 FORM_SET_CD_ORDER_ID
1039 HiiCreateGotoOpCode (
1041 FORM_SET_NET_ORDER_ID
,
1042 STRING_TOKEN (STR_FORM_SET_NET_ORDER_TITLE
),
1043 STRING_TOKEN (STR_FORM_SET_NET_ORDER_TITLE
),
1044 EFI_IFR_FLAG_CALLBACK
,
1045 FORM_SET_NET_ORDER_ID
1048 HiiCreateGotoOpCode (
1050 FORM_SET_BEV_ORDER_ID
,
1051 STRING_TOKEN (STR_FORM_SET_BEV_ORDER_TITLE
),
1052 STRING_TOKEN (STR_FORM_SET_BEV_ORDER_TITLE
),
1053 EFI_IFR_FLAG_CALLBACK
,
1054 FORM_SET_BEV_ORDER_ID
1058 BmmCallbackInfo
->BmmHiiHandle
,
1061 mStartOpCodeHandle
, // Label FORM_BOOT_LEGACY_DEVICE_ID
1062 mEndOpCodeHandle
// LABEL_END
1067 // Dispatch BMM main formset and File Explorer formset.
1069 FormSetDispatcher (BmmCallbackInfo
);
1072 // Remove our IFR data from HII database
1074 HiiRemovePackages (BmmCallbackInfo
->BmmHiiHandle
);
1075 HiiRemovePackages (BmmCallbackInfo
->FeHiiHandle
);
1077 CleanUpStringDepository ();
1082 if (mStartOpCodeHandle
!= NULL
) {
1083 HiiFreeOpCodeHandle (mStartOpCodeHandle
);
1086 if (mEndOpCodeHandle
!= NULL
) {
1087 HiiFreeOpCodeHandle (mEndOpCodeHandle
);
1090 if (BmmCallbackInfo
->FeDriverHandle
!= NULL
) {
1091 gBS
->UninstallMultipleProtocolInterfaces (
1092 BmmCallbackInfo
->FeDriverHandle
,
1093 &gEfiDevicePathProtocolGuid
,
1094 &mFeHiiVendorDevicePath
,
1095 &gEfiHiiConfigAccessProtocolGuid
,
1096 &BmmCallbackInfo
->FeConfigAccess
,
1101 if (BmmCallbackInfo
->BmmDriverHandle
!= NULL
) {
1102 gBS
->UninstallMultipleProtocolInterfaces (
1103 BmmCallbackInfo
->BmmDriverHandle
,
1104 &gEfiDevicePathProtocolGuid
,
1105 &mBmmHiiVendorDevicePath
,
1106 &gEfiHiiConfigAccessProtocolGuid
,
1107 &BmmCallbackInfo
->BmmConfigAccess
,
1112 FreePool (BmmCallbackInfo
->LoadContext
);
1113 FreePool (BmmCallbackInfo
);
1119 Initialized all Menu Option List.
1121 @param CallbackData The BMM context data.
1126 IN BMM_CALLBACK_DATA
*CallbackData
1129 InitializeListHead (&BootOptionMenu
.Head
);
1130 InitializeListHead (&DriverOptionMenu
.Head
);
1131 BOpt_GetBootOptions (CallbackData
);
1132 BOpt_GetDriverOptions (CallbackData
);
1133 BOpt_GetLegacyOptions ();
1134 InitializeListHead (&FsOptionMenu
.Head
);
1135 BOpt_FindDrivers ();
1136 InitializeListHead (&DirectoryMenu
.Head
);
1137 InitializeListHead (&ConsoleInpMenu
.Head
);
1138 InitializeListHead (&ConsoleOutMenu
.Head
);
1139 InitializeListHead (&ConsoleErrMenu
.Head
);
1140 InitializeListHead (&TerminalMenu
.Head
);
1146 Free up all Menu Option list.
1154 BOpt_FreeMenu (&DirectoryMenu
);
1155 BOpt_FreeMenu (&FsOptionMenu
);
1156 BOpt_FreeMenu (&BootOptionMenu
);
1157 BOpt_FreeMenu (&DriverOptionMenu
);
1158 BOpt_FreeMenu (&DriverMenu
);
1159 BOpt_FreeLegacyOptions ();
1164 Intialize all the string depositories.
1168 InitializeStringDepository (
1172 STRING_DEPOSITORY
*StringDepository
;
1173 StringDepository
= AllocateZeroPool (sizeof (STRING_DEPOSITORY
) * STRING_DEPOSITORY_NUMBER
);
1174 FileOptionStrDepository
= StringDepository
++;
1175 ConsoleOptionStrDepository
= StringDepository
++;
1176 BootOptionStrDepository
= StringDepository
++;
1177 BootOptionHelpStrDepository
= StringDepository
++;
1178 DriverOptionStrDepository
= StringDepository
++;
1179 DriverOptionHelpStrDepository
= StringDepository
++;
1180 TerminalStrDepository
= StringDepository
;
1184 Fetch a usable string node from the string depository and return the string token.
1186 @param CallbackData The BMM context data.
1187 @param StringDepository The string repository.
1189 @retval EFI_STRING_ID String token.
1193 GetStringTokenFromDepository (
1194 IN BMM_CALLBACK_DATA
*CallbackData
,
1195 IN STRING_DEPOSITORY
*StringDepository
1198 STRING_LIST_NODE
*CurrentListNode
;
1199 STRING_LIST_NODE
*NextListNode
;
1201 CurrentListNode
= StringDepository
->CurrentNode
;
1203 if ((NULL
!= CurrentListNode
) && (NULL
!= CurrentListNode
->Next
)) {
1205 // Fetch one reclaimed node from the list.
1207 NextListNode
= StringDepository
->CurrentNode
->Next
;
1210 // If there is no usable node in the list, update the list.
1212 NextListNode
= AllocateZeroPool (sizeof (STRING_LIST_NODE
));
1213 ASSERT (NextListNode
!= NULL
);
1214 NextListNode
->StringToken
= HiiSetString (CallbackData
->BmmHiiHandle
, 0, L
" ", NULL
);
1215 ASSERT (NextListNode
->StringToken
!= 0);
1217 StringDepository
->TotalNodeNumber
++;
1219 if (NULL
== CurrentListNode
) {
1220 StringDepository
->ListHead
= NextListNode
;
1222 CurrentListNode
->Next
= NextListNode
;
1226 StringDepository
->CurrentNode
= NextListNode
;
1228 return StringDepository
->CurrentNode
->StringToken
;
1232 Reclaim string depositories by moving the current node pointer to list head..
1236 ReclaimStringDepository (
1240 UINTN DepositoryIndex
;
1241 STRING_DEPOSITORY
*StringDepository
;
1243 StringDepository
= FileOptionStrDepository
;
1244 for (DepositoryIndex
= 0; DepositoryIndex
< STRING_DEPOSITORY_NUMBER
; DepositoryIndex
++) {
1245 StringDepository
->CurrentNode
= StringDepository
->ListHead
;
1251 Release resource for all the string depositories.
1255 CleanUpStringDepository (
1260 UINTN DepositoryIndex
;
1261 STRING_LIST_NODE
*CurrentListNode
;
1262 STRING_LIST_NODE
*NextListNode
;
1263 STRING_DEPOSITORY
*StringDepository
;
1266 // Release string list nodes.
1268 StringDepository
= FileOptionStrDepository
;
1269 for (DepositoryIndex
= 0; DepositoryIndex
< STRING_DEPOSITORY_NUMBER
; DepositoryIndex
++) {
1270 CurrentListNode
= StringDepository
->ListHead
;
1271 for (NodeIndex
= 0; NodeIndex
< StringDepository
->TotalNodeNumber
; NodeIndex
++) {
1272 NextListNode
= CurrentListNode
->Next
;
1273 FreePool (CurrentListNode
);
1274 CurrentListNode
= NextListNode
;
1280 // Release string depository.
1282 FreePool (FileOptionStrDepository
);
1286 Start boot maintenance manager
1288 @retval EFI_SUCCESS If BMM is invoked successfully.
1289 @return Other value if BMM return unsuccessfully.
1298 LIST_ENTRY BdsBootOptionList
;
1300 InitializeListHead (&BdsBootOptionList
);
1303 // Connect all prior to entering the platform setup menu.
1305 if (!gConnectAllHappened
) {
1306 BdsLibConnectAllDriversToAllControllers ();
1307 gConnectAllHappened
= TRUE
;
1310 // Have chance to enumerate boot device
1312 BdsLibEnumerateAllBootOption (&BdsBootOptionList
);
1317 Status
= InitializeBM ();
1323 Dispatch BMM formset and FileExplorer formset.
1326 @param CallbackData The BMM context data.
1328 @retval EFI_SUCCESS If function complete successfully.
1329 @return Other value if the Setup Browser process BMM's pages and
1330 return unsuccessfully.
1335 IN BMM_CALLBACK_DATA
*CallbackData
1339 EFI_BROWSER_ACTION_REQUEST ActionRequest
;
1342 UpdatePageId (CallbackData
, FORM_MAIN_ID
);
1344 ActionRequest
= EFI_BROWSER_ACTION_REQUEST_NONE
;
1345 Status
= gFormBrowser2
->SendForm (
1347 &CallbackData
->BmmHiiHandle
,
1354 if (ActionRequest
== EFI_BROWSER_ACTION_REQUEST_RESET
) {
1355 EnableResetRequired ();
1358 ReclaimStringDepository ();
1361 // When this Formset returns, check if we are going to explore files.
1363 if (FileExplorerStateInActive
!= CallbackData
->FeCurrentState
) {
1364 UpdateFileExplorer (CallbackData
, 0);
1366 ActionRequest
= EFI_BROWSER_ACTION_REQUEST_NONE
;
1367 Status
= gFormBrowser2
->SendForm (
1369 &CallbackData
->FeHiiHandle
,
1376 if (ActionRequest
== EFI_BROWSER_ACTION_REQUEST_RESET
) {
1377 EnableResetRequired ();
1380 CallbackData
->FeCurrentState
= FileExplorerStateInActive
;
1381 CallbackData
->FeDisplayContext
= FileExplorerDisplayUnknown
;
1382 ReclaimStringDepository ();
1393 Deletete the Boot Option from EFI Variable. The Boot Order Arrray
1396 @param OptionNumber The number of Boot option want to be deleted.
1397 @param BootOrder The Boot Order array.
1398 @param BootOrderSize The size of the Boot Order Array.
1400 @return Other value if the Boot Option specified by OptionNumber is not deleteed succesfully.
1401 @retval EFI_SUCCESS If function return successfully.
1406 BdsDeleteBootOption (
1407 IN UINTN OptionNumber
,
1408 IN OUT UINT16
*BootOrder
,
1409 IN OUT UINTN
*BootOrderSize
1412 UINT16 BootOption
[100];
1417 Status
= EFI_SUCCESS
;
1420 UnicodeSPrint (BootOption
, sizeof (BootOption
), L
"Boot%04x", OptionNumber
);
1421 Status
= EfiLibDeleteVariable (BootOption
, &gEfiGlobalVariableGuid
);
1424 // adjust boot order array
1426 for (Index
= 0; Index
< *BootOrderSize
/ sizeof (UINT16
); Index
++) {
1427 if (BootOrder
[Index
] == OptionNumber
) {
1433 if (Index
!= *BootOrderSize
/ sizeof (UINT16
)) {
1434 for (Index
= 0; Index
< *BootOrderSize
/ sizeof (UINT16
) - 1; Index
++) {
1435 if (Index
>= Index2Del
) {
1436 BootOrder
[Index
] = BootOrder
[Index
+ 1];
1440 *BootOrderSize
-= sizeof (UINT16
);