diff options
author | qwang12 <qwang12@6f19259b-4bc3-4df7-8a09-765794883524> | 2008-09-04 10:15:50 +0000 |
---|---|---|
committer | qwang12 <qwang12@6f19259b-4bc3-4df7-8a09-765794883524> | 2008-09-04 10:15:50 +0000 |
commit | 8ea58c070785281087061b0f706b03cf873949c7 (patch) | |
tree | 0a2a63d7fbf05b94ebaed4e9760c7a1c5fbe6271 /EdkCompatibilityPkg/Compatibility | |
parent | e00e1d46940a267d6fbe92be4ed2e547b4e946dc (diff) | |
download | edk2-platforms-8ea58c070785281087061b0f706b03cf873949c7.tar.xz |
1) Add a stringent check to make sure the package list for UpdateForm call must have IFR packages.
2) Fix a bug for Numeric Opcode creation.
3) Add AssignQuestionId to assign QuestionId to be a non-zero value always.
4) Add in Check in UefiRegisterPackageList to same package list to be registered for more than once. (Framework BDS has this behavior).
5) Fix a bug in HiiNewString
git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@5822 6f19259b-4bc3-4df7-8a09-765794883524
Diffstat (limited to 'EdkCompatibilityPkg/Compatibility')
6 files changed, 81 insertions, 56 deletions
diff --git a/EdkCompatibilityPkg/Compatibility/FrameworkHiiToUefiHiiThunk/Forms.c b/EdkCompatibilityPkg/Compatibility/FrameworkHiiToUefiHiiThunk/Forms.c index 3679f6dfb4..02beec331f 100644 --- a/EdkCompatibilityPkg/Compatibility/FrameworkHiiToUefiHiiThunk/Forms.c +++ b/EdkCompatibilityPkg/Compatibility/FrameworkHiiToUefiHiiThunk/Forms.c @@ -519,13 +519,10 @@ HiiUpdateForm ( }
}
- if ((ThunkContext->IfrPackageCount == 0) && (ThunkContext->StringPackageCount != 0)) {
- UefiHiiHandle = TagGuidToUefiHiiHandle (Private, &ThunkContext->TagGuid);
-
- if (UefiHiiHandle == NULL) {
- Status = EFI_INVALID_PARAMETER;
- goto Done;
- }
+ if (ThunkContext->IfrPackageCount == 0) {
+ ASSERT (FALSE);
+ Status = EFI_INVALID_PARAMETER;
+ goto Done;
} else {
UefiHiiHandle = ThunkContext->UefiHiiHandle;
}
diff --git a/EdkCompatibilityPkg/Compatibility/FrameworkHiiToUefiHiiThunk/OpcodeCreation.c b/EdkCompatibilityPkg/Compatibility/FrameworkHiiToUefiHiiThunk/OpcodeCreation.c index 6359c8e680..0fbe943165 100644 --- a/EdkCompatibilityPkg/Compatibility/FrameworkHiiToUefiHiiThunk/OpcodeCreation.c +++ b/EdkCompatibilityPkg/Compatibility/FrameworkHiiToUefiHiiThunk/OpcodeCreation.c @@ -44,6 +44,21 @@ AppendToUpdateBuffer ( return EFI_SUCCESS;
}
+EFI_QUESTION_ID
+AssignQuestionId (
+ IN UINT16 FwQuestionId
+ )
+{
+ if (FwQuestionId == 0) {
+ //
+ // In UEFI IFR, the Question ID can't be zero. Zero means no storage.
+ // So use 0xABBA as a Question ID.
+ //
+ return 0xABBA;
+ } else {
+ return FwQuestionId;
+ }
+}
EFI_STATUS
@@ -368,7 +383,7 @@ F2UCreateOneOfOpCode ( if (UOpcode.Question.QuestionId == 0) {
Status = FwQuestionIdToUefiQuestionId (ThunkContext, VarStoreId, FwOpcode->QuestionId, &UOpcode.Question.QuestionId);
if (EFI_ERROR (Status)) {
- UOpcode.Question.QuestionId = FwOneOfOp->Key;
+ UOpcode.Question.QuestionId = AssignQuestionId (FwOneOfOp->Key);
}
OneOfOptionMap = AllocateZeroPool (sizeof (ONE_OF_OPTION_MAP));
@@ -382,6 +397,7 @@ F2UCreateOneOfOpCode ( break;
case 2:
OneOfOptionMap->ValueType = EFI_IFR_TYPE_NUM_SIZE_16;
+ break;
default:
ASSERT (FALSE);
break;
@@ -416,7 +432,7 @@ F2UCreateOneOfOpCode ( //
Status = FwQuestionIdToUefiQuestionId (ThunkContext, VarStoreId, FwOpcode->QuestionId, &UOpcode.Question.QuestionId);
if (EFI_ERROR (Status)) {
- UOpcode.Question.QuestionId = FwOpcode->QuestionId;
+ UOpcode.Question.QuestionId = AssignQuestionId (FwOpcode->QuestionId);
}
}
@@ -519,7 +535,7 @@ F2UCreateOrderedListOpCode ( if (UOpcode.Question.QuestionId == 0) {
Status = FwQuestionIdToUefiQuestionId (ThunkContext, VarStoreId, FwOpcode->QuestionId, &UOpcode.Question.QuestionId);
if (EFI_ERROR (Status)) {
- UOpcode.Question.QuestionId = FwOneOfOp->Key;
+ UOpcode.Question.QuestionId = AssignQuestionId (FwOneOfOp->Key);
}
}
@@ -535,7 +551,7 @@ F2UCreateOrderedListOpCode ( if (UOpcode.Question.QuestionId == 0) {
Status = FwQuestionIdToUefiQuestionId (ThunkContext, VarStoreId, FwOpcode->QuestionId, &UOpcode.Question.QuestionId);
if (EFI_ERROR (Status)) {
- UOpcode.Question.QuestionId = FwOpcode->QuestionId;
+ UOpcode.Question.QuestionId = AssignQuestionId (FwOpcode->QuestionId);
}
}
@@ -626,7 +642,7 @@ F2UCreateCheckBoxOpCode ( //
// Add a new opcode and it will not trigger call back. So we just reuse the FW QuestionId.
//
- UOpcode.Question.QuestionId = FwOpcode->QuestionId;
+ UOpcode.Question.QuestionId = AssignQuestionId (FwOpcode->QuestionId);
}
} else {
UOpcode.Question.QuestionId = FwOpcode->Key;
@@ -735,7 +751,7 @@ F2UCreateNumericOpCode ( //
// Add a new opcode and it will not trigger call back. So we just reuse the FW QuestionId.
//
- UOpcode.Question.QuestionId = FwOpcode->QuestionId;
+ UOpcode.Question.QuestionId = AssignQuestionId (FwOpcode->QuestionId);
}
} else {
UOpcode.Question.QuestionId = FwOpcode->Key;
@@ -747,14 +763,11 @@ F2UCreateNumericOpCode ( // We need to create a nested default value for the UEFI Numeric Opcode.
// So turn on the scope.
//
- if (FwOpcode->Default != 0) {
- UOpcode.Header.Scope = 1;
- }
+ UOpcode.Header.Scope = 1;
UOpcode.Question.Header.Prompt = FwOpcode->Prompt;
UOpcode.Question.Header.Help = FwOpcode->Help;
- UOpcode.Question.QuestionId = FwOpcode->Key;
UOpcode.Question.VarStoreId = VarStoreId;
UOpcode.Question.VarStoreInfo.VarOffset = FwOpcode->QuestionId;
@@ -770,12 +783,12 @@ F2UCreateNumericOpCode ( switch (FwOpcode->Width) {
case 1:
{
- UOpcode.Flags = EFI_IFR_NUMERIC_SIZE_2 | EFI_IFR_DISPLAY_UINT_DEC;
+ UOpcode.Flags = EFI_IFR_NUMERIC_SIZE_1 | EFI_IFR_DISPLAY_UINT_DEC;
break;
}
case 2:
{
- UOpcode.Flags = EFI_IFR_NUMERIC_SIZE_1 | EFI_IFR_DISPLAY_UINT_DEC;
+ UOpcode.Flags = EFI_IFR_NUMERIC_SIZE_2 | EFI_IFR_DISPLAY_UINT_DEC;
break;
}
default:
@@ -793,34 +806,32 @@ F2UCreateNumericOpCode ( //
// We need to create a default value.
//
- if (FwOpcode->Default != 0) {
- ZeroMem (&UOpcodeDefault, sizeof (UOpcodeDefault));
- UOpcodeDefault.Header.Length = sizeof (UOpcodeDefault);
- UOpcodeDefault.Header.OpCode = EFI_IFR_DEFAULT_OP;
+ ZeroMem (&UOpcodeDefault, sizeof (UOpcodeDefault));
+ UOpcodeDefault.Header.Length = sizeof (UOpcodeDefault);
+ UOpcodeDefault.Header.OpCode = EFI_IFR_DEFAULT_OP;
- UOpcodeDefault.DefaultId = 0;
+ UOpcodeDefault.DefaultId = 0;
- switch (FwOpcode->Width) {
- case 1:
- {
- UOpcodeDefault.Type = EFI_IFR_TYPE_NUM_SIZE_8;
- break;
- }
- case 2:
- {
- UOpcodeDefault.Type = EFI_IFR_TYPE_NUM_SIZE_16;
- break;
- }
+ switch (FwOpcode->Width) {
+ case 1:
+ {
+ UOpcodeDefault.Type = EFI_IFR_TYPE_NUM_SIZE_8;
+ break;
+ }
+ case 2:
+ {
+ UOpcodeDefault.Type = EFI_IFR_TYPE_NUM_SIZE_16;
+ break;
}
+ }
- CopyMem (&UOpcodeDefault.Value.u8, &FwOpcode->Default, FwOpcode->Width);
+ CopyMem (&UOpcodeDefault.Value.u8, &FwOpcode->Default, FwOpcode->Width);
- Status = AppendToUpdateBuffer ((UINT8 *) &UOpcodeDefault, sizeof(UOpcodeDefault), UefiData);
- if (EFI_ERROR (Status)) {
- return Status;
- }
- Status = UCreateEndOfOpcode (UefiData);
+ Status = AppendToUpdateBuffer ((UINT8 *) &UOpcodeDefault, sizeof(UOpcodeDefault), UefiData);
+ if (EFI_ERROR (Status)) {
+ return Status;
}
+ Status = UCreateEndOfOpcode (UefiData);
return Status;
}
@@ -1037,6 +1048,11 @@ FwUpdateDataToUefiUpdateData ( DataCount = 1;
break;
+ case FRAMEWORK_EFI_IFR_NUMERIC_OP:
+ Status = F2UCreateNumericOpCode (ThunkContext, VarStoreId, (FRAMEWORK_EFI_IFR_NUMERIC *) FwOpCode, UefiOpCode);
+ DataCount = 1;
+ break;
+
default:
ASSERT (FALSE);
return EFI_UNSUPPORTED;
diff --git a/EdkCompatibilityPkg/Compatibility/FrameworkHiiToUefiHiiThunk/Package.c b/EdkCompatibilityPkg/Compatibility/FrameworkHiiToUefiHiiThunk/Package.c index 6e2c9dfd34..a5bf876e25 100644 --- a/EdkCompatibilityPkg/Compatibility/FrameworkHiiToUefiHiiThunk/Package.c +++ b/EdkCompatibilityPkg/Compatibility/FrameworkHiiToUefiHiiThunk/Package.c @@ -248,6 +248,7 @@ FindStringPackAndUpdatePackListWithOnlyIfrPack ( //
EFI_STATUS
UefiRegisterPackageList(
+ IN EFI_HII_PROTOCOL *This,
IN HII_THUNK_PRIVATE_DATA *Private,
IN EFI_HII_PACKAGES *Packages,
OUT FRAMEWORK_EFI_HII_HANDLE *Handle
@@ -273,12 +274,6 @@ UefiRegisterPackageList( return EFI_UNSUPPORTED;
}
- ThunkContext = CreateThunkContext (Private, StringPackageCount, IfrPackageCount);
- if (ThunkContext == NULL) {
- return EFI_OUT_OF_RESOURCES;
- }
- ThunkContext->ByFrameworkHiiNewPack = TRUE;
-
if (Packages->GuidId == NULL) {
//
// UEFI HII Database require Package List GUID must be unique.
@@ -291,9 +286,24 @@ UefiRegisterPackageList( ASSERT (StringPackageCount >=1 && IfrPackageCount == 1);
GenerateRandomGuid (&GuidId);
} else {
+ ThunkContext = TagGuidToIfrPackThunkContext (Private, Packages->GuidId);
+
+ if (IfrPackageCount > 0 &&
+ StringPackageCount > 0 &&
+ (ThunkContext!= NULL)) {
+ DEBUG((EFI_D_WARN, "Framework code registers HII package list with the same GUID more than once.\n"));
+ DEBUG((EFI_D_WARN, "This package list should be already registered. Just return successfully.\n"));
+ HiiRemovePack (This, ThunkContext->FwHiiHandle);
+ }
CopyGuid (&GuidId, Packages->GuidId);
}
+ ThunkContext = CreateThunkContext (Private, StringPackageCount, IfrPackageCount);
+ if (ThunkContext == NULL) {
+ return EFI_OUT_OF_RESOURCES;
+ }
+ ThunkContext->ByFrameworkHiiNewPack = TRUE;
+
//
// Record the Package List GUID, it is used as a name for the package list by Framework HII.
//
@@ -426,6 +436,7 @@ Returns: Private = HII_THUNK_PRIVATE_DATA_FROM_THIS(This);
Status = UefiRegisterPackageList (
+ This,
Private,
Packages,
Handle
@@ -479,7 +490,6 @@ Returns: UninstallDefaultConfigAccessProtocol (ThunkContext);
}
- RemoveEntryList (&ThunkContext->Link);
DestroyThunkContext (ThunkContext);
}else {
Status = EFI_NOT_FOUND;
diff --git a/EdkCompatibilityPkg/Compatibility/FrameworkHiiToUefiHiiThunk/Strings.c b/EdkCompatibilityPkg/Compatibility/FrameworkHiiToUefiHiiThunk/Strings.c index 9e2df6fc62..14e27dda18 100644 --- a/EdkCompatibilityPkg/Compatibility/FrameworkHiiToUefiHiiThunk/Strings.c +++ b/EdkCompatibilityPkg/Compatibility/FrameworkHiiToUefiHiiThunk/Strings.c @@ -129,6 +129,7 @@ Returns: EFI_STRING_ID StringId;
EFI_STRING_ID LastStringId;
CHAR8 AsciiLanguage[ISO_639_2_ENTRY_SIZE + 1];
+ CHAR16 LanguageCopy[ISO_639_2_ENTRY_SIZE + 1];
BOOLEAN Found;
CHAR8 *Rfc3066AsciiLanguage;
@@ -144,8 +145,9 @@ Returns: if (Language != NULL) {
ZeroMem (AsciiLanguage, sizeof (AsciiLanguage));;
-
- UnicodeStrToAsciiStr (Language, AsciiLanguage);
+ ZeroMem (LanguageCopy, sizeof (LanguageCopy));
+ CopyMem (LanguageCopy, Language, ISO_639_2_ENTRY_SIZE * sizeof (CHAR16));
+ UnicodeStrToAsciiStr (LanguageCopy, AsciiLanguage);
Rfc3066AsciiLanguage = ConvertIso639ToRfc3066 (AsciiLanguage);
ASSERT (Rfc3066AsciiLanguage != NULL);
}
diff --git a/EdkCompatibilityPkg/Compatibility/FrameworkHiiToUefiHiiThunk/Utility.c b/EdkCompatibilityPkg/Compatibility/FrameworkHiiToUefiHiiThunk/Utility.c index 638d835286..67e0877dd9 100644 --- a/EdkCompatibilityPkg/Compatibility/FrameworkHiiToUefiHiiThunk/Utility.c +++ b/EdkCompatibilityPkg/Compatibility/FrameworkHiiToUefiHiiThunk/Utility.c @@ -90,8 +90,8 @@ UefiHiiHandleToThunkContext ( return NULL;
}
-EFI_HII_HANDLE *
-TagGuidToUefiHiiHandle (
+HII_THUNK_CONTEXT *
+TagGuidToIfrPackThunkContext (
IN CONST HII_THUNK_PRIVATE_DATA *Private,
IN CONST EFI_GUID *Guid
)
@@ -104,8 +104,8 @@ TagGuidToUefiHiiHandle ( while (!IsNull (&Private->ThunkContextListHead, Link)) {
ThunkContext = HII_THUNK_CONTEXT_FROM_LINK (Link);
- if (CompareMem (Guid, &ThunkContext->TagGuid, sizeof (EFI_GUID) == 0) && (ThunkContext->IfrPackageCount != 0)) {
- return ThunkContext->UefiHiiHandle;
+ if (CompareGuid (Guid, &ThunkContext->TagGuid) && (ThunkContext->IfrPackageCount != 0)) {
+ return ThunkContext;
}
Link = GetNextNode (&Private->ThunkContextListHead, Link);
diff --git a/EdkCompatibilityPkg/Compatibility/FrameworkHiiToUefiHiiThunk/Utility.h b/EdkCompatibilityPkg/Compatibility/FrameworkHiiToUefiHiiThunk/Utility.h index 0a45144cf8..5d93c70627 100644 --- a/EdkCompatibilityPkg/Compatibility/FrameworkHiiToUefiHiiThunk/Utility.h +++ b/EdkCompatibilityPkg/Compatibility/FrameworkHiiToUefiHiiThunk/Utility.h @@ -45,8 +45,8 @@ UefiHiiHandleToThunkContext ( IN EFI_HII_HANDLE UefiHiiHandle
);
-EFI_HII_HANDLE *
-TagGuidToUefiHiiHandle (
+HII_THUNK_CONTEXT *
+TagGuidToIfrPackThunkContext (
IN CONST HII_THUNK_PRIVATE_DATA *Private,
IN CONST EFI_GUID *Guid
);
|