2 FrontPage routines to handle the callbacks and browser calls
4 Copyright (c) 2004 - 2008, 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.
16 #include "FrontPage.h"
18 EFI_GUID mFrontPageGuid
= FRONT_PAGE_FORMSET_GUID
;
20 BOOLEAN gConnectAllHappened
= FALSE
;
23 EFI_HII_DATABASE_PROTOCOL
*gHiiDatabase
;
24 EFI_HII_STRING_PROTOCOL
*gHiiString
;
25 EFI_FORM_BROWSER2_PROTOCOL
*gFormBrowser2
;
26 EFI_HII_CONFIG_ROUTING_PROTOCOL
*gHiiConfigRouting
;
28 FRONT_PAGE_CALLBACK_DATA gFrontPagePrivate
= {
29 FRONT_PAGE_CALLBACK_DATA_SIGNATURE
,
41 This function allows a caller to extract the current configuration for one
42 or more named elements from the target driver.
45 @param This - Points to the EFI_HII_CONFIG_ACCESS_PROTOCOL.
46 @param Request - A null-terminated Unicode string in <ConfigRequest> format.
47 @param Progress - On return, points to a character in the Request string.
48 Points to the string's null terminator if request was successful.
49 Points to the most recent '&' before the first failing name/value
50 pair (or the beginning of the string if the failure is in the
51 first name/value pair) if the request was not successful.
52 @param Results - A null-terminated Unicode string in <ConfigAltResp> format which
53 has all values filled in for the names in the Request string.
54 String to be allocated by the called function.
56 @retval EFI_SUCCESS The Results is filled with the requested values.
57 @retval EFI_OUT_OF_RESOURCES Not enough memory to store the results.
58 @retval EFI_INVALID_PARAMETER Request is NULL, illegal syntax, or unknown name.
59 @retval EFI_NOT_FOUND Routing data doesn't match any storage in this driver.
65 IN CONST EFI_HII_CONFIG_ACCESS_PROTOCOL
*This
,
66 IN CONST EFI_STRING Request
,
67 OUT EFI_STRING
*Progress
,
68 OUT EFI_STRING
*Results
75 This function processes the results of changes in configuration.
78 @param This - Points to the EFI_HII_CONFIG_ACCESS_PROTOCOL.
79 @param Configuration - A null-terminated Unicode string in <ConfigResp> format.
80 @param Progress - A pointer to a string filled in with the offset of the most
81 recent '&' before the first failing name/value pair (or the
82 beginning of the string if the failure is in the first
83 name/value pair) or the terminating NULL if all was successful.
85 @retval EFI_SUCCESS The Results is processed successfully.
86 @retval EFI_INVALID_PARAMETER Configuration is NULL.
87 @retval EFI_NOT_FOUND Routing data doesn't match any storage in this driver.
93 IN CONST EFI_HII_CONFIG_ACCESS_PROTOCOL
*This
,
94 IN CONST EFI_STRING Configuration
,
95 OUT EFI_STRING
*Progress
102 This function processes the results of changes in configuration.
105 @param This - Points to the EFI_HII_CONFIG_ACCESS_PROTOCOL.
106 @param Action - Specifies the type of action taken by the browser.
107 @param QuestionId - A unique value which is sent to the original exporting driver
108 so that it can identify the type of data to expect.
109 @param Type - The type of value for the question.
110 @param Value - A pointer to the data being sent to the original exporting driver.
111 @param ActionRequest - On return, points to the action requested by the callback function.
113 @retval EFI_SUCCESS The callback successfully handled the action.
114 @retval EFI_OUT_OF_RESOURCES Not enough storage is available to hold the variable and its data.
115 @retval EFI_DEVICE_ERROR The variable could not be saved.
116 @retval EFI_UNSUPPORTED The specified Action is not supported by the callback.
122 IN CONST EFI_HII_CONFIG_ACCESS_PROTOCOL
*This
,
123 IN EFI_BROWSER_ACTION Action
,
124 IN EFI_QUESTION_ID QuestionId
,
126 IN EFI_IFR_TYPE_VALUE
*Value
,
127 OUT EFI_BROWSER_ACTION_REQUEST
*ActionRequest
130 CHAR8
*LanguageString
;
132 CHAR8 Lang
[RFC_3066_ENTRY_SIZE
];
133 CHAR8 OldLang
[ISO_639_2_ENTRY_SIZE
];
137 if ((Value
== NULL
) || (ActionRequest
== NULL
)) {
138 return EFI_INVALID_PARAMETER
;
141 gCallbackKey
= QuestionId
;
144 // The first 4 entries in the Front Page are to be GUARANTEED to remain constant so IHV's can
145 // describe to their customers in documentation how to find their setup information (namely
146 // under the device manager and specific buckets)
148 switch (QuestionId
) {
149 case FRONT_PAGE_KEY_CONTINUE
:
151 // This is the continue - clear the screen and return an error to get out of FrontPage loop
155 case FRONT_PAGE_KEY_LANGUAGE
:
157 // Collect the languages from what our current Language support is based on our VFR
159 LanguageString
= HiiLibGetSupportedLanguages (gFrontPagePrivate
.HiiHandle
);
160 ASSERT (LanguageString
!= NULL
);
163 LangCode
= LanguageString
;
164 while (*LangCode
!= 0) {
165 HiiLibGetNextLanguage (&LangCode
, Lang
);
167 if (Index
== Value
->u8
) {
174 Status
= gRT
->SetVariable (
176 &gEfiGlobalVariableGuid
,
177 EFI_VARIABLE_NON_VOLATILE
| EFI_VARIABLE_BOOTSERVICE_ACCESS
| EFI_VARIABLE_RUNTIME_ACCESS
,
182 if (!FeaturePcdGet (PcdUefiVariableDefaultLangDepricate
)) {
184 // Set UEFI deprecated variable "Lang" for backwards compatibility
186 Status
= ConvertRfc3066LanguageToIso639Language (Lang
, OldLang
);
187 if (!EFI_ERROR (Status
)) {
188 Status
= gRT
->SetVariable (
190 &gEfiGlobalVariableGuid
,
191 EFI_VARIABLE_NON_VOLATILE
| EFI_VARIABLE_BOOTSERVICE_ACCESS
| EFI_VARIABLE_RUNTIME_ACCESS
,
192 ISO_639_2_ENTRY_SIZE
,
198 FreePool (LanguageString
);
201 case FRONT_PAGE_KEY_BOOT_MANAGER
:
207 case FRONT_PAGE_KEY_DEVICE_MANAGER
:
213 case FRONT_PAGE_KEY_BOOT_MAINTAIN
:
215 // Boot Maintenance Manager
224 *ActionRequest
= EFI_BROWSER_ACTION_REQUEST_EXIT
;
230 Initialize HII information for the FrontPage
233 @param InitializeHiiData TRUE if HII elements need to be initialized.
235 @retval EFI_SUCCESS The operation is successful.
236 @retval EFI_DEVICE_ERROR If the dynamic opcode creation failed.
240 InitializeFrontPage (
241 IN BOOLEAN InitializeHiiData
245 EFI_HII_PACKAGE_LIST_HEADER
*PackageList
;
246 EFI_HII_UPDATE_DATA UpdateData
;
247 IFR_OPTION
*OptionList
;
248 CHAR8
*LanguageString
;
250 CHAR8 Lang
[RFC_3066_ENTRY_SIZE
];
251 CHAR8 CurrentLang
[RFC_3066_ENTRY_SIZE
];
254 CHAR16
*StringBuffer
;
257 EFI_HII_HANDLE HiiHandle
;
259 if (InitializeHiiData
) {
261 // Initialize the Device Manager
263 InitializeDeviceManager ();
266 // Initialize the Device Manager
268 InitializeBootManager ();
273 // Locate Hii relative protocols
275 Status
= gBS
->LocateProtocol (&gEfiHiiDatabaseProtocolGuid
, NULL
, (VOID
**) &gHiiDatabase
);
276 if (EFI_ERROR (Status
)) {
280 Status
= gBS
->LocateProtocol (&gEfiHiiStringProtocolGuid
, NULL
, (VOID
**) &gHiiString
);
281 if (EFI_ERROR (Status
)) {
285 Status
= gBS
->LocateProtocol (&gEfiFormBrowser2ProtocolGuid
, NULL
, (VOID
**) &gFormBrowser2
);
286 if (EFI_ERROR (Status
)) {
290 Status
= gBS
->LocateProtocol (&gEfiHiiConfigRoutingProtocolGuid
, NULL
, (VOID
**) &gHiiConfigRouting
);
291 if (EFI_ERROR (Status
)) {
296 // Create driver handle used by HII database
298 Status
= HiiLibCreateHiiDriverHandle (&gFrontPagePrivate
.DriverHandle
);
299 if (EFI_ERROR (Status
)) {
304 // Install Config Access protocol to driver handle
306 Status
= gBS
->InstallProtocolInterface (
307 &gFrontPagePrivate
.DriverHandle
,
308 &gEfiHiiConfigAccessProtocolGuid
,
309 EFI_NATIVE_INTERFACE
,
310 &gFrontPagePrivate
.ConfigAccess
312 ASSERT_EFI_ERROR (Status
);
315 // Publish our HII data
317 PackageList
= HiiLibPreparePackageList (2, &mFrontPageGuid
, FrontPageVfrBin
, BdsDxeStrings
);
318 ASSERT (PackageList
!= NULL
);
320 Status
= gHiiDatabase
->NewPackageList (
323 gFrontPagePrivate
.DriverHandle
,
324 &gFrontPagePrivate
.HiiHandle
326 FreePool (PackageList
);
327 if (EFI_ERROR (Status
)) {
333 // Get current language setting
335 HiiLibGetCurrentLanguage (CurrentLang
);
338 // Allocate space for creation of UpdateData Buffer
340 UpdateData
.BufferSize
= 0x1000;
341 UpdateData
.Data
= AllocateZeroPool (0x1000);
342 ASSERT (UpdateData
.Data
!= NULL
);
344 OptionList
= AllocateZeroPool (0x1000);
345 ASSERT (OptionList
!= NULL
);
348 // Collect the languages from what our current Language support is based on our VFR
350 HiiHandle
= gFrontPagePrivate
.HiiHandle
;
351 LanguageString
= HiiLibGetSupportedLanguages (HiiHandle
);
352 ASSERT (LanguageString
!= NULL
);
355 LangCode
= LanguageString
;
356 while (*LangCode
!= 0) {
357 HiiLibGetNextLanguage (&LangCode
, Lang
);
359 if (gFrontPagePrivate
.LanguageToken
== NULL
) {
361 // Get Language Name from String Package. The StringId of Printable Language
362 // Name is always 1 which is generated by StringGather Tool.
365 StringBuffer
= AllocatePool (BufferSize
);
366 Status
= gHiiString
->GetString (
370 PRINTABLE_LANGUAGE_NAME_STRING_ID
,
375 if (Status
== EFI_BUFFER_TOO_SMALL
) {
376 FreePool (StringBuffer
);
377 StringBuffer
= AllocatePool (BufferSize
);
378 Status
= gHiiString
->GetString (
382 PRINTABLE_LANGUAGE_NAME_STRING_ID
,
388 ASSERT_EFI_ERROR (Status
);
391 Status
= HiiLibNewString (HiiHandle
, &Token
, StringBuffer
);
392 FreePool (StringBuffer
);
394 Token
= gFrontPagePrivate
.LanguageToken
[OptionCount
];
397 if (AsciiStrCmp (Lang
, CurrentLang
) == 0) {
398 OptionList
[OptionCount
].Flags
= EFI_IFR_OPTION_DEFAULT
;
400 OptionList
[OptionCount
].Flags
= 0;
402 OptionList
[OptionCount
].StringToken
= Token
;
403 OptionList
[OptionCount
].Value
.u8
= (UINT8
) OptionCount
;
408 FreePool (LanguageString
);
410 UpdateData
.Offset
= 0;
412 FRONT_PAGE_KEY_LANGUAGE
,
415 STRING_TOKEN (STR_LANGUAGE_SELECT
),
416 STRING_TOKEN (STR_LANGUAGE_SELECT_HELP
),
417 EFI_IFR_FLAG_CALLBACK
,
418 EFI_IFR_NUMERIC_SIZE_1
,
424 Status
= IfrLibUpdateForm (
428 LABEL_SELECT_LANGUAGE
,
434 // Save the string Id for each language
436 gFrontPagePrivate
.LanguageToken
= AllocatePool (OptionCount
* sizeof (EFI_STRING_ID
));
437 ASSERT (gFrontPagePrivate
.LanguageToken
!= NULL
);
438 for (Index
= 0; Index
< OptionCount
; Index
++) {
439 gFrontPagePrivate
.LanguageToken
[Index
] = OptionList
[Index
].StringToken
;
442 FreePool (UpdateData
.Data
);
443 FreePool (OptionList
);
448 Call the browser and display the front page
451 @param VOID No input.
453 @return Status code that will be returned by
454 EFI_FORM_BROWSER2_PROTOCOL.SendForm ().
463 EFI_BROWSER_ACTION_REQUEST ActionRequest
;
466 // Begin waiting for USER INPUT
470 (EFI_SOFTWARE_DXE_BS_DRIVER
| EFI_SW_PC_INPUT_WAIT
)
475 // Drop the TPL level from TPL_APPLICATION to TPL_APPLICATION
477 gBS
->RestoreTPL (TPL_APPLICATION
);
479 ActionRequest
= EFI_BROWSER_ACTION_REQUEST_NONE
;
480 Status
= gFormBrowser2
->SendForm (
482 &gFrontPagePrivate
.HiiHandle
,
490 // Check whether user change any option setting which needs a reset to be effective
492 if (ActionRequest
== EFI_BROWSER_ACTION_REQUEST_RESET
) {
493 EnableResetRequired ();
496 gBS
->RaiseTPL (TPL_APPLICATION
);
501 Acquire the string associated with the ProducerGuid and return it.
504 @param ProducerGuid - The Guid to search the HII database for
505 @param Token - The token value of the string to extract
506 @param String - The string that is extracted
508 @retval EFI_SUCCESS The function returns EFI_SUCCESS always.
513 IN EFI_GUID
*ProducerGuid
,
514 IN EFI_STRING_ID Token
,
520 Status
= HiiLibGetStringFromToken (ProducerGuid
, Token
, String
);
521 if (EFI_ERROR (Status
)) {
522 *String
= GetStringById (STRING_TOKEN (STR_MISSING_STRING
));
529 Convert Processor Frequency Data to a string
532 @param ProcessorFrequency - The frequency data to process
533 @param String - The string that is created
539 ConvertProcessorToString (
540 IN EFI_PROCESSOR_CORE_FREQUENCY_DATA
*ProcessorFrequency
,
544 CHAR16
*StringBuffer
;
548 if (ProcessorFrequency
->Exponent
>= 6) {
549 FreqMhz
= ProcessorFrequency
->Value
;
550 for (Index
= 0; Index
< (UINTN
) (ProcessorFrequency
->Exponent
- 6); Index
++) {
557 StringBuffer
= AllocateZeroPool (0x20);
558 ASSERT (StringBuffer
!= NULL
);
559 Index
= UnicodeValueToString (StringBuffer
, LEFT_JUSTIFY
, FreqMhz
/ 1000, 3);
560 StrCat (StringBuffer
, L
".");
561 UnicodeValueToString (StringBuffer
+ Index
+ 1, PREFIX_ZERO
, (FreqMhz
% 1000) / 10, 2);
562 StrCat (StringBuffer
, L
" GHz");
564 *String
= (CHAR16
*) StringBuffer
;
570 Convert Memory Size to a string
573 @param MemorySize - The size of the memory to process
574 @param String - The string that is created
580 ConvertMemorySizeToString (
581 IN UINT32 MemorySize
,
585 CHAR16
*StringBuffer
;
587 StringBuffer
= AllocateZeroPool (0x20);
588 ASSERT (StringBuffer
!= NULL
);
589 UnicodeValueToString (StringBuffer
, LEFT_JUSTIFY
, MemorySize
, 6);
590 StrCat (StringBuffer
, L
" MB RAM");
592 *String
= (CHAR16
*) StringBuffer
;
598 Update the banner information for the Front Page based on DataHub information.
602 UpdateFrontPageStrings (
607 EFI_STRING_ID TokenToUpdate
;
609 UINT64 MonotonicCount
;
610 EFI_DATA_HUB_PROTOCOL
*DataHub
;
611 EFI_DATA_RECORD_HEADER
*Record
;
612 EFI_SUBCLASS_TYPE1_HEADER
*DataHeader
;
613 EFI_MISC_BIOS_VENDOR_DATA
*BiosVendor
;
614 EFI_MISC_SYSTEM_MANUFACTURER_DATA
*SystemManufacturer
;
615 EFI_PROCESSOR_VERSION_DATA
*ProcessorVersion
;
616 EFI_PROCESSOR_CORE_FREQUENCY_DATA
*ProcessorFrequency
;
617 EFI_MEMORY_ARRAY_START_ADDRESS_DATA
*MemoryArray
;
620 ZeroMem (Find
, sizeof (Find
));
623 // Update Front Page strings
625 Status
= gBS
->LocateProtocol (
626 &gEfiDataHubProtocolGuid
,
630 ASSERT_EFI_ERROR (Status
);
635 Status
= DataHub
->GetNextRecord (DataHub
, &MonotonicCount
, NULL
, &Record
);
636 if (Record
->DataRecordClass
== EFI_DATA_RECORD_CLASS_DATA
) {
637 DataHeader
= (EFI_SUBCLASS_TYPE1_HEADER
*) (Record
+ 1);
638 if (CompareGuid (&Record
->DataRecordGuid
, &gEfiMiscSubClassGuid
) &&
639 (DataHeader
->RecordType
== EFI_MISC_BIOS_VENDOR_RECORD_NUMBER
)
641 BiosVendor
= (EFI_MISC_BIOS_VENDOR_DATA
*) (DataHeader
+ 1);
642 GetProducerString (&Record
->ProducerName
, BiosVendor
->BiosVersion
, &NewString
);
643 TokenToUpdate
= STRING_TOKEN (STR_FRONT_PAGE_BIOS_VERSION
);
644 HiiLibSetString (gFrontPagePrivate
.HiiHandle
, TokenToUpdate
, NewString
);
645 FreePool (NewString
);
649 if (CompareGuid (&Record
->DataRecordGuid
, &gEfiMiscSubClassGuid
) &&
650 (DataHeader
->RecordType
== EFI_MISC_SYSTEM_MANUFACTURER_RECORD_NUMBER
)
652 SystemManufacturer
= (EFI_MISC_SYSTEM_MANUFACTURER_DATA
*) (DataHeader
+ 1);
653 GetProducerString (&Record
->ProducerName
, SystemManufacturer
->SystemProductName
, &NewString
);
654 TokenToUpdate
= STRING_TOKEN (STR_FRONT_PAGE_COMPUTER_MODEL
);
655 HiiLibSetString (gFrontPagePrivate
.HiiHandle
, TokenToUpdate
, NewString
);
656 FreePool (NewString
);
660 if (CompareGuid (&Record
->DataRecordGuid
, &gEfiProcessorSubClassGuid
) &&
661 (DataHeader
->RecordType
== ProcessorVersionRecordType
)
663 ProcessorVersion
= (EFI_PROCESSOR_VERSION_DATA
*) (DataHeader
+ 1);
664 GetProducerString (&Record
->ProducerName
, *ProcessorVersion
, &NewString
);
665 TokenToUpdate
= STRING_TOKEN (STR_FRONT_PAGE_CPU_MODEL
);
666 HiiLibSetString (gFrontPagePrivate
.HiiHandle
, TokenToUpdate
, NewString
);
667 FreePool (NewString
);
671 if (CompareGuid (&Record
->DataRecordGuid
, &gEfiProcessorSubClassGuid
) &&
672 (DataHeader
->RecordType
== ProcessorCoreFrequencyRecordType
)
674 ProcessorFrequency
= (EFI_PROCESSOR_CORE_FREQUENCY_DATA
*) (DataHeader
+ 1);
675 ConvertProcessorToString (ProcessorFrequency
, &NewString
);
676 TokenToUpdate
= STRING_TOKEN (STR_FRONT_PAGE_CPU_SPEED
);
677 HiiLibSetString (gFrontPagePrivate
.HiiHandle
, TokenToUpdate
, NewString
);
678 FreePool (NewString
);
682 if (CompareGuid (&Record
->DataRecordGuid
, &gEfiMemorySubClassGuid
) &&
683 (DataHeader
->RecordType
== EFI_MEMORY_ARRAY_START_ADDRESS_RECORD_NUMBER
)
685 MemoryArray
= (EFI_MEMORY_ARRAY_START_ADDRESS_DATA
*) (DataHeader
+ 1);
686 ConvertMemorySizeToString (
687 (UINT32
)(RShiftU64((MemoryArray
->MemoryArrayEndAddress
- MemoryArray
->MemoryArrayStartAddress
+ 1), 20)),
690 TokenToUpdate
= STRING_TOKEN (STR_FRONT_PAGE_MEMORY_SIZE
);
691 HiiLibSetString (gFrontPagePrivate
.HiiHandle
, TokenToUpdate
, NewString
);
692 FreePool (NewString
);
696 } while (!EFI_ERROR (Status
) && (MonotonicCount
!= 0) && !(Find
[0] && Find
[1] && Find
[2] && Find
[3] && Find
[4]));
702 Function waits for a given event to fire, or for an optional timeout to expire.
705 @param Event The event to wait for
707 @param Timeout An optional timeout value in 100 ns units.
709 @retval EFI_SUCCESS Event fired before Timeout expired.
710 @retval EFI_TIME_OUT Timout expired before Event fired..
716 IN UINT64 Timeout OPTIONAL
721 EFI_EVENT TimerEvent
;
722 EFI_EVENT WaitList
[2];
726 // Create a timer event
728 Status
= gBS
->CreateEvent (EVT_TIMER
, 0, NULL
, NULL
, &TimerEvent
);
729 if (!EFI_ERROR (Status
)) {
731 // Set the timer event
740 // Wait for the original event or the timer
743 WaitList
[1] = TimerEvent
;
744 Status
= gBS
->WaitForEvent (2, WaitList
, &Index
);
745 gBS
->CloseEvent (TimerEvent
);
748 // If the timer expired, change the return to timed out
750 if (!EFI_ERROR (Status
) && Index
== 1) {
751 Status
= EFI_TIMEOUT
;
756 // No timeout... just wait on the event
758 Status
= gBS
->WaitForEvent (1, &Event
, &Index
);
759 ASSERT (!EFI_ERROR (Status
));
767 Function show progress bar to wait for user input.
770 @param TimeoutDefault - The fault time out value before the system
773 @retval EFI_SUCCESS User pressed some key except "Enter"
774 @retval EFI_TIME_OUT Timout expired or user press "Enter"
779 IN UINT16 TimeoutDefault
784 EFI_GRAPHICS_OUTPUT_BLT_PIXEL Foreground
;
785 EFI_GRAPHICS_OUTPUT_BLT_PIXEL Background
;
786 EFI_GRAPHICS_OUTPUT_BLT_PIXEL Color
;
788 UINT16 TimeoutRemain
;
790 if (TimeoutDefault
== 0) {
794 DEBUG ((EFI_D_INFO
, "\n\nStart showing progress bar... Press any key to stop it! ...Zzz....\n"));
796 SetMem (&Foreground
, sizeof (EFI_GRAPHICS_OUTPUT_BLT_PIXEL
), 0xff);
797 SetMem (&Background
, sizeof (EFI_GRAPHICS_OUTPUT_BLT_PIXEL
), 0x0);
798 SetMem (&Color
, sizeof (EFI_GRAPHICS_OUTPUT_BLT_PIXEL
), 0xff);
801 // Clear the progress status bar first
803 TmpStr
= GetStringById (STRING_TOKEN (STR_START_BOOT_OPTION
));
804 if (TmpStr
!= NULL
) {
805 PlatformBdsShowProgress (Foreground
, Background
, TmpStr
, Color
, 0, 0);
808 TimeoutRemain
= TimeoutDefault
;
809 while (TimeoutRemain
!= 0) {
810 DEBUG ((EFI_D_INFO
, "Showing progress bar...Remaining %d second!\n", TimeoutRemain
));
812 Status
= WaitForSingleEvent (gST
->ConIn
->WaitForKey
, ONE_SECOND
);
813 if (Status
!= EFI_TIMEOUT
) {
821 if (TmpStr
!= NULL
) {
822 PlatformBdsShowProgress (
827 ((TimeoutDefault
- TimeoutRemain
) * 100 / TimeoutDefault
),
832 gBS
->FreePool (TmpStr
);
837 if (TimeoutRemain
== 0) {
842 // User pressed some key
844 Status
= gST
->ConIn
->ReadKeyStroke (gST
->ConIn
, &Key
);
845 if (EFI_ERROR (Status
)) {
849 if (Key
.UnicodeChar
== CHAR_CARRIAGE_RETURN
) {
851 // User pressed enter, equivalent to select "continue"
860 This function is the main entry of the platform setup entry.
861 The function will present the main menu of the system setup,
862 this is the platform reference part and can be customize.
865 @param TimeoutDefault - The fault time out value before the system
867 @param ConnectAllHappened - The indicater to check if the connect all have
874 PlatformBdsEnterFrontPage (
875 IN UINT16 TimeoutDefault
,
876 IN BOOLEAN ConnectAllHappened
880 EFI_CONSOLE_CONTROL_PROTOCOL
*ConsoleControl
;
882 PERF_START (0, "BdsTimeOut", "BDS", 0);
884 // Indicate if we need connect all in the platform setup
886 if (ConnectAllHappened
) {
887 gConnectAllHappened
= TRUE
;
890 if (TimeoutDefault
!= 0xffff) {
891 gBS
->RestoreTPL (TPL_APPLICATION
);
892 Status
= ShowProgress (TimeoutDefault
);
893 gBS
->RaiseTPL (TPL_APPLICATION
);
895 if (EFI_ERROR (Status
)) {
897 // Timeout or user press enter to continue
899 gST
->ConOut
->EnableCursor (gST
->ConOut
, TRUE
);
900 gST
->ConOut
->ClearScreen (gST
->ConOut
);
907 InitializeFrontPage (FALSE
);
910 // Update Front Page strings
912 UpdateFrontPageStrings ();
915 Status
= CallFrontPage ();
918 // If gCallbackKey is greater than 1 and less or equal to 5,
919 // it will lauch configuration utilities.
922 // 4 = device manager
923 // 5 = boot maintainenance manager
925 if (gCallbackKey
!= 0) {
928 (EFI_SOFTWARE_DXE_BS_DRIVER
| EFI_SW_PC_USER_SETUP
)
932 // Based on the key that was set, we can determine what to do
934 switch (gCallbackKey
) {
936 // The first 4 entries in the Front Page are to be GUARANTEED to remain constant so IHV's can
937 // describe to their customers in documentation how to find their setup information (namely
938 // under the device manager and specific buckets)
940 // These entries consist of the Continue, Select language, Boot Manager, and Device Manager
942 case FRONT_PAGE_KEY_CONTINUE
:
948 case FRONT_PAGE_KEY_LANGUAGE
:
950 // User made a language setting change - display front page again
954 case FRONT_PAGE_KEY_BOOT_MANAGER
:
956 // User chose to run the Boot Manager
961 case FRONT_PAGE_KEY_DEVICE_MANAGER
:
963 // Display the Device Manager
967 } while (gCallbackKey
== FRONT_PAGE_KEY_DEVICE_MANAGER
);
970 case FRONT_PAGE_KEY_BOOT_MAINTAIN
:
972 // Display the Boot Maintenance Manager
974 BdsStartBootMaint ();
978 } while ((Status
== EFI_SUCCESS
) && (gCallbackKey
!= FRONT_PAGE_KEY_CONTINUE
));
981 //Will leave browser, check any reset required change is applied? if yes, reset system
983 gBS
->RestoreTPL (TPL_APPLICATION
);
984 SetupResetReminder ();
985 gBS
->RaiseTPL (TPL_APPLICATION
);
989 // Automatically load current entry
990 // Note: The following lines of code only execute when Auto boot
993 PERF_END (0, "BdsTimeOut", "BDS", 0);
994 Status
= gBS
->LocateProtocol (&gEfiConsoleControlProtocolGuid
, NULL
, (VOID
**) &ConsoleControl
);
995 ConsoleControl
->SetMode (ConsoleControl
, EfiConsoleControlScreenText
);