2 FrontPage routines to handle the callbacks and browser calls
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.
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
,
40 HII_VENDOR_DEVICE_PATH mFrontPageHiiVendorDevicePath
= {
46 (UINT8
) (sizeof (VENDOR_DEVICE_PATH
)),
47 (UINT8
) ((sizeof (VENDOR_DEVICE_PATH
)) >> 8)
51 // {8E6D99EE-7531-48f8-8745-7F6144468FF2}
53 { 0x8e6d99ee, 0x7531, 0x48f8, { 0x87, 0x45, 0x7f, 0x61, 0x44, 0x46, 0x8f, 0xf2 } }
57 END_ENTIRE_DEVICE_PATH_SUBTYPE
,
59 (UINT8
) (END_DEVICE_PATH_LENGTH
),
60 (UINT8
) ((END_DEVICE_PATH_LENGTH
) >> 8)
66 This function allows a caller to extract the current configuration for one
67 or more named elements from the target driver.
70 @param This Points to the EFI_HII_CONFIG_ACCESS_PROTOCOL.
71 @param Request A null-terminated Unicode string in <ConfigRequest> format.
72 @param Progress On return, points to a character in the Request string.
73 Points to the string's null terminator if request was successful.
74 Points to the most recent '&' before the first failing name/value
75 pair (or the beginning of the string if the failure is in the
76 first name/value pair) if the request was not successful.
77 @param Results A null-terminated Unicode string in <ConfigAltResp> format which
78 has all values filled in for the names in the Request string.
79 String to be allocated by the called function.
81 @retval EFI_SUCCESS The Results is filled with the requested values.
82 @retval EFI_OUT_OF_RESOURCES Not enough memory to store the results.
83 @retval EFI_INVALID_PARAMETER Request is NULL, illegal syntax, or unknown name.
84 @retval EFI_NOT_FOUND Routing data doesn't match any storage in this driver.
90 IN CONST EFI_HII_CONFIG_ACCESS_PROTOCOL
*This
,
91 IN CONST EFI_STRING Request
,
92 OUT EFI_STRING
*Progress
,
93 OUT EFI_STRING
*Results
100 This function processes the results of changes in configuration.
103 @param This Points to the EFI_HII_CONFIG_ACCESS_PROTOCOL.
104 @param Configuration A null-terminated Unicode string in <ConfigResp> format.
105 @param Progress A pointer to a string filled in with the offset of the most
106 recent '&' before the first failing name/value pair (or the
107 beginning of the string if the failure is in the first
108 name/value pair) or the terminating NULL if all was successful.
110 @retval EFI_SUCCESS The Results is processed successfully.
111 @retval EFI_INVALID_PARAMETER Configuration is NULL.
112 @retval EFI_NOT_FOUND Routing data doesn't match any storage in this driver.
118 IN CONST EFI_HII_CONFIG_ACCESS_PROTOCOL
*This
,
119 IN CONST EFI_STRING Configuration
,
120 OUT EFI_STRING
*Progress
127 This function processes the results of changes in configuration.
130 @param This Points to the EFI_HII_CONFIG_ACCESS_PROTOCOL.
131 @param Action Specifies the type of action taken by the browser.
132 @param QuestionId A unique value which is sent to the original exporting driver
133 so that it can identify the type of data to expect.
134 @param Type The type of value for the question.
135 @param Value A pointer to the data being sent to the original exporting driver.
136 @param ActionRequest On return, points to the action requested by the callback function.
138 @retval EFI_SUCCESS The callback successfully handled the action.
139 @retval EFI_OUT_OF_RESOURCES Not enough storage is available to hold the variable and its data.
140 @retval EFI_DEVICE_ERROR The variable could not be saved.
141 @retval EFI_UNSUPPORTED The specified Action is not supported by the callback.
147 IN CONST EFI_HII_CONFIG_ACCESS_PROTOCOL
*This
,
148 IN EFI_BROWSER_ACTION Action
,
149 IN EFI_QUESTION_ID QuestionId
,
151 IN EFI_IFR_TYPE_VALUE
*Value
,
152 OUT EFI_BROWSER_ACTION_REQUEST
*ActionRequest
155 CHAR8
*LanguageString
;
158 CHAR8 OldLang
[ISO_639_2_ENTRY_SIZE
];
161 CHAR8
*PlatformSupportedLanguages
;
164 if ((Value
== NULL
) || (ActionRequest
== NULL
)) {
165 return EFI_INVALID_PARAMETER
;
168 gCallbackKey
= QuestionId
;
171 // The first 4 entries in the Front Page are to be GUARANTEED to remain constant so IHV's can
172 // describe to their customers in documentation how to find their setup information (namely
173 // under the device manager and specific buckets)
175 switch (QuestionId
) {
176 case FRONT_PAGE_KEY_CONTINUE
:
178 // This is the continue - clear the screen and return an error to get out of FrontPage loop
182 case FRONT_PAGE_KEY_LANGUAGE
:
184 // Collect the languages from what our current Language support is based on our VFR
186 LanguageString
= HiiLibGetSupportedLanguages (gFrontPagePrivate
.HiiHandle
);
187 ASSERT (LanguageString
!= NULL
);
189 // Allocate working buffer for RFC 4646 language in supported LanguageString.
191 Lang
= AllocatePool (AsciiStrSize (LanguageString
));
192 ASSERT (Lang
!= NULL
);
195 LangCode
= LanguageString
;
196 while (*LangCode
!= 0) {
197 HiiLibGetNextLanguage (&LangCode
, Lang
);
199 if (Index
== Value
->u8
) {
206 PlatformSupportedLanguages
= GetEfiGlobalVariable (L
"PlatformLangCodes");
207 if (PlatformSupportedLanguages
== NULL
) {
208 PlatformSupportedLanguages
= AllocateCopyPool (
209 AsciiStrSize ((CHAR8
*) PcdGetPtr (PcdUefiVariableDefaultPlatformLangCodes
)),
210 (CHAR8
*) PcdGetPtr (PcdUefiVariableDefaultPlatformLangCodes
)
212 ASSERT (PlatformSupportedLanguages
!= NULL
);
216 // Select the best language in platform supported Language.
218 BestLanguage
= GetBestLanguage (
219 PlatformSupportedLanguages
,
224 if (BestLanguage
!= NULL
) {
225 Status
= gRT
->SetVariable (
227 &gEfiGlobalVariableGuid
,
228 EFI_VARIABLE_NON_VOLATILE
| EFI_VARIABLE_BOOTSERVICE_ACCESS
| EFI_VARIABLE_RUNTIME_ACCESS
,
229 AsciiStrSize (BestLanguage
),
233 if (!FeaturePcdGet (PcdUefiVariableDefaultLangDeprecate
)) {
235 // Set UEFI deprecated variable "Lang" for backwards compatibility
237 Status
= ConvertRfc3066LanguageToIso639Language (BestLanguage
, OldLang
);
238 if (!EFI_ERROR (Status
)) {
239 Status
= gRT
->SetVariable (
241 &gEfiGlobalVariableGuid
,
242 EFI_VARIABLE_NON_VOLATILE
| EFI_VARIABLE_BOOTSERVICE_ACCESS
| EFI_VARIABLE_RUNTIME_ACCESS
,
243 ISO_639_2_ENTRY_SIZE
,
248 FreePool (BestLanguage
);
251 FreePool (PlatformSupportedLanguages
);
253 FreePool (LanguageString
);
256 case FRONT_PAGE_KEY_BOOT_MANAGER
:
262 case FRONT_PAGE_KEY_DEVICE_MANAGER
:
268 case FRONT_PAGE_KEY_BOOT_MAINTAIN
:
270 // Boot Maintenance Manager
279 *ActionRequest
= EFI_BROWSER_ACTION_REQUEST_EXIT
;
285 Initialize HII information for the FrontPage
288 @param InitializeHiiData TRUE if HII elements need to be initialized.
290 @retval EFI_SUCCESS The operation is successful.
291 @retval EFI_DEVICE_ERROR If the dynamic opcode creation failed.
295 InitializeFrontPage (
296 IN BOOLEAN InitializeHiiData
300 EFI_HII_PACKAGE_LIST_HEADER
*PackageList
;
301 EFI_HII_UPDATE_DATA UpdateData
;
302 IFR_OPTION
*OptionList
;
303 CHAR8
*LanguageString
;
310 CHAR16
*StringBuffer
;
313 EFI_HII_HANDLE HiiHandle
;
315 if (InitializeHiiData
) {
317 // Initialize the Device Manager
319 InitializeDeviceManager ();
322 // Initialize the Device Manager
324 InitializeBootManager ();
329 // Locate Hii relative protocols
331 Status
= gBS
->LocateProtocol (&gEfiHiiDatabaseProtocolGuid
, NULL
, (VOID
**) &gHiiDatabase
);
332 if (EFI_ERROR (Status
)) {
336 Status
= gBS
->LocateProtocol (&gEfiHiiStringProtocolGuid
, NULL
, (VOID
**) &gHiiString
);
337 if (EFI_ERROR (Status
)) {
341 Status
= gBS
->LocateProtocol (&gEfiFormBrowser2ProtocolGuid
, NULL
, (VOID
**) &gFormBrowser2
);
342 if (EFI_ERROR (Status
)) {
346 Status
= gBS
->LocateProtocol (&gEfiHiiConfigRoutingProtocolGuid
, NULL
, (VOID
**) &gHiiConfigRouting
);
347 if (EFI_ERROR (Status
)) {
352 // Install Device Path Protocol and Config Access protocol to driver handle
354 Status
= gBS
->InstallMultipleProtocolInterfaces (
355 &gFrontPagePrivate
.DriverHandle
,
356 &gEfiDevicePathProtocolGuid
,
357 &mFrontPageHiiVendorDevicePath
,
358 &gEfiHiiConfigAccessProtocolGuid
,
359 &gFrontPagePrivate
.ConfigAccess
,
362 ASSERT_EFI_ERROR (Status
);
365 // Publish our HII data
367 PackageList
= HiiLibPreparePackageList (2, &mFrontPageGuid
, FrontPageVfrBin
, BdsDxeStrings
);
368 ASSERT (PackageList
!= NULL
);
370 Status
= gHiiDatabase
->NewPackageList (
373 gFrontPagePrivate
.DriverHandle
,
374 &gFrontPagePrivate
.HiiHandle
376 FreePool (PackageList
);
377 if (EFI_ERROR (Status
)) {
384 // Allocate space for creation of UpdateData Buffer
386 UpdateData
.BufferSize
= 0x1000;
387 UpdateData
.Data
= AllocateZeroPool (0x1000);
388 ASSERT (UpdateData
.Data
!= NULL
);
390 OptionList
= AllocateZeroPool (0x1000);
391 ASSERT (OptionList
!= NULL
);
394 // Collect the languages from what our current Language support is based on our VFR
396 HiiHandle
= gFrontPagePrivate
.HiiHandle
;
397 LanguageString
= HiiLibGetSupportedLanguages (HiiHandle
);
398 ASSERT (LanguageString
!= NULL
);
400 // Allocate working buffer for RFC 4646 language in supported LanguageString.
402 Lang
= AllocatePool (AsciiStrSize (LanguageString
));
403 ASSERT (Lang
!= NULL
);
405 CurrentLang
= GetEfiGlobalVariable (L
"PlatformLang");
407 // Select the best language in LanguageString as the default one.
409 BestLanguage
= GetBestLanguage (
412 (CurrentLang
!= NULL
) ? CurrentLang
: "",
413 (CHAR8
*) PcdGetPtr (PcdUefiVariableDefaultPlatformLang
),
418 // BestLanguage must be selected as it is the first language in LanguageString by default
420 ASSERT (BestLanguage
!= NULL
);
423 LangCode
= LanguageString
;
424 while (*LangCode
!= 0) {
425 HiiLibGetNextLanguage (&LangCode
, Lang
);
427 if (gFrontPagePrivate
.LanguageToken
== NULL
) {
429 // Get Language Name from String Package. The StringId of Printable Language
430 // Name is always 1 which is generated by StringGather Tool.
433 StringBuffer
= AllocatePool (BufferSize
);
434 Status
= gHiiString
->GetString (
438 PRINTABLE_LANGUAGE_NAME_STRING_ID
,
443 if (Status
== EFI_BUFFER_TOO_SMALL
) {
444 FreePool (StringBuffer
);
445 StringBuffer
= AllocatePool (BufferSize
);
446 Status
= gHiiString
->GetString (
450 PRINTABLE_LANGUAGE_NAME_STRING_ID
,
456 ASSERT_EFI_ERROR (Status
);
459 Status
= HiiLibNewString (HiiHandle
, &Token
, StringBuffer
);
460 FreePool (StringBuffer
);
462 Token
= gFrontPagePrivate
.LanguageToken
[OptionCount
];
465 if (AsciiStrCmp (Lang
, BestLanguage
) == 0) {
466 OptionList
[OptionCount
].Flags
= EFI_IFR_OPTION_DEFAULT
;
468 OptionList
[OptionCount
].Flags
= 0;
470 OptionList
[OptionCount
].StringToken
= Token
;
471 OptionList
[OptionCount
].Value
.u8
= (UINT8
) OptionCount
;
476 if (CurrentLang
!= NULL
) {
477 FreePool (CurrentLang
);
479 FreePool (BestLanguage
);
481 FreePool (LanguageString
);
483 UpdateData
.Offset
= 0;
485 FRONT_PAGE_KEY_LANGUAGE
,
488 STRING_TOKEN (STR_LANGUAGE_SELECT
),
489 STRING_TOKEN (STR_LANGUAGE_SELECT_HELP
),
490 EFI_IFR_FLAG_CALLBACK
,
491 EFI_IFR_NUMERIC_SIZE_1
,
497 Status
= IfrLibUpdateForm (
501 LABEL_SELECT_LANGUAGE
,
507 // Save the string Id for each language
509 gFrontPagePrivate
.LanguageToken
= AllocatePool (OptionCount
* sizeof (EFI_STRING_ID
));
510 ASSERT (gFrontPagePrivate
.LanguageToken
!= NULL
);
511 for (Index
= 0; Index
< OptionCount
; Index
++) {
512 gFrontPagePrivate
.LanguageToken
[Index
] = OptionList
[Index
].StringToken
;
515 FreePool (UpdateData
.Data
);
516 FreePool (OptionList
);
521 Call the browser and display the front page
523 @return Status code that will be returned by
524 EFI_FORM_BROWSER2_PROTOCOL.SendForm ().
533 EFI_BROWSER_ACTION_REQUEST ActionRequest
;
536 // Begin waiting for USER INPUT
540 (EFI_SOFTWARE_DXE_BS_DRIVER
| EFI_SW_PC_INPUT_WAIT
)
543 ActionRequest
= EFI_BROWSER_ACTION_REQUEST_NONE
;
544 Status
= gFormBrowser2
->SendForm (
546 &gFrontPagePrivate
.HiiHandle
,
554 // Check whether user change any option setting which needs a reset to be effective
556 if (ActionRequest
== EFI_BROWSER_ACTION_REQUEST_RESET
) {
557 EnableResetRequired ();
564 Acquire the string associated with the ProducerGuid and return it.
567 @param ProducerGuid The Guid to search the HII database for
568 @param Token The token value of the string to extract
569 @param String The string that is extracted
571 @retval EFI_SUCCESS The function returns EFI_SUCCESS always.
576 IN EFI_GUID
*ProducerGuid
,
577 IN EFI_STRING_ID Token
,
583 Status
= HiiLibGetStringFromToken (ProducerGuid
, Token
, String
);
584 if (EFI_ERROR (Status
)) {
585 *String
= GetStringById (STRING_TOKEN (STR_MISSING_STRING
));
592 Convert Processor Frequency Data to a string
594 @param ProcessorFrequency The frequency data to process
595 @param String The string that is created
599 ConvertProcessorToString (
600 IN EFI_PROCESSOR_CORE_FREQUENCY_DATA
*ProcessorFrequency
,
604 CHAR16
*StringBuffer
;
608 if (ProcessorFrequency
->Exponent
>= 6) {
609 FreqMhz
= ProcessorFrequency
->Value
;
610 for (Index
= 0; Index
< (UINTN
) (ProcessorFrequency
->Exponent
- 6); Index
++) {
617 StringBuffer
= AllocateZeroPool (0x20);
618 ASSERT (StringBuffer
!= NULL
);
619 Index
= UnicodeValueToString (StringBuffer
, LEFT_JUSTIFY
, FreqMhz
/ 1000, 3);
620 StrCat (StringBuffer
, L
".");
621 UnicodeValueToString (StringBuffer
+ Index
+ 1, PREFIX_ZERO
, (FreqMhz
% 1000) / 10, 2);
622 StrCat (StringBuffer
, L
" GHz");
624 *String
= (CHAR16
*) StringBuffer
;
630 Convert Memory Size to a string.
632 @param MemorySize The size of the memory to process
633 @param String The string that is created
637 ConvertMemorySizeToString (
638 IN UINT32 MemorySize
,
642 CHAR16
*StringBuffer
;
644 StringBuffer
= AllocateZeroPool (0x20);
645 ASSERT (StringBuffer
!= NULL
);
646 UnicodeValueToString (StringBuffer
, LEFT_JUSTIFY
, MemorySize
, 6);
647 StrCat (StringBuffer
, L
" MB RAM");
649 *String
= (CHAR16
*) StringBuffer
;
655 Update the banner information for the Front Page based on DataHub information.
659 UpdateFrontPageStrings (
664 EFI_STRING_ID TokenToUpdate
;
666 UINT64 MonotonicCount
;
667 EFI_DATA_HUB_PROTOCOL
*DataHub
;
668 EFI_DATA_RECORD_HEADER
*Record
;
669 EFI_SUBCLASS_TYPE1_HEADER
*DataHeader
;
670 EFI_MISC_BIOS_VENDOR_DATA
*BiosVendor
;
671 EFI_MISC_SYSTEM_MANUFACTURER_DATA
*SystemManufacturer
;
672 EFI_PROCESSOR_VERSION_DATA
*ProcessorVersion
;
673 EFI_PROCESSOR_CORE_FREQUENCY_DATA
*ProcessorFrequency
;
674 EFI_MEMORY_ARRAY_START_ADDRESS_DATA
*MemoryArray
;
677 ZeroMem (Find
, sizeof (Find
));
680 // Update Front Page strings
682 Status
= gBS
->LocateProtocol (
683 &gEfiDataHubProtocolGuid
,
687 ASSERT_EFI_ERROR (Status
);
692 Status
= DataHub
->GetNextRecord (DataHub
, &MonotonicCount
, NULL
, &Record
);
693 if (Record
->DataRecordClass
== EFI_DATA_RECORD_CLASS_DATA
) {
694 DataHeader
= (EFI_SUBCLASS_TYPE1_HEADER
*) (Record
+ 1);
695 if (CompareGuid (&Record
->DataRecordGuid
, &gEfiMiscSubClassGuid
) &&
696 (DataHeader
->RecordType
== EFI_MISC_BIOS_VENDOR_RECORD_NUMBER
)
698 BiosVendor
= (EFI_MISC_BIOS_VENDOR_DATA
*) (DataHeader
+ 1);
699 GetProducerString (&Record
->ProducerName
, BiosVendor
->BiosVersion
, &NewString
);
700 TokenToUpdate
= STRING_TOKEN (STR_FRONT_PAGE_BIOS_VERSION
);
701 HiiLibSetString (gFrontPagePrivate
.HiiHandle
, TokenToUpdate
, NewString
);
702 FreePool (NewString
);
706 if (CompareGuid (&Record
->DataRecordGuid
, &gEfiMiscSubClassGuid
) &&
707 (DataHeader
->RecordType
== EFI_MISC_SYSTEM_MANUFACTURER_RECORD_NUMBER
)
709 SystemManufacturer
= (EFI_MISC_SYSTEM_MANUFACTURER_DATA
*) (DataHeader
+ 1);
710 GetProducerString (&Record
->ProducerName
, SystemManufacturer
->SystemProductName
, &NewString
);
711 TokenToUpdate
= STRING_TOKEN (STR_FRONT_PAGE_COMPUTER_MODEL
);
712 HiiLibSetString (gFrontPagePrivate
.HiiHandle
, TokenToUpdate
, NewString
);
713 FreePool (NewString
);
717 if (CompareGuid (&Record
->DataRecordGuid
, &gEfiProcessorSubClassGuid
) &&
718 (DataHeader
->RecordType
== ProcessorVersionRecordType
)
720 ProcessorVersion
= (EFI_PROCESSOR_VERSION_DATA
*) (DataHeader
+ 1);
721 GetProducerString (&Record
->ProducerName
, *ProcessorVersion
, &NewString
);
722 TokenToUpdate
= STRING_TOKEN (STR_FRONT_PAGE_CPU_MODEL
);
723 HiiLibSetString (gFrontPagePrivate
.HiiHandle
, TokenToUpdate
, NewString
);
724 FreePool (NewString
);
728 if (CompareGuid (&Record
->DataRecordGuid
, &gEfiProcessorSubClassGuid
) &&
729 (DataHeader
->RecordType
== ProcessorCoreFrequencyRecordType
)
731 ProcessorFrequency
= (EFI_PROCESSOR_CORE_FREQUENCY_DATA
*) (DataHeader
+ 1);
732 ConvertProcessorToString (ProcessorFrequency
, &NewString
);
733 TokenToUpdate
= STRING_TOKEN (STR_FRONT_PAGE_CPU_SPEED
);
734 HiiLibSetString (gFrontPagePrivate
.HiiHandle
, TokenToUpdate
, NewString
);
735 FreePool (NewString
);
739 if (CompareGuid (&Record
->DataRecordGuid
, &gEfiMemorySubClassGuid
) &&
740 (DataHeader
->RecordType
== EFI_MEMORY_ARRAY_START_ADDRESS_RECORD_NUMBER
)
742 MemoryArray
= (EFI_MEMORY_ARRAY_START_ADDRESS_DATA
*) (DataHeader
+ 1);
743 ConvertMemorySizeToString (
744 (UINT32
)(RShiftU64((MemoryArray
->MemoryArrayEndAddress
- MemoryArray
->MemoryArrayStartAddress
+ 1), 20)),
747 TokenToUpdate
= STRING_TOKEN (STR_FRONT_PAGE_MEMORY_SIZE
);
748 HiiLibSetString (gFrontPagePrivate
.HiiHandle
, TokenToUpdate
, NewString
);
749 FreePool (NewString
);
753 } while (!EFI_ERROR (Status
) && (MonotonicCount
!= 0) && !(Find
[0] && Find
[1] && Find
[2] && Find
[3] && Find
[4]));
759 Function waits for a given event to fire, or for an optional timeout to expire.
761 @param Event The event to wait for
762 @param Timeout An optional timeout value in 100 ns units.
764 @retval EFI_SUCCESS Event fired before Timeout expired.
765 @retval EFI_TIME_OUT Timout expired before Event fired..
771 IN UINT64 Timeout OPTIONAL
776 EFI_EVENT TimerEvent
;
777 EFI_EVENT WaitList
[2];
781 // Create a timer event
783 Status
= gBS
->CreateEvent (EVT_TIMER
, 0, NULL
, NULL
, &TimerEvent
);
784 if (!EFI_ERROR (Status
)) {
786 // Set the timer event
795 // Wait for the original event or the timer
798 WaitList
[1] = TimerEvent
;
799 Status
= gBS
->WaitForEvent (2, WaitList
, &Index
);
800 gBS
->CloseEvent (TimerEvent
);
803 // If the timer expired, change the return to timed out
805 if (!EFI_ERROR (Status
) && Index
== 1) {
806 Status
= EFI_TIMEOUT
;
811 // No timeout... just wait on the event
813 Status
= gBS
->WaitForEvent (1, &Event
, &Index
);
814 ASSERT (!EFI_ERROR (Status
));
822 Function show progress bar to wait for user input.
825 @param TimeoutDefault The fault time out value before the system continue to boot.
827 @retval EFI_SUCCESS User pressed some key except "Enter"
828 @retval EFI_TIME_OUT Timout expired or user press "Enter"
833 IN UINT16 TimeoutDefault
838 EFI_GRAPHICS_OUTPUT_BLT_PIXEL Foreground
;
839 EFI_GRAPHICS_OUTPUT_BLT_PIXEL Background
;
840 EFI_GRAPHICS_OUTPUT_BLT_PIXEL Color
;
842 UINT16 TimeoutRemain
;
844 if (TimeoutDefault
== 0) {
848 DEBUG ((EFI_D_INFO
, "\n\nStart showing progress bar... Press any key to stop it! ...Zzz....\n"));
850 SetMem (&Foreground
, sizeof (EFI_GRAPHICS_OUTPUT_BLT_PIXEL
), 0xff);
851 SetMem (&Background
, sizeof (EFI_GRAPHICS_OUTPUT_BLT_PIXEL
), 0x0);
852 SetMem (&Color
, sizeof (EFI_GRAPHICS_OUTPUT_BLT_PIXEL
), 0xff);
855 // Clear the progress status bar first
857 TmpStr
= GetStringById (STRING_TOKEN (STR_START_BOOT_OPTION
));
858 if (TmpStr
!= NULL
) {
859 PlatformBdsShowProgress (Foreground
, Background
, TmpStr
, Color
, 0, 0);
862 TimeoutRemain
= TimeoutDefault
;
863 while (TimeoutRemain
!= 0) {
864 DEBUG ((EFI_D_INFO
, "Showing progress bar...Remaining %d second!\n", TimeoutRemain
));
866 Status
= WaitForSingleEvent (gST
->ConIn
->WaitForKey
, ONE_SECOND
);
867 if (Status
!= EFI_TIMEOUT
) {
875 if (TmpStr
!= NULL
) {
876 PlatformBdsShowProgress (
881 ((TimeoutDefault
- TimeoutRemain
) * 100 / TimeoutDefault
),
886 gBS
->FreePool (TmpStr
);
891 if (TimeoutRemain
== 0) {
896 // User pressed some key
898 Status
= gST
->ConIn
->ReadKeyStroke (gST
->ConIn
, &Key
);
899 if (EFI_ERROR (Status
)) {
903 if (Key
.UnicodeChar
== CHAR_CARRIAGE_RETURN
) {
905 // User pressed enter, equivalent to select "continue"
914 This function is the main entry of the platform setup entry.
915 The function will present the main menu of the system setup,
916 this is the platform reference part and can be customize.
919 @param TimeoutDefault The fault time out value before the system
921 @param ConnectAllHappened The indicater to check if the connect all have
926 PlatformBdsEnterFrontPage (
927 IN UINT16 TimeoutDefault
,
928 IN BOOLEAN ConnectAllHappened
933 PERF_START (0, "BdsTimeOut", "BDS", 0);
935 // Indicate if we need connect all in the platform setup
937 if (ConnectAllHappened
) {
938 gConnectAllHappened
= TRUE
;
941 if (TimeoutDefault
!= 0xffff) {
942 Status
= ShowProgress (TimeoutDefault
);
945 // Ensure screen is clear when switch Console from Graphics mode to Text mode
947 gST
->ConOut
->EnableCursor (gST
->ConOut
, TRUE
);
948 gST
->ConOut
->ClearScreen (gST
->ConOut
);
950 if (EFI_ERROR (Status
)) {
952 // Timeout or user press enter to continue
960 InitializeFrontPage (FALSE
);
963 // Update Front Page strings
965 UpdateFrontPageStrings ();
968 Status
= CallFrontPage ();
971 // If gCallbackKey is greater than 1 and less or equal to 5,
972 // it will lauch configuration utilities.
975 // 4 = device manager
976 // 5 = boot maintainenance manager
978 if (gCallbackKey
!= 0) {
981 (EFI_SOFTWARE_DXE_BS_DRIVER
| EFI_SW_PC_USER_SETUP
)
985 // Based on the key that was set, we can determine what to do
987 switch (gCallbackKey
) {
989 // The first 4 entries in the Front Page are to be GUARANTEED to remain constant so IHV's can
990 // describe to their customers in documentation how to find their setup information (namely
991 // under the device manager and specific buckets)
993 // These entries consist of the Continue, Select language, Boot Manager, and Device Manager
995 case FRONT_PAGE_KEY_CONTINUE
:
1001 case FRONT_PAGE_KEY_LANGUAGE
:
1003 // User made a language setting change - display front page again
1007 case FRONT_PAGE_KEY_BOOT_MANAGER
:
1009 // User chose to run the Boot Manager
1014 case FRONT_PAGE_KEY_DEVICE_MANAGER
:
1016 // Display the Device Manager
1019 CallDeviceManager();
1020 } while (gCallbackKey
== FRONT_PAGE_KEY_DEVICE_MANAGER
);
1023 case FRONT_PAGE_KEY_BOOT_MAINTAIN
:
1025 // Display the Boot Maintenance Manager
1027 BdsStartBootMaint ();
1031 } while ((Status
== EFI_SUCCESS
) && (gCallbackKey
!= FRONT_PAGE_KEY_CONTINUE
));
1034 //Will leave browser, check any reset required change is applied? if yes, reset system
1036 SetupResetReminder ();
1040 // Automatically load current entry
1041 // Note: The following lines of code only execute when Auto boot
1044 PERF_END (0, "BdsTimeOut", "BDS", 0);