2008-07-15 10:35:54 +02:00
|
|
|
/** @file
|
|
|
|
Utility functions for UI presentation.
|
|
|
|
|
2013-01-22 10:49:44 +01:00
|
|
|
Copyright (c) 2004 - 2013, Intel Corporation. All rights reserved.<BR>
|
2010-04-24 11:33:45 +02:00
|
|
|
This program and the accompanying materials
|
2008-07-15 10:35:54 +02: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 "Setup.h"
|
|
|
|
|
|
|
|
BOOLEAN mHiiPackageListUpdated;
|
|
|
|
UI_MENU_SELECTION *gCurrentSelection;
|
2010-06-04 03:29:03 +02:00
|
|
|
EFI_HII_HANDLE mCurrentHiiHandle = NULL;
|
|
|
|
EFI_GUID mCurrentFormSetGuid = {0, 0, 0, {0, 0, 0, 0, 0, 0, 0, 0}};
|
|
|
|
UINT16 mCurrentFormId = 0;
|
2013-08-09 07:26:47 +02:00
|
|
|
EFI_EVENT mValueChangedEvent = NULL;
|
|
|
|
LIST_ENTRY mRefreshEventList = INITIALIZE_LIST_HEAD_VARIABLE (mRefreshEventList);
|
|
|
|
UINT32 gBrowserStatus = BROWSER_SUCCESS;
|
|
|
|
CHAR16 *gErrorInfo;
|
|
|
|
UINT16 mCurFakeQestId;
|
|
|
|
FORM_DISPLAY_ENGINE_FORM gDisplayFormData;
|
|
|
|
|
|
|
|
/**
|
|
|
|
Evaluate all expressions in a Form.
|
|
|
|
|
|
|
|
@param FormSet FormSet this Form belongs to.
|
|
|
|
@param Form The Form.
|
|
|
|
|
|
|
|
@retval EFI_SUCCESS The expression evaluated successfuly
|
|
|
|
|
|
|
|
**/
|
|
|
|
EFI_STATUS
|
|
|
|
EvaluateFormExpressions (
|
|
|
|
IN FORM_BROWSER_FORMSET *FormSet,
|
|
|
|
IN FORM_BROWSER_FORM *Form
|
|
|
|
)
|
|
|
|
{
|
|
|
|
EFI_STATUS Status;
|
|
|
|
LIST_ENTRY *Link;
|
|
|
|
FORM_EXPRESSION *Expression;
|
|
|
|
|
|
|
|
Link = GetFirstNode (&Form->ExpressionListHead);
|
|
|
|
while (!IsNull (&Form->ExpressionListHead, Link)) {
|
|
|
|
Expression = FORM_EXPRESSION_FROM_LINK (Link);
|
|
|
|
Link = GetNextNode (&Form->ExpressionListHead, Link);
|
|
|
|
|
|
|
|
if (Expression->Type == EFI_HII_EXPRESSION_INCONSISTENT_IF ||
|
|
|
|
Expression->Type == EFI_HII_EXPRESSION_NO_SUBMIT_IF ||
|
|
|
|
Expression->Type == EFI_HII_EXPRESSION_WRITE ||
|
|
|
|
(Expression->Type == EFI_HII_EXPRESSION_READ && Form->FormType != STANDARD_MAP_FORM_TYPE)) {
|
|
|
|
//
|
|
|
|
// Postpone Form validation to Question editing or Form submitting or Question Write or Question Read for nonstandard form.
|
|
|
|
//
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
|
|
|
Status = EvaluateExpression (FormSet, Form, Expression);
|
|
|
|
if (EFI_ERROR (Status)) {
|
|
|
|
return Status;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return EFI_SUCCESS;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
Add empty function for event process function.
|
|
|
|
|
|
|
|
@param Event The Event need to be process
|
|
|
|
@param Context The context of the event.
|
|
|
|
|
|
|
|
**/
|
|
|
|
VOID
|
|
|
|
EFIAPI
|
|
|
|
SetupBrowserEmptyFunction (
|
|
|
|
IN EFI_EVENT Event,
|
|
|
|
IN VOID *Context
|
|
|
|
)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
Base on the opcode buffer info to get the display statement.
|
|
|
|
|
|
|
|
@param OpCode The input opcode buffer for this statement.
|
|
|
|
|
|
|
|
@retval Statement The statement use this opcode buffer.
|
|
|
|
|
|
|
|
**/
|
|
|
|
FORM_DISPLAY_ENGINE_STATEMENT *
|
|
|
|
GetDisplayStatement (
|
|
|
|
IN EFI_IFR_OP_HEADER *OpCode
|
|
|
|
)
|
|
|
|
{
|
|
|
|
FORM_DISPLAY_ENGINE_STATEMENT *DisplayStatement;
|
|
|
|
LIST_ENTRY *Link;
|
|
|
|
|
|
|
|
Link = GetFirstNode (&gDisplayFormData.StatementListHead);
|
|
|
|
while (!IsNull (&gDisplayFormData.StatementListHead, Link)) {
|
|
|
|
DisplayStatement = FORM_DISPLAY_ENGINE_STATEMENT_FROM_LINK (Link);
|
|
|
|
|
|
|
|
if (DisplayStatement->OpCode == OpCode) {
|
|
|
|
return DisplayStatement;
|
|
|
|
}
|
|
|
|
Link = GetNextNode (&gDisplayFormData.StatementListHead, Link);
|
|
|
|
}
|
|
|
|
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
Free the refresh event list.
|
|
|
|
|
|
|
|
**/
|
|
|
|
VOID
|
|
|
|
FreeRefreshEvent (
|
|
|
|
VOID
|
|
|
|
)
|
|
|
|
{
|
|
|
|
LIST_ENTRY *Link;
|
|
|
|
FORM_BROWSER_REFRESH_EVENT_NODE *EventNode;
|
|
|
|
|
|
|
|
while (!IsListEmpty (&mRefreshEventList)) {
|
|
|
|
Link = GetFirstNode (&mRefreshEventList);
|
|
|
|
EventNode = FORM_BROWSER_REFRESH_EVENT_FROM_LINK (Link);
|
|
|
|
RemoveEntryList (&EventNode->Link);
|
|
|
|
|
|
|
|
gBS->CloseEvent (EventNode->RefreshEvent);
|
|
|
|
|
|
|
|
FreePool (EventNode);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
Check whether this statement value is changed. If yes, update the statement value and return TRUE;
|
|
|
|
else return FALSE.
|
|
|
|
|
|
|
|
@param Statement The statement need to check.
|
|
|
|
|
|
|
|
**/
|
|
|
|
VOID
|
|
|
|
UpdateStatement (
|
|
|
|
IN OUT FORM_BROWSER_STATEMENT *Statement
|
|
|
|
)
|
|
|
|
{
|
|
|
|
GetQuestionValue (gCurrentSelection->FormSet, gCurrentSelection->Form, Statement, GetSetValueWithHiiDriver);
|
|
|
|
|
|
|
|
//
|
|
|
|
// Reset FormPackage update flag
|
|
|
|
//
|
|
|
|
mHiiPackageListUpdated = FALSE;
|
|
|
|
|
|
|
|
//
|
|
|
|
// Question value may be changed, need invoke its Callback()
|
|
|
|
//
|
|
|
|
ProcessCallBackFunction (gCurrentSelection, Statement, EFI_BROWSER_ACTION_CHANGING, FALSE);
|
|
|
|
|
|
|
|
if (mHiiPackageListUpdated) {
|
|
|
|
//
|
|
|
|
// Package list is updated, force to reparse IFR binary of target Formset
|
|
|
|
//
|
|
|
|
mHiiPackageListUpdated = FALSE;
|
|
|
|
gCurrentSelection->Action = UI_ACTION_REFRESH_FORMSET;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
Refresh the question which has refresh guid event attribute.
|
|
|
|
|
|
|
|
@param Event The event which has this function related.
|
|
|
|
@param Context The input context info related to this event or the status code return to the caller.
|
|
|
|
**/
|
|
|
|
VOID
|
|
|
|
EFIAPI
|
|
|
|
RefreshEventNotify(
|
|
|
|
IN EFI_EVENT Event,
|
|
|
|
IN VOID *Context
|
|
|
|
)
|
|
|
|
{
|
|
|
|
FORM_BROWSER_STATEMENT *Statement;
|
|
|
|
|
|
|
|
Statement = (FORM_BROWSER_STATEMENT *)Context;
|
|
|
|
UpdateStatement(Statement);
|
|
|
|
gBS->SignalEvent (mValueChangedEvent);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
Create refresh hook event for statement which has refresh event or interval.
|
|
|
|
|
|
|
|
@param Statement The statement need to check.
|
|
|
|
|
|
|
|
**/
|
|
|
|
VOID
|
|
|
|
CreateRefreshEvent (
|
|
|
|
IN FORM_BROWSER_STATEMENT *Statement
|
|
|
|
)
|
|
|
|
{
|
|
|
|
EFI_STATUS Status;
|
|
|
|
EFI_EVENT RefreshEvent;
|
|
|
|
FORM_BROWSER_REFRESH_EVENT_NODE *EventNode;
|
|
|
|
|
|
|
|
//
|
|
|
|
// If question has refresh guid, create the notify function.
|
|
|
|
//
|
|
|
|
Status = gBS->CreateEventEx (
|
|
|
|
EVT_NOTIFY_SIGNAL,
|
|
|
|
TPL_CALLBACK,
|
|
|
|
RefreshEventNotify,
|
|
|
|
Statement,
|
|
|
|
&Statement->RefreshGuid,
|
|
|
|
&RefreshEvent);
|
|
|
|
ASSERT_EFI_ERROR (Status);
|
|
|
|
|
|
|
|
EventNode = AllocateZeroPool (sizeof (FORM_BROWSER_REFRESH_EVENT_NODE));
|
|
|
|
ASSERT (EventNode != NULL);
|
|
|
|
EventNode->RefreshEvent = RefreshEvent;
|
|
|
|
InsertTailList(&mRefreshEventList, &EventNode->Link);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
Perform value check for a question.
|
|
|
|
|
|
|
|
@param Question The question need to do check.
|
|
|
|
@param ErrorInfo Return info about the error.
|
|
|
|
|
|
|
|
@retval The check result.
|
|
|
|
**/
|
|
|
|
UINT32
|
|
|
|
InConsistentIfCheck (
|
|
|
|
IN FORM_BROWSER_STATEMENT *Question,
|
|
|
|
OUT STATEMENT_ERROR_INFO *ErrorInfo
|
|
|
|
)
|
|
|
|
{
|
|
|
|
EFI_STATUS Status;
|
|
|
|
LIST_ENTRY *Link;
|
|
|
|
FORM_EXPRESSION *Expression;
|
|
|
|
LIST_ENTRY *ListHead;
|
|
|
|
UINT32 RetVal;
|
|
|
|
|
|
|
|
RetVal = STATEMENT_VALID;
|
|
|
|
ListHead = &Question->InconsistentListHead;
|
|
|
|
|
|
|
|
Link = GetFirstNode (ListHead);
|
|
|
|
while (!IsNull (ListHead, Link)) {
|
|
|
|
Expression = FORM_EXPRESSION_FROM_LINK (Link);
|
|
|
|
Link = GetNextNode (ListHead, Link);
|
|
|
|
|
|
|
|
//
|
|
|
|
// Evaluate the expression
|
|
|
|
//
|
|
|
|
Status = EvaluateExpression (gCurrentSelection->FormSet, gCurrentSelection->Form, Expression);
|
|
|
|
if (EFI_ERROR (Status)) {
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
|
|
|
if ((Expression->Result.Type == EFI_IFR_TYPE_BOOLEAN) && Expression->Result.Value.b) {
|
|
|
|
ErrorInfo->StringId = Expression->Error;
|
|
|
|
ErrorInfo->TimeOut = 0;
|
|
|
|
RetVal = INCOSISTENT_IF_TRUE;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return RetVal;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
Perform value check for a question.
|
|
|
|
|
|
|
|
@param Form Form where Statement is in.
|
|
|
|
@param Statement Value will check for it.
|
|
|
|
@param InputValue New value will be checked.
|
|
|
|
@param ErrorInfo Return the error info for this check.
|
|
|
|
|
|
|
|
@retval TRUE Input Value is valid.
|
|
|
|
@retval FALSE Input Value is invalid.
|
|
|
|
**/
|
|
|
|
UINT32
|
|
|
|
EFIAPI
|
|
|
|
QuestionCheck (
|
|
|
|
IN FORM_DISPLAY_ENGINE_FORM *Form,
|
|
|
|
IN FORM_DISPLAY_ENGINE_STATEMENT *Statement,
|
|
|
|
IN EFI_HII_VALUE *InputValue,
|
|
|
|
OUT STATEMENT_ERROR_INFO *ErrorInfo
|
|
|
|
)
|
|
|
|
{
|
|
|
|
FORM_BROWSER_STATEMENT *Question;
|
|
|
|
EFI_HII_VALUE BackUpValue;
|
|
|
|
UINT8 *BackUpBuffer;
|
|
|
|
UINT32 RetVal;
|
|
|
|
|
|
|
|
BackUpBuffer = NULL;
|
|
|
|
RetVal = STATEMENT_VALID;
|
|
|
|
|
|
|
|
ASSERT (Form != NULL && Statement != NULL && InputValue != NULL && ErrorInfo != NULL);
|
|
|
|
|
|
|
|
Question = GetBrowserStatement(Statement);
|
|
|
|
ASSERT (Question != NULL);
|
|
|
|
|
|
|
|
//
|
|
|
|
// Back up the quesion value.
|
|
|
|
//
|
|
|
|
switch (Question->Operand) {
|
|
|
|
case EFI_IFR_ORDERED_LIST_OP:
|
|
|
|
BackUpBuffer = AllocateCopyPool (Question->StorageWidth, Question->BufferValue);
|
|
|
|
ASSERT (BackUpBuffer != NULL);
|
|
|
|
CopyMem (Question->BufferValue, InputValue->Buffer, Question->StorageWidth);
|
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
CopyMem (&BackUpValue, &Question->HiiValue, sizeof (EFI_HII_VALUE));
|
|
|
|
CopyMem (&Question->HiiValue, InputValue, sizeof (EFI_HII_VALUE));
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
//
|
|
|
|
// Do the inconsistentif check.
|
|
|
|
//
|
|
|
|
if (!IsListEmpty (&Question->InconsistentListHead)) {
|
|
|
|
RetVal = InConsistentIfCheck(Question, ErrorInfo);
|
|
|
|
}
|
|
|
|
|
|
|
|
//
|
|
|
|
// Restore the quesion value.
|
|
|
|
//
|
|
|
|
switch (Question->Operand) {
|
|
|
|
case EFI_IFR_ORDERED_LIST_OP:
|
|
|
|
CopyMem (Question->BufferValue, BackUpBuffer, Question->StorageWidth);
|
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
CopyMem (&Question->HiiValue, &BackUpValue, sizeof (EFI_HII_VALUE));
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
return RetVal;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
|
|
|
Initialize the Display statement structure data.
|
|
|
|
|
|
|
|
@param DisplayStatement Pointer to the display Statement data strucure.
|
|
|
|
@param Statement The statement need to check.
|
|
|
|
@param HostDisplayStatement Pointer to the display Statement data strucure which is an host statement.
|
|
|
|
**/
|
|
|
|
VOID
|
|
|
|
InitializeDisplayStatement (
|
|
|
|
IN OUT FORM_DISPLAY_ENGINE_STATEMENT *DisplayStatement,
|
|
|
|
IN FORM_BROWSER_STATEMENT *Statement,
|
|
|
|
IN FORM_DISPLAY_ENGINE_STATEMENT *HostDisplayStatement
|
|
|
|
)
|
|
|
|
{
|
|
|
|
LIST_ENTRY *Link;
|
|
|
|
QUESTION_OPTION *Option;
|
|
|
|
DISPLAY_QUESTION_OPTION *DisplayOption;
|
|
|
|
|
|
|
|
DisplayStatement->Signature = FORM_DISPLAY_ENGINE_STATEMENT_SIGNATURE;
|
|
|
|
DisplayStatement->Version = FORM_DISPLAY_ENGINE_STATEMENT_VERSION_1;
|
|
|
|
DisplayStatement->OpCode = Statement->OpCode;
|
|
|
|
InitializeListHead (&DisplayStatement->NestStatementList);
|
|
|
|
InitializeListHead (&DisplayStatement->OptionListHead);
|
|
|
|
|
|
|
|
if ((EvaluateExpressionList(Statement->Expression, FALSE, NULL, NULL) == ExpressGrayOut) || Statement->Locked) {
|
|
|
|
DisplayStatement->Attribute |= HII_DISPLAY_GRAYOUT;
|
|
|
|
}
|
|
|
|
if ((Statement->ValueExpression != NULL) || ((Statement->QuestionFlags & EFI_IFR_FLAG_READ_ONLY) != 0)) {
|
|
|
|
DisplayStatement->Attribute |= HII_DISPLAY_READONLY;
|
|
|
|
}
|
|
|
|
|
|
|
|
//
|
|
|
|
// Initilize the option list in statement.
|
|
|
|
//
|
|
|
|
Link = GetFirstNode (&Statement->OptionListHead);
|
|
|
|
while (!IsNull (&Statement->OptionListHead, Link)) {
|
|
|
|
Option = QUESTION_OPTION_FROM_LINK (Link);
|
|
|
|
Link = GetNextNode (&Statement->OptionListHead, Link);
|
|
|
|
if ((Option->SuppressExpression != NULL) &&
|
|
|
|
((EvaluateExpressionList(Option->SuppressExpression, FALSE, NULL, NULL) == ExpressSuppress))) {
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
|
|
|
DisplayOption = AllocateZeroPool (sizeof (DISPLAY_QUESTION_OPTION));
|
|
|
|
ASSERT (DisplayOption != NULL);
|
|
|
|
|
|
|
|
DisplayOption->ImageId = Option->ImageId;
|
|
|
|
DisplayOption->Signature = DISPLAY_QUESTION_OPTION_SIGNATURE;
|
|
|
|
DisplayOption->OptionOpCode = Option->OpCode;
|
|
|
|
InsertTailList(&DisplayStatement->OptionListHead, &DisplayOption->Link);
|
|
|
|
}
|
|
|
|
|
|
|
|
CopyMem (&DisplayStatement->CurrentValue, &Statement->HiiValue, sizeof (EFI_HII_VALUE));
|
|
|
|
|
|
|
|
//
|
|
|
|
// Some special op code need an extra buffer to save the data.
|
|
|
|
// Such as string, password, orderedlist...
|
|
|
|
//
|
|
|
|
if (Statement->BufferValue != NULL) {
|
|
|
|
//
|
|
|
|
// Ordered list opcode may not initilized, get default value here.
|
|
|
|
//
|
|
|
|
if (Statement->OpCode->OpCode == EFI_IFR_ORDERED_LIST_OP && GetArrayData (Statement->BufferValue, Statement->ValueType, 0) == 0) {
|
|
|
|
GetQuestionDefault (gCurrentSelection->FormSet, gCurrentSelection->Form, Statement, 0);
|
|
|
|
}
|
|
|
|
|
|
|
|
DisplayStatement->CurrentValue.Buffer = AllocateCopyPool(Statement->StorageWidth,Statement->BufferValue);
|
|
|
|
DisplayStatement->CurrentValue.BufferLen = Statement->StorageWidth;
|
|
|
|
}
|
|
|
|
|
|
|
|
DisplayStatement->SettingChangedFlag = Statement->ValueChanged;
|
|
|
|
|
|
|
|
//
|
|
|
|
// Get the highlight statement for current form.
|
|
|
|
//
|
|
|
|
if (((gCurrentSelection->QuestionId != 0) && (Statement->QuestionId == gCurrentSelection->QuestionId)) ||
|
|
|
|
((mCurFakeQestId != 0) && (Statement->FakeQuestionId == mCurFakeQestId))) {
|
|
|
|
gDisplayFormData.HighLightedStatement = DisplayStatement;
|
|
|
|
}
|
|
|
|
|
|
|
|
//
|
|
|
|
// Create the refresh event process function.
|
|
|
|
//
|
|
|
|
if (!CompareGuid (&Statement->RefreshGuid, &gZeroGuid)) {
|
|
|
|
CreateRefreshEvent (Statement);
|
|
|
|
}
|
|
|
|
|
|
|
|
//
|
|
|
|
// For RTC type of date/time, set default refresh interval to be 1 second.
|
|
|
|
//
|
|
|
|
if ((Statement->Operand == EFI_IFR_DATE_OP || Statement->Operand == EFI_IFR_TIME_OP) && Statement->Storage == NULL) {
|
|
|
|
Statement->RefreshInterval = 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
//
|
|
|
|
// Create the refresh guid hook event.
|
|
|
|
// If the statement in this form has refresh event or refresh interval, browser will create this event for display engine.
|
|
|
|
//
|
|
|
|
if ((!CompareGuid (&Statement->RefreshGuid, &gZeroGuid)) || (Statement->RefreshInterval != 0)) {
|
|
|
|
gDisplayFormData.FormRefreshEvent = mValueChangedEvent;
|
|
|
|
}
|
|
|
|
|
|
|
|
//
|
|
|
|
// Save the password check function for later use.
|
|
|
|
//
|
|
|
|
if (Statement->Operand == EFI_IFR_PASSWORD_OP) {
|
|
|
|
DisplayStatement->PasswordCheck = PasswordCheck;
|
|
|
|
}
|
|
|
|
|
|
|
|
//
|
|
|
|
// Save the validate check question for later use.
|
|
|
|
//
|
|
|
|
if (!IsListEmpty (&Statement->InconsistentListHead)) {
|
|
|
|
DisplayStatement->ValidateQuestion = QuestionCheck;
|
|
|
|
}
|
|
|
|
|
|
|
|
//
|
|
|
|
// If this statement is nest in the subtitle, insert to the host statement.
|
|
|
|
// else insert to the form it belongs to.
|
|
|
|
//
|
|
|
|
if (Statement->InSubtitle) {
|
|
|
|
InsertTailList(&HostDisplayStatement->NestStatementList, &DisplayStatement->DisplayLink);
|
|
|
|
} else {
|
|
|
|
InsertTailList(&gDisplayFormData.StatementListHead, &DisplayStatement->DisplayLink);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
Process for the refresh interval statement.
|
|
|
|
|
|
|
|
@param Event The Event need to be process
|
|
|
|
@param Context The context of the event.
|
|
|
|
|
|
|
|
**/
|
|
|
|
VOID
|
|
|
|
EFIAPI
|
|
|
|
RefreshIntervalProcess (
|
|
|
|
IN EFI_EVENT Event,
|
|
|
|
IN VOID *Context
|
|
|
|
)
|
|
|
|
{
|
|
|
|
FORM_BROWSER_STATEMENT *Statement;
|
|
|
|
LIST_ENTRY *Link;
|
|
|
|
|
|
|
|
Link = GetFirstNode (&gCurrentSelection->Form->StatementListHead);
|
|
|
|
while (!IsNull (&gCurrentSelection->Form->StatementListHead, Link)) {
|
|
|
|
Statement = FORM_BROWSER_STATEMENT_FROM_LINK (Link);
|
|
|
|
Link = GetNextNode (&gCurrentSelection->Form->StatementListHead, Link);
|
|
|
|
|
|
|
|
if (Statement->RefreshInterval == 0) {
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
|
|
|
UpdateStatement(Statement);
|
|
|
|
}
|
|
|
|
|
|
|
|
gBS->SignalEvent (mValueChangedEvent);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
|
|
|
Make a copy of the global hotkey info.
|
|
|
|
|
|
|
|
**/
|
|
|
|
VOID
|
|
|
|
UpdateHotkeyList (
|
|
|
|
VOID
|
|
|
|
)
|
|
|
|
{
|
|
|
|
BROWSER_HOT_KEY *HotKey;
|
|
|
|
BROWSER_HOT_KEY *CopyKey;
|
|
|
|
LIST_ENTRY *Link;
|
|
|
|
|
|
|
|
Link = GetFirstNode (&gBrowserHotKeyList);
|
|
|
|
while (!IsNull (&gBrowserHotKeyList, Link)) {
|
|
|
|
HotKey = BROWSER_HOT_KEY_FROM_LINK (Link);
|
|
|
|
|
|
|
|
CopyKey = AllocateCopyPool(sizeof (BROWSER_HOT_KEY), HotKey);
|
|
|
|
CopyKey->KeyData = AllocateCopyPool(sizeof (EFI_INPUT_KEY), HotKey->KeyData);
|
|
|
|
CopyKey->HelpString = AllocateCopyPool(StrSize (HotKey->HelpString), HotKey->HelpString);
|
|
|
|
|
|
|
|
InsertTailList(&gDisplayFormData.HotKeyListHead, &CopyKey->Link);
|
|
|
|
|
|
|
|
Link = GetNextNode (&gBrowserHotKeyList, Link);
|
|
|
|
}
|
|
|
|
}
|
2008-07-15 10:35:54 +02:00
|
|
|
|
|
|
|
/**
|
|
|
|
|
2013-08-09 07:26:47 +02:00
|
|
|
Enum all statement in current form, find all the statement can be display and
|
|
|
|
add to the display form.
|
2008-07-15 10:35:54 +02:00
|
|
|
|
|
|
|
**/
|
|
|
|
VOID
|
2013-08-09 07:26:47 +02:00
|
|
|
AddStatementToDisplayForm (
|
|
|
|
VOID
|
|
|
|
)
|
|
|
|
{
|
|
|
|
EFI_STATUS Status;
|
|
|
|
LIST_ENTRY *Link;
|
|
|
|
FORM_BROWSER_STATEMENT *Statement;
|
|
|
|
FORM_DISPLAY_ENGINE_STATEMENT *DisplayStatement;
|
|
|
|
FORM_DISPLAY_ENGINE_STATEMENT *HostDisplayStatement;
|
|
|
|
UINT8 MinRefreshInterval;
|
|
|
|
EFI_EVENT RefreshIntervalEvent;
|
|
|
|
FORM_BROWSER_REFRESH_EVENT_NODE *EventNode;
|
|
|
|
BOOLEAN FormEditable;
|
|
|
|
|
|
|
|
HostDisplayStatement = NULL;
|
|
|
|
MinRefreshInterval = 0;
|
|
|
|
FormEditable = FALSE;
|
|
|
|
|
|
|
|
//
|
|
|
|
// Process the statement outside the form, these statements are not recognized
|
|
|
|
// by browser core.
|
|
|
|
//
|
|
|
|
Link = GetFirstNode (&gCurrentSelection->FormSet->StatementListOSF);
|
|
|
|
while (!IsNull (&gCurrentSelection->FormSet->StatementListOSF, Link)) {
|
|
|
|
Statement = FORM_BROWSER_STATEMENT_FROM_LINK (Link);
|
|
|
|
Link = GetNextNode (&gCurrentSelection->FormSet->StatementListOSF, Link);
|
|
|
|
|
|
|
|
DisplayStatement = AllocateZeroPool (sizeof (FORM_DISPLAY_ENGINE_STATEMENT));
|
|
|
|
ASSERT (DisplayStatement != NULL);
|
|
|
|
DisplayStatement->Signature = FORM_DISPLAY_ENGINE_STATEMENT_SIGNATURE;
|
|
|
|
DisplayStatement->Version = FORM_DISPLAY_ENGINE_STATEMENT_VERSION_1;
|
|
|
|
DisplayStatement->OpCode = Statement->OpCode;
|
|
|
|
|
|
|
|
InitializeListHead (&DisplayStatement->NestStatementList);
|
|
|
|
InitializeListHead (&DisplayStatement->OptionListHead);
|
|
|
|
|
|
|
|
InsertTailList(&gDisplayFormData.StatementListOSF, &DisplayStatement->DisplayLink);
|
|
|
|
}
|
|
|
|
|
|
|
|
//
|
|
|
|
// Process the statement in this form.
|
|
|
|
//
|
|
|
|
Link = GetFirstNode (&gCurrentSelection->Form->StatementListHead);
|
|
|
|
while (!IsNull (&gCurrentSelection->Form->StatementListHead, Link)) {
|
|
|
|
Statement = FORM_BROWSER_STATEMENT_FROM_LINK (Link);
|
|
|
|
Link = GetNextNode (&gCurrentSelection->Form->StatementListHead, Link);
|
|
|
|
|
|
|
|
//
|
|
|
|
// This statement can't be show, skip it.
|
|
|
|
//
|
|
|
|
if (EvaluateExpressionList(Statement->Expression, FALSE, NULL, NULL) > ExpressGrayOut) {
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
|
|
|
DisplayStatement = AllocateZeroPool (sizeof (FORM_DISPLAY_ENGINE_STATEMENT));
|
|
|
|
ASSERT (DisplayStatement != NULL);
|
|
|
|
|
|
|
|
//
|
|
|
|
// Initialize this statement and add it to the display form.
|
|
|
|
//
|
|
|
|
InitializeDisplayStatement(DisplayStatement, Statement, HostDisplayStatement);
|
|
|
|
|
|
|
|
//
|
|
|
|
// Save the Host statement info.
|
|
|
|
// Host statement may has nest statement follow it.
|
|
|
|
//
|
|
|
|
if (!Statement->InSubtitle) {
|
|
|
|
HostDisplayStatement = DisplayStatement;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (Statement->Storage != NULL) {
|
|
|
|
FormEditable = TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
//
|
|
|
|
// Get the minimal refresh interval value for later use.
|
|
|
|
//
|
|
|
|
if ((Statement->RefreshInterval != 0) &&
|
|
|
|
(MinRefreshInterval == 0 || Statement->RefreshInterval < MinRefreshInterval)) {
|
|
|
|
MinRefreshInterval = Statement->RefreshInterval;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
//
|
|
|
|
// Create the periodic timer for refresh interval statement.
|
|
|
|
//
|
|
|
|
if (MinRefreshInterval != 0) {
|
|
|
|
Status = gBS->CreateEvent (EVT_TIMER | EVT_NOTIFY_SIGNAL, TPL_CALLBACK, RefreshIntervalProcess, NULL, &RefreshIntervalEvent);
|
|
|
|
ASSERT_EFI_ERROR (Status);
|
|
|
|
Status = gBS->SetTimer (RefreshIntervalEvent, TimerPeriodic, MinRefreshInterval * ONE_SECOND);
|
|
|
|
ASSERT_EFI_ERROR (Status);
|
|
|
|
|
|
|
|
EventNode = AllocateZeroPool (sizeof (FORM_BROWSER_REFRESH_EVENT_NODE));
|
|
|
|
ASSERT (EventNode != NULL);
|
|
|
|
EventNode->RefreshEvent = RefreshIntervalEvent;
|
|
|
|
InsertTailList(&mRefreshEventList, &EventNode->Link);
|
|
|
|
}
|
|
|
|
|
|
|
|
//
|
|
|
|
// Update hotkey list field.
|
|
|
|
//
|
|
|
|
if (gBrowserSettingScope == SystemLevel || FormEditable) {
|
|
|
|
UpdateHotkeyList();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
|
|
|
Initialize the SettingChangedFlag variable in the display form.
|
|
|
|
|
|
|
|
**/
|
|
|
|
VOID
|
|
|
|
UpdateDataChangedFlag (
|
|
|
|
VOID
|
|
|
|
)
|
|
|
|
{
|
|
|
|
LIST_ENTRY *Link;
|
|
|
|
FORM_BROWSER_FORMSET *LocalFormSet;
|
|
|
|
|
|
|
|
gDisplayFormData.SettingChangedFlag = FALSE;
|
|
|
|
|
|
|
|
if (IsNvUpdateRequiredForForm (gCurrentSelection->Form)) {
|
|
|
|
gDisplayFormData.SettingChangedFlag = TRUE;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
//
|
|
|
|
// Base on the system level to check whether need to show the NV flag.
|
|
|
|
//
|
|
|
|
switch (gBrowserSettingScope) {
|
|
|
|
case SystemLevel:
|
|
|
|
//
|
|
|
|
// Check the maintain list to see whether there is any change.
|
|
|
|
//
|
|
|
|
Link = GetFirstNode (&gBrowserFormSetList);
|
|
|
|
while (!IsNull (&gBrowserFormSetList, Link)) {
|
|
|
|
LocalFormSet = FORM_BROWSER_FORMSET_FROM_LINK (Link);
|
|
|
|
if (IsNvUpdateRequiredForFormSet(LocalFormSet)) {
|
|
|
|
gDisplayFormData.SettingChangedFlag = TRUE;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
Link = GetNextNode (&gBrowserFormSetList, Link);
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
case FormSetLevel:
|
|
|
|
if (IsNvUpdateRequiredForFormSet(gCurrentSelection->FormSet)) {
|
|
|
|
gDisplayFormData.SettingChangedFlag = TRUE;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
|
|
|
Initialize the Display form structure data.
|
|
|
|
|
|
|
|
**/
|
|
|
|
VOID
|
|
|
|
InitializeDisplayFormData (
|
|
|
|
VOID
|
|
|
|
)
|
|
|
|
{
|
|
|
|
EFI_STATUS Status;
|
|
|
|
|
|
|
|
gDisplayFormData.Signature = FORM_DISPLAY_ENGINE_FORM_SIGNATURE;
|
|
|
|
gDisplayFormData.Version = FORM_DISPLAY_ENGINE_VERSION_1;
|
|
|
|
gDisplayFormData.ImageId = 0;
|
|
|
|
gDisplayFormData.AnimationId = 0;
|
|
|
|
|
|
|
|
InitializeListHead (&gDisplayFormData.StatementListHead);
|
|
|
|
InitializeListHead (&gDisplayFormData.StatementListOSF);
|
|
|
|
InitializeListHead (&gDisplayFormData.HotKeyListHead);
|
|
|
|
|
|
|
|
Status = gBS->CreateEvent (
|
|
|
|
EVT_NOTIFY_WAIT,
|
|
|
|
TPL_CALLBACK,
|
|
|
|
SetupBrowserEmptyFunction,
|
|
|
|
NULL,
|
|
|
|
&mValueChangedEvent
|
|
|
|
);
|
|
|
|
ASSERT_EFI_ERROR (Status);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
|
|
|
Free the kotkey info saved in form data.
|
|
|
|
|
|
|
|
**/
|
|
|
|
VOID
|
|
|
|
FreeHotkeyList (
|
|
|
|
VOID
|
|
|
|
)
|
|
|
|
{
|
|
|
|
BROWSER_HOT_KEY *HotKey;
|
|
|
|
LIST_ENTRY *Link;
|
|
|
|
|
|
|
|
while (!IsListEmpty (&gDisplayFormData.HotKeyListHead)) {
|
|
|
|
Link = GetFirstNode (&gDisplayFormData.HotKeyListHead);
|
|
|
|
HotKey = BROWSER_HOT_KEY_FROM_LINK (Link);
|
|
|
|
|
|
|
|
RemoveEntryList (&HotKey->Link);
|
|
|
|
|
|
|
|
FreePool (HotKey->KeyData);
|
|
|
|
FreePool (HotKey->HelpString);
|
|
|
|
FreePool (HotKey);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
|
|
|
Update the Display form structure data.
|
|
|
|
|
|
|
|
**/
|
|
|
|
VOID
|
|
|
|
UpdateDisplayFormData (
|
|
|
|
VOID
|
|
|
|
)
|
|
|
|
{
|
|
|
|
gDisplayFormData.FormTitle = gCurrentSelection->Form->FormTitle;
|
|
|
|
gDisplayFormData.FormId = gCurrentSelection->FormId;
|
|
|
|
gDisplayFormData.HiiHandle = gCurrentSelection->Handle;
|
|
|
|
CopyGuid (&gDisplayFormData.FormSetGuid, &gCurrentSelection->FormSetGuid);
|
|
|
|
|
|
|
|
gDisplayFormData.Attribute = 0;
|
|
|
|
gDisplayFormData.Attribute |= gCurrentSelection->Form->ModalForm ? HII_DISPLAY_MODAL : 0;
|
|
|
|
gDisplayFormData.Attribute |= gCurrentSelection->Form->Locked ? HII_DISPLAY_LOCK : 0;
|
|
|
|
|
|
|
|
gDisplayFormData.FormRefreshEvent = NULL;
|
|
|
|
gDisplayFormData.HighLightedStatement = NULL;
|
|
|
|
|
|
|
|
gDisplayFormData.BrowserStatus = gBrowserStatus;
|
|
|
|
gDisplayFormData.ErrorString = gErrorInfo;
|
|
|
|
|
|
|
|
gBrowserStatus = BROWSER_SUCCESS;
|
|
|
|
gErrorInfo = NULL;
|
|
|
|
|
|
|
|
UpdateDataChangedFlag ();
|
|
|
|
|
|
|
|
AddStatementToDisplayForm ();
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
|
|
|
Free the Display Statement structure data.
|
|
|
|
|
|
|
|
@param StatementList Point to the statement list which need to be free.
|
|
|
|
|
|
|
|
**/
|
|
|
|
VOID
|
|
|
|
FreeStatementData (
|
|
|
|
LIST_ENTRY *StatementList
|
|
|
|
)
|
|
|
|
{
|
|
|
|
LIST_ENTRY *Link;
|
|
|
|
LIST_ENTRY *OptionLink;
|
|
|
|
FORM_DISPLAY_ENGINE_STATEMENT *Statement;
|
|
|
|
DISPLAY_QUESTION_OPTION *Option;
|
|
|
|
|
|
|
|
//
|
|
|
|
// Free Statements/Questions
|
|
|
|
//
|
|
|
|
while (!IsListEmpty (StatementList)) {
|
|
|
|
Link = GetFirstNode (StatementList);
|
|
|
|
Statement = FORM_DISPLAY_ENGINE_STATEMENT_FROM_LINK (Link);
|
|
|
|
|
|
|
|
//
|
|
|
|
// Free Options List
|
|
|
|
//
|
|
|
|
while (!IsListEmpty (&Statement->OptionListHead)) {
|
|
|
|
OptionLink = GetFirstNode (&Statement->OptionListHead);
|
|
|
|
Option = DISPLAY_QUESTION_OPTION_FROM_LINK (OptionLink);
|
|
|
|
RemoveEntryList (&Option->Link);
|
|
|
|
FreePool (Option);
|
|
|
|
}
|
|
|
|
|
|
|
|
//
|
|
|
|
// Free nest statement List
|
|
|
|
//
|
|
|
|
if (!IsListEmpty (&Statement->NestStatementList)) {
|
|
|
|
FreeStatementData(&Statement->NestStatementList);
|
|
|
|
}
|
|
|
|
|
|
|
|
RemoveEntryList (&Statement->DisplayLink);
|
|
|
|
FreePool (Statement);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
|
|
|
Free the Display form structure data.
|
|
|
|
|
|
|
|
**/
|
|
|
|
VOID
|
|
|
|
FreeDisplayFormData (
|
|
|
|
VOID
|
|
|
|
)
|
|
|
|
{
|
|
|
|
FreeStatementData (&gDisplayFormData.StatementListHead);
|
|
|
|
FreeStatementData (&gDisplayFormData.StatementListOSF);
|
|
|
|
|
|
|
|
FreeRefreshEvent();
|
|
|
|
|
|
|
|
FreeHotkeyList();
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
|
|
|
Get FORM_BROWSER_STATEMENT from FORM_DISPLAY_ENGINE_STATEMENT based on the OpCode info.
|
|
|
|
|
|
|
|
@param DisplayStatement The input FORM_DISPLAY_ENGINE_STATEMENT.
|
|
|
|
|
|
|
|
@retval FORM_BROWSER_STATEMENT The return FORM_BROWSER_STATEMENT info.
|
|
|
|
|
|
|
|
**/
|
|
|
|
FORM_BROWSER_STATEMENT *
|
|
|
|
GetBrowserStatement (
|
|
|
|
IN FORM_DISPLAY_ENGINE_STATEMENT *DisplayStatement
|
|
|
|
)
|
|
|
|
{
|
|
|
|
FORM_BROWSER_STATEMENT *Statement;
|
|
|
|
LIST_ENTRY *Link;
|
|
|
|
|
|
|
|
Link = GetFirstNode (&gCurrentSelection->Form->StatementListHead);
|
|
|
|
while (!IsNull (&gCurrentSelection->Form->StatementListHead, Link)) {
|
|
|
|
Statement = FORM_BROWSER_STATEMENT_FROM_LINK (Link);
|
|
|
|
|
|
|
|
if (Statement->OpCode == DisplayStatement->OpCode) {
|
|
|
|
return Statement;
|
|
|
|
}
|
|
|
|
|
|
|
|
Link = GetNextNode (&gCurrentSelection->Form->StatementListHead, Link);
|
|
|
|
}
|
|
|
|
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
|
|
|
Process the action request in user input.
|
|
|
|
|
|
|
|
@param Action The user input action request info.
|
|
|
|
@param DefaultId The user input default Id info.
|
|
|
|
|
|
|
|
@retval EFI_SUCESSS This function always return successfully for now.
|
|
|
|
|
|
|
|
**/
|
|
|
|
EFI_STATUS
|
|
|
|
ProcessAction (
|
|
|
|
IN UINT32 Action,
|
|
|
|
IN UINT16 DefaultId
|
|
|
|
)
|
|
|
|
{
|
|
|
|
EFI_STATUS Status;
|
|
|
|
|
|
|
|
//
|
|
|
|
// This is caused by use press ESC, and it should not combine with other action type.
|
|
|
|
//
|
|
|
|
if ((Action & BROWSER_ACTION_FORM_EXIT) == BROWSER_ACTION_FORM_EXIT) {
|
|
|
|
FindNextMenu (gCurrentSelection, FormLevel);
|
|
|
|
return EFI_SUCCESS;
|
|
|
|
}
|
|
|
|
|
|
|
|
//
|
|
|
|
// Below is normal hotkey trigged action, these action maybe combine with each other.
|
|
|
|
//
|
|
|
|
if ((Action & BROWSER_ACTION_DISCARD) == BROWSER_ACTION_DISCARD) {
|
|
|
|
DiscardForm (gCurrentSelection->FormSet, gCurrentSelection->Form, gBrowserSettingScope);
|
|
|
|
}
|
|
|
|
|
|
|
|
if ((Action & BROWSER_ACTION_DEFAULT) == BROWSER_ACTION_DEFAULT) {
|
|
|
|
ExtractDefault (gCurrentSelection->FormSet, gCurrentSelection->Form, DefaultId, gBrowserSettingScope, GetDefaultForAll, NULL, FALSE);
|
|
|
|
}
|
|
|
|
|
|
|
|
if ((Action & BROWSER_ACTION_SUBMIT) == BROWSER_ACTION_SUBMIT) {
|
|
|
|
Status = SubmitForm (gCurrentSelection->FormSet, gCurrentSelection->Form, gBrowserSettingScope);
|
|
|
|
if (EFI_ERROR (Status)) {
|
|
|
|
gBrowserStatus = BROWSER_SUBMIT_FAIL;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if ((Action & BROWSER_ACTION_RESET) == BROWSER_ACTION_RESET) {
|
|
|
|
gResetRequired = TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
if ((Action & BROWSER_ACTION_EXIT) == BROWSER_ACTION_EXIT) {
|
|
|
|
//
|
|
|
|
// Form Exit without saving, Similar to ESC Key.
|
|
|
|
// FormSet Exit without saving, Exit SendForm.
|
|
|
|
// System Exit without saving, CallExitHandler and Exit SendForm.
|
|
|
|
//
|
|
|
|
DiscardForm (gCurrentSelection->FormSet, gCurrentSelection->Form, gBrowserSettingScope);
|
|
|
|
if (gBrowserSettingScope == FormLevel || gBrowserSettingScope == FormSetLevel) {
|
|
|
|
FindNextMenu (gCurrentSelection, gBrowserSettingScope);
|
|
|
|
} else if (gBrowserSettingScope == SystemLevel) {
|
|
|
|
if (ExitHandlerFunction != NULL) {
|
|
|
|
ExitHandlerFunction ();
|
|
|
|
}
|
|
|
|
gCurrentSelection->Action = UI_ACTION_EXIT;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return EFI_SUCCESS;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
Find HII Handle in the HII database associated with given Device Path.
|
|
|
|
|
|
|
|
If DevicePath is NULL, then ASSERT.
|
|
|
|
|
|
|
|
@param DevicePath Device Path associated with the HII package list
|
|
|
|
handle.
|
|
|
|
|
|
|
|
@retval Handle HII package list Handle associated with the Device
|
|
|
|
Path.
|
|
|
|
@retval NULL Hii Package list handle is not found.
|
|
|
|
|
|
|
|
**/
|
|
|
|
EFI_HII_HANDLE
|
|
|
|
EFIAPI
|
|
|
|
DevicePathToHiiHandle (
|
|
|
|
IN EFI_DEVICE_PATH_PROTOCOL *DevicePath
|
2008-07-15 10:35:54 +02:00
|
|
|
)
|
|
|
|
{
|
2013-08-09 07:26:47 +02:00
|
|
|
EFI_STATUS Status;
|
|
|
|
EFI_DEVICE_PATH_PROTOCOL *TmpDevicePath;
|
|
|
|
UINTN BufferSize;
|
|
|
|
UINTN HandleCount;
|
|
|
|
UINTN Index;
|
|
|
|
EFI_HANDLE Handle;
|
|
|
|
EFI_HANDLE DriverHandle;
|
|
|
|
EFI_HII_HANDLE *HiiHandles;
|
|
|
|
EFI_HII_HANDLE HiiHandle;
|
|
|
|
|
|
|
|
ASSERT (DevicePath != NULL);
|
|
|
|
|
|
|
|
TmpDevicePath = DevicePath;
|
|
|
|
//
|
|
|
|
// Locate Device Path Protocol handle buffer
|
|
|
|
//
|
|
|
|
Status = gBS->LocateDevicePath (
|
|
|
|
&gEfiDevicePathProtocolGuid,
|
|
|
|
&TmpDevicePath,
|
|
|
|
&DriverHandle
|
|
|
|
);
|
|
|
|
if (EFI_ERROR (Status) || !IsDevicePathEnd (TmpDevicePath)) {
|
|
|
|
return NULL;
|
|
|
|
}
|
2008-07-15 10:35:54 +02:00
|
|
|
|
|
|
|
//
|
2013-08-09 07:26:47 +02:00
|
|
|
// Retrieve all HII Handles from HII database
|
2008-07-15 10:35:54 +02:00
|
|
|
//
|
2013-08-09 07:26:47 +02:00
|
|
|
BufferSize = 0x1000;
|
|
|
|
HiiHandles = AllocatePool (BufferSize);
|
|
|
|
ASSERT (HiiHandles != NULL);
|
|
|
|
Status = mHiiDatabase->ListPackageLists (
|
|
|
|
mHiiDatabase,
|
|
|
|
EFI_HII_PACKAGE_TYPE_ALL,
|
|
|
|
NULL,
|
|
|
|
&BufferSize,
|
|
|
|
HiiHandles
|
|
|
|
);
|
|
|
|
if (Status == EFI_BUFFER_TOO_SMALL) {
|
|
|
|
FreePool (HiiHandles);
|
|
|
|
HiiHandles = AllocatePool (BufferSize);
|
|
|
|
ASSERT (HiiHandles != NULL);
|
|
|
|
|
|
|
|
Status = mHiiDatabase->ListPackageLists (
|
|
|
|
mHiiDatabase,
|
|
|
|
EFI_HII_PACKAGE_TYPE_ALL,
|
|
|
|
NULL,
|
|
|
|
&BufferSize,
|
|
|
|
HiiHandles
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (EFI_ERROR (Status)) {
|
|
|
|
FreePool (HiiHandles);
|
|
|
|
return NULL;
|
|
|
|
}
|
2008-07-15 10:35:54 +02:00
|
|
|
|
|
|
|
//
|
2013-08-09 07:26:47 +02:00
|
|
|
// Search Hii Handle by Driver Handle
|
2008-07-15 10:35:54 +02:00
|
|
|
//
|
2013-08-09 07:26:47 +02:00
|
|
|
HiiHandle = NULL;
|
|
|
|
HandleCount = BufferSize / sizeof (EFI_HII_HANDLE);
|
|
|
|
for (Index = 0; Index < HandleCount; Index++) {
|
|
|
|
Status = mHiiDatabase->GetPackageListHandle (
|
|
|
|
mHiiDatabase,
|
|
|
|
HiiHandles[Index],
|
|
|
|
&Handle
|
|
|
|
);
|
|
|
|
if (!EFI_ERROR (Status) && (Handle == DriverHandle)) {
|
|
|
|
HiiHandle = HiiHandles[Index];
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
FreePool (HiiHandles);
|
|
|
|
return HiiHandle;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
Find HII Handle in the HII database associated with given form set guid.
|
|
|
|
|
|
|
|
If FormSetGuid is NULL, then ASSERT.
|
|
|
|
|
|
|
|
@param ComparingGuid FormSet Guid associated with the HII package list
|
|
|
|
handle.
|
|
|
|
|
|
|
|
@retval Handle HII package list Handle associated with the Device
|
|
|
|
Path.
|
|
|
|
@retval NULL Hii Package list handle is not found.
|
2008-07-15 10:35:54 +02:00
|
|
|
|
2013-08-09 07:26:47 +02:00
|
|
|
**/
|
|
|
|
EFI_HII_HANDLE
|
|
|
|
FormSetGuidToHiiHandle (
|
|
|
|
EFI_GUID *ComparingGuid
|
|
|
|
)
|
|
|
|
{
|
|
|
|
EFI_HII_HANDLE *HiiHandles;
|
|
|
|
UINTN Index;
|
|
|
|
EFI_HII_PACKAGE_LIST_HEADER *HiiPackageList;
|
|
|
|
UINTN BufferSize;
|
|
|
|
UINT32 Offset;
|
|
|
|
UINT32 Offset2;
|
|
|
|
UINT32 PackageListLength;
|
|
|
|
EFI_HII_PACKAGE_HEADER PackageHeader;
|
|
|
|
UINT8 *Package;
|
|
|
|
UINT8 *OpCodeData;
|
|
|
|
EFI_STATUS Status;
|
|
|
|
EFI_HII_HANDLE HiiHandle;
|
|
|
|
|
|
|
|
ASSERT (ComparingGuid != NULL);
|
|
|
|
|
|
|
|
HiiHandle = NULL;
|
2008-07-15 10:35:54 +02:00
|
|
|
//
|
2013-08-09 07:26:47 +02:00
|
|
|
// Get all the Hii handles
|
2008-07-15 10:35:54 +02:00
|
|
|
//
|
2013-08-09 07:26:47 +02:00
|
|
|
HiiHandles = HiiGetHiiHandles (NULL);
|
|
|
|
ASSERT (HiiHandles != NULL);
|
2008-07-15 10:35:54 +02:00
|
|
|
|
|
|
|
//
|
2013-08-09 07:26:47 +02:00
|
|
|
// Search for formset of each class type
|
2008-07-15 10:35:54 +02:00
|
|
|
//
|
2013-08-09 07:26:47 +02:00
|
|
|
for (Index = 0; HiiHandles[Index] != NULL; Index++) {
|
|
|
|
BufferSize = 0;
|
|
|
|
HiiPackageList = NULL;
|
|
|
|
Status = mHiiDatabase->ExportPackageLists (mHiiDatabase, HiiHandles[Index], &BufferSize, HiiPackageList);
|
|
|
|
if (Status == EFI_BUFFER_TOO_SMALL) {
|
|
|
|
HiiPackageList = AllocatePool (BufferSize);
|
|
|
|
ASSERT (HiiPackageList != NULL);
|
|
|
|
|
|
|
|
Status = mHiiDatabase->ExportPackageLists (mHiiDatabase, HiiHandles[Index], &BufferSize, HiiPackageList);
|
|
|
|
}
|
|
|
|
if (EFI_ERROR (Status) || HiiPackageList == NULL) {
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
//
|
|
|
|
// Get Form package from this HII package List
|
|
|
|
//
|
|
|
|
Offset = sizeof (EFI_HII_PACKAGE_LIST_HEADER);
|
|
|
|
Offset2 = 0;
|
|
|
|
CopyMem (&PackageListLength, &HiiPackageList->PackageLength, sizeof (UINT32));
|
|
|
|
|
|
|
|
while (Offset < PackageListLength) {
|
|
|
|
Package = ((UINT8 *) HiiPackageList) + Offset;
|
|
|
|
CopyMem (&PackageHeader, Package, sizeof (EFI_HII_PACKAGE_HEADER));
|
|
|
|
|
|
|
|
if (PackageHeader.Type == EFI_HII_PACKAGE_FORMS) {
|
|
|
|
//
|
|
|
|
// Search FormSet in this Form Package
|
|
|
|
//
|
|
|
|
Offset2 = sizeof (EFI_HII_PACKAGE_HEADER);
|
|
|
|
while (Offset2 < PackageHeader.Length) {
|
|
|
|
OpCodeData = Package + Offset2;
|
|
|
|
|
|
|
|
if (((EFI_IFR_OP_HEADER *) OpCodeData)->OpCode == EFI_IFR_FORM_SET_OP) {
|
|
|
|
//
|
|
|
|
// Try to compare against formset GUID
|
|
|
|
//
|
|
|
|
if (CompareGuid (ComparingGuid, (EFI_GUID *)(OpCodeData + sizeof (EFI_IFR_OP_HEADER)))) {
|
|
|
|
HiiHandle = HiiHandles[Index];
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
Offset2 += ((EFI_IFR_OP_HEADER *) OpCodeData)->Length;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (HiiHandle != NULL) {
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
Offset += PackageHeader.Length;
|
|
|
|
}
|
|
|
|
|
|
|
|
FreePool (HiiPackageList);
|
|
|
|
if (HiiHandle != NULL) {
|
|
|
|
break;
|
|
|
|
}
|
2008-07-15 10:35:54 +02:00
|
|
|
}
|
|
|
|
|
2013-08-09 07:26:47 +02:00
|
|
|
FreePool (HiiHandles);
|
2008-07-15 10:35:54 +02:00
|
|
|
|
2013-08-09 07:26:47 +02:00
|
|
|
return HiiHandle;
|
2008-07-15 10:35:54 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2013-08-09 07:26:47 +02:00
|
|
|
check how to process the changed data in current form or form set.
|
|
|
|
|
|
|
|
@param Selection On input, Selection tell setup browser the information
|
|
|
|
about the Selection, form and formset to be displayed.
|
|
|
|
On output, Selection return the screen item that is selected
|
|
|
|
by user.
|
2008-07-15 10:35:54 +02:00
|
|
|
|
2013-08-09 07:26:47 +02:00
|
|
|
@param Scope Data save or discard scope, form or formset.
|
2008-07-15 10:35:54 +02:00
|
|
|
|
2013-08-09 07:26:47 +02:00
|
|
|
@retval TRUE Success process the changed data, will return to the parent form.
|
|
|
|
@retval FALSE Reject to process the changed data, will stay at current form.
|
2008-07-15 10:35:54 +02:00
|
|
|
**/
|
2013-08-09 07:26:47 +02:00
|
|
|
BOOLEAN
|
|
|
|
ProcessChangedData (
|
|
|
|
IN OUT UI_MENU_SELECTION *Selection,
|
|
|
|
IN BROWSER_SETTING_SCOPE Scope
|
2008-07-15 10:35:54 +02:00
|
|
|
)
|
|
|
|
{
|
2013-08-09 07:26:47 +02:00
|
|
|
BOOLEAN RetValue;
|
2008-07-15 10:35:54 +02:00
|
|
|
|
2013-08-09 07:26:47 +02:00
|
|
|
RetValue = TRUE;
|
|
|
|
switch (mFormDisplay->ConfirmDataChange()) {
|
|
|
|
case BROWSER_ACTION_DISCARD:
|
|
|
|
DiscardForm (Selection->FormSet, Selection->Form, Scope);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case BROWSER_ACTION_SUBMIT:
|
|
|
|
SubmitForm (Selection->FormSet, Selection->Form, Scope);
|
|
|
|
break;
|
2008-07-15 10:35:54 +02:00
|
|
|
|
2013-08-09 07:26:47 +02:00
|
|
|
case BROWSER_ACTION_NONE:
|
|
|
|
RetValue = FALSE;
|
|
|
|
break;
|
2008-07-15 10:35:54 +02:00
|
|
|
|
2013-08-09 07:26:47 +02:00
|
|
|
default:
|
|
|
|
//
|
|
|
|
// if Invalid value return, process same as BROWSER_ACTION_NONE.
|
|
|
|
//
|
|
|
|
RetValue = FALSE;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
return RetValue;
|
2008-07-15 10:35:54 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2013-08-09 07:26:47 +02:00
|
|
|
Find parent formset menu(the first menu which has different formset) for current menu.
|
|
|
|
If not find, just return to the first menu.
|
2008-07-15 10:35:54 +02:00
|
|
|
|
2013-08-09 07:26:47 +02:00
|
|
|
@param Selection The selection info.
|
2008-07-15 10:35:54 +02:00
|
|
|
|
|
|
|
**/
|
2013-08-09 07:26:47 +02:00
|
|
|
VOID
|
|
|
|
FindParentFormSet (
|
|
|
|
IN OUT UI_MENU_SELECTION *Selection
|
2008-07-15 10:35:54 +02:00
|
|
|
)
|
|
|
|
{
|
2013-08-09 07:26:47 +02:00
|
|
|
FORM_ENTRY_INFO *CurrentMenu;
|
|
|
|
FORM_ENTRY_INFO *ParentMenu;
|
2008-07-15 10:35:54 +02:00
|
|
|
|
2013-08-09 07:26:47 +02:00
|
|
|
CurrentMenu = Selection->CurrentMenu;
|
|
|
|
ParentMenu = UiFindParentMenu(CurrentMenu);
|
2008-07-15 10:35:54 +02:00
|
|
|
|
|
|
|
//
|
2013-08-09 07:26:47 +02:00
|
|
|
// Find a menu which has different formset guid with current.
|
2008-07-15 10:35:54 +02:00
|
|
|
//
|
2013-08-09 07:26:47 +02:00
|
|
|
while (ParentMenu != NULL && CompareGuid (&CurrentMenu->FormSetGuid, &ParentMenu->FormSetGuid)) {
|
|
|
|
CurrentMenu = ParentMenu;
|
|
|
|
ParentMenu = UiFindParentMenu(CurrentMenu);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (ParentMenu != NULL) {
|
|
|
|
CopyMem (&Selection->FormSetGuid, &ParentMenu->FormSetGuid, sizeof (EFI_GUID));
|
|
|
|
Selection->Handle = ParentMenu->HiiHandle;
|
|
|
|
Selection->FormId = ParentMenu->FormId;
|
|
|
|
Selection->QuestionId = ParentMenu->QuestionId;
|
|
|
|
} else {
|
|
|
|
Selection->FormId = CurrentMenu->FormId;
|
|
|
|
Selection->QuestionId = CurrentMenu->QuestionId;
|
|
|
|
}
|
2008-07-15 10:35:54 +02:00
|
|
|
|
2013-08-09 07:26:47 +02:00
|
|
|
Selection->Statement = NULL;
|
2008-07-15 10:35:54 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2013-08-09 07:26:47 +02:00
|
|
|
Process the goto op code, update the info in the selection structure.
|
2008-07-15 10:35:54 +02:00
|
|
|
|
2013-08-09 07:26:47 +02:00
|
|
|
@param Statement The statement belong to goto op code.
|
|
|
|
@param Selection The selection info.
|
|
|
|
|
|
|
|
@retval EFI_SUCCESS The menu process successfully.
|
|
|
|
@return Other value if the process failed.
|
2008-07-15 10:35:54 +02:00
|
|
|
**/
|
2013-08-09 07:26:47 +02:00
|
|
|
EFI_STATUS
|
|
|
|
ProcessGotoOpCode (
|
|
|
|
IN OUT FORM_BROWSER_STATEMENT *Statement,
|
|
|
|
IN OUT UI_MENU_SELECTION *Selection
|
2008-07-15 10:35:54 +02:00
|
|
|
)
|
|
|
|
{
|
2013-08-09 07:26:47 +02:00
|
|
|
CHAR16 *StringPtr;
|
|
|
|
EFI_DEVICE_PATH_PROTOCOL *DevicePath;
|
|
|
|
FORM_BROWSER_FORM *RefForm;
|
|
|
|
EFI_STATUS Status;
|
|
|
|
EFI_HII_HANDLE HiiHandle;
|
|
|
|
|
|
|
|
Status = EFI_SUCCESS;
|
|
|
|
StringPtr = NULL;
|
|
|
|
HiiHandle = NULL;
|
2008-07-15 10:35:54 +02:00
|
|
|
|
|
|
|
//
|
2013-08-09 07:26:47 +02:00
|
|
|
// Prepare the device path check, get the device path info first.
|
2008-07-15 10:35:54 +02:00
|
|
|
//
|
2013-08-09 07:26:47 +02:00
|
|
|
if (Statement->HiiValue.Value.ref.DevicePath != 0) {
|
|
|
|
StringPtr = GetToken (Statement->HiiValue.Value.ref.DevicePath, Selection->FormSet->HiiHandle);
|
2008-07-15 10:35:54 +02:00
|
|
|
}
|
|
|
|
|
2013-08-09 07:26:47 +02:00
|
|
|
//
|
|
|
|
// Check whether the device path string is a valid string.
|
|
|
|
//
|
|
|
|
if (Statement->HiiValue.Value.ref.DevicePath != 0 && StringPtr != NULL) {
|
|
|
|
if (Selection->Form->ModalForm) {
|
|
|
|
return Status;
|
|
|
|
}
|
|
|
|
|
2008-07-15 10:35:54 +02:00
|
|
|
//
|
2013-08-09 07:26:47 +02:00
|
|
|
// Goto another Hii Package list
|
2008-07-15 10:35:54 +02:00
|
|
|
//
|
2013-08-09 07:26:47 +02:00
|
|
|
if (mPathFromText != NULL) {
|
|
|
|
DevicePath = mPathFromText->ConvertTextToDevicePath(StringPtr);
|
|
|
|
if (DevicePath != NULL) {
|
|
|
|
HiiHandle = DevicePathToHiiHandle (DevicePath);
|
|
|
|
FreePool (DevicePath);
|
|
|
|
}
|
|
|
|
FreePool (StringPtr);
|
|
|
|
} else {
|
2008-07-15 10:35:54 +02:00
|
|
|
//
|
2013-08-09 07:26:47 +02:00
|
|
|
// Not found the EFI_DEVICE_PATH_FROM_TEXT_PROTOCOL protocol.
|
2008-07-15 10:35:54 +02:00
|
|
|
//
|
2013-08-09 07:26:47 +02:00
|
|
|
gBrowserStatus = BROWSER_PROTOCOL_NOT_FOUND;
|
|
|
|
FreePool (StringPtr);
|
|
|
|
return Status;
|
|
|
|
}
|
2008-07-15 10:35:54 +02:00
|
|
|
|
2013-08-09 07:26:47 +02:00
|
|
|
if (HiiHandle != Selection->Handle) {
|
|
|
|
//
|
|
|
|
// Goto another Formset, check for uncommitted data
|
|
|
|
//
|
|
|
|
if ((gBrowserSettingScope == FormLevel || gBrowserSettingScope == FormSetLevel) &&
|
|
|
|
IsNvUpdateRequiredForFormSet(Selection->FormSet)) {
|
|
|
|
if (!ProcessChangedData(Selection, FormSetLevel)) {
|
|
|
|
return EFI_SUCCESS;
|
2008-07-15 10:35:54 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-08-09 07:26:47 +02:00
|
|
|
Selection->Action = UI_ACTION_REFRESH_FORMSET;
|
|
|
|
Selection->Handle = HiiHandle;
|
|
|
|
if (Selection->Handle == NULL) {
|
|
|
|
//
|
|
|
|
// If target Hii Handle not found, exit current formset.
|
|
|
|
//
|
|
|
|
FindParentFormSet(Selection);
|
|
|
|
return EFI_SUCCESS;
|
2008-07-15 10:35:54 +02:00
|
|
|
}
|
|
|
|
|
2013-08-09 07:26:47 +02:00
|
|
|
CopyMem (&Selection->FormSetGuid,&Statement->HiiValue.Value.ref.FormSetGuid, sizeof (EFI_GUID));
|
|
|
|
Selection->FormId = Statement->HiiValue.Value.ref.FormId;
|
|
|
|
Selection->QuestionId = Statement->HiiValue.Value.ref.QuestionId;
|
|
|
|
} else if (!CompareGuid (&Statement->HiiValue.Value.ref.FormSetGuid, &gZeroGuid)) {
|
|
|
|
if (Selection->Form->ModalForm) {
|
|
|
|
return Status;
|
|
|
|
}
|
|
|
|
if (!CompareGuid (&Statement->HiiValue.Value.ref.FormSetGuid, &Selection->FormSetGuid)) {
|
2008-07-15 10:35:54 +02:00
|
|
|
//
|
2013-08-09 07:26:47 +02:00
|
|
|
// Goto another Formset, check for uncommitted data
|
2008-07-15 10:35:54 +02:00
|
|
|
//
|
2013-08-09 07:26:47 +02:00
|
|
|
if ((gBrowserSettingScope == FormLevel || gBrowserSettingScope == FormSetLevel) &&
|
|
|
|
IsNvUpdateRequiredForFormSet(Selection->FormSet)) {
|
|
|
|
if (!ProcessChangedData(Selection, FormSetLevel)) {
|
|
|
|
return EFI_SUCCESS;
|
|
|
|
}
|
2008-07-15 10:35:54 +02:00
|
|
|
}
|
2013-08-09 07:26:47 +02:00
|
|
|
}
|
2008-07-15 10:35:54 +02:00
|
|
|
|
2013-08-09 07:26:47 +02:00
|
|
|
Selection->Action = UI_ACTION_REFRESH_FORMSET;
|
|
|
|
Selection->Handle = FormSetGuidToHiiHandle(&Statement->HiiValue.Value.ref.FormSetGuid);
|
|
|
|
if (Selection->Handle == NULL) {
|
|
|
|
//
|
|
|
|
// If target Hii Handle not found, exit current formset.
|
|
|
|
//
|
|
|
|
FindParentFormSet(Selection);
|
|
|
|
return EFI_SUCCESS;
|
|
|
|
}
|
2008-07-15 10:35:54 +02:00
|
|
|
|
2013-08-09 07:26:47 +02:00
|
|
|
CopyMem (&Selection->FormSetGuid, &Statement->HiiValue.Value.ref.FormSetGuid, sizeof (EFI_GUID));
|
|
|
|
Selection->FormId = Statement->HiiValue.Value.ref.FormId;
|
|
|
|
Selection->QuestionId = Statement->HiiValue.Value.ref.QuestionId;
|
|
|
|
} else if (Statement->HiiValue.Value.ref.FormId != 0) {
|
|
|
|
//
|
|
|
|
// Goto another Form, check for uncommitted data
|
|
|
|
//
|
|
|
|
if (Statement->HiiValue.Value.ref.FormId != Selection->FormId) {
|
|
|
|
if ((gBrowserSettingScope == FormLevel && IsNvUpdateRequiredForForm(Selection->Form))) {
|
|
|
|
if (!ProcessChangedData (Selection, FormLevel)) {
|
|
|
|
return EFI_SUCCESS;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2008-07-15 10:35:54 +02:00
|
|
|
|
2013-08-09 07:26:47 +02:00
|
|
|
RefForm = IdToForm (Selection->FormSet, Statement->HiiValue.Value.ref.FormId);
|
|
|
|
if ((RefForm != NULL) && (RefForm->SuppressExpression != NULL)) {
|
|
|
|
if (EvaluateExpressionList(RefForm->SuppressExpression, TRUE, Selection->FormSet, RefForm) != ExpressFalse) {
|
|
|
|
//
|
|
|
|
// Form is suppressed.
|
|
|
|
//
|
|
|
|
gBrowserStatus = BROWSER_FORM_SUPPRESS;
|
|
|
|
return EFI_SUCCESS;
|
|
|
|
}
|
2008-07-15 10:35:54 +02:00
|
|
|
}
|
|
|
|
|
2013-08-09 07:26:47 +02:00
|
|
|
Selection->FormId = Statement->HiiValue.Value.ref.FormId;
|
|
|
|
Selection->QuestionId = Statement->HiiValue.Value.ref.QuestionId;
|
|
|
|
} else if (Statement->HiiValue.Value.ref.QuestionId != 0) {
|
|
|
|
Selection->QuestionId = Statement->HiiValue.Value.ref.QuestionId;
|
|
|
|
}
|
2008-07-15 10:35:54 +02:00
|
|
|
|
2013-08-09 07:26:47 +02:00
|
|
|
return Status;
|
2008-07-15 10:35:54 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
2013-08-09 07:26:47 +02:00
|
|
|
Process Question Config.
|
2008-07-15 10:35:54 +02:00
|
|
|
|
2013-08-09 07:26:47 +02:00
|
|
|
@param Selection The UI menu selection.
|
|
|
|
@param Question The Question to be peocessed.
|
2008-07-15 10:35:54 +02:00
|
|
|
|
2013-08-09 07:26:47 +02:00
|
|
|
@retval EFI_SUCCESS Question Config process success.
|
|
|
|
@retval Other Question Config process fail.
|
2008-07-15 10:35:54 +02:00
|
|
|
|
|
|
|
**/
|
|
|
|
EFI_STATUS
|
2013-08-09 07:26:47 +02:00
|
|
|
ProcessQuestionConfig (
|
|
|
|
IN UI_MENU_SELECTION *Selection,
|
|
|
|
IN FORM_BROWSER_STATEMENT *Question
|
2008-07-15 10:35:54 +02:00
|
|
|
)
|
|
|
|
{
|
2013-08-09 07:26:47 +02:00
|
|
|
EFI_STATUS Status;
|
|
|
|
CHAR16 *ConfigResp;
|
|
|
|
CHAR16 *Progress;
|
|
|
|
EFI_HII_CONFIG_ACCESS_PROTOCOL *ConfigAccess;
|
2008-07-15 10:35:54 +02:00
|
|
|
|
2013-08-09 07:26:47 +02:00
|
|
|
if (Question->QuestionConfig == 0) {
|
|
|
|
return EFI_SUCCESS;
|
|
|
|
}
|
2008-07-15 10:35:54 +02:00
|
|
|
|
2013-08-09 07:26:47 +02:00
|
|
|
//
|
|
|
|
// Get <ConfigResp>
|
|
|
|
//
|
|
|
|
ConfigResp = GetToken (Question->QuestionConfig, Selection->FormSet->HiiHandle);
|
|
|
|
if (ConfigResp == NULL) {
|
|
|
|
return EFI_NOT_FOUND;
|
|
|
|
}
|
2008-07-15 10:35:54 +02:00
|
|
|
|
2013-08-09 07:26:47 +02:00
|
|
|
//
|
|
|
|
// Send config to Configuration Driver
|
|
|
|
//
|
|
|
|
ConfigAccess = Selection->FormSet->ConfigAccess;
|
|
|
|
if (ConfigAccess == NULL) {
|
|
|
|
return EFI_UNSUPPORTED;
|
2008-07-15 10:35:54 +02:00
|
|
|
}
|
2013-08-09 07:26:47 +02:00
|
|
|
Status = ConfigAccess->RouteConfig (
|
|
|
|
ConfigAccess,
|
|
|
|
ConfigResp,
|
|
|
|
&Progress
|
|
|
|
);
|
2008-07-15 10:35:54 +02:00
|
|
|
|
2013-08-09 07:26:47 +02:00
|
|
|
return Status;
|
2008-07-15 10:35:54 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
2013-08-09 07:26:47 +02:00
|
|
|
Process the user input data.
|
2009-10-26 04:03:12 +01:00
|
|
|
|
2013-08-09 07:26:47 +02:00
|
|
|
@param UserInput The user input data.
|
|
|
|
@param ChangeHighlight Whether need to change the highlight statement.
|
2009-10-26 04:03:12 +01:00
|
|
|
|
2008-07-15 10:35:54 +02:00
|
|
|
@retval EFI_SUCESSS This function always return successfully for now.
|
|
|
|
|
|
|
|
**/
|
|
|
|
EFI_STATUS
|
2013-08-09 07:26:47 +02:00
|
|
|
ProcessUserInput (
|
|
|
|
IN USER_INPUT *UserInput,
|
|
|
|
IN BOOLEAN ChangeHighlight
|
2008-07-15 10:35:54 +02:00
|
|
|
)
|
|
|
|
{
|
2013-08-09 07:26:47 +02:00
|
|
|
EFI_STATUS Status;
|
|
|
|
FORM_BROWSER_STATEMENT *Statement;
|
2008-07-15 10:35:54 +02:00
|
|
|
|
2013-08-09 07:26:47 +02:00
|
|
|
Status = EFI_SUCCESS;
|
2008-07-15 10:35:54 +02:00
|
|
|
|
|
|
|
//
|
2013-08-09 07:26:47 +02:00
|
|
|
// When Exit from FormDisplay function, one of the below two cases must be true.
|
2008-07-15 10:35:54 +02:00
|
|
|
//
|
2013-08-09 07:26:47 +02:00
|
|
|
ASSERT (UserInput->Action != 0 || UserInput->SelectedStatement != NULL);
|
2008-07-15 10:35:54 +02:00
|
|
|
|
|
|
|
//
|
2013-08-09 07:26:47 +02:00
|
|
|
// Remove the last highligh question id, this id will update when show next form.
|
2008-07-15 10:35:54 +02:00
|
|
|
//
|
2013-08-09 07:26:47 +02:00
|
|
|
gCurrentSelection->QuestionId = 0;
|
2008-07-15 10:35:54 +02:00
|
|
|
|
2013-08-09 07:26:47 +02:00
|
|
|
//
|
|
|
|
// First process the Action field in USER_INPUT.
|
|
|
|
//
|
|
|
|
if (UserInput->Action != 0) {
|
|
|
|
Status = ProcessAction (UserInput->Action, UserInput->DefaultId);
|
|
|
|
if (EFI_ERROR (Status)) {
|
|
|
|
return Status;
|
|
|
|
}
|
2008-07-15 10:35:54 +02:00
|
|
|
|
2013-08-09 07:26:47 +02:00
|
|
|
//
|
|
|
|
// Clear the highlight info.
|
|
|
|
//
|
|
|
|
gCurrentSelection->Statement = NULL;
|
2008-07-15 10:35:54 +02:00
|
|
|
|
2013-08-09 07:26:47 +02:00
|
|
|
if (UserInput->SelectedStatement != NULL) {
|
|
|
|
Statement = GetBrowserStatement(UserInput->SelectedStatement);
|
|
|
|
ASSERT (Statement != NULL);
|
|
|
|
//
|
|
|
|
// Save the current highlight menu in the menu history data.
|
|
|
|
// which will be used when later browse back to this form.
|
|
|
|
//
|
|
|
|
gCurrentSelection->CurrentMenu->QuestionId = Statement->QuestionId;
|
|
|
|
//
|
|
|
|
// For statement like text, actio, it not has question id.
|
|
|
|
// So use FakeQuestionId to save the question.
|
|
|
|
//
|
|
|
|
if (gCurrentSelection->CurrentMenu->QuestionId == 0) {
|
|
|
|
mCurFakeQestId = Statement->FakeQuestionId;
|
|
|
|
} else {
|
|
|
|
mCurFakeQestId = 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
Statement = GetBrowserStatement(UserInput->SelectedStatement);
|
|
|
|
ASSERT (Statement != NULL);
|
2008-07-15 10:35:54 +02:00
|
|
|
|
2013-08-09 07:26:47 +02:00
|
|
|
gCurrentSelection->Statement = Statement;
|
2008-07-15 10:35:54 +02:00
|
|
|
|
2013-08-09 07:26:47 +02:00
|
|
|
if (ChangeHighlight) {
|
|
|
|
//
|
|
|
|
// This question is the current user select one,record it and later
|
|
|
|
// show it as the highlight question.
|
|
|
|
//
|
|
|
|
gCurrentSelection->CurrentMenu->QuestionId = Statement->QuestionId;
|
|
|
|
//
|
|
|
|
// For statement like text, actio, it not has question id.
|
|
|
|
// So use FakeQuestionId to save the question.
|
|
|
|
//
|
|
|
|
if (gCurrentSelection->CurrentMenu->QuestionId == 0) {
|
|
|
|
mCurFakeQestId = Statement->FakeQuestionId;
|
|
|
|
} else {
|
|
|
|
mCurFakeQestId = 0;
|
2008-07-15 10:35:54 +02:00
|
|
|
}
|
2013-08-09 07:26:47 +02:00
|
|
|
}
|
2008-07-15 10:35:54 +02:00
|
|
|
|
2013-08-09 07:26:47 +02:00
|
|
|
switch (Statement->Operand) {
|
|
|
|
case EFI_IFR_REF_OP:
|
|
|
|
Status = ProcessGotoOpCode(Statement, gCurrentSelection);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case EFI_IFR_ACTION_OP:
|
|
|
|
//
|
|
|
|
// Process the Config string <ConfigResp>
|
|
|
|
//
|
|
|
|
Status = ProcessQuestionConfig (gCurrentSelection, Statement);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case EFI_IFR_RESET_BUTTON_OP:
|
2008-07-15 10:35:54 +02:00
|
|
|
//
|
2013-08-09 07:26:47 +02:00
|
|
|
// Reset Question to default value specified by DefaultId
|
2008-07-15 10:35:54 +02:00
|
|
|
//
|
2013-08-09 07:26:47 +02:00
|
|
|
Status = ExtractDefault (gCurrentSelection->FormSet, NULL, Statement->DefaultId, FormSetLevel, GetDefaultForAll, NULL, FALSE);
|
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
switch (Statement->Operand) {
|
|
|
|
case EFI_IFR_STRING_OP:
|
|
|
|
DeleteString(Statement->HiiValue.Value.string, gCurrentSelection->FormSet->HiiHandle);
|
|
|
|
Statement->HiiValue.Value.string = UserInput->InputValue.Value.string;
|
|
|
|
CopyMem (Statement->BufferValue, UserInput->InputValue.Buffer, (UINTN) UserInput->InputValue.BufferLen);
|
|
|
|
FreePool (UserInput->InputValue.Buffer);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case EFI_IFR_PASSWORD_OP:
|
|
|
|
if (UserInput->InputValue.Buffer == NULL) {
|
|
|
|
//
|
|
|
|
// User not input new password, just return.
|
|
|
|
//
|
|
|
|
break;
|
|
|
|
}
|
2009-10-26 04:05:16 +01:00
|
|
|
|
2013-08-09 07:26:47 +02:00
|
|
|
DeleteString(Statement->HiiValue.Value.string, gCurrentSelection->FormSet->HiiHandle);
|
|
|
|
Statement->HiiValue.Value.string = UserInput->InputValue.Value.string;
|
|
|
|
CopyMem (Statement->BufferValue, UserInput->InputValue.Buffer, (UINTN) UserInput->InputValue.BufferLen);
|
|
|
|
FreePool (UserInput->InputValue.Buffer);
|
2009-10-26 04:05:16 +01:00
|
|
|
//
|
2013-08-09 07:26:47 +02:00
|
|
|
// Two password match, send it to Configuration Driver
|
2009-10-26 04:05:16 +01:00
|
|
|
//
|
2013-08-09 07:26:47 +02:00
|
|
|
if ((Statement->QuestionFlags & EFI_IFR_FLAG_CALLBACK) != 0) {
|
|
|
|
PasswordCheck (NULL, UserInput->SelectedStatement, (CHAR16 *) Statement->BufferValue);
|
|
|
|
//
|
|
|
|
// Clean the value after saved it.
|
|
|
|
//
|
|
|
|
ZeroMem (Statement->BufferValue, (UINTN) UserInput->InputValue.BufferLen);
|
|
|
|
HiiSetString (gCurrentSelection->FormSet->HiiHandle, Statement->HiiValue.Value.string, (CHAR16*)Statement->BufferValue, NULL);
|
|
|
|
} else {
|
|
|
|
SetQuestionValue (gCurrentSelection->FormSet, gCurrentSelection->Form, Statement, GetSetValueWithHiiDriver);
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
case EFI_IFR_ORDERED_LIST_OP:
|
|
|
|
CopyMem (Statement->BufferValue, UserInput->InputValue.Buffer, UserInput->InputValue.BufferLen);
|
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
CopyMem (&Statement->HiiValue, &UserInput->InputValue, sizeof (EFI_HII_VALUE));
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
if (Statement->Operand != EFI_IFR_PASSWORD_OP) {
|
|
|
|
SetQuestionValue (gCurrentSelection->FormSet, gCurrentSelection->Form, Statement, GetSetValueWithEditBuffer);
|
2009-10-26 04:05:16 +01:00
|
|
|
}
|
2013-08-09 07:26:47 +02:00
|
|
|
break;
|
2008-07-15 10:35:54 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return Status;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
2013-08-09 07:26:47 +02:00
|
|
|
Display form and wait for user to select one menu option, then return it.
|
2008-07-15 10:35:54 +02:00
|
|
|
|
2013-08-09 07:26:47 +02:00
|
|
|
@retval EFI_SUCESSS This function always return successfully for now.
|
2011-09-13 11:32:54 +02:00
|
|
|
|
|
|
|
**/
|
2013-08-09 07:26:47 +02:00
|
|
|
EFI_STATUS
|
|
|
|
DisplayForm (
|
2011-09-13 11:32:54 +02:00
|
|
|
VOID
|
|
|
|
)
|
|
|
|
{
|
2013-08-09 07:26:47 +02:00
|
|
|
EFI_STATUS Status;
|
|
|
|
USER_INPUT UserInput;
|
|
|
|
FORM_ENTRY_INFO *CurrentMenu;
|
|
|
|
BOOLEAN ChangeHighlight;
|
2011-09-13 11:32:54 +02:00
|
|
|
|
2013-08-09 07:26:47 +02:00
|
|
|
ZeroMem (&UserInput, sizeof (USER_INPUT));
|
2011-09-13 11:32:54 +02:00
|
|
|
|
|
|
|
//
|
2013-08-09 07:26:47 +02:00
|
|
|
// Update the menu history data.
|
2011-09-13 11:32:54 +02:00
|
|
|
//
|
2013-08-09 07:26:47 +02:00
|
|
|
CurrentMenu = UiFindMenuList (gCurrentSelection->Handle, &gCurrentSelection->FormSetGuid, gCurrentSelection->FormId);
|
|
|
|
if (CurrentMenu == NULL) {
|
2011-09-13 11:32:54 +02:00
|
|
|
//
|
2013-08-09 07:26:47 +02:00
|
|
|
// Current menu not found, add it to the menu tree
|
2011-09-13 11:32:54 +02:00
|
|
|
//
|
2013-08-09 07:26:47 +02:00
|
|
|
CurrentMenu = UiAddMenuList (gCurrentSelection->Handle, &gCurrentSelection->FormSetGuid,
|
|
|
|
gCurrentSelection->FormId, gCurrentSelection->QuestionId);
|
|
|
|
ASSERT (CurrentMenu != NULL);
|
|
|
|
}
|
|
|
|
gCurrentSelection->CurrentMenu = CurrentMenu;
|
2011-09-13 11:32:54 +02:00
|
|
|
|
2013-08-09 07:26:47 +02:00
|
|
|
//
|
|
|
|
// Find currrent highlight statement.
|
|
|
|
//
|
|
|
|
if (gCurrentSelection->QuestionId == 0) {
|
2011-09-13 11:32:54 +02:00
|
|
|
//
|
2013-08-09 07:26:47 +02:00
|
|
|
// Highlight not specified, fetch it from cached menu
|
2011-09-13 11:32:54 +02:00
|
|
|
//
|
2013-08-09 07:26:47 +02:00
|
|
|
gCurrentSelection->QuestionId = CurrentMenu->QuestionId;
|
2011-09-13 11:32:54 +02:00
|
|
|
}
|
2011-06-08 09:27:39 +02:00
|
|
|
|
2013-08-09 07:26:47 +02:00
|
|
|
//
|
|
|
|
// Evaluate all the Expressions in this Form
|
|
|
|
//
|
|
|
|
Status = EvaluateFormExpressions (gCurrentSelection->FormSet, gCurrentSelection->Form);
|
|
|
|
if (EFI_ERROR (Status)) {
|
|
|
|
return Status;
|
2011-06-08 09:27:39 +02:00
|
|
|
}
|
|
|
|
|
2013-08-09 07:26:47 +02:00
|
|
|
UpdateDisplayFormData ();
|
2008-07-15 10:35:54 +02:00
|
|
|
|
2013-08-09 07:26:47 +02:00
|
|
|
//
|
|
|
|
// Three possible status maybe return.
|
|
|
|
//
|
|
|
|
// EFI_INVALID_PARAMETER: The input dimension info is not valid.
|
|
|
|
// EFI_NOT_FOUND: The input value for oneof/orderedlist opcode is not valid
|
|
|
|
// and an valid value has return.
|
|
|
|
// EFI_SUCCESS: Success shows form and get user input in UserInput paramenter.
|
|
|
|
//
|
|
|
|
Status = mFormDisplay->FormDisplay (&gDisplayFormData, &UserInput);
|
|
|
|
if (EFI_ERROR (Status) && Status != EFI_NOT_FOUND) {
|
|
|
|
FreeDisplayFormData();
|
|
|
|
return Status;
|
|
|
|
}
|
2008-07-15 10:35:54 +02:00
|
|
|
|
2013-08-09 07:26:47 +02:00
|
|
|
//
|
|
|
|
// If status is EFI_SUCCESS, means user has change the highlight menu and new user input return.
|
|
|
|
// in this case, browser need to change the highlight menu.
|
|
|
|
// If status is EFI_NOT_FOUND, means the input DisplayFormData has error for oneof/orderedlist
|
|
|
|
// opcode and new valid value has return, browser core need to adjust
|
|
|
|
// value for this opcode and shows this form again.
|
|
|
|
//
|
|
|
|
ChangeHighlight = (Status == EFI_SUCCESS ? TRUE :FALSE);
|
2008-07-15 10:35:54 +02:00
|
|
|
|
2013-08-09 07:26:47 +02:00
|
|
|
Status = ProcessUserInput (&UserInput, ChangeHighlight);
|
2008-07-15 10:35:54 +02:00
|
|
|
|
2013-08-09 07:26:47 +02:00
|
|
|
FreeDisplayFormData();
|
2008-07-15 10:35:54 +02:00
|
|
|
|
2013-08-09 07:26:47 +02:00
|
|
|
return Status;
|
2008-07-15 10:35:54 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
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.
|
|
|
|
|
|
|
|
**/
|
|
|
|
EFI_STATUS
|
2009-04-10 22:58:18 +02:00
|
|
|
EFIAPI
|
2008-07-15 10:35:54 +02:00
|
|
|
FormUpdateNotify (
|
|
|
|
IN UINT8 PackageType,
|
|
|
|
IN CONST EFI_GUID *PackageGuid,
|
|
|
|
IN CONST EFI_HII_PACKAGE_HEADER *Package,
|
|
|
|
IN EFI_HII_HANDLE Handle,
|
|
|
|
IN EFI_HII_DATABASE_NOTIFY_TYPE NotifyType
|
|
|
|
)
|
|
|
|
{
|
|
|
|
mHiiPackageListUpdated = TRUE;
|
|
|
|
|
|
|
|
return EFI_SUCCESS;
|
|
|
|
}
|
|
|
|
|
2011-05-31 02:59:15 +02:00
|
|
|
/**
|
2013-08-09 07:26:47 +02:00
|
|
|
Update the NV flag info for this form set.
|
2011-05-31 02:59:15 +02:00
|
|
|
|
|
|
|
@param FormSet FormSet data structure.
|
|
|
|
|
|
|
|
**/
|
2013-08-09 07:26:47 +02:00
|
|
|
BOOLEAN
|
|
|
|
IsNvUpdateRequiredForFormSet (
|
2011-05-31 02:59:15 +02:00
|
|
|
IN FORM_BROWSER_FORMSET *FormSet
|
|
|
|
)
|
|
|
|
{
|
|
|
|
LIST_ENTRY *Link;
|
|
|
|
FORM_BROWSER_FORM *Form;
|
2013-08-09 07:26:47 +02:00
|
|
|
BOOLEAN RetVal;
|
|
|
|
|
|
|
|
//
|
|
|
|
// Not finished question initialization, return FALSE.
|
|
|
|
//
|
|
|
|
if (!FormSet->QuestionInited) {
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
RetVal = FALSE;
|
2011-05-31 02:59:15 +02:00
|
|
|
|
|
|
|
Link = GetFirstNode (&FormSet->FormListHead);
|
|
|
|
while (!IsNull (&FormSet->FormListHead, Link)) {
|
|
|
|
Form = FORM_BROWSER_FORM_FROM_LINK (Link);
|
|
|
|
|
2013-08-09 07:26:47 +02:00
|
|
|
RetVal = IsNvUpdateRequiredForForm(Form);
|
|
|
|
if (RetVal) {
|
|
|
|
break;
|
2011-05-31 02:59:15 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
Link = GetNextNode (&FormSet->FormListHead, Link);
|
|
|
|
}
|
|
|
|
|
2013-08-09 07:26:47 +02:00
|
|
|
return RetVal;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
Update the NvUpdateRequired flag for a form.
|
|
|
|
|
|
|
|
@param Form Form data structure.
|
|
|
|
|
|
|
|
**/
|
|
|
|
BOOLEAN
|
|
|
|
IsNvUpdateRequiredForForm (
|
|
|
|
IN FORM_BROWSER_FORM *Form
|
|
|
|
)
|
|
|
|
{
|
|
|
|
LIST_ENTRY *Link;
|
|
|
|
FORM_BROWSER_STATEMENT *Statement;
|
|
|
|
|
|
|
|
Link = GetFirstNode (&Form->StatementListHead);
|
|
|
|
while (!IsNull (&Form->StatementListHead, Link)) {
|
|
|
|
Statement = FORM_BROWSER_STATEMENT_FROM_LINK (Link);
|
|
|
|
|
|
|
|
if (Statement->ValueChanged) {
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
Link = GetNextNode (&Form->StatementListHead, Link);
|
|
|
|
}
|
|
|
|
|
2011-05-31 02:59:15 +02:00
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2013-08-09 07:26:47 +02:00
|
|
|
Check whether the storage data for current form set is changed.
|
2011-05-31 02:59:15 +02:00
|
|
|
|
2013-08-09 07:26:47 +02:00
|
|
|
@param FormSet FormSet data structure.
|
2011-05-31 02:59:15 +02:00
|
|
|
|
2013-08-09 07:26:47 +02:00
|
|
|
@retval TRUE Data is changed.
|
|
|
|
@retval FALSE Data is not changed.
|
2011-05-31 02:59:15 +02:00
|
|
|
**/
|
2013-08-09 07:26:47 +02:00
|
|
|
BOOLEAN
|
|
|
|
IsStorageDataChangedForFormSet (
|
|
|
|
IN FORM_BROWSER_FORMSET *FormSet
|
2011-05-31 02:59:15 +02:00
|
|
|
)
|
|
|
|
{
|
|
|
|
LIST_ENTRY *Link;
|
2013-08-09 07:26:47 +02:00
|
|
|
FORMSET_STORAGE *Storage;
|
|
|
|
BROWSER_STORAGE *BrowserStorage;
|
|
|
|
CHAR16 *ConfigRespNew;
|
|
|
|
CHAR16 *ConfigRespOld;
|
|
|
|
BOOLEAN RetVal;
|
2011-05-31 02:59:15 +02:00
|
|
|
|
2013-08-09 07:26:47 +02:00
|
|
|
RetVal = FALSE;
|
|
|
|
ConfigRespNew = NULL;
|
|
|
|
ConfigRespOld = NULL;
|
2011-05-31 02:59:15 +02:00
|
|
|
|
2013-08-09 07:26:47 +02:00
|
|
|
//
|
|
|
|
// Request current settings from Configuration Driver
|
|
|
|
//
|
|
|
|
Link = GetFirstNode (&FormSet->StorageListHead);
|
|
|
|
while (!IsNull (&FormSet->StorageListHead, Link)) {
|
|
|
|
Storage = FORMSET_STORAGE_FROM_LINK (Link);
|
|
|
|
Link = GetNextNode (&FormSet->StorageListHead, Link);
|
|
|
|
|
|
|
|
BrowserStorage = Storage->BrowserStorage;
|
|
|
|
|
|
|
|
if (BrowserStorage->Type == EFI_HII_VARSTORE_EFI_VARIABLE) {
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (Storage->ElementCount == 0) {
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
|
|
|
StorageToConfigResp (BrowserStorage, &ConfigRespNew, Storage->ConfigRequest, TRUE);
|
|
|
|
StorageToConfigResp (BrowserStorage, &ConfigRespOld, Storage->ConfigRequest, FALSE);
|
|
|
|
ASSERT (ConfigRespNew != NULL && ConfigRespOld != NULL);
|
|
|
|
|
|
|
|
if (StrCmp (ConfigRespNew, ConfigRespOld) != 0) {
|
|
|
|
RetVal = TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
FreePool (ConfigRespNew);
|
|
|
|
ConfigRespNew = NULL;
|
|
|
|
|
|
|
|
FreePool (ConfigRespOld);
|
|
|
|
ConfigRespOld = NULL;
|
|
|
|
|
|
|
|
if (RetVal) {
|
|
|
|
break;
|
|
|
|
}
|
2011-05-31 02:59:15 +02:00
|
|
|
}
|
2013-08-09 07:26:47 +02:00
|
|
|
|
|
|
|
return RetVal;
|
2011-05-31 02:59:15 +02:00
|
|
|
}
|
2013-08-09 07:26:47 +02:00
|
|
|
|
2011-05-31 02:59:15 +02:00
|
|
|
/**
|
|
|
|
Find menu which will show next time.
|
|
|
|
|
|
|
|
@param Selection On input, Selection tell setup browser the information
|
|
|
|
about the Selection, form and formset to be displayed.
|
|
|
|
On output, Selection return the screen item that is selected
|
|
|
|
by user.
|
2013-08-09 07:26:47 +02:00
|
|
|
@param SettingLevel Input Settting level, if it is FormLevel, just exit current form.
|
|
|
|
else, we need to exit current formset.
|
2011-05-31 02:59:15 +02:00
|
|
|
|
2013-08-09 07:26:47 +02:00
|
|
|
@retval TRUE Exit current form.
|
|
|
|
@retval FALSE User press ESC and keep in current form.
|
2011-05-31 02:59:15 +02:00
|
|
|
**/
|
|
|
|
BOOLEAN
|
|
|
|
FindNextMenu (
|
2013-08-09 07:26:47 +02:00
|
|
|
IN OUT UI_MENU_SELECTION *Selection,
|
|
|
|
IN BROWSER_SETTING_SCOPE SettingLevel
|
2011-05-31 02:59:15 +02:00
|
|
|
)
|
|
|
|
{
|
2013-08-09 07:26:47 +02:00
|
|
|
FORM_ENTRY_INFO *CurrentMenu;
|
|
|
|
FORM_ENTRY_INFO *ParentMenu;
|
|
|
|
BROWSER_SETTING_SCOPE Scope;
|
2011-05-31 02:59:15 +02:00
|
|
|
|
|
|
|
CurrentMenu = Selection->CurrentMenu;
|
2013-08-09 07:26:47 +02:00
|
|
|
ParentMenu = NULL;
|
|
|
|
Scope = FormSetLevel;
|
2011-05-31 02:59:15 +02:00
|
|
|
|
2013-08-09 07:26:47 +02:00
|
|
|
if (CurrentMenu != NULL && (ParentMenu = UiFindParentMenu(CurrentMenu)) != NULL) {
|
2011-10-31 04:33:55 +01:00
|
|
|
//
|
|
|
|
// we have a parent, so go to the parent menu
|
|
|
|
//
|
2013-08-09 07:26:47 +02:00
|
|
|
if (CompareGuid (&CurrentMenu->FormSetGuid, &ParentMenu->FormSetGuid)) {
|
|
|
|
if (SettingLevel == FormSetLevel) {
|
2011-09-13 11:32:54 +02:00
|
|
|
//
|
2013-08-09 07:26:47 +02:00
|
|
|
// Find a menu which has different formset guid with current.
|
2011-09-13 11:32:54 +02:00
|
|
|
//
|
2013-08-09 07:26:47 +02:00
|
|
|
while (CompareGuid (&CurrentMenu->FormSetGuid, &ParentMenu->FormSetGuid)) {
|
|
|
|
CurrentMenu = ParentMenu;
|
|
|
|
if ((ParentMenu = UiFindParentMenu(CurrentMenu)) == NULL) {
|
|
|
|
break;
|
|
|
|
}
|
2011-09-13 11:32:54 +02:00
|
|
|
}
|
|
|
|
|
2013-08-09 07:26:47 +02:00
|
|
|
if (ParentMenu != NULL) {
|
|
|
|
Scope = FormSetLevel;
|
|
|
|
}
|
2011-09-13 11:32:54 +02:00
|
|
|
} else {
|
2013-08-09 07:26:47 +02:00
|
|
|
Scope = FormLevel;
|
2011-09-13 11:32:54 +02:00
|
|
|
}
|
2013-08-09 07:26:47 +02:00
|
|
|
} else {
|
|
|
|
Scope = FormSetLevel;
|
2011-09-13 11:32:54 +02:00
|
|
|
}
|
2011-05-31 02:59:15 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
//
|
2013-08-09 07:26:47 +02:00
|
|
|
// Form Level Check whether the data is changed.
|
2011-05-31 02:59:15 +02:00
|
|
|
//
|
2013-08-09 07:26:47 +02:00
|
|
|
if ((gBrowserSettingScope == FormLevel && IsNvUpdateRequiredForForm (Selection->Form)) ||
|
|
|
|
(gBrowserSettingScope == FormSetLevel && IsNvUpdateRequiredForFormSet(Selection->FormSet) && Scope == FormSetLevel)) {
|
|
|
|
if (!ProcessChangedData(Selection, Scope)) {
|
2011-05-31 02:59:15 +02:00
|
|
|
return FALSE;
|
|
|
|
}
|
2013-08-09 07:26:47 +02:00
|
|
|
}
|
2011-05-31 02:59:15 +02:00
|
|
|
|
2013-08-09 07:26:47 +02:00
|
|
|
if (ParentMenu != NULL) {
|
|
|
|
//
|
|
|
|
// ParentMenu is found. Then, go to it.
|
|
|
|
//
|
|
|
|
if (Scope == FormLevel) {
|
|
|
|
Selection->Action = UI_ACTION_REFRESH_FORM;
|
2011-09-13 11:32:54 +02:00
|
|
|
} else {
|
2013-08-09 07:26:47 +02:00
|
|
|
Selection->Action = UI_ACTION_REFRESH_FORMSET;
|
|
|
|
CopyMem (&Selection->FormSetGuid, &ParentMenu->FormSetGuid, sizeof (EFI_GUID));
|
|
|
|
Selection->Handle = ParentMenu->HiiHandle;
|
2011-05-31 02:59:15 +02:00
|
|
|
}
|
|
|
|
|
2013-08-09 07:26:47 +02:00
|
|
|
Selection->Statement = NULL;
|
|
|
|
|
|
|
|
Selection->FormId = ParentMenu->FormId;
|
|
|
|
Selection->QuestionId = ParentMenu->QuestionId;
|
|
|
|
|
|
|
|
//
|
|
|
|
// Clear highlight record for this menu
|
|
|
|
//
|
2011-06-13 07:20:23 +02:00
|
|
|
CurrentMenu->QuestionId = 0;
|
2013-08-09 07:26:47 +02:00
|
|
|
return FALSE;
|
2011-06-13 07:20:23 +02:00
|
|
|
}
|
2011-05-31 02:59:15 +02:00
|
|
|
|
2013-08-09 07:26:47 +02:00
|
|
|
//
|
|
|
|
// Current in root page, exit the SendForm
|
|
|
|
//
|
2011-05-31 02:59:15 +02:00
|
|
|
Selection->Action = UI_ACTION_EXIT;
|
2013-08-09 07:26:47 +02:00
|
|
|
|
2011-05-31 02:59:15 +02:00
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
Call the call back function for the question and process the return action.
|
|
|
|
|
|
|
|
@param Selection On input, Selection tell setup browser the information
|
|
|
|
about the Selection, form and formset to be displayed.
|
|
|
|
On output, Selection return the screen item that is selected
|
|
|
|
by user.
|
|
|
|
@param Question The Question which need to call.
|
|
|
|
@param Action The action request.
|
|
|
|
@param SkipSaveOrDiscard Whether skip save or discard action.
|
|
|
|
|
|
|
|
@retval EFI_SUCCESS The call back function excutes successfully.
|
|
|
|
@return Other value if the call back function failed to excute.
|
|
|
|
**/
|
|
|
|
EFI_STATUS
|
|
|
|
ProcessCallBackFunction (
|
|
|
|
IN OUT UI_MENU_SELECTION *Selection,
|
|
|
|
IN FORM_BROWSER_STATEMENT *Question,
|
|
|
|
IN EFI_BROWSER_ACTION Action,
|
|
|
|
IN BOOLEAN SkipSaveOrDiscard
|
|
|
|
)
|
|
|
|
{
|
|
|
|
EFI_STATUS Status;
|
|
|
|
EFI_BROWSER_ACTION_REQUEST ActionRequest;
|
|
|
|
EFI_HII_CONFIG_ACCESS_PROTOCOL *ConfigAccess;
|
|
|
|
EFI_HII_VALUE *HiiValue;
|
|
|
|
EFI_IFR_TYPE_VALUE *TypeValue;
|
|
|
|
FORM_BROWSER_STATEMENT *Statement;
|
|
|
|
BOOLEAN SubmitFormIsRequired;
|
|
|
|
BOOLEAN DiscardFormIsRequired;
|
|
|
|
BOOLEAN NeedExit;
|
|
|
|
LIST_ENTRY *Link;
|
2011-09-13 11:32:54 +02:00
|
|
|
BROWSER_SETTING_SCOPE SettingLevel;
|
2011-05-31 02:59:15 +02:00
|
|
|
|
|
|
|
ConfigAccess = Selection->FormSet->ConfigAccess;
|
|
|
|
SubmitFormIsRequired = FALSE;
|
2011-09-13 11:32:54 +02:00
|
|
|
SettingLevel = FormSetLevel;
|
2011-05-31 02:59:15 +02:00
|
|
|
DiscardFormIsRequired = FALSE;
|
|
|
|
NeedExit = FALSE;
|
|
|
|
Status = EFI_SUCCESS;
|
|
|
|
ActionRequest = EFI_BROWSER_ACTION_REQUEST_NONE;
|
|
|
|
|
|
|
|
if (ConfigAccess == NULL) {
|
|
|
|
return EFI_SUCCESS;
|
|
|
|
}
|
|
|
|
|
|
|
|
Link = GetFirstNode (&Selection->Form->StatementListHead);
|
|
|
|
while (!IsNull (&Selection->Form->StatementListHead, Link)) {
|
|
|
|
Statement = FORM_BROWSER_STATEMENT_FROM_LINK (Link);
|
|
|
|
Link = GetNextNode (&Selection->Form->StatementListHead, Link);
|
|
|
|
|
|
|
|
//
|
|
|
|
// if Question != NULL, only process the question. Else, process all question in this form.
|
|
|
|
//
|
|
|
|
if ((Question != NULL) && (Statement != Question)) {
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
|
|
|
if ((Statement->QuestionFlags & EFI_IFR_FLAG_CALLBACK) != EFI_IFR_FLAG_CALLBACK) {
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
|
|
|
//
|
|
|
|
// Check whether Statement is disabled.
|
|
|
|
//
|
2012-01-31 08:17:42 +01:00
|
|
|
if (Statement->Expression != NULL) {
|
|
|
|
if (EvaluateExpressionList(Statement->Expression, TRUE, Selection->FormSet, Selection->Form) == ExpressDisable) {
|
2011-05-31 02:59:15 +02:00
|
|
|
continue;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
HiiValue = &Statement->HiiValue;
|
|
|
|
TypeValue = &HiiValue->Value;
|
|
|
|
if (HiiValue->Type == EFI_IFR_TYPE_BUFFER) {
|
|
|
|
//
|
|
|
|
// For OrderedList, passing in the value buffer to Callback()
|
|
|
|
//
|
|
|
|
TypeValue = (EFI_IFR_TYPE_VALUE *) Statement->BufferValue;
|
|
|
|
}
|
|
|
|
|
|
|
|
ActionRequest = EFI_BROWSER_ACTION_REQUEST_NONE;
|
|
|
|
Status = ConfigAccess->Callback (
|
|
|
|
ConfigAccess,
|
|
|
|
Action,
|
|
|
|
Statement->QuestionId,
|
|
|
|
HiiValue->Type,
|
|
|
|
TypeValue,
|
|
|
|
&ActionRequest
|
|
|
|
);
|
|
|
|
if (!EFI_ERROR (Status)) {
|
2011-12-15 03:54:49 +01:00
|
|
|
//
|
|
|
|
// Only for EFI_BROWSER_ACTION_CHANGED need to handle this ActionRequest.
|
|
|
|
//
|
|
|
|
if (Action == EFI_BROWSER_ACTION_CHANGED) {
|
|
|
|
switch (ActionRequest) {
|
|
|
|
case EFI_BROWSER_ACTION_REQUEST_RESET:
|
2013-06-06 11:31:46 +02:00
|
|
|
DiscardFormIsRequired = TRUE;
|
2011-12-15 03:54:49 +01:00
|
|
|
gResetRequired = TRUE;
|
2013-08-09 07:26:47 +02:00
|
|
|
NeedExit = TRUE;
|
2011-12-15 03:54:49 +01:00
|
|
|
break;
|
2011-05-31 02:59:15 +02:00
|
|
|
|
2011-12-15 03:54:49 +01:00
|
|
|
case EFI_BROWSER_ACTION_REQUEST_SUBMIT:
|
|
|
|
SubmitFormIsRequired = TRUE;
|
2013-08-09 07:26:47 +02:00
|
|
|
NeedExit = TRUE;
|
2011-12-15 03:54:49 +01:00
|
|
|
break;
|
2011-05-31 02:59:15 +02:00
|
|
|
|
2011-12-15 03:54:49 +01:00
|
|
|
case EFI_BROWSER_ACTION_REQUEST_EXIT:
|
2013-03-27 03:03:48 +01:00
|
|
|
DiscardFormIsRequired = TRUE;
|
2013-08-09 07:26:47 +02:00
|
|
|
NeedExit = TRUE;
|
2011-12-15 03:54:49 +01:00
|
|
|
break;
|
2011-05-31 02:59:15 +02:00
|
|
|
|
2011-12-15 03:54:49 +01:00
|
|
|
case EFI_BROWSER_ACTION_REQUEST_FORM_SUBMIT_EXIT:
|
|
|
|
SubmitFormIsRequired = TRUE;
|
|
|
|
SettingLevel = FormLevel;
|
|
|
|
NeedExit = TRUE;
|
|
|
|
break;
|
2011-05-31 02:59:15 +02:00
|
|
|
|
2011-12-15 03:54:49 +01:00
|
|
|
case EFI_BROWSER_ACTION_REQUEST_FORM_DISCARD_EXIT:
|
|
|
|
DiscardFormIsRequired = TRUE;
|
2013-08-09 07:26:47 +02:00
|
|
|
SettingLevel = FormLevel;
|
2011-12-15 03:54:49 +01:00
|
|
|
NeedExit = TRUE;
|
|
|
|
break;
|
2011-05-31 02:59:15 +02:00
|
|
|
|
2011-12-15 03:54:49 +01:00
|
|
|
case EFI_BROWSER_ACTION_REQUEST_FORM_APPLY:
|
|
|
|
SubmitFormIsRequired = TRUE;
|
|
|
|
SettingLevel = FormLevel;
|
|
|
|
break;
|
2011-05-31 02:59:15 +02:00
|
|
|
|
2011-12-15 03:54:49 +01:00
|
|
|
case EFI_BROWSER_ACTION_REQUEST_FORM_DISCARD:
|
|
|
|
DiscardFormIsRequired = TRUE;
|
|
|
|
SettingLevel = FormLevel;
|
|
|
|
break;
|
2011-05-31 02:59:15 +02:00
|
|
|
|
2011-12-15 03:54:49 +01:00
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
2011-05-31 02:59:15 +02:00
|
|
|
}
|
2011-06-28 08:41:28 +02:00
|
|
|
|
|
|
|
//
|
|
|
|
// According the spec, return value from call back of "changing" and
|
|
|
|
// "retrieve" should update to the question's temp buffer.
|
|
|
|
//
|
|
|
|
if (Action == EFI_BROWSER_ACTION_CHANGING || Action == EFI_BROWSER_ACTION_RETRIEVE) {
|
2012-07-06 04:27:33 +02:00
|
|
|
SetQuestionValue(Selection->FormSet, Selection->Form, Statement, GetSetValueWithEditBuffer);
|
2011-06-28 08:41:28 +02:00
|
|
|
}
|
2011-10-09 12:52:54 +02:00
|
|
|
} else {
|
2011-05-31 02:59:15 +02:00
|
|
|
//
|
2011-10-09 12:52:54 +02:00
|
|
|
// According the spec, return fail from call back of "changing" and
|
|
|
|
// "retrieve", should restore the question's value.
|
2011-05-31 02:59:15 +02:00
|
|
|
//
|
2011-10-09 12:52:54 +02:00
|
|
|
if (Action == EFI_BROWSER_ACTION_CHANGING || Action == EFI_BROWSER_ACTION_RETRIEVE) {
|
2012-07-06 04:27:33 +02:00
|
|
|
GetQuestionValue(Selection->FormSet, Selection->Form, Statement, GetSetValueWithEditBuffer);
|
2011-10-09 12:52:54 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
if (Status == EFI_UNSUPPORTED) {
|
|
|
|
//
|
|
|
|
// If return EFI_UNSUPPORTED, also consider Hii driver suceess deal with it.
|
|
|
|
//
|
|
|
|
Status = EFI_SUCCESS;
|
|
|
|
}
|
2011-05-31 02:59:15 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (SubmitFormIsRequired && !SkipSaveOrDiscard) {
|
2011-09-13 11:32:54 +02:00
|
|
|
SubmitForm (Selection->FormSet, Selection->Form, SettingLevel);
|
2011-05-31 02:59:15 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
if (DiscardFormIsRequired && !SkipSaveOrDiscard) {
|
2011-09-13 11:32:54 +02:00
|
|
|
DiscardForm (Selection->FormSet, Selection->Form, SettingLevel);
|
2011-05-31 02:59:15 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
if (NeedExit) {
|
2013-08-09 07:26:47 +02:00
|
|
|
FindNextMenu (Selection, SettingLevel);
|
2011-05-31 02:59:15 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
return Status;
|
|
|
|
}
|
|
|
|
|
2012-08-21 10:23:20 +02:00
|
|
|
/**
|
|
|
|
Call the retrieve type call back function for one question to get the initialize data.
|
|
|
|
|
|
|
|
This function only used when in the initialize stage, because in this stage, the
|
|
|
|
Selection->Form is not ready. For other case, use the ProcessCallBackFunction instead.
|
|
|
|
|
|
|
|
@param ConfigAccess The config access protocol produced by the hii driver.
|
|
|
|
@param Statement The Question which need to call.
|
|
|
|
|
|
|
|
@retval EFI_SUCCESS The call back function excutes successfully.
|
|
|
|
@return Other value if the call back function failed to excute.
|
|
|
|
**/
|
|
|
|
EFI_STATUS
|
|
|
|
ProcessRetrieveForQuestion (
|
|
|
|
IN EFI_HII_CONFIG_ACCESS_PROTOCOL *ConfigAccess,
|
|
|
|
IN FORM_BROWSER_STATEMENT *Statement
|
|
|
|
)
|
|
|
|
{
|
|
|
|
EFI_STATUS Status;
|
|
|
|
EFI_BROWSER_ACTION_REQUEST ActionRequest;
|
|
|
|
EFI_HII_VALUE *HiiValue;
|
|
|
|
EFI_IFR_TYPE_VALUE *TypeValue;
|
|
|
|
|
|
|
|
Status = EFI_SUCCESS;
|
|
|
|
ActionRequest = EFI_BROWSER_ACTION_REQUEST_NONE;
|
|
|
|
|
|
|
|
if ((Statement->QuestionFlags & EFI_IFR_FLAG_CALLBACK) != EFI_IFR_FLAG_CALLBACK) {
|
|
|
|
return EFI_UNSUPPORTED;
|
|
|
|
}
|
|
|
|
|
|
|
|
HiiValue = &Statement->HiiValue;
|
|
|
|
TypeValue = &HiiValue->Value;
|
|
|
|
if (HiiValue->Type == EFI_IFR_TYPE_BUFFER) {
|
|
|
|
//
|
|
|
|
// For OrderedList, passing in the value buffer to Callback()
|
|
|
|
//
|
|
|
|
TypeValue = (EFI_IFR_TYPE_VALUE *) Statement->BufferValue;
|
|
|
|
}
|
|
|
|
|
|
|
|
ActionRequest = EFI_BROWSER_ACTION_REQUEST_NONE;
|
|
|
|
Status = ConfigAccess->Callback (
|
|
|
|
ConfigAccess,
|
|
|
|
EFI_BROWSER_ACTION_RETRIEVE,
|
|
|
|
Statement->QuestionId,
|
|
|
|
HiiValue->Type,
|
|
|
|
TypeValue,
|
|
|
|
&ActionRequest
|
|
|
|
);
|
|
|
|
return Status;
|
|
|
|
}
|
|
|
|
|
2008-07-15 10:35:54 +02:00
|
|
|
/**
|
|
|
|
The worker function that send the displays to the screen. On output,
|
|
|
|
the selection made by user is returned.
|
|
|
|
|
|
|
|
@param Selection On input, Selection tell setup browser the information
|
|
|
|
about the Selection, form and formset to be displayed.
|
|
|
|
On output, Selection return the screen item that is selected
|
|
|
|
by user.
|
|
|
|
|
|
|
|
@retval EFI_SUCCESS The page is displayed successfully.
|
|
|
|
@return Other value if the page failed to be diplayed.
|
|
|
|
|
|
|
|
**/
|
|
|
|
EFI_STATUS
|
|
|
|
SetupBrowser (
|
|
|
|
IN OUT UI_MENU_SELECTION *Selection
|
|
|
|
)
|
|
|
|
{
|
|
|
|
EFI_STATUS Status;
|
|
|
|
LIST_ENTRY *Link;
|
|
|
|
EFI_HANDLE NotifyHandle;
|
|
|
|
FORM_BROWSER_STATEMENT *Statement;
|
|
|
|
EFI_HII_CONFIG_ACCESS_PROTOCOL *ConfigAccess;
|
|
|
|
|
2010-06-02 04:05:47 +02:00
|
|
|
ConfigAccess = Selection->FormSet->ConfigAccess;
|
2008-07-15 10:35:54 +02:00
|
|
|
|
|
|
|
//
|
|
|
|
// Register notify for Form package update
|
|
|
|
//
|
|
|
|
Status = mHiiDatabase->RegisterPackageNotify (
|
|
|
|
mHiiDatabase,
|
2008-11-04 15:28:08 +01:00
|
|
|
EFI_HII_PACKAGE_FORMS,
|
2008-07-15 10:35:54 +02:00
|
|
|
NULL,
|
|
|
|
FormUpdateNotify,
|
|
|
|
EFI_HII_DATABASE_NOTIFY_REMOVE_PACK,
|
|
|
|
&NotifyHandle
|
|
|
|
);
|
|
|
|
if (EFI_ERROR (Status)) {
|
|
|
|
return Status;
|
|
|
|
}
|
|
|
|
|
2009-10-26 04:03:12 +01:00
|
|
|
//
|
|
|
|
// Initialize current settings of Questions in this FormSet
|
|
|
|
//
|
2013-08-09 07:26:47 +02:00
|
|
|
InitializeCurrentSetting (Selection->FormSet);
|
2009-10-26 04:03:12 +01:00
|
|
|
|
2011-09-13 11:32:54 +02:00
|
|
|
//
|
2013-08-09 07:26:47 +02:00
|
|
|
// Initilize Action field.
|
2011-09-13 11:32:54 +02:00
|
|
|
//
|
2013-08-09 07:26:47 +02:00
|
|
|
Selection->Action = UI_ACTION_REFRESH_FORM;
|
|
|
|
|
|
|
|
//
|
|
|
|
// Clean the mCurFakeQestId value is formset refreshed.
|
|
|
|
//
|
|
|
|
mCurFakeQestId = 0;
|
2011-09-13 11:32:54 +02:00
|
|
|
|
2008-07-15 10:35:54 +02:00
|
|
|
do {
|
2012-11-15 09:13:23 +01:00
|
|
|
//
|
|
|
|
// IFR is updated, force to reparse the IFR binary
|
|
|
|
//
|
|
|
|
if (mHiiPackageListUpdated) {
|
|
|
|
Selection->Action = UI_ACTION_REFRESH_FORMSET;
|
|
|
|
mHiiPackageListUpdated = FALSE;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2008-07-15 10:35:54 +02:00
|
|
|
//
|
|
|
|
// Initialize Selection->Form
|
|
|
|
//
|
|
|
|
if (Selection->FormId == 0) {
|
|
|
|
//
|
|
|
|
// Zero FormId indicates display the first Form in a FormSet
|
|
|
|
//
|
|
|
|
Link = GetFirstNode (&Selection->FormSet->FormListHead);
|
|
|
|
|
|
|
|
Selection->Form = FORM_BROWSER_FORM_FROM_LINK (Link);
|
|
|
|
Selection->FormId = Selection->Form->FormId;
|
|
|
|
} else {
|
|
|
|
Selection->Form = IdToForm (Selection->FormSet, Selection->FormId);
|
|
|
|
}
|
|
|
|
|
2009-04-22 05:18:37 +02:00
|
|
|
if (Selection->Form == NULL) {
|
|
|
|
//
|
|
|
|
// No Form to display
|
|
|
|
//
|
2010-06-04 03:29:03 +02:00
|
|
|
Status = EFI_NOT_FOUND;
|
|
|
|
goto Done;
|
2009-04-22 05:18:37 +02:00
|
|
|
}
|
|
|
|
|
2009-11-12 02:16:12 +01:00
|
|
|
//
|
|
|
|
// Check Form is suppressed.
|
|
|
|
//
|
|
|
|
if (Selection->Form->SuppressExpression != NULL) {
|
2012-01-31 08:17:42 +01:00
|
|
|
if (EvaluateExpressionList(Selection->Form->SuppressExpression, TRUE, Selection->FormSet, Selection->Form) == ExpressSuppress) {
|
2009-11-12 02:16:12 +01:00
|
|
|
//
|
|
|
|
// Form is suppressed.
|
|
|
|
//
|
2013-08-09 07:26:47 +02:00
|
|
|
gBrowserStatus = BROWSER_FORM_SUPPRESS;
|
2010-06-04 03:29:03 +02:00
|
|
|
Status = EFI_NOT_FOUND;
|
|
|
|
goto Done;
|
2009-11-12 02:16:12 +01:00
|
|
|
}
|
|
|
|
}
|
2010-06-02 04:05:47 +02:00
|
|
|
|
|
|
|
//
|
|
|
|
// Before display new form, invoke ConfigAccess.Callback() with EFI_BROWSER_ACTION_FORM_OPEN
|
|
|
|
// for each question with callback flag.
|
|
|
|
// New form may be the first form, or the different form after another form close.
|
|
|
|
//
|
2010-06-04 03:29:03 +02:00
|
|
|
if ((ConfigAccess != NULL) &&
|
|
|
|
((Selection->Handle != mCurrentHiiHandle) ||
|
|
|
|
(!CompareGuid (&Selection->FormSetGuid, &mCurrentFormSetGuid)) ||
|
|
|
|
(Selection->FormId != mCurrentFormId))) {
|
|
|
|
//
|
|
|
|
// Keep current form information
|
|
|
|
//
|
|
|
|
mCurrentHiiHandle = Selection->Handle;
|
|
|
|
CopyGuid (&mCurrentFormSetGuid, &Selection->FormSetGuid);
|
|
|
|
mCurrentFormId = Selection->FormId;
|
|
|
|
|
2011-05-31 02:59:15 +02:00
|
|
|
Status = ProcessCallBackFunction (Selection, NULL, EFI_BROWSER_ACTION_FORM_OPEN, FALSE);
|
|
|
|
if (EFI_ERROR (Status)) {
|
|
|
|
goto Done;
|
2010-06-02 04:05:47 +02:00
|
|
|
}
|
2011-05-31 02:59:15 +02:00
|
|
|
|
2010-06-02 04:05:47 +02:00
|
|
|
//
|
|
|
|
// IFR is updated during callback of open form, force to reparse the IFR binary
|
|
|
|
//
|
|
|
|
if (mHiiPackageListUpdated) {
|
|
|
|
Selection->Action = UI_ACTION_REFRESH_FORMSET;
|
|
|
|
mHiiPackageListUpdated = FALSE;
|
2011-06-15 10:40:08 +02:00
|
|
|
break;
|
2010-06-02 04:05:47 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2008-07-15 10:35:54 +02:00
|
|
|
//
|
|
|
|
// Load Questions' Value for display
|
|
|
|
//
|
2009-11-13 07:46:59 +01:00
|
|
|
Status = LoadFormSetConfig (Selection, Selection->FormSet);
|
2008-07-15 10:35:54 +02:00
|
|
|
if (EFI_ERROR (Status)) {
|
2010-06-04 03:29:03 +02:00
|
|
|
goto Done;
|
2008-07-15 10:35:54 +02:00
|
|
|
}
|
|
|
|
|
2009-11-13 07:46:59 +01:00
|
|
|
//
|
|
|
|
// IFR is updated during callback of read value, force to reparse the IFR binary
|
|
|
|
//
|
|
|
|
if (mHiiPackageListUpdated) {
|
|
|
|
Selection->Action = UI_ACTION_REFRESH_FORMSET;
|
|
|
|
mHiiPackageListUpdated = FALSE;
|
2011-06-15 10:40:08 +02:00
|
|
|
break;
|
2009-11-13 07:46:59 +01:00
|
|
|
}
|
|
|
|
|
2008-07-15 10:35:54 +02:00
|
|
|
//
|
|
|
|
// Display form
|
|
|
|
//
|
2013-08-09 07:26:47 +02:00
|
|
|
Status = DisplayForm ();
|
2008-07-15 10:35:54 +02:00
|
|
|
if (EFI_ERROR (Status)) {
|
2010-06-04 03:29:03 +02:00
|
|
|
goto Done;
|
2008-07-15 10:35:54 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
//
|
|
|
|
// Check Selected Statement (if press ESC, Selection->Statement will be NULL)
|
|
|
|
//
|
|
|
|
Statement = Selection->Statement;
|
|
|
|
if (Statement != NULL) {
|
2010-06-04 03:29:03 +02:00
|
|
|
if ((ConfigAccess != NULL) &&
|
|
|
|
((Statement->QuestionFlags & EFI_IFR_FLAG_CALLBACK) == EFI_IFR_FLAG_CALLBACK) &&
|
|
|
|
(Statement->Operand != EFI_IFR_PASSWORD_OP)) {
|
2013-08-09 07:26:47 +02:00
|
|
|
Status = ProcessCallBackFunction(Selection, Statement, EFI_BROWSER_ACTION_CHANGING, FALSE);
|
|
|
|
if (Statement->Operand == EFI_IFR_REF_OP) {
|
2011-06-28 08:41:28 +02:00
|
|
|
//
|
|
|
|
// Process dynamic update ref opcode.
|
|
|
|
//
|
|
|
|
if (!EFI_ERROR (Status)) {
|
2013-08-09 07:26:47 +02:00
|
|
|
Status = ProcessGotoOpCode(Statement, Selection);
|
2011-06-28 08:41:28 +02:00
|
|
|
}
|
|
|
|
|
2009-10-26 04:04:08 +01:00
|
|
|
//
|
2011-06-28 08:41:28 +02:00
|
|
|
// Callback return error status or status return from process goto opcode.
|
2009-10-26 04:04:08 +01:00
|
|
|
//
|
2011-06-28 08:41:28 +02:00
|
|
|
if (EFI_ERROR (Status)) {
|
2009-10-26 04:04:08 +01:00
|
|
|
//
|
|
|
|
// Cross reference will not be taken
|
|
|
|
//
|
|
|
|
Selection->FormId = Selection->Form->FormId;
|
|
|
|
Selection->QuestionId = 0;
|
|
|
|
}
|
2008-07-15 10:35:54 +02:00
|
|
|
}
|
2011-12-07 06:49:01 +01:00
|
|
|
|
2011-12-15 03:54:49 +01:00
|
|
|
if (!EFI_ERROR (Status) && Statement->Operand != EFI_IFR_REF_OP) {
|
2011-12-07 06:49:01 +01:00
|
|
|
ProcessCallBackFunction(Selection, Statement, EFI_BROWSER_ACTION_CHANGED, FALSE);
|
|
|
|
}
|
2008-07-15 10:35:54 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-08-09 07:26:47 +02:00
|
|
|
//
|
|
|
|
// Check whether Exit flag is TRUE.
|
|
|
|
//
|
|
|
|
if (gExitRequired) {
|
|
|
|
switch (gBrowserSettingScope) {
|
|
|
|
case SystemLevel:
|
|
|
|
Selection->Action = UI_ACTION_EXIT;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case FormSetLevel:
|
|
|
|
case FormLevel:
|
|
|
|
FindNextMenu (Selection, gBrowserSettingScope);
|
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
gExitRequired = FALSE;
|
|
|
|
}
|
|
|
|
|
2010-06-02 04:05:47 +02:00
|
|
|
//
|
|
|
|
// Before exit the form, invoke ConfigAccess.Callback() with EFI_BROWSER_ACTION_FORM_CLOSE
|
|
|
|
// for each question with callback flag.
|
|
|
|
//
|
|
|
|
if ((ConfigAccess != NULL) &&
|
|
|
|
((Selection->Action == UI_ACTION_EXIT) ||
|
2010-06-04 03:29:03 +02:00
|
|
|
(Selection->Handle != mCurrentHiiHandle) ||
|
|
|
|
(!CompareGuid (&Selection->FormSetGuid, &mCurrentFormSetGuid)) ||
|
|
|
|
(Selection->FormId != mCurrentFormId))) {
|
2009-10-26 04:04:31 +01:00
|
|
|
|
2011-05-31 02:59:15 +02:00
|
|
|
Status = ProcessCallBackFunction (Selection, NULL, EFI_BROWSER_ACTION_FORM_CLOSE, FALSE);
|
|
|
|
if (EFI_ERROR (Status)) {
|
|
|
|
goto Done;
|
2009-10-26 04:04:31 +01:00
|
|
|
}
|
|
|
|
}
|
2010-06-02 04:05:47 +02:00
|
|
|
} while (Selection->Action == UI_ACTION_REFRESH_FORM);
|
2009-10-26 04:04:31 +01:00
|
|
|
|
2009-10-26 04:03:12 +01:00
|
|
|
Done:
|
2010-06-04 03:29:03 +02:00
|
|
|
//
|
|
|
|
// Reset current form information to the initial setting when error happens or form exit.
|
|
|
|
//
|
|
|
|
if (EFI_ERROR (Status) || Selection->Action == UI_ACTION_EXIT) {
|
|
|
|
mCurrentHiiHandle = NULL;
|
|
|
|
CopyGuid (&mCurrentFormSetGuid, &gZeroGuid);
|
|
|
|
mCurrentFormId = 0;
|
|
|
|
}
|
|
|
|
|
2008-07-15 10:35:54 +02:00
|
|
|
//
|
|
|
|
// Unregister notify for Form package update
|
|
|
|
//
|
2010-06-04 03:29:03 +02:00
|
|
|
mHiiDatabase->UnregisterPackageNotify (
|
|
|
|
mHiiDatabase,
|
|
|
|
NotifyHandle
|
|
|
|
);
|
2008-07-15 10:35:54 +02:00
|
|
|
return Status;
|
|
|
|
}
|