Sync in bug fix from EDK I:

1) issue with setup browser and IFR refresh opcode
2) [HII]HIIConfigRoutingExportConfig generate error format of <MultiConfigAltResp>
3) [HII] ConfigRouting->ExtractConfig() will cause overflow
4) [Hii Database] EFI_HII_DATABASE_NOTIFY should be invoked when a string package is created internally when a new String Token is created
5) [PT]HIIConfigAccessProtocolTest fail on NT32uefi
6) Incorrect HII package types in EDK

git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@6378 6f19259b-4bc3-4df7-8a09-765794883524
This commit is contained in:
qwang12
2008-11-04 14:28:08 +00:00
parent 9185c388a9
commit 8d00a0f195
23 changed files with 680 additions and 550 deletions

View File

@@ -1,7 +1,7 @@
/** @file
Utility functions for expression evaluation.
Copyright (c) 2007, Intel Corporation
Copyright (c) 2007 - 2008, Intel Corporation
All rights reserved. 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
@@ -421,6 +421,14 @@ IdToQuestion (
Question = IdToQuestion2 (Form, QuestionId);
if (Question != NULL) {
//
// EFI variable storage may be updated by Callback() asynchronous,
// to keep synchronous, always reload the Question Value.
//
if (Question->Storage->Type == EFI_HII_VARSTORE_EFI_VARIABLE) {
GetQuestionValue (FormSet, Form, Question, FALSE);
}
return Question;
}

View File

@@ -1,7 +1,7 @@
/** @file
Utility functions for UI presentation.
Copyright (c) 2004 - 2007, Intel Corporation
Copyright (c) 2004 - 2008, Intel Corporation
All rights reserved. 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
@@ -482,24 +482,6 @@ DisplayForm (
if (!IsListEmpty (&gMenuList)) {
PrintStringAt (LocalScreen.LeftColumn + 2, LocalScreen.TopRow + 1, gFunctionTwoString);
}
PrintStringAt (LocalScreen.LeftColumn + 2, LocalScreen.BottomRow - 4, gFunctionOneString);
PrintStringAt (
LocalScreen.LeftColumn + (LocalScreen.RightColumn - LocalScreen.LeftColumn) / 3,
LocalScreen.BottomRow - 4,
gFunctionNineString
);
PrintStringAt (
LocalScreen.LeftColumn + (LocalScreen.RightColumn - LocalScreen.LeftColumn) * 2 / 3,
LocalScreen.BottomRow - 4,
gFunctionTenString
);
PrintAt (LocalScreen.LeftColumn + 2, LocalScreen.BottomRow - 3, L"%c%c%s", ARROW_UP, ARROW_DOWN, gMoveHighlight);
PrintStringAt (
LocalScreen.LeftColumn + (LocalScreen.RightColumn - LocalScreen.LeftColumn) / 3,
LocalScreen.BottomRow - 3,
gEscapeString
);
}
//
// Remove Buffer allocated for StringPtr after it has been used.
@@ -575,6 +557,7 @@ InitializeBrowserStrings (
gFunctionTenString = GetToken (STRING_TOKEN (FUNCTION_TEN_STRING), gHiiHandle);
gEnterString = GetToken (STRING_TOKEN (ENTER_STRING), gHiiHandle);
gEnterCommitString = GetToken (STRING_TOKEN (ENTER_COMMIT_STRING), gHiiHandle);
gEnterEscapeString = GetToken (STRING_TOKEN (ENTER_ESCAPE_STRING), gHiiHandle);
gEscapeString = GetToken (STRING_TOKEN (ESCAPE_STRING), gHiiHandle);
gSaveFailed = GetToken (STRING_TOKEN (SAVE_FAILED), gHiiHandle);
gMoveHighlight = GetToken (STRING_TOKEN (MOVE_HIGHLIGHT), gHiiHandle);
@@ -598,6 +581,7 @@ InitializeBrowserStrings (
gMinusString = GetToken (STRING_TOKEN (MINUS_STRING), gHiiHandle);
gAdjustNumber = GetToken (STRING_TOKEN (ADJUST_NUMBER), gHiiHandle);
gSaveChanges = GetToken (STRING_TOKEN (SAVE_CHANGES), gHiiHandle);
gOptionMismatch = GetToken (STRING_TOKEN (OPTION_MISMATCH), gHiiHandle);
return ;
}
@@ -617,6 +601,7 @@ FreeBrowserStrings (
FreePool (gFunctionTenString);
FreePool (gEnterString);
FreePool (gEnterCommitString);
FreePool (gEnterEscapeString);
FreePool (gEscapeString);
FreePool (gMoveHighlight);
FreePool (gMakeSelection);
@@ -639,6 +624,7 @@ FreeBrowserStrings (
FreePool (gMinusString);
FreePool (gAdjustNumber);
FreePool (gSaveChanges);
FreePool (gOptionMismatch);
return ;
}
@@ -701,8 +687,7 @@ UpdateKeyHelp (
}
if ((Statement->Operand == EFI_IFR_DATE_OP) ||
(Statement->Operand == EFI_IFR_TIME_OP) ||
(Statement->Operand == EFI_IFR_NUMERIC_OP && Statement->Step != 0)) {
(Statement->Operand == EFI_IFR_TIME_OP)) {
PrintAt (
StartColumnOfHelp,
BottomRowOfHelp,
@@ -716,7 +701,11 @@ UpdateKeyHelp (
PrintStringAt (SecCol, BottomRowOfHelp, gAdjustNumber);
} else {
PrintAt (StartColumnOfHelp, BottomRowOfHelp, L"%c%c%s", ARROW_UP, ARROW_DOWN, gMoveHighlight);
PrintStringAt (SecCol, BottomRowOfHelp, gEnterString);
if (Statement->Operand == EFI_IFR_NUMERIC_OP && Statement->Step != 0) {
PrintStringAt (SecCol, BottomRowOfHelp, gAdjustNumber);
} else {
PrintStringAt (SecCol, BottomRowOfHelp, gEnterString);
}
}
} else {
PrintStringAt (SecCol, BottomRowOfHelp, gEnterCommitString);
@@ -739,7 +728,7 @@ UpdateKeyHelp (
PrintStringAt (ThdCol, TopRowOfHelp, gMinusString);
}
PrintStringAt (ThdCol, BottomRowOfHelp, gEscapeString);
PrintStringAt (ThdCol, BottomRowOfHelp, gEnterEscapeString);
}
break;
@@ -784,7 +773,7 @@ UpdateKeyHelp (
BottomRowOfHelp,
gEnterCommitString
);
PrintStringAt (ThdCol, BottomRowOfHelp, gEscapeString);
PrintStringAt (ThdCol, BottomRowOfHelp, gEnterEscapeString);
}
}
break;
@@ -874,7 +863,7 @@ SetupBrowser (
//
Status = mHiiDatabase->RegisterPackageNotify (
mHiiDatabase,
EFI_HII_PACKAGE_FORM,
EFI_HII_PACKAGE_FORMS,
NULL,
FormUpdateNotify,
EFI_HII_DATABASE_NOTIFY_REMOVE_PACK,

View File

@@ -2,7 +2,7 @@
Implementation for handling the User Interface option processing.
Copyright (c) 2004 - 2007, Intel Corporation
Copyright (c) 2004 - 2008, Intel Corporation
All rights reserved. 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
@@ -309,6 +309,8 @@ ProcessOptions (
EFI_HII_VALUE *QuestionValue;
BOOLEAN Suppress;
UINT16 Maximum;
QUESTION_OPTION *Option;
UINTN Index2;
Status = EFI_SUCCESS;
@@ -359,7 +361,30 @@ ProcessOptions (
OneOfOption = ValueToOption (Question, &HiiValue);
if (OneOfOption == NULL) {
//
// Show error message
//
do {
CreateDialog (4, TRUE, 0, NULL, &Key, gEmptyString, gOptionMismatch, gPressEnter, gEmptyString);
} while (Key.UnicodeChar != CHAR_CARRIAGE_RETURN);
//
// The initial value of the orderedlist is invalid, force to be valid value
//
Link = GetFirstNode (&Question->OptionListHead);
Index2 = 0;
while (!IsNull (&Question->OptionListHead, Link) && Index2 < Question->MaxContainers) {
Option = QUESTION_OPTION_FROM_LINK (Link);
Question->BufferValue[Index2++] = Option->Value.Value.u8;
Link = GetNextNode (&Question->OptionListHead, Link);
}
Question->BufferValue[Index2] = 0;
Status = SetQuestionValue (Selection->FormSet, Selection->Form, Question, TRUE);
UpdateStatusBar (NV_UPDATE_REQUIRED, Question->QuestionFlags, TRUE);
gBS->FreePool (*OptionString);
*OptionString = NULL;
return EFI_NOT_FOUND;
}
@@ -400,8 +425,33 @@ ProcessOptions (
OneOfOption = ValueToOption (Question, QuestionValue);
if (OneOfOption == NULL) {
//
// Show error message
//
do {
CreateDialog (4, TRUE, 0, NULL, &Key, gEmptyString, gOptionMismatch, gPressEnter, gEmptyString);
} while (Key.UnicodeChar != CHAR_CARRIAGE_RETURN);
//
// Force the Question value to be valid
//
Link = GetFirstNode (&Question->OptionListHead);
while (!IsNull (&Question->OptionListHead, Link)) {
Option = QUESTION_OPTION_FROM_LINK (Link);
if ((Option->SuppressExpression == NULL) ||
!Option->SuppressExpression->Result.Value.b) {
CopyMem (QuestionValue, &Option->Value, sizeof (EFI_HII_VALUE));
SetQuestionValue (Selection->FormSet, Selection->Form, Question, TRUE);
UpdateStatusBar (NV_UPDATE_REQUIRED, Question->QuestionFlags, TRUE);
break;
}
Link = GetNextNode (&Question->OptionListHead, Link);
}
gBS->FreePool (*OptionString);
return EFI_NOT_FOUND;
*OptionString = NULL;
}
if ((OneOfOption->SuppressExpression != NULL) &&
@@ -428,6 +478,8 @@ ProcessOptions (
Suppress = FALSE;
CopyMem (QuestionValue, &OneOfOption->Value, sizeof (EFI_HII_VALUE));
SetQuestionValue (Selection->FormSet, Selection->Form, Question, TRUE);
UpdateStatusBar (NV_UPDATE_REQUIRED, Question->QuestionFlags, TRUE);
gST->ConOut->SetAttribute (gST->ConOut, FIELD_TEXT | FIELD_BACKGROUND);
break;
}
@@ -470,6 +522,7 @@ ProcessOptions (
//
QuestionValue->Value.b = (BOOLEAN) (QuestionValue->Value.b ? FALSE : TRUE);
gBS->FreePool (*OptionString);
*OptionString = NULL;
return Status;
}

View File

@@ -58,6 +58,7 @@ CHAR16 *gFunctionNineString;
CHAR16 *gFunctionTenString;
CHAR16 *gEnterString;
CHAR16 *gEnterCommitString;
CHAR16 *gEnterEscapeString;
CHAR16 *gEscapeString;
CHAR16 *gSaveFailed;
CHAR16 *gMoveHighlight;
@@ -81,6 +82,7 @@ CHAR16 *gPlusString;
CHAR16 *gMinusString;
CHAR16 *gAdjustNumber;
CHAR16 *gSaveChanges;
CHAR16 *gOptionMismatch;
CHAR16 gPromptBlockWidth;
CHAR16 gOptionBlockWidth;
@@ -1050,6 +1052,7 @@ GetQuestionValue (
CHAR16 *Progress;
CHAR16 *Result;
CHAR16 *Value;
CHAR16 *StringPtr;
UINTN Length;
BOOLEAN IsBufferStorage;
BOOLEAN IsString;
@@ -1245,6 +1248,16 @@ GetQuestionValue (
// Skip '=', point to value
//
Value = Value + 1;
//
// Suppress <AltResp> if any
//
StringPtr = Value;
while (*StringPtr != L'\0' && *StringPtr != L'&') {
StringPtr++;
}
*StringPtr = L'\0';
if (!IsBufferStorage && IsString) {
//
// Convert Config String to Unicode String, e.g "0041004200430044" => "ABCD"
@@ -1895,6 +1908,16 @@ ExtractFormDefault (
Question = FORM_BROWSER_STATEMENT_FROM_LINK (Link);
Link = GetNextNode (&Form->StatementListHead, Link);
//
// If Question is suppressed, don't reset it to default
//
if (Question->SuppressExpression != NULL) {
Status = EvaluateExpression (FormSet, Form, Question->SuppressExpression);
if (!EFI_ERROR (Status) && Question->SuppressExpression->Result.Value.b) {
continue;
}
}
//
// Reset Question to its default value
//
@@ -2146,7 +2169,7 @@ GetIfrBinaryData (
Package = ((UINT8 *) HiiPackageList) + Offset;
CopyMem (&PackageHeader, Package, sizeof (EFI_HII_PACKAGE_HEADER));
if (PackageHeader.Type == EFI_HII_PACKAGE_FORM) {
if (PackageHeader.Type == EFI_HII_PACKAGE_FORMS) {
//
// Search FormSet in this Form Package
//

View File

@@ -469,6 +469,7 @@ extern CHAR16 *gFunctionNineString;
extern CHAR16 *gFunctionTenString;
extern CHAR16 *gEnterString;
extern CHAR16 *gEnterCommitString;
extern CHAR16 *gEnterEscapeString;
extern CHAR16 *gEscapeString;
extern CHAR16 *gSaveFailed;
extern CHAR16 *gMoveHighlight;
@@ -492,6 +493,7 @@ extern CHAR16 *gPlusString;
extern CHAR16 *gMinusString;
extern CHAR16 *gAdjustNumber;
extern CHAR16 *gSaveChanges;
extern CHAR16 *gOptionMismatch;
extern CHAR16 gPromptBlockWidth;
extern CHAR16 gOptionBlockWidth;

View File

@@ -295,66 +295,122 @@ UiFreeRefreshList (
Refresh screen.
**/
VOID
EFI_STATUS
RefreshForm (
VOID
)
{
CHAR16 *OptionString;
MENU_REFRESH_ENTRY *MenuRefreshEntry;
UINTN Index;
UINTN Loop;
EFI_STATUS Status;
UI_MENU_SELECTION *Selection;
FORM_BROWSER_STATEMENT *Question;
OptionString = NULL;
CHAR16 *OptionString;
MENU_REFRESH_ENTRY *MenuRefreshEntry;
UINTN Index;
EFI_STATUS Status;
UI_MENU_SELECTION *Selection;
FORM_BROWSER_STATEMENT *Question;
EFI_HII_CONFIG_ACCESS_PROTOCOL *ConfigAccess;
EFI_HII_VALUE *HiiValue;
EFI_BROWSER_ACTION_REQUEST ActionRequest;
if (gMenuRefreshHead != NULL) {
MenuRefreshEntry = gMenuRefreshHead;
//
// Reset FormPackage update flag
//
mHiiPackageListUpdated = FALSE;
do {
gST->ConOut->SetAttribute (gST->ConOut, MenuRefreshEntry->CurrentAttribute);
Selection = MenuRefreshEntry->Selection;
Question = MenuRefreshEntry->MenuOption->ThisTag;
//
// Don't update Question being edited
//
if (Question != MenuRefreshEntry->Selection->Statement) {
Status = GetQuestionValue (Selection->FormSet, Selection->Form, Question, FALSE);
if (EFI_ERROR (Status)) {
return Status;
}
Status = GetQuestionValue (Selection->FormSet, Selection->Form, Question, FALSE);
if (EFI_ERROR (Status)) {
return;
OptionString = NULL;
ProcessOptions (Selection, MenuRefreshEntry->MenuOption, FALSE, &OptionString);
if (OptionString != NULL) {
//
// If leading spaces on OptionString - remove the spaces
//
for (Index = 0; OptionString[Index] == L' '; Index++)
;
PrintStringAt (MenuRefreshEntry->CurrentColumn, MenuRefreshEntry->CurrentRow, &OptionString[Index]);
gBS->FreePool (OptionString);
}
//
// Question value may be changed, need invoke its Callback()
//
ConfigAccess = Selection->FormSet->ConfigAccess;
if ((Question->QuestionFlags & EFI_IFR_FLAG_CALLBACK) && (ConfigAccess != NULL)) {
ActionRequest = EFI_BROWSER_ACTION_REQUEST_NONE;
HiiValue = &Question->HiiValue;
if (HiiValue->Type == EFI_IFR_TYPE_STRING) {
//
// Create String in HII database for Configuration Driver to retrieve
//
HiiValue->Value.string = NewString ((CHAR16 *) Question->BufferValue, Selection->FormSet->HiiHandle);
}
ProcessOptions (Selection, MenuRefreshEntry->MenuOption, FALSE, &OptionString);
Status = ConfigAccess->Callback (
ConfigAccess,
EFI_BROWSER_ACTION_CHANGING,
Question->QuestionId,
HiiValue->Type,
&HiiValue->Value,
&ActionRequest
);
if (OptionString != NULL) {
if (HiiValue->Type == EFI_IFR_TYPE_STRING) {
//
// If leading spaces on OptionString - remove the spaces
// Clean the String in HII Database
//
for (Index = 0; OptionString[Index] == L' '; Index++)
;
DeleteString (HiiValue->Value.string, Selection->FormSet->HiiHandle);
}
for (Loop = 0; OptionString[Index] != CHAR_NULL; Index++) {
OptionString[Loop] = OptionString[Index];
Loop++;
if (!EFI_ERROR (Status)) {
switch (ActionRequest) {
case EFI_BROWSER_ACTION_REQUEST_RESET:
gResetRequired = TRUE;
break;
case EFI_BROWSER_ACTION_REQUEST_SUBMIT:
SubmitForm (Selection->FormSet, Selection->Form);
break;
case EFI_BROWSER_ACTION_REQUEST_EXIT:
Selection->Action = UI_ACTION_EXIT;
gNvUpdateRequired = FALSE;
break;
default:
break;
}
OptionString[Loop] = CHAR_NULL;
PrintStringAt (MenuRefreshEntry->CurrentColumn, MenuRefreshEntry->CurrentRow, OptionString);
gBS->FreePool (OptionString);
}
}
MenuRefreshEntry = MenuRefreshEntry->Next;
} while (MenuRefreshEntry != NULL);
if (mHiiPackageListUpdated) {
//
// Package list is updated, force to reparse IFR binary of target Formset
//
mHiiPackageListUpdated = FALSE;
Selection->Action = UI_ACTION_REFRESH_FORMSET;
return EFI_SUCCESS;
}
}
return EFI_TIMEOUT;
}
@@ -446,7 +502,7 @@ UiWaitForSingleEvent (
if (!EFI_ERROR (Status) && Index == 1) {
Status = EFI_TIMEOUT;
if (RefreshInterval != 0) {
RefreshForm ();
Status = RefreshForm ();
}
}
@@ -1595,7 +1651,16 @@ UiDisplayMenu (
Row = OriginalRow;
gST->ConOut->SetAttribute (gST->ConOut, FIELD_TEXT | FIELD_BACKGROUND);
ProcessOptions (Selection, MenuOption, FALSE, &OptionString);
Status = ProcessOptions (Selection, MenuOption, FALSE, &OptionString);
if (EFI_ERROR (Status)) {
//
// Repaint to clear possible error prompt pop-up
//
Repaint = TRUE;
NewLine = TRUE;
ControlFlag = CfRepaint;
break;
}
if (OptionString != NULL) {
if (Statement->Operand == EFI_IFR_DATE_OP || Statement->Operand == EFI_IFR_TIME_OP) {
@@ -2023,12 +2088,8 @@ UiDisplayMenu (
}
}
if (((NewPos->ForwardLink != &Menu) && (ScreenOperation == UiDown)) ||
((NewPos->BackLink != &Menu) && (ScreenOperation == UiUp)) ||
(ScreenOperation == UiNoOperation)
) {
UpdateKeyHelp (MenuOption, FALSE);
}
UpdateKeyHelp (MenuOption, FALSE);
//
// Clear reverse attribute
//
@@ -2095,17 +2156,22 @@ UiDisplayMenu (
Status = UiWaitForSingleEvent (gST->ConIn->WaitForKey, 0, MinRefreshInterval);
} while (Status == EFI_TIMEOUT);
if (Status == EFI_TIMEOUT) {
Key.UnicodeChar = CHAR_CARRIAGE_RETURN;
} else {
Status = gST->ConIn->ReadKeyStroke (gST->ConIn, &Key);
if (Selection->Action == UI_ACTION_REFRESH_FORMSET) {
//
// if we encounter error, continue to read another key in.
// IFR is updated in Callback of refresh opcode, re-parse it
//
if (EFI_ERROR (Status)) {
ControlFlag = CfReadKey;
continue;
}
ControlFlag = CfUiReset;
Selection->Statement = NULL;
break;
}
Status = gST->ConIn->ReadKeyStroke (gST->ConIn, &Key);
//
// if we encounter error, continue to read another key in.
//
if (EFI_ERROR (Status)) {
ControlFlag = CfReadKey;
break;
}
if (IsListEmpty (&Menu) && Key.UnicodeChar != CHAR_NULL) {
@@ -2138,6 +2204,13 @@ UiDisplayMenu (
gDirection = SCAN_LEFT;
}
Status = ProcessOptions (Selection, MenuOption, TRUE, &OptionString);
if (EFI_ERROR (Status)) {
//
// Repaint to clear possible error prompt pop-up
//
Repaint = TRUE;
NewLine = TRUE;
}
if (OptionString != NULL) {
FreePool (OptionString);
}
@@ -2378,15 +2451,14 @@ UiDisplayMenu (
if (EFI_ERROR (Status)) {
Repaint = TRUE;
NewLine = TRUE;
break;
}
UpdateKeyHelp (MenuOption, FALSE);
} else {
Selection->Action = UI_ACTION_REFRESH_FORM;
}
if (OptionString != NULL) {
PrintStringAt (LocalScreen.LeftColumn + gPromptBlockWidth + 1, MenuOption->Row, OptionString);
gBS->FreePool (OptionString);
}
Selection->Action = UI_ACTION_REFRESH_FORM;
if (OptionString != NULL) {
FreePool (OptionString);
}
break;
}
break;

View File

@@ -1,7 +1,7 @@
/** @file
Private structure, MACRO and function definitions for User Interface related functionalities.
Copyright (c) 2004 - 2007, Intel Corporation
Copyright (c) 2004 - 2008, Intel Corporation
All rights reserved. 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
@@ -169,6 +169,7 @@ typedef struct {
extern LIST_ENTRY gMenuList;
extern MENU_REFRESH_ENTRY *gMenuRefreshHead;
extern UI_MENU_SELECTION *gCurrentSelection;
extern BOOLEAN mHiiPackageListUpdated;
//
// Global Functions