/** @file
Entry and initialization module for the browser.
Copyright (c) 2007 - 2012, Intel Corporation. All rights reserved.<BR>
This program and the accompanying materials
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
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 "Setup.h"
NULL,
{
},
{
}
};
//
// Browser Global Strings
//
0xab368524, 0xb60c, 0x495b, {0xa0, 0x9, 0x12, 0xe8, 0x5b, 0x1a, 0xea, 0x32}
};
//
// Boot Manager
//
{
{
0x847bc3fe,
0xb974,
0x446d,
{
0x94,
0x49,
0x5a,
0xd5,
0x41,
0x2e,
0x99,
0x3b
}
},
},
//
// Device Manager
//
{
{
0x3ebfa8e6,
0x511d,
0x4b5b,
{
0xa9,
0x5f,
0xfb,
0x38,
0x26,
0xf,
0x1c,
0x27
}
},
},
//
// BMM FormSet.
//
{
{
0x642237c7,
0x35d4,
0x472d,
{
0x83,
0x65,
0x12,
0xe0,
0xcc,
0xf2,
0x7a,
0x22
}
},
},
//
// BMM File Explorer FormSet.
//
{
{
0x1f2d63e1,
0xfebd,
0x4dc7,
{
0x9c,
0xc5,
0xba,
0x2b,
0x1c,
0xef,
0x9c,
0x5b
}
},
},
};
/**
This is the routine which an external caller uses to direct the browser
where to obtain it's information.
@param This The Form Browser protocol instanse.
@param Handles A pointer to an array of Handles. If HandleCount > 1 we
display a list of the formsets for the handles specified.
@param HandleCount The number of Handles specified in Handle.
@param FormSetGuid This field points to the EFI_GUID which must match the Guid
field in the EFI_IFR_FORM_SET op-code for the specified
forms-based package. If FormSetGuid is NULL, then this
function will display the first found forms package.
@param FormId This field specifies which EFI_IFR_FORM to render as the first
displayable page. If this field has a value of 0x0000, then
the forms browser will render the specified forms in their encoded order.
@param ScreenDimensions Points to recommended form dimensions, including any non-content area, in
characters.
@param ActionRequest Points to the action recommended by the form.
@retval EFI_SUCCESS The function completed successfully.
@retval EFI_INVALID_PARAMETER One of the parameters has an invalid value.
@retval EFI_NOT_FOUND No valid forms could be found to display.
**/
SendForm (
)
{
//
// Calculate total number of Register HotKeys.
//
Index = 0;
Index ++;
}
//
// Show three HotKeys help information on one ROW.
//
//
// Save globals used by SendForm()
//
//
// Seed the dimensions in the global
//
);
if (ScreenDimensions != NULL) {
//
// Check local dimension vs. global dimension.
//
) {
goto Done;
} else {
//
// Local dimension validation.
//
(
2 +
1
)
) {
} else {
goto Done;
}
}
}
//
// Initialize the strings for the browser, upon exit of the browser, the strings will be freed
//
//
// Ensure we are in Text mode
//
if (FormSetGuid != NULL) {
} else {
}
do {
//
// Initialize internal data structures of FormSet
//
break;
}
//
// Try to find pre FormSet in the maintain backup list.
//
//
// Display this formset
//
break;
}
if (gOldFormSet != NULL) {
//
// If no data is changed, don't need to save current FormSet into the maintain list.
//
if (!IsNvUpdateRequired (gOldFormSet)) {
}
gOldFormSet = NULL;
}
}
if (ActionRequest != NULL) {
if (gResetRequired) {
}
}
Done:
//
// Restore globals used by SendForm()
//
return Status;
}
/**
This function is called by a callback handler to retrieve uncommitted state
data from the browser.
@param This A pointer to the EFI_FORM_BROWSER2_PROTOCOL
instance.
@param ResultsDataSize A pointer to the size of the buffer associated
with ResultsData.
@param ResultsData A string returned from an IFR browser or
equivalent. The results string will have no
routing information in them.
@param RetrieveData A BOOLEAN field which allows an agent to retrieve
(if RetrieveData = TRUE) data from the uncommitted
browser state information or set (if RetrieveData
= FALSE) data in the uncommitted browser state
information.
@param VariableGuid An optional field to indicate the target variable
GUID name to use.
@param VariableName An optional field to indicate the target
human-readable variable name.
@retval EFI_SUCCESS The results have been distributed or are awaiting
distribution.
@retval EFI_BUFFER_TOO_SMALL The ResultsDataSize specified was too small to
contain the results data.
**/
)
{
return EFI_INVALID_PARAMETER;
}
if (gCurrentSelection == NULL) {
return EFI_NOT_READY;
}
ConfigResp = NULL;
//
// Find target storage
//
return EFI_UNSUPPORTED;
}
if (VariableGuid != NULL) {
//
// Try to find target storage
//
//
// Buffer storage require both GUID and Name
//
if (VariableName == NULL) {
return EFI_NOT_FOUND;
}
continue;
}
}
break;
}
}
if (!Found) {
return EFI_NOT_FOUND;
}
} else {
//
//
}
if (RetrieveData) {
//
// Skip if there is no RequestElement
//
if (Storage->ElementCount == 0) {
return EFI_SUCCESS;
}
//
// Generate <ConfigResp>
//
return Status;
}
//
// Skip <ConfigHdr> and '&' to point to <ConfigBody>
//
if (*ResultsDataSize < BufferSize) {
return EFI_BUFFER_TOO_SMALL;
}
} else {
//
// Prepare <ConfigResp>
//
//
// Update Browser uncommited data
//
return Status;
}
}
return EFI_SUCCESS;
}
/**
Notify function will remove the formset in the maintain list
once this formset is removed.
Functions which are registered to receive notification of
database events have this prototype. The actual event is encoded
in NotifyType. The following table describes how PackageType,
PackageGuid, Handle, and Package are used for each of the
notification types.
@param PackageType Package type of the notification.
@param PackageGuid If PackageType is
EFI_HII_PACKAGE_TYPE_GUID, then this is
the pointer to the GUID from the Guid
field of EFI_HII_PACKAGE_GUID_HEADER.
Otherwise, it must be NULL.
@param Package Points to the package referred to by the
notification Handle The handle of the package
list which contains the specified package.
@param Handle The HII handle.
@param NotifyType The type of change concerning the
database. See
EFI_HII_DATABASE_NOTIFY_TYPE.
**/
)
{
//
// Ignore the update for current using formset, which is handled by another notify function.
//
if (IsHiiHandleInBrowserContext (Handle)) {
return EFI_SUCCESS;
}
//
// Remove the backup FormSet data when the Form Package is removed.
//
}
return EFI_SUCCESS;
}
/**
Initialize Setup Browser driver.
@param ImageHandle The image handle.
@param SystemTable The system table.
@retval EFI_SUCCESS The Setup Browser module is initialized correctly..
@return Other value if failed to initialize the Setup Browser module.
**/
)
{
//
// Locate required Hii relative protocols
//
NULL,
(VOID **) &mHiiDatabase
);
NULL,
(VOID **) &mHiiString
);
NULL,
(VOID **) &mHiiConfigRouting
);
//
// Publish our HII data
//
);
//
// Initialize Driver private data
//
//
// Initialize generic help strings.
//
//
// Install FormBrowser2 protocol
//
);
//
// Install default HotKey F10 for Save
//
//
// Install default HotKey F9 for Reset To Defaults
//
RegisterHotKey (&DefaultHotKey, BROWSER_ACTION_DEFAULT, EFI_HII_DEFAULT_CLASS_STANDARD, HelpString);
//
// Install FormBrowserEx protocol
//
);
//
// Register notify for Form package remove
//
NULL,
);
return Status;
}
/**
Create a new string in HII Package List.
@param String The String to be added
@param HiiHandle The package list in the HII database to insert the
specified string.
@return The output string.
**/
)
{
return StringId;
}
/**
Delete a string from HII Package List.
@param StringId Id of the string in HII database.
@param HiiHandle The HII package list handle.
@retval EFI_SUCCESS The string was deleted successfully.
**/
)
{
return EFI_SUCCESS;
}
/**
Get the string based on the StringId and HII Package List Handle.
@param Token The String's ID.
@param HiiHandle The package list in the HII database to search for
the specified string.
@return The output string.
**/
CHAR16 *
GetToken (
)
{
return NULL;
}
}
}
/**
Allocate new memory and then copy the Unicode string Source to Destination.
@param Dest Location to copy string
@param Src String to copy
**/
)
{
}
}
/**
Allocate new memory and concatinate Source on the end of Destination.
@param Dest String to added to the end of.
@param Src String to concatinate.
**/
)
{
return;
}
}
/**
Synchronize or restore Storage's Edit copy and Shadow copy.
@param Storage The Storage to be synchronized.
@param SyncOrRestore Sync the buffer to editbuffer or Restore the
editbuffer to buffer
if TRUE, copy the editbuffer to the buffer.
if FALSE, copy the buffer to the editbuffer.
**/
)
{
case EFI_HII_VARSTORE_BUFFER:
if (SyncOrRestore) {
} else {
}
break;
if (SyncOrRestore) {
} else {
}
}
break;
default:
break;
}
}
/**
Get Value for given Name from a NameValue Storage.
@param Storage The NameValue Storage.
@param Name The Name.
@param Value The retured Value.
@retval EFI_SUCCESS Value found for given Name.
@retval EFI_NOT_FOUND No such Name found in NameValue storage.
**/
)
{
return EFI_SUCCESS;
}
}
return EFI_NOT_FOUND;
}
/**
Set Value of given Name in a NameValue Storage.
@param Storage The NameValue Storage.
@param Name The Name.
@param Value The Value to set.
@param Edit Whether update editValue or Value.
@retval EFI_SUCCESS Value found for given Name.
@retval EFI_NOT_FOUND No such Name found in NameValue storage.
**/
)
{
if (Edit) {
} else {
}
}
if (Edit) {
} else {
}
return EFI_SUCCESS;
}
}
return EFI_NOT_FOUND;
}
/**
Convert setting of Buffer Storage or NameValue Storage to <ConfigResp>.
@param Buffer The Storage to be conveted.
@param ConfigResp The returned <ConfigResp>.
@param SingleForm Whether update data for single form or formset level.
@retval EFI_SUCCESS Convert success.
@retval EFI_INVALID_PARAMETER Incorrect storage type.
**/
)
{
if (SingleForm) {
} else {
}
case EFI_HII_VARSTORE_BUFFER:
);
break;
*ConfigResp = NULL;
}
}
break;
default:
break;
}
return Status;
}
/**
Convert <ConfigResp> to settings in Buffer Storage or NameValue Storage.
@param Storage The Storage to receive the settings.
@param ConfigResp The <ConfigResp> to be converted.
@retval EFI_SUCCESS Convert success.
@retval EFI_INVALID_PARAMETER Incorrect storage type.
**/
)
{
case EFI_HII_VARSTORE_BUFFER:
);
break;
break;
}
//
// Skip '&'
//
break;
}
*StrPtr = 0;
//
// Skip '='
//
*StrPtr = 0;
}
}
break;
default:
break;
}
return Status;
}
/**
Get Question's current Value.
@param FormSet FormSet data structure.
@param Form Form data structure.
@param Question Question to be initialized.
@param Cached TRUE: get from Edit copy FALSE: get from original
Storage
@retval EFI_SUCCESS The function completed successfully.
**/
)
{
//
// Statement don't have storage, skip them
//
if (Question->QuestionId == 0) {
return Status;
}
//
// Question value is provided by an Expression, evaluate it
//
CopyMem (Question->HiiValue.Buffer, Question->ValueExpression->Result.Buffer, Question->ValueExpression->Result.BufferLen);
} else {
CopyMem (Question->HiiValue.Buffer, Question->ValueExpression->Result.Buffer, Question->StorageWidth);
}
}
CopyMem (&Question->HiiValue.Value, &Question->ValueExpression->Result.Value, sizeof (EFI_IFR_TYPE_VALUE));
}
return Status;
}
//
// Get question value by read expression.
//
((Question->ReadExpression->Result.Type < EFI_IFR_TYPE_OTHER) || (Question->ReadExpression->Result.Type == EFI_IFR_TYPE_BUFFER))) {
//
// Only update question value to the valid result.
//
CopyMem (Question->HiiValue.Buffer, Question->ReadExpression->Result.Buffer, Question->ReadExpression->Result.BufferLen);
} else {
CopyMem (Question->HiiValue.Buffer, Question->ReadExpression->Result.Buffer, Question->StorageWidth);
}
}
CopyMem (&Question->HiiValue.Value, &Question->ReadExpression->Result.Value, sizeof (EFI_IFR_TYPE_VALUE));
return EFI_SUCCESS;
}
}
//
// Question value is provided by RTC
//
//
//
//
// Date and time define the same Flags bit
//
case QF_DATE_STORAGE_TIME:
break;
case QF_DATE_STORAGE_WAKEUP:
break;
case QF_DATE_STORAGE_NORMAL:
default:
//
//
return EFI_SUCCESS;
}
return Status;
}
} else {
}
}
return EFI_SUCCESS;
}
//
// Question value is provided by EFI variable
//
} else {
}
NULL,
);
//
// Always return success, even this EFI variable doesn't exist
//
return EFI_SUCCESS;
}
//
// Question Value is provided by Buffer Storage or NameValue Storage
//
//
// This Question is password or orderedlist
//
} else {
//
// Other type of Questions
//
}
} else {
}
if (Cached) {
if (IsBufferStorage) {
//
// Copy from storage Edit buffer
//
} else {
return Status;
}
if (IsString) {
//
// Convert Config String to Unicode String, e.g "0041004200430044" => "ABCD"
// Add string tail char L'\0' into Length
//
} else {
}
//
// Add tailing L'\0' character
//
}
} else {
} else {
if ((Index & 1) == 0) {
} else {
}
}
}
}
}
} else {
//
// Request current settings from Configuration Driver
//
return EFI_NOT_FOUND;
}
//
// <ConfigRequest> ::= <ConfigHdr> + <BlockName> ||
// <ConfigHdr> + "&" + <VariableName>
//
if (IsBufferStorage) {
} else {
}
if (IsBufferStorage) {
} else {
}
&Progress,
);
return Status;
}
//
// Skip <ConfigRequest>
//
if (IsBufferStorage) {
return EFI_NOT_FOUND;
}
//
// Skip "&VALUE"
//
} else {
}
if (*Value != '=') {
return EFI_NOT_FOUND;
}
//
// Skip '=', point to value
//
//
// Suppress <AltResp> if any
//
StringPtr++;
}
*StringPtr = L'\0';
if (!IsBufferStorage && IsString) {
//
// Convert Config String to Unicode String, e.g "0041004200430044" => "ABCD"
// Add string tail char L'\0' into Length
//
} else {
}
//
// Add tailing L'\0' character
//
}
} else {
} else {
if ((Index & 1) == 0) {
} else {
}
}
}
}
return Status;
}
return Status;
}
NULL,
&Length,
);
return Status;
}
}
//
// Synchronize Edit Buffer
//
if (IsBufferStorage) {
} else {
}
}
}
return Status;
}
/**
Save Question Value to edit copy(cached) or Storage(uncached).
@param FormSet FormSet data structure.
@param Form Form data structure.
@param Question Pointer to the Question.
@param Cached TRUE: set to Edit copy FALSE: set to original
Storage
@retval EFI_SUCCESS The function completed successfully.
**/
)
{
//
// Statement don't have storage, skip them
//
if (Question->QuestionId == 0) {
return Status;
}
//
// If Question value is provided by an Expression, then it is read only
//
return Status;
}
//
// Before set question value, evaluate its write expression.
//
return Status;
}
}
//
// Question value is provided by RTC
//
//
//
//
// Date and time define the same Flags bit
//
case QF_DATE_STORAGE_TIME:
break;
case QF_DATE_STORAGE_WAKEUP:
break;
case QF_DATE_STORAGE_NORMAL:
default:
//
//
return EFI_SUCCESS;
}
return Status;
}
} else {
}
} else {
}
}
return Status;
}
//
// Question value is provided by EFI variable
//
} else {
}
);
return Status;
}
//
// Question Value is provided by Buffer Storage or NameValue Storage
//
} else {
}
} else {
}
if (IsBufferStorage) {
//
// Copy to storage edit buffer
//
} else {
if (IsString) {
//
// Allocate enough string buffer.
//
//
// Convert Unicode String to Config String, e.g. "ABCD" => "0041004200430044"
//
}
} else {
//
// Convert Buffer to Hex String
//
}
}
}
if (!Cached) {
//
// <ConfigResp> ::= <ConfigHdr> + <BlockName> + "&VALUE=" + "<HexCh>StorageWidth * 2" ||
// <ConfigHdr> + "&" + <VariableName> + "=" + "<string>"
//
if (IsBufferStorage) {
} else {
}
if (!IsBufferStorage && IsString) {
} else {
}
if (IsBufferStorage) {
} else {
}
if (!IsBufferStorage && IsString) {
//
// Convert Unicode String to Config String, e.g. "ABCD" => "0041004200430044"
//
}
} else {
//
// Convert Buffer to Hex String
//
}
}
//
// Convert to lower char.
//
}
}
//
// Submit Question Value to Configuration Driver
//
);
return Status;
}
}
return Status;
}
NULL,
&Length,
);
);
return Status;
}
}
//
// Sync storage, from editbuffer to buffer.
//
}
return Status;
}
/**
Perform inconsistent check for a Form.
@param FormSet FormSet data structure.
@param Form Form data structure.
@param Question The Question to be validated.
@param Type Validation type: InConsistent or NoSubmit
@retval EFI_SUCCESS Form validation pass.
@retval other Form validation failed.
**/
)
{
if (Type == EFI_HII_EXPRESSION_INCONSISTENT_IF) {
} else if (Type == EFI_HII_EXPRESSION_NO_SUBMIT_IF) {
} else {
return EFI_UNSUPPORTED;
}
//
// Evaluate the expression
//
return Status;
}
//
// Condition meet, show up error message
//
if (Expression->Error != 0) {
do {
}
return EFI_NOT_READY;
}
}
return EFI_SUCCESS;
}
/**
Perform NoSubmit check for each Form in FormSet.
@param FormSet FormSet data structure.
@param CurrentForm Current input form data structure.
@retval EFI_SUCCESS Form validation pass.
@retval other Form validation failed.
**/
)
{
continue;
}
return Status;
}
}
}
return EFI_SUCCESS;
}
/**
Fill storage's edit copy with settings requested from Configuration Driver.
@param FormSet FormSet data structure.
@param ConfigInfo The config info related to this form.
@param SyncOrRestore Sync the buffer to editbuffer or Restore the
editbuffer to buffer
if TRUE, copy the editbuffer to the buffer.
if FALSE, copy the buffer to the editbuffer.
@retval EFI_SUCCESS The function completed successfully.
**/
)
{
return EFI_NOT_FOUND;
}
if (ConfigInfo->ElementCount == 0) {
//
// Skip if there is no RequestElement
//
return EFI_SUCCESS;
}
if (SyncOrRestore) {
} else {
}
Src,
&Result,
);
return Status;
}
Dst,
);
}
if (SyncOrRestore) {
} else {
}
}
}
}
return Status;
}
/**
Discard data based on the input setting scope (Form, FormSet or System).
@param FormSet FormSet data structure.
@param Form Form data structure.
@param SettingScope Setting Scope for Discard action.
@retval EFI_SUCCESS The function completed successfully.
@retval EFI_UNSUPPORTED Unsupport SettingScope.
**/
)
{
//
// Check the supported setting level.
//
if (SettingScope >= MaxLevel) {
return EFI_UNSUPPORTED;
}
ConfigInfo = NULL;
continue;
}
//
// Skip if there is no RequestElement
//
if (ConfigInfo->ElementCount == 0) {
continue;
}
//
// Prepare <ConfigResp>
//
}
//
//
continue;
}
//
// Skip if there is no RequestElement
//
if (Storage->ElementCount == 0) {
continue;
}
}
} else if (SettingScope == SystemLevel) {
//
// System Level Discard.
//
//
// Discard changed value for each FormSet in the maintain list.
//
//
// Remove maintain backup list after discard except for the current using FormSet.
//
}
}
}
return EFI_SUCCESS;
}
/**
Submit data based on the input Setting level (Form, FormSet or System).
@param FormSet FormSet data structure.
@param Form Form data structure.
@param SettingScope Setting Scope for Submit action.
@retval EFI_SUCCESS The function completed successfully.
@retval EFI_UNSUPPORTED Unsupport SettingScope.
**/
)
{
//
// Check the supported setting level.
//
if (SettingScope >= MaxLevel) {
return EFI_UNSUPPORTED;
}
//
// Validate the Form by NoSubmit check
//
if (SettingScope == FormLevel) {
} else if (SettingScope == FormSetLevel) {
}
return Status;
}
ConfigInfo = NULL;
continue;
}
//
// Skip if there is no RequestElement
//
if (ConfigInfo->ElementCount == 0) {
continue;
}
//
// 1. Prepare <ConfigResp>
//
return Status;
}
//
// 2. Set value to hii driver or efi variable.
//
//
// Send <ConfigResp> to Configuration Driver
//
);
return Status;
}
}
return Status;
}
NULL,
);
return Status;
}
);
return Status;
}
);
return Status;
}
}
//
// 3. Config success, update storage shadow Buffer, only update the data belong to this form.
//
}
//
// 4. Update the NV flag.
//
//
//
continue;
}
//
// Skip if there is no RequestElement
//
if (Storage->ElementCount == 0) {
continue;
}
//
// 1. Prepare <ConfigResp>
//
return Status;
}
//
// 2. Send <ConfigResp> to Configuration Driver
//
);
return Status;
}
}
//
// 1&2. Set the edit data to the variable.
//
return Status;
}
NULL,
);
);
return Status;
}
);
return Status;
}
}
//
// 3. Config success, update storage shadow Buffer
//
}
//
// 4. Update the NV flag.
//
} else if (SettingScope == SystemLevel) {
//
// System Level Save.
//
//
// Save changed value for each FormSet in the maintain list.
//
//
// Remove maintain backup list after save except for the current using FormSet.
//
}
}
}
return EFI_SUCCESS;
}
/**
Get Question default value from AltCfg string.
@param FormSet The form set.
@param Question The question.
@param DefaultId The default Id.
@retval EFI_SUCCESS Question is reset to default value.
**/
)
{
Length = 0;
ConfigResp = NULL;
return Status;
}
//
// Question Value is provided by Buffer Storage or NameValue Storage
//
//
// This Question is password or orderedlist
//
} else {
//
// Other type of Questions
//
}
//
// <ConfigRequest> ::= <ConfigHdr> + <BlockName> ||
// <ConfigHdr> + "&" + <VariableName>
//
if (IsBufferStorage) {
} else {
}
if (IsBufferStorage) {
} else {
}
&Progress,
);
goto Done;
}
//
// Call ConfigRouting GetAltCfg(ConfigRoute, <ConfigResponse>, Guid, Name, DevicePath, AltCfgId, AltCfgResp)
// Get the default configuration string according to the default ID.
//
NULL,
&DefaultId, // it can be NULL to get the current setting.
);
//
// The required setting can't be found. So, it is not required to be validated and set.
//
goto Done;
}
//
// Skip <ConfigRequest>
//
if (IsBufferStorage) {
//
// Skip "&VALUE"
//
} else {
}
if (*Value != '=') {
goto Done;
}
//
// Skip '=', point to value
//
//
// Suppress <AltResp> if any
//
StringPtr++;
}
*StringPtr = L'\0';
if (!IsBufferStorage && IsString) {
}
//
// Add tailing L'\0' character
//
} else {
if ((Index & 1) == 0) {
} else {
}
}
}
Done:
if (ConfigRequest != NULL){
}
if (ConfigResp != NULL) {
}
}
return Status;
}
/**
Get default Id value used for browser.
@param DefaultId The default id value used by hii.
@retval Browser used default value.
**/
)
{
if (DefaultId == EFI_HII_DEFAULT_CLASS_STANDARD) {
} else if (DefaultId == EFI_HII_DEFAULT_CLASS_MANUFACTURING) {
} else if (DefaultId == EFI_HII_DEFAULT_CLASS_SAFE) {
return EFI_BROWSER_ACTION_DEFAULT_SAFE;
} else if (DefaultId >= EFI_HII_DEFAULT_CLASS_PLATFORM_BEGIN && DefaultId < EFI_HII_DEFAULT_CLASS_PLATFORM_BEGIN + 0x1000) {
} else if (DefaultId >= EFI_HII_DEFAULT_CLASS_HARDWARE_BEGIN && DefaultId < EFI_HII_DEFAULT_CLASS_HARDWARE_BEGIN + 0x1000) {
} else if (DefaultId >= EFI_HII_DEFAULT_CLASS_FIRMWARE_BEGIN && DefaultId < EFI_HII_DEFAULT_CLASS_FIRMWARE_BEGIN + 0x1000) {
} else {
return -1;
}
}
/**
Reset Question to its default value.
@param FormSet The form set.
@param Form The form.
@param Question The question.
@param DefaultId The Class of the default.
@retval EFI_SUCCESS Question is reset to default value.
**/
)
{
//
// Statement don't have storage, skip them
//
if (Question->QuestionId == 0) {
return Status;
}
//
// There are Five ways to specify default value for a Question:
// 1, use call back function (highest priority)
// 2, use ExtractConfig function
// 3, use nested EFI_IFR_DEFAULT
// 4, set flags of EFI_ONE_OF_OPTION (provide Standard and Manufacturing default)
// 5, set flags of EFI_IFR_CHECKBOX (provide Standard and Manufacturing default) (lowest priority)
//
//
// Get Question defaut value from call back function.
//
if ((Action > 0) && ((Question->QuestionFlags & EFI_IFR_FLAG_CALLBACK) != 0) && (ConfigAccess != NULL)) {
);
return Status;
}
}
//
// Get default value from altcfg string.
//
if (ConfigAccess != NULL) {
return Status;
}
}
//
// EFI_IFR_DEFAULT has highest priority
//
//
// Default is provided by an Expression, evaluate it
//
return Status;
}
CopyMem (Question->HiiValue.Buffer, Default->ValueExpression->Result.Buffer, Default->ValueExpression->Result.BufferLen);
} else {
CopyMem (Question->HiiValue.Buffer, Default->ValueExpression->Result.Buffer, Question->StorageWidth);
}
}
} else {
//
// Default value is embedded in EFI_IFR_DEFAULT
//
}
return EFI_NOT_FOUND;
}
} else {
}
}
return EFI_SUCCESS;
}
}
}
//
// EFI_ONE_OF_OPTION
//
if (DefaultId <= EFI_HII_DEFAULT_CLASS_MANUFACTURING) {
//
// OneOfOption could only provide Standard and Manufacturing default
//
if (((DefaultId == EFI_HII_DEFAULT_CLASS_STANDARD) && ((Option->Flags & EFI_IFR_OPTION_DEFAULT) != 0)) ||
((DefaultId == EFI_HII_DEFAULT_CLASS_MANUFACTURING) && ((Option->Flags & EFI_IFR_OPTION_DEFAULT_MFG) != 0))
) {
return EFI_SUCCESS;
}
}
}
}
//
// EFI_IFR_CHECKBOX - lowest priority
//
if (DefaultId <= EFI_HII_DEFAULT_CLASS_MANUFACTURING) {
//
// Checkbox could only provide Standard and Manufacturing default
//
if (((DefaultId == EFI_HII_DEFAULT_CLASS_STANDARD) && ((Question->Flags & EFI_IFR_CHECKBOX_DEFAULT) != 0)) ||
((DefaultId == EFI_HII_DEFAULT_CLASS_MANUFACTURING) && ((Question->Flags & EFI_IFR_CHECKBOX_DEFAULT_MFG) != 0))
) {
} else {
}
return EFI_SUCCESS;
}
}
//
// For Questions without default
//
case EFI_IFR_NUMERIC_OP:
//
// Take minimum value as numeric default value
//
}
break;
case EFI_IFR_ONE_OF_OP:
//
// Take first oneof option as oneof's default value
//
}
}
break;
case EFI_IFR_ORDERED_LIST_OP:
//
// Take option sequence in IFR as ordered list's default value
//
Index = 0;
Index++;
break;
}
}
break;
default:
break;
}
return Status;
}
/**
Reset Questions to their default value in a Form, Formset or System.
@param FormSet FormSet data structure.
@param Form Form data structure.
@param DefaultId The Class of the default.
@param SettingScope Setting Scope for Default action.
@retval EFI_SUCCESS The function completed successfully.
@retval EFI_UNSUPPORTED Unsupport SettingScope.
**/
)
{
//
// Check the supported setting level.
//
if (SettingScope >= MaxLevel) {
return EFI_UNSUPPORTED;
}
if (SettingScope == FormLevel) {
//
// Extract Form default
//
//
// If Question is disabled, don't reset it to default
//
continue;
}
}
//
// Reset Question to its default value
//
continue;
}
//
// Synchronize Buffer storage's Edit buffer
//
//
// Update Form NV flag.
//
}
}
} else if (SettingScope == FormSetLevel) {
}
} else if (SettingScope == SystemLevel) {
//
// Open all FormSet by locate HII packages.
// Initiliaze the maintain FormSet to store default data as back up data.
//
gOldFormSet = NULL;
//
// Get all the Hii handles
//
//
// Search for formset of each class type
//
//
// Check HiiHandles[Index] does exist in global maintain list.
//
continue;
}
//
// Initilize FormSet Setting
//
continue;
}
continue;
}
//
// Initilize Questions' Value
//
continue;
}
//
// Add FormSet into the maintain list.
//
}
//
// Free resources, and restore gOldFormSet and gClassOfVfr
//
//
// Set Default Value for each FormSet in the maintain list.
//
}
}
return EFI_SUCCESS;
}
/**
Initialize Question's Edit copy from Storage.
@param Selection Selection contains the information about
the Selection, form and formset to be displayed.
Selection action may be updated in retrieve callback.
If Selection is NULL, only initialize Question value.
@param FormSet FormSet data structure.
@param Form Form data structure.
@retval EFI_SUCCESS The function completed successfully.
**/
)
{
//
// Initialize local copy of Value for each Question
//
return Status;
}
HiiSetString (FormSet->HiiHandle, Question->HiiValue.Value.string, (CHAR16*)Question->BufferValue, NULL);
}
//
// According the spec, ref opcode try to get value from call back with "retrieve" type.
//
if ((Question->Operand == EFI_IFR_REF_OP) && (FormSet->ConfigAccess != NULL) && (Selection != NULL)) {
return Status;
}
}
//
// Check whether EfiVarstore with CallBack can be got.
//
(Question->QuestionId != 0) &&
//
// Check QuestionValue does exist.
//
} else {
}
NULL,
);
}
}
}
return EFI_SUCCESS;
}
/**
Initialize Question's Edit copy from Storage for the whole Formset.
@param Selection Selection contains the information about
the Selection, form and formset to be displayed.
Selection action may be updated in retrieve callback.
If Selection is NULL, only initialize Question value.
@param FormSet FormSet data structure.
@retval EFI_SUCCESS The function completed successfully.
**/
)
{
//
// Initialize local copy of Value for each Form
//
return Status;
}
}
return EFI_SUCCESS;
}
/**
Fill storage's edit copy with settings requested from Configuration Driver.
@param FormSet FormSet data structure.
@param Storage Buffer Storage.
@retval EFI_SUCCESS The function completed successfully.
**/
)
{
return EFI_SUCCESS;
}
NULL,
);
return Status;
}
return EFI_NOT_FOUND;
}
if (Storage->ElementCount == 0) {
//
// Skip if there is no RequestElement
//
return EFI_SUCCESS;
}
//
// Request current settings from Configuration Driver
//
&Progress,
);
return Status;
}
//
// Convert Result from <ConfigAltResp> to <ConfigResp>
//
*StrPtr = L'\0';
}
return Status;
}
/**
Copy uncommitted data from source Storage to destination Storage.
@param Dst Target Storage for uncommitted data.
@param Src Source Storage for uncommitted data.
@retval EFI_SUCCESS The function completed successfully.
@retval EFI_INVALID_PARAMETER Source and destination Storage is not the same type.
**/
)
{
return EFI_INVALID_PARAMETER;
}
case EFI_HII_VARSTORE_BUFFER:
break;
}
break;
default:
break;
}
return EFI_SUCCESS;
}
/**
Get current setting of Questions.
@param FormSet FormSet data structure.
@retval EFI_SUCCESS The function completed successfully.
**/
)
{
//
// Extract default from IFR binary
//
//
// Request current settings from Configuration Driver
//
OldStorage = NULL;
if (gOldFormSet != NULL) {
//
// Try to find the Storage in backup formset gOldFormSet
//
break;
}
}
}
if (OldStorage == NULL) {
//
// Storage is not found in backup formset, request it from ConfigDriver
//
//
// Now Edit Buffer is filled with default values(lower priority) and current
// settings(higher priority), sychronize it to shadow Buffer
//
}
} else {
//
// Storage found in backup formset, use it
//
}
}
//
// If has old formset, get the old nv update status.
//
if (gOldFormSet != NULL) {
break;
}
}
}
}
return EFI_SUCCESS;
}
/**
Fetch the Ifr binary data of a FormSet.
@param Handle PackageList Handle
@param FormSetGuid On input, GUID or class GUID of a formset. If not
specified (NULL or zero GUID), take the first
FormSet with class GUID EFI_HII_PLATFORM_SETUP_FORMSET_GUID
found in package list.
On output, GUID of the formset found(if not NULL).
@param BinaryLength The length of the FormSet IFR binary.
@param BinaryData The buffer designed to receive the FormSet.
@retval EFI_SUCCESS Buffer filled with the requested FormSet.
BufferLength was updated.
@retval EFI_INVALID_PARAMETER The handle is unknown.
@retval EFI_NOT_FOUND A form or FormSet on the requested handle cannot
be found with the requested FormId.
**/
)
{
OpCodeData = NULL;
//
// if FormSetGuid is NULL or zero GUID, return first Setup FormSet in the package list
//
if (FormSetGuid == NULL) {
} else {
}
//
// Get HII PackageList
//
BufferSize = 0;
if (Status == EFI_BUFFER_TOO_SMALL) {
}
return Status;
}
//
// Get Form package from this HII package List
//
Offset = sizeof (EFI_HII_PACKAGE_LIST_HEADER);
Offset2 = 0;
while (Offset < PackageListLength) {
//
// Search FormSet in this Form Package
//
Offset2 = sizeof (EFI_HII_PACKAGE_HEADER);
//
// Try to compare against formset GUID
//
break;
}
//
// Try to compare against formset class GUID
//
break;
}
}
if (ClassGuidMatch) {
break;
}
} else if (ComparingGuid == &gEfiHiiPlatformSetupFormsetGuid) {
break;
}
}
}
//
// Target formset found
//
break;
}
}
}
if (Offset >= PackageListLength) {
//
// Form package not found in this Package List
//
return EFI_NOT_FOUND;
}
if (FormSetGuid != NULL) {
//
// Return the FormSet GUID
//
}
//
// To determine the length of a whole FormSet IFR binary, one have to parse all the Opcodes
// in this FormSet; So, here just simply copy the data from start of a FormSet to the end
// of the Form Package.
//
if (*BinaryData == NULL) {
return EFI_OUT_OF_RESOURCES;
}
return EFI_SUCCESS;
}
/**
Initialize the internal data structure of a FormSet.
@param Handle PackageList Handle
@param FormSetGuid On input, GUID or class GUID of a formset. If not
specified (NULL or zero GUID), take the first
FormSet with class GUID EFI_HII_PLATFORM_SETUP_FORMSET_GUID
found in package list.
On output, GUID of the formset found(if not NULL).
@param FormSet FormSet data structure.
@param UpdateGlobalVar Whether need to update the global variable.
@retval EFI_SUCCESS The function completed successfully.
@retval EFI_NOT_FOUND The specified FormSet could not be found.
**/
)
{
Status = GetIfrBinaryData (Handle, FormSetGuid, &FormSet->IfrBinaryLength, &FormSet->IfrBinaryData);
return Status;
}
//
// Retrieve ConfigAccess Protocol associated with this HiiPackageList
//
return Status;
}
);
//
// Configuration Driver don't attach ConfigAccess protocol to its HII package
// list, then there will be no configuration action required
//
}
//
// Parse the IFR binary OpCodes
//
return Status;
}
//
// If not need to update the global variable, just return.
//
if (!UpdateGlobalVar) {
return Status;
}
//
// Set VFR type by FormSet SubClass field
//
}
//
// Set VFR type by FormSet class guid
//
break;
}
}
}
//
// Match GUID to find out the function key setting. If match fail, use the default setting.
//
for (Index = 0; Index < sizeof (gFunctionKeySettingTable) / sizeof (FUNCTIION_KEY_SETTING); Index++) {
//
// Update the function key setting.
//
}
}
return EFI_SUCCESS;
}
/**
Save globals used by previous call to SendForm(). SendForm() may be called from
HiiConfigAccess.Callback(), this will cause SendForm() be reentried.
So, save globals of previous call to SendForm() and restore them upon exit.
**/
)
{
if (gBrowserContextCount == 1) {
//
// This is not reentry of SendForm(), no context to save
//
return;
}
//
// Save FormBrowser context
//
//
// Insert to FormBrowser context list
//
}
/**
Restore globals used by previous call to SendForm().
**/
)
{
ASSERT (gBrowserContextCount != 0);
if (gBrowserContextCount == 0) {
//
// This is not reentry of SendForm(), no context to restore
//
return;
}
//
// Restore FormBrowser context
//
//
// Remove from FormBrowser context list
//
}
/**
Find the matched FormSet context in the backup maintain list based on HiiHandle.
@param Handle The Hii Handle.
@return the found FormSet context. If no found, NULL will return.
**/
)
{
return FormSet;
}
}
return NULL;
}
/**
Check whether the input HII handle is the FormSet that is being used.
@param Handle The Hii Handle.
@retval TRUE HII handle is being used.
@retval FALSE HII handle is not being used.
**/
)
{
//
// HiiHandle is Current FormSet.
//
return TRUE;
}
//
// Check whether HiiHandle is in BrowserContext.
//
//
// HiiHandle is in BrowserContext
//
return TRUE;
}
}
return FALSE;
}
/**
Find the registered HotKey based on KeyData.
@param[in] KeyData A pointer to a buffer that describes the keystroke
information for the hot key.
@return The registered HotKey context. If no found, NULL will return.
**/
)
{
return HotKey;
}
}
return NULL;
}
/**
Configure what scope the hot key will impact.
All hot keys have the same scope. The mixed hot keys with the different level are not supported.
If no scope is set, the default scope will be FormSet level.
After all registered hot keys are removed, previous Scope can reset to another level.
@param[in] Scope Scope level to be set.
@retval EFI_SUCCESS Scope is set correctly.
@retval EFI_INVALID_PARAMETER Scope is not the valid value specified in BROWSER_SETTING_SCOPE.
@retval EFI_UNSPPORTED Scope level is different from current one that the registered hot keys have.
**/
SetScope (
)
{
return EFI_INVALID_PARAMETER;
}
//
// When no hot key registered in system or on the first setting,
// Scope can be set.
//
} else if (Scope != gBrowserSettingScope) {
return EFI_UNSUPPORTED;
}
return EFI_SUCCESS;
}
/**
Register the hot key with its browser action, or unregistered the hot key.
Only support hot key that is not printable character (control key, function key, etc.).
If the action value is zero, the hot key will be unregistered if it has been registered.
If the same hot key has been registered, the new action and help string will override the previous ones.
@param[in] KeyData A pointer to a buffer that describes the keystroke
information for the hot key. Its type is EFI_INPUT_KEY to
be supported by all ConsoleIn devices.
@param[in] Action Action value that describes what action will be trigged when the hot key is pressed.
@param[in] DefaultId Specifies the type of defaults to retrieve, which is only for DEFAULT action.
@param[in] HelpString Help string that describes the hot key information.
Its value may be NULL for the unregistered hot key.
@retval EFI_SUCCESS Hot key is registered or unregistered.
@retval EFI_INVALID_PARAMETER KeyData is NULL or HelpString is NULL on register.
@retval EFI_NOT_FOUND KeyData is not found to be unregistered.
@retval EFI_UNSUPPORTED Key represents a printable character. It is conflicted with Browser.
**/
)
{
//
// Check input parameters.
//
return EFI_INVALID_PARAMETER;
}
//
// Check whether the input KeyData is in BrowserHotKeyList.
//
//
// Unregister HotKey
//
if (Action == BROWSER_ACTION_UNREGISTER) {
//
// The registered HotKey is found.
// Remove it from List, and free its resource.
//
return EFI_SUCCESS;
} else {
//
// The registered HotKey is not found.
//
return EFI_NOT_FOUND;
}
}
//
// Register HotKey into List.
//
//
// Create new Key, and add it into List.
//
}
//
// Fill HotKey information.
//
}
return EFI_SUCCESS;
}
/**
Register Exit handler function.
When more than one handler function is registered, the latter one will override the previous one.
When NULL handler is specified, the previous Exit handler will be unregistered.
@param[in] Handler Pointer to handler function.
**/
)
{
return;
}
/**
Create reminder to let user to choose save or discard the changed browser data.
Caller can use it to actively check the changed browser data.
@retval BROWSER_NO_CHANGES No browser data is changed.
@retval BROWSER_SAVE_CHANGES The changed browser data is saved.
@retval BROWSER_DISCARD_CHANGES The changed browser data is discard.
**/
)
{
if (IsNvUpdateRequired (FormSet)) {
break;
}
}
//
// No data is changed. No save is required.
//
if (!IsDataChanged) {
return DataSavedAction;
}
//
// If data is changed, prompt user
//
do {
CreateDialog (4, TRUE, 0, NULL, &Key, EmptyString, ChangeReminderString, SaveConfirmString, EmptyString);
} while
);
//
// If the user hits the YesResponse key
//
} else {
}
return DataSavedAction;
}