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
;
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 GetNextLanguage (&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
),
232 ASSERT_EFI_ERROR(Status
);
233 FreePool (BestLanguage
);
238 FreePool (PlatformSupportedLanguages
);
240 FreePool (LanguageString
);
243 case FRONT_PAGE_KEY_BOOT_MANAGER
:
249 case FRONT_PAGE_KEY_DEVICE_MANAGER
:
255 case FRONT_PAGE_KEY_BOOT_MAINTAIN
:
257 // Boot Maintenance Manager
266 *ActionRequest
= EFI_BROWSER_ACTION_REQUEST_EXIT
;
272 Initialize HII information for the FrontPage
275 @param InitializeHiiData TRUE if HII elements need to be initialized.
277 @retval EFI_SUCCESS The operation is successful.
278 @retval EFI_DEVICE_ERROR If the dynamic opcode creation failed.
282 InitializeFrontPage (
283 IN BOOLEAN InitializeHiiData
287 CHAR8
*LanguageString
;
293 CHAR16
*StringBuffer
;
295 EFI_HII_HANDLE HiiHandle
;
296 VOID
*OptionsOpCodeHandle
;
297 VOID
*StartOpCodeHandle
;
298 VOID
*EndOpCodeHandle
;
299 EFI_IFR_GUID_LABEL
*StartLabel
;
300 EFI_IFR_GUID_LABEL
*EndLabel
;
303 if (InitializeHiiData
) {
305 // Initialize the Device Manager
307 InitializeDeviceManager ();
310 // Initialize the Device Manager
312 InitializeBootManager ();
317 // Locate Hii relative protocols
319 Status
= gBS
->LocateProtocol (&gEfiHiiDatabaseProtocolGuid
, NULL
, (VOID
**) &gHiiDatabase
);
320 if (EFI_ERROR (Status
)) {
324 Status
= gBS
->LocateProtocol (&gEfiHiiStringProtocolGuid
, NULL
, (VOID
**) &gHiiString
);
325 if (EFI_ERROR (Status
)) {
329 Status
= gBS
->LocateProtocol (&gEfiFormBrowser2ProtocolGuid
, NULL
, (VOID
**) &gFormBrowser2
);
330 if (EFI_ERROR (Status
)) {
334 Status
= gBS
->LocateProtocol (&gEfiHiiConfigRoutingProtocolGuid
, NULL
, (VOID
**) &gHiiConfigRouting
);
335 if (EFI_ERROR (Status
)) {
340 // Install Device Path Protocol and Config Access protocol to driver handle
342 Status
= gBS
->InstallMultipleProtocolInterfaces (
343 &gFrontPagePrivate
.DriverHandle
,
344 &gEfiDevicePathProtocolGuid
,
345 &mFrontPageHiiVendorDevicePath
,
346 &gEfiHiiConfigAccessProtocolGuid
,
347 &gFrontPagePrivate
.ConfigAccess
,
350 ASSERT_EFI_ERROR (Status
);
353 // Publish our HII data
355 gFrontPagePrivate
.HiiHandle
= HiiAddPackages (
357 gFrontPagePrivate
.DriverHandle
,
362 if (gFrontPagePrivate
.HiiHandle
== NULL
) {
363 return EFI_OUT_OF_RESOURCES
;
369 // Init OpCode Handle and Allocate space for creation of UpdateData Buffer
371 StartOpCodeHandle
= HiiAllocateOpCodeHandle ();
372 ASSERT (StartOpCodeHandle
!= NULL
);
374 EndOpCodeHandle
= HiiAllocateOpCodeHandle ();
375 ASSERT (EndOpCodeHandle
!= NULL
);
377 OptionsOpCodeHandle
= HiiAllocateOpCodeHandle ();
378 ASSERT (OptionsOpCodeHandle
!= NULL
);
380 // Create Hii Extend Label OpCode as the start opcode
382 StartLabel
= (EFI_IFR_GUID_LABEL
*) HiiCreateGuidOpCode (StartOpCodeHandle
, &gEfiIfrTianoGuid
, NULL
, sizeof (EFI_IFR_GUID_LABEL
));
383 StartLabel
->ExtendOpCode
= EFI_IFR_EXTEND_OP_LABEL
;
384 StartLabel
->Number
= LABEL_SELECT_LANGUAGE
;
387 // Create Hii Extend Label OpCode as the end opcode
389 EndLabel
= (EFI_IFR_GUID_LABEL
*) HiiCreateGuidOpCode (EndOpCodeHandle
, &gEfiIfrTianoGuid
, NULL
, sizeof (EFI_IFR_GUID_LABEL
));
390 EndLabel
->ExtendOpCode
= EFI_IFR_EXTEND_OP_LABEL
;
391 EndLabel
->Number
= LABEL_END
;
394 // Collect the languages from what our current Language support is based on our VFR
396 HiiHandle
= gFrontPagePrivate
.HiiHandle
;
397 LanguageString
= HiiGetSupportedLanguages (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
;
426 if (gFrontPagePrivate
.LanguageToken
== NULL
) {
427 while (*LangCode
!= 0) {
428 GetNextLanguage (&LangCode
, Lang
);
431 gFrontPagePrivate
.LanguageToken
= AllocatePool (OptionCount
* sizeof (EFI_STRING_ID
));
432 ASSERT (gFrontPagePrivate
.LanguageToken
!= NULL
);
437 LangCode
= LanguageString
;
438 while (*LangCode
!= 0) {
439 GetNextLanguage (&LangCode
, Lang
);
443 // Get Language Name from String Package. The StringId of Printable Language
444 // Name is always 1 which is generated by StringGather Tool.
447 StringBuffer
= AllocatePool (BufferSize
);
448 Status
= gHiiString
->GetString (
452 PRINTABLE_LANGUAGE_NAME_STRING_ID
,
457 if (Status
== EFI_BUFFER_TOO_SMALL
) {
458 FreePool (StringBuffer
);
459 StringBuffer
= AllocatePool (BufferSize
);
460 Status
= gHiiString
->GetString (
464 PRINTABLE_LANGUAGE_NAME_STRING_ID
,
470 ASSERT_EFI_ERROR (Status
);
473 // Save the string Id for each language
475 gFrontPagePrivate
.LanguageToken
[OptionCount
] = HiiSetString (HiiHandle
, 0, StringBuffer
, NULL
);
476 FreePool (StringBuffer
);
479 if (AsciiStrCmp (Lang
, BestLanguage
) == 0) {
480 HiiCreateOneOfOptionOpCode (
482 gFrontPagePrivate
.LanguageToken
[OptionCount
],
483 EFI_IFR_OPTION_DEFAULT
,
484 EFI_IFR_NUMERIC_SIZE_1
,
488 HiiCreateOneOfOptionOpCode (
490 gFrontPagePrivate
.LanguageToken
[OptionCount
],
492 EFI_IFR_NUMERIC_SIZE_1
,
500 if (CurrentLang
!= NULL
) {
501 FreePool (CurrentLang
);
503 FreePool (BestLanguage
);
505 FreePool (LanguageString
);
507 HiiCreateOneOfOpCode (
509 FRONT_PAGE_KEY_LANGUAGE
,
512 STRING_TOKEN (STR_LANGUAGE_SELECT
),
513 STRING_TOKEN (STR_LANGUAGE_SELECT_HELP
),
514 EFI_IFR_FLAG_CALLBACK
,
515 EFI_IFR_NUMERIC_SIZE_1
,
520 Status
= HiiUpdateForm (
524 StartOpCodeHandle
, // LABEL_SELECT_LANGUAGE
525 EndOpCodeHandle
// LABEL_END
528 HiiFreeOpCodeHandle (StartOpCodeHandle
);
529 HiiFreeOpCodeHandle (EndOpCodeHandle
);
530 HiiFreeOpCodeHandle (OptionsOpCodeHandle
);
535 Call the browser and display the front page
537 @return Status code that will be returned by
538 EFI_FORM_BROWSER2_PROTOCOL.SendForm ().
547 EFI_BROWSER_ACTION_REQUEST ActionRequest
;
550 // Begin waiting for USER INPUT
554 (EFI_SOFTWARE_DXE_BS_DRIVER
| EFI_SW_PC_INPUT_WAIT
)
557 ActionRequest
= EFI_BROWSER_ACTION_REQUEST_NONE
;
558 Status
= gFormBrowser2
->SendForm (
560 &gFrontPagePrivate
.HiiHandle
,
568 // Check whether user change any option setting which needs a reset to be effective
570 if (ActionRequest
== EFI_BROWSER_ACTION_REQUEST_RESET
) {
571 EnableResetRequired ();
578 Acquire the string associated with the ProducerGuid and return it.
581 @param ProducerGuid The Guid to search the HII database for
582 @param Token The token value of the string to extract
583 @param String The string that is extracted
585 @retval EFI_SUCCESS The function returns EFI_SUCCESS always.
590 IN EFI_GUID
*ProducerGuid
,
591 IN EFI_STRING_ID Token
,
595 EFI_STRING TmpString
;
597 TmpString
= HiiGetPackageString (ProducerGuid
, Token
, NULL
);
598 if (TmpString
== NULL
) {
599 *String
= GetStringById (STRING_TOKEN (STR_MISSING_STRING
));
608 Convert Processor Frequency Data to a string
610 @param ProcessorFrequency The frequency data to process
611 @param String The string that is created
615 ConvertProcessorToString (
616 IN EFI_PROCESSOR_CORE_FREQUENCY_DATA
*ProcessorFrequency
,
620 CHAR16
*StringBuffer
;
624 if (ProcessorFrequency
->Exponent
>= 6) {
625 FreqMhz
= ProcessorFrequency
->Value
;
626 for (Index
= 0; Index
< (UINTN
) (ProcessorFrequency
->Exponent
- 6); Index
++) {
633 StringBuffer
= AllocateZeroPool (0x20);
634 ASSERT (StringBuffer
!= NULL
);
635 Index
= UnicodeValueToString (StringBuffer
, LEFT_JUSTIFY
, FreqMhz
/ 1000, 3);
636 StrCat (StringBuffer
, L
".");
637 UnicodeValueToString (StringBuffer
+ Index
+ 1, PREFIX_ZERO
, (FreqMhz
% 1000) / 10, 2);
638 StrCat (StringBuffer
, L
" GHz");
640 *String
= (CHAR16
*) StringBuffer
;
646 Convert Memory Size to a string.
648 @param MemorySize The size of the memory to process
649 @param String The string that is created
653 ConvertMemorySizeToString (
654 IN UINT32 MemorySize
,
658 CHAR16
*StringBuffer
;
660 StringBuffer
= AllocateZeroPool (0x20);
661 ASSERT (StringBuffer
!= NULL
);
662 UnicodeValueToString (StringBuffer
, LEFT_JUSTIFY
, MemorySize
, 6);
663 StrCat (StringBuffer
, L
" MB RAM");
665 *String
= (CHAR16
*) StringBuffer
;
671 Update the banner information for the Front Page based on DataHub information.
675 UpdateFrontPageStrings (
680 EFI_STRING_ID TokenToUpdate
;
682 UINT64 MonotonicCount
;
683 EFI_DATA_HUB_PROTOCOL
*DataHub
;
684 EFI_DATA_RECORD_HEADER
*Record
;
685 EFI_SUBCLASS_TYPE1_HEADER
*DataHeader
;
686 EFI_MISC_BIOS_VENDOR_DATA
*BiosVendor
;
687 EFI_MISC_SYSTEM_MANUFACTURER_DATA
*SystemManufacturer
;
688 EFI_PROCESSOR_VERSION_DATA
*ProcessorVersion
;
689 EFI_PROCESSOR_CORE_FREQUENCY_DATA
*ProcessorFrequency
;
690 EFI_MEMORY_ARRAY_START_ADDRESS_DATA
*MemoryArray
;
693 ZeroMem (Find
, sizeof (Find
));
696 // Update Front Page strings
698 Status
= gBS
->LocateProtocol (
699 &gEfiDataHubProtocolGuid
,
703 ASSERT_EFI_ERROR (Status
);
708 Status
= DataHub
->GetNextRecord (DataHub
, &MonotonicCount
, NULL
, &Record
);
709 if (Record
->DataRecordClass
== EFI_DATA_RECORD_CLASS_DATA
) {
710 DataHeader
= (EFI_SUBCLASS_TYPE1_HEADER
*) (Record
+ 1);
711 if (CompareGuid (&Record
->DataRecordGuid
, &gEfiMiscSubClassGuid
) &&
712 (DataHeader
->RecordType
== EFI_MISC_BIOS_VENDOR_RECORD_NUMBER
)
714 BiosVendor
= (EFI_MISC_BIOS_VENDOR_DATA
*) (DataHeader
+ 1);
715 GetProducerString (&Record
->ProducerName
, BiosVendor
->BiosVersion
, &NewString
);
716 TokenToUpdate
= STRING_TOKEN (STR_FRONT_PAGE_BIOS_VERSION
);
717 HiiSetString (gFrontPagePrivate
.HiiHandle
, TokenToUpdate
, NewString
, NULL
);
718 FreePool (NewString
);
722 if (CompareGuid (&Record
->DataRecordGuid
, &gEfiMiscSubClassGuid
) &&
723 (DataHeader
->RecordType
== EFI_MISC_SYSTEM_MANUFACTURER_RECORD_NUMBER
)
725 SystemManufacturer
= (EFI_MISC_SYSTEM_MANUFACTURER_DATA
*) (DataHeader
+ 1);
726 GetProducerString (&Record
->ProducerName
, SystemManufacturer
->SystemProductName
, &NewString
);
727 TokenToUpdate
= STRING_TOKEN (STR_FRONT_PAGE_COMPUTER_MODEL
);
728 HiiSetString (gFrontPagePrivate
.HiiHandle
, TokenToUpdate
, NewString
, NULL
);
729 FreePool (NewString
);
733 if (CompareGuid (&Record
->DataRecordGuid
, &gEfiProcessorSubClassGuid
) &&
734 (DataHeader
->RecordType
== ProcessorVersionRecordType
)
736 ProcessorVersion
= (EFI_PROCESSOR_VERSION_DATA
*) (DataHeader
+ 1);
737 GetProducerString (&Record
->ProducerName
, *ProcessorVersion
, &NewString
);
738 TokenToUpdate
= STRING_TOKEN (STR_FRONT_PAGE_CPU_MODEL
);
739 HiiSetString (gFrontPagePrivate
.HiiHandle
, TokenToUpdate
, NewString
, NULL
);
740 FreePool (NewString
);
744 if (CompareGuid (&Record
->DataRecordGuid
, &gEfiProcessorSubClassGuid
) &&
745 (DataHeader
->RecordType
== ProcessorCoreFrequencyRecordType
)
747 ProcessorFrequency
= (EFI_PROCESSOR_CORE_FREQUENCY_DATA
*) (DataHeader
+ 1);
748 ConvertProcessorToString (ProcessorFrequency
, &NewString
);
749 TokenToUpdate
= STRING_TOKEN (STR_FRONT_PAGE_CPU_SPEED
);
750 HiiSetString (gFrontPagePrivate
.HiiHandle
, TokenToUpdate
, NewString
, NULL
);
751 FreePool (NewString
);
755 if (CompareGuid (&Record
->DataRecordGuid
, &gEfiMemorySubClassGuid
) &&
756 (DataHeader
->RecordType
== EFI_MEMORY_ARRAY_START_ADDRESS_RECORD_NUMBER
)
758 MemoryArray
= (EFI_MEMORY_ARRAY_START_ADDRESS_DATA
*) (DataHeader
+ 1);
759 ConvertMemorySizeToString (
760 (UINT32
)(RShiftU64((MemoryArray
->MemoryArrayEndAddress
- MemoryArray
->MemoryArrayStartAddress
+ 1), 20)),
763 TokenToUpdate
= STRING_TOKEN (STR_FRONT_PAGE_MEMORY_SIZE
);
764 HiiSetString (gFrontPagePrivate
.HiiHandle
, TokenToUpdate
, NewString
, NULL
);
765 FreePool (NewString
);
769 } while (!EFI_ERROR (Status
) && (MonotonicCount
!= 0) && !(Find
[0] && Find
[1] && Find
[2] && Find
[3] && Find
[4]));
775 Function waits for a given event to fire, or for an optional timeout to expire.
777 @param Event The event to wait for
778 @param Timeout An optional timeout value in 100 ns units.
780 @retval EFI_SUCCESS Event fired before Timeout expired.
781 @retval EFI_TIME_OUT Timout expired before Event fired..
787 IN UINT64 Timeout OPTIONAL
792 EFI_EVENT TimerEvent
;
793 EFI_EVENT WaitList
[2];
797 // Create a timer event
799 Status
= gBS
->CreateEvent (EVT_TIMER
, 0, NULL
, NULL
, &TimerEvent
);
800 if (!EFI_ERROR (Status
)) {
802 // Set the timer event
811 // Wait for the original event or the timer
814 WaitList
[1] = TimerEvent
;
815 Status
= gBS
->WaitForEvent (2, WaitList
, &Index
);
816 gBS
->CloseEvent (TimerEvent
);
819 // If the timer expired, change the return to timed out
821 if (!EFI_ERROR (Status
) && Index
== 1) {
822 Status
= EFI_TIMEOUT
;
827 // No timeout... just wait on the event
829 Status
= gBS
->WaitForEvent (1, &Event
, &Index
);
830 ASSERT (!EFI_ERROR (Status
));
838 Function show progress bar to wait for user input.
841 @param TimeoutDefault The fault time out value before the system continue to boot.
843 @retval EFI_SUCCESS User pressed some key except "Enter"
844 @retval EFI_TIME_OUT Timout expired or user press "Enter"
849 IN UINT16 TimeoutDefault
854 EFI_GRAPHICS_OUTPUT_BLT_PIXEL Foreground
;
855 EFI_GRAPHICS_OUTPUT_BLT_PIXEL Background
;
856 EFI_GRAPHICS_OUTPUT_BLT_PIXEL Color
;
858 UINT16 TimeoutRemain
;
860 if (TimeoutDefault
== 0) {
864 DEBUG ((EFI_D_INFO
, "\n\nStart showing progress bar... Press any key to stop it! ...Zzz....\n"));
866 SetMem (&Foreground
, sizeof (EFI_GRAPHICS_OUTPUT_BLT_PIXEL
), 0xff);
867 SetMem (&Background
, sizeof (EFI_GRAPHICS_OUTPUT_BLT_PIXEL
), 0x0);
868 SetMem (&Color
, sizeof (EFI_GRAPHICS_OUTPUT_BLT_PIXEL
), 0xff);
871 // Clear the progress status bar first
873 TmpStr
= GetStringById (STRING_TOKEN (STR_START_BOOT_OPTION
));
874 if (TmpStr
!= NULL
) {
875 PlatformBdsShowProgress (Foreground
, Background
, TmpStr
, Color
, 0, 0);
878 TimeoutRemain
= TimeoutDefault
;
879 while (TimeoutRemain
!= 0) {
880 DEBUG ((EFI_D_INFO
, "Showing progress bar...Remaining %d second!\n", TimeoutRemain
));
882 Status
= WaitForSingleEvent (gST
->ConIn
->WaitForKey
, ONE_SECOND
);
883 if (Status
!= EFI_TIMEOUT
) {
891 if (TmpStr
!= NULL
) {
892 PlatformBdsShowProgress (
897 ((TimeoutDefault
- TimeoutRemain
) * 100 / TimeoutDefault
),
902 gBS
->FreePool (TmpStr
);
907 if (TimeoutRemain
== 0) {
912 // User pressed some key
914 Status
= gST
->ConIn
->ReadKeyStroke (gST
->ConIn
, &Key
);
915 if (EFI_ERROR (Status
)) {
919 if (Key
.UnicodeChar
== CHAR_CARRIAGE_RETURN
) {
921 // User pressed enter, equivalent to select "continue"
930 This function is the main entry of the platform setup entry.
931 The function will present the main menu of the system setup,
932 this is the platform reference part and can be customize.
935 @param TimeoutDefault The fault time out value before the system
937 @param ConnectAllHappened The indicater to check if the connect all have
942 PlatformBdsEnterFrontPage (
943 IN UINT16 TimeoutDefault
,
944 IN BOOLEAN ConnectAllHappened
949 PERF_START (0, "BdsTimeOut", "BDS", 0);
951 // Indicate if we need connect all in the platform setup
953 if (ConnectAllHappened
) {
954 gConnectAllHappened
= TRUE
;
957 if (TimeoutDefault
!= 0xffff) {
958 Status
= ShowProgress (TimeoutDefault
);
961 // Ensure screen is clear when switch Console from Graphics mode to Text mode
963 gST
->ConOut
->EnableCursor (gST
->ConOut
, TRUE
);
964 gST
->ConOut
->ClearScreen (gST
->ConOut
);
966 if (EFI_ERROR (Status
)) {
968 // Timeout or user press enter to continue
976 InitializeFrontPage (FALSE
);
979 // Update Front Page strings
981 UpdateFrontPageStrings ();
984 Status
= CallFrontPage ();
987 // If gCallbackKey is greater than 1 and less or equal to 5,
988 // it will lauch configuration utilities.
991 // 4 = device manager
992 // 5 = boot maintainenance manager
994 if (gCallbackKey
!= 0) {
997 (EFI_SOFTWARE_DXE_BS_DRIVER
| EFI_SW_PC_USER_SETUP
)
1001 // Based on the key that was set, we can determine what to do
1003 switch (gCallbackKey
) {
1005 // The first 4 entries in the Front Page are to be GUARANTEED to remain constant so IHV's can
1006 // describe to their customers in documentation how to find their setup information (namely
1007 // under the device manager and specific buckets)
1009 // These entries consist of the Continue, Select language, Boot Manager, and Device Manager
1011 case FRONT_PAGE_KEY_CONTINUE
:
1013 // User hit continue
1017 case FRONT_PAGE_KEY_LANGUAGE
:
1019 // User made a language setting change - display front page again
1023 case FRONT_PAGE_KEY_BOOT_MANAGER
:
1025 // User chose to run the Boot Manager
1030 case FRONT_PAGE_KEY_DEVICE_MANAGER
:
1032 // Display the Device Manager
1035 CallDeviceManager();
1036 } while (gCallbackKey
== FRONT_PAGE_KEY_DEVICE_MANAGER
);
1039 case FRONT_PAGE_KEY_BOOT_MAINTAIN
:
1041 // Display the Boot Maintenance Manager
1043 BdsStartBootMaint ();
1047 } while ((Status
== EFI_SUCCESS
) && (gCallbackKey
!= FRONT_PAGE_KEY_CONTINUE
));
1050 //Will leave browser, check any reset required change is applied? if yes, reset system
1052 SetupResetReminder ();
1056 // Automatically load current entry
1057 // Note: The following lines of code only execute when Auto boot
1060 PERF_END (0, "BdsTimeOut", "BDS", 0);