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
= HiiGetSupportedLanguages (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_UPDATE_DATA UpdateData
;
301 IFR_OPTION
*OptionList
;
302 CHAR8
*LanguageString
;
309 CHAR16
*StringBuffer
;
312 EFI_HII_HANDLE HiiHandle
;
314 if (InitializeHiiData
) {
316 // Initialize the Device Manager
318 InitializeDeviceManager ();
321 // Initialize the Device Manager
323 InitializeBootManager ();
328 // Locate Hii relative protocols
330 Status
= gBS
->LocateProtocol (&gEfiHiiDatabaseProtocolGuid
, NULL
, (VOID
**) &gHiiDatabase
);
331 if (EFI_ERROR (Status
)) {
335 Status
= gBS
->LocateProtocol (&gEfiHiiStringProtocolGuid
, NULL
, (VOID
**) &gHiiString
);
336 if (EFI_ERROR (Status
)) {
340 Status
= gBS
->LocateProtocol (&gEfiFormBrowser2ProtocolGuid
, NULL
, (VOID
**) &gFormBrowser2
);
341 if (EFI_ERROR (Status
)) {
345 Status
= gBS
->LocateProtocol (&gEfiHiiConfigRoutingProtocolGuid
, NULL
, (VOID
**) &gHiiConfigRouting
);
346 if (EFI_ERROR (Status
)) {
351 // Install Device Path Protocol and Config Access protocol to driver handle
353 Status
= gBS
->InstallMultipleProtocolInterfaces (
354 &gFrontPagePrivate
.DriverHandle
,
355 &gEfiDevicePathProtocolGuid
,
356 &mFrontPageHiiVendorDevicePath
,
357 &gEfiHiiConfigAccessProtocolGuid
,
358 &gFrontPagePrivate
.ConfigAccess
,
361 ASSERT_EFI_ERROR (Status
);
364 // Publish our HII data
366 gFrontPagePrivate
.HiiHandle
= HiiAddPackages (
368 gFrontPagePrivate
.DriverHandle
,
373 if (gFrontPagePrivate
.HiiHandle
== NULL
) {
374 return EFI_OUT_OF_RESOURCES
;
380 // Allocate space for creation of UpdateData Buffer
382 UpdateData
.BufferSize
= 0x1000;
383 UpdateData
.Data
= AllocateZeroPool (0x1000);
384 ASSERT (UpdateData
.Data
!= NULL
);
386 OptionList
= AllocateZeroPool (0x1000);
387 ASSERT (OptionList
!= NULL
);
390 // Collect the languages from what our current Language support is based on our VFR
392 HiiHandle
= gFrontPagePrivate
.HiiHandle
;
393 LanguageString
= HiiGetSupportedLanguages (HiiHandle
);
394 ASSERT (LanguageString
!= NULL
);
396 // Allocate working buffer for RFC 4646 language in supported LanguageString.
398 Lang
= AllocatePool (AsciiStrSize (LanguageString
));
399 ASSERT (Lang
!= NULL
);
401 CurrentLang
= GetEfiGlobalVariable (L
"PlatformLang");
403 // Select the best language in LanguageString as the default one.
405 BestLanguage
= GetBestLanguage (
408 (CurrentLang
!= NULL
) ? CurrentLang
: "",
409 (CHAR8
*) PcdGetPtr (PcdUefiVariableDefaultPlatformLang
),
414 // BestLanguage must be selected as it is the first language in LanguageString by default
416 ASSERT (BestLanguage
!= NULL
);
419 LangCode
= LanguageString
;
420 while (*LangCode
!= 0) {
421 HiiLibGetNextLanguage (&LangCode
, Lang
);
423 if (gFrontPagePrivate
.LanguageToken
== NULL
) {
425 // Get Language Name from String Package. The StringId of Printable Language
426 // Name is always 1 which is generated by StringGather Tool.
429 StringBuffer
= AllocatePool (BufferSize
);
430 Status
= gHiiString
->GetString (
434 PRINTABLE_LANGUAGE_NAME_STRING_ID
,
439 if (Status
== EFI_BUFFER_TOO_SMALL
) {
440 FreePool (StringBuffer
);
441 StringBuffer
= AllocatePool (BufferSize
);
442 Status
= gHiiString
->GetString (
446 PRINTABLE_LANGUAGE_NAME_STRING_ID
,
452 ASSERT_EFI_ERROR (Status
);
454 Token
= HiiSetString (HiiHandle
, 0, StringBuffer
, NULL
);
455 FreePool (StringBuffer
);
457 Token
= gFrontPagePrivate
.LanguageToken
[OptionCount
];
460 if (AsciiStrCmp (Lang
, BestLanguage
) == 0) {
461 OptionList
[OptionCount
].Flags
= EFI_IFR_OPTION_DEFAULT
;
463 OptionList
[OptionCount
].Flags
= 0;
465 OptionList
[OptionCount
].StringToken
= Token
;
466 OptionList
[OptionCount
].Value
.u8
= (UINT8
) OptionCount
;
471 if (CurrentLang
!= NULL
) {
472 FreePool (CurrentLang
);
474 FreePool (BestLanguage
);
476 FreePool (LanguageString
);
478 UpdateData
.Offset
= 0;
480 FRONT_PAGE_KEY_LANGUAGE
,
483 STRING_TOKEN (STR_LANGUAGE_SELECT
),
484 STRING_TOKEN (STR_LANGUAGE_SELECT_HELP
),
485 EFI_IFR_FLAG_CALLBACK
,
486 EFI_IFR_NUMERIC_SIZE_1
,
492 Status
= IfrLibUpdateForm (
496 LABEL_SELECT_LANGUAGE
,
502 // Save the string Id for each language
504 gFrontPagePrivate
.LanguageToken
= AllocatePool (OptionCount
* sizeof (EFI_STRING_ID
));
505 ASSERT (gFrontPagePrivate
.LanguageToken
!= NULL
);
506 for (Index
= 0; Index
< OptionCount
; Index
++) {
507 gFrontPagePrivate
.LanguageToken
[Index
] = OptionList
[Index
].StringToken
;
510 FreePool (UpdateData
.Data
);
511 FreePool (OptionList
);
516 Call the browser and display the front page
518 @return Status code that will be returned by
519 EFI_FORM_BROWSER2_PROTOCOL.SendForm ().
528 EFI_BROWSER_ACTION_REQUEST ActionRequest
;
531 // Begin waiting for USER INPUT
535 (EFI_SOFTWARE_DXE_BS_DRIVER
| EFI_SW_PC_INPUT_WAIT
)
538 ActionRequest
= EFI_BROWSER_ACTION_REQUEST_NONE
;
539 Status
= gFormBrowser2
->SendForm (
541 &gFrontPagePrivate
.HiiHandle
,
549 // Check whether user change any option setting which needs a reset to be effective
551 if (ActionRequest
== EFI_BROWSER_ACTION_REQUEST_RESET
) {
552 EnableResetRequired ();
559 Acquire the string associated with the ProducerGuid and return it.
562 @param ProducerGuid The Guid to search the HII database for
563 @param Token The token value of the string to extract
564 @param String The string that is extracted
566 @retval EFI_SUCCESS The function returns EFI_SUCCESS always.
571 IN EFI_GUID
*ProducerGuid
,
572 IN EFI_STRING_ID Token
,
576 EFI_STRING TmpString
;
578 TmpString
= HiiGetPackageString (ProducerGuid
, Token
, NULL
);
579 if (TmpString
== NULL
) {
580 *String
= GetStringById (STRING_TOKEN (STR_MISSING_STRING
));
589 Convert Processor Frequency Data to a string
591 @param ProcessorFrequency The frequency data to process
592 @param String The string that is created
596 ConvertProcessorToString (
597 IN EFI_PROCESSOR_CORE_FREQUENCY_DATA
*ProcessorFrequency
,
601 CHAR16
*StringBuffer
;
605 if (ProcessorFrequency
->Exponent
>= 6) {
606 FreqMhz
= ProcessorFrequency
->Value
;
607 for (Index
= 0; Index
< (UINTN
) (ProcessorFrequency
->Exponent
- 6); Index
++) {
614 StringBuffer
= AllocateZeroPool (0x20);
615 ASSERT (StringBuffer
!= NULL
);
616 Index
= UnicodeValueToString (StringBuffer
, LEFT_JUSTIFY
, FreqMhz
/ 1000, 3);
617 StrCat (StringBuffer
, L
".");
618 UnicodeValueToString (StringBuffer
+ Index
+ 1, PREFIX_ZERO
, (FreqMhz
% 1000) / 10, 2);
619 StrCat (StringBuffer
, L
" GHz");
621 *String
= (CHAR16
*) StringBuffer
;
627 Convert Memory Size to a string.
629 @param MemorySize The size of the memory to process
630 @param String The string that is created
634 ConvertMemorySizeToString (
635 IN UINT32 MemorySize
,
639 CHAR16
*StringBuffer
;
641 StringBuffer
= AllocateZeroPool (0x20);
642 ASSERT (StringBuffer
!= NULL
);
643 UnicodeValueToString (StringBuffer
, LEFT_JUSTIFY
, MemorySize
, 6);
644 StrCat (StringBuffer
, L
" MB RAM");
646 *String
= (CHAR16
*) StringBuffer
;
652 Update the banner information for the Front Page based on DataHub information.
656 UpdateFrontPageStrings (
661 EFI_STRING_ID TokenToUpdate
;
663 UINT64 MonotonicCount
;
664 EFI_DATA_HUB_PROTOCOL
*DataHub
;
665 EFI_DATA_RECORD_HEADER
*Record
;
666 EFI_SUBCLASS_TYPE1_HEADER
*DataHeader
;
667 EFI_MISC_BIOS_VENDOR_DATA
*BiosVendor
;
668 EFI_MISC_SYSTEM_MANUFACTURER_DATA
*SystemManufacturer
;
669 EFI_PROCESSOR_VERSION_DATA
*ProcessorVersion
;
670 EFI_PROCESSOR_CORE_FREQUENCY_DATA
*ProcessorFrequency
;
671 EFI_MEMORY_ARRAY_START_ADDRESS_DATA
*MemoryArray
;
674 ZeroMem (Find
, sizeof (Find
));
677 // Update Front Page strings
679 Status
= gBS
->LocateProtocol (
680 &gEfiDataHubProtocolGuid
,
684 ASSERT_EFI_ERROR (Status
);
689 Status
= DataHub
->GetNextRecord (DataHub
, &MonotonicCount
, NULL
, &Record
);
690 if (Record
->DataRecordClass
== EFI_DATA_RECORD_CLASS_DATA
) {
691 DataHeader
= (EFI_SUBCLASS_TYPE1_HEADER
*) (Record
+ 1);
692 if (CompareGuid (&Record
->DataRecordGuid
, &gEfiMiscSubClassGuid
) &&
693 (DataHeader
->RecordType
== EFI_MISC_BIOS_VENDOR_RECORD_NUMBER
)
695 BiosVendor
= (EFI_MISC_BIOS_VENDOR_DATA
*) (DataHeader
+ 1);
696 GetProducerString (&Record
->ProducerName
, BiosVendor
->BiosVersion
, &NewString
);
697 TokenToUpdate
= STRING_TOKEN (STR_FRONT_PAGE_BIOS_VERSION
);
698 HiiSetString (gFrontPagePrivate
.HiiHandle
, TokenToUpdate
, NewString
, NULL
);
699 FreePool (NewString
);
703 if (CompareGuid (&Record
->DataRecordGuid
, &gEfiMiscSubClassGuid
) &&
704 (DataHeader
->RecordType
== EFI_MISC_SYSTEM_MANUFACTURER_RECORD_NUMBER
)
706 SystemManufacturer
= (EFI_MISC_SYSTEM_MANUFACTURER_DATA
*) (DataHeader
+ 1);
707 GetProducerString (&Record
->ProducerName
, SystemManufacturer
->SystemProductName
, &NewString
);
708 TokenToUpdate
= STRING_TOKEN (STR_FRONT_PAGE_COMPUTER_MODEL
);
709 HiiSetString (gFrontPagePrivate
.HiiHandle
, TokenToUpdate
, NewString
, NULL
);
710 FreePool (NewString
);
714 if (CompareGuid (&Record
->DataRecordGuid
, &gEfiProcessorSubClassGuid
) &&
715 (DataHeader
->RecordType
== ProcessorVersionRecordType
)
717 ProcessorVersion
= (EFI_PROCESSOR_VERSION_DATA
*) (DataHeader
+ 1);
718 GetProducerString (&Record
->ProducerName
, *ProcessorVersion
, &NewString
);
719 TokenToUpdate
= STRING_TOKEN (STR_FRONT_PAGE_CPU_MODEL
);
720 HiiSetString (gFrontPagePrivate
.HiiHandle
, TokenToUpdate
, NewString
, NULL
);
721 FreePool (NewString
);
725 if (CompareGuid (&Record
->DataRecordGuid
, &gEfiProcessorSubClassGuid
) &&
726 (DataHeader
->RecordType
== ProcessorCoreFrequencyRecordType
)
728 ProcessorFrequency
= (EFI_PROCESSOR_CORE_FREQUENCY_DATA
*) (DataHeader
+ 1);
729 ConvertProcessorToString (ProcessorFrequency
, &NewString
);
730 TokenToUpdate
= STRING_TOKEN (STR_FRONT_PAGE_CPU_SPEED
);
731 HiiSetString (gFrontPagePrivate
.HiiHandle
, TokenToUpdate
, NewString
, NULL
);
732 FreePool (NewString
);
736 if (CompareGuid (&Record
->DataRecordGuid
, &gEfiMemorySubClassGuid
) &&
737 (DataHeader
->RecordType
== EFI_MEMORY_ARRAY_START_ADDRESS_RECORD_NUMBER
)
739 MemoryArray
= (EFI_MEMORY_ARRAY_START_ADDRESS_DATA
*) (DataHeader
+ 1);
740 ConvertMemorySizeToString (
741 (UINT32
)(RShiftU64((MemoryArray
->MemoryArrayEndAddress
- MemoryArray
->MemoryArrayStartAddress
+ 1), 20)),
744 TokenToUpdate
= STRING_TOKEN (STR_FRONT_PAGE_MEMORY_SIZE
);
745 HiiSetString (gFrontPagePrivate
.HiiHandle
, TokenToUpdate
, NewString
, NULL
);
746 FreePool (NewString
);
750 } while (!EFI_ERROR (Status
) && (MonotonicCount
!= 0) && !(Find
[0] && Find
[1] && Find
[2] && Find
[3] && Find
[4]));
756 Function waits for a given event to fire, or for an optional timeout to expire.
758 @param Event The event to wait for
759 @param Timeout An optional timeout value in 100 ns units.
761 @retval EFI_SUCCESS Event fired before Timeout expired.
762 @retval EFI_TIME_OUT Timout expired before Event fired..
768 IN UINT64 Timeout OPTIONAL
773 EFI_EVENT TimerEvent
;
774 EFI_EVENT WaitList
[2];
778 // Create a timer event
780 Status
= gBS
->CreateEvent (EVT_TIMER
, 0, NULL
, NULL
, &TimerEvent
);
781 if (!EFI_ERROR (Status
)) {
783 // Set the timer event
792 // Wait for the original event or the timer
795 WaitList
[1] = TimerEvent
;
796 Status
= gBS
->WaitForEvent (2, WaitList
, &Index
);
797 gBS
->CloseEvent (TimerEvent
);
800 // If the timer expired, change the return to timed out
802 if (!EFI_ERROR (Status
) && Index
== 1) {
803 Status
= EFI_TIMEOUT
;
808 // No timeout... just wait on the event
810 Status
= gBS
->WaitForEvent (1, &Event
, &Index
);
811 ASSERT (!EFI_ERROR (Status
));
819 Function show progress bar to wait for user input.
822 @param TimeoutDefault The fault time out value before the system continue to boot.
824 @retval EFI_SUCCESS User pressed some key except "Enter"
825 @retval EFI_TIME_OUT Timout expired or user press "Enter"
830 IN UINT16 TimeoutDefault
835 EFI_GRAPHICS_OUTPUT_BLT_PIXEL Foreground
;
836 EFI_GRAPHICS_OUTPUT_BLT_PIXEL Background
;
837 EFI_GRAPHICS_OUTPUT_BLT_PIXEL Color
;
839 UINT16 TimeoutRemain
;
841 if (TimeoutDefault
== 0) {
845 DEBUG ((EFI_D_INFO
, "\n\nStart showing progress bar... Press any key to stop it! ...Zzz....\n"));
847 SetMem (&Foreground
, sizeof (EFI_GRAPHICS_OUTPUT_BLT_PIXEL
), 0xff);
848 SetMem (&Background
, sizeof (EFI_GRAPHICS_OUTPUT_BLT_PIXEL
), 0x0);
849 SetMem (&Color
, sizeof (EFI_GRAPHICS_OUTPUT_BLT_PIXEL
), 0xff);
852 // Clear the progress status bar first
854 TmpStr
= GetStringById (STRING_TOKEN (STR_START_BOOT_OPTION
));
855 if (TmpStr
!= NULL
) {
856 PlatformBdsShowProgress (Foreground
, Background
, TmpStr
, Color
, 0, 0);
859 TimeoutRemain
= TimeoutDefault
;
860 while (TimeoutRemain
!= 0) {
861 DEBUG ((EFI_D_INFO
, "Showing progress bar...Remaining %d second!\n", TimeoutRemain
));
863 Status
= WaitForSingleEvent (gST
->ConIn
->WaitForKey
, ONE_SECOND
);
864 if (Status
!= EFI_TIMEOUT
) {
872 if (TmpStr
!= NULL
) {
873 PlatformBdsShowProgress (
878 ((TimeoutDefault
- TimeoutRemain
) * 100 / TimeoutDefault
),
883 gBS
->FreePool (TmpStr
);
888 if (TimeoutRemain
== 0) {
893 // User pressed some key
895 Status
= gST
->ConIn
->ReadKeyStroke (gST
->ConIn
, &Key
);
896 if (EFI_ERROR (Status
)) {
900 if (Key
.UnicodeChar
== CHAR_CARRIAGE_RETURN
) {
902 // User pressed enter, equivalent to select "continue"
911 This function is the main entry of the platform setup entry.
912 The function will present the main menu of the system setup,
913 this is the platform reference part and can be customize.
916 @param TimeoutDefault The fault time out value before the system
918 @param ConnectAllHappened The indicater to check if the connect all have
923 PlatformBdsEnterFrontPage (
924 IN UINT16 TimeoutDefault
,
925 IN BOOLEAN ConnectAllHappened
930 PERF_START (0, "BdsTimeOut", "BDS", 0);
932 // Indicate if we need connect all in the platform setup
934 if (ConnectAllHappened
) {
935 gConnectAllHappened
= TRUE
;
938 if (TimeoutDefault
!= 0xffff) {
939 Status
= ShowProgress (TimeoutDefault
);
942 // Ensure screen is clear when switch Console from Graphics mode to Text mode
944 gST
->ConOut
->EnableCursor (gST
->ConOut
, TRUE
);
945 gST
->ConOut
->ClearScreen (gST
->ConOut
);
947 if (EFI_ERROR (Status
)) {
949 // Timeout or user press enter to continue
957 InitializeFrontPage (FALSE
);
960 // Update Front Page strings
962 UpdateFrontPageStrings ();
965 Status
= CallFrontPage ();
968 // If gCallbackKey is greater than 1 and less or equal to 5,
969 // it will lauch configuration utilities.
972 // 4 = device manager
973 // 5 = boot maintainenance manager
975 if (gCallbackKey
!= 0) {
978 (EFI_SOFTWARE_DXE_BS_DRIVER
| EFI_SW_PC_USER_SETUP
)
982 // Based on the key that was set, we can determine what to do
984 switch (gCallbackKey
) {
986 // The first 4 entries in the Front Page are to be GUARANTEED to remain constant so IHV's can
987 // describe to their customers in documentation how to find their setup information (namely
988 // under the device manager and specific buckets)
990 // These entries consist of the Continue, Select language, Boot Manager, and Device Manager
992 case FRONT_PAGE_KEY_CONTINUE
:
998 case FRONT_PAGE_KEY_LANGUAGE
:
1000 // User made a language setting change - display front page again
1004 case FRONT_PAGE_KEY_BOOT_MANAGER
:
1006 // User chose to run the Boot Manager
1011 case FRONT_PAGE_KEY_DEVICE_MANAGER
:
1013 // Display the Device Manager
1016 CallDeviceManager();
1017 } while (gCallbackKey
== FRONT_PAGE_KEY_DEVICE_MANAGER
);
1020 case FRONT_PAGE_KEY_BOOT_MAINTAIN
:
1022 // Display the Boot Maintenance Manager
1024 BdsStartBootMaint ();
1028 } while ((Status
== EFI_SUCCESS
) && (gCallbackKey
!= FRONT_PAGE_KEY_CONTINUE
));
1031 //Will leave browser, check any reset required change is applied? if yes, reset system
1033 SetupResetReminder ();
1037 // Automatically load current entry
1038 // Note: The following lines of code only execute when Auto boot
1041 PERF_END (0, "BdsTimeOut", "BDS", 0);