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_FORM_BROWSER2_PROTOCOL
*gFormBrowser2
;
26 FRONT_PAGE_CALLBACK_DATA gFrontPagePrivate
= {
27 FRONT_PAGE_CALLBACK_DATA_SIGNATURE
,
38 HII_VENDOR_DEVICE_PATH mFrontPageHiiVendorDevicePath
= {
44 (UINT8
) (sizeof (VENDOR_DEVICE_PATH
)),
45 (UINT8
) ((sizeof (VENDOR_DEVICE_PATH
)) >> 8)
49 // {8E6D99EE-7531-48f8-8745-7F6144468FF2}
51 { 0x8e6d99ee, 0x7531, 0x48f8, { 0x87, 0x45, 0x7f, 0x61, 0x44, 0x46, 0x8f, 0xf2 } }
55 END_ENTIRE_DEVICE_PATH_SUBTYPE
,
57 (UINT8
) (END_DEVICE_PATH_LENGTH
),
58 (UINT8
) ((END_DEVICE_PATH_LENGTH
) >> 8)
64 This function allows a caller to extract the current configuration for one
65 or more named elements from the target driver.
68 @param This Points to the EFI_HII_CONFIG_ACCESS_PROTOCOL.
69 @param Request A null-terminated Unicode string in <ConfigRequest> format.
70 @param Progress On return, points to a character in the Request string.
71 Points to the string's null terminator if request was successful.
72 Points to the most recent '&' before the first failing name/value
73 pair (or the beginning of the string if the failure is in the
74 first name/value pair) if the request was not successful.
75 @param Results A null-terminated Unicode string in <ConfigAltResp> format which
76 has all values filled in for the names in the Request string.
77 String to be allocated by the called function.
79 @retval EFI_SUCCESS The Results is filled with the requested values.
80 @retval EFI_OUT_OF_RESOURCES Not enough memory to store the results.
81 @retval EFI_INVALID_PARAMETER Request is illegal syntax, or unknown name.
82 @retval EFI_NOT_FOUND Routing data doesn't match any storage in this driver.
88 IN CONST EFI_HII_CONFIG_ACCESS_PROTOCOL
*This
,
89 IN CONST EFI_STRING Request
,
90 OUT EFI_STRING
*Progress
,
91 OUT EFI_STRING
*Results
94 if (Progress
== NULL
|| Results
== NULL
) {
95 return EFI_INVALID_PARAMETER
;
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
|| Progress
== NULL
) {
126 return EFI_INVALID_PARAMETER
;
129 *Progress
= Configuration
;
130 if (!HiiIsConfigHdrMatch (Configuration
, &mBootMaintGuid
, mBootMaintStorageName
)
131 && !HiiIsConfigHdrMatch (Configuration
, &mFileExplorerGuid
, mFileExplorerStorageName
)) {
132 return EFI_NOT_FOUND
;
135 *Progress
= Configuration
+ StrLen (Configuration
);
140 This function processes the results of changes in configuration.
143 @param This Points to the EFI_HII_CONFIG_ACCESS_PROTOCOL.
144 @param Action Specifies the type of action taken by the browser.
145 @param QuestionId A unique value which is sent to the original exporting driver
146 so that it can identify the type of data to expect.
147 @param Type The type of value for the question.
148 @param Value A pointer to the data being sent to the original exporting driver.
149 @param ActionRequest On return, points to the action requested by the callback function.
151 @retval EFI_SUCCESS The callback successfully handled the action.
152 @retval EFI_OUT_OF_RESOURCES Not enough storage is available to hold the variable and its data.
153 @retval EFI_DEVICE_ERROR The variable could not be saved.
154 @retval EFI_UNSUPPORTED The specified Action is not supported by the callback.
160 IN CONST EFI_HII_CONFIG_ACCESS_PROTOCOL
*This
,
161 IN EFI_BROWSER_ACTION Action
,
162 IN EFI_QUESTION_ID QuestionId
,
164 IN EFI_IFR_TYPE_VALUE
*Value
,
165 OUT EFI_BROWSER_ACTION_REQUEST
*ActionRequest
168 CHAR8
*LanguageString
;
173 CHAR8
*PlatformSupportedLanguages
;
176 if ((Value
== NULL
) || (ActionRequest
== NULL
)) {
177 return EFI_INVALID_PARAMETER
;
180 gCallbackKey
= QuestionId
;
183 // The first 4 entries in the Front Page are to be GUARANTEED to remain constant so IHV's can
184 // describe to their customers in documentation how to find their setup information (namely
185 // under the device manager and specific buckets)
187 switch (QuestionId
) {
188 case FRONT_PAGE_KEY_CONTINUE
:
190 // This is the continue - clear the screen and return an error to get out of FrontPage loop
194 case FRONT_PAGE_KEY_LANGUAGE
:
196 // Collect the languages from what our current Language support is based on our VFR
198 LanguageString
= HiiGetSupportedLanguages (gFrontPagePrivate
.HiiHandle
);
199 ASSERT (LanguageString
!= NULL
);
201 // Allocate working buffer for RFC 4646 language in supported LanguageString.
203 Lang
= AllocatePool (AsciiStrSize (LanguageString
));
204 ASSERT (Lang
!= NULL
);
207 LangCode
= LanguageString
;
208 while (*LangCode
!= 0) {
209 GetNextLanguage (&LangCode
, Lang
);
211 if (Index
== Value
->u8
) {
218 PlatformSupportedLanguages
= GetEfiGlobalVariable (L
"PlatformLangCodes");
219 if (PlatformSupportedLanguages
== NULL
) {
220 PlatformSupportedLanguages
= AllocateCopyPool (
221 AsciiStrSize ((CHAR8
*) PcdGetPtr (PcdUefiVariableDefaultPlatformLangCodes
)),
222 (CHAR8
*) PcdGetPtr (PcdUefiVariableDefaultPlatformLangCodes
)
224 ASSERT (PlatformSupportedLanguages
!= NULL
);
228 // Select the best language in platform supported Language.
230 BestLanguage
= GetBestLanguage (
231 PlatformSupportedLanguages
,
236 if (BestLanguage
!= NULL
) {
237 Status
= gRT
->SetVariable (
239 &gEfiGlobalVariableGuid
,
240 EFI_VARIABLE_NON_VOLATILE
| EFI_VARIABLE_BOOTSERVICE_ACCESS
| EFI_VARIABLE_RUNTIME_ACCESS
,
241 AsciiStrSize (BestLanguage
),
244 ASSERT_EFI_ERROR(Status
);
245 FreePool (BestLanguage
);
250 FreePool (PlatformSupportedLanguages
);
252 FreePool (LanguageString
);
255 case FRONT_PAGE_KEY_BOOT_MANAGER
:
261 case FRONT_PAGE_KEY_DEVICE_MANAGER
:
267 case FRONT_PAGE_KEY_BOOT_MAINTAIN
:
269 // Boot Maintenance Manager
278 *ActionRequest
= EFI_BROWSER_ACTION_REQUEST_EXIT
;
284 Initialize HII information for the FrontPage
287 @param InitializeHiiData TRUE if HII elements need to be initialized.
289 @retval EFI_SUCCESS The operation is successful.
290 @retval EFI_DEVICE_ERROR If the dynamic opcode creation failed.
294 InitializeFrontPage (
295 IN BOOLEAN InitializeHiiData
299 CHAR8
*LanguageString
;
305 CHAR16
*StringBuffer
;
306 EFI_HII_HANDLE HiiHandle
;
307 VOID
*OptionsOpCodeHandle
;
308 VOID
*StartOpCodeHandle
;
309 VOID
*EndOpCodeHandle
;
310 EFI_IFR_GUID_LABEL
*StartLabel
;
311 EFI_IFR_GUID_LABEL
*EndLabel
;
314 if (InitializeHiiData
) {
316 // Initialize the Device Manager
318 InitializeDeviceManager ();
321 // Initialize the Device Manager
323 InitializeBootManager ();
328 // Locate Hii relative protocols
330 Status
= gBS
->LocateProtocol (&gEfiFormBrowser2ProtocolGuid
, NULL
, (VOID
**) &gFormBrowser2
);
331 if (EFI_ERROR (Status
)) {
336 // Install Device Path Protocol and Config Access protocol to driver handle
338 Status
= gBS
->InstallMultipleProtocolInterfaces (
339 &gFrontPagePrivate
.DriverHandle
,
340 &gEfiDevicePathProtocolGuid
,
341 &mFrontPageHiiVendorDevicePath
,
342 &gEfiHiiConfigAccessProtocolGuid
,
343 &gFrontPagePrivate
.ConfigAccess
,
346 ASSERT_EFI_ERROR (Status
);
349 // Publish our HII data
351 gFrontPagePrivate
.HiiHandle
= HiiAddPackages (
353 gFrontPagePrivate
.DriverHandle
,
358 if (gFrontPagePrivate
.HiiHandle
== NULL
) {
359 return EFI_OUT_OF_RESOURCES
;
365 // Init OpCode Handle and Allocate space for creation of UpdateData Buffer
367 StartOpCodeHandle
= HiiAllocateOpCodeHandle ();
368 ASSERT (StartOpCodeHandle
!= NULL
);
370 EndOpCodeHandle
= HiiAllocateOpCodeHandle ();
371 ASSERT (EndOpCodeHandle
!= NULL
);
373 OptionsOpCodeHandle
= HiiAllocateOpCodeHandle ();
374 ASSERT (OptionsOpCodeHandle
!= NULL
);
376 // Create Hii Extend Label OpCode as the start opcode
378 StartLabel
= (EFI_IFR_GUID_LABEL
*) HiiCreateGuidOpCode (StartOpCodeHandle
, &gEfiIfrTianoGuid
, NULL
, sizeof (EFI_IFR_GUID_LABEL
));
379 StartLabel
->ExtendOpCode
= EFI_IFR_EXTEND_OP_LABEL
;
380 StartLabel
->Number
= LABEL_SELECT_LANGUAGE
;
383 // Create Hii Extend Label OpCode as the end opcode
385 EndLabel
= (EFI_IFR_GUID_LABEL
*) HiiCreateGuidOpCode (EndOpCodeHandle
, &gEfiIfrTianoGuid
, NULL
, sizeof (EFI_IFR_GUID_LABEL
));
386 EndLabel
->ExtendOpCode
= EFI_IFR_EXTEND_OP_LABEL
;
387 EndLabel
->Number
= LABEL_END
;
390 // Collect the languages from what our current Language support is based on our VFR
392 HiiHandle
= gFrontPagePrivate
.HiiHandle
;
393 LanguageString
= HiiGetSupportedLanguages (HiiHandle
);
394 ASSERT (LanguageString
!= NULL
);
396 // Allocate working buffer for RFC 4646 language in supported LanguageString.
398 Lang
= AllocatePool (AsciiStrSize (LanguageString
));
399 ASSERT (Lang
!= NULL
);
401 CurrentLang
= GetEfiGlobalVariable (L
"PlatformLang");
403 // Select the best language in LanguageString as the default one.
405 BestLanguage
= GetBestLanguage (
408 (CurrentLang
!= NULL
) ? CurrentLang
: "",
409 (CHAR8
*) PcdGetPtr (PcdUefiVariableDefaultPlatformLang
),
414 // BestLanguage must be selected as it is the first language in LanguageString by default
416 ASSERT (BestLanguage
!= NULL
);
419 LangCode
= LanguageString
;
422 if (gFrontPagePrivate
.LanguageToken
== NULL
) {
423 while (*LangCode
!= 0) {
424 GetNextLanguage (&LangCode
, Lang
);
427 gFrontPagePrivate
.LanguageToken
= AllocatePool (OptionCount
* sizeof (EFI_STRING_ID
));
428 ASSERT (gFrontPagePrivate
.LanguageToken
!= NULL
);
433 LangCode
= LanguageString
;
434 while (*LangCode
!= 0) {
435 GetNextLanguage (&LangCode
, Lang
);
438 StringBuffer
= HiiGetString (HiiHandle
, PRINTABLE_LANGUAGE_NAME_STRING_ID
, Lang
);
439 ASSERT_EFI_ERROR (StringBuffer
!= NULL
);
442 // Save the string Id for each language
444 gFrontPagePrivate
.LanguageToken
[OptionCount
] = HiiSetString (HiiHandle
, 0, StringBuffer
, NULL
);
445 FreePool (StringBuffer
);
448 if (AsciiStrCmp (Lang
, BestLanguage
) == 0) {
449 HiiCreateOneOfOptionOpCode (
451 gFrontPagePrivate
.LanguageToken
[OptionCount
],
452 EFI_IFR_OPTION_DEFAULT
,
453 EFI_IFR_NUMERIC_SIZE_1
,
457 HiiCreateOneOfOptionOpCode (
459 gFrontPagePrivate
.LanguageToken
[OptionCount
],
461 EFI_IFR_NUMERIC_SIZE_1
,
469 if (CurrentLang
!= NULL
) {
470 FreePool (CurrentLang
);
472 FreePool (BestLanguage
);
474 FreePool (LanguageString
);
476 HiiCreateOneOfOpCode (
478 FRONT_PAGE_KEY_LANGUAGE
,
481 STRING_TOKEN (STR_LANGUAGE_SELECT
),
482 STRING_TOKEN (STR_LANGUAGE_SELECT_HELP
),
483 EFI_IFR_FLAG_CALLBACK
,
484 EFI_IFR_NUMERIC_SIZE_1
,
489 Status
= HiiUpdateForm (
493 StartOpCodeHandle
, // LABEL_SELECT_LANGUAGE
494 EndOpCodeHandle
// LABEL_END
497 HiiFreeOpCodeHandle (StartOpCodeHandle
);
498 HiiFreeOpCodeHandle (EndOpCodeHandle
);
499 HiiFreeOpCodeHandle (OptionsOpCodeHandle
);
504 Call the browser and display the front page
506 @return Status code that will be returned by
507 EFI_FORM_BROWSER2_PROTOCOL.SendForm ().
516 EFI_BROWSER_ACTION_REQUEST ActionRequest
;
519 // Begin waiting for USER INPUT
523 (EFI_SOFTWARE_DXE_BS_DRIVER
| EFI_SW_PC_INPUT_WAIT
)
526 ActionRequest
= EFI_BROWSER_ACTION_REQUEST_NONE
;
527 Status
= gFormBrowser2
->SendForm (
529 &gFrontPagePrivate
.HiiHandle
,
537 // Check whether user change any option setting which needs a reset to be effective
539 if (ActionRequest
== EFI_BROWSER_ACTION_REQUEST_RESET
) {
540 EnableResetRequired ();
547 Acquire the string associated with the ProducerGuid and return it.
550 @param ProducerGuid The Guid to search the HII database for
551 @param Token The token value of the string to extract
552 @param String The string that is extracted
554 @retval EFI_SUCCESS The function returns EFI_SUCCESS always.
559 IN EFI_GUID
*ProducerGuid
,
560 IN EFI_STRING_ID Token
,
564 EFI_STRING TmpString
;
566 TmpString
= HiiGetPackageString (ProducerGuid
, Token
, NULL
);
567 if (TmpString
== NULL
) {
568 *String
= GetStringById (STRING_TOKEN (STR_MISSING_STRING
));
577 Convert Processor Frequency Data to a string.
579 @param ProcessorFrequency The frequency data to process
580 @param Base10Exponent The exponent based on 10
581 @param String The string that is created
585 ConvertProcessorToString (
586 IN UINT16 ProcessorFrequency
,
587 IN UINT16 Base10Exponent
,
591 CHAR16
*StringBuffer
;
595 if (Base10Exponent
>= 6) {
596 FreqMhz
= ProcessorFrequency
;
597 for (Index
= 0; Index
< (UINTN
) (Base10Exponent
- 6); Index
++) {
604 StringBuffer
= AllocateZeroPool (0x20);
605 ASSERT (StringBuffer
!= NULL
);
606 Index
= UnicodeValueToString (StringBuffer
, LEFT_JUSTIFY
, FreqMhz
/ 1000, 3);
607 StrCat (StringBuffer
, L
".");
608 UnicodeValueToString (StringBuffer
+ Index
+ 1, PREFIX_ZERO
, (FreqMhz
% 1000) / 10, 2);
609 StrCat (StringBuffer
, L
" GHz");
610 *String
= (CHAR16
*) StringBuffer
;
616 Convert Memory Size to a string.
618 @param MemorySize The size of the memory to process
619 @param String The string that is created
623 ConvertMemorySizeToString (
624 IN UINT32 MemorySize
,
628 CHAR16
*StringBuffer
;
630 StringBuffer
= AllocateZeroPool (0x20);
631 ASSERT (StringBuffer
!= NULL
);
632 UnicodeValueToString (StringBuffer
, LEFT_JUSTIFY
, MemorySize
, 6);
633 StrCat (StringBuffer
, L
" MB RAM");
635 *String
= (CHAR16
*) StringBuffer
;
642 Acquire the string associated with the Index from smbios structure and return it.
643 The caller is responsible for free the string buffer.
645 @param OptionalStrStart The start position to search the string
646 @param Index The index of the string to extract
647 @param String The string that is extracted
649 @retval EFI_SUCCESS The function returns EFI_SUCCESS always.
653 GetOptionalStringByIndex (
654 IN CHAR8
*OptionalStrStart
,
665 Status
= EFI_NOT_FOUND
;
666 CharInStr
= OptionalStrStart
;
671 // look for the two consecutive zeros, check the string limit by the way.
673 while (*CharInStr
!= 0 || *(CharInStr
+1) != 0) {
674 if (*CharInStr
== 0) {
679 if (StrNum
== Index
) {
680 Status
= EFI_SUCCESS
;
684 CurrentStrLen
= AsciiStrLen(CharInStr
);
687 // forward the pointer
689 OptionalStrStart
= CharInStr
;
690 CharInStr
+= CurrentStrLen
;
693 if (EFI_ERROR (Status
)) {
694 *String
= GetStringById (STRING_TOKEN (STR_MISSING_STRING
));
698 CurrentStrLen
= AsciiStrLen(CharInStr
);
701 *String
= AllocatePool((CurrentStrLen
+ 1)*sizeof(CHAR16
));
702 AsciiStrToUnicodeStr(OptionalStrStart
, *String
);
709 Update the banner information for the Front Page based on DataHub information.
713 UpdateFrontPageStrings (
721 EFI_STRING_ID TokenToUpdate
;
722 EFI_SMBIOS_HANDLE SmbiosHandle
;
723 EFI_SMBIOS_PROTOCOL
*Smbios
;
724 SMBIOS_TABLE_TYPE0
*Type0Record
;
725 SMBIOS_TABLE_TYPE1
*Type1Record
;
726 SMBIOS_TABLE_TYPE4
*Type4Record
;
727 SMBIOS_TABLE_TYPE19
*Type19Record
;
728 EFI_SMBIOS_TABLE_HEADER
*Record
;
730 ZeroMem (Find
, sizeof (Find
));
733 // Update Front Page strings
735 Status
= gBS
->LocateProtocol (
736 &gEfiSmbiosProtocolGuid
,
740 ASSERT_EFI_ERROR (Status
);
744 Status
= Smbios
->GetNext (Smbios
, &SmbiosHandle
, NULL
, &Record
, NULL
);
745 if (EFI_ERROR(Status
)) {
749 if (Record
->Type
== EFI_SMBIOS_TYPE_BIOS_INFORMATION
) {
750 Type0Record
= (SMBIOS_TABLE_TYPE0
*) Record
;
751 StrIndex
= Type0Record
->BiosVersion
;
752 GetOptionalStringByIndex ((CHAR8
*)((UINT8
*)Type0Record
+ Type0Record
->Hdr
.Length
), StrIndex
, &NewString
);
753 TokenToUpdate
= STRING_TOKEN (STR_FRONT_PAGE_BIOS_VERSION
);
754 HiiSetString (gFrontPagePrivate
.HiiHandle
, TokenToUpdate
, NewString
, NULL
);
755 FreePool (NewString
);
759 if (Record
->Type
== EFI_SMBIOS_TYPE_SYSTEM_INFORMATION
) {
760 Type1Record
= (SMBIOS_TABLE_TYPE1
*) Record
;
761 StrIndex
= Type1Record
->ProductName
;
762 GetOptionalStringByIndex ((CHAR8
*)((UINT8
*)Type1Record
+ Type1Record
->Hdr
.Length
), StrIndex
, &NewString
);
763 TokenToUpdate
= STRING_TOKEN (STR_FRONT_PAGE_COMPUTER_MODEL
);
764 HiiSetString (gFrontPagePrivate
.HiiHandle
, TokenToUpdate
, NewString
, NULL
);
765 FreePool (NewString
);
769 if (Record
->Type
== EFI_SMBIOS_TYPE_PROCESSOR_INFORMATION
) {
770 Type4Record
= (SMBIOS_TABLE_TYPE4
*) Record
;
771 StrIndex
= Type4Record
->ProcessorVersion
;
772 GetOptionalStringByIndex ((CHAR8
*)((UINT8
*)Type4Record
+ Type4Record
->Hdr
.Length
), StrIndex
, &NewString
);
773 TokenToUpdate
= STRING_TOKEN (STR_FRONT_PAGE_CPU_MODEL
);
774 HiiSetString (gFrontPagePrivate
.HiiHandle
, TokenToUpdate
, NewString
, NULL
);
775 FreePool (NewString
);
779 if (Record
->Type
== EFI_SMBIOS_TYPE_PROCESSOR_INFORMATION
) {
780 Type4Record
= (SMBIOS_TABLE_TYPE4
*) Record
;
781 ConvertProcessorToString(Type4Record
->CurrentSpeed
, 6, &NewString
);
782 TokenToUpdate
= STRING_TOKEN (STR_FRONT_PAGE_CPU_SPEED
);
783 HiiSetString (gFrontPagePrivate
.HiiHandle
, TokenToUpdate
, NewString
, NULL
);
784 FreePool (NewString
);
788 if ( Record
->Type
== EFI_SMBIOS_TYPE_MEMORY_ARRAY_MAPPED_ADDRESS
) {
789 Type19Record
= (SMBIOS_TABLE_TYPE19
*) Record
;
790 ConvertMemorySizeToString (
791 (UINT32
)(RShiftU64((Type19Record
->EndingAddress
- Type19Record
->StartingAddress
+ 1), 10)),
794 TokenToUpdate
= STRING_TOKEN (STR_FRONT_PAGE_MEMORY_SIZE
);
795 HiiSetString (gFrontPagePrivate
.HiiHandle
, TokenToUpdate
, NewString
, NULL
);
796 FreePool (NewString
);
799 } while ( !(Find
[0] && Find
[1] && Find
[2] && Find
[3] && Find
[4]));
805 Function waits for a given event to fire, or for an optional timeout to expire.
807 @param Event The event to wait for
808 @param Timeout An optional timeout value in 100 ns units.
810 @retval EFI_SUCCESS Event fired before Timeout expired.
811 @retval EFI_TIME_OUT Timout expired before Event fired..
817 IN UINT64 Timeout OPTIONAL
822 EFI_EVENT TimerEvent
;
823 EFI_EVENT WaitList
[2];
827 // Create a timer event
829 Status
= gBS
->CreateEvent (EVT_TIMER
, 0, NULL
, NULL
, &TimerEvent
);
830 if (!EFI_ERROR (Status
)) {
832 // Set the timer event
841 // Wait for the original event or the timer
844 WaitList
[1] = TimerEvent
;
845 Status
= gBS
->WaitForEvent (2, WaitList
, &Index
);
846 gBS
->CloseEvent (TimerEvent
);
849 // If the timer expired, change the return to timed out
851 if (!EFI_ERROR (Status
) && Index
== 1) {
852 Status
= EFI_TIMEOUT
;
857 // No timeout... just wait on the event
859 Status
= gBS
->WaitForEvent (1, &Event
, &Index
);
860 ASSERT (!EFI_ERROR (Status
));
868 Function show progress bar to wait for user input.
871 @param TimeoutDefault The fault time out value before the system continue to boot.
873 @retval EFI_SUCCESS User pressed some key except "Enter"
874 @retval EFI_TIME_OUT Timeout expired or user press "Enter"
879 IN UINT16 TimeoutDefault
883 UINT16 TimeoutRemain
;
886 EFI_GRAPHICS_OUTPUT_BLT_PIXEL Foreground
;
887 EFI_GRAPHICS_OUTPUT_BLT_PIXEL Background
;
888 EFI_GRAPHICS_OUTPUT_BLT_PIXEL Color
;
890 if (TimeoutDefault
== 0) {
894 DEBUG ((EFI_D_INFO
, "\n\nStart showing progress bar... Press any key to stop it! ...Zzz....\n"));
896 SetMem (&Foreground
, sizeof (EFI_GRAPHICS_OUTPUT_BLT_PIXEL
), 0xff);
897 SetMem (&Background
, sizeof (EFI_GRAPHICS_OUTPUT_BLT_PIXEL
), 0x0);
898 SetMem (&Color
, sizeof (EFI_GRAPHICS_OUTPUT_BLT_PIXEL
), 0xff);
901 // Clear the progress status bar first
903 TmpStr
= GetStringById (STRING_TOKEN (STR_START_BOOT_OPTION
));
904 if (TmpStr
!= NULL
) {
905 PlatformBdsShowProgress (Foreground
, Background
, TmpStr
, Color
, 0, 0);
908 TimeoutRemain
= TimeoutDefault
;
909 while (TimeoutRemain
!= 0) {
910 DEBUG ((EFI_D_INFO
, "Showing progress bar...Remaining %d second!\n", TimeoutRemain
));
912 Status
= WaitForSingleEvent (gST
->ConIn
->WaitForKey
, ONE_SECOND
);
913 if (Status
!= EFI_TIMEOUT
) {
921 if (TmpStr
!= NULL
) {
922 PlatformBdsShowProgress (
927 ((TimeoutDefault
- TimeoutRemain
) * 100 / TimeoutDefault
),
932 gBS
->FreePool (TmpStr
);
937 if (TimeoutRemain
== 0) {
942 // User pressed some key
944 Status
= gST
->ConIn
->ReadKeyStroke (gST
->ConIn
, &Key
);
945 if (EFI_ERROR (Status
)) {
949 if (Key
.UnicodeChar
== CHAR_CARRIAGE_RETURN
) {
951 // User pressed enter, equivalent to select "continue"
960 This function is the main entry of the platform setup entry.
961 The function will present the main menu of the system setup,
962 this is the platform reference part and can be customize.
965 @param TimeoutDefault The fault time out value before the system
967 @param ConnectAllHappened The indicater to check if the connect all have
972 PlatformBdsEnterFrontPage (
973 IN UINT16 TimeoutDefault
,
974 IN BOOLEAN ConnectAllHappened
979 PERF_START (NULL
, "BdsTimeOut", "BDS", 0);
981 // Indicate if we need connect all in the platform setup
983 if (ConnectAllHappened
) {
984 gConnectAllHappened
= TRUE
;
987 if (TimeoutDefault
!= 0xffff) {
988 Status
= ShowProgress (TimeoutDefault
);
991 // Ensure screen is clear when switch Console from Graphics mode to Text mode
993 gST
->ConOut
->EnableCursor (gST
->ConOut
, TRUE
);
994 gST
->ConOut
->ClearScreen (gST
->ConOut
);
996 if (EFI_ERROR (Status
)) {
998 // Timeout or user press enter to continue
1006 InitializeFrontPage (FALSE
);
1009 // Update Front Page strings
1011 UpdateFrontPageStrings ();
1014 Status
= CallFrontPage ();
1017 // If gCallbackKey is greater than 1 and less or equal to 5,
1018 // it will launch configuration utilities.
1021 // 4 = device manager
1022 // 5 = boot maintenance manager
1024 if (gCallbackKey
!= 0) {
1025 REPORT_STATUS_CODE (
1027 (EFI_SOFTWARE_DXE_BS_DRIVER
| EFI_SW_PC_USER_SETUP
)
1031 // Based on the key that was set, we can determine what to do
1033 switch (gCallbackKey
) {
1035 // The first 4 entries in the Front Page are to be GUARANTEED to remain constant so IHV's can
1036 // describe to their customers in documentation how to find their setup information (namely
1037 // under the device manager and specific buckets)
1039 // These entries consist of the Continue, Select language, Boot Manager, and Device Manager
1041 case FRONT_PAGE_KEY_CONTINUE
:
1043 // User hit continue
1047 case FRONT_PAGE_KEY_LANGUAGE
:
1049 // User made a language setting change - display front page again
1053 case FRONT_PAGE_KEY_BOOT_MANAGER
:
1055 // User chose to run the Boot Manager
1060 case FRONT_PAGE_KEY_DEVICE_MANAGER
:
1062 // Display the Device Manager
1065 CallDeviceManager ();
1066 } while (gCallbackKey
== FRONT_PAGE_KEY_DEVICE_MANAGER
);
1069 case FRONT_PAGE_KEY_BOOT_MAINTAIN
:
1071 // Display the Boot Maintenance Manager
1073 BdsStartBootMaint ();
1077 } while ((Status
== EFI_SUCCESS
) && (gCallbackKey
!= FRONT_PAGE_KEY_CONTINUE
));
1080 //Will leave browser, check any reset required change is applied? if yes, reset system
1082 SetupResetReminder ();
1086 // Automatically load current entry
1087 // Note: The following lines of code only execute when Auto boot
1090 PERF_END (NULL
, "BdsTimeOut", "BDS", 0);