2009-01-23 08:24:55 +01:00
|
|
|
/** @file
|
|
|
|
FrontPage routines to handle the callbacks and browser calls
|
|
|
|
|
2010-06-02 04:06:01 +02:00
|
|
|
Copyright (c) 2004 - 2010, Intel Corporation. All rights reserved.<BR>
|
2010-04-23 18:28:26 +02:00
|
|
|
This program and the accompanying materials
|
2009-01-23 08:24:55 +01:00
|
|
|
are licensed and made available under the terms and conditions of the BSD License
|
|
|
|
which accompanies this distribution. The full text of the license may be found at
|
|
|
|
http://opensource.org/licenses/bsd-license.php
|
|
|
|
|
|
|
|
THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
|
|
|
|
WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
|
|
|
|
|
|
|
|
**/
|
|
|
|
|
|
|
|
#include "Bds.h"
|
|
|
|
#include "FrontPage.h"
|
2009-04-16 10:46:28 +02:00
|
|
|
#include "Language.h"
|
2009-01-23 08:24:55 +01:00
|
|
|
|
|
|
|
EFI_GUID mFrontPageGuid = FRONT_PAGE_FORMSET_GUID;
|
|
|
|
|
|
|
|
BOOLEAN gConnectAllHappened = FALSE;
|
|
|
|
UINTN gCallbackKey;
|
|
|
|
|
|
|
|
EFI_FORM_BROWSER2_PROTOCOL *gFormBrowser2;
|
|
|
|
|
|
|
|
FRONT_PAGE_CALLBACK_DATA gFrontPagePrivate = {
|
|
|
|
FRONT_PAGE_CALLBACK_DATA_SIGNATURE,
|
|
|
|
NULL,
|
|
|
|
NULL,
|
|
|
|
NULL,
|
|
|
|
{
|
|
|
|
FakeExtractConfig,
|
|
|
|
FakeRouteConfig,
|
|
|
|
FrontPageCallback
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2009-04-02 10:48:03 +02:00
|
|
|
HII_VENDOR_DEVICE_PATH mFrontPageHiiVendorDevicePath = {
|
|
|
|
{
|
|
|
|
{
|
|
|
|
HARDWARE_DEVICE_PATH,
|
|
|
|
HW_VENDOR_DP,
|
|
|
|
{
|
|
|
|
(UINT8) (sizeof (VENDOR_DEVICE_PATH)),
|
|
|
|
(UINT8) ((sizeof (VENDOR_DEVICE_PATH)) >> 8)
|
|
|
|
}
|
|
|
|
},
|
|
|
|
//
|
|
|
|
// {8E6D99EE-7531-48f8-8745-7F6144468FF2}
|
|
|
|
//
|
|
|
|
{ 0x8e6d99ee, 0x7531, 0x48f8, { 0x87, 0x45, 0x7f, 0x61, 0x44, 0x46, 0x8f, 0xf2 } }
|
|
|
|
},
|
|
|
|
{
|
|
|
|
END_DEVICE_PATH_TYPE,
|
|
|
|
END_ENTIRE_DEVICE_PATH_SUBTYPE,
|
2009-07-16 00:28:07 +02:00
|
|
|
{
|
2009-04-02 10:48:03 +02:00
|
|
|
(UINT8) (END_DEVICE_PATH_LENGTH),
|
|
|
|
(UINT8) ((END_DEVICE_PATH_LENGTH) >> 8)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2009-01-23 08:24:55 +01:00
|
|
|
/**
|
|
|
|
This function allows a caller to extract the current configuration for one
|
|
|
|
or more named elements from the target driver.
|
|
|
|
|
|
|
|
|
|
|
|
@param This Points to the EFI_HII_CONFIG_ACCESS_PROTOCOL.
|
|
|
|
@param Request A null-terminated Unicode string in <ConfigRequest> format.
|
|
|
|
@param Progress On return, points to a character in the Request string.
|
|
|
|
Points to the string's null terminator if request was successful.
|
|
|
|
Points to the most recent '&' before the first failing name/value
|
|
|
|
pair (or the beginning of the string if the failure is in the
|
|
|
|
first name/value pair) if the request was not successful.
|
|
|
|
@param Results A null-terminated Unicode string in <ConfigAltResp> format which
|
|
|
|
has all values filled in for the names in the Request string.
|
|
|
|
String to be allocated by the called function.
|
|
|
|
|
|
|
|
@retval EFI_SUCCESS The Results is filled with the requested values.
|
|
|
|
@retval EFI_OUT_OF_RESOURCES Not enough memory to store the results.
|
2010-03-04 07:48:52 +01:00
|
|
|
@retval EFI_INVALID_PARAMETER Request is illegal syntax, or unknown name.
|
2009-01-23 08:24:55 +01:00
|
|
|
@retval EFI_NOT_FOUND Routing data doesn't match any storage in this driver.
|
|
|
|
|
|
|
|
**/
|
|
|
|
EFI_STATUS
|
|
|
|
EFIAPI
|
|
|
|
FakeExtractConfig (
|
|
|
|
IN CONST EFI_HII_CONFIG_ACCESS_PROTOCOL *This,
|
|
|
|
IN CONST EFI_STRING Request,
|
|
|
|
OUT EFI_STRING *Progress,
|
|
|
|
OUT EFI_STRING *Results
|
|
|
|
)
|
|
|
|
{
|
2010-03-04 07:48:52 +01:00
|
|
|
if (Progress == NULL || Results == NULL) {
|
2009-05-20 11:29:13 +02:00
|
|
|
return EFI_INVALID_PARAMETER;
|
|
|
|
}
|
2009-05-19 11:13:47 +02:00
|
|
|
*Progress = Request;
|
2009-01-23 08:24:55 +01:00
|
|
|
return EFI_NOT_FOUND;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
This function processes the results of changes in configuration.
|
|
|
|
|
|
|
|
|
|
|
|
@param This Points to the EFI_HII_CONFIG_ACCESS_PROTOCOL.
|
|
|
|
@param Configuration A null-terminated Unicode string in <ConfigResp> format.
|
|
|
|
@param Progress A pointer to a string filled in with the offset of the most
|
|
|
|
recent '&' before the first failing name/value pair (or the
|
|
|
|
beginning of the string if the failure is in the first
|
|
|
|
name/value pair) or the terminating NULL if all was successful.
|
|
|
|
|
|
|
|
@retval EFI_SUCCESS The Results is processed successfully.
|
|
|
|
@retval EFI_INVALID_PARAMETER Configuration is NULL.
|
|
|
|
@retval EFI_NOT_FOUND Routing data doesn't match any storage in this driver.
|
|
|
|
|
|
|
|
**/
|
|
|
|
EFI_STATUS
|
|
|
|
EFIAPI
|
|
|
|
FakeRouteConfig (
|
|
|
|
IN CONST EFI_HII_CONFIG_ACCESS_PROTOCOL *This,
|
|
|
|
IN CONST EFI_STRING Configuration,
|
|
|
|
OUT EFI_STRING *Progress
|
|
|
|
)
|
|
|
|
{
|
2009-05-20 11:29:13 +02:00
|
|
|
if (Configuration == NULL || Progress == NULL) {
|
2009-05-19 11:13:47 +02:00
|
|
|
return EFI_INVALID_PARAMETER;
|
|
|
|
}
|
|
|
|
|
2009-05-20 11:29:13 +02:00
|
|
|
*Progress = Configuration;
|
|
|
|
if (!HiiIsConfigHdrMatch (Configuration, &mBootMaintGuid, mBootMaintStorageName)
|
|
|
|
&& !HiiIsConfigHdrMatch (Configuration, &mFileExplorerGuid, mFileExplorerStorageName)) {
|
|
|
|
return EFI_NOT_FOUND;
|
2009-05-19 11:13:47 +02:00
|
|
|
}
|
|
|
|
|
2009-05-20 11:29:13 +02:00
|
|
|
*Progress = Configuration + StrLen (Configuration);
|
|
|
|
return EFI_SUCCESS;
|
2009-01-23 08:24:55 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
This function processes the results of changes in configuration.
|
|
|
|
|
|
|
|
|
|
|
|
@param This Points to the EFI_HII_CONFIG_ACCESS_PROTOCOL.
|
|
|
|
@param Action Specifies the type of action taken by the browser.
|
|
|
|
@param QuestionId A unique value which is sent to the original exporting driver
|
|
|
|
so that it can identify the type of data to expect.
|
|
|
|
@param Type The type of value for the question.
|
|
|
|
@param Value A pointer to the data being sent to the original exporting driver.
|
|
|
|
@param ActionRequest On return, points to the action requested by the callback function.
|
|
|
|
|
|
|
|
@retval EFI_SUCCESS The callback successfully handled the action.
|
|
|
|
@retval EFI_OUT_OF_RESOURCES Not enough storage is available to hold the variable and its data.
|
|
|
|
@retval EFI_DEVICE_ERROR The variable could not be saved.
|
|
|
|
@retval EFI_UNSUPPORTED The specified Action is not supported by the callback.
|
|
|
|
|
|
|
|
**/
|
|
|
|
EFI_STATUS
|
|
|
|
EFIAPI
|
|
|
|
FrontPageCallback (
|
|
|
|
IN CONST EFI_HII_CONFIG_ACCESS_PROTOCOL *This,
|
|
|
|
IN EFI_BROWSER_ACTION Action,
|
|
|
|
IN EFI_QUESTION_ID QuestionId,
|
|
|
|
IN UINT8 Type,
|
|
|
|
IN EFI_IFR_TYPE_VALUE *Value,
|
|
|
|
OUT EFI_BROWSER_ACTION_REQUEST *ActionRequest
|
|
|
|
)
|
|
|
|
{
|
|
|
|
CHAR8 *LanguageString;
|
|
|
|
CHAR8 *LangCode;
|
2009-03-27 04:21:37 +01:00
|
|
|
CHAR8 *Lang;
|
2009-01-23 08:24:55 +01:00
|
|
|
UINTN Index;
|
|
|
|
EFI_STATUS Status;
|
2009-03-27 04:21:37 +01:00
|
|
|
CHAR8 *PlatformSupportedLanguages;
|
|
|
|
CHAR8 *BestLanguage;
|
2009-01-23 08:24:55 +01:00
|
|
|
|
2010-06-02 04:06:01 +02:00
|
|
|
if ((Action == EFI_BROWSER_ACTION_FORM_OPEN) || (Action == EFI_BROWSER_ACTION_FORM_CLOSE)) {
|
|
|
|
//
|
|
|
|
// Do nothing for UEFI OPEN/CLOSE Action
|
|
|
|
//
|
|
|
|
return EFI_SUCCESS;
|
|
|
|
}
|
|
|
|
|
2009-01-23 08:24:55 +01:00
|
|
|
if ((Value == NULL) || (ActionRequest == NULL)) {
|
|
|
|
return EFI_INVALID_PARAMETER;
|
|
|
|
}
|
|
|
|
|
|
|
|
gCallbackKey = QuestionId;
|
|
|
|
|
|
|
|
//
|
|
|
|
// The first 4 entries in the Front Page are to be GUARANTEED to remain constant so IHV's can
|
|
|
|
// describe to their customers in documentation how to find their setup information (namely
|
|
|
|
// under the device manager and specific buckets)
|
|
|
|
//
|
|
|
|
switch (QuestionId) {
|
|
|
|
case FRONT_PAGE_KEY_CONTINUE:
|
|
|
|
//
|
|
|
|
// This is the continue - clear the screen and return an error to get out of FrontPage loop
|
|
|
|
//
|
|
|
|
break;
|
|
|
|
|
|
|
|
case FRONT_PAGE_KEY_LANGUAGE:
|
|
|
|
//
|
|
|
|
// Collect the languages from what our current Language support is based on our VFR
|
|
|
|
//
|
2009-04-14 12:47:19 +02:00
|
|
|
LanguageString = HiiGetSupportedLanguages (gFrontPagePrivate.HiiHandle);
|
2009-01-23 08:24:55 +01:00
|
|
|
ASSERT (LanguageString != NULL);
|
2009-03-27 04:21:37 +01:00
|
|
|
//
|
|
|
|
// Allocate working buffer for RFC 4646 language in supported LanguageString.
|
|
|
|
//
|
|
|
|
Lang = AllocatePool (AsciiStrSize (LanguageString));
|
|
|
|
ASSERT (Lang != NULL);
|
2009-07-16 00:28:07 +02:00
|
|
|
|
2009-01-23 08:24:55 +01:00
|
|
|
Index = 0;
|
|
|
|
LangCode = LanguageString;
|
|
|
|
while (*LangCode != 0) {
|
2009-04-17 04:38:11 +02:00
|
|
|
GetNextLanguage (&LangCode, Lang);
|
2009-01-23 08:24:55 +01:00
|
|
|
|
|
|
|
if (Index == Value->u8) {
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
Index++;
|
|
|
|
}
|
|
|
|
|
2009-03-27 04:21:37 +01:00
|
|
|
PlatformSupportedLanguages = GetEfiGlobalVariable (L"PlatformLangCodes");
|
|
|
|
if (PlatformSupportedLanguages == NULL) {
|
|
|
|
PlatformSupportedLanguages = AllocateCopyPool (
|
|
|
|
AsciiStrSize ((CHAR8 *) PcdGetPtr (PcdUefiVariableDefaultPlatformLangCodes)),
|
|
|
|
(CHAR8 *) PcdGetPtr (PcdUefiVariableDefaultPlatformLangCodes)
|
|
|
|
);
|
|
|
|
ASSERT (PlatformSupportedLanguages != NULL);
|
|
|
|
}
|
2009-07-16 00:28:07 +02:00
|
|
|
|
2009-03-27 04:21:37 +01:00
|
|
|
//
|
|
|
|
// Select the best language in platform supported Language.
|
|
|
|
//
|
|
|
|
BestLanguage = GetBestLanguage (
|
|
|
|
PlatformSupportedLanguages,
|
|
|
|
FALSE,
|
|
|
|
Lang,
|
|
|
|
NULL
|
|
|
|
);
|
|
|
|
if (BestLanguage != NULL) {
|
|
|
|
Status = gRT->SetVariable (
|
|
|
|
L"PlatformLang",
|
|
|
|
&gEfiGlobalVariableGuid,
|
|
|
|
EFI_VARIABLE_NON_VOLATILE | EFI_VARIABLE_BOOTSERVICE_ACCESS | EFI_VARIABLE_RUNTIME_ACCESS,
|
|
|
|
AsciiStrSize (BestLanguage),
|
|
|
|
Lang
|
|
|
|
);
|
2009-04-28 03:46:32 +02:00
|
|
|
ASSERT_EFI_ERROR(Status);
|
2009-03-27 04:21:37 +01:00
|
|
|
FreePool (BestLanguage);
|
2009-04-27 09:12:20 +02:00
|
|
|
} else {
|
|
|
|
ASSERT (FALSE);
|
2009-01-23 08:24:55 +01:00
|
|
|
}
|
2009-04-27 09:12:20 +02:00
|
|
|
|
2009-03-27 04:21:37 +01:00
|
|
|
FreePool (PlatformSupportedLanguages);
|
|
|
|
FreePool (Lang);
|
2009-01-23 08:24:55 +01:00
|
|
|
FreePool (LanguageString);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case FRONT_PAGE_KEY_BOOT_MANAGER:
|
|
|
|
//
|
|
|
|
// Boot Manager
|
|
|
|
//
|
|
|
|
break;
|
|
|
|
|
|
|
|
case FRONT_PAGE_KEY_DEVICE_MANAGER:
|
|
|
|
//
|
|
|
|
// Device Manager
|
|
|
|
//
|
|
|
|
break;
|
|
|
|
|
|
|
|
case FRONT_PAGE_KEY_BOOT_MAINTAIN:
|
|
|
|
//
|
|
|
|
// Boot Maintenance Manager
|
|
|
|
//
|
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
gCallbackKey = 0;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
*ActionRequest = EFI_BROWSER_ACTION_REQUEST_EXIT;
|
|
|
|
|
|
|
|
return EFI_SUCCESS;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
Initialize HII information for the FrontPage
|
|
|
|
|
|
|
|
|
|
|
|
@param InitializeHiiData TRUE if HII elements need to be initialized.
|
|
|
|
|
|
|
|
@retval EFI_SUCCESS The operation is successful.
|
|
|
|
@retval EFI_DEVICE_ERROR If the dynamic opcode creation failed.
|
|
|
|
|
|
|
|
**/
|
|
|
|
EFI_STATUS
|
|
|
|
InitializeFrontPage (
|
|
|
|
IN BOOLEAN InitializeHiiData
|
|
|
|
)
|
|
|
|
{
|
|
|
|
EFI_STATUS Status;
|
|
|
|
CHAR8 *LanguageString;
|
|
|
|
CHAR8 *LangCode;
|
2009-03-27 04:21:37 +01:00
|
|
|
CHAR8 *Lang;
|
|
|
|
CHAR8 *CurrentLang;
|
|
|
|
CHAR8 *BestLanguage;
|
2009-01-23 08:24:55 +01:00
|
|
|
UINTN OptionCount;
|
|
|
|
CHAR16 *StringBuffer;
|
|
|
|
EFI_HII_HANDLE HiiHandle;
|
2009-04-17 07:31:38 +02:00
|
|
|
VOID *OptionsOpCodeHandle;
|
|
|
|
VOID *StartOpCodeHandle;
|
|
|
|
VOID *EndOpCodeHandle;
|
|
|
|
EFI_IFR_GUID_LABEL *StartLabel;
|
|
|
|
EFI_IFR_GUID_LABEL *EndLabel;
|
|
|
|
BOOLEAN FirstFlag;
|
2009-01-23 08:24:55 +01:00
|
|
|
|
|
|
|
if (InitializeHiiData) {
|
|
|
|
//
|
|
|
|
// Initialize the Device Manager
|
|
|
|
//
|
|
|
|
InitializeDeviceManager ();
|
|
|
|
|
|
|
|
//
|
|
|
|
// Initialize the Device Manager
|
|
|
|
//
|
|
|
|
InitializeBootManager ();
|
|
|
|
|
|
|
|
gCallbackKey = 0;
|
|
|
|
|
|
|
|
//
|
|
|
|
// Locate Hii relative protocols
|
|
|
|
//
|
|
|
|
Status = gBS->LocateProtocol (&gEfiFormBrowser2ProtocolGuid, NULL, (VOID **) &gFormBrowser2);
|
|
|
|
if (EFI_ERROR (Status)) {
|
|
|
|
return Status;
|
|
|
|
}
|
|
|
|
|
|
|
|
//
|
2009-04-02 10:48:03 +02:00
|
|
|
// Install Device Path Protocol and Config Access protocol to driver handle
|
2009-01-23 08:24:55 +01:00
|
|
|
//
|
2009-04-02 10:48:03 +02:00
|
|
|
Status = gBS->InstallMultipleProtocolInterfaces (
|
2009-01-23 08:24:55 +01:00
|
|
|
&gFrontPagePrivate.DriverHandle,
|
2009-04-02 10:48:03 +02:00
|
|
|
&gEfiDevicePathProtocolGuid,
|
|
|
|
&mFrontPageHiiVendorDevicePath,
|
2009-01-23 08:24:55 +01:00
|
|
|
&gEfiHiiConfigAccessProtocolGuid,
|
2009-04-02 10:48:03 +02:00
|
|
|
&gFrontPagePrivate.ConfigAccess,
|
|
|
|
NULL
|
2009-01-23 08:24:55 +01:00
|
|
|
);
|
|
|
|
ASSERT_EFI_ERROR (Status);
|
|
|
|
|
|
|
|
//
|
|
|
|
// Publish our HII data
|
|
|
|
//
|
2009-04-14 12:47:19 +02:00
|
|
|
gFrontPagePrivate.HiiHandle = HiiAddPackages (
|
|
|
|
&mFrontPageGuid,
|
|
|
|
gFrontPagePrivate.DriverHandle,
|
|
|
|
FrontPageVfrBin,
|
|
|
|
BdsDxeStrings,
|
|
|
|
NULL
|
|
|
|
);
|
|
|
|
if (gFrontPagePrivate.HiiHandle == NULL) {
|
|
|
|
return EFI_OUT_OF_RESOURCES;
|
2009-01-23 08:24:55 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
//
|
2009-04-17 07:31:38 +02:00
|
|
|
// Init OpCode Handle and Allocate space for creation of UpdateData Buffer
|
2009-01-23 08:24:55 +01:00
|
|
|
//
|
2009-04-17 07:31:38 +02:00
|
|
|
StartOpCodeHandle = HiiAllocateOpCodeHandle ();
|
|
|
|
ASSERT (StartOpCodeHandle != NULL);
|
2009-01-23 08:24:55 +01:00
|
|
|
|
2009-04-17 07:31:38 +02:00
|
|
|
EndOpCodeHandle = HiiAllocateOpCodeHandle ();
|
|
|
|
ASSERT (EndOpCodeHandle != NULL);
|
|
|
|
|
|
|
|
OptionsOpCodeHandle = HiiAllocateOpCodeHandle ();
|
|
|
|
ASSERT (OptionsOpCodeHandle != NULL);
|
|
|
|
//
|
|
|
|
// Create Hii Extend Label OpCode as the start opcode
|
|
|
|
//
|
|
|
|
StartLabel = (EFI_IFR_GUID_LABEL *) HiiCreateGuidOpCode (StartOpCodeHandle, &gEfiIfrTianoGuid, NULL, sizeof (EFI_IFR_GUID_LABEL));
|
|
|
|
StartLabel->ExtendOpCode = EFI_IFR_EXTEND_OP_LABEL;
|
|
|
|
StartLabel->Number = LABEL_SELECT_LANGUAGE;
|
|
|
|
|
|
|
|
//
|
|
|
|
// Create Hii Extend Label OpCode as the end opcode
|
|
|
|
//
|
|
|
|
EndLabel = (EFI_IFR_GUID_LABEL *) HiiCreateGuidOpCode (EndOpCodeHandle, &gEfiIfrTianoGuid, NULL, sizeof (EFI_IFR_GUID_LABEL));
|
|
|
|
EndLabel->ExtendOpCode = EFI_IFR_EXTEND_OP_LABEL;
|
|
|
|
EndLabel->Number = LABEL_END;
|
2009-01-23 08:24:55 +01:00
|
|
|
|
|
|
|
//
|
|
|
|
// Collect the languages from what our current Language support is based on our VFR
|
|
|
|
//
|
|
|
|
HiiHandle = gFrontPagePrivate.HiiHandle;
|
2009-04-14 12:47:19 +02:00
|
|
|
LanguageString = HiiGetSupportedLanguages (HiiHandle);
|
2009-01-23 08:24:55 +01:00
|
|
|
ASSERT (LanguageString != NULL);
|
2009-03-27 04:21:37 +01:00
|
|
|
//
|
|
|
|
// Allocate working buffer for RFC 4646 language in supported LanguageString.
|
|
|
|
//
|
|
|
|
Lang = AllocatePool (AsciiStrSize (LanguageString));
|
|
|
|
ASSERT (Lang != NULL);
|
|
|
|
|
|
|
|
CurrentLang = GetEfiGlobalVariable (L"PlatformLang");
|
|
|
|
//
|
|
|
|
// Select the best language in LanguageString as the default one.
|
|
|
|
//
|
|
|
|
BestLanguage = GetBestLanguage (
|
|
|
|
LanguageString,
|
|
|
|
FALSE,
|
|
|
|
(CurrentLang != NULL) ? CurrentLang : "",
|
|
|
|
(CHAR8 *) PcdGetPtr (PcdUefiVariableDefaultPlatformLang),
|
|
|
|
LanguageString,
|
|
|
|
NULL
|
|
|
|
);
|
|
|
|
//
|
|
|
|
// BestLanguage must be selected as it is the first language in LanguageString by default
|
|
|
|
//
|
|
|
|
ASSERT (BestLanguage != NULL);
|
2009-01-23 08:24:55 +01:00
|
|
|
|
2009-04-17 07:31:38 +02:00
|
|
|
OptionCount = 0;
|
|
|
|
LangCode = LanguageString;
|
|
|
|
FirstFlag = FALSE;
|
2009-07-16 00:28:07 +02:00
|
|
|
|
2009-04-17 07:31:38 +02:00
|
|
|
if (gFrontPagePrivate.LanguageToken == NULL) {
|
|
|
|
while (*LangCode != 0) {
|
2009-04-17 07:42:23 +02:00
|
|
|
GetNextLanguage (&LangCode, Lang);
|
2009-04-17 07:31:38 +02:00
|
|
|
OptionCount ++;
|
|
|
|
}
|
2010-03-22 13:31:57 +01:00
|
|
|
gFrontPagePrivate.LanguageToken = AllocatePool (OptionCount * sizeof (EFI_STRING_ID));
|
2009-04-17 07:31:38 +02:00
|
|
|
ASSERT (gFrontPagePrivate.LanguageToken != NULL);
|
|
|
|
FirstFlag = TRUE;
|
|
|
|
}
|
|
|
|
|
2009-01-23 08:24:55 +01:00
|
|
|
OptionCount = 0;
|
|
|
|
LangCode = LanguageString;
|
|
|
|
while (*LangCode != 0) {
|
2009-04-17 04:38:11 +02:00
|
|
|
GetNextLanguage (&LangCode, Lang);
|
2009-01-23 08:24:55 +01:00
|
|
|
|
2009-04-17 07:31:38 +02:00
|
|
|
if (FirstFlag) {
|
2009-08-31 16:14:44 +02:00
|
|
|
StringBuffer = HiiGetString (HiiHandle, PRINTABLE_LANGUAGE_NAME_STRING_ID, Lang);
|
2010-07-01 05:21:55 +02:00
|
|
|
ASSERT (StringBuffer != NULL);
|
2009-01-23 08:24:55 +01:00
|
|
|
|
2009-04-17 07:31:38 +02:00
|
|
|
//
|
|
|
|
// Save the string Id for each language
|
|
|
|
//
|
|
|
|
gFrontPagePrivate.LanguageToken[OptionCount] = HiiSetString (HiiHandle, 0, StringBuffer, NULL);
|
2009-01-23 08:24:55 +01:00
|
|
|
FreePool (StringBuffer);
|
|
|
|
}
|
|
|
|
|
2009-03-27 04:21:37 +01:00
|
|
|
if (AsciiStrCmp (Lang, BestLanguage) == 0) {
|
2009-04-17 07:31:38 +02:00
|
|
|
HiiCreateOneOfOptionOpCode (
|
|
|
|
OptionsOpCodeHandle,
|
|
|
|
gFrontPagePrivate.LanguageToken[OptionCount],
|
|
|
|
EFI_IFR_OPTION_DEFAULT,
|
|
|
|
EFI_IFR_NUMERIC_SIZE_1,
|
|
|
|
(UINT8) OptionCount
|
|
|
|
);
|
2009-01-23 08:24:55 +01:00
|
|
|
} else {
|
2009-04-17 07:31:38 +02:00
|
|
|
HiiCreateOneOfOptionOpCode (
|
|
|
|
OptionsOpCodeHandle,
|
|
|
|
gFrontPagePrivate.LanguageToken[OptionCount],
|
|
|
|
0,
|
|
|
|
EFI_IFR_NUMERIC_SIZE_1,
|
|
|
|
(UINT8) OptionCount
|
|
|
|
);
|
2009-01-23 08:24:55 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
OptionCount++;
|
|
|
|
}
|
|
|
|
|
2009-03-27 04:21:37 +01:00
|
|
|
if (CurrentLang != NULL) {
|
|
|
|
FreePool (CurrentLang);
|
|
|
|
}
|
|
|
|
FreePool (BestLanguage);
|
|
|
|
FreePool (Lang);
|
2009-01-23 08:24:55 +01:00
|
|
|
FreePool (LanguageString);
|
|
|
|
|
2009-04-17 07:31:38 +02:00
|
|
|
HiiCreateOneOfOpCode (
|
|
|
|
StartOpCodeHandle,
|
2009-01-23 08:24:55 +01:00
|
|
|
FRONT_PAGE_KEY_LANGUAGE,
|
|
|
|
0,
|
|
|
|
0,
|
|
|
|
STRING_TOKEN (STR_LANGUAGE_SELECT),
|
|
|
|
STRING_TOKEN (STR_LANGUAGE_SELECT_HELP),
|
|
|
|
EFI_IFR_FLAG_CALLBACK,
|
|
|
|
EFI_IFR_NUMERIC_SIZE_1,
|
2009-04-17 07:31:38 +02:00
|
|
|
OptionsOpCodeHandle,
|
|
|
|
NULL
|
2009-01-23 08:24:55 +01:00
|
|
|
);
|
|
|
|
|
2009-04-17 07:31:38 +02:00
|
|
|
Status = HiiUpdateForm (
|
2009-01-23 08:24:55 +01:00
|
|
|
HiiHandle,
|
|
|
|
&mFrontPageGuid,
|
|
|
|
FRONT_PAGE_FORM_ID,
|
2009-04-17 07:31:38 +02:00
|
|
|
StartOpCodeHandle, // LABEL_SELECT_LANGUAGE
|
|
|
|
EndOpCodeHandle // LABEL_END
|
2009-01-23 08:24:55 +01:00
|
|
|
);
|
|
|
|
|
2009-04-17 07:31:38 +02:00
|
|
|
HiiFreeOpCodeHandle (StartOpCodeHandle);
|
|
|
|
HiiFreeOpCodeHandle (EndOpCodeHandle);
|
|
|
|
HiiFreeOpCodeHandle (OptionsOpCodeHandle);
|
2009-01-23 08:24:55 +01:00
|
|
|
return Status;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
Call the browser and display the front page
|
|
|
|
|
|
|
|
@return Status code that will be returned by
|
|
|
|
EFI_FORM_BROWSER2_PROTOCOL.SendForm ().
|
|
|
|
|
|
|
|
**/
|
|
|
|
EFI_STATUS
|
|
|
|
CallFrontPage (
|
|
|
|
VOID
|
|
|
|
)
|
|
|
|
{
|
|
|
|
EFI_STATUS Status;
|
|
|
|
EFI_BROWSER_ACTION_REQUEST ActionRequest;
|
|
|
|
|
|
|
|
//
|
|
|
|
// Begin waiting for USER INPUT
|
|
|
|
//
|
|
|
|
REPORT_STATUS_CODE (
|
|
|
|
EFI_PROGRESS_CODE,
|
|
|
|
(EFI_SOFTWARE_DXE_BS_DRIVER | EFI_SW_PC_INPUT_WAIT)
|
|
|
|
);
|
|
|
|
|
|
|
|
ActionRequest = EFI_BROWSER_ACTION_REQUEST_NONE;
|
|
|
|
Status = gFormBrowser2->SendForm (
|
|
|
|
gFormBrowser2,
|
|
|
|
&gFrontPagePrivate.HiiHandle,
|
|
|
|
1,
|
2009-04-21 15:37:14 +02:00
|
|
|
&mFrontPageGuid,
|
2009-01-23 08:24:55 +01:00
|
|
|
0,
|
|
|
|
NULL,
|
|
|
|
&ActionRequest
|
|
|
|
);
|
|
|
|
//
|
2009-12-04 04:35:56 +01:00
|
|
|
// Check whether user change any option setting which needs a reset to be effective
|
2009-01-23 08:24:55 +01:00
|
|
|
//
|
|
|
|
if (ActionRequest == EFI_BROWSER_ACTION_REQUEST_RESET) {
|
|
|
|
EnableResetRequired ();
|
|
|
|
}
|
|
|
|
|
|
|
|
return Status;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
Acquire the string associated with the ProducerGuid and return it.
|
|
|
|
|
|
|
|
|
|
|
|
@param ProducerGuid The Guid to search the HII database for
|
|
|
|
@param Token The token value of the string to extract
|
|
|
|
@param String The string that is extracted
|
|
|
|
|
|
|
|
@retval EFI_SUCCESS The function returns EFI_SUCCESS always.
|
|
|
|
|
|
|
|
**/
|
|
|
|
EFI_STATUS
|
|
|
|
GetProducerString (
|
|
|
|
IN EFI_GUID *ProducerGuid,
|
|
|
|
IN EFI_STRING_ID Token,
|
|
|
|
OUT CHAR16 **String
|
|
|
|
)
|
|
|
|
{
|
2009-04-14 12:47:19 +02:00
|
|
|
EFI_STRING TmpString;
|
2009-01-23 08:24:55 +01:00
|
|
|
|
2009-04-14 12:47:19 +02:00
|
|
|
TmpString = HiiGetPackageString (ProducerGuid, Token, NULL);
|
|
|
|
if (TmpString == NULL) {
|
2009-01-23 08:24:55 +01:00
|
|
|
*String = GetStringById (STRING_TOKEN (STR_MISSING_STRING));
|
2009-04-14 12:47:19 +02:00
|
|
|
} else {
|
|
|
|
*String = TmpString;
|
2009-01-23 08:24:55 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
return EFI_SUCCESS;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2009-06-19 09:45:13 +02:00
|
|
|
Convert Processor Frequency Data to a string.
|
2009-01-23 08:24:55 +01:00
|
|
|
|
|
|
|
@param ProcessorFrequency The frequency data to process
|
2009-11-20 05:01:15 +01:00
|
|
|
@param Base10Exponent The exponent based on 10
|
2009-01-23 08:24:55 +01:00
|
|
|
@param String The string that is created
|
|
|
|
|
|
|
|
**/
|
|
|
|
VOID
|
|
|
|
ConvertProcessorToString (
|
2009-11-20 05:01:15 +01:00
|
|
|
IN UINT16 ProcessorFrequency,
|
|
|
|
IN UINT16 Base10Exponent,
|
|
|
|
OUT CHAR16 **String
|
2009-01-23 08:24:55 +01:00
|
|
|
)
|
|
|
|
{
|
|
|
|
CHAR16 *StringBuffer;
|
|
|
|
UINTN Index;
|
|
|
|
UINT32 FreqMhz;
|
|
|
|
|
2009-11-20 05:01:15 +01:00
|
|
|
if (Base10Exponent >= 6) {
|
|
|
|
FreqMhz = ProcessorFrequency;
|
|
|
|
for (Index = 0; Index < (UINTN) (Base10Exponent - 6); Index++) {
|
2009-01-23 08:24:55 +01:00
|
|
|
FreqMhz *= 10;
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
FreqMhz = 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
StringBuffer = AllocateZeroPool (0x20);
|
|
|
|
ASSERT (StringBuffer != NULL);
|
|
|
|
Index = UnicodeValueToString (StringBuffer, LEFT_JUSTIFY, FreqMhz / 1000, 3);
|
|
|
|
StrCat (StringBuffer, L".");
|
|
|
|
UnicodeValueToString (StringBuffer + Index + 1, PREFIX_ZERO, (FreqMhz % 1000) / 10, 2);
|
|
|
|
StrCat (StringBuffer, L" GHz");
|
|
|
|
*String = (CHAR16 *) StringBuffer;
|
|
|
|
return ;
|
|
|
|
}
|
|
|
|
|
2009-11-20 05:01:15 +01:00
|
|
|
|
2009-01-23 08:24:55 +01:00
|
|
|
/**
|
|
|
|
Convert Memory Size to a string.
|
|
|
|
|
|
|
|
@param MemorySize The size of the memory to process
|
|
|
|
@param String The string that is created
|
|
|
|
|
|
|
|
**/
|
|
|
|
VOID
|
|
|
|
ConvertMemorySizeToString (
|
|
|
|
IN UINT32 MemorySize,
|
|
|
|
OUT CHAR16 **String
|
|
|
|
)
|
|
|
|
{
|
|
|
|
CHAR16 *StringBuffer;
|
|
|
|
|
|
|
|
StringBuffer = AllocateZeroPool (0x20);
|
|
|
|
ASSERT (StringBuffer != NULL);
|
|
|
|
UnicodeValueToString (StringBuffer, LEFT_JUSTIFY, MemorySize, 6);
|
|
|
|
StrCat (StringBuffer, L" MB RAM");
|
|
|
|
|
|
|
|
*String = (CHAR16 *) StringBuffer;
|
|
|
|
|
|
|
|
return ;
|
|
|
|
}
|
|
|
|
|
2009-11-20 05:01:15 +01:00
|
|
|
/**
|
|
|
|
|
|
|
|
Acquire the string associated with the Index from smbios structure and return it.
|
|
|
|
The caller is responsible for free the string buffer.
|
|
|
|
|
|
|
|
@param OptionalStrStart The start position to search the string
|
|
|
|
@param Index The index of the string to extract
|
|
|
|
@param String The string that is extracted
|
|
|
|
|
|
|
|
@retval EFI_SUCCESS The function returns EFI_SUCCESS always.
|
|
|
|
|
|
|
|
**/
|
|
|
|
EFI_STATUS
|
|
|
|
GetOptionalStringByIndex (
|
|
|
|
IN CHAR8 *OptionalStrStart,
|
|
|
|
IN UINT8 Index,
|
|
|
|
OUT CHAR16 **String
|
|
|
|
)
|
|
|
|
{
|
2010-08-26 05:15:23 +02:00
|
|
|
UINTN StrSize;
|
2009-11-20 05:01:15 +01:00
|
|
|
|
2010-08-26 05:15:23 +02:00
|
|
|
if (Index == 0) {
|
|
|
|
*String = AllocateZeroPool (sizeof (CHAR16));
|
|
|
|
return EFI_SUCCESS;
|
|
|
|
}
|
2009-11-20 05:01:15 +01:00
|
|
|
|
2010-08-26 05:15:23 +02:00
|
|
|
StrSize = 0;
|
|
|
|
do {
|
|
|
|
Index--;
|
|
|
|
OptionalStrStart += StrSize;
|
|
|
|
StrSize = AsciiStrSize (OptionalStrStart);
|
|
|
|
} while (OptionalStrStart[StrSize] != 0 && Index != 0);
|
|
|
|
|
|
|
|
if (Index != 0) {
|
|
|
|
*String = GetStringById (STRING_TOKEN (STR_MISSING_STRING));
|
2009-11-20 05:01:15 +01:00
|
|
|
} else {
|
2010-08-26 05:15:23 +02:00
|
|
|
*String = AllocatePool (StrSize * sizeof (CHAR16));
|
|
|
|
AsciiStrToUnicodeStr (OptionalStrStart, *String);
|
2009-11-20 05:01:15 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
return EFI_SUCCESS;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2009-01-23 08:24:55 +01:00
|
|
|
/**
|
|
|
|
Update the banner information for the Front Page based on DataHub information.
|
|
|
|
|
|
|
|
**/
|
|
|
|
VOID
|
|
|
|
UpdateFrontPageStrings (
|
|
|
|
VOID
|
|
|
|
)
|
|
|
|
{
|
2009-11-20 05:01:15 +01:00
|
|
|
UINT8 StrIndex;
|
2009-01-23 08:24:55 +01:00
|
|
|
CHAR16 *NewString;
|
|
|
|
BOOLEAN Find[5];
|
2009-11-20 05:01:15 +01:00
|
|
|
EFI_STATUS Status;
|
|
|
|
EFI_STRING_ID TokenToUpdate;
|
|
|
|
EFI_SMBIOS_HANDLE SmbiosHandle;
|
|
|
|
EFI_SMBIOS_PROTOCOL *Smbios;
|
|
|
|
SMBIOS_TABLE_TYPE0 *Type0Record;
|
|
|
|
SMBIOS_TABLE_TYPE1 *Type1Record;
|
|
|
|
SMBIOS_TABLE_TYPE4 *Type4Record;
|
|
|
|
SMBIOS_TABLE_TYPE19 *Type19Record;
|
|
|
|
EFI_SMBIOS_TABLE_HEADER *Record;
|
2009-01-23 08:24:55 +01:00
|
|
|
|
|
|
|
ZeroMem (Find, sizeof (Find));
|
|
|
|
|
|
|
|
//
|
|
|
|
// Update Front Page strings
|
|
|
|
//
|
|
|
|
Status = gBS->LocateProtocol (
|
2009-11-20 05:01:15 +01:00
|
|
|
&gEfiSmbiosProtocolGuid,
|
2009-01-23 08:24:55 +01:00
|
|
|
NULL,
|
2009-11-20 05:01:15 +01:00
|
|
|
(VOID **) &Smbios
|
2009-01-23 08:24:55 +01:00
|
|
|
);
|
|
|
|
ASSERT_EFI_ERROR (Status);
|
|
|
|
|
2009-11-20 05:01:15 +01:00
|
|
|
SmbiosHandle = 0;
|
2009-01-23 08:24:55 +01:00
|
|
|
do {
|
2009-11-20 05:01:15 +01:00
|
|
|
Status = Smbios->GetNext (Smbios, &SmbiosHandle, NULL, &Record, NULL);
|
|
|
|
if (EFI_ERROR(Status)) {
|
2009-08-14 04:21:55 +02:00
|
|
|
break;
|
|
|
|
}
|
2009-01-23 08:24:55 +01:00
|
|
|
|
2009-11-20 05:01:15 +01:00
|
|
|
if (Record->Type == EFI_SMBIOS_TYPE_BIOS_INFORMATION) {
|
|
|
|
Type0Record = (SMBIOS_TABLE_TYPE0 *) Record;
|
|
|
|
StrIndex = Type0Record->BiosVersion;
|
2009-12-11 12:52:26 +01:00
|
|
|
GetOptionalStringByIndex ((CHAR8*)((UINT8*)Type0Record + Type0Record->Hdr.Length), StrIndex, &NewString);
|
2009-11-20 05:01:15 +01:00
|
|
|
TokenToUpdate = STRING_TOKEN (STR_FRONT_PAGE_BIOS_VERSION);
|
|
|
|
HiiSetString (gFrontPagePrivate.HiiHandle, TokenToUpdate, NewString, NULL);
|
|
|
|
FreePool (NewString);
|
|
|
|
Find[0] = TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (Record->Type == EFI_SMBIOS_TYPE_SYSTEM_INFORMATION) {
|
|
|
|
Type1Record = (SMBIOS_TABLE_TYPE1 *) Record;
|
|
|
|
StrIndex = Type1Record->ProductName;
|
2009-12-11 12:52:26 +01:00
|
|
|
GetOptionalStringByIndex ((CHAR8*)((UINT8*)Type1Record + Type1Record->Hdr.Length), StrIndex, &NewString);
|
2009-11-20 05:01:15 +01:00
|
|
|
TokenToUpdate = STRING_TOKEN (STR_FRONT_PAGE_COMPUTER_MODEL);
|
|
|
|
HiiSetString (gFrontPagePrivate.HiiHandle, TokenToUpdate, NewString, NULL);
|
|
|
|
FreePool (NewString);
|
|
|
|
Find[1] = TRUE;
|
2009-01-23 08:24:55 +01:00
|
|
|
}
|
2009-11-20 05:01:15 +01:00
|
|
|
|
|
|
|
if (Record->Type == EFI_SMBIOS_TYPE_PROCESSOR_INFORMATION) {
|
|
|
|
Type4Record = (SMBIOS_TABLE_TYPE4 *) Record;
|
|
|
|
StrIndex = Type4Record->ProcessorVersion;
|
2009-12-11 12:52:26 +01:00
|
|
|
GetOptionalStringByIndex ((CHAR8*)((UINT8*)Type4Record + Type4Record->Hdr.Length), StrIndex, &NewString);
|
2009-11-20 05:01:15 +01:00
|
|
|
TokenToUpdate = STRING_TOKEN (STR_FRONT_PAGE_CPU_MODEL);
|
|
|
|
HiiSetString (gFrontPagePrivate.HiiHandle, TokenToUpdate, NewString, NULL);
|
|
|
|
FreePool (NewString);
|
|
|
|
Find[2] = TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (Record->Type == EFI_SMBIOS_TYPE_PROCESSOR_INFORMATION) {
|
|
|
|
Type4Record = (SMBIOS_TABLE_TYPE4 *) Record;
|
|
|
|
ConvertProcessorToString(Type4Record->CurrentSpeed, 6, &NewString);
|
|
|
|
TokenToUpdate = STRING_TOKEN (STR_FRONT_PAGE_CPU_SPEED);
|
|
|
|
HiiSetString (gFrontPagePrivate.HiiHandle, TokenToUpdate, NewString, NULL);
|
|
|
|
FreePool (NewString);
|
|
|
|
Find[3] = TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
if ( Record->Type == EFI_SMBIOS_TYPE_MEMORY_ARRAY_MAPPED_ADDRESS ) {
|
|
|
|
Type19Record = (SMBIOS_TABLE_TYPE19 *) Record;
|
|
|
|
ConvertMemorySizeToString (
|
|
|
|
(UINT32)(RShiftU64((Type19Record->EndingAddress - Type19Record->StartingAddress + 1), 10)),
|
|
|
|
&NewString
|
|
|
|
);
|
|
|
|
TokenToUpdate = STRING_TOKEN (STR_FRONT_PAGE_MEMORY_SIZE);
|
|
|
|
HiiSetString (gFrontPagePrivate.HiiHandle, TokenToUpdate, NewString, NULL);
|
|
|
|
FreePool (NewString);
|
|
|
|
Find[4] = TRUE;
|
|
|
|
}
|
|
|
|
} while ( !(Find[0] && Find[1] && Find[2] && Find[3] && Find[4]));
|
2009-01-23 08:24:55 +01:00
|
|
|
return ;
|
|
|
|
}
|
|
|
|
|
2009-11-20 05:01:15 +01:00
|
|
|
|
2009-01-23 08:24:55 +01:00
|
|
|
/**
|
|
|
|
Function waits for a given event to fire, or for an optional timeout to expire.
|
|
|
|
|
2009-11-20 05:01:15 +01:00
|
|
|
@param Event The event to wait for
|
|
|
|
@param Timeout An optional timeout value in 100 ns units.
|
2009-01-23 08:24:55 +01:00
|
|
|
|
|
|
|
@retval EFI_SUCCESS Event fired before Timeout expired.
|
|
|
|
@retval EFI_TIME_OUT Timout expired before Event fired..
|
|
|
|
|
|
|
|
**/
|
|
|
|
EFI_STATUS
|
|
|
|
WaitForSingleEvent (
|
|
|
|
IN EFI_EVENT Event,
|
|
|
|
IN UINT64 Timeout OPTIONAL
|
|
|
|
)
|
|
|
|
{
|
|
|
|
UINTN Index;
|
2009-11-20 05:01:15 +01:00
|
|
|
EFI_STATUS Status;
|
2009-01-23 08:24:55 +01:00
|
|
|
EFI_EVENT TimerEvent;
|
|
|
|
EFI_EVENT WaitList[2];
|
|
|
|
|
|
|
|
if (Timeout != 0) {
|
|
|
|
//
|
|
|
|
// Create a timer event
|
|
|
|
//
|
|
|
|
Status = gBS->CreateEvent (EVT_TIMER, 0, NULL, NULL, &TimerEvent);
|
|
|
|
if (!EFI_ERROR (Status)) {
|
|
|
|
//
|
|
|
|
// Set the timer event
|
|
|
|
//
|
|
|
|
gBS->SetTimer (
|
2009-11-20 05:01:15 +01:00
|
|
|
TimerEvent,
|
|
|
|
TimerRelative,
|
|
|
|
Timeout
|
|
|
|
);
|
2009-01-23 08:24:55 +01:00
|
|
|
|
|
|
|
//
|
|
|
|
// Wait for the original event or the timer
|
|
|
|
//
|
|
|
|
WaitList[0] = Event;
|
|
|
|
WaitList[1] = TimerEvent;
|
|
|
|
Status = gBS->WaitForEvent (2, WaitList, &Index);
|
|
|
|
gBS->CloseEvent (TimerEvent);
|
|
|
|
|
|
|
|
//
|
|
|
|
// If the timer expired, change the return to timed out
|
|
|
|
//
|
|
|
|
if (!EFI_ERROR (Status) && Index == 1) {
|
|
|
|
Status = EFI_TIMEOUT;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
//
|
|
|
|
// No timeout... just wait on the event
|
|
|
|
//
|
|
|
|
Status = gBS->WaitForEvent (1, &Event, &Index);
|
|
|
|
ASSERT (!EFI_ERROR (Status));
|
|
|
|
ASSERT (Index == 0);
|
|
|
|
}
|
|
|
|
|
|
|
|
return Status;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
Function show progress bar to wait for user input.
|
|
|
|
|
|
|
|
|
2009-11-20 05:01:15 +01:00
|
|
|
@param TimeoutDefault The fault time out value before the system continue to boot.
|
2009-01-23 08:24:55 +01:00
|
|
|
|
|
|
|
@retval EFI_SUCCESS User pressed some key except "Enter"
|
2009-12-04 04:35:56 +01:00
|
|
|
@retval EFI_TIME_OUT Timeout expired or user press "Enter"
|
2009-01-23 08:24:55 +01:00
|
|
|
|
|
|
|
**/
|
|
|
|
EFI_STATUS
|
|
|
|
ShowProgress (
|
|
|
|
IN UINT16 TimeoutDefault
|
|
|
|
)
|
|
|
|
{
|
|
|
|
CHAR16 *TmpStr;
|
2009-11-20 05:01:15 +01:00
|
|
|
UINT16 TimeoutRemain;
|
|
|
|
EFI_STATUS Status;
|
|
|
|
EFI_INPUT_KEY Key;
|
2009-01-23 08:24:55 +01:00
|
|
|
EFI_GRAPHICS_OUTPUT_BLT_PIXEL Foreground;
|
|
|
|
EFI_GRAPHICS_OUTPUT_BLT_PIXEL Background;
|
|
|
|
EFI_GRAPHICS_OUTPUT_BLT_PIXEL Color;
|
|
|
|
|
|
|
|
if (TimeoutDefault == 0) {
|
|
|
|
return EFI_TIMEOUT;
|
|
|
|
}
|
|
|
|
|
|
|
|
DEBUG ((EFI_D_INFO, "\n\nStart showing progress bar... Press any key to stop it! ...Zzz....\n"));
|
2009-07-16 00:28:07 +02:00
|
|
|
|
2009-01-23 08:24:55 +01:00
|
|
|
SetMem (&Foreground, sizeof (EFI_GRAPHICS_OUTPUT_BLT_PIXEL), 0xff);
|
|
|
|
SetMem (&Background, sizeof (EFI_GRAPHICS_OUTPUT_BLT_PIXEL), 0x0);
|
|
|
|
SetMem (&Color, sizeof (EFI_GRAPHICS_OUTPUT_BLT_PIXEL), 0xff);
|
|
|
|
|
|
|
|
//
|
|
|
|
// Clear the progress status bar first
|
|
|
|
//
|
|
|
|
TmpStr = GetStringById (STRING_TOKEN (STR_START_BOOT_OPTION));
|
|
|
|
if (TmpStr != NULL) {
|
|
|
|
PlatformBdsShowProgress (Foreground, Background, TmpStr, Color, 0, 0);
|
|
|
|
}
|
|
|
|
|
|
|
|
TimeoutRemain = TimeoutDefault;
|
|
|
|
while (TimeoutRemain != 0) {
|
|
|
|
DEBUG ((EFI_D_INFO, "Showing progress bar...Remaining %d second!\n", TimeoutRemain));
|
2009-07-16 00:28:07 +02:00
|
|
|
|
2009-01-23 08:24:55 +01:00
|
|
|
Status = WaitForSingleEvent (gST->ConIn->WaitForKey, ONE_SECOND);
|
|
|
|
if (Status != EFI_TIMEOUT) {
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
TimeoutRemain--;
|
|
|
|
|
|
|
|
//
|
|
|
|
// Show progress
|
|
|
|
//
|
|
|
|
if (TmpStr != NULL) {
|
|
|
|
PlatformBdsShowProgress (
|
|
|
|
Foreground,
|
|
|
|
Background,
|
|
|
|
TmpStr,
|
|
|
|
Color,
|
|
|
|
((TimeoutDefault - TimeoutRemain) * 100 / TimeoutDefault),
|
|
|
|
0
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
gBS->FreePool (TmpStr);
|
|
|
|
|
|
|
|
//
|
|
|
|
// Timeout expired
|
|
|
|
//
|
|
|
|
if (TimeoutRemain == 0) {
|
|
|
|
return EFI_TIMEOUT;
|
|
|
|
}
|
|
|
|
|
|
|
|
//
|
|
|
|
// User pressed some key
|
|
|
|
//
|
|
|
|
Status = gST->ConIn->ReadKeyStroke (gST->ConIn, &Key);
|
|
|
|
if (EFI_ERROR (Status)) {
|
|
|
|
return Status;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (Key.UnicodeChar == CHAR_CARRIAGE_RETURN) {
|
|
|
|
//
|
|
|
|
// User pressed enter, equivalent to select "continue"
|
|
|
|
//
|
|
|
|
return EFI_TIMEOUT;
|
|
|
|
}
|
|
|
|
|
|
|
|
return EFI_SUCCESS;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
This function is the main entry of the platform setup entry.
|
|
|
|
The function will present the main menu of the system setup,
|
|
|
|
this is the platform reference part and can be customize.
|
|
|
|
|
|
|
|
|
|
|
|
@param TimeoutDefault The fault time out value before the system
|
|
|
|
continue to boot.
|
|
|
|
@param ConnectAllHappened The indicater to check if the connect all have
|
2009-12-04 04:35:56 +01:00
|
|
|
already happened.
|
2009-01-23 08:24:55 +01:00
|
|
|
|
|
|
|
**/
|
|
|
|
VOID
|
|
|
|
PlatformBdsEnterFrontPage (
|
|
|
|
IN UINT16 TimeoutDefault,
|
|
|
|
IN BOOLEAN ConnectAllHappened
|
|
|
|
)
|
|
|
|
{
|
|
|
|
EFI_STATUS Status;
|
|
|
|
|
2009-07-16 00:28:07 +02:00
|
|
|
PERF_START (NULL, "BdsTimeOut", "BDS", 0);
|
2009-01-23 08:24:55 +01:00
|
|
|
//
|
|
|
|
// Indicate if we need connect all in the platform setup
|
|
|
|
//
|
|
|
|
if (ConnectAllHappened) {
|
|
|
|
gConnectAllHappened = TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (TimeoutDefault != 0xffff) {
|
|
|
|
Status = ShowProgress (TimeoutDefault);
|
|
|
|
|
|
|
|
//
|
|
|
|
// Ensure screen is clear when switch Console from Graphics mode to Text mode
|
|
|
|
//
|
|
|
|
gST->ConOut->EnableCursor (gST->ConOut, TRUE);
|
|
|
|
gST->ConOut->ClearScreen (gST->ConOut);
|
|
|
|
|
|
|
|
if (EFI_ERROR (Status)) {
|
|
|
|
//
|
|
|
|
// Timeout or user press enter to continue
|
|
|
|
//
|
|
|
|
goto Exit;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
do {
|
|
|
|
|
|
|
|
InitializeFrontPage (FALSE);
|
|
|
|
|
|
|
|
//
|
|
|
|
// Update Front Page strings
|
|
|
|
//
|
|
|
|
UpdateFrontPageStrings ();
|
|
|
|
|
|
|
|
gCallbackKey = 0;
|
|
|
|
Status = CallFrontPage ();
|
|
|
|
|
|
|
|
//
|
|
|
|
// If gCallbackKey is greater than 1 and less or equal to 5,
|
2009-12-04 04:35:56 +01:00
|
|
|
// it will launch configuration utilities.
|
2009-01-23 08:24:55 +01:00
|
|
|
// 2 = set language
|
|
|
|
// 3 = boot manager
|
|
|
|
// 4 = device manager
|
2009-12-04 04:35:56 +01:00
|
|
|
// 5 = boot maintenance manager
|
2009-01-23 08:24:55 +01:00
|
|
|
//
|
|
|
|
if (gCallbackKey != 0) {
|
|
|
|
REPORT_STATUS_CODE (
|
|
|
|
EFI_PROGRESS_CODE,
|
|
|
|
(EFI_SOFTWARE_DXE_BS_DRIVER | EFI_SW_PC_USER_SETUP)
|
|
|
|
);
|
|
|
|
}
|
|
|
|
//
|
|
|
|
// Based on the key that was set, we can determine what to do
|
|
|
|
//
|
|
|
|
switch (gCallbackKey) {
|
|
|
|
//
|
|
|
|
// The first 4 entries in the Front Page are to be GUARANTEED to remain constant so IHV's can
|
|
|
|
// describe to their customers in documentation how to find their setup information (namely
|
|
|
|
// under the device manager and specific buckets)
|
|
|
|
//
|
|
|
|
// These entries consist of the Continue, Select language, Boot Manager, and Device Manager
|
|
|
|
//
|
|
|
|
case FRONT_PAGE_KEY_CONTINUE:
|
|
|
|
//
|
|
|
|
// User hit continue
|
|
|
|
//
|
|
|
|
break;
|
|
|
|
|
|
|
|
case FRONT_PAGE_KEY_LANGUAGE:
|
|
|
|
//
|
|
|
|
// User made a language setting change - display front page again
|
|
|
|
//
|
|
|
|
break;
|
|
|
|
|
|
|
|
case FRONT_PAGE_KEY_BOOT_MANAGER:
|
|
|
|
//
|
|
|
|
// User chose to run the Boot Manager
|
|
|
|
//
|
2009-12-07 06:55:07 +01:00
|
|
|
CallBootManager ();
|
2009-01-23 08:24:55 +01:00
|
|
|
break;
|
|
|
|
|
|
|
|
case FRONT_PAGE_KEY_DEVICE_MANAGER:
|
|
|
|
//
|
|
|
|
// Display the Device Manager
|
|
|
|
//
|
|
|
|
do {
|
2009-12-07 06:55:07 +01:00
|
|
|
CallDeviceManager ();
|
2009-01-23 08:24:55 +01:00
|
|
|
} while (gCallbackKey == FRONT_PAGE_KEY_DEVICE_MANAGER);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case FRONT_PAGE_KEY_BOOT_MAINTAIN:
|
|
|
|
//
|
|
|
|
// Display the Boot Maintenance Manager
|
|
|
|
//
|
|
|
|
BdsStartBootMaint ();
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
} while ((Status == EFI_SUCCESS) && (gCallbackKey != FRONT_PAGE_KEY_CONTINUE));
|
|
|
|
|
|
|
|
//
|
|
|
|
//Will leave browser, check any reset required change is applied? if yes, reset system
|
|
|
|
//
|
|
|
|
SetupResetReminder ();
|
|
|
|
|
|
|
|
Exit:
|
|
|
|
//
|
|
|
|
// Automatically load current entry
|
|
|
|
// Note: The following lines of code only execute when Auto boot
|
|
|
|
// takes affect
|
|
|
|
//
|
2009-07-16 00:28:07 +02:00
|
|
|
PERF_END (NULL, "BdsTimeOut", "BDS", 0);
|
2009-01-23 08:24:55 +01:00
|
|
|
}
|