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 EFI_GUID mFrontPageGuid
= FRONT_PAGE_FORMSET_GUID
;
22 BOOLEAN gConnectAllHappened
= FALSE
;
25 EFI_FORM_BROWSER2_PROTOCOL
*gFormBrowser2
;
27 FRONT_PAGE_CALLBACK_DATA gFrontPagePrivate
= {
28 FRONT_PAGE_CALLBACK_DATA_SIGNATURE
,
39 HII_VENDOR_DEVICE_PATH mFrontPageHiiVendorDevicePath
= {
45 (UINT8
) (sizeof (VENDOR_DEVICE_PATH
)),
46 (UINT8
) ((sizeof (VENDOR_DEVICE_PATH
)) >> 8)
50 // {8E6D99EE-7531-48f8-8745-7F6144468FF2}
52 { 0x8e6d99ee, 0x7531, 0x48f8, { 0x87, 0x45, 0x7f, 0x61, 0x44, 0x46, 0x8f, 0xf2 } }
56 END_ENTIRE_DEVICE_PATH_SUBTYPE
,
58 (UINT8
) (END_DEVICE_PATH_LENGTH
),
59 (UINT8
) ((END_DEVICE_PATH_LENGTH
) >> 8)
65 This function allows a caller to extract the current configuration for one
66 or more named elements from the target driver.
69 @param This Points to the EFI_HII_CONFIG_ACCESS_PROTOCOL.
70 @param Request A null-terminated Unicode string in <ConfigRequest> format.
71 @param Progress On return, points to a character in the Request string.
72 Points to the string's null terminator if request was successful.
73 Points to the most recent '&' before the first failing name/value
74 pair (or the beginning of the string if the failure is in the
75 first name/value pair) if the request was not successful.
76 @param Results A null-terminated Unicode string in <ConfigAltResp> format which
77 has all values filled in for the names in the Request string.
78 String to be allocated by the called function.
80 @retval EFI_SUCCESS The Results is filled with the requested values.
81 @retval EFI_OUT_OF_RESOURCES Not enough memory to store the results.
82 @retval EFI_INVALID_PARAMETER Request is illegal syntax, or unknown name.
83 @retval EFI_NOT_FOUND Routing data doesn't match any storage in this driver.
89 IN CONST EFI_HII_CONFIG_ACCESS_PROTOCOL
*This
,
90 IN CONST EFI_STRING Request
,
91 OUT EFI_STRING
*Progress
,
92 OUT EFI_STRING
*Results
95 if (Progress
== NULL
|| Results
== NULL
) {
96 return EFI_INVALID_PARAMETER
;
103 This function processes the results of changes in configuration.
106 @param This Points to the EFI_HII_CONFIG_ACCESS_PROTOCOL.
107 @param Configuration A null-terminated Unicode string in <ConfigResp> format.
108 @param Progress A pointer to a string filled in with the offset of the most
109 recent '&' before the first failing name/value pair (or the
110 beginning of the string if the failure is in the first
111 name/value pair) or the terminating NULL if all was successful.
113 @retval EFI_SUCCESS The Results is processed successfully.
114 @retval EFI_INVALID_PARAMETER Configuration is NULL.
115 @retval EFI_NOT_FOUND Routing data doesn't match any storage in this driver.
121 IN CONST EFI_HII_CONFIG_ACCESS_PROTOCOL
*This
,
122 IN CONST EFI_STRING Configuration
,
123 OUT EFI_STRING
*Progress
126 if (Configuration
== NULL
|| Progress
== NULL
) {
127 return EFI_INVALID_PARAMETER
;
130 *Progress
= Configuration
;
131 if (!HiiIsConfigHdrMatch (Configuration
, &mBootMaintGuid
, mBootMaintStorageName
)
132 && !HiiIsConfigHdrMatch (Configuration
, &mFileExplorerGuid
, mFileExplorerStorageName
)) {
133 return EFI_NOT_FOUND
;
136 *Progress
= Configuration
+ StrLen (Configuration
);
141 This function processes the results of changes in configuration.
144 @param This Points to the EFI_HII_CONFIG_ACCESS_PROTOCOL.
145 @param Action Specifies the type of action taken by the browser.
146 @param QuestionId A unique value which is sent to the original exporting driver
147 so that it can identify the type of data to expect.
148 @param Type The type of value for the question.
149 @param Value A pointer to the data being sent to the original exporting driver.
150 @param ActionRequest On return, points to the action requested by the callback function.
152 @retval EFI_SUCCESS The callback successfully handled the action.
153 @retval EFI_OUT_OF_RESOURCES Not enough storage is available to hold the variable and its data.
154 @retval EFI_DEVICE_ERROR The variable could not be saved.
155 @retval EFI_UNSUPPORTED The specified Action is not supported by the callback.
161 IN CONST EFI_HII_CONFIG_ACCESS_PROTOCOL
*This
,
162 IN EFI_BROWSER_ACTION Action
,
163 IN EFI_QUESTION_ID QuestionId
,
165 IN EFI_IFR_TYPE_VALUE
*Value
,
166 OUT EFI_BROWSER_ACTION_REQUEST
*ActionRequest
169 CHAR8
*LanguageString
;
174 CHAR8
*PlatformSupportedLanguages
;
177 if ((Action
== EFI_BROWSER_ACTION_FORM_OPEN
) || (Action
== EFI_BROWSER_ACTION_FORM_CLOSE
)) {
179 // Do nothing for UEFI OPEN/CLOSE Action
184 if ((Value
== NULL
) || (ActionRequest
== NULL
)) {
185 return EFI_INVALID_PARAMETER
;
188 gCallbackKey
= QuestionId
;
191 // The first 4 entries in the Front Page are to be GUARANTEED to remain constant so IHV's can
192 // describe to their customers in documentation how to find their setup information (namely
193 // under the device manager and specific buckets)
195 switch (QuestionId
) {
196 case FRONT_PAGE_KEY_CONTINUE
:
198 // This is the continue - clear the screen and return an error to get out of FrontPage loop
202 case FRONT_PAGE_KEY_LANGUAGE
:
204 // Collect the languages from what our current Language support is based on our VFR
206 LanguageString
= HiiGetSupportedLanguages (gFrontPagePrivate
.HiiHandle
);
207 ASSERT (LanguageString
!= NULL
);
209 // Allocate working buffer for RFC 4646 language in supported LanguageString.
211 Lang
= AllocatePool (AsciiStrSize (LanguageString
));
212 ASSERT (Lang
!= NULL
);
215 LangCode
= LanguageString
;
216 while (*LangCode
!= 0) {
217 GetNextLanguage (&LangCode
, Lang
);
219 if (Index
== Value
->u8
) {
226 PlatformSupportedLanguages
= GetEfiGlobalVariable (L
"PlatformLangCodes");
227 if (PlatformSupportedLanguages
== NULL
) {
228 PlatformSupportedLanguages
= AllocateCopyPool (
229 AsciiStrSize ((CHAR8
*) PcdGetPtr (PcdUefiVariableDefaultPlatformLangCodes
)),
230 (CHAR8
*) PcdGetPtr (PcdUefiVariableDefaultPlatformLangCodes
)
232 ASSERT (PlatformSupportedLanguages
!= NULL
);
236 // Select the best language in platform supported Language.
238 BestLanguage
= GetBestLanguage (
239 PlatformSupportedLanguages
,
244 if (BestLanguage
!= NULL
) {
245 Status
= gRT
->SetVariable (
247 &gEfiGlobalVariableGuid
,
248 EFI_VARIABLE_NON_VOLATILE
| EFI_VARIABLE_BOOTSERVICE_ACCESS
| EFI_VARIABLE_RUNTIME_ACCESS
,
249 AsciiStrSize (BestLanguage
),
252 ASSERT_EFI_ERROR(Status
);
253 FreePool (BestLanguage
);
258 FreePool (PlatformSupportedLanguages
);
260 FreePool (LanguageString
);
263 case FRONT_PAGE_KEY_BOOT_MANAGER
:
269 case FRONT_PAGE_KEY_DEVICE_MANAGER
:
275 case FRONT_PAGE_KEY_BOOT_MAINTAIN
:
277 // Boot Maintenance Manager
286 *ActionRequest
= EFI_BROWSER_ACTION_REQUEST_EXIT
;
292 Initialize HII information for the FrontPage
295 @param InitializeHiiData TRUE if HII elements need to be initialized.
297 @retval EFI_SUCCESS The operation is successful.
298 @retval EFI_DEVICE_ERROR If the dynamic opcode creation failed.
302 InitializeFrontPage (
303 IN BOOLEAN InitializeHiiData
307 CHAR8
*LanguageString
;
313 CHAR16
*StringBuffer
;
314 EFI_HII_HANDLE HiiHandle
;
315 VOID
*OptionsOpCodeHandle
;
316 VOID
*StartOpCodeHandle
;
317 VOID
*EndOpCodeHandle
;
318 EFI_IFR_GUID_LABEL
*StartLabel
;
319 EFI_IFR_GUID_LABEL
*EndLabel
;
322 if (InitializeHiiData
) {
324 // Initialize the Device Manager
326 InitializeDeviceManager ();
329 // Initialize the Device Manager
331 InitializeBootManager ();
336 // Locate Hii relative protocols
338 Status
= gBS
->LocateProtocol (&gEfiFormBrowser2ProtocolGuid
, NULL
, (VOID
**) &gFormBrowser2
);
339 if (EFI_ERROR (Status
)) {
344 // Install Device Path Protocol and Config Access protocol to driver handle
346 Status
= gBS
->InstallMultipleProtocolInterfaces (
347 &gFrontPagePrivate
.DriverHandle
,
348 &gEfiDevicePathProtocolGuid
,
349 &mFrontPageHiiVendorDevicePath
,
350 &gEfiHiiConfigAccessProtocolGuid
,
351 &gFrontPagePrivate
.ConfigAccess
,
354 ASSERT_EFI_ERROR (Status
);
357 // Publish our HII data
359 gFrontPagePrivate
.HiiHandle
= HiiAddPackages (
361 gFrontPagePrivate
.DriverHandle
,
366 if (gFrontPagePrivate
.HiiHandle
== NULL
) {
367 return EFI_OUT_OF_RESOURCES
;
373 // Init OpCode Handle and Allocate space for creation of UpdateData Buffer
375 StartOpCodeHandle
= HiiAllocateOpCodeHandle ();
376 ASSERT (StartOpCodeHandle
!= NULL
);
378 EndOpCodeHandle
= HiiAllocateOpCodeHandle ();
379 ASSERT (EndOpCodeHandle
!= NULL
);
381 OptionsOpCodeHandle
= HiiAllocateOpCodeHandle ();
382 ASSERT (OptionsOpCodeHandle
!= NULL
);
384 // Create Hii Extend Label OpCode as the start opcode
386 StartLabel
= (EFI_IFR_GUID_LABEL
*) HiiCreateGuidOpCode (StartOpCodeHandle
, &gEfiIfrTianoGuid
, NULL
, sizeof (EFI_IFR_GUID_LABEL
));
387 StartLabel
->ExtendOpCode
= EFI_IFR_EXTEND_OP_LABEL
;
388 StartLabel
->Number
= LABEL_SELECT_LANGUAGE
;
391 // Create Hii Extend Label OpCode as the end opcode
393 EndLabel
= (EFI_IFR_GUID_LABEL
*) HiiCreateGuidOpCode (EndOpCodeHandle
, &gEfiIfrTianoGuid
, NULL
, sizeof (EFI_IFR_GUID_LABEL
));
394 EndLabel
->ExtendOpCode
= EFI_IFR_EXTEND_OP_LABEL
;
395 EndLabel
->Number
= LABEL_END
;
398 // Collect the languages from what our current Language support is based on our VFR
400 HiiHandle
= gFrontPagePrivate
.HiiHandle
;
401 LanguageString
= HiiGetSupportedLanguages (HiiHandle
);
402 ASSERT (LanguageString
!= NULL
);
404 // Allocate working buffer for RFC 4646 language in supported LanguageString.
406 Lang
= AllocatePool (AsciiStrSize (LanguageString
));
407 ASSERT (Lang
!= NULL
);
409 CurrentLang
= GetEfiGlobalVariable (L
"PlatformLang");
411 // Select the best language in LanguageString as the default one.
413 BestLanguage
= GetBestLanguage (
416 (CurrentLang
!= NULL
) ? CurrentLang
: "",
417 (CHAR8
*) PcdGetPtr (PcdUefiVariableDefaultPlatformLang
),
422 // BestLanguage must be selected as it is the first language in LanguageString by default
424 ASSERT (BestLanguage
!= NULL
);
427 LangCode
= LanguageString
;
430 if (gFrontPagePrivate
.LanguageToken
== NULL
) {
431 while (*LangCode
!= 0) {
432 GetNextLanguage (&LangCode
, Lang
);
435 gFrontPagePrivate
.LanguageToken
= AllocatePool (OptionCount
* sizeof (EFI_STRING_ID
));
436 ASSERT (gFrontPagePrivate
.LanguageToken
!= NULL
);
441 LangCode
= LanguageString
;
442 while (*LangCode
!= 0) {
443 GetNextLanguage (&LangCode
, Lang
);
446 StringBuffer
= HiiGetString (HiiHandle
, PRINTABLE_LANGUAGE_NAME_STRING_ID
, Lang
);
447 ASSERT (StringBuffer
!= NULL
);
450 // Save the string Id for each language
452 gFrontPagePrivate
.LanguageToken
[OptionCount
] = HiiSetString (HiiHandle
, 0, StringBuffer
, NULL
);
453 FreePool (StringBuffer
);
456 if (AsciiStrCmp (Lang
, BestLanguage
) == 0) {
457 HiiCreateOneOfOptionOpCode (
459 gFrontPagePrivate
.LanguageToken
[OptionCount
],
460 EFI_IFR_OPTION_DEFAULT
,
461 EFI_IFR_NUMERIC_SIZE_1
,
465 HiiCreateOneOfOptionOpCode (
467 gFrontPagePrivate
.LanguageToken
[OptionCount
],
469 EFI_IFR_NUMERIC_SIZE_1
,
477 if (CurrentLang
!= NULL
) {
478 FreePool (CurrentLang
);
480 FreePool (BestLanguage
);
482 FreePool (LanguageString
);
484 HiiCreateOneOfOpCode (
486 FRONT_PAGE_KEY_LANGUAGE
,
489 STRING_TOKEN (STR_LANGUAGE_SELECT
),
490 STRING_TOKEN (STR_LANGUAGE_SELECT_HELP
),
491 EFI_IFR_FLAG_CALLBACK
,
492 EFI_IFR_NUMERIC_SIZE_1
,
497 Status
= HiiUpdateForm (
501 StartOpCodeHandle
, // LABEL_SELECT_LANGUAGE
502 EndOpCodeHandle
// LABEL_END
505 HiiFreeOpCodeHandle (StartOpCodeHandle
);
506 HiiFreeOpCodeHandle (EndOpCodeHandle
);
507 HiiFreeOpCodeHandle (OptionsOpCodeHandle
);
512 Call the browser and display the front page
514 @return Status code that will be returned by
515 EFI_FORM_BROWSER2_PROTOCOL.SendForm ().
524 EFI_BROWSER_ACTION_REQUEST ActionRequest
;
527 // Begin waiting for USER INPUT
531 (EFI_SOFTWARE_DXE_BS_DRIVER
| EFI_SW_PC_INPUT_WAIT
)
534 ActionRequest
= EFI_BROWSER_ACTION_REQUEST_NONE
;
535 Status
= gFormBrowser2
->SendForm (
537 &gFrontPagePrivate
.HiiHandle
,
545 // Check whether user change any option setting which needs a reset to be effective
547 if (ActionRequest
== EFI_BROWSER_ACTION_REQUEST_RESET
) {
548 EnableResetRequired ();
555 Acquire the string associated with the ProducerGuid and return it.
558 @param ProducerGuid The Guid to search the HII database for
559 @param Token The token value of the string to extract
560 @param String The string that is extracted
562 @retval EFI_SUCCESS The function returns EFI_SUCCESS always.
567 IN EFI_GUID
*ProducerGuid
,
568 IN EFI_STRING_ID Token
,
572 EFI_STRING TmpString
;
574 TmpString
= HiiGetPackageString (ProducerGuid
, Token
, NULL
);
575 if (TmpString
== NULL
) {
576 *String
= GetStringById (STRING_TOKEN (STR_MISSING_STRING
));
585 Convert Processor Frequency Data to a string.
587 @param ProcessorFrequency The frequency data to process
588 @param Base10Exponent The exponent based on 10
589 @param String The string that is created
593 ConvertProcessorToString (
594 IN UINT16 ProcessorFrequency
,
595 IN UINT16 Base10Exponent
,
599 CHAR16
*StringBuffer
;
603 if (Base10Exponent
>= 6) {
604 FreqMhz
= ProcessorFrequency
;
605 for (Index
= 0; Index
< (UINTN
) (Base10Exponent
- 6); Index
++) {
612 StringBuffer
= AllocateZeroPool (0x20);
613 ASSERT (StringBuffer
!= NULL
);
614 Index
= UnicodeValueToString (StringBuffer
, LEFT_JUSTIFY
, FreqMhz
/ 1000, 3);
615 StrCat (StringBuffer
, L
".");
616 UnicodeValueToString (StringBuffer
+ Index
+ 1, PREFIX_ZERO
, (FreqMhz
% 1000) / 10, 2);
617 StrCat (StringBuffer
, L
" GHz");
618 *String
= (CHAR16
*) StringBuffer
;
624 Convert Memory Size to a string.
626 @param MemorySize The size of the memory to process
627 @param String The string that is created
631 ConvertMemorySizeToString (
632 IN UINT32 MemorySize
,
636 CHAR16
*StringBuffer
;
638 StringBuffer
= AllocateZeroPool (0x20);
639 ASSERT (StringBuffer
!= NULL
);
640 UnicodeValueToString (StringBuffer
, LEFT_JUSTIFY
, MemorySize
, 6);
641 StrCat (StringBuffer
, L
" MB RAM");
643 *String
= (CHAR16
*) StringBuffer
;
650 Acquire the string associated with the Index from smbios structure and return it.
651 The caller is responsible for free the string buffer.
653 @param OptionalStrStart The start position to search the string
654 @param Index The index of the string to extract
655 @param String The string that is extracted
657 @retval EFI_SUCCESS The function returns EFI_SUCCESS always.
661 GetOptionalStringByIndex (
662 IN CHAR8
*OptionalStrStart
,
670 *String
= AllocateZeroPool (sizeof (CHAR16
));
677 OptionalStrStart
+= StrSize
;
678 StrSize
= AsciiStrSize (OptionalStrStart
);
679 } while (OptionalStrStart
[StrSize
] != 0 && Index
!= 0);
681 if ((Index
!= 0) || (StrSize
== 1)) {
683 // Meet the end of strings set but Index is non-zero, or
684 // Find an empty string
686 *String
= GetStringById (STRING_TOKEN (STR_MISSING_STRING
));
688 *String
= AllocatePool (StrSize
* sizeof (CHAR16
));
689 AsciiStrToUnicodeStr (OptionalStrStart
, *String
);
697 Update the banner information for the Front Page based on DataHub information.
701 UpdateFrontPageStrings (
709 EFI_STRING_ID TokenToUpdate
;
710 EFI_SMBIOS_HANDLE SmbiosHandle
;
711 EFI_SMBIOS_PROTOCOL
*Smbios
;
712 SMBIOS_TABLE_TYPE0
*Type0Record
;
713 SMBIOS_TABLE_TYPE1
*Type1Record
;
714 SMBIOS_TABLE_TYPE4
*Type4Record
;
715 SMBIOS_TABLE_TYPE19
*Type19Record
;
716 EFI_SMBIOS_TABLE_HEADER
*Record
;
718 ZeroMem (Find
, sizeof (Find
));
721 // Update Front Page strings
723 Status
= gBS
->LocateProtocol (
724 &gEfiSmbiosProtocolGuid
,
728 ASSERT_EFI_ERROR (Status
);
732 Status
= Smbios
->GetNext (Smbios
, &SmbiosHandle
, NULL
, &Record
, NULL
);
733 if (EFI_ERROR(Status
)) {
737 if (Record
->Type
== EFI_SMBIOS_TYPE_BIOS_INFORMATION
) {
738 Type0Record
= (SMBIOS_TABLE_TYPE0
*) Record
;
739 StrIndex
= Type0Record
->BiosVersion
;
740 GetOptionalStringByIndex ((CHAR8
*)((UINT8
*)Type0Record
+ Type0Record
->Hdr
.Length
), StrIndex
, &NewString
);
741 TokenToUpdate
= STRING_TOKEN (STR_FRONT_PAGE_BIOS_VERSION
);
742 HiiSetString (gFrontPagePrivate
.HiiHandle
, TokenToUpdate
, NewString
, NULL
);
743 FreePool (NewString
);
747 if (Record
->Type
== EFI_SMBIOS_TYPE_SYSTEM_INFORMATION
) {
748 Type1Record
= (SMBIOS_TABLE_TYPE1
*) Record
;
749 StrIndex
= Type1Record
->ProductName
;
750 GetOptionalStringByIndex ((CHAR8
*)((UINT8
*)Type1Record
+ Type1Record
->Hdr
.Length
), StrIndex
, &NewString
);
751 TokenToUpdate
= STRING_TOKEN (STR_FRONT_PAGE_COMPUTER_MODEL
);
752 HiiSetString (gFrontPagePrivate
.HiiHandle
, TokenToUpdate
, NewString
, NULL
);
753 FreePool (NewString
);
757 if (Record
->Type
== EFI_SMBIOS_TYPE_PROCESSOR_INFORMATION
) {
758 Type4Record
= (SMBIOS_TABLE_TYPE4
*) Record
;
759 StrIndex
= Type4Record
->ProcessorVersion
;
760 GetOptionalStringByIndex ((CHAR8
*)((UINT8
*)Type4Record
+ Type4Record
->Hdr
.Length
), StrIndex
, &NewString
);
761 TokenToUpdate
= STRING_TOKEN (STR_FRONT_PAGE_CPU_MODEL
);
762 HiiSetString (gFrontPagePrivate
.HiiHandle
, TokenToUpdate
, NewString
, NULL
);
763 FreePool (NewString
);
767 if (Record
->Type
== EFI_SMBIOS_TYPE_PROCESSOR_INFORMATION
) {
768 Type4Record
= (SMBIOS_TABLE_TYPE4
*) Record
;
769 ConvertProcessorToString(Type4Record
->CurrentSpeed
, 6, &NewString
);
770 TokenToUpdate
= STRING_TOKEN (STR_FRONT_PAGE_CPU_SPEED
);
771 HiiSetString (gFrontPagePrivate
.HiiHandle
, TokenToUpdate
, NewString
, NULL
);
772 FreePool (NewString
);
776 if ( Record
->Type
== EFI_SMBIOS_TYPE_MEMORY_ARRAY_MAPPED_ADDRESS
) {
777 Type19Record
= (SMBIOS_TABLE_TYPE19
*) Record
;
778 ConvertMemorySizeToString (
779 (UINT32
)(RShiftU64((Type19Record
->EndingAddress
- Type19Record
->StartingAddress
+ 1), 10)),
782 TokenToUpdate
= STRING_TOKEN (STR_FRONT_PAGE_MEMORY_SIZE
);
783 HiiSetString (gFrontPagePrivate
.HiiHandle
, TokenToUpdate
, NewString
, NULL
);
784 FreePool (NewString
);
787 } while ( !(Find
[0] && Find
[1] && Find
[2] && Find
[3] && Find
[4]));
793 Function waits for a given event to fire, or for an optional timeout to expire.
795 @param Event The event to wait for
796 @param Timeout An optional timeout value in 100 ns units.
798 @retval EFI_SUCCESS Event fired before Timeout expired.
799 @retval EFI_TIME_OUT Timout expired before Event fired..
805 IN UINT64 Timeout OPTIONAL
810 EFI_EVENT TimerEvent
;
811 EFI_EVENT WaitList
[2];
815 // Create a timer event
817 Status
= gBS
->CreateEvent (EVT_TIMER
, 0, NULL
, NULL
, &TimerEvent
);
818 if (!EFI_ERROR (Status
)) {
820 // Set the timer event
829 // Wait for the original event or the timer
832 WaitList
[1] = TimerEvent
;
833 Status
= gBS
->WaitForEvent (2, WaitList
, &Index
);
834 gBS
->CloseEvent (TimerEvent
);
837 // If the timer expired, change the return to timed out
839 if (!EFI_ERROR (Status
) && Index
== 1) {
840 Status
= EFI_TIMEOUT
;
845 // No timeout... just wait on the event
847 Status
= gBS
->WaitForEvent (1, &Event
, &Index
);
848 ASSERT (!EFI_ERROR (Status
));
856 Function show progress bar to wait for user input.
859 @param TimeoutDefault The fault time out value before the system continue to boot.
861 @retval EFI_SUCCESS User pressed some key except "Enter"
862 @retval EFI_TIME_OUT Timeout expired or user press "Enter"
867 IN UINT16 TimeoutDefault
871 UINT16 TimeoutRemain
;
874 EFI_GRAPHICS_OUTPUT_BLT_PIXEL Foreground
;
875 EFI_GRAPHICS_OUTPUT_BLT_PIXEL Background
;
876 EFI_GRAPHICS_OUTPUT_BLT_PIXEL Color
;
878 if (TimeoutDefault
== 0) {
882 DEBUG ((EFI_D_INFO
, "\n\nStart showing progress bar... Press any key to stop it! ...Zzz....\n"));
884 SetMem (&Foreground
, sizeof (EFI_GRAPHICS_OUTPUT_BLT_PIXEL
), 0xff);
885 SetMem (&Background
, sizeof (EFI_GRAPHICS_OUTPUT_BLT_PIXEL
), 0x0);
886 SetMem (&Color
, sizeof (EFI_GRAPHICS_OUTPUT_BLT_PIXEL
), 0xff);
889 // Clear the progress status bar first
891 TmpStr
= GetStringById (STRING_TOKEN (STR_START_BOOT_OPTION
));
892 if (TmpStr
!= NULL
) {
893 PlatformBdsShowProgress (Foreground
, Background
, TmpStr
, Color
, 0, 0);
896 TimeoutRemain
= TimeoutDefault
;
897 while (TimeoutRemain
!= 0) {
898 DEBUG ((EFI_D_INFO
, "Showing progress bar...Remaining %d second!\n", TimeoutRemain
));
900 Status
= WaitForSingleEvent (gST
->ConIn
->WaitForKey
, ONE_SECOND
);
901 if (Status
!= EFI_TIMEOUT
) {
909 if (TmpStr
!= NULL
) {
910 PlatformBdsShowProgress (
915 ((TimeoutDefault
- TimeoutRemain
) * 100 / TimeoutDefault
),
920 gBS
->FreePool (TmpStr
);
925 if (TimeoutRemain
== 0) {
930 // User pressed some key
932 Status
= gST
->ConIn
->ReadKeyStroke (gST
->ConIn
, &Key
);
933 if (EFI_ERROR (Status
)) {
937 if (Key
.UnicodeChar
== CHAR_CARRIAGE_RETURN
) {
939 // User pressed enter, equivalent to select "continue"
948 This function is the main entry of the platform setup entry.
949 The function will present the main menu of the system setup,
950 this is the platform reference part and can be customize.
953 @param TimeoutDefault The fault time out value before the system
955 @param ConnectAllHappened The indicater to check if the connect all have
960 PlatformBdsEnterFrontPage (
961 IN UINT16 TimeoutDefault
,
962 IN BOOLEAN ConnectAllHappened
967 PERF_START (NULL
, "BdsTimeOut", "BDS", 0);
969 // Indicate if we need connect all in the platform setup
971 if (ConnectAllHappened
) {
972 gConnectAllHappened
= TRUE
;
976 if (TimeoutDefault
!= 0xffff) {
977 Status
= ShowProgress (TimeoutDefault
);
981 // Ensure screen is clear when switch Console from Graphics mode to Text mode
983 gST
->ConOut
->EnableCursor (gST
->ConOut
, TRUE
);
984 gST
->ConOut
->ClearScreen (gST
->ConOut
);
986 if (EFI_ERROR (Status
)) {
988 // Timeout or user press enter to continue
996 InitializeFrontPage (FALSE
);
999 // Update Front Page strings
1001 UpdateFrontPageStrings ();
1004 Status
= CallFrontPage ();
1007 // If gCallbackKey is greater than 1 and less or equal to 5,
1008 // it will launch configuration utilities.
1011 // 4 = device manager
1012 // 5 = boot maintenance manager
1014 if (gCallbackKey
!= 0) {
1015 REPORT_STATUS_CODE (
1017 (EFI_SOFTWARE_DXE_BS_DRIVER
| EFI_SW_PC_USER_SETUP
)
1021 // Based on the key that was set, we can determine what to do
1023 switch (gCallbackKey
) {
1025 // The first 4 entries in the Front Page are to be GUARANTEED to remain constant so IHV's can
1026 // describe to their customers in documentation how to find their setup information (namely
1027 // under the device manager and specific buckets)
1029 // These entries consist of the Continue, Select language, Boot Manager, and Device Manager
1031 case FRONT_PAGE_KEY_CONTINUE
:
1033 // User hit continue
1037 case FRONT_PAGE_KEY_LANGUAGE
:
1039 // User made a language setting change - display front page again
1043 case FRONT_PAGE_KEY_BOOT_MANAGER
:
1045 // User chose to run the Boot Manager
1050 case FRONT_PAGE_KEY_DEVICE_MANAGER
:
1052 // Display the Device Manager
1055 CallDeviceManager ();
1056 } while (gCallbackKey
== FRONT_PAGE_KEY_DEVICE_MANAGER
);
1059 case FRONT_PAGE_KEY_BOOT_MAINTAIN
:
1061 // Display the Boot Maintenance Manager
1063 BdsStartBootMaint ();
1067 } while ((Status
== EFI_SUCCESS
) && (gCallbackKey
!= FRONT_PAGE_KEY_CONTINUE
));
1070 //Will leave browser, check any reset required change is applied? if yes, reset system
1072 SetupResetReminder ();
1076 // Automatically load current entry
1077 // Note: The following lines of code only execute when Auto boot
1080 PERF_END (NULL
, "BdsTimeOut", "BDS", 0);