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
102 This function processes the results of changes in configuration.
105 @param This Points to the EFI_HII_CONFIG_ACCESS_PROTOCOL.
106 @param Configuration A null-terminated Unicode string in <ConfigResp> format.
107 @param Progress A pointer to a string filled in with the offset of the most
108 recent '&' before the first failing name/value pair (or the
109 beginning of the string if the failure is in the first
110 name/value pair) or the terminating NULL if all was successful.
112 @retval EFI_SUCCESS The Results is processed successfully.
113 @retval EFI_INVALID_PARAMETER Configuration is NULL.
114 @retval EFI_NOT_FOUND Routing data doesn't match any storage in this driver.
120 IN CONST EFI_HII_CONFIG_ACCESS_PROTOCOL
*This
,
121 IN CONST EFI_STRING Configuration
,
122 OUT EFI_STRING
*Progress
125 if (Configuration
== NULL
) {
126 return EFI_INVALID_PARAMETER
;
129 if (Progress
== NULL
) {
130 return EFI_INVALID_PARAMETER
;
133 return EFI_NOT_FOUND
;
137 This function processes the results of changes in configuration.
140 @param This Points to the EFI_HII_CONFIG_ACCESS_PROTOCOL.
141 @param Action Specifies the type of action taken by the browser.
142 @param QuestionId A unique value which is sent to the original exporting driver
143 so that it can identify the type of data to expect.
144 @param Type The type of value for the question.
145 @param Value A pointer to the data being sent to the original exporting driver.
146 @param ActionRequest On return, points to the action requested by the callback function.
148 @retval EFI_SUCCESS The callback successfully handled the action.
149 @retval EFI_OUT_OF_RESOURCES Not enough storage is available to hold the variable and its data.
150 @retval EFI_DEVICE_ERROR The variable could not be saved.
151 @retval EFI_UNSUPPORTED The specified Action is not supported by the callback.
157 IN CONST EFI_HII_CONFIG_ACCESS_PROTOCOL
*This
,
158 IN EFI_BROWSER_ACTION Action
,
159 IN EFI_QUESTION_ID QuestionId
,
161 IN EFI_IFR_TYPE_VALUE
*Value
,
162 OUT EFI_BROWSER_ACTION_REQUEST
*ActionRequest
165 CHAR8
*LanguageString
;
170 CHAR8
*PlatformSupportedLanguages
;
173 if ((Value
== NULL
) || (ActionRequest
== NULL
)) {
174 return EFI_INVALID_PARAMETER
;
177 gCallbackKey
= QuestionId
;
180 // The first 4 entries in the Front Page are to be GUARANTEED to remain constant so IHV's can
181 // describe to their customers in documentation how to find their setup information (namely
182 // under the device manager and specific buckets)
184 switch (QuestionId
) {
185 case FRONT_PAGE_KEY_CONTINUE
:
187 // This is the continue - clear the screen and return an error to get out of FrontPage loop
191 case FRONT_PAGE_KEY_LANGUAGE
:
193 // Collect the languages from what our current Language support is based on our VFR
195 LanguageString
= HiiGetSupportedLanguages (gFrontPagePrivate
.HiiHandle
);
196 ASSERT (LanguageString
!= NULL
);
198 // Allocate working buffer for RFC 4646 language in supported LanguageString.
200 Lang
= AllocatePool (AsciiStrSize (LanguageString
));
201 ASSERT (Lang
!= NULL
);
204 LangCode
= LanguageString
;
205 while (*LangCode
!= 0) {
206 GetNextLanguage (&LangCode
, Lang
);
208 if (Index
== Value
->u8
) {
215 PlatformSupportedLanguages
= GetEfiGlobalVariable (L
"PlatformLangCodes");
216 if (PlatformSupportedLanguages
== NULL
) {
217 PlatformSupportedLanguages
= AllocateCopyPool (
218 AsciiStrSize ((CHAR8
*) PcdGetPtr (PcdUefiVariableDefaultPlatformLangCodes
)),
219 (CHAR8
*) PcdGetPtr (PcdUefiVariableDefaultPlatformLangCodes
)
221 ASSERT (PlatformSupportedLanguages
!= NULL
);
225 // Select the best language in platform supported Language.
227 BestLanguage
= GetBestLanguage (
228 PlatformSupportedLanguages
,
233 if (BestLanguage
!= NULL
) {
234 Status
= gRT
->SetVariable (
236 &gEfiGlobalVariableGuid
,
237 EFI_VARIABLE_NON_VOLATILE
| EFI_VARIABLE_BOOTSERVICE_ACCESS
| EFI_VARIABLE_RUNTIME_ACCESS
,
238 AsciiStrSize (BestLanguage
),
241 ASSERT_EFI_ERROR(Status
);
242 FreePool (BestLanguage
);
247 FreePool (PlatformSupportedLanguages
);
249 FreePool (LanguageString
);
252 case FRONT_PAGE_KEY_BOOT_MANAGER
:
258 case FRONT_PAGE_KEY_DEVICE_MANAGER
:
264 case FRONT_PAGE_KEY_BOOT_MAINTAIN
:
266 // Boot Maintenance Manager
275 *ActionRequest
= EFI_BROWSER_ACTION_REQUEST_EXIT
;
281 Initialize HII information for the FrontPage
284 @param InitializeHiiData TRUE if HII elements need to be initialized.
286 @retval EFI_SUCCESS The operation is successful.
287 @retval EFI_DEVICE_ERROR If the dynamic opcode creation failed.
291 InitializeFrontPage (
292 IN BOOLEAN InitializeHiiData
296 CHAR8
*LanguageString
;
302 CHAR16
*StringBuffer
;
304 EFI_HII_HANDLE HiiHandle
;
305 VOID
*OptionsOpCodeHandle
;
306 VOID
*StartOpCodeHandle
;
307 VOID
*EndOpCodeHandle
;
308 EFI_IFR_GUID_LABEL
*StartLabel
;
309 EFI_IFR_GUID_LABEL
*EndLabel
;
312 if (InitializeHiiData
) {
314 // Initialize the Device Manager
316 InitializeDeviceManager ();
319 // Initialize the Device Manager
321 InitializeBootManager ();
326 // Locate Hii relative protocols
328 Status
= gBS
->LocateProtocol (&gEfiHiiDatabaseProtocolGuid
, NULL
, (VOID
**) &gHiiDatabase
);
329 if (EFI_ERROR (Status
)) {
333 Status
= gBS
->LocateProtocol (&gEfiHiiStringProtocolGuid
, NULL
, (VOID
**) &gHiiString
);
334 if (EFI_ERROR (Status
)) {
338 Status
= gBS
->LocateProtocol (&gEfiFormBrowser2ProtocolGuid
, NULL
, (VOID
**) &gFormBrowser2
);
339 if (EFI_ERROR (Status
)) {
343 Status
= gBS
->LocateProtocol (&gEfiHiiConfigRoutingProtocolGuid
, NULL
, (VOID
**) &gHiiConfigRouting
);
344 if (EFI_ERROR (Status
)) {
349 // Install Device Path Protocol and Config Access protocol to driver handle
351 Status
= gBS
->InstallMultipleProtocolInterfaces (
352 &gFrontPagePrivate
.DriverHandle
,
353 &gEfiDevicePathProtocolGuid
,
354 &mFrontPageHiiVendorDevicePath
,
355 &gEfiHiiConfigAccessProtocolGuid
,
356 &gFrontPagePrivate
.ConfigAccess
,
359 ASSERT_EFI_ERROR (Status
);
362 // Publish our HII data
364 gFrontPagePrivate
.HiiHandle
= HiiAddPackages (
366 gFrontPagePrivate
.DriverHandle
,
371 if (gFrontPagePrivate
.HiiHandle
== NULL
) {
372 return EFI_OUT_OF_RESOURCES
;
378 // Init OpCode Handle and Allocate space for creation of UpdateData Buffer
380 StartOpCodeHandle
= HiiAllocateOpCodeHandle ();
381 ASSERT (StartOpCodeHandle
!= NULL
);
383 EndOpCodeHandle
= HiiAllocateOpCodeHandle ();
384 ASSERT (EndOpCodeHandle
!= NULL
);
386 OptionsOpCodeHandle
= HiiAllocateOpCodeHandle ();
387 ASSERT (OptionsOpCodeHandle
!= NULL
);
389 // Create Hii Extend Label OpCode as the start opcode
391 StartLabel
= (EFI_IFR_GUID_LABEL
*) HiiCreateGuidOpCode (StartOpCodeHandle
, &gEfiIfrTianoGuid
, NULL
, sizeof (EFI_IFR_GUID_LABEL
));
392 StartLabel
->ExtendOpCode
= EFI_IFR_EXTEND_OP_LABEL
;
393 StartLabel
->Number
= LABEL_SELECT_LANGUAGE
;
396 // Create Hii Extend Label OpCode as the end opcode
398 EndLabel
= (EFI_IFR_GUID_LABEL
*) HiiCreateGuidOpCode (EndOpCodeHandle
, &gEfiIfrTianoGuid
, NULL
, sizeof (EFI_IFR_GUID_LABEL
));
399 EndLabel
->ExtendOpCode
= EFI_IFR_EXTEND_OP_LABEL
;
400 EndLabel
->Number
= LABEL_END
;
403 // Collect the languages from what our current Language support is based on our VFR
405 HiiHandle
= gFrontPagePrivate
.HiiHandle
;
406 LanguageString
= HiiGetSupportedLanguages (HiiHandle
);
407 ASSERT (LanguageString
!= NULL
);
409 // Allocate working buffer for RFC 4646 language in supported LanguageString.
411 Lang
= AllocatePool (AsciiStrSize (LanguageString
));
412 ASSERT (Lang
!= NULL
);
414 CurrentLang
= GetEfiGlobalVariable (L
"PlatformLang");
416 // Select the best language in LanguageString as the default one.
418 BestLanguage
= GetBestLanguage (
421 (CurrentLang
!= NULL
) ? CurrentLang
: "",
422 (CHAR8
*) PcdGetPtr (PcdUefiVariableDefaultPlatformLang
),
427 // BestLanguage must be selected as it is the first language in LanguageString by default
429 ASSERT (BestLanguage
!= NULL
);
432 LangCode
= LanguageString
;
435 if (gFrontPagePrivate
.LanguageToken
== NULL
) {
436 while (*LangCode
!= 0) {
437 GetNextLanguage (&LangCode
, Lang
);
440 gFrontPagePrivate
.LanguageToken
= AllocatePool (OptionCount
* sizeof (EFI_STRING_ID
));
441 ASSERT (gFrontPagePrivate
.LanguageToken
!= NULL
);
446 LangCode
= LanguageString
;
447 while (*LangCode
!= 0) {
448 GetNextLanguage (&LangCode
, Lang
);
452 // Get Language Name from String Package. The StringId of Printable Language
453 // Name is always 1 which is generated by StringGather Tool.
456 StringBuffer
= AllocatePool (BufferSize
);
457 Status
= gHiiString
->GetString (
461 PRINTABLE_LANGUAGE_NAME_STRING_ID
,
466 if (Status
== EFI_BUFFER_TOO_SMALL
) {
467 FreePool (StringBuffer
);
468 StringBuffer
= AllocatePool (BufferSize
);
469 Status
= gHiiString
->GetString (
473 PRINTABLE_LANGUAGE_NAME_STRING_ID
,
479 ASSERT_EFI_ERROR (Status
);
482 // Save the string Id for each language
484 gFrontPagePrivate
.LanguageToken
[OptionCount
] = HiiSetString (HiiHandle
, 0, StringBuffer
, NULL
);
485 FreePool (StringBuffer
);
488 if (AsciiStrCmp (Lang
, BestLanguage
) == 0) {
489 HiiCreateOneOfOptionOpCode (
491 gFrontPagePrivate
.LanguageToken
[OptionCount
],
492 EFI_IFR_OPTION_DEFAULT
,
493 EFI_IFR_NUMERIC_SIZE_1
,
497 HiiCreateOneOfOptionOpCode (
499 gFrontPagePrivate
.LanguageToken
[OptionCount
],
501 EFI_IFR_NUMERIC_SIZE_1
,
509 if (CurrentLang
!= NULL
) {
510 FreePool (CurrentLang
);
512 FreePool (BestLanguage
);
514 FreePool (LanguageString
);
516 HiiCreateOneOfOpCode (
518 FRONT_PAGE_KEY_LANGUAGE
,
521 STRING_TOKEN (STR_LANGUAGE_SELECT
),
522 STRING_TOKEN (STR_LANGUAGE_SELECT_HELP
),
523 EFI_IFR_FLAG_CALLBACK
,
524 EFI_IFR_NUMERIC_SIZE_1
,
529 Status
= HiiUpdateForm (
533 StartOpCodeHandle
, // LABEL_SELECT_LANGUAGE
534 EndOpCodeHandle
// LABEL_END
537 HiiFreeOpCodeHandle (StartOpCodeHandle
);
538 HiiFreeOpCodeHandle (EndOpCodeHandle
);
539 HiiFreeOpCodeHandle (OptionsOpCodeHandle
);
544 Call the browser and display the front page
546 @return Status code that will be returned by
547 EFI_FORM_BROWSER2_PROTOCOL.SendForm ().
556 EFI_BROWSER_ACTION_REQUEST ActionRequest
;
559 // Begin waiting for USER INPUT
563 (EFI_SOFTWARE_DXE_BS_DRIVER
| EFI_SW_PC_INPUT_WAIT
)
566 ActionRequest
= EFI_BROWSER_ACTION_REQUEST_NONE
;
567 Status
= gFormBrowser2
->SendForm (
569 &gFrontPagePrivate
.HiiHandle
,
577 // Check whether user change any option setting which needs a reset to be effective
579 if (ActionRequest
== EFI_BROWSER_ACTION_REQUEST_RESET
) {
580 EnableResetRequired ();
587 Acquire the string associated with the ProducerGuid and return it.
590 @param ProducerGuid The Guid to search the HII database for
591 @param Token The token value of the string to extract
592 @param String The string that is extracted
594 @retval EFI_SUCCESS The function returns EFI_SUCCESS always.
599 IN EFI_GUID
*ProducerGuid
,
600 IN EFI_STRING_ID Token
,
604 EFI_STRING TmpString
;
606 TmpString
= HiiGetPackageString (ProducerGuid
, Token
, NULL
);
607 if (TmpString
== NULL
) {
608 *String
= GetStringById (STRING_TOKEN (STR_MISSING_STRING
));
617 Convert Processor Frequency Data to a string
619 @param ProcessorFrequency The frequency data to process
620 @param String The string that is created
624 ConvertProcessorToString (
625 IN EFI_PROCESSOR_CORE_FREQUENCY_DATA
*ProcessorFrequency
,
629 CHAR16
*StringBuffer
;
633 if (ProcessorFrequency
->Exponent
>= 6) {
634 FreqMhz
= ProcessorFrequency
->Value
;
635 for (Index
= 0; Index
< (UINTN
) (ProcessorFrequency
->Exponent
- 6); Index
++) {
642 StringBuffer
= AllocateZeroPool (0x20);
643 ASSERT (StringBuffer
!= NULL
);
644 Index
= UnicodeValueToString (StringBuffer
, LEFT_JUSTIFY
, FreqMhz
/ 1000, 3);
645 StrCat (StringBuffer
, L
".");
646 UnicodeValueToString (StringBuffer
+ Index
+ 1, PREFIX_ZERO
, (FreqMhz
% 1000) / 10, 2);
647 StrCat (StringBuffer
, L
" GHz");
649 *String
= (CHAR16
*) StringBuffer
;
655 Convert Memory Size to a string.
657 @param MemorySize The size of the memory to process
658 @param String The string that is created
662 ConvertMemorySizeToString (
663 IN UINT32 MemorySize
,
667 CHAR16
*StringBuffer
;
669 StringBuffer
= AllocateZeroPool (0x20);
670 ASSERT (StringBuffer
!= NULL
);
671 UnicodeValueToString (StringBuffer
, LEFT_JUSTIFY
, MemorySize
, 6);
672 StrCat (StringBuffer
, L
" MB RAM");
674 *String
= (CHAR16
*) StringBuffer
;
680 Update the banner information for the Front Page based on DataHub information.
684 UpdateFrontPageStrings (
689 EFI_STRING_ID TokenToUpdate
;
691 UINT64 MonotonicCount
;
692 EFI_DATA_HUB_PROTOCOL
*DataHub
;
693 EFI_DATA_RECORD_HEADER
*Record
;
694 EFI_SUBCLASS_TYPE1_HEADER
*DataHeader
;
695 EFI_MISC_BIOS_VENDOR_DATA
*BiosVendor
;
696 EFI_MISC_SYSTEM_MANUFACTURER_DATA
*SystemManufacturer
;
697 EFI_PROCESSOR_VERSION_DATA
*ProcessorVersion
;
698 EFI_PROCESSOR_CORE_FREQUENCY_DATA
*ProcessorFrequency
;
699 EFI_MEMORY_ARRAY_START_ADDRESS_DATA
*MemoryArray
;
702 ZeroMem (Find
, sizeof (Find
));
705 // Update Front Page strings
707 Status
= gBS
->LocateProtocol (
708 &gEfiDataHubProtocolGuid
,
712 ASSERT_EFI_ERROR (Status
);
717 Status
= DataHub
->GetNextRecord (DataHub
, &MonotonicCount
, NULL
, &Record
);
718 if (Record
->DataRecordClass
== EFI_DATA_RECORD_CLASS_DATA
) {
719 DataHeader
= (EFI_SUBCLASS_TYPE1_HEADER
*) (Record
+ 1);
720 if (CompareGuid (&Record
->DataRecordGuid
, &gEfiMiscSubClassGuid
) &&
721 (DataHeader
->RecordType
== EFI_MISC_BIOS_VENDOR_RECORD_NUMBER
)
723 BiosVendor
= (EFI_MISC_BIOS_VENDOR_DATA
*) (DataHeader
+ 1);
724 GetProducerString (&Record
->ProducerName
, BiosVendor
->BiosVersion
, &NewString
);
725 TokenToUpdate
= STRING_TOKEN (STR_FRONT_PAGE_BIOS_VERSION
);
726 HiiSetString (gFrontPagePrivate
.HiiHandle
, TokenToUpdate
, NewString
, NULL
);
727 FreePool (NewString
);
731 if (CompareGuid (&Record
->DataRecordGuid
, &gEfiMiscSubClassGuid
) &&
732 (DataHeader
->RecordType
== EFI_MISC_SYSTEM_MANUFACTURER_RECORD_NUMBER
)
734 SystemManufacturer
= (EFI_MISC_SYSTEM_MANUFACTURER_DATA
*) (DataHeader
+ 1);
735 GetProducerString (&Record
->ProducerName
, SystemManufacturer
->SystemProductName
, &NewString
);
736 TokenToUpdate
= STRING_TOKEN (STR_FRONT_PAGE_COMPUTER_MODEL
);
737 HiiSetString (gFrontPagePrivate
.HiiHandle
, TokenToUpdate
, NewString
, NULL
);
738 FreePool (NewString
);
742 if (CompareGuid (&Record
->DataRecordGuid
, &gEfiProcessorSubClassGuid
) &&
743 (DataHeader
->RecordType
== ProcessorVersionRecordType
)
745 ProcessorVersion
= (EFI_PROCESSOR_VERSION_DATA
*) (DataHeader
+ 1);
746 GetProducerString (&Record
->ProducerName
, *ProcessorVersion
, &NewString
);
747 TokenToUpdate
= STRING_TOKEN (STR_FRONT_PAGE_CPU_MODEL
);
748 HiiSetString (gFrontPagePrivate
.HiiHandle
, TokenToUpdate
, NewString
, NULL
);
749 FreePool (NewString
);
753 if (CompareGuid (&Record
->DataRecordGuid
, &gEfiProcessorSubClassGuid
) &&
754 (DataHeader
->RecordType
== ProcessorCoreFrequencyRecordType
)
756 ProcessorFrequency
= (EFI_PROCESSOR_CORE_FREQUENCY_DATA
*) (DataHeader
+ 1);
757 ConvertProcessorToString (ProcessorFrequency
, &NewString
);
758 TokenToUpdate
= STRING_TOKEN (STR_FRONT_PAGE_CPU_SPEED
);
759 HiiSetString (gFrontPagePrivate
.HiiHandle
, TokenToUpdate
, NewString
, NULL
);
760 FreePool (NewString
);
764 if (CompareGuid (&Record
->DataRecordGuid
, &gEfiMemorySubClassGuid
) &&
765 (DataHeader
->RecordType
== EFI_MEMORY_ARRAY_START_ADDRESS_RECORD_NUMBER
)
767 MemoryArray
= (EFI_MEMORY_ARRAY_START_ADDRESS_DATA
*) (DataHeader
+ 1);
768 ConvertMemorySizeToString (
769 (UINT32
)(RShiftU64((MemoryArray
->MemoryArrayEndAddress
- MemoryArray
->MemoryArrayStartAddress
+ 1), 20)),
772 TokenToUpdate
= STRING_TOKEN (STR_FRONT_PAGE_MEMORY_SIZE
);
773 HiiSetString (gFrontPagePrivate
.HiiHandle
, TokenToUpdate
, NewString
, NULL
);
774 FreePool (NewString
);
778 } while (!EFI_ERROR (Status
) && (MonotonicCount
!= 0) && !(Find
[0] && Find
[1] && Find
[2] && Find
[3] && Find
[4]));
784 Function waits for a given event to fire, or for an optional timeout to expire.
786 @param Event The event to wait for
787 @param Timeout An optional timeout value in 100 ns units.
789 @retval EFI_SUCCESS Event fired before Timeout expired.
790 @retval EFI_TIME_OUT Timout expired before Event fired..
796 IN UINT64 Timeout OPTIONAL
801 EFI_EVENT TimerEvent
;
802 EFI_EVENT WaitList
[2];
806 // Create a timer event
808 Status
= gBS
->CreateEvent (EVT_TIMER
, 0, NULL
, NULL
, &TimerEvent
);
809 if (!EFI_ERROR (Status
)) {
811 // Set the timer event
820 // Wait for the original event or the timer
823 WaitList
[1] = TimerEvent
;
824 Status
= gBS
->WaitForEvent (2, WaitList
, &Index
);
825 gBS
->CloseEvent (TimerEvent
);
828 // If the timer expired, change the return to timed out
830 if (!EFI_ERROR (Status
) && Index
== 1) {
831 Status
= EFI_TIMEOUT
;
836 // No timeout... just wait on the event
838 Status
= gBS
->WaitForEvent (1, &Event
, &Index
);
839 ASSERT (!EFI_ERROR (Status
));
847 Function show progress bar to wait for user input.
850 @param TimeoutDefault The fault time out value before the system continue to boot.
852 @retval EFI_SUCCESS User pressed some key except "Enter"
853 @retval EFI_TIME_OUT Timout expired or user press "Enter"
858 IN UINT16 TimeoutDefault
863 EFI_GRAPHICS_OUTPUT_BLT_PIXEL Foreground
;
864 EFI_GRAPHICS_OUTPUT_BLT_PIXEL Background
;
865 EFI_GRAPHICS_OUTPUT_BLT_PIXEL Color
;
867 UINT16 TimeoutRemain
;
869 if (TimeoutDefault
== 0) {
873 DEBUG ((EFI_D_INFO
, "\n\nStart showing progress bar... Press any key to stop it! ...Zzz....\n"));
875 SetMem (&Foreground
, sizeof (EFI_GRAPHICS_OUTPUT_BLT_PIXEL
), 0xff);
876 SetMem (&Background
, sizeof (EFI_GRAPHICS_OUTPUT_BLT_PIXEL
), 0x0);
877 SetMem (&Color
, sizeof (EFI_GRAPHICS_OUTPUT_BLT_PIXEL
), 0xff);
880 // Clear the progress status bar first
882 TmpStr
= GetStringById (STRING_TOKEN (STR_START_BOOT_OPTION
));
883 if (TmpStr
!= NULL
) {
884 PlatformBdsShowProgress (Foreground
, Background
, TmpStr
, Color
, 0, 0);
887 TimeoutRemain
= TimeoutDefault
;
888 while (TimeoutRemain
!= 0) {
889 DEBUG ((EFI_D_INFO
, "Showing progress bar...Remaining %d second!\n", TimeoutRemain
));
891 Status
= WaitForSingleEvent (gST
->ConIn
->WaitForKey
, ONE_SECOND
);
892 if (Status
!= EFI_TIMEOUT
) {
900 if (TmpStr
!= NULL
) {
901 PlatformBdsShowProgress (
906 ((TimeoutDefault
- TimeoutRemain
) * 100 / TimeoutDefault
),
911 gBS
->FreePool (TmpStr
);
916 if (TimeoutRemain
== 0) {
921 // User pressed some key
923 Status
= gST
->ConIn
->ReadKeyStroke (gST
->ConIn
, &Key
);
924 if (EFI_ERROR (Status
)) {
928 if (Key
.UnicodeChar
== CHAR_CARRIAGE_RETURN
) {
930 // User pressed enter, equivalent to select "continue"
939 This function is the main entry of the platform setup entry.
940 The function will present the main menu of the system setup,
941 this is the platform reference part and can be customize.
944 @param TimeoutDefault The fault time out value before the system
946 @param ConnectAllHappened The indicater to check if the connect all have
951 PlatformBdsEnterFrontPage (
952 IN UINT16 TimeoutDefault
,
953 IN BOOLEAN ConnectAllHappened
958 PERF_START (0, "BdsTimeOut", "BDS", 0);
960 // Indicate if we need connect all in the platform setup
962 if (ConnectAllHappened
) {
963 gConnectAllHappened
= TRUE
;
966 if (TimeoutDefault
!= 0xffff) {
967 Status
= ShowProgress (TimeoutDefault
);
970 // Ensure screen is clear when switch Console from Graphics mode to Text mode
972 gST
->ConOut
->EnableCursor (gST
->ConOut
, TRUE
);
973 gST
->ConOut
->ClearScreen (gST
->ConOut
);
975 if (EFI_ERROR (Status
)) {
977 // Timeout or user press enter to continue
985 InitializeFrontPage (FALSE
);
988 // Update Front Page strings
990 UpdateFrontPageStrings ();
993 Status
= CallFrontPage ();
996 // If gCallbackKey is greater than 1 and less or equal to 5,
997 // it will lauch configuration utilities.
1000 // 4 = device manager
1001 // 5 = boot maintainenance manager
1003 if (gCallbackKey
!= 0) {
1004 REPORT_STATUS_CODE (
1006 (EFI_SOFTWARE_DXE_BS_DRIVER
| EFI_SW_PC_USER_SETUP
)
1010 // Based on the key that was set, we can determine what to do
1012 switch (gCallbackKey
) {
1014 // The first 4 entries in the Front Page are to be GUARANTEED to remain constant so IHV's can
1015 // describe to their customers in documentation how to find their setup information (namely
1016 // under the device manager and specific buckets)
1018 // These entries consist of the Continue, Select language, Boot Manager, and Device Manager
1020 case FRONT_PAGE_KEY_CONTINUE
:
1022 // User hit continue
1026 case FRONT_PAGE_KEY_LANGUAGE
:
1028 // User made a language setting change - display front page again
1032 case FRONT_PAGE_KEY_BOOT_MANAGER
:
1034 // User chose to run the Boot Manager
1039 case FRONT_PAGE_KEY_DEVICE_MANAGER
:
1041 // Display the Device Manager
1044 CallDeviceManager();
1045 } while (gCallbackKey
== FRONT_PAGE_KEY_DEVICE_MANAGER
);
1048 case FRONT_PAGE_KEY_BOOT_MAINTAIN
:
1050 // Display the Boot Maintenance Manager
1052 BdsStartBootMaint ();
1056 } while ((Status
== EFI_SUCCESS
) && (gCallbackKey
!= FRONT_PAGE_KEY_CONTINUE
));
1059 //Will leave browser, check any reset required change is applied? if yes, reset system
1061 SetupResetReminder ();
1065 // Automatically load current entry
1066 // Note: The following lines of code only execute when Auto boot
1069 PERF_END (0, "BdsTimeOut", "BDS", 0);