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"
19 EFI_GUID mFrontPageGuid
= FRONT_PAGE_FORMSET_GUID
;
21 BOOLEAN gConnectAllHappened
= FALSE
;
24 EFI_HII_DATABASE_PROTOCOL
*gHiiDatabase
;
25 EFI_HII_STRING_PROTOCOL
*gHiiString
;
26 EFI_FORM_BROWSER2_PROTOCOL
*gFormBrowser2
;
27 EFI_HII_CONFIG_ROUTING_PROTOCOL
*gHiiConfigRouting
;
29 FRONT_PAGE_CALLBACK_DATA gFrontPagePrivate
= {
30 FRONT_PAGE_CALLBACK_DATA_SIGNATURE
,
41 HII_VENDOR_DEVICE_PATH mFrontPageHiiVendorDevicePath
= {
47 (UINT8
) (sizeof (VENDOR_DEVICE_PATH
)),
48 (UINT8
) ((sizeof (VENDOR_DEVICE_PATH
)) >> 8)
52 // {8E6D99EE-7531-48f8-8745-7F6144468FF2}
54 { 0x8e6d99ee, 0x7531, 0x48f8, { 0x87, 0x45, 0x7f, 0x61, 0x44, 0x46, 0x8f, 0xf2 } }
58 END_ENTIRE_DEVICE_PATH_SUBTYPE
,
60 (UINT8
) (END_DEVICE_PATH_LENGTH
),
61 (UINT8
) ((END_DEVICE_PATH_LENGTH
) >> 8)
67 This function allows a caller to extract the current configuration for one
68 or more named elements from the target driver.
71 @param This Points to the EFI_HII_CONFIG_ACCESS_PROTOCOL.
72 @param Request A null-terminated Unicode string in <ConfigRequest> format.
73 @param Progress On return, points to a character in the Request string.
74 Points to the string's null terminator if request was successful.
75 Points to the most recent '&' before the first failing name/value
76 pair (or the beginning of the string if the failure is in the
77 first name/value pair) if the request was not successful.
78 @param Results A null-terminated Unicode string in <ConfigAltResp> format which
79 has all values filled in for the names in the Request string.
80 String to be allocated by the called function.
82 @retval EFI_SUCCESS The Results is filled with the requested values.
83 @retval EFI_OUT_OF_RESOURCES Not enough memory to store the results.
84 @retval EFI_INVALID_PARAMETER Request is NULL, illegal syntax, or unknown name.
85 @retval EFI_NOT_FOUND Routing data doesn't match any storage in this driver.
91 IN CONST EFI_HII_CONFIG_ACCESS_PROTOCOL
*This
,
92 IN CONST EFI_STRING Request
,
93 OUT EFI_STRING
*Progress
,
94 OUT EFI_STRING
*Results
101 This function processes the results of changes in configuration.
104 @param This Points to the EFI_HII_CONFIG_ACCESS_PROTOCOL.
105 @param Configuration A null-terminated Unicode string in <ConfigResp> format.
106 @param Progress A pointer to a string filled in with the offset of the most
107 recent '&' before the first failing name/value pair (or the
108 beginning of the string if the failure is in the first
109 name/value pair) or the terminating NULL if all was successful.
111 @retval EFI_SUCCESS The Results is processed successfully.
112 @retval EFI_INVALID_PARAMETER Configuration is NULL.
113 @retval EFI_NOT_FOUND Routing data doesn't match any storage in this driver.
119 IN CONST EFI_HII_CONFIG_ACCESS_PROTOCOL
*This
,
120 IN CONST EFI_STRING Configuration
,
121 OUT EFI_STRING
*Progress
128 This function processes the results of changes in configuration.
131 @param This Points to the EFI_HII_CONFIG_ACCESS_PROTOCOL.
132 @param Action Specifies the type of action taken by the browser.
133 @param QuestionId A unique value which is sent to the original exporting driver
134 so that it can identify the type of data to expect.
135 @param Type The type of value for the question.
136 @param Value A pointer to the data being sent to the original exporting driver.
137 @param ActionRequest On return, points to the action requested by the callback function.
139 @retval EFI_SUCCESS The callback successfully handled the action.
140 @retval EFI_OUT_OF_RESOURCES Not enough storage is available to hold the variable and its data.
141 @retval EFI_DEVICE_ERROR The variable could not be saved.
142 @retval EFI_UNSUPPORTED The specified Action is not supported by the callback.
148 IN CONST EFI_HII_CONFIG_ACCESS_PROTOCOL
*This
,
149 IN EFI_BROWSER_ACTION Action
,
150 IN EFI_QUESTION_ID QuestionId
,
152 IN EFI_IFR_TYPE_VALUE
*Value
,
153 OUT EFI_BROWSER_ACTION_REQUEST
*ActionRequest
156 CHAR8
*LanguageString
;
159 CHAR8 OldLang
[ISO_639_2_ENTRY_SIZE
];
162 CHAR8
*PlatformSupportedLanguages
;
165 if ((Value
== NULL
) || (ActionRequest
== NULL
)) {
166 return EFI_INVALID_PARAMETER
;
169 gCallbackKey
= QuestionId
;
172 // The first 4 entries in the Front Page are to be GUARANTEED to remain constant so IHV's can
173 // describe to their customers in documentation how to find their setup information (namely
174 // under the device manager and specific buckets)
176 switch (QuestionId
) {
177 case FRONT_PAGE_KEY_CONTINUE
:
179 // This is the continue - clear the screen and return an error to get out of FrontPage loop
183 case FRONT_PAGE_KEY_LANGUAGE
:
185 // Collect the languages from what our current Language support is based on our VFR
187 LanguageString
= HiiGetSupportedLanguages (gFrontPagePrivate
.HiiHandle
);
188 ASSERT (LanguageString
!= NULL
);
190 // Allocate working buffer for RFC 4646 language in supported LanguageString.
192 Lang
= AllocatePool (AsciiStrSize (LanguageString
));
193 ASSERT (Lang
!= NULL
);
196 LangCode
= LanguageString
;
197 while (*LangCode
!= 0) {
198 GetNextLanguage (&LangCode
, Lang
);
200 if (Index
== Value
->u8
) {
207 PlatformSupportedLanguages
= GetEfiGlobalVariable (L
"PlatformLangCodes");
208 if (PlatformSupportedLanguages
== NULL
) {
209 PlatformSupportedLanguages
= AllocateCopyPool (
210 AsciiStrSize ((CHAR8
*) PcdGetPtr (PcdUefiVariableDefaultPlatformLangCodes
)),
211 (CHAR8
*) PcdGetPtr (PcdUefiVariableDefaultPlatformLangCodes
)
213 ASSERT (PlatformSupportedLanguages
!= NULL
);
217 // Select the best language in platform supported Language.
219 BestLanguage
= GetBestLanguage (
220 PlatformSupportedLanguages
,
225 if (BestLanguage
!= NULL
) {
226 Status
= gRT
->SetVariable (
228 &gEfiGlobalVariableGuid
,
229 EFI_VARIABLE_NON_VOLATILE
| EFI_VARIABLE_BOOTSERVICE_ACCESS
| EFI_VARIABLE_RUNTIME_ACCESS
,
230 AsciiStrSize (BestLanguage
),
234 if (!FeaturePcdGet (PcdUefiVariableDefaultLangDeprecate
)) {
236 // Set UEFI deprecated variable "Lang" for backwards compatibility
238 Status
= ConvertRfc3066LanguageToIso639Language (BestLanguage
, OldLang
);
239 if (!EFI_ERROR (Status
)) {
240 Status
= gRT
->SetVariable (
242 &gEfiGlobalVariableGuid
,
243 EFI_VARIABLE_NON_VOLATILE
| EFI_VARIABLE_BOOTSERVICE_ACCESS
| EFI_VARIABLE_RUNTIME_ACCESS
,
244 ISO_639_2_ENTRY_SIZE
,
249 FreePool (BestLanguage
);
252 FreePool (PlatformSupportedLanguages
);
254 FreePool (LanguageString
);
257 case FRONT_PAGE_KEY_BOOT_MANAGER
:
263 case FRONT_PAGE_KEY_DEVICE_MANAGER
:
269 case FRONT_PAGE_KEY_BOOT_MAINTAIN
:
271 // Boot Maintenance Manager
280 *ActionRequest
= EFI_BROWSER_ACTION_REQUEST_EXIT
;
286 Initialize HII information for the FrontPage
289 @param InitializeHiiData TRUE if HII elements need to be initialized.
291 @retval EFI_SUCCESS The operation is successful.
292 @retval EFI_DEVICE_ERROR If the dynamic opcode creation failed.
296 InitializeFrontPage (
297 IN BOOLEAN InitializeHiiData
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 gFrontPagePrivate
.HiiHandle
= HiiAddPackages (
369 gFrontPagePrivate
.DriverHandle
,
374 if (gFrontPagePrivate
.HiiHandle
== NULL
) {
375 return EFI_OUT_OF_RESOURCES
;
381 // Allocate space for creation of UpdateData Buffer
383 UpdateData
.BufferSize
= 0x1000;
384 UpdateData
.Data
= AllocateZeroPool (0x1000);
385 ASSERT (UpdateData
.Data
!= NULL
);
387 OptionList
= AllocateZeroPool (0x1000);
388 ASSERT (OptionList
!= NULL
);
391 // Collect the languages from what our current Language support is based on our VFR
393 HiiHandle
= gFrontPagePrivate
.HiiHandle
;
394 LanguageString
= HiiGetSupportedLanguages (HiiHandle
);
395 ASSERT (LanguageString
!= NULL
);
397 // Allocate working buffer for RFC 4646 language in supported LanguageString.
399 Lang
= AllocatePool (AsciiStrSize (LanguageString
));
400 ASSERT (Lang
!= NULL
);
402 CurrentLang
= GetEfiGlobalVariable (L
"PlatformLang");
404 // Select the best language in LanguageString as the default one.
406 BestLanguage
= GetBestLanguage (
409 (CurrentLang
!= NULL
) ? CurrentLang
: "",
410 (CHAR8
*) PcdGetPtr (PcdUefiVariableDefaultPlatformLang
),
415 // BestLanguage must be selected as it is the first language in LanguageString by default
417 ASSERT (BestLanguage
!= NULL
);
420 LangCode
= LanguageString
;
421 while (*LangCode
!= 0) {
422 GetNextLanguage (&LangCode
, Lang
);
424 if (gFrontPagePrivate
.LanguageToken
== NULL
) {
426 // Get Language Name from String Package. The StringId of Printable Language
427 // Name is always 1 which is generated by StringGather Tool.
430 StringBuffer
= AllocatePool (BufferSize
);
431 Status
= gHiiString
->GetString (
435 PRINTABLE_LANGUAGE_NAME_STRING_ID
,
440 if (Status
== EFI_BUFFER_TOO_SMALL
) {
441 FreePool (StringBuffer
);
442 StringBuffer
= AllocatePool (BufferSize
);
443 Status
= gHiiString
->GetString (
447 PRINTABLE_LANGUAGE_NAME_STRING_ID
,
453 ASSERT_EFI_ERROR (Status
);
455 Token
= HiiSetString (HiiHandle
, 0, StringBuffer
, NULL
);
456 FreePool (StringBuffer
);
458 Token
= gFrontPagePrivate
.LanguageToken
[OptionCount
];
461 if (AsciiStrCmp (Lang
, BestLanguage
) == 0) {
462 OptionList
[OptionCount
].Flags
= EFI_IFR_OPTION_DEFAULT
;
464 OptionList
[OptionCount
].Flags
= 0;
466 OptionList
[OptionCount
].StringToken
= Token
;
467 OptionList
[OptionCount
].Value
.u8
= (UINT8
) OptionCount
;
472 if (CurrentLang
!= NULL
) {
473 FreePool (CurrentLang
);
475 FreePool (BestLanguage
);
477 FreePool (LanguageString
);
479 UpdateData
.Offset
= 0;
481 FRONT_PAGE_KEY_LANGUAGE
,
484 STRING_TOKEN (STR_LANGUAGE_SELECT
),
485 STRING_TOKEN (STR_LANGUAGE_SELECT_HELP
),
486 EFI_IFR_FLAG_CALLBACK
,
487 EFI_IFR_NUMERIC_SIZE_1
,
493 Status
= IfrLibUpdateForm (
497 LABEL_SELECT_LANGUAGE
,
503 // Save the string Id for each language
505 gFrontPagePrivate
.LanguageToken
= AllocatePool (OptionCount
* sizeof (EFI_STRING_ID
));
506 ASSERT (gFrontPagePrivate
.LanguageToken
!= NULL
);
507 for (Index
= 0; Index
< OptionCount
; Index
++) {
508 gFrontPagePrivate
.LanguageToken
[Index
] = OptionList
[Index
].StringToken
;
511 FreePool (UpdateData
.Data
);
512 FreePool (OptionList
);
517 Call the browser and display the front page
519 @return Status code that will be returned by
520 EFI_FORM_BROWSER2_PROTOCOL.SendForm ().
529 EFI_BROWSER_ACTION_REQUEST ActionRequest
;
532 // Begin waiting for USER INPUT
536 (EFI_SOFTWARE_DXE_BS_DRIVER
| EFI_SW_PC_INPUT_WAIT
)
539 ActionRequest
= EFI_BROWSER_ACTION_REQUEST_NONE
;
540 Status
= gFormBrowser2
->SendForm (
542 &gFrontPagePrivate
.HiiHandle
,
550 // Check whether user change any option setting which needs a reset to be effective
552 if (ActionRequest
== EFI_BROWSER_ACTION_REQUEST_RESET
) {
553 EnableResetRequired ();
560 Acquire the string associated with the ProducerGuid and return it.
563 @param ProducerGuid The Guid to search the HII database for
564 @param Token The token value of the string to extract
565 @param String The string that is extracted
567 @retval EFI_SUCCESS The function returns EFI_SUCCESS always.
572 IN EFI_GUID
*ProducerGuid
,
573 IN EFI_STRING_ID Token
,
577 EFI_STRING TmpString
;
579 TmpString
= HiiGetPackageString (ProducerGuid
, Token
, NULL
);
580 if (TmpString
== NULL
) {
581 *String
= GetStringById (STRING_TOKEN (STR_MISSING_STRING
));
590 Convert Processor Frequency Data to a string
592 @param ProcessorFrequency The frequency data to process
593 @param String The string that is created
597 ConvertProcessorToString (
598 IN EFI_PROCESSOR_CORE_FREQUENCY_DATA
*ProcessorFrequency
,
602 CHAR16
*StringBuffer
;
606 if (ProcessorFrequency
->Exponent
>= 6) {
607 FreqMhz
= ProcessorFrequency
->Value
;
608 for (Index
= 0; Index
< (UINTN
) (ProcessorFrequency
->Exponent
- 6); Index
++) {
615 StringBuffer
= AllocateZeroPool (0x20);
616 ASSERT (StringBuffer
!= NULL
);
617 Index
= UnicodeValueToString (StringBuffer
, LEFT_JUSTIFY
, FreqMhz
/ 1000, 3);
618 StrCat (StringBuffer
, L
".");
619 UnicodeValueToString (StringBuffer
+ Index
+ 1, PREFIX_ZERO
, (FreqMhz
% 1000) / 10, 2);
620 StrCat (StringBuffer
, L
" GHz");
622 *String
= (CHAR16
*) StringBuffer
;
628 Convert Memory Size to a string.
630 @param MemorySize The size of the memory to process
631 @param String The string that is created
635 ConvertMemorySizeToString (
636 IN UINT32 MemorySize
,
640 CHAR16
*StringBuffer
;
642 StringBuffer
= AllocateZeroPool (0x20);
643 ASSERT (StringBuffer
!= NULL
);
644 UnicodeValueToString (StringBuffer
, LEFT_JUSTIFY
, MemorySize
, 6);
645 StrCat (StringBuffer
, L
" MB RAM");
647 *String
= (CHAR16
*) StringBuffer
;
653 Update the banner information for the Front Page based on DataHub information.
657 UpdateFrontPageStrings (
662 EFI_STRING_ID TokenToUpdate
;
664 UINT64 MonotonicCount
;
665 EFI_DATA_HUB_PROTOCOL
*DataHub
;
666 EFI_DATA_RECORD_HEADER
*Record
;
667 EFI_SUBCLASS_TYPE1_HEADER
*DataHeader
;
668 EFI_MISC_BIOS_VENDOR_DATA
*BiosVendor
;
669 EFI_MISC_SYSTEM_MANUFACTURER_DATA
*SystemManufacturer
;
670 EFI_PROCESSOR_VERSION_DATA
*ProcessorVersion
;
671 EFI_PROCESSOR_CORE_FREQUENCY_DATA
*ProcessorFrequency
;
672 EFI_MEMORY_ARRAY_START_ADDRESS_DATA
*MemoryArray
;
675 ZeroMem (Find
, sizeof (Find
));
678 // Update Front Page strings
680 Status
= gBS
->LocateProtocol (
681 &gEfiDataHubProtocolGuid
,
685 ASSERT_EFI_ERROR (Status
);
690 Status
= DataHub
->GetNextRecord (DataHub
, &MonotonicCount
, NULL
, &Record
);
691 if (Record
->DataRecordClass
== EFI_DATA_RECORD_CLASS_DATA
) {
692 DataHeader
= (EFI_SUBCLASS_TYPE1_HEADER
*) (Record
+ 1);
693 if (CompareGuid (&Record
->DataRecordGuid
, &gEfiMiscSubClassGuid
) &&
694 (DataHeader
->RecordType
== EFI_MISC_BIOS_VENDOR_RECORD_NUMBER
)
696 BiosVendor
= (EFI_MISC_BIOS_VENDOR_DATA
*) (DataHeader
+ 1);
697 GetProducerString (&Record
->ProducerName
, BiosVendor
->BiosVersion
, &NewString
);
698 TokenToUpdate
= STRING_TOKEN (STR_FRONT_PAGE_BIOS_VERSION
);
699 HiiSetString (gFrontPagePrivate
.HiiHandle
, TokenToUpdate
, NewString
, NULL
);
700 FreePool (NewString
);
704 if (CompareGuid (&Record
->DataRecordGuid
, &gEfiMiscSubClassGuid
) &&
705 (DataHeader
->RecordType
== EFI_MISC_SYSTEM_MANUFACTURER_RECORD_NUMBER
)
707 SystemManufacturer
= (EFI_MISC_SYSTEM_MANUFACTURER_DATA
*) (DataHeader
+ 1);
708 GetProducerString (&Record
->ProducerName
, SystemManufacturer
->SystemProductName
, &NewString
);
709 TokenToUpdate
= STRING_TOKEN (STR_FRONT_PAGE_COMPUTER_MODEL
);
710 HiiSetString (gFrontPagePrivate
.HiiHandle
, TokenToUpdate
, NewString
, NULL
);
711 FreePool (NewString
);
715 if (CompareGuid (&Record
->DataRecordGuid
, &gEfiProcessorSubClassGuid
) &&
716 (DataHeader
->RecordType
== ProcessorVersionRecordType
)
718 ProcessorVersion
= (EFI_PROCESSOR_VERSION_DATA
*) (DataHeader
+ 1);
719 GetProducerString (&Record
->ProducerName
, *ProcessorVersion
, &NewString
);
720 TokenToUpdate
= STRING_TOKEN (STR_FRONT_PAGE_CPU_MODEL
);
721 HiiSetString (gFrontPagePrivate
.HiiHandle
, TokenToUpdate
, NewString
, NULL
);
722 FreePool (NewString
);
726 if (CompareGuid (&Record
->DataRecordGuid
, &gEfiProcessorSubClassGuid
) &&
727 (DataHeader
->RecordType
== ProcessorCoreFrequencyRecordType
)
729 ProcessorFrequency
= (EFI_PROCESSOR_CORE_FREQUENCY_DATA
*) (DataHeader
+ 1);
730 ConvertProcessorToString (ProcessorFrequency
, &NewString
);
731 TokenToUpdate
= STRING_TOKEN (STR_FRONT_PAGE_CPU_SPEED
);
732 HiiSetString (gFrontPagePrivate
.HiiHandle
, TokenToUpdate
, NewString
, NULL
);
733 FreePool (NewString
);
737 if (CompareGuid (&Record
->DataRecordGuid
, &gEfiMemorySubClassGuid
) &&
738 (DataHeader
->RecordType
== EFI_MEMORY_ARRAY_START_ADDRESS_RECORD_NUMBER
)
740 MemoryArray
= (EFI_MEMORY_ARRAY_START_ADDRESS_DATA
*) (DataHeader
+ 1);
741 ConvertMemorySizeToString (
742 (UINT32
)(RShiftU64((MemoryArray
->MemoryArrayEndAddress
- MemoryArray
->MemoryArrayStartAddress
+ 1), 20)),
745 TokenToUpdate
= STRING_TOKEN (STR_FRONT_PAGE_MEMORY_SIZE
);
746 HiiSetString (gFrontPagePrivate
.HiiHandle
, TokenToUpdate
, NewString
, NULL
);
747 FreePool (NewString
);
751 } while (!EFI_ERROR (Status
) && (MonotonicCount
!= 0) && !(Find
[0] && Find
[1] && Find
[2] && Find
[3] && Find
[4]));
757 Function waits for a given event to fire, or for an optional timeout to expire.
759 @param Event The event to wait for
760 @param Timeout An optional timeout value in 100 ns units.
762 @retval EFI_SUCCESS Event fired before Timeout expired.
763 @retval EFI_TIME_OUT Timout expired before Event fired..
769 IN UINT64 Timeout OPTIONAL
774 EFI_EVENT TimerEvent
;
775 EFI_EVENT WaitList
[2];
779 // Create a timer event
781 Status
= gBS
->CreateEvent (EVT_TIMER
, 0, NULL
, NULL
, &TimerEvent
);
782 if (!EFI_ERROR (Status
)) {
784 // Set the timer event
793 // Wait for the original event or the timer
796 WaitList
[1] = TimerEvent
;
797 Status
= gBS
->WaitForEvent (2, WaitList
, &Index
);
798 gBS
->CloseEvent (TimerEvent
);
801 // If the timer expired, change the return to timed out
803 if (!EFI_ERROR (Status
) && Index
== 1) {
804 Status
= EFI_TIMEOUT
;
809 // No timeout... just wait on the event
811 Status
= gBS
->WaitForEvent (1, &Event
, &Index
);
812 ASSERT (!EFI_ERROR (Status
));
820 Function show progress bar to wait for user input.
823 @param TimeoutDefault The fault time out value before the system continue to boot.
825 @retval EFI_SUCCESS User pressed some key except "Enter"
826 @retval EFI_TIME_OUT Timout expired or user press "Enter"
831 IN UINT16 TimeoutDefault
836 EFI_GRAPHICS_OUTPUT_BLT_PIXEL Foreground
;
837 EFI_GRAPHICS_OUTPUT_BLT_PIXEL Background
;
838 EFI_GRAPHICS_OUTPUT_BLT_PIXEL Color
;
840 UINT16 TimeoutRemain
;
842 if (TimeoutDefault
== 0) {
846 DEBUG ((EFI_D_INFO
, "\n\nStart showing progress bar... Press any key to stop it! ...Zzz....\n"));
848 SetMem (&Foreground
, sizeof (EFI_GRAPHICS_OUTPUT_BLT_PIXEL
), 0xff);
849 SetMem (&Background
, sizeof (EFI_GRAPHICS_OUTPUT_BLT_PIXEL
), 0x0);
850 SetMem (&Color
, sizeof (EFI_GRAPHICS_OUTPUT_BLT_PIXEL
), 0xff);
853 // Clear the progress status bar first
855 TmpStr
= GetStringById (STRING_TOKEN (STR_START_BOOT_OPTION
));
856 if (TmpStr
!= NULL
) {
857 PlatformBdsShowProgress (Foreground
, Background
, TmpStr
, Color
, 0, 0);
860 TimeoutRemain
= TimeoutDefault
;
861 while (TimeoutRemain
!= 0) {
862 DEBUG ((EFI_D_INFO
, "Showing progress bar...Remaining %d second!\n", TimeoutRemain
));
864 Status
= WaitForSingleEvent (gST
->ConIn
->WaitForKey
, ONE_SECOND
);
865 if (Status
!= EFI_TIMEOUT
) {
873 if (TmpStr
!= NULL
) {
874 PlatformBdsShowProgress (
879 ((TimeoutDefault
- TimeoutRemain
) * 100 / TimeoutDefault
),
884 gBS
->FreePool (TmpStr
);
889 if (TimeoutRemain
== 0) {
894 // User pressed some key
896 Status
= gST
->ConIn
->ReadKeyStroke (gST
->ConIn
, &Key
);
897 if (EFI_ERROR (Status
)) {
901 if (Key
.UnicodeChar
== CHAR_CARRIAGE_RETURN
) {
903 // User pressed enter, equivalent to select "continue"
912 This function is the main entry of the platform setup entry.
913 The function will present the main menu of the system setup,
914 this is the platform reference part and can be customize.
917 @param TimeoutDefault The fault time out value before the system
919 @param ConnectAllHappened The indicater to check if the connect all have
924 PlatformBdsEnterFrontPage (
925 IN UINT16 TimeoutDefault
,
926 IN BOOLEAN ConnectAllHappened
931 PERF_START (0, "BdsTimeOut", "BDS", 0);
933 // Indicate if we need connect all in the platform setup
935 if (ConnectAllHappened
) {
936 gConnectAllHappened
= TRUE
;
939 if (TimeoutDefault
!= 0xffff) {
940 Status
= ShowProgress (TimeoutDefault
);
943 // Ensure screen is clear when switch Console from Graphics mode to Text mode
945 gST
->ConOut
->EnableCursor (gST
->ConOut
, TRUE
);
946 gST
->ConOut
->ClearScreen (gST
->ConOut
);
948 if (EFI_ERROR (Status
)) {
950 // Timeout or user press enter to continue
958 InitializeFrontPage (FALSE
);
961 // Update Front Page strings
963 UpdateFrontPageStrings ();
966 Status
= CallFrontPage ();
969 // If gCallbackKey is greater than 1 and less or equal to 5,
970 // it will lauch configuration utilities.
973 // 4 = device manager
974 // 5 = boot maintainenance manager
976 if (gCallbackKey
!= 0) {
979 (EFI_SOFTWARE_DXE_BS_DRIVER
| EFI_SW_PC_USER_SETUP
)
983 // Based on the key that was set, we can determine what to do
985 switch (gCallbackKey
) {
987 // The first 4 entries in the Front Page are to be GUARANTEED to remain constant so IHV's can
988 // describe to their customers in documentation how to find their setup information (namely
989 // under the device manager and specific buckets)
991 // These entries consist of the Continue, Select language, Boot Manager, and Device Manager
993 case FRONT_PAGE_KEY_CONTINUE
:
999 case FRONT_PAGE_KEY_LANGUAGE
:
1001 // User made a language setting change - display front page again
1005 case FRONT_PAGE_KEY_BOOT_MANAGER
:
1007 // User chose to run the Boot Manager
1012 case FRONT_PAGE_KEY_DEVICE_MANAGER
:
1014 // Display the Device Manager
1017 CallDeviceManager();
1018 } while (gCallbackKey
== FRONT_PAGE_KEY_DEVICE_MANAGER
);
1021 case FRONT_PAGE_KEY_BOOT_MAINTAIN
:
1023 // Display the Boot Maintenance Manager
1025 BdsStartBootMaint ();
1029 } while ((Status
== EFI_SUCCESS
) && (gCallbackKey
!= FRONT_PAGE_KEY_CONTINUE
));
1032 //Will leave browser, check any reset required change is applied? if yes, reset system
1034 SetupResetReminder ();
1038 // Automatically load current entry
1039 // Note: The following lines of code only execute when Auto boot
1042 PERF_END (0, "BdsTimeOut", "BDS", 0);