2 FrontPage routines to handle the callbacks and browser calls
4 Copyright (c) 2004 - 2011, Intel Corporation. All rights reserved.<BR>
5 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"
20 BOOLEAN gConnectAllHappened
= FALSE
;
23 EFI_FORM_BROWSER2_PROTOCOL
*gFormBrowser2
;
25 FRONT_PAGE_CALLBACK_DATA gFrontPagePrivate
= {
26 FRONT_PAGE_CALLBACK_DATA_SIGNATURE
,
37 HII_VENDOR_DEVICE_PATH mFrontPageHiiVendorDevicePath
= {
43 (UINT8
) (sizeof (VENDOR_DEVICE_PATH
)),
44 (UINT8
) ((sizeof (VENDOR_DEVICE_PATH
)) >> 8)
47 FRONT_PAGE_FORMSET_GUID
51 END_ENTIRE_DEVICE_PATH_SUBTYPE
,
53 (UINT8
) (END_DEVICE_PATH_LENGTH
),
54 (UINT8
) ((END_DEVICE_PATH_LENGTH
) >> 8)
60 This function allows a caller to extract the current configuration for one
61 or more named elements from the target driver.
64 @param This Points to the EFI_HII_CONFIG_ACCESS_PROTOCOL.
65 @param Request A null-terminated Unicode string in <ConfigRequest> format.
66 @param Progress On return, points to a character in the Request string.
67 Points to the string's null terminator if request was successful.
68 Points to the most recent '&' before the first failing name/value
69 pair (or the beginning of the string if the failure is in the
70 first name/value pair) if the request was not successful.
71 @param Results A null-terminated Unicode string in <ConfigAltResp> format which
72 has all values filled in for the names in the Request string.
73 String to be allocated by the called function.
75 @retval EFI_SUCCESS The Results is filled with the requested values.
76 @retval EFI_OUT_OF_RESOURCES Not enough memory to store the results.
77 @retval EFI_INVALID_PARAMETER Request is illegal syntax, or unknown name.
78 @retval EFI_NOT_FOUND Routing data doesn't match any storage in this driver.
84 IN CONST EFI_HII_CONFIG_ACCESS_PROTOCOL
*This
,
85 IN CONST EFI_STRING Request
,
86 OUT EFI_STRING
*Progress
,
87 OUT EFI_STRING
*Results
90 if (Progress
== NULL
|| Results
== NULL
) {
91 return EFI_INVALID_PARAMETER
;
98 This function processes the results of changes in configuration.
101 @param This Points to the EFI_HII_CONFIG_ACCESS_PROTOCOL.
102 @param Configuration A null-terminated Unicode string in <ConfigResp> format.
103 @param Progress A pointer to a string filled in with the offset of the most
104 recent '&' before the first failing name/value pair (or the
105 beginning of the string if the failure is in the first
106 name/value pair) or the terminating NULL if all was successful.
108 @retval EFI_SUCCESS The Results is processed successfully.
109 @retval EFI_INVALID_PARAMETER Configuration is NULL.
110 @retval EFI_NOT_FOUND Routing data doesn't match any storage in this driver.
116 IN CONST EFI_HII_CONFIG_ACCESS_PROTOCOL
*This
,
117 IN CONST EFI_STRING Configuration
,
118 OUT EFI_STRING
*Progress
121 if (Configuration
== NULL
|| Progress
== NULL
) {
122 return EFI_INVALID_PARAMETER
;
125 *Progress
= Configuration
;
126 if (!HiiIsConfigHdrMatch (Configuration
, &gBootMaintFormSetGuid
, mBootMaintStorageName
)
127 && !HiiIsConfigHdrMatch (Configuration
, &gFileExploreFormSetGuid
, mFileExplorerStorageName
)) {
128 return EFI_NOT_FOUND
;
131 *Progress
= Configuration
+ StrLen (Configuration
);
136 This function processes the results of changes in configuration.
139 @param This Points to the EFI_HII_CONFIG_ACCESS_PROTOCOL.
140 @param Action Specifies the type of action taken by the browser.
141 @param QuestionId A unique value which is sent to the original exporting driver
142 so that it can identify the type of data to expect.
143 @param Type The type of value for the question.
144 @param Value A pointer to the data being sent to the original exporting driver.
145 @param ActionRequest On return, points to the action requested by the callback function.
147 @retval EFI_SUCCESS The callback successfully handled the action.
148 @retval EFI_OUT_OF_RESOURCES Not enough storage is available to hold the variable and its data.
149 @retval EFI_DEVICE_ERROR The variable could not be saved.
150 @retval EFI_UNSUPPORTED The specified Action is not supported by the callback.
156 IN CONST EFI_HII_CONFIG_ACCESS_PROTOCOL
*This
,
157 IN EFI_BROWSER_ACTION Action
,
158 IN EFI_QUESTION_ID QuestionId
,
160 IN EFI_IFR_TYPE_VALUE
*Value
,
161 OUT EFI_BROWSER_ACTION_REQUEST
*ActionRequest
164 CHAR8
*LanguageString
;
169 CHAR8
*PlatformSupportedLanguages
;
172 if (Action
== EFI_BROWSER_ACTION_CHANGING
) {
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 // All other action return unsupported.
283 return EFI_UNSUPPORTED
;
287 Initialize HII information for the FrontPage
290 @param InitializeHiiData TRUE if HII elements need to be initialized.
292 @retval EFI_SUCCESS The operation is successful.
293 @retval EFI_DEVICE_ERROR If the dynamic opcode creation failed.
297 InitializeFrontPage (
298 IN BOOLEAN InitializeHiiData
302 CHAR8
*LanguageString
;
308 CHAR16
*StringBuffer
;
309 EFI_HII_HANDLE HiiHandle
;
310 VOID
*OptionsOpCodeHandle
;
311 VOID
*StartOpCodeHandle
;
312 VOID
*EndOpCodeHandle
;
313 EFI_IFR_GUID_LABEL
*StartLabel
;
314 EFI_IFR_GUID_LABEL
*EndLabel
;
317 if (InitializeHiiData
) {
319 // Initialize the Device Manager
321 InitializeDeviceManager ();
324 // Initialize the Device Manager
326 InitializeBootManager ();
331 // Locate Hii relative protocols
333 Status
= gBS
->LocateProtocol (&gEfiFormBrowser2ProtocolGuid
, NULL
, (VOID
**) &gFormBrowser2
);
334 if (EFI_ERROR (Status
)) {
339 // Install Device Path Protocol and Config Access protocol to driver handle
341 Status
= gBS
->InstallMultipleProtocolInterfaces (
342 &gFrontPagePrivate
.DriverHandle
,
343 &gEfiDevicePathProtocolGuid
,
344 &mFrontPageHiiVendorDevicePath
,
345 &gEfiHiiConfigAccessProtocolGuid
,
346 &gFrontPagePrivate
.ConfigAccess
,
349 ASSERT_EFI_ERROR (Status
);
352 // Publish our HII data
354 gFrontPagePrivate
.HiiHandle
= HiiAddPackages (
355 &gFrontPageFormSetGuid
,
356 gFrontPagePrivate
.DriverHandle
,
361 if (gFrontPagePrivate
.HiiHandle
== NULL
) {
362 return EFI_OUT_OF_RESOURCES
;
368 // Init OpCode Handle and Allocate space for creation of UpdateData Buffer
370 StartOpCodeHandle
= HiiAllocateOpCodeHandle ();
371 ASSERT (StartOpCodeHandle
!= NULL
);
373 EndOpCodeHandle
= HiiAllocateOpCodeHandle ();
374 ASSERT (EndOpCodeHandle
!= NULL
);
376 OptionsOpCodeHandle
= HiiAllocateOpCodeHandle ();
377 ASSERT (OptionsOpCodeHandle
!= NULL
);
379 // Create Hii Extend Label OpCode as the start opcode
381 StartLabel
= (EFI_IFR_GUID_LABEL
*) HiiCreateGuidOpCode (StartOpCodeHandle
, &gEfiIfrTianoGuid
, NULL
, sizeof (EFI_IFR_GUID_LABEL
));
382 StartLabel
->ExtendOpCode
= EFI_IFR_EXTEND_OP_LABEL
;
383 StartLabel
->Number
= LABEL_SELECT_LANGUAGE
;
386 // Create Hii Extend Label OpCode as the end opcode
388 EndLabel
= (EFI_IFR_GUID_LABEL
*) HiiCreateGuidOpCode (EndOpCodeHandle
, &gEfiIfrTianoGuid
, NULL
, sizeof (EFI_IFR_GUID_LABEL
));
389 EndLabel
->ExtendOpCode
= EFI_IFR_EXTEND_OP_LABEL
;
390 EndLabel
->Number
= LABEL_END
;
393 // Collect the languages from what our current Language support is based on our VFR
395 HiiHandle
= gFrontPagePrivate
.HiiHandle
;
396 LanguageString
= HiiGetSupportedLanguages (HiiHandle
);
397 ASSERT (LanguageString
!= NULL
);
399 // Allocate working buffer for RFC 4646 language in supported LanguageString.
401 Lang
= AllocatePool (AsciiStrSize (LanguageString
));
402 ASSERT (Lang
!= NULL
);
404 CurrentLang
= GetEfiGlobalVariable (L
"PlatformLang");
406 // Select the best language in LanguageString as the default one.
408 BestLanguage
= GetBestLanguage (
411 (CurrentLang
!= NULL
) ? CurrentLang
: "",
412 (CHAR8
*) PcdGetPtr (PcdUefiVariableDefaultPlatformLang
),
417 // BestLanguage must be selected as it is the first language in LanguageString by default
419 ASSERT (BestLanguage
!= NULL
);
422 LangCode
= LanguageString
;
425 if (gFrontPagePrivate
.LanguageToken
== NULL
) {
426 while (*LangCode
!= 0) {
427 GetNextLanguage (&LangCode
, Lang
);
430 gFrontPagePrivate
.LanguageToken
= AllocatePool (OptionCount
* sizeof (EFI_STRING_ID
));
431 ASSERT (gFrontPagePrivate
.LanguageToken
!= NULL
);
436 LangCode
= LanguageString
;
437 while (*LangCode
!= 0) {
438 GetNextLanguage (&LangCode
, Lang
);
441 StringBuffer
= HiiGetString (HiiHandle
, PRINTABLE_LANGUAGE_NAME_STRING_ID
, Lang
);
442 ASSERT (StringBuffer
!= NULL
);
445 // Save the string Id for each language
447 gFrontPagePrivate
.LanguageToken
[OptionCount
] = HiiSetString (HiiHandle
, 0, StringBuffer
, NULL
);
448 FreePool (StringBuffer
);
451 if (AsciiStrCmp (Lang
, BestLanguage
) == 0) {
452 HiiCreateOneOfOptionOpCode (
454 gFrontPagePrivate
.LanguageToken
[OptionCount
],
455 EFI_IFR_OPTION_DEFAULT
,
456 EFI_IFR_NUMERIC_SIZE_1
,
460 HiiCreateOneOfOptionOpCode (
462 gFrontPagePrivate
.LanguageToken
[OptionCount
],
464 EFI_IFR_NUMERIC_SIZE_1
,
472 if (CurrentLang
!= NULL
) {
473 FreePool (CurrentLang
);
475 FreePool (BestLanguage
);
477 FreePool (LanguageString
);
479 HiiCreateOneOfOpCode (
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
,
492 Status
= HiiUpdateForm (
494 &gFrontPageFormSetGuid
,
496 StartOpCodeHandle
, // LABEL_SELECT_LANGUAGE
497 EndOpCodeHandle
// LABEL_END
500 HiiFreeOpCodeHandle (StartOpCodeHandle
);
501 HiiFreeOpCodeHandle (EndOpCodeHandle
);
502 HiiFreeOpCodeHandle (OptionsOpCodeHandle
);
507 Call the browser and display the front page
509 @return Status code that will be returned by
510 EFI_FORM_BROWSER2_PROTOCOL.SendForm ().
519 EFI_BROWSER_ACTION_REQUEST ActionRequest
;
522 // Begin waiting for USER INPUT
526 (EFI_SOFTWARE_DXE_BS_DRIVER
| EFI_SW_PC_INPUT_WAIT
)
529 ActionRequest
= EFI_BROWSER_ACTION_REQUEST_NONE
;
530 Status
= gFormBrowser2
->SendForm (
532 &gFrontPagePrivate
.HiiHandle
,
534 &gFrontPageFormSetGuid
,
540 // Check whether user change any option setting which needs a reset to be effective
542 if (ActionRequest
== EFI_BROWSER_ACTION_REQUEST_RESET
) {
543 EnableResetRequired ();
550 Acquire the string associated with the ProducerGuid and return it.
553 @param ProducerGuid The Guid to search the HII database for
554 @param Token The token value of the string to extract
555 @param String The string that is extracted
557 @retval EFI_SUCCESS The function returns EFI_SUCCESS always.
562 IN EFI_GUID
*ProducerGuid
,
563 IN EFI_STRING_ID Token
,
567 EFI_STRING TmpString
;
569 TmpString
= HiiGetPackageString (ProducerGuid
, Token
, NULL
);
570 if (TmpString
== NULL
) {
571 *String
= GetStringById (STRING_TOKEN (STR_MISSING_STRING
));
580 Convert Processor Frequency Data to a string.
582 @param ProcessorFrequency The frequency data to process
583 @param Base10Exponent The exponent based on 10
584 @param String The string that is created
588 ConvertProcessorToString (
589 IN UINT16 ProcessorFrequency
,
590 IN UINT16 Base10Exponent
,
594 CHAR16
*StringBuffer
;
598 if (Base10Exponent
>= 6) {
599 FreqMhz
= ProcessorFrequency
;
600 for (Index
= 0; Index
< (UINTN
) (Base10Exponent
- 6); Index
++) {
607 StringBuffer
= AllocateZeroPool (0x20);
608 ASSERT (StringBuffer
!= NULL
);
609 Index
= UnicodeValueToString (StringBuffer
, LEFT_JUSTIFY
, FreqMhz
/ 1000, 3);
610 StrCat (StringBuffer
, L
".");
611 UnicodeValueToString (StringBuffer
+ Index
+ 1, PREFIX_ZERO
, (FreqMhz
% 1000) / 10, 2);
612 StrCat (StringBuffer
, L
" GHz");
613 *String
= (CHAR16
*) StringBuffer
;
619 Convert Memory Size to a string.
621 @param MemorySize The size of the memory to process
622 @param String The string that is created
626 ConvertMemorySizeToString (
627 IN UINT32 MemorySize
,
631 CHAR16
*StringBuffer
;
633 StringBuffer
= AllocateZeroPool (0x20);
634 ASSERT (StringBuffer
!= NULL
);
635 UnicodeValueToString (StringBuffer
, LEFT_JUSTIFY
, MemorySize
, 6);
636 StrCat (StringBuffer
, L
" MB RAM");
638 *String
= (CHAR16
*) StringBuffer
;
645 Acquire the string associated with the Index from smbios structure and return it.
646 The caller is responsible for free the string buffer.
648 @param OptionalStrStart The start position to search the string
649 @param Index The index of the string to extract
650 @param String The string that is extracted
652 @retval EFI_SUCCESS The function returns EFI_SUCCESS always.
656 GetOptionalStringByIndex (
657 IN CHAR8
*OptionalStrStart
,
665 *String
= AllocateZeroPool (sizeof (CHAR16
));
672 OptionalStrStart
+= StrSize
;
673 StrSize
= AsciiStrSize (OptionalStrStart
);
674 } while (OptionalStrStart
[StrSize
] != 0 && Index
!= 0);
676 if ((Index
!= 0) || (StrSize
== 1)) {
678 // Meet the end of strings set but Index is non-zero, or
679 // Find an empty string
681 *String
= GetStringById (STRING_TOKEN (STR_MISSING_STRING
));
683 *String
= AllocatePool (StrSize
* sizeof (CHAR16
));
684 AsciiStrToUnicodeStr (OptionalStrStart
, *String
);
692 Update the banner information for the Front Page based on DataHub information.
696 UpdateFrontPageStrings (
704 EFI_STRING_ID TokenToUpdate
;
705 EFI_SMBIOS_HANDLE SmbiosHandle
;
706 EFI_SMBIOS_PROTOCOL
*Smbios
;
707 SMBIOS_TABLE_TYPE0
*Type0Record
;
708 SMBIOS_TABLE_TYPE1
*Type1Record
;
709 SMBIOS_TABLE_TYPE4
*Type4Record
;
710 SMBIOS_TABLE_TYPE19
*Type19Record
;
711 EFI_SMBIOS_TABLE_HEADER
*Record
;
713 ZeroMem (Find
, sizeof (Find
));
716 // Update Front Page strings
718 Status
= gBS
->LocateProtocol (
719 &gEfiSmbiosProtocolGuid
,
723 ASSERT_EFI_ERROR (Status
);
727 Status
= Smbios
->GetNext (Smbios
, &SmbiosHandle
, NULL
, &Record
, NULL
);
728 if (EFI_ERROR(Status
)) {
732 if (Record
->Type
== EFI_SMBIOS_TYPE_BIOS_INFORMATION
) {
733 Type0Record
= (SMBIOS_TABLE_TYPE0
*) Record
;
734 StrIndex
= Type0Record
->BiosVersion
;
735 GetOptionalStringByIndex ((CHAR8
*)((UINT8
*)Type0Record
+ Type0Record
->Hdr
.Length
), StrIndex
, &NewString
);
736 TokenToUpdate
= STRING_TOKEN (STR_FRONT_PAGE_BIOS_VERSION
);
737 HiiSetString (gFrontPagePrivate
.HiiHandle
, TokenToUpdate
, NewString
, NULL
);
738 FreePool (NewString
);
742 if (Record
->Type
== EFI_SMBIOS_TYPE_SYSTEM_INFORMATION
) {
743 Type1Record
= (SMBIOS_TABLE_TYPE1
*) Record
;
744 StrIndex
= Type1Record
->ProductName
;
745 GetOptionalStringByIndex ((CHAR8
*)((UINT8
*)Type1Record
+ Type1Record
->Hdr
.Length
), StrIndex
, &NewString
);
746 TokenToUpdate
= STRING_TOKEN (STR_FRONT_PAGE_COMPUTER_MODEL
);
747 HiiSetString (gFrontPagePrivate
.HiiHandle
, TokenToUpdate
, NewString
, NULL
);
748 FreePool (NewString
);
752 if (Record
->Type
== EFI_SMBIOS_TYPE_PROCESSOR_INFORMATION
) {
753 Type4Record
= (SMBIOS_TABLE_TYPE4
*) Record
;
754 StrIndex
= Type4Record
->ProcessorVersion
;
755 GetOptionalStringByIndex ((CHAR8
*)((UINT8
*)Type4Record
+ Type4Record
->Hdr
.Length
), StrIndex
, &NewString
);
756 TokenToUpdate
= STRING_TOKEN (STR_FRONT_PAGE_CPU_MODEL
);
757 HiiSetString (gFrontPagePrivate
.HiiHandle
, TokenToUpdate
, NewString
, NULL
);
758 FreePool (NewString
);
762 if (Record
->Type
== EFI_SMBIOS_TYPE_PROCESSOR_INFORMATION
) {
763 Type4Record
= (SMBIOS_TABLE_TYPE4
*) Record
;
764 ConvertProcessorToString(Type4Record
->CurrentSpeed
, 6, &NewString
);
765 TokenToUpdate
= STRING_TOKEN (STR_FRONT_PAGE_CPU_SPEED
);
766 HiiSetString (gFrontPagePrivate
.HiiHandle
, TokenToUpdate
, NewString
, NULL
);
767 FreePool (NewString
);
771 if ( Record
->Type
== EFI_SMBIOS_TYPE_MEMORY_ARRAY_MAPPED_ADDRESS
) {
772 Type19Record
= (SMBIOS_TABLE_TYPE19
*) Record
;
773 ConvertMemorySizeToString (
774 (UINT32
)(RShiftU64((Type19Record
->EndingAddress
- Type19Record
->StartingAddress
+ 1), 10)),
777 TokenToUpdate
= STRING_TOKEN (STR_FRONT_PAGE_MEMORY_SIZE
);
778 HiiSetString (gFrontPagePrivate
.HiiHandle
, TokenToUpdate
, NewString
, NULL
);
779 FreePool (NewString
);
782 } while ( !(Find
[0] && Find
[1] && Find
[2] && Find
[3] && Find
[4]));
788 Function waits for a given event to fire, or for an optional timeout to expire.
790 @param Event The event to wait for
791 @param Timeout An optional timeout value in 100 ns units.
793 @retval EFI_SUCCESS Event fired before Timeout expired.
794 @retval EFI_TIME_OUT Timout expired before Event fired..
800 IN UINT64 Timeout OPTIONAL
805 EFI_EVENT TimerEvent
;
806 EFI_EVENT WaitList
[2];
810 // Create a timer event
812 Status
= gBS
->CreateEvent (EVT_TIMER
, 0, NULL
, NULL
, &TimerEvent
);
813 if (!EFI_ERROR (Status
)) {
815 // Set the timer event
824 // Wait for the original event or the timer
827 WaitList
[1] = TimerEvent
;
828 Status
= gBS
->WaitForEvent (2, WaitList
, &Index
);
829 gBS
->CloseEvent (TimerEvent
);
832 // If the timer expired, change the return to timed out
834 if (!EFI_ERROR (Status
) && Index
== 1) {
835 Status
= EFI_TIMEOUT
;
840 // No timeout... just wait on the event
842 Status
= gBS
->WaitForEvent (1, &Event
, &Index
);
843 ASSERT (!EFI_ERROR (Status
));
851 Function show progress bar to wait for user input.
854 @param TimeoutDefault The fault time out value before the system continue to boot.
856 @retval EFI_SUCCESS User pressed some key except "Enter"
857 @retval EFI_TIME_OUT Timeout expired or user press "Enter"
862 IN UINT16 TimeoutDefault
866 UINT16 TimeoutRemain
;
869 EFI_GRAPHICS_OUTPUT_BLT_PIXEL Foreground
;
870 EFI_GRAPHICS_OUTPUT_BLT_PIXEL Background
;
871 EFI_GRAPHICS_OUTPUT_BLT_PIXEL Color
;
873 if (TimeoutDefault
== 0) {
877 DEBUG ((EFI_D_INFO
, "\n\nStart showing progress bar... Press any key to stop it! ...Zzz....\n"));
879 SetMem (&Foreground
, sizeof (EFI_GRAPHICS_OUTPUT_BLT_PIXEL
), 0xff);
880 SetMem (&Background
, sizeof (EFI_GRAPHICS_OUTPUT_BLT_PIXEL
), 0x0);
881 SetMem (&Color
, sizeof (EFI_GRAPHICS_OUTPUT_BLT_PIXEL
), 0xff);
884 // Clear the progress status bar first
886 TmpStr
= GetStringById (STRING_TOKEN (STR_START_BOOT_OPTION
));
887 if (TmpStr
!= NULL
) {
888 PlatformBdsShowProgress (Foreground
, Background
, TmpStr
, Color
, 0, 0);
891 TimeoutRemain
= TimeoutDefault
;
892 while (TimeoutRemain
!= 0) {
893 DEBUG ((EFI_D_INFO
, "Showing progress bar...Remaining %d second!\n", TimeoutRemain
));
895 Status
= WaitForSingleEvent (gST
->ConIn
->WaitForKey
, ONE_SECOND
);
896 if (Status
!= EFI_TIMEOUT
) {
904 if (TmpStr
!= NULL
) {
905 PlatformBdsShowProgress (
910 ((TimeoutDefault
- TimeoutRemain
) * 100 / TimeoutDefault
),
915 gBS
->FreePool (TmpStr
);
920 if (TimeoutRemain
== 0) {
925 // User pressed some key
927 Status
= gST
->ConIn
->ReadKeyStroke (gST
->ConIn
, &Key
);
928 if (EFI_ERROR (Status
)) {
932 if (Key
.UnicodeChar
== CHAR_CARRIAGE_RETURN
) {
934 // User pressed enter, equivalent to select "continue"
943 This function is the main entry of the platform setup entry.
944 The function will present the main menu of the system setup,
945 this is the platform reference part and can be customize.
948 @param TimeoutDefault The fault time out value before the system
950 @param ConnectAllHappened The indicater to check if the connect all have
955 PlatformBdsEnterFrontPage (
956 IN UINT16 TimeoutDefault
,
957 IN BOOLEAN ConnectAllHappened
962 PERF_START (NULL
, "BdsTimeOut", "BDS", 0);
964 // Indicate if we need connect all in the platform setup
966 if (ConnectAllHappened
) {
967 gConnectAllHappened
= TRUE
;
971 if (TimeoutDefault
!= 0xffff) {
972 Status
= ShowProgress (TimeoutDefault
);
976 // Ensure screen is clear when switch Console from Graphics mode to Text mode
978 gST
->ConOut
->EnableCursor (gST
->ConOut
, TRUE
);
979 gST
->ConOut
->ClearScreen (gST
->ConOut
);
981 if (EFI_ERROR (Status
)) {
983 // Timeout or user press enter to continue
991 InitializeFrontPage (FALSE
);
994 // Update Front Page strings
996 UpdateFrontPageStrings ();
999 Status
= CallFrontPage ();
1002 // If gCallbackKey is greater than 1 and less or equal to 5,
1003 // it will launch configuration utilities.
1006 // 4 = device manager
1007 // 5 = boot maintenance manager
1009 if (gCallbackKey
!= 0) {
1010 REPORT_STATUS_CODE (
1012 (EFI_SOFTWARE_DXE_BS_DRIVER
| EFI_SW_PC_USER_SETUP
)
1016 // Based on the key that was set, we can determine what to do
1018 switch (gCallbackKey
) {
1020 // The first 4 entries in the Front Page are to be GUARANTEED to remain constant so IHV's can
1021 // describe to their customers in documentation how to find their setup information (namely
1022 // under the device manager and specific buckets)
1024 // These entries consist of the Continue, Select language, Boot Manager, and Device Manager
1026 case FRONT_PAGE_KEY_CONTINUE
:
1028 // User hit continue
1032 case FRONT_PAGE_KEY_LANGUAGE
:
1034 // User made a language setting change - display front page again
1038 case FRONT_PAGE_KEY_BOOT_MANAGER
:
1040 // User chose to run the Boot Manager
1045 case FRONT_PAGE_KEY_DEVICE_MANAGER
:
1047 // Display the Device Manager
1050 CallDeviceManager ();
1051 } while (gCallbackKey
== FRONT_PAGE_KEY_DEVICE_MANAGER
);
1054 case FRONT_PAGE_KEY_BOOT_MAINTAIN
:
1056 // Display the Boot Maintenance Manager
1058 BdsStartBootMaint ();
1062 } while ((Status
== EFI_SUCCESS
) && (gCallbackKey
!= FRONT_PAGE_KEY_CONTINUE
));
1065 //Will leave browser, check any reset required change is applied? if yes, reset system
1067 SetupResetReminder ();
1071 // Automatically load current entry
1072 // Note: The following lines of code only execute when Auto boot
1075 PERF_END (NULL
, "BdsTimeOut", "BDS", 0);