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
:
628 ASSERT (BootOptionMenu
.MenuNumber
<= (sizeof (CurrentFakeNVMap
->BootOptionDel
) / sizeof (UINT8
)));
629 for (Index
= 0; Index
< BootOptionMenu
.MenuNumber
; Index
++) {
630 NewMenuEntry
= BOpt_GetMenuEntry (&BootOptionMenu
, Index
);
631 NewLoadContext
= (BM_LOAD_CONTEXT
*) NewMenuEntry
->VariableContext
;
632 NewLoadContext
->Deleted
= CurrentFakeNVMap
->BootOptionDel
[Index
];
635 Var_DelBootOption ();
638 case FORM_DRV_DEL_ID
:
639 ASSERT (DriverOptionMenu
.MenuNumber
<= (sizeof (CurrentFakeNVMap
->DriverOptionDel
) / sizeof (UINT8
)));
640 for (Index
= 0; Index
< DriverOptionMenu
.MenuNumber
; Index
++) {
641 NewMenuEntry
= BOpt_GetMenuEntry (&DriverOptionMenu
, Index
);
642 NewLoadContext
= (BM_LOAD_CONTEXT
*) NewMenuEntry
->VariableContext
;
643 NewLoadContext
->Deleted
= CurrentFakeNVMap
->DriverOptionDel
[Index
];
646 Var_DelDriverOption ();
649 case FORM_BOOT_CHG_ID
:
650 Status
= Var_UpdateBootOrder (Private
);
653 case FORM_DRV_CHG_ID
:
654 Status
= Var_UpdateDriverOrder (Private
);
657 case FORM_TIME_OUT_ID
:
658 PcdSet16 (PcdPlatformBootTimeOut
, CurrentFakeNVMap
->BootTimeOut
);
660 Private
->BmmOldFakeNVData
.BootTimeOut
= CurrentFakeNVMap
->BootTimeOut
;
663 case FORM_BOOT_NEXT_ID
:
664 Status
= Var_UpdateBootNext (Private
);
667 case FORM_CON_MODE_ID
:
668 Status
= Var_UpdateConMode (Private
);
671 case FORM_CON_COM_SETUP_ID
:
672 NewMenuEntry
= BOpt_GetMenuEntry (&TerminalMenu
, Private
->CurrentTerminal
);
674 ASSERT (NewMenuEntry
!= NULL
);
676 NewTerminalContext
= (BM_TERMINAL_CONTEXT
*) NewMenuEntry
->VariableContext
;
678 NewTerminalContext
->BaudRateIndex
= CurrentFakeNVMap
->COMBaudRate
;
679 ASSERT (CurrentFakeNVMap
->COMBaudRate
< (sizeof (BaudRateList
) / sizeof (BaudRateList
[0])));
680 NewTerminalContext
->BaudRate
= BaudRateList
[CurrentFakeNVMap
->COMBaudRate
].Value
;
681 NewTerminalContext
->DataBitsIndex
= CurrentFakeNVMap
->COMDataRate
;
682 ASSERT (CurrentFakeNVMap
->COMDataRate
< (sizeof (DataBitsList
) / sizeof (DataBitsList
[0])));
683 NewTerminalContext
->DataBits
= (UINT8
) DataBitsList
[CurrentFakeNVMap
->COMDataRate
].Value
;
684 NewTerminalContext
->StopBitsIndex
= CurrentFakeNVMap
->COMStopBits
;
685 ASSERT (CurrentFakeNVMap
->COMStopBits
< (sizeof (StopBitsList
) / sizeof (StopBitsList
[0])));
686 NewTerminalContext
->StopBits
= (UINT8
) StopBitsList
[CurrentFakeNVMap
->COMStopBits
].Value
;
687 NewTerminalContext
->ParityIndex
= CurrentFakeNVMap
->COMParity
;
688 ASSERT (CurrentFakeNVMap
->COMParity
< (sizeof (ParityList
) / sizeof (ParityList
[0])));
689 NewTerminalContext
->Parity
= (UINT8
) ParityList
[CurrentFakeNVMap
->COMParity
].Value
;
690 NewTerminalContext
->TerminalType
= CurrentFakeNVMap
->COMTerminalType
;
692 ChangeTerminalDevicePath (
693 NewTerminalContext
->DevicePath
,
697 Var_UpdateConsoleInpOption ();
698 Var_UpdateConsoleOutOption ();
699 Var_UpdateErrorOutOption ();
703 ASSERT ((ConsoleInpMenu
.MenuNumber
+ TerminalMenu
.MenuNumber
) <= (sizeof (CurrentFakeNVMap
->ConsoleCheck
) / sizeof (UINT8
)));
704 for (Index
= 0; Index
< ConsoleInpMenu
.MenuNumber
; Index
++) {
705 NewMenuEntry
= BOpt_GetMenuEntry (&ConsoleInpMenu
, Index
);
706 NewConsoleContext
= (BM_CONSOLE_CONTEXT
*) NewMenuEntry
->VariableContext
;
707 NewConsoleContext
->IsActive
= CurrentFakeNVMap
->ConsoleCheck
[Index
];
710 for (Index
= 0; Index
< TerminalMenu
.MenuNumber
; Index
++) {
711 NewMenuEntry
= BOpt_GetMenuEntry (&TerminalMenu
, Index
);
712 NewTerminalContext
= (BM_TERMINAL_CONTEXT
*) NewMenuEntry
->VariableContext
;
713 NewTerminalContext
->IsConIn
= CurrentFakeNVMap
->ConsoleCheck
[Index
+ ConsoleInpMenu
.MenuNumber
];
716 Var_UpdateConsoleInpOption ();
719 case FORM_CON_OUT_ID
:
720 ASSERT ((ConsoleOutMenu
.MenuNumber
+ TerminalMenu
.MenuNumber
) <= (sizeof (CurrentFakeNVMap
->ConsoleCheck
) / sizeof (UINT8
)));
721 for (Index
= 0; Index
< ConsoleOutMenu
.MenuNumber
; Index
++) {
722 NewMenuEntry
= BOpt_GetMenuEntry (&ConsoleOutMenu
, Index
);
723 NewConsoleContext
= (BM_CONSOLE_CONTEXT
*) NewMenuEntry
->VariableContext
;
724 NewConsoleContext
->IsActive
= CurrentFakeNVMap
->ConsoleCheck
[Index
];
727 for (Index
= 0; Index
< TerminalMenu
.MenuNumber
; Index
++) {
728 NewMenuEntry
= BOpt_GetMenuEntry (&TerminalMenu
, Index
);
729 NewTerminalContext
= (BM_TERMINAL_CONTEXT
*) NewMenuEntry
->VariableContext
;
730 NewTerminalContext
->IsConOut
= CurrentFakeNVMap
->ConsoleCheck
[Index
+ ConsoleOutMenu
.MenuNumber
];
733 Var_UpdateConsoleOutOption ();
736 case FORM_CON_ERR_ID
:
737 ASSERT ((ConsoleErrMenu
.MenuNumber
+ TerminalMenu
.MenuNumber
) <= (sizeof (CurrentFakeNVMap
->ConsoleCheck
) / sizeof (UINT8
)));
738 for (Index
= 0; Index
< ConsoleErrMenu
.MenuNumber
; Index
++) {
739 NewMenuEntry
= BOpt_GetMenuEntry (&ConsoleErrMenu
, Index
);
740 NewConsoleContext
= (BM_CONSOLE_CONTEXT
*) NewMenuEntry
->VariableContext
;
741 NewConsoleContext
->IsActive
= CurrentFakeNVMap
->ConsoleCheck
[Index
];
744 for (Index
= 0; Index
< TerminalMenu
.MenuNumber
; Index
++) {
745 NewMenuEntry
= BOpt_GetMenuEntry (&TerminalMenu
, Index
);
746 NewTerminalContext
= (BM_TERMINAL_CONTEXT
*) NewMenuEntry
->VariableContext
;
747 NewTerminalContext
->IsStdErr
= CurrentFakeNVMap
->ConsoleCheck
[Index
+ ConsoleErrMenu
.MenuNumber
];
750 Var_UpdateErrorOutOption ();
753 case FORM_DRV_ADD_HANDLE_DESC_ID
:
754 Status
= Var_UpdateDriverOption (
756 Private
->BmmHiiHandle
,
757 CurrentFakeNVMap
->DriverAddHandleDesc
,
758 CurrentFakeNVMap
->DriverAddHandleOptionalData
,
759 CurrentFakeNVMap
->DriverAddForceReconnect
761 if (EFI_ERROR (Status
)) {
765 BOpt_GetDriverOptions (Private
);
766 CreateMenuStringToken (Private
, Private
->BmmHiiHandle
, &DriverOptionMenu
);
778 Discard all changes done to the BMM pages such as Boot Order change,
781 @param Private The BMM context data.
782 @param CurrentFakeNVMap The current Fack NV Map.
786 DiscardChangeHandler (
787 IN BMM_CALLBACK_DATA
*Private
,
788 IN BMM_FAKE_NV_DATA
*CurrentFakeNVMap
793 switch (Private
->BmmPreviousPageId
) {
794 case FORM_BOOT_CHG_ID
:
795 case FORM_DRV_CHG_ID
:
796 CopyMem (CurrentFakeNVMap
->OptionOrder
, Private
->BmmOldFakeNVData
.OptionOrder
, 100);
799 case FORM_BOOT_DEL_ID
:
800 ASSERT (BootOptionMenu
.MenuNumber
<= (sizeof (CurrentFakeNVMap
->BootOptionDel
) / sizeof (CurrentFakeNVMap
->BootOptionDel
[0])));
801 for (Index
= 0; Index
< BootOptionMenu
.MenuNumber
; Index
++) {
802 CurrentFakeNVMap
->BootOptionDel
[Index
] = 0x00;
806 case FORM_DRV_DEL_ID
:
807 ASSERT (DriverOptionMenu
.MenuNumber
<= (sizeof (CurrentFakeNVMap
->DriverOptionDel
) / sizeof (CurrentFakeNVMap
->DriverOptionDel
[0])));
808 for (Index
= 0; Index
< DriverOptionMenu
.MenuNumber
; Index
++) {
809 CurrentFakeNVMap
->DriverOptionDel
[Index
] = 0x00;
813 case FORM_BOOT_NEXT_ID
:
814 CurrentFakeNVMap
->BootNext
= Private
->BmmOldFakeNVData
.BootNext
;
817 case FORM_TIME_OUT_ID
:
818 CurrentFakeNVMap
->BootTimeOut
= Private
->BmmOldFakeNVData
.BootTimeOut
;
821 case FORM_DRV_ADD_HANDLE_DESC_ID
:
822 case FORM_DRV_ADD_FILE_ID
:
823 case FORM_DRV_ADD_HANDLE_ID
:
824 CurrentFakeNVMap
->DriverAddHandleDesc
[0] = 0x0000;
825 CurrentFakeNVMap
->DriverAddHandleOptionalData
[0] = 0x0000;
834 Initialize the Boot Maintenance Utitliy.
837 @retval EFI_SUCCESS utility ended successfully
838 @retval others contain some errors
846 EFI_LEGACY_BIOS_PROTOCOL
*LegacyBios
;
847 BMM_CALLBACK_DATA
*BmmCallbackInfo
;
851 Status
= EFI_SUCCESS
;
854 // Create CallbackData structures for Driver Callback
856 BmmCallbackInfo
= AllocateZeroPool (sizeof (BMM_CALLBACK_DATA
));
857 if (BmmCallbackInfo
== NULL
) {
858 return EFI_OUT_OF_RESOURCES
;
862 // Create LoadOption in BmmCallbackInfo for Driver Callback
864 Ptr
= AllocateZeroPool (sizeof (BM_LOAD_CONTEXT
) + sizeof (BM_FILE_CONTEXT
) + sizeof (BM_HANDLE_CONTEXT
) + sizeof (BM_MENU_ENTRY
));
866 FreePool (BmmCallbackInfo
);
867 return EFI_OUT_OF_RESOURCES
;
871 // Initialize Bmm callback data.
873 BmmCallbackInfo
->LoadContext
= (BM_LOAD_CONTEXT
*) Ptr
;
874 Ptr
+= sizeof (BM_LOAD_CONTEXT
);
876 BmmCallbackInfo
->FileContext
= (BM_FILE_CONTEXT
*) Ptr
;
877 Ptr
+= sizeof (BM_FILE_CONTEXT
);
879 BmmCallbackInfo
->HandleContext
= (BM_HANDLE_CONTEXT
*) Ptr
;
880 Ptr
+= sizeof (BM_HANDLE_CONTEXT
);
882 BmmCallbackInfo
->MenuEntry
= (BM_MENU_ENTRY
*) Ptr
;
884 BmmCallbackInfo
->Signature
= BMM_CALLBACK_DATA_SIGNATURE
;
885 BmmCallbackInfo
->BmmConfigAccess
.ExtractConfig
= BootMaintExtractConfig
;
886 BmmCallbackInfo
->BmmConfigAccess
.RouteConfig
= FakeRouteConfig
;
887 BmmCallbackInfo
->BmmConfigAccess
.Callback
= BootMaintCallback
;
888 BmmCallbackInfo
->BmmPreviousPageId
= FORM_MAIN_ID
;
889 BmmCallbackInfo
->BmmCurrentPageId
= FORM_MAIN_ID
;
890 BmmCallbackInfo
->FeConfigAccess
.ExtractConfig
= FakeExtractConfig
;
891 BmmCallbackInfo
->FeConfigAccess
.RouteConfig
= FakeRouteConfig
;
892 BmmCallbackInfo
->FeConfigAccess
.Callback
= FileExplorerCallback
;
893 BmmCallbackInfo
->FeCurrentState
= FileExplorerStateInActive
;
894 BmmCallbackInfo
->FeDisplayContext
= FileExplorerDisplayUnknown
;
897 // Install Device Path Protocol and Config Access protocol to driver handle
899 Status
= gBS
->InstallMultipleProtocolInterfaces (
900 &BmmCallbackInfo
->BmmDriverHandle
,
901 &gEfiDevicePathProtocolGuid
,
902 &mBmmHiiVendorDevicePath
,
903 &gEfiHiiConfigAccessProtocolGuid
,
904 &BmmCallbackInfo
->BmmConfigAccess
,
907 if (EFI_ERROR (Status
)) {
912 // Install Device Path Protocol and Config Access protocol to driver handle
914 Status
= gBS
->InstallMultipleProtocolInterfaces (
915 &BmmCallbackInfo
->FeDriverHandle
,
916 &gEfiDevicePathProtocolGuid
,
917 &mFeHiiVendorDevicePath
,
918 &gEfiHiiConfigAccessProtocolGuid
,
919 &BmmCallbackInfo
->FeConfigAccess
,
922 if (EFI_ERROR (Status
)) {
927 // Post our Boot Maint VFR binnary to the HII database.
929 BmmCallbackInfo
->BmmHiiHandle
= HiiAddPackages (
931 BmmCallbackInfo
->BmmDriverHandle
,
936 ASSERT (BmmCallbackInfo
->BmmHiiHandle
!= NULL
);
939 // Post our File Explorer VFR binary to the HII database.
941 BmmCallbackInfo
->FeHiiHandle
= HiiAddPackages (
943 BmmCallbackInfo
->FeDriverHandle
,
948 ASSERT (BmmCallbackInfo
->FeHiiHandle
!= NULL
);
951 // Init OpCode Handle and Allocate space for creation of Buffer
953 mStartOpCodeHandle
= HiiAllocateOpCodeHandle ();
954 if (mStartOpCodeHandle
== NULL
) {
955 Status
= EFI_OUT_OF_RESOURCES
;
959 mEndOpCodeHandle
= HiiAllocateOpCodeHandle ();
960 if (mEndOpCodeHandle
== NULL
) {
961 Status
= EFI_OUT_OF_RESOURCES
;
966 // Create Hii Extend Label OpCode as the start opcode
968 mStartLabel
= (EFI_IFR_GUID_LABEL
*) HiiCreateGuidOpCode (mStartOpCodeHandle
, &gEfiIfrTianoGuid
, NULL
, sizeof (EFI_IFR_GUID_LABEL
));
969 mStartLabel
->ExtendOpCode
= EFI_IFR_EXTEND_OP_LABEL
;
972 // Create Hii Extend Label OpCode as the end opcode
974 mEndLabel
= (EFI_IFR_GUID_LABEL
*) HiiCreateGuidOpCode (mEndOpCodeHandle
, &gEfiIfrTianoGuid
, NULL
, sizeof (EFI_IFR_GUID_LABEL
));
975 mEndLabel
->ExtendOpCode
= EFI_IFR_EXTEND_OP_LABEL
;
976 mEndLabel
->Number
= LABEL_END
;
978 InitializeStringDepository ();
980 InitAllMenu (BmmCallbackInfo
);
982 CreateMenuStringToken (BmmCallbackInfo
, BmmCallbackInfo
->BmmHiiHandle
, &ConsoleInpMenu
);
983 CreateMenuStringToken (BmmCallbackInfo
, BmmCallbackInfo
->BmmHiiHandle
, &ConsoleOutMenu
);
984 CreateMenuStringToken (BmmCallbackInfo
, BmmCallbackInfo
->BmmHiiHandle
, &ConsoleErrMenu
);
985 CreateMenuStringToken (BmmCallbackInfo
, BmmCallbackInfo
->BmmHiiHandle
, &BootOptionMenu
);
986 CreateMenuStringToken (BmmCallbackInfo
, BmmCallbackInfo
->BmmHiiHandle
, &DriverOptionMenu
);
987 CreateMenuStringToken (BmmCallbackInfo
, BmmCallbackInfo
->BmmHiiHandle
, &TerminalMenu
);
988 CreateMenuStringToken (BmmCallbackInfo
, BmmCallbackInfo
->BmmHiiHandle
, &DriverMenu
);
990 UpdateBootDelPage (BmmCallbackInfo
);
991 UpdateDrvDelPage (BmmCallbackInfo
);
993 if (TerminalMenu
.MenuNumber
> 0) {
994 BmmCallbackInfo
->CurrentTerminal
= 0;
995 UpdateTerminalPage (BmmCallbackInfo
);
998 Status
= EfiLibLocateProtocol (&gEfiLegacyBiosProtocolGuid
, (VOID
**) &LegacyBios
);
999 if (!EFI_ERROR (Status
)) {
1000 RefreshUpdateData ();
1001 mStartLabel
->Number
= FORM_BOOT_LEGACY_DEVICE_ID
;
1004 // If LegacyBios Protocol is installed, add 3 tags about legacy boot option
1005 // in BootOption form: legacy FD/HD/CD/NET/BEV
1007 HiiCreateGotoOpCode (
1009 FORM_SET_FD_ORDER_ID
,
1010 STRING_TOKEN (STR_FORM_SET_FD_ORDER_TITLE
),
1011 STRING_TOKEN (STR_FORM_SET_FD_ORDER_TITLE
),
1012 EFI_IFR_FLAG_CALLBACK
,
1013 FORM_SET_FD_ORDER_ID
1016 HiiCreateGotoOpCode (
1018 FORM_SET_HD_ORDER_ID
,
1019 STRING_TOKEN (STR_FORM_SET_HD_ORDER_TITLE
),
1020 STRING_TOKEN (STR_FORM_SET_HD_ORDER_TITLE
),
1021 EFI_IFR_FLAG_CALLBACK
,
1022 FORM_SET_HD_ORDER_ID
1025 HiiCreateGotoOpCode (
1027 FORM_SET_CD_ORDER_ID
,
1028 STRING_TOKEN (STR_FORM_SET_CD_ORDER_TITLE
),
1029 STRING_TOKEN (STR_FORM_SET_CD_ORDER_TITLE
),
1030 EFI_IFR_FLAG_CALLBACK
,
1031 FORM_SET_CD_ORDER_ID
1034 HiiCreateGotoOpCode (
1036 FORM_SET_NET_ORDER_ID
,
1037 STRING_TOKEN (STR_FORM_SET_NET_ORDER_TITLE
),
1038 STRING_TOKEN (STR_FORM_SET_NET_ORDER_TITLE
),
1039 EFI_IFR_FLAG_CALLBACK
,
1040 FORM_SET_NET_ORDER_ID
1043 HiiCreateGotoOpCode (
1045 FORM_SET_BEV_ORDER_ID
,
1046 STRING_TOKEN (STR_FORM_SET_BEV_ORDER_TITLE
),
1047 STRING_TOKEN (STR_FORM_SET_BEV_ORDER_TITLE
),
1048 EFI_IFR_FLAG_CALLBACK
,
1049 FORM_SET_BEV_ORDER_ID
1053 BmmCallbackInfo
->BmmHiiHandle
,
1056 mStartOpCodeHandle
, // Label FORM_BOOT_LEGACY_DEVICE_ID
1057 mEndOpCodeHandle
// LABEL_END
1062 // Dispatch BMM main formset and File Explorer formset.
1064 FormSetDispatcher (BmmCallbackInfo
);
1067 // Remove our IFR data from HII database
1069 HiiRemovePackages (BmmCallbackInfo
->BmmHiiHandle
);
1070 HiiRemovePackages (BmmCallbackInfo
->FeHiiHandle
);
1072 CleanUpStringDepository ();
1077 if (mStartOpCodeHandle
!= NULL
) {
1078 HiiFreeOpCodeHandle (mStartOpCodeHandle
);
1081 if (mEndOpCodeHandle
!= NULL
) {
1082 HiiFreeOpCodeHandle (mEndOpCodeHandle
);
1085 if (BmmCallbackInfo
->FeDriverHandle
!= NULL
) {
1086 gBS
->UninstallMultipleProtocolInterfaces (
1087 BmmCallbackInfo
->FeDriverHandle
,
1088 &gEfiDevicePathProtocolGuid
,
1089 &mFeHiiVendorDevicePath
,
1090 &gEfiHiiConfigAccessProtocolGuid
,
1091 &BmmCallbackInfo
->FeConfigAccess
,
1096 if (BmmCallbackInfo
->BmmDriverHandle
!= NULL
) {
1097 gBS
->UninstallMultipleProtocolInterfaces (
1098 BmmCallbackInfo
->BmmDriverHandle
,
1099 &gEfiDevicePathProtocolGuid
,
1100 &mBmmHiiVendorDevicePath
,
1101 &gEfiHiiConfigAccessProtocolGuid
,
1102 &BmmCallbackInfo
->BmmConfigAccess
,
1107 FreePool (BmmCallbackInfo
->LoadContext
);
1108 FreePool (BmmCallbackInfo
);
1114 Initialized all Menu Option List.
1116 @param CallbackData The BMM context data.
1121 IN BMM_CALLBACK_DATA
*CallbackData
1124 InitializeListHead (&BootOptionMenu
.Head
);
1125 InitializeListHead (&DriverOptionMenu
.Head
);
1126 BOpt_GetBootOptions (CallbackData
);
1127 BOpt_GetDriverOptions (CallbackData
);
1128 BOpt_GetLegacyOptions ();
1129 InitializeListHead (&FsOptionMenu
.Head
);
1130 BOpt_FindDrivers ();
1131 InitializeListHead (&DirectoryMenu
.Head
);
1132 InitializeListHead (&ConsoleInpMenu
.Head
);
1133 InitializeListHead (&ConsoleOutMenu
.Head
);
1134 InitializeListHead (&ConsoleErrMenu
.Head
);
1135 InitializeListHead (&TerminalMenu
.Head
);
1141 Free up all Menu Option list.
1149 BOpt_FreeMenu (&DirectoryMenu
);
1150 BOpt_FreeMenu (&FsOptionMenu
);
1151 BOpt_FreeMenu (&BootOptionMenu
);
1152 BOpt_FreeMenu (&DriverOptionMenu
);
1153 BOpt_FreeMenu (&DriverMenu
);
1154 BOpt_FreeLegacyOptions ();
1159 Intialize all the string depositories.
1163 InitializeStringDepository (
1167 STRING_DEPOSITORY
*StringDepository
;
1168 StringDepository
= AllocateZeroPool (sizeof (STRING_DEPOSITORY
) * STRING_DEPOSITORY_NUMBER
);
1169 FileOptionStrDepository
= StringDepository
++;
1170 ConsoleOptionStrDepository
= StringDepository
++;
1171 BootOptionStrDepository
= StringDepository
++;
1172 BootOptionHelpStrDepository
= StringDepository
++;
1173 DriverOptionStrDepository
= StringDepository
++;
1174 DriverOptionHelpStrDepository
= StringDepository
++;
1175 TerminalStrDepository
= StringDepository
;
1179 Fetch a usable string node from the string depository and return the string token.
1181 @param CallbackData The BMM context data.
1182 @param StringDepository The string repository.
1184 @retval EFI_STRING_ID String token.
1188 GetStringTokenFromDepository (
1189 IN BMM_CALLBACK_DATA
*CallbackData
,
1190 IN STRING_DEPOSITORY
*StringDepository
1193 STRING_LIST_NODE
*CurrentListNode
;
1194 STRING_LIST_NODE
*NextListNode
;
1196 CurrentListNode
= StringDepository
->CurrentNode
;
1198 if ((NULL
!= CurrentListNode
) && (NULL
!= CurrentListNode
->Next
)) {
1200 // Fetch one reclaimed node from the list.
1202 NextListNode
= StringDepository
->CurrentNode
->Next
;
1205 // If there is no usable node in the list, update the list.
1207 NextListNode
= AllocateZeroPool (sizeof (STRING_LIST_NODE
));
1208 ASSERT (NextListNode
!= NULL
);
1209 NextListNode
->StringToken
= HiiSetString (CallbackData
->BmmHiiHandle
, 0, L
" ", NULL
);
1210 ASSERT (NextListNode
->StringToken
!= 0);
1212 StringDepository
->TotalNodeNumber
++;
1214 if (NULL
== CurrentListNode
) {
1215 StringDepository
->ListHead
= NextListNode
;
1217 CurrentListNode
->Next
= NextListNode
;
1221 StringDepository
->CurrentNode
= NextListNode
;
1223 return StringDepository
->CurrentNode
->StringToken
;
1227 Reclaim string depositories by moving the current node pointer to list head..
1231 ReclaimStringDepository (
1235 UINTN DepositoryIndex
;
1236 STRING_DEPOSITORY
*StringDepository
;
1238 StringDepository
= FileOptionStrDepository
;
1239 for (DepositoryIndex
= 0; DepositoryIndex
< STRING_DEPOSITORY_NUMBER
; DepositoryIndex
++) {
1240 StringDepository
->CurrentNode
= StringDepository
->ListHead
;
1246 Release resource for all the string depositories.
1250 CleanUpStringDepository (
1255 UINTN DepositoryIndex
;
1256 STRING_LIST_NODE
*CurrentListNode
;
1257 STRING_LIST_NODE
*NextListNode
;
1258 STRING_DEPOSITORY
*StringDepository
;
1261 // Release string list nodes.
1263 StringDepository
= FileOptionStrDepository
;
1264 for (DepositoryIndex
= 0; DepositoryIndex
< STRING_DEPOSITORY_NUMBER
; DepositoryIndex
++) {
1265 CurrentListNode
= StringDepository
->ListHead
;
1266 for (NodeIndex
= 0; NodeIndex
< StringDepository
->TotalNodeNumber
; NodeIndex
++) {
1267 NextListNode
= CurrentListNode
->Next
;
1268 FreePool (CurrentListNode
);
1269 CurrentListNode
= NextListNode
;
1275 // Release string depository.
1277 FreePool (FileOptionStrDepository
);
1281 Start boot maintenance manager
1283 @retval EFI_SUCCESS If BMM is invoked successfully.
1284 @return Other value if BMM return unsuccessfully.
1293 LIST_ENTRY BdsBootOptionList
;
1295 InitializeListHead (&BdsBootOptionList
);
1298 // Connect all prior to entering the platform setup menu.
1300 if (!gConnectAllHappened
) {
1301 BdsLibConnectAllDriversToAllControllers ();
1302 gConnectAllHappened
= TRUE
;
1305 // Have chance to enumerate boot device
1307 BdsLibEnumerateAllBootOption (&BdsBootOptionList
);
1312 Status
= InitializeBM ();
1318 Dispatch BMM formset and FileExplorer formset.
1321 @param CallbackData The BMM context data.
1323 @retval EFI_SUCCESS If function complete successfully.
1324 @return Other value if the Setup Browser process BMM's pages and
1325 return unsuccessfully.
1330 IN BMM_CALLBACK_DATA
*CallbackData
1334 EFI_BROWSER_ACTION_REQUEST ActionRequest
;
1337 UpdatePageId (CallbackData
, FORM_MAIN_ID
);
1339 ActionRequest
= EFI_BROWSER_ACTION_REQUEST_NONE
;
1340 Status
= gFormBrowser2
->SendForm (
1342 &CallbackData
->BmmHiiHandle
,
1349 if (ActionRequest
== EFI_BROWSER_ACTION_REQUEST_RESET
) {
1350 EnableResetRequired ();
1353 ReclaimStringDepository ();
1356 // When this Formset returns, check if we are going to explore files.
1358 if (FileExplorerStateInActive
!= CallbackData
->FeCurrentState
) {
1359 UpdateFileExplorer (CallbackData
, 0);
1361 ActionRequest
= EFI_BROWSER_ACTION_REQUEST_NONE
;
1362 Status
= gFormBrowser2
->SendForm (
1364 &CallbackData
->FeHiiHandle
,
1371 if (ActionRequest
== EFI_BROWSER_ACTION_REQUEST_RESET
) {
1372 EnableResetRequired ();
1375 CallbackData
->FeCurrentState
= FileExplorerStateInActive
;
1376 CallbackData
->FeDisplayContext
= FileExplorerDisplayUnknown
;
1377 ReclaimStringDepository ();
1388 Deletete the Boot Option from EFI Variable. The Boot Order Arrray
1391 @param OptionNumber The number of Boot option want to be deleted.
1392 @param BootOrder The Boot Order array.
1393 @param BootOrderSize The size of the Boot Order Array.
1395 @return Other value if the Boot Option specified by OptionNumber is not deleteed succesfully.
1396 @retval EFI_SUCCESS If function return successfully.
1401 BdsDeleteBootOption (
1402 IN UINTN OptionNumber
,
1403 IN OUT UINT16
*BootOrder
,
1404 IN OUT UINTN
*BootOrderSize
1407 UINT16 BootOption
[100];
1412 Status
= EFI_SUCCESS
;
1415 UnicodeSPrint (BootOption
, sizeof (BootOption
), L
"Boot%04x", OptionNumber
);
1416 Status
= EfiLibDeleteVariable (BootOption
, &gEfiGlobalVariableGuid
);
1419 // adjust boot order array
1421 for (Index
= 0; Index
< *BootOrderSize
/ sizeof (UINT16
); Index
++) {
1422 if (BootOrder
[Index
] == OptionNumber
) {
1428 if (Index
!= *BootOrderSize
/ sizeof (UINT16
)) {
1429 for (Index
= 0; Index
< *BootOrderSize
/ sizeof (UINT16
) - 1; Index
++) {
1430 if (Index
>= Index2Del
) {
1431 BootOrder
[Index
] = BootOrder
[Index
+ 1];
1435 *BootOrderSize
-= sizeof (UINT16
);