mirror of https://github.com/acidanthera/audk.git
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
This commit is contained in:
parent
e00e1d4694
commit
8ea58c0707
|
@ -519,13 +519,10 @@ HiiUpdateForm (
|
|||
}
|
||||
}
|
||||
|
||||
if ((ThunkContext->IfrPackageCount == 0) && (ThunkContext->StringPackageCount != 0)) {
|
||||
UefiHiiHandle = TagGuidToUefiHiiHandle (Private, &ThunkContext->TagGuid);
|
||||
|
||||
if (UefiHiiHandle == NULL) {
|
||||
if (ThunkContext->IfrPackageCount == 0) {
|
||||
ASSERT (FALSE);
|
||||
Status = EFI_INVALID_PARAMETER;
|
||||
goto Done;
|
||||
}
|
||||
} else {
|
||||
UefiHiiHandle = ThunkContext->UefiHiiHandle;
|
||||
}
|
||||
|
|
|
@ -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.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,7 +806,6 @@ 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;
|
||||
|
@ -820,7 +832,6 @@ F2UCreateNumericOpCode (
|
|||
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;
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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
|
||||
);
|
||||
|
|
Loading…
Reference in New Issue