2 The functions for Boot Maintainence Main menu.
4 Copyright (c) 2004 - 2016, 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 "BootMaintenanceManager.h"
17 #define FRONT_PAGE_KEY_OFFSET 0x4000
19 // Boot video resolution and text mode.
21 UINT32 mBmmBootHorizontalResolution
= 0;
22 UINT32 mBmmBootVerticalResolution
= 0;
23 UINT32 mBmmBootTextModeColumn
= 0;
24 UINT32 mBmmBootTextModeRow
= 0;
26 // BIOS setup video resolution and text mode.
28 UINT32 mBmmSetupTextModeColumn
= 0;
29 UINT32 mBmmSetupTextModeRow
= 0;
30 UINT32 mBmmSetupHorizontalResolution
= 0;
31 UINT32 mBmmSetupVerticalResolution
= 0;
33 BOOLEAN mBmmModeInitialized
= FALSE
;
35 EFI_DEVICE_PATH_PROTOCOL EndDevicePath
[] = {
38 END_ENTIRE_DEVICE_PATH_SUBTYPE
,
40 END_DEVICE_PATH_LENGTH
,
46 HII_VENDOR_DEVICE_PATH mBmmHiiVendorDevicePath
= {
52 (UINT8
) (sizeof (VENDOR_DEVICE_PATH
)),
53 (UINT8
) ((sizeof (VENDOR_DEVICE_PATH
)) >> 8)
57 // {165A028F-0BB2-4b5f-8747-77592E3F6499}
59 { 0x165a028f, 0xbb2, 0x4b5f, { 0x87, 0x47, 0x77, 0x59, 0x2e, 0x3f, 0x64, 0x99 } }
63 END_ENTIRE_DEVICE_PATH_SUBTYPE
,
65 (UINT8
) (END_DEVICE_PATH_LENGTH
),
66 (UINT8
) ((END_DEVICE_PATH_LENGTH
) >> 8)
71 EFI_GUID mBootMaintGuid
= BOOT_MAINT_FORMSET_GUID
;
73 CHAR16 mBootMaintStorageName
[] = L
"BmmData";
74 BMM_CALLBACK_DATA gBootMaintenancePrivate
= {
75 BMM_CALLBACK_DATA_SIGNATURE
,
79 BootMaintExtractConfig
,
85 BMM_CALLBACK_DATA
*mBmmCallbackInfo
= &gBootMaintenancePrivate
;
86 BOOLEAN mAllMenuInit
= FALSE
;
87 BOOLEAN mFirstEnterBMMForm
= FALSE
;
92 @param CallbackData The BMM context data.
97 IN BMM_CALLBACK_DATA
*CallbackData
101 Free up all Menu Option list.
111 Update the menus in the BMM page.
120 This function will change video resolution and text mode
121 according to defined setup mode or defined boot mode
123 @param IsSetupMode Indicate mode is changed to setup mode or boot mode.
125 @retval EFI_SUCCESS Mode is changed successfully.
126 @retval Others Mode failed to be changed.
134 EFI_GRAPHICS_OUTPUT_PROTOCOL
*GraphicsOutput
;
135 EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL
*SimpleTextOut
;
137 EFI_GRAPHICS_OUTPUT_MODE_INFORMATION
*Info
;
141 UINT32 NewHorizontalResolution
;
142 UINT32 NewVerticalResolution
;
146 EFI_HANDLE
*HandleBuffer
;
156 // Get current video resolution and text mode
158 Status
= gBS
->HandleProtocol (
159 gST
->ConsoleOutHandle
,
160 &gEfiGraphicsOutputProtocolGuid
,
161 (VOID
**)&GraphicsOutput
163 if (EFI_ERROR (Status
)) {
164 GraphicsOutput
= NULL
;
167 Status
= gBS
->HandleProtocol (
168 gST
->ConsoleOutHandle
,
169 &gEfiSimpleTextOutProtocolGuid
,
170 (VOID
**)&SimpleTextOut
172 if (EFI_ERROR (Status
)) {
173 SimpleTextOut
= NULL
;
176 if ((GraphicsOutput
== NULL
) || (SimpleTextOut
== NULL
)) {
177 return EFI_UNSUPPORTED
;
182 // The required resolution and text mode is setup mode.
184 NewHorizontalResolution
= mBmmSetupHorizontalResolution
;
185 NewVerticalResolution
= mBmmSetupVerticalResolution
;
186 NewColumns
= mBmmSetupTextModeColumn
;
187 NewRows
= mBmmSetupTextModeRow
;
190 // The required resolution and text mode is boot mode.
192 NewHorizontalResolution
= mBmmBootHorizontalResolution
;
193 NewVerticalResolution
= mBmmBootVerticalResolution
;
194 NewColumns
= mBmmBootTextModeColumn
;
195 NewRows
= mBmmBootTextModeRow
;
198 if (GraphicsOutput
!= NULL
) {
199 MaxGopMode
= GraphicsOutput
->Mode
->MaxMode
;
202 if (SimpleTextOut
!= NULL
) {
203 MaxTextMode
= SimpleTextOut
->Mode
->MaxMode
;
207 // 1. If current video resolution is same with required video resolution,
208 // video resolution need not be changed.
209 // 1.1. If current text mode is same with required text mode, text mode need not be changed.
210 // 1.2. If current text mode is different from required text mode, text mode need be changed.
211 // 2. If current video resolution is different from required video resolution, we need restart whole console drivers.
213 for (ModeNumber
= 0; ModeNumber
< MaxGopMode
; ModeNumber
++) {
214 Status
= GraphicsOutput
->QueryMode (
220 if (!EFI_ERROR (Status
)) {
221 if ((Info
->HorizontalResolution
== NewHorizontalResolution
) &&
222 (Info
->VerticalResolution
== NewVerticalResolution
)) {
223 if ((GraphicsOutput
->Mode
->Info
->HorizontalResolution
== NewHorizontalResolution
) &&
224 (GraphicsOutput
->Mode
->Info
->VerticalResolution
== NewVerticalResolution
)) {
226 // Current resolution is same with required resolution, check if text mode need be set
228 Status
= SimpleTextOut
->QueryMode (SimpleTextOut
, SimpleTextOut
->Mode
->Mode
, &CurrentColumn
, &CurrentRow
);
229 ASSERT_EFI_ERROR (Status
);
230 if (CurrentColumn
== NewColumns
&& CurrentRow
== NewRows
) {
232 // If current text mode is same with required text mode. Do nothing
238 // If current text mode is different from required text mode. Set new video mode
240 for (Index
= 0; Index
< MaxTextMode
; Index
++) {
241 Status
= SimpleTextOut
->QueryMode (SimpleTextOut
, Index
, &CurrentColumn
, &CurrentRow
);
242 if (!EFI_ERROR(Status
)) {
243 if ((CurrentColumn
== NewColumns
) && (CurrentRow
== NewRows
)) {
245 // Required text mode is supported, set it.
247 Status
= SimpleTextOut
->SetMode (SimpleTextOut
, Index
);
248 ASSERT_EFI_ERROR (Status
);
250 // Update text mode PCD.
252 Status
= PcdSet32S (PcdConOutColumn
, mBmmSetupTextModeColumn
);
253 ASSERT_EFI_ERROR (Status
);
254 Status
= PcdSet32S (PcdConOutRow
, mBmmSetupTextModeRow
);
255 ASSERT_EFI_ERROR (Status
);
261 if (Index
== MaxTextMode
) {
263 // If required text mode is not supported, return error.
266 return EFI_UNSUPPORTED
;
271 // If current video resolution is not same with the new one, set new video resolution.
272 // In this case, the driver which produces simple text out need be restarted.
274 Status
= GraphicsOutput
->SetMode (GraphicsOutput
, ModeNumber
);
275 if (!EFI_ERROR (Status
)) {
285 if (ModeNumber
== MaxGopMode
) {
287 // If the resolution is not supported, return error.
289 return EFI_UNSUPPORTED
;
293 // Set PCD to Inform GraphicsConsole to change video resolution.
294 // Set PCD to Inform Consplitter to change text mode.
296 Status
= PcdSet32S (PcdVideoHorizontalResolution
, NewHorizontalResolution
);
297 ASSERT_EFI_ERROR (Status
);
298 Status
= PcdSet32S (PcdVideoVerticalResolution
, NewVerticalResolution
);
299 ASSERT_EFI_ERROR (Status
);
300 Status
= PcdSet32S (PcdConOutColumn
, NewColumns
);
301 ASSERT_EFI_ERROR (Status
);
302 Status
= PcdSet32S (PcdConOutRow
, NewRows
);
303 ASSERT_EFI_ERROR (Status
);
306 // Video mode is changed, so restart graphics console driver and higher level driver.
307 // Reconnect graphics console driver and higher level driver.
308 // Locate all the handles with GOP protocol and reconnect it.
310 Status
= gBS
->LocateHandleBuffer (
312 &gEfiSimpleTextOutProtocolGuid
,
317 if (!EFI_ERROR (Status
)) {
318 for (Index
= 0; Index
< HandleCount
; Index
++) {
319 gBS
->DisconnectController (HandleBuffer
[Index
], NULL
, NULL
);
321 for (Index
= 0; Index
< HandleCount
; Index
++) {
322 gBS
->ConnectController (HandleBuffer
[Index
], NULL
, NULL
, TRUE
);
324 if (HandleBuffer
!= NULL
) {
325 FreePool (HandleBuffer
);
333 This function converts an input device structure to a Unicode string.
335 @param DevPath A pointer to the device path structure.
337 @return A new allocated Unicode string that represents the device path.
342 IN EFI_DEVICE_PATH_PROTOCOL
*DevPath
347 EFI_DEVICE_PATH_TO_TEXT_PROTOCOL
*DevPathToText
;
349 if (DevPath
== NULL
) {
353 Status
= gBS
->LocateProtocol (
354 &gEfiDevicePathToTextProtocolGuid
,
356 (VOID
**) &DevPathToText
358 ASSERT_EFI_ERROR (Status
);
359 ToText
= DevPathToText
->ConvertDevicePathToText (
364 ASSERT (ToText
!= NULL
);
369 Extract filename from device path. The returned buffer is allocated using AllocateCopyPool.
370 The caller is responsible for freeing the allocated buffer using FreePool().
372 @param DevicePath Device path.
374 @return A new allocated string that represents the file name.
378 ExtractFileNameFromDevicePath (
379 IN EFI_DEVICE_PATH_PROTOCOL
*DevicePath
388 ASSERT(DevicePath
!= NULL
);
390 String
= UiDevicePathToStr(DevicePath
);
391 MatchString
= String
;
395 while(MatchString
!= NULL
){
396 LastMatch
= MatchString
+ 1;
397 MatchString
= StrStr(LastMatch
,L
"\\");
400 Length
= StrLen(LastMatch
);
401 FileName
= AllocateCopyPool ((Length
+ 1) * sizeof(CHAR16
), LastMatch
);
402 if (FileName
!= NULL
) {
403 *(FileName
+ Length
) = 0;
412 Extract device path for given HII handle and class guid.
414 @param Handle The HII handle.
416 @retval NULL Fail to get the device path string.
417 @return PathString Get the device path string.
421 BmmExtractDevicePathFromHiiHandle (
422 IN EFI_HII_HANDLE Handle
426 EFI_HANDLE DriverHandle
;
428 ASSERT (Handle
!= NULL
);
430 if (Handle
== NULL
) {
434 Status
= gHiiDatabase
->GetPackageListHandle (gHiiDatabase
, Handle
, &DriverHandle
);
435 if (EFI_ERROR (Status
)) {
440 // Get device path string.
442 return ConvertDevicePathToText(DevicePathFromHandle (DriverHandle
), FALSE
, FALSE
);
447 This function allows a caller to extract the current configuration for one
448 or more named elements from the target driver.
450 @param This Points to the EFI_HII_CONFIG_ACCESS_PROTOCOL.
451 @param Request A null-terminated Unicode string in <ConfigRequest> format.
452 @param Progress On return, points to a character in the Request string.
453 Points to the string's null terminator if request was successful.
454 Points to the most recent '&' before the first failing name/value
455 pair (or the beginning of the string if the failure is in the
456 first name/value pair) if the request was not successful.
457 @param Results A null-terminated Unicode string in <ConfigAltResp> format which
458 has all values filled in for the names in the Request string.
459 String to be allocated by the called function.
461 @retval EFI_SUCCESS The Results is filled with the requested values.
462 @retval EFI_OUT_OF_RESOURCES Not enough memory to store the results.
463 @retval EFI_INVALID_PARAMETER Request is NULL, illegal syntax, or unknown name.
464 @retval EFI_NOT_FOUND Routing data doesn't match any storage in this driver.
469 BootMaintExtractConfig (
470 IN CONST EFI_HII_CONFIG_ACCESS_PROTOCOL
*This
,
471 IN CONST EFI_STRING Request
,
472 OUT EFI_STRING
*Progress
,
473 OUT EFI_STRING
*Results
478 BMM_CALLBACK_DATA
*Private
;
479 EFI_STRING ConfigRequestHdr
;
480 EFI_STRING ConfigRequest
;
481 BOOLEAN AllocatedRequest
;
484 if (Progress
== NULL
|| Results
== NULL
) {
485 return EFI_INVALID_PARAMETER
;
489 if ((Request
!= NULL
) && !HiiIsConfigHdrMatch (Request
, &mBootMaintGuid
, mBootMaintStorageName
)) {
490 return EFI_NOT_FOUND
;
493 ConfigRequestHdr
= NULL
;
494 ConfigRequest
= NULL
;
495 AllocatedRequest
= FALSE
;
498 Private
= BMM_CALLBACK_DATA_FROM_THIS (This
);
500 // Convert buffer data to <ConfigResp> by helper function BlockToConfig()
502 BufferSize
= sizeof (BMM_FAKE_NV_DATA
);
503 ConfigRequest
= Request
;
504 if ((Request
== NULL
) || (StrStr (Request
, L
"OFFSET") == NULL
)) {
506 // Request has no request element, construct full request string.
507 // Allocate and fill a buffer large enough to hold the <ConfigHdr> template
508 // followed by "&OFFSET=0&WIDTH=WWWWWWWWWWWWWWWW" followed by a Null-terminator
510 ConfigRequestHdr
= HiiConstructConfigHdr (&mBootMaintGuid
, mBootMaintStorageName
, Private
->BmmDriverHandle
);
511 Size
= (StrLen (ConfigRequestHdr
) + 32 + 1) * sizeof (CHAR16
);
512 ConfigRequest
= AllocateZeroPool (Size
);
513 ASSERT (ConfigRequest
!= NULL
);
514 AllocatedRequest
= TRUE
;
515 UnicodeSPrint (ConfigRequest
, Size
, L
"%s&OFFSET=0&WIDTH=%016LX", ConfigRequestHdr
, (UINT64
)BufferSize
);
516 FreePool (ConfigRequestHdr
);
519 Status
= gHiiConfigRouting
->BlockToConfig (
522 (UINT8
*) &Private
->BmmFakeNvData
,
528 // Free the allocated config request string.
530 if (AllocatedRequest
) {
531 FreePool (ConfigRequest
);
532 ConfigRequest
= NULL
;
535 // Set Progress string to the original request string.
537 if (Request
== NULL
) {
539 } else if (StrStr (Request
, L
"OFFSET") == NULL
) {
540 *Progress
= Request
+ StrLen (Request
);
547 This function applies changes in a driver's configuration.
548 Input is a Configuration, which has the routing data for this
549 driver followed by name / value configuration pairs. The driver
550 must apply those pairs to its configurable storage. If the
551 driver's configuration is stored in a linear block of data
552 and the driver's name / value pairs are in <BlockConfig>
553 format, it may use the ConfigToBlock helper function (above) to
554 simplify the job. Currently not implemented.
556 @param[in] This Points to the EFI_HII_CONFIG_ACCESS_PROTOCOL.
557 @param[in] Configuration A null-terminated Unicode string in
558 <ConfigString> format.
559 @param[out] Progress A pointer to a string filled in with the
560 offset of the most recent '&' before the
561 first failing name / value pair (or the
562 beginn ing of the string if the failure
563 is in the first name / value pair) or
564 the terminating NULL if all was
567 @retval EFI_SUCCESS The results have been distributed or are
568 awaiting distribution.
569 @retval EFI_OUT_OF_RESOURCES Not enough memory to store the
570 parts of the results that must be
571 stored awaiting possible future
573 @retval EFI_INVALID_PARAMETERS Passing in a NULL for the
574 Results parameter would result
575 in this type of error.
576 @retval EFI_NOT_FOUND Target for the specified routing data
581 BootMaintRouteConfig (
582 IN CONST EFI_HII_CONFIG_ACCESS_PROTOCOL
*This
,
583 IN CONST EFI_STRING Configuration
,
584 OUT EFI_STRING
*Progress
589 EFI_HII_CONFIG_ROUTING_PROTOCOL
*ConfigRouting
;
590 BMM_FAKE_NV_DATA
*NewBmmData
;
591 BMM_FAKE_NV_DATA
*OldBmmData
;
592 BM_CONSOLE_CONTEXT
*NewConsoleContext
;
593 BM_TERMINAL_CONTEXT
*NewTerminalContext
;
594 BM_MENU_ENTRY
*NewMenuEntry
;
595 BM_LOAD_CONTEXT
*NewLoadContext
;
597 BOOLEAN TerminalAttChange
;
598 BMM_CALLBACK_DATA
*Private
;
600 if (Progress
== NULL
) {
601 return EFI_INVALID_PARAMETER
;
603 *Progress
= Configuration
;
605 if (Configuration
== NULL
) {
606 return EFI_INVALID_PARAMETER
;
610 // Check routing data in <ConfigHdr>.
611 // Note: there is no name for Name/Value storage, only GUID will be checked
613 if (!HiiIsConfigHdrMatch (Configuration
, &mBootMaintGuid
, mBootMaintStorageName
)) {
614 return EFI_NOT_FOUND
;
617 Status
= gBS
->LocateProtocol (
618 &gEfiHiiConfigRoutingProtocolGuid
,
620 (VOID
**)&ConfigRouting
622 if (EFI_ERROR (Status
)) {
626 Private
= BMM_CALLBACK_DATA_FROM_THIS (This
);
628 // Get Buffer Storage data from EFI variable
630 BufferSize
= sizeof (BMM_FAKE_NV_DATA
);
631 OldBmmData
= &Private
->BmmOldFakeNVData
;
632 NewBmmData
= &Private
->BmmFakeNvData
;
634 // Convert <ConfigResp> to buffer data by helper function ConfigToBlock()
636 Status
= ConfigRouting
->ConfigToBlock (
639 (UINT8
*) NewBmmData
,
643 ASSERT_EFI_ERROR (Status
);
645 // Compare new and old BMM configuration data and only do action for modified item to
646 // avoid setting unnecessary non-volatile variable
650 // Check data which located in BMM main page and save the settings if need
652 if (CompareMem (&NewBmmData
->BootNext
, &OldBmmData
->BootNext
, sizeof (NewBmmData
->BootNext
)) != 0) {
653 Status
= Var_UpdateBootNext (Private
);
657 // Check data which located in Boot Options Menu and save the settings if need
659 if (CompareMem (NewBmmData
->BootOptionDel
, OldBmmData
->BootOptionDel
, sizeof (NewBmmData
->BootOptionDel
)) != 0) {
661 ((Index
< BootOptionMenu
.MenuNumber
) && (Index
< (sizeof (NewBmmData
->BootOptionDel
) / sizeof (NewBmmData
->BootOptionDel
[0]))));
663 NewMenuEntry
= BOpt_GetMenuEntry (&BootOptionMenu
, Index
);
664 NewLoadContext
= (BM_LOAD_CONTEXT
*) NewMenuEntry
->VariableContext
;
665 NewLoadContext
->Deleted
= NewBmmData
->BootOptionDel
[Index
];
666 NewBmmData
->BootOptionDel
[Index
] = FALSE
;
667 NewBmmData
->BootOptionDelMark
[Index
] = FALSE
;
670 Var_DelBootOption ();
673 if (CompareMem (NewBmmData
->BootOptionOrder
, OldBmmData
->BootOptionOrder
, sizeof (NewBmmData
->BootOptionOrder
)) != 0) {
674 Status
= Var_UpdateBootOrder (Private
);
677 if (CompareMem (&NewBmmData
->BootTimeOut
, &OldBmmData
->BootTimeOut
, sizeof (NewBmmData
->BootTimeOut
)) != 0){
678 Status
= gRT
->SetVariable(
680 &gEfiGlobalVariableGuid
,
681 EFI_VARIABLE_BOOTSERVICE_ACCESS
| EFI_VARIABLE_RUNTIME_ACCESS
| EFI_VARIABLE_NON_VOLATILE
,
683 &(NewBmmData
->BootTimeOut
)
685 if (EFI_ERROR (Status
)) {
687 // If set variable fail, and don't have the appropriate error status for RouteConfig fuction to return,
688 // just return the EFI_NOT_FOUND.
690 if (Status
== EFI_OUT_OF_RESOURCES
) {
693 return EFI_NOT_FOUND
;
696 Private
->BmmOldFakeNVData
.BootTimeOut
= NewBmmData
->BootTimeOut
;
700 // Check data which located in Driver Options Menu and save the settings if need
702 if (CompareMem (NewBmmData
->DriverOptionDel
, OldBmmData
->DriverOptionDel
, sizeof (NewBmmData
->DriverOptionDel
)) != 0) {
704 ((Index
< DriverOptionMenu
.MenuNumber
) && (Index
< (sizeof (NewBmmData
->DriverOptionDel
) / sizeof (NewBmmData
->DriverOptionDel
[0]))));
706 NewMenuEntry
= BOpt_GetMenuEntry (&DriverOptionMenu
, Index
);
707 NewLoadContext
= (BM_LOAD_CONTEXT
*) NewMenuEntry
->VariableContext
;
708 NewLoadContext
->Deleted
= NewBmmData
->DriverOptionDel
[Index
];
709 NewBmmData
->DriverOptionDel
[Index
] = FALSE
;
710 NewBmmData
->DriverOptionDelMark
[Index
] = FALSE
;
712 Var_DelDriverOption ();
715 if (CompareMem (NewBmmData
->DriverOptionOrder
, OldBmmData
->DriverOptionOrder
, sizeof (NewBmmData
->DriverOptionOrder
)) != 0) {
716 Status
= Var_UpdateDriverOrder (Private
);
719 if (CompareMem (&NewBmmData
->ConsoleOutMode
, &OldBmmData
->ConsoleOutMode
, sizeof (NewBmmData
->ConsoleOutMode
)) != 0){
720 Var_UpdateConMode(Private
);
723 TerminalAttChange
= FALSE
;
724 for (Index
= 0; Index
< TerminalMenu
.MenuNumber
; Index
++) {
727 // only need update modified items
729 if (CompareMem (&NewBmmData
->COMBaudRate
[Index
], &OldBmmData
->COMBaudRate
[Index
], sizeof (NewBmmData
->COMBaudRate
[Index
])) == 0 &&
730 CompareMem (&NewBmmData
->COMDataRate
[Index
], &OldBmmData
->COMDataRate
[Index
], sizeof (NewBmmData
->COMDataRate
[Index
])) == 0 &&
731 CompareMem (&NewBmmData
->COMStopBits
[Index
], &OldBmmData
->COMStopBits
[Index
], sizeof (NewBmmData
->COMStopBits
[Index
])) == 0 &&
732 CompareMem (&NewBmmData
->COMParity
[Index
], &OldBmmData
->COMParity
[Index
], sizeof (NewBmmData
->COMParity
[Index
])) == 0 &&
733 CompareMem (&NewBmmData
->COMTerminalType
[Index
], &OldBmmData
->COMTerminalType
[Index
], sizeof (NewBmmData
->COMTerminalType
[Index
])) == 0 &&
734 CompareMem (&NewBmmData
->COMFlowControl
[Index
], &OldBmmData
->COMFlowControl
[Index
], sizeof (NewBmmData
->COMFlowControl
[Index
])) == 0) {
738 NewMenuEntry
= BOpt_GetMenuEntry (&TerminalMenu
, Index
);
739 ASSERT (NewMenuEntry
!= NULL
);
740 NewTerminalContext
= (BM_TERMINAL_CONTEXT
*) NewMenuEntry
->VariableContext
;
741 NewTerminalContext
->BaudRateIndex
= NewBmmData
->COMBaudRate
[Index
];
742 ASSERT (NewBmmData
->COMBaudRate
[Index
] < (sizeof (BaudRateList
) / sizeof (BaudRateList
[0])));
743 NewTerminalContext
->BaudRate
= BaudRateList
[NewBmmData
->COMBaudRate
[Index
]].Value
;
744 NewTerminalContext
->DataBitsIndex
= NewBmmData
->COMDataRate
[Index
];
745 ASSERT (NewBmmData
->COMDataRate
[Index
] < (sizeof (DataBitsList
) / sizeof (DataBitsList
[0])));
746 NewTerminalContext
->DataBits
= (UINT8
) DataBitsList
[NewBmmData
->COMDataRate
[Index
]].Value
;
747 NewTerminalContext
->StopBitsIndex
= NewBmmData
->COMStopBits
[Index
];
748 ASSERT (NewBmmData
->COMStopBits
[Index
] < (sizeof (StopBitsList
) / sizeof (StopBitsList
[0])));
749 NewTerminalContext
->StopBits
= (UINT8
) StopBitsList
[NewBmmData
->COMStopBits
[Index
]].Value
;
750 NewTerminalContext
->ParityIndex
= NewBmmData
->COMParity
[Index
];
751 ASSERT (NewBmmData
->COMParity
[Index
] < (sizeof (ParityList
) / sizeof (ParityList
[0])));
752 NewTerminalContext
->Parity
= (UINT8
) ParityList
[NewBmmData
->COMParity
[Index
]].Value
;
753 NewTerminalContext
->TerminalType
= NewBmmData
->COMTerminalType
[Index
];
754 NewTerminalContext
->FlowControl
= NewBmmData
->COMFlowControl
[Index
];
755 ChangeTerminalDevicePath (
756 NewTerminalContext
->DevicePath
,
759 TerminalAttChange
= TRUE
;
761 if (TerminalAttChange
) {
762 Var_UpdateConsoleInpOption ();
763 Var_UpdateConsoleOutOption ();
764 Var_UpdateErrorOutOption ();
767 // Check data which located in Console Options Menu and save the settings if need
769 if (CompareMem (NewBmmData
->ConsoleInCheck
, OldBmmData
->ConsoleInCheck
, sizeof (NewBmmData
->ConsoleInCheck
)) != 0){
770 for (Index
= 0; Index
< ConsoleInpMenu
.MenuNumber
; Index
++){
771 NewMenuEntry
= BOpt_GetMenuEntry(&ConsoleInpMenu
, Index
);
772 NewConsoleContext
= (BM_CONSOLE_CONTEXT
*)NewMenuEntry
->VariableContext
;
773 ASSERT (Index
< MAX_MENU_NUMBER
);
774 NewConsoleContext
->IsActive
= NewBmmData
->ConsoleInCheck
[Index
];
776 for (Index
= 0; Index
< TerminalMenu
.MenuNumber
; Index
++) {
777 NewMenuEntry
= BOpt_GetMenuEntry (&TerminalMenu
, Index
);
778 NewTerminalContext
= (BM_TERMINAL_CONTEXT
*) NewMenuEntry
->VariableContext
;
779 ASSERT (Index
+ ConsoleInpMenu
.MenuNumber
< MAX_MENU_NUMBER
);
780 NewTerminalContext
->IsConIn
= NewBmmData
->ConsoleInCheck
[Index
+ ConsoleInpMenu
.MenuNumber
];
782 Var_UpdateConsoleInpOption();
785 if (CompareMem (NewBmmData
->ConsoleOutCheck
, OldBmmData
->ConsoleOutCheck
, sizeof (NewBmmData
->ConsoleOutCheck
)) != 0){
786 for (Index
= 0; Index
< ConsoleOutMenu
.MenuNumber
; Index
++){
787 NewMenuEntry
= BOpt_GetMenuEntry(&ConsoleOutMenu
, Index
);
788 NewConsoleContext
= (BM_CONSOLE_CONTEXT
*)NewMenuEntry
->VariableContext
;
789 ASSERT (Index
< MAX_MENU_NUMBER
);
790 NewConsoleContext
->IsActive
= NewBmmData
->ConsoleOutCheck
[Index
];
792 for (Index
= 0; Index
< TerminalMenu
.MenuNumber
; Index
++) {
793 NewMenuEntry
= BOpt_GetMenuEntry (&TerminalMenu
, Index
);
794 NewTerminalContext
= (BM_TERMINAL_CONTEXT
*) NewMenuEntry
->VariableContext
;
795 ASSERT (Index
+ ConsoleOutMenu
.MenuNumber
< MAX_MENU_NUMBER
);
796 NewTerminalContext
->IsConOut
= NewBmmData
->ConsoleOutCheck
[Index
+ ConsoleOutMenu
.MenuNumber
];
798 Var_UpdateConsoleOutOption();
801 if (CompareMem (NewBmmData
->ConsoleErrCheck
, OldBmmData
->ConsoleErrCheck
, sizeof (NewBmmData
->ConsoleErrCheck
)) != 0){
802 for (Index
= 0; Index
< ConsoleErrMenu
.MenuNumber
; Index
++){
803 NewMenuEntry
= BOpt_GetMenuEntry(&ConsoleErrMenu
, Index
);
804 NewConsoleContext
= (BM_CONSOLE_CONTEXT
*)NewMenuEntry
->VariableContext
;
805 ASSERT (Index
< MAX_MENU_NUMBER
);
806 NewConsoleContext
->IsActive
= NewBmmData
->ConsoleErrCheck
[Index
];
808 for (Index
= 0; Index
< TerminalMenu
.MenuNumber
; Index
++) {
809 NewMenuEntry
= BOpt_GetMenuEntry (&TerminalMenu
, Index
);
810 NewTerminalContext
= (BM_TERMINAL_CONTEXT
*) NewMenuEntry
->VariableContext
;
811 ASSERT (Index
+ ConsoleErrMenu
.MenuNumber
< MAX_MENU_NUMBER
);
812 NewTerminalContext
->IsStdErr
= NewBmmData
->ConsoleErrCheck
[Index
+ ConsoleErrMenu
.MenuNumber
];
814 Var_UpdateErrorOutOption();
817 if (CompareMem (NewBmmData
->BootDescriptionData
, OldBmmData
->BootDescriptionData
, sizeof (NewBmmData
->BootDescriptionData
)) != 0 ||
818 CompareMem (NewBmmData
->BootOptionalData
, OldBmmData
->BootOptionalData
, sizeof (NewBmmData
->BootOptionalData
)) != 0) {
819 Status
= Var_UpdateBootOption (Private
);
820 NewBmmData
->BootOptionChanged
= FALSE
;
821 if (EFI_ERROR (Status
)) {
824 BOpt_GetBootOptions (Private
);
827 if (CompareMem (NewBmmData
->DriverDescriptionData
, OldBmmData
->DriverDescriptionData
, sizeof (NewBmmData
->DriverDescriptionData
)) != 0 ||
828 CompareMem (NewBmmData
->DriverOptionalData
, OldBmmData
->DriverOptionalData
, sizeof (NewBmmData
->DriverOptionalData
)) != 0) {
829 Status
= Var_UpdateDriverOption (
831 Private
->BmmHiiHandle
,
832 NewBmmData
->DriverDescriptionData
,
833 NewBmmData
->DriverOptionalData
,
834 NewBmmData
->ForceReconnect
836 NewBmmData
->DriverOptionChanged
= FALSE
;
837 NewBmmData
->ForceReconnect
= TRUE
;
838 if (EFI_ERROR (Status
)) {
842 BOpt_GetDriverOptions (Private
);
846 // After user do the save action, need to update OldBmmData.
848 CopyMem (OldBmmData
, NewBmmData
, sizeof (BMM_FAKE_NV_DATA
));
854 This function processes the results of changes in configuration.
857 @param This Points to the EFI_HII_CONFIG_ACCESS_PROTOCOL.
858 @param Action Specifies the type of action taken by the browser.
859 @param QuestionId A unique value which is sent to the original exporting driver
860 so that it can identify the type of data to expect.
861 @param Type The type of value for the question.
862 @param Value A pointer to the data being sent to the original exporting driver.
863 @param ActionRequest On return, points to the action requested by the callback function.
865 @retval EFI_SUCCESS The callback successfully handled the action.
866 @retval EFI_OUT_OF_RESOURCES Not enough storage is available to hold the variable and its data.
867 @retval EFI_DEVICE_ERROR The variable could not be saved.
868 @retval EFI_UNSUPPORTED The specified Action is not supported by the callback.
869 @retval EFI_INVALID_PARAMETER The parameter of Value or ActionRequest is invalid.
874 IN CONST EFI_HII_CONFIG_ACCESS_PROTOCOL
*This
,
875 IN EFI_BROWSER_ACTION Action
,
876 IN EFI_QUESTION_ID QuestionId
,
878 IN EFI_IFR_TYPE_VALUE
*Value
,
879 OUT EFI_BROWSER_ACTION_REQUEST
*ActionRequest
882 BMM_CALLBACK_DATA
*Private
;
883 BM_MENU_ENTRY
*NewMenuEntry
;
884 BMM_FAKE_NV_DATA
*CurrentFakeNVMap
;
886 EFI_DEVICE_PATH_PROTOCOL
* File
;
888 if (Action
!= EFI_BROWSER_ACTION_CHANGING
&& Action
!= EFI_BROWSER_ACTION_CHANGED
&& Action
!= EFI_BROWSER_ACTION_FORM_OPEN
) {
890 // Do nothing for other UEFI Action. Only do call back when data is changed or the form is open.
892 return EFI_UNSUPPORTED
;
895 Private
= BMM_CALLBACK_DATA_FROM_THIS (This
);
897 if (Action
== EFI_BROWSER_ACTION_FORM_OPEN
) {
898 if (QuestionId
== KEY_VALUE_TRIGGER_FORM_OPEN_ACTION
) {
899 if (!mFirstEnterBMMForm
) {
901 // BMMUiLib depends on LegacyUi library to show legacy menus.
902 // If we want to show Legacy menus correctly in BMM page,
903 // we must do it after the LegacyUi library has already been initialized.
904 // Opening the BMM form is the appropriate time that the LegacyUi library has already been initialized.
905 // So we do the tasks which are related to legacy menus here.
906 // 1. Update the menus (including legacy munu) show in BootMiantenanceManager page.
907 // 2. Re-scan the BootOption menus (including the legacy boot option).
910 BOpt_GetBootOptions (Private
);
911 mFirstEnterBMMForm
= TRUE
;
916 // Retrive uncommitted data from Form Browser
918 CurrentFakeNVMap
= &Private
->BmmFakeNvData
;
919 HiiGetBrowserData (&mBootMaintGuid
, mBootMaintStorageName
, sizeof (BMM_FAKE_NV_DATA
), (UINT8
*) CurrentFakeNVMap
);
921 if (Action
== EFI_BROWSER_ACTION_CHANGING
) {
923 return EFI_INVALID_PARAMETER
;
926 UpdatePageId (Private
, QuestionId
);
928 if (QuestionId
< FILE_OPTION_OFFSET
) {
929 if (QuestionId
< CONFIG_OPTION_OFFSET
) {
930 switch (QuestionId
) {
931 case FORM_BOOT_ADD_ID
:
932 // Leave BMM and enter FileExplorer.
933 ChooseFile (NULL
, L
".efi", CreateBootOptionFromFile
, &File
);
936 case FORM_DRV_ADD_FILE_ID
:
937 // Leave BMM and enter FileExplorer.
938 ChooseFile (NULL
, L
".efi", CreateDriverOptionFromFile
, &File
);
941 case FORM_DRV_ADD_HANDLE_ID
:
942 CleanUpPage (FORM_DRV_ADD_HANDLE_ID
, Private
);
943 UpdateDrvAddHandlePage (Private
);
946 case FORM_BOOT_DEL_ID
:
947 CleanUpPage (FORM_BOOT_DEL_ID
, Private
);
948 UpdateBootDelPage (Private
);
951 case FORM_BOOT_CHG_ID
:
952 case FORM_DRV_CHG_ID
:
953 UpdatePageBody (QuestionId
, Private
);
956 case FORM_DRV_DEL_ID
:
957 CleanUpPage (FORM_DRV_DEL_ID
, Private
);
958 UpdateDrvDelPage (Private
);
962 case FORM_CON_OUT_ID
:
963 case FORM_CON_ERR_ID
:
964 UpdatePageBody (QuestionId
, Private
);
967 case FORM_CON_MODE_ID
:
968 CleanUpPage (FORM_CON_MODE_ID
, Private
);
969 UpdateConModePage (Private
);
972 case FORM_CON_COM_ID
:
973 CleanUpPage (FORM_CON_COM_ID
, Private
);
974 UpdateConCOMPage (Private
);
980 } else if ((QuestionId
>= TERMINAL_OPTION_OFFSET
) && (QuestionId
< CONSOLE_OPTION_OFFSET
)) {
981 Index
= (UINT16
) (QuestionId
- TERMINAL_OPTION_OFFSET
);
982 Private
->CurrentTerminal
= Index
;
984 CleanUpPage (FORM_CON_COM_SETUP_ID
, Private
);
985 UpdateTerminalPage (Private
);
987 } else if (QuestionId
>= HANDLE_OPTION_OFFSET
) {
988 Index
= (UINT16
) (QuestionId
- HANDLE_OPTION_OFFSET
);
990 NewMenuEntry
= BOpt_GetMenuEntry (&DriverMenu
, Index
);
991 ASSERT (NewMenuEntry
!= NULL
);
992 Private
->HandleContext
= (BM_HANDLE_CONTEXT
*) NewMenuEntry
->VariableContext
;
994 CleanUpPage (FORM_DRV_ADD_HANDLE_DESC_ID
, Private
);
996 Private
->MenuEntry
= NewMenuEntry
;
997 Private
->LoadContext
->FilePathList
= Private
->HandleContext
->DevicePath
;
999 UpdateDriverAddHandleDescPage (Private
);
1002 if (QuestionId
== KEY_VALUE_BOOT_FROM_FILE
){
1003 // Leave BMM and enter FileExplorer.
1004 ChooseFile (NULL
, L
".efi", BootFromFile
, &File
);
1006 } else if (Action
== EFI_BROWSER_ACTION_CHANGED
) {
1007 if ((Value
== NULL
) || (ActionRequest
== NULL
)) {
1008 return EFI_INVALID_PARAMETER
;
1011 if (QuestionId
== KEY_VALUE_SAVE_AND_EXIT_BOOT
) {
1012 CurrentFakeNVMap
->BootOptionChanged
= FALSE
;
1013 *ActionRequest
= EFI_BROWSER_ACTION_REQUEST_FORM_SUBMIT_EXIT
;
1014 } else if (QuestionId
== KEY_VALUE_SAVE_AND_EXIT_DRIVER
) {
1015 CurrentFakeNVMap
->DriverOptionChanged
= FALSE
;
1016 *ActionRequest
= EFI_BROWSER_ACTION_REQUEST_FORM_SUBMIT_EXIT
;
1017 } else if (QuestionId
== KEY_VALUE_NO_SAVE_AND_EXIT_DRIVER
) {
1019 // Discard changes and exit formset
1021 CurrentFakeNVMap
->DriverOptionalData
[0] = 0x0000;
1022 CurrentFakeNVMap
->DriverDescriptionData
[0] = 0x0000;
1023 CurrentFakeNVMap
->DriverOptionChanged
= FALSE
;
1024 CurrentFakeNVMap
->ForceReconnect
= TRUE
;
1025 *ActionRequest
= EFI_BROWSER_ACTION_REQUEST_FORM_DISCARD_EXIT
;
1026 } else if (QuestionId
== KEY_VALUE_NO_SAVE_AND_EXIT_BOOT
) {
1028 // Discard changes and exit formset
1030 CurrentFakeNVMap
->BootOptionalData
[0] = 0x0000;
1031 CurrentFakeNVMap
->BootDescriptionData
[0] = 0x0000;
1032 CurrentFakeNVMap
->BootOptionChanged
= FALSE
;
1033 *ActionRequest
= EFI_BROWSER_ACTION_REQUEST_FORM_DISCARD_EXIT
;
1034 } else if (QuestionId
== KEY_VALUE_BOOT_DESCRIPTION
|| QuestionId
== KEY_VALUE_BOOT_OPTION
) {
1035 CurrentFakeNVMap
->BootOptionChanged
= TRUE
;
1036 } else if (QuestionId
== KEY_VALUE_DRIVER_DESCRIPTION
|| QuestionId
== KEY_VALUE_DRIVER_OPTION
) {
1037 CurrentFakeNVMap
->DriverOptionChanged
= TRUE
;
1040 if ((QuestionId
>= BOOT_OPTION_DEL_QUESTION_ID
) && (QuestionId
< BOOT_OPTION_DEL_QUESTION_ID
+ MAX_MENU_NUMBER
)) {
1043 // Means user try to delete this boot option but not press F10 or "Commit Changes and Exit" menu.
1045 CurrentFakeNVMap
->BootOptionDelMark
[QuestionId
- BOOT_OPTION_DEL_QUESTION_ID
] = TRUE
;
1048 // Means user remove the old check status.
1050 CurrentFakeNVMap
->BootOptionDelMark
[QuestionId
- BOOT_OPTION_DEL_QUESTION_ID
] = FALSE
;
1052 } else if ((QuestionId
>= DRIVER_OPTION_DEL_QUESTION_ID
) && (QuestionId
< DRIVER_OPTION_DEL_QUESTION_ID
+ MAX_MENU_NUMBER
)) {
1054 CurrentFakeNVMap
->DriverOptionDelMark
[QuestionId
- DRIVER_OPTION_DEL_QUESTION_ID
] = TRUE
;
1056 CurrentFakeNVMap
->DriverOptionDelMark
[QuestionId
- DRIVER_OPTION_DEL_QUESTION_ID
] = FALSE
;
1059 switch (QuestionId
) {
1060 case KEY_VALUE_SAVE_AND_EXIT
:
1061 case KEY_VALUE_NO_SAVE_AND_EXIT
:
1062 if (QuestionId
== KEY_VALUE_SAVE_AND_EXIT
) {
1063 *ActionRequest
= EFI_BROWSER_ACTION_REQUEST_FORM_SUBMIT_EXIT
;
1064 } else if (QuestionId
== KEY_VALUE_NO_SAVE_AND_EXIT
) {
1065 DiscardChangeHandler (Private
, CurrentFakeNVMap
);
1066 *ActionRequest
= EFI_BROWSER_ACTION_REQUEST_FORM_DISCARD_EXIT
;
1072 gRT
->ResetSystem (EfiResetCold
, EFI_SUCCESS
, 0, NULL
);
1073 return EFI_UNSUPPORTED
;
1082 // Pass changed uncommitted data back to Form Browser
1084 HiiSetBrowserData (&mBootMaintGuid
, mBootMaintStorageName
, sizeof (BMM_FAKE_NV_DATA
), (UINT8
*) CurrentFakeNVMap
, NULL
);
1090 Discard all changes done to the BMM pages such as Boot Order change,
1091 Driver order change.
1093 @param Private The BMM context data.
1094 @param CurrentFakeNVMap The current Fack NV Map.
1098 DiscardChangeHandler (
1099 IN BMM_CALLBACK_DATA
*Private
,
1100 IN BMM_FAKE_NV_DATA
*CurrentFakeNVMap
1105 switch (Private
->BmmPreviousPageId
) {
1106 case FORM_BOOT_CHG_ID
:
1107 CopyMem (CurrentFakeNVMap
->BootOptionOrder
, Private
->BmmOldFakeNVData
.BootOptionOrder
, sizeof (CurrentFakeNVMap
->BootOptionOrder
));
1110 case FORM_DRV_CHG_ID
:
1111 CopyMem (CurrentFakeNVMap
->DriverOptionOrder
, Private
->BmmOldFakeNVData
.DriverOptionOrder
, sizeof (CurrentFakeNVMap
->DriverOptionOrder
));
1114 case FORM_BOOT_DEL_ID
:
1115 ASSERT (BootOptionMenu
.MenuNumber
<= (sizeof (CurrentFakeNVMap
->BootOptionDel
) / sizeof (CurrentFakeNVMap
->BootOptionDel
[0])));
1116 for (Index
= 0; Index
< BootOptionMenu
.MenuNumber
; Index
++) {
1117 CurrentFakeNVMap
->BootOptionDel
[Index
] = FALSE
;
1121 case FORM_DRV_DEL_ID
:
1122 ASSERT (DriverOptionMenu
.MenuNumber
<= (sizeof (CurrentFakeNVMap
->DriverOptionDel
) / sizeof (CurrentFakeNVMap
->DriverOptionDel
[0])));
1123 for (Index
= 0; Index
< DriverOptionMenu
.MenuNumber
; Index
++) {
1124 CurrentFakeNVMap
->DriverOptionDel
[Index
] = FALSE
;
1128 case FORM_BOOT_NEXT_ID
:
1129 CurrentFakeNVMap
->BootNext
= Private
->BmmOldFakeNVData
.BootNext
;
1132 case FORM_TIME_OUT_ID
:
1133 CurrentFakeNVMap
->BootTimeOut
= Private
->BmmOldFakeNVData
.BootTimeOut
;
1136 case FORM_DRV_ADD_HANDLE_DESC_ID
:
1137 case FORM_DRV_ADD_FILE_ID
:
1138 case FORM_DRV_ADD_HANDLE_ID
:
1139 CurrentFakeNVMap
->DriverAddHandleDesc
[0] = 0x0000;
1140 CurrentFakeNVMap
->DriverAddHandleOptionalData
[0] = 0x0000;
1150 Update the menus in the BMM page.
1158 VOID
*StartOpCodeHandle
;
1159 VOID
*EndOpCodeHandle
;
1160 EFI_IFR_GUID_LABEL
*StartGuidLabel
;
1161 EFI_IFR_GUID_LABEL
*EndGuidLabel
;
1164 // Allocate space for creation of UpdateData Buffer
1166 StartOpCodeHandle
= HiiAllocateOpCodeHandle ();
1167 ASSERT (StartOpCodeHandle
!= NULL
);
1169 EndOpCodeHandle
= HiiAllocateOpCodeHandle ();
1170 ASSERT (EndOpCodeHandle
!= NULL
);
1172 // Create Hii Extend Label OpCode as the start opcode
1174 StartGuidLabel
= (EFI_IFR_GUID_LABEL
*) HiiCreateGuidOpCode (StartOpCodeHandle
, &gEfiIfrTianoGuid
, NULL
, sizeof (EFI_IFR_GUID_LABEL
));
1175 StartGuidLabel
->ExtendOpCode
= EFI_IFR_EXTEND_OP_LABEL
;
1176 StartGuidLabel
->Number
= LABEL_FORM_MAIN_START
;
1178 // Create Hii Extend Label OpCode as the end opcode
1180 EndGuidLabel
= (EFI_IFR_GUID_LABEL
*) HiiCreateGuidOpCode (EndOpCodeHandle
, &gEfiIfrTianoGuid
, NULL
, sizeof (EFI_IFR_GUID_LABEL
));
1181 EndGuidLabel
->ExtendOpCode
= EFI_IFR_EXTEND_OP_LABEL
;
1182 EndGuidLabel
->Number
= LABEL_FORM_MAIN_END
;
1185 //Updata Front Page form
1187 UiCustomizeBMMPage (
1188 mBmmCallbackInfo
->BmmHiiHandle
,
1193 mBmmCallbackInfo
->BmmHiiHandle
,
1200 HiiFreeOpCodeHandle (StartOpCodeHandle
);
1201 HiiFreeOpCodeHandle (EndOpCodeHandle
);
1205 Create dynamic code for BMM and initialize all of BMM configuration data in BmmFakeNvData and
1206 BmmOldFakeNVData member in BMM context data.
1208 @param CallbackData The BMM context data.
1212 InitializeBmmConfig (
1213 IN BMM_CALLBACK_DATA
*CallbackData
1216 BM_MENU_ENTRY
*NewMenuEntry
;
1217 BM_LOAD_CONTEXT
*NewLoadContext
;
1220 ASSERT (CallbackData
!= NULL
);
1223 // Initialize data which located in BMM main page
1225 CallbackData
->BmmFakeNvData
.BootNext
= NONE_BOOTNEXT_VALUE
;
1226 for (Index
= 0; Index
< BootOptionMenu
.MenuNumber
; Index
++) {
1227 NewMenuEntry
= BOpt_GetMenuEntry (&BootOptionMenu
, Index
);
1228 NewLoadContext
= (BM_LOAD_CONTEXT
*) NewMenuEntry
->VariableContext
;
1230 if (NewLoadContext
->IsBootNext
) {
1231 CallbackData
->BmmFakeNvData
.BootNext
= Index
;
1236 CallbackData
->BmmFakeNvData
.BootTimeOut
= PcdGet16 (PcdPlatformBootTimeOut
);
1239 // Initialize data which located in Boot Options Menu
1241 GetBootOrder (CallbackData
);
1244 // Initialize data which located in Driver Options Menu
1246 GetDriverOrder (CallbackData
);
1249 // Initialize data which located in Console Options Menu
1251 GetConsoleOutMode (CallbackData
);
1252 GetConsoleInCheck (CallbackData
);
1253 GetConsoleOutCheck (CallbackData
);
1254 GetConsoleErrCheck (CallbackData
);
1255 GetTerminalAttribute (CallbackData
);
1257 CallbackData
->BmmFakeNvData
.ForceReconnect
= TRUE
;
1260 // Backup Initialize BMM configuartion data to BmmOldFakeNVData
1262 CopyMem (&CallbackData
->BmmOldFakeNVData
, &CallbackData
->BmmFakeNvData
, sizeof (BMM_FAKE_NV_DATA
));
1266 Initialized all Menu Option List.
1268 @param CallbackData The BMM context data.
1273 IN BMM_CALLBACK_DATA
*CallbackData
1276 InitializeListHead (&BootOptionMenu
.Head
);
1277 InitializeListHead (&DriverOptionMenu
.Head
);
1278 BOpt_GetBootOptions (CallbackData
);
1279 BOpt_GetDriverOptions (CallbackData
);
1280 BOpt_FindDrivers ();
1281 InitializeListHead (&ConsoleInpMenu
.Head
);
1282 InitializeListHead (&ConsoleOutMenu
.Head
);
1283 InitializeListHead (&ConsoleErrMenu
.Head
);
1284 InitializeListHead (&TerminalMenu
.Head
);
1287 mAllMenuInit
= TRUE
;
1291 Free up all Menu Option list.
1302 BOpt_FreeMenu (&BootOptionMenu
);
1303 BOpt_FreeMenu (&DriverOptionMenu
);
1304 BOpt_FreeMenu (&DriverMenu
);
1306 mAllMenuInit
= FALSE
;
1310 Initial the boot mode related parameters.
1314 BmmInitialBootModeInfo (
1319 EFI_GRAPHICS_OUTPUT_PROTOCOL
*GraphicsOutput
;
1320 EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL
*SimpleTextOut
;
1321 UINTN BootTextColumn
;
1324 if (mBmmModeInitialized
) {
1329 // After the console is ready, get current video resolution
1330 // and text mode before launching setup at first time.
1332 Status
= gBS
->HandleProtocol (
1333 gST
->ConsoleOutHandle
,
1334 &gEfiGraphicsOutputProtocolGuid
,
1335 (VOID
**)&GraphicsOutput
1337 if (EFI_ERROR (Status
)) {
1338 GraphicsOutput
= NULL
;
1341 Status
= gBS
->HandleProtocol (
1342 gST
->ConsoleOutHandle
,
1343 &gEfiSimpleTextOutProtocolGuid
,
1344 (VOID
**)&SimpleTextOut
1346 if (EFI_ERROR (Status
)) {
1347 SimpleTextOut
= NULL
;
1350 if (GraphicsOutput
!= NULL
) {
1352 // Get current video resolution and text mode.
1354 mBmmBootHorizontalResolution
= GraphicsOutput
->Mode
->Info
->HorizontalResolution
;
1355 mBmmBootVerticalResolution
= GraphicsOutput
->Mode
->Info
->VerticalResolution
;
1358 if (SimpleTextOut
!= NULL
) {
1359 Status
= SimpleTextOut
->QueryMode (
1361 SimpleTextOut
->Mode
->Mode
,
1365 mBmmBootTextModeColumn
= (UINT32
)BootTextColumn
;
1366 mBmmBootTextModeRow
= (UINT32
)BootTextRow
;
1370 // Get user defined text mode for setup.
1372 mBmmSetupHorizontalResolution
= PcdGet32 (PcdSetupVideoHorizontalResolution
);
1373 mBmmSetupVerticalResolution
= PcdGet32 (PcdSetupVideoVerticalResolution
);
1374 mBmmSetupTextModeColumn
= PcdGet32 (PcdSetupConOutColumn
);
1375 mBmmSetupTextModeRow
= PcdGet32 (PcdSetupConOutRow
);
1377 mBmmModeInitialized
= TRUE
;
1382 Install Boot Maintenance Manager Menu driver.
1384 @param ImageHandle The image handle.
1385 @param SystemTable The system table.
1387 @retval EFI_SUCEESS Install Boot manager menu success.
1388 @retval Other Return error status.
1393 BootMaintenanceManagerUiLibConstructor (
1394 IN EFI_HANDLE ImageHandle
,
1395 IN EFI_SYSTEM_TABLE
*SystemTable
1402 Status
= EFI_SUCCESS
;
1405 // Install Device Path Protocol and Config Access protocol to driver handle
1407 Status
= gBS
->InstallMultipleProtocolInterfaces (
1408 &mBmmCallbackInfo
->BmmDriverHandle
,
1409 &gEfiDevicePathProtocolGuid
,
1410 &mBmmHiiVendorDevicePath
,
1411 &gEfiHiiConfigAccessProtocolGuid
,
1412 &mBmmCallbackInfo
->BmmConfigAccess
,
1415 ASSERT_EFI_ERROR (Status
);
1418 // Post our Boot Maint VFR binary to the HII database.
1420 mBmmCallbackInfo
->BmmHiiHandle
= HiiAddPackages (
1422 mBmmCallbackInfo
->BmmDriverHandle
,
1423 BootMaintenanceManagerBin
,
1424 BootMaintenanceManagerUiLibStrings
,
1427 ASSERT (mBmmCallbackInfo
->BmmHiiHandle
!= NULL
);
1430 // Locate Formbrowser2 protocol
1432 Status
= gBS
->LocateProtocol (&gEfiFormBrowser2ProtocolGuid
, NULL
, (VOID
**) &mBmmCallbackInfo
->FormBrowser2
);
1433 ASSERT_EFI_ERROR (Status
);
1435 EfiBootManagerRefreshAllBootOption ();
1438 // Create LoadOption in BmmCallbackInfo for Driver Callback
1440 Ptr
= AllocateZeroPool (sizeof (BM_LOAD_CONTEXT
) + sizeof (BM_FILE_CONTEXT
) + sizeof (BM_HANDLE_CONTEXT
) + sizeof (BM_MENU_ENTRY
));
1441 ASSERT (Ptr
!= NULL
);
1444 // Initialize Bmm callback data.
1446 mBmmCallbackInfo
->LoadContext
= (BM_LOAD_CONTEXT
*) Ptr
;
1447 Ptr
+= sizeof (BM_LOAD_CONTEXT
);
1449 mBmmCallbackInfo
->FileContext
= (BM_FILE_CONTEXT
*) Ptr
;
1450 Ptr
+= sizeof (BM_FILE_CONTEXT
);
1452 mBmmCallbackInfo
->HandleContext
= (BM_HANDLE_CONTEXT
*) Ptr
;
1453 Ptr
+= sizeof (BM_HANDLE_CONTEXT
);
1455 mBmmCallbackInfo
->MenuEntry
= (BM_MENU_ENTRY
*) Ptr
;
1457 mBmmCallbackInfo
->BmmPreviousPageId
= FORM_MAIN_ID
;
1458 mBmmCallbackInfo
->BmmCurrentPageId
= FORM_MAIN_ID
;
1460 InitAllMenu (mBmmCallbackInfo
);
1464 // Update boot maintenance manager page
1466 InitializeBmmConfig(mBmmCallbackInfo
);
1468 BmmInitialBootModeInfo();
1474 Unloads the application and its installed protocol.
1476 @param ImageHandle Handle that identifies the image to be unloaded.
1477 @param SystemTable The system table.
1479 @retval EFI_SUCCESS The image has been unloaded.
1484 BootMaintenanceManagerUiLibDestructor (
1485 IN EFI_HANDLE ImageHandle
,
1486 IN EFI_SYSTEM_TABLE
*SystemTable
1490 if (mStartOpCodeHandle
!= NULL
) {
1491 HiiFreeOpCodeHandle (mStartOpCodeHandle
);
1494 if (mEndOpCodeHandle
!= NULL
) {
1495 HiiFreeOpCodeHandle (mEndOpCodeHandle
);
1501 // Remove our IFR data from HII database
1503 HiiRemovePackages (mBmmCallbackInfo
->BmmHiiHandle
);
1505 gBS
->UninstallMultipleProtocolInterfaces (
1506 mBmmCallbackInfo
->BmmDriverHandle
,
1507 &gEfiDevicePathProtocolGuid
,
1508 &mBmmHiiVendorDevicePath
,
1509 &gEfiHiiConfigAccessProtocolGuid
,
1510 &mBmmCallbackInfo
->BmmConfigAccess
,
1514 FreePool (mBmmCallbackInfo
->LoadContext
);